djtodoro updated this revision to Diff 317873.
djtodoro edited the summary of this revision.

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D93939/new/

https://reviews.llvm.org/D93939

Files:
  lldb/source/Plugins/Process/elf-core/ProcessElfCore.cpp
  lldb/test/API/functionalities/postmortem/elf-core/TestLinuxCore.py
  
lldb/test/API/functionalities/postmortem/elf-core/linux-x86_64-for-disassemble.core
  
lldb/test/API/functionalities/postmortem/elf-core/linux-x86_64-for-disassemble.out


Index: lldb/test/API/functionalities/postmortem/elf-core/TestLinuxCore.py
===================================================================
--- lldb/test/API/functionalities/postmortem/elf-core/TestLinuxCore.py
+++ lldb/test/API/functionalities/postmortem/elf-core/TestLinuxCore.py
@@ -155,6 +155,37 @@
         self.do_test("linux-x86_64", self._x86_64_pid, self._x86_64_regions,
                      "a.out")
 
+
+    @skipIf(triple='^mips')
+    @skipIfLLVMTargetMissing("X86")
+    @skipIfWindows
+    @skipIfReproducer
+    def test_frame_disassemble(self):
+        """Test that we are able to disassemble all the frames"""
+        disasmtarget = 
self.dbg.CreateTarget("linux-x86_64-for-disassemble.out")
+        disasmprocess = 
disasmtarget.LoadCore("linux-x86_64-for-disassemble.core")
+        self.assertTrue(disasmprocess, PROCESS_IS_VALID)
+
+        disasmthread = disasmprocess.GetSelectedThread()
+        framenum = disasmthread.GetNumFrames()
+        for i in range(framenum):
+            frame = disasmthread.GetFrameAtIndex(i)
+            disassembly = frame.Disassemble()
+            self.assertNotEqual(disassembly, "")
+            self.assertNotIn("error", disassembly)
+            # Make sure we don't have some dummy disassembly.
+            # Each function should start with:
+            #   pushq %rbp
+            #   ...
+            # Sometimes it just prints some dummy code as:
+            #   addb %al, (%rax)
+            #   addb %al, (%rax)
+            #   ...
+            framesetup = disassembly.splitlines()[1]
+            self.assertNotIn("addb", framesetup)
+
+        self.dbg.DeleteTarget(disasmtarget)
+
     @skipIf(triple='^mips')
     @skipIfLLVMTargetMissing("X86")
     def test_FPR_SSE(self):
Index: lldb/source/Plugins/Process/elf-core/ProcessElfCore.cpp
===================================================================
--- lldb/source/Plugins/Process/elf-core/ProcessElfCore.cpp
+++ lldb/source/Plugins/Process/elf-core/ProcessElfCore.cpp
@@ -353,7 +353,6 @@
   const lldb::addr_t file_end = address_range->data.GetRangeEnd();
   size_t bytes_to_read = size; // Number of bytes to read from the core file
   size_t bytes_copied = 0;   // Number of bytes actually read from the core 
file
-  size_t zero_fill_size = 0; // Padding
   lldb::addr_t bytes_left =
       0; // Number of bytes available in the core file from the given address
 
@@ -369,22 +368,15 @@
 
   // Figure out how many bytes we need to zero-fill if we are reading more
   // bytes than available in the on-disk segment
-  if (bytes_to_read > bytes_left) {
-    zero_fill_size = bytes_to_read - bytes_left;
+  if (bytes_to_read > bytes_left)
     bytes_to_read = bytes_left;
-  }
 
   // If there is data available on the core file read it
   if (bytes_to_read)
     bytes_copied =
         core_objfile->CopyData(offset + file_start, bytes_to_read, buf);
 
-  assert(zero_fill_size <= size);
-  // Pad remaining bytes
-  if (zero_fill_size)
-    memset(((char *)buf) + bytes_copied, 0, zero_fill_size);
-
-  return bytes_copied + zero_fill_size;
+  return bytes_copied;
 }
 
 void ProcessElfCore::Clear() {


Index: lldb/test/API/functionalities/postmortem/elf-core/TestLinuxCore.py
===================================================================
--- lldb/test/API/functionalities/postmortem/elf-core/TestLinuxCore.py
+++ lldb/test/API/functionalities/postmortem/elf-core/TestLinuxCore.py
@@ -155,6 +155,37 @@
         self.do_test("linux-x86_64", self._x86_64_pid, self._x86_64_regions,
                      "a.out")
 
+
+    @skipIf(triple='^mips')
+    @skipIfLLVMTargetMissing("X86")
+    @skipIfWindows
+    @skipIfReproducer
+    def test_frame_disassemble(self):
+        """Test that we are able to disassemble all the frames"""
+        disasmtarget = self.dbg.CreateTarget("linux-x86_64-for-disassemble.out")
+        disasmprocess = disasmtarget.LoadCore("linux-x86_64-for-disassemble.core")
+        self.assertTrue(disasmprocess, PROCESS_IS_VALID)
+
+        disasmthread = disasmprocess.GetSelectedThread()
+        framenum = disasmthread.GetNumFrames()
+        for i in range(framenum):
+            frame = disasmthread.GetFrameAtIndex(i)
+            disassembly = frame.Disassemble()
+            self.assertNotEqual(disassembly, "")
+            self.assertNotIn("error", disassembly)
+            # Make sure we don't have some dummy disassembly.
+            # Each function should start with:
+            #   pushq %rbp
+            #   ...
+            # Sometimes it just prints some dummy code as:
+            #   addb %al, (%rax)
+            #   addb %al, (%rax)
+            #   ...
+            framesetup = disassembly.splitlines()[1]
+            self.assertNotIn("addb", framesetup)
+
+        self.dbg.DeleteTarget(disasmtarget)
+
     @skipIf(triple='^mips')
     @skipIfLLVMTargetMissing("X86")
     def test_FPR_SSE(self):
Index: lldb/source/Plugins/Process/elf-core/ProcessElfCore.cpp
===================================================================
--- lldb/source/Plugins/Process/elf-core/ProcessElfCore.cpp
+++ lldb/source/Plugins/Process/elf-core/ProcessElfCore.cpp
@@ -353,7 +353,6 @@
   const lldb::addr_t file_end = address_range->data.GetRangeEnd();
   size_t bytes_to_read = size; // Number of bytes to read from the core file
   size_t bytes_copied = 0;   // Number of bytes actually read from the core file
-  size_t zero_fill_size = 0; // Padding
   lldb::addr_t bytes_left =
       0; // Number of bytes available in the core file from the given address
 
@@ -369,22 +368,15 @@
 
   // Figure out how many bytes we need to zero-fill if we are reading more
   // bytes than available in the on-disk segment
-  if (bytes_to_read > bytes_left) {
-    zero_fill_size = bytes_to_read - bytes_left;
+  if (bytes_to_read > bytes_left)
     bytes_to_read = bytes_left;
-  }
 
   // If there is data available on the core file read it
   if (bytes_to_read)
     bytes_copied =
         core_objfile->CopyData(offset + file_start, bytes_to_read, buf);
 
-  assert(zero_fill_size <= size);
-  // Pad remaining bytes
-  if (zero_fill_size)
-    memset(((char *)buf) + bytes_copied, 0, zero_fill_size);
-
-  return bytes_copied + zero_fill_size;
+  return bytes_copied;
 }
 
 void ProcessElfCore::Clear() {
_______________________________________________
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits

Reply via email to