[Lldb-commits] [PATCH] D88387: Create "skinny corefiles" for Mach-O with process save-core / reading

2021-06-20 Thread Jason Molenda via Phabricator via lldb-commits
jasonmolenda updated this revision to Diff 353226.
jasonmolenda added a comment.

Update patch to:

1. Fix the testsuite hang I was getting in the unittests.

2. Incorporate Pavel's great review feedback from last November -- thanks 
Pavel!  Most importantly, I misunderstood the nature of Minidumps, I thought a 
Minidump described a minimal snapshot of process memory (maybe stack memory) 
that can be captured for more detailed crash analysis, so I offered it as a 
coredump style in addition to "full coredump" and "dirty memory coredump", but 
this was incorrect.  I've removed Minidump as a coredump style option.

3. Rebased to current llvm.

It all looks good, pasts the testsuite on Darwin, by-hand testing all works 
right. I'll land it soon.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D88387

Files:
  lldb/bindings/interface/SBMemoryRegionInfo.i
  lldb/docs/lldb-gdb-remote.txt
  lldb/include/lldb/API/SBMemoryRegionInfo.h
  lldb/include/lldb/Core/PluginManager.h
  lldb/include/lldb/Symbol/ObjectFile.h
  lldb/include/lldb/Target/MemoryRegionInfo.h
  lldb/include/lldb/lldb-enumerations.h
  lldb/include/lldb/lldb-private-interfaces.h
  lldb/packages/Python/lldbsuite/test/tools/lldb-server/gdbremote_testcase.py
  lldb/source/API/SBMemoryRegionInfo.cpp
  lldb/source/API/SBProcess.cpp
  lldb/source/Commands/CommandObjectMemory.cpp
  lldb/source/Commands/CommandObjectProcess.cpp
  lldb/source/Commands/Options.td
  lldb/source/Core/PluginManager.cpp
  lldb/source/Interpreter/CommandObject.cpp
  lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp
  lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.h
  lldb/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp
  lldb/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.h
  lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp
  lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.h
  lldb/source/Plugins/Process/mach-core/ProcessMachCore.cpp
  lldb/test/API/functionalities/gdb_remote_client/TestMemoryRegionDirtyPages.py
  lldb/test/API/functionalities/gdb_remote_client/gdbclientutils.py
  lldb/test/API/macosx/skinny-corefile/Makefile
  lldb/test/API/macosx/skinny-corefile/TestSkinnyCorefile.py
  lldb/test/API/macosx/skinny-corefile/main.c
  lldb/test/API/macosx/skinny-corefile/present.c
  lldb/test/API/macosx/skinny-corefile/present.h
  lldb/test/API/macosx/skinny-corefile/to-be-removed.c
  lldb/test/API/macosx/skinny-corefile/to-be-removed.h
  lldb/test/API/tools/lldb-server/TestGdbRemoteHostInfo.py
  lldb/tools/debugserver/source/DNBDefs.h
  lldb/tools/debugserver/source/MacOSX/MachVMMemory.cpp
  lldb/tools/debugserver/source/RNBRemote.cpp

Index: lldb/tools/debugserver/source/RNBRemote.cpp
===
--- lldb/tools/debugserver/source/RNBRemote.cpp
+++ lldb/tools/debugserver/source/RNBRemote.cpp
@@ -19,6 +19,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -4447,7 +4448,7 @@
 __FILE__, __LINE__, p, "Invalid address in qMemoryRegionInfo packet");
   }
 
-  DNBRegionInfo region_info = {0, 0, 0};
+  DNBRegionInfo region_info;
   DNBProcessMemoryRegionInfo(m_ctx.ProcessID(), address, ®ion_info);
   std::ostringstream ostrm;
 
@@ -4467,6 +4468,18 @@
 if (region_info.permissions & eMemoryPermissionsExecutable)
   ostrm << 'x';
 ostrm << ';';
+
+ostrm << "dirty-pages:";
+if (region_info.dirty_pages.size() > 0) {
+  bool first = true;
+  for (nub_addr_t addr : region_info.dirty_pages) {
+if (!first)
+  ostrm << ",";
+first = false;
+ostrm << "0x" << std::hex << addr;
+  }
+}
+ostrm << ";";
   }
   return SendPacket(ostrm.str());
 }
@@ -4993,6 +5006,8 @@
   strm << "default_packet_timeout:10;";
 #endif
 
+  strm << "vm-page-size:" << std::dec << vm_page_size << ";";
+
   return SendPacket(strm.str());
 }
 
Index: lldb/tools/debugserver/source/MacOSX/MachVMMemory.cpp
===
--- lldb/tools/debugserver/source/MacOSX/MachVMMemory.cpp
+++ lldb/tools/debugserver/source/MacOSX/MachVMMemory.cpp
@@ -72,6 +72,49 @@
   return count;
 }
 
+#define MAX_STACK_ALLOC_DISPOSITIONS   \
+  (16 * 1024 / sizeof(int)) // 16K of allocations
+
+std::vector get_dirty_pages(task_t task, mach_vm_address_t addr,
+mach_vm_size_t size) {
+  std::vector dirty_pages;
+
+  int pages_to_query = size / vm_page_size;
+  // Don't try to fetch too many pages' dispositions in a single call or we
+  // could blow our stack out.
+  mach_vm_size_t dispositions_size =
+  std::min(pages_to_query, (int)MAX_STACK_ALLOC_DISPOSITIONS);
+  int dispositions[dispositions_size];
+
+  mach_vm_size_t chunk_count =
+  ((pages_to_query + MAX_STACK_ALLOC_DISPOSITIONS - 1) /
+   MAX_ST

[Lldb-commits] [lldb] d4c437c - [lldb] [Process/elf-core] Fix reading NetBSD/i386 core dumps

2021-06-20 Thread Michał Górny via lldb-commits

Author: Michał Górny
Date: 2021-06-20T18:59:21+02:00
New Revision: d4c437c4289c0e0fd2684920b7e59b3f3c19b8e5

URL: 
https://github.com/llvm/llvm-project/commit/d4c437c4289c0e0fd2684920b7e59b3f3c19b8e5
DIFF: 
https://github.com/llvm/llvm-project/commit/d4c437c4289c0e0fd2684920b7e59b3f3c19b8e5.diff

LOG: [lldb] [Process/elf-core] Fix reading NetBSD/i386 core dumps

Add support for extracting basic data from NetBSD/i386 core dumps.
FPU registers are not supported at the moment.

Differential Revision: https://reviews.llvm.org/D101091

Added: 
lldb/test/Shell/Register/Core/x86-32-netbsd-addr.test
lldb/test/Shell/Register/Core/x86-32-netbsd-gp.test

Modified: 
lldb/source/Plugins/Process/elf-core/ProcessElfCore.cpp
lldb/source/Plugins/Process/elf-core/RegisterUtilities.h
lldb/source/Plugins/Process/elf-core/ThreadElfCore.cpp

Removed: 




diff  --git a/lldb/source/Plugins/Process/elf-core/ProcessElfCore.cpp 
b/lldb/source/Plugins/Process/elf-core/ProcessElfCore.cpp
index 21f1b93dc13a8..12bc7390c7294 100644
--- a/lldb/source/Plugins/Process/elf-core/ProcessElfCore.cpp
+++ b/lldb/source/Plugins/Process/elf-core/ProcessElfCore.cpp
@@ -664,6 +664,32 @@ llvm::Error 
ProcessElfCore::parseNetBSDNotes(llvm::ArrayRef notes) {
   thread_data.notes.push_back(note);
 }
   } break;
+  case llvm::Triple::x86: {
+// Assume order PT_GETREGS, PT_GETFPREGS
+if (note.info.n_type == NETBSD::I386::NT_REGS) {
+  // If this is the next thread, push the previous one first.
+  if (had_nt_regs) {
+m_thread_data.push_back(thread_data);
+thread_data = ThreadData();
+had_nt_regs = false;
+  }
+
+  thread_data.gpregset = note.data;
+  thread_data.tid = tid;
+  if (thread_data.gpregset.GetByteSize() == 0)
+return llvm::make_error(
+"Could not find general purpose registers note in core file.",
+llvm::inconvertibleErrorCode());
+  had_nt_regs = true;
+} else if (note.info.n_type == NETBSD::I386::NT_FPREGS) {
+  if (!had_nt_regs || tid != thread_data.tid)
+return llvm::make_error(
+"Error parsing NetBSD core(5) notes: Unexpected order "
+"of NOTEs PT_GETFPREG before PT_GETREG",
+llvm::inconvertibleErrorCode());
+  thread_data.notes.push_back(note);
+}
+  } break;
   case llvm::Triple::x86_64: {
 // Assume order PT_GETREGS, PT_GETFPREGS
 if (note.info.n_type == NETBSD::AMD64::NT_REGS) {

diff  --git a/lldb/source/Plugins/Process/elf-core/RegisterUtilities.h 
b/lldb/source/Plugins/Process/elf-core/RegisterUtilities.h
index ce07dfc38f808..f6a2fbdcc9387 100644
--- a/lldb/source/Plugins/Process/elf-core/RegisterUtilities.h
+++ b/lldb/source/Plugins/Process/elf-core/RegisterUtilities.h
@@ -55,6 +55,10 @@ namespace AMD64 {
 enum { NT_REGS = 33, NT_FPREGS = 35 };
 }
 
+namespace I386 {
+enum { NT_REGS = 33, NT_FPREGS = 35 };
+}
+
 } // namespace NETBSD
 
 namespace OPENBSD {
@@ -106,6 +110,7 @@ constexpr RegsetDesc FPR_Desc[] = {
 {llvm::Triple::Linux, llvm::Triple::x86, llvm::ELF::NT_PRXFPREG},
 {llvm::Triple::Linux, llvm::Triple::UnknownArch, llvm::ELF::NT_FPREGSET},
 {llvm::Triple::NetBSD, llvm::Triple::aarch64, NETBSD::AARCH64::NT_FPREGS},
+{llvm::Triple::NetBSD, llvm::Triple::x86, NETBSD::I386::NT_FPREGS},
 {llvm::Triple::NetBSD, llvm::Triple::x86_64, NETBSD::AMD64::NT_FPREGS},
 {llvm::Triple::OpenBSD, llvm::Triple::UnknownArch, OPENBSD::NT_FPREGS},
 };

diff  --git a/lldb/source/Plugins/Process/elf-core/ThreadElfCore.cpp 
b/lldb/source/Plugins/Process/elf-core/ThreadElfCore.cpp
index 28483cf5f5a05..937d074869a25 100644
--- a/lldb/source/Plugins/Process/elf-core/ThreadElfCore.cpp
+++ b/lldb/source/Plugins/Process/elf-core/ThreadElfCore.cpp
@@ -20,6 +20,7 @@
 #include "Plugins/Process/Utility/RegisterContextLinux_i386.h"
 #include "Plugins/Process/Utility/RegisterContextLinux_s390x.h"
 #include "Plugins/Process/Utility/RegisterContextLinux_x86_64.h"
+#include "Plugins/Process/Utility/RegisterContextNetBSD_i386.h"
 #include "Plugins/Process/Utility/RegisterContextNetBSD_x86_64.h"
 #include "Plugins/Process/Utility/RegisterContextOpenBSD_i386.h"
 #include "Plugins/Process/Utility/RegisterContextOpenBSD_x86_64.h"
@@ -107,6 +108,9 @@ ThreadElfCore::CreateRegisterContextForFrame(StackFrame 
*frame) {
   switch (arch.GetMachine()) {
   case llvm::Triple::aarch64:
 break;
+  case llvm::Triple::x86:
+reg_interface = new RegisterContextNetBSD_i386(arch);
+break;
   case llvm::Triple::x86_64:
 reg_interface = new RegisterContextNetBSD_x86_64(arch);
 break;

diff  --git a/lldb/test/Shell/Register/Core/x86-32-netbsd-addr.test 
b/lldb/test/Shell/Register/Core/x86-32-netbsd-addr.test
new file 

[Lldb-commits] [PATCH] D101091: [lldb] [Process/elf-core] Fix reading NetBSD/i386 core dumps

2021-06-20 Thread Michał Górny via Phabricator via lldb-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rGd4c437c4289c: [lldb] [Process/elf-core] Fix reading 
NetBSD/i386 core dumps (authored by mgorny).
Herald added a project: LLDB.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101091

Files:
  lldb/source/Plugins/Process/elf-core/ProcessElfCore.cpp
  lldb/source/Plugins/Process/elf-core/RegisterUtilities.h
  lldb/source/Plugins/Process/elf-core/ThreadElfCore.cpp
  lldb/test/Shell/Register/Core/x86-32-netbsd-addr.test
  lldb/test/Shell/Register/Core/x86-32-netbsd-gp.test

Index: lldb/test/Shell/Register/Core/x86-32-netbsd-gp.test
===
--- /dev/null
+++ lldb/test/Shell/Register/Core/x86-32-netbsd-gp.test
@@ -0,0 +1,3 @@
+# RUN: %lldb -b -s %s -c %p/Inputs/x86-32-netbsd.core | FileCheck %p/Inputs/x86-32-gp.check
+
+register read --all
Index: lldb/test/Shell/Register/Core/x86-32-netbsd-addr.test
===
--- /dev/null
+++ lldb/test/Shell/Register/Core/x86-32-netbsd-addr.test
@@ -0,0 +1,13 @@
+# RUN: %lldb -b -s %s -c %p/Inputs/x86-32-netbsd.core | FileCheck %s
+
+register read --all
+# CHECK-DAG: eip = 0x08048955
+# CHECK-DAG: eflags = 0x00010282
+# CHECK-DAG: cs = 0x0037
+# CHECK-DAG: fs = 0x004f
+# CHECK-DAG: gs = 0x008b
+# CHECK-DAG: ss = 0x004f
+# CHECK-DAG: ds = 0x004f
+# CHECK-DAG: es = 0x004f
+
+# TODO: fix reading fp registers
Index: lldb/source/Plugins/Process/elf-core/ThreadElfCore.cpp
===
--- lldb/source/Plugins/Process/elf-core/ThreadElfCore.cpp
+++ lldb/source/Plugins/Process/elf-core/ThreadElfCore.cpp
@@ -20,6 +20,7 @@
 #include "Plugins/Process/Utility/RegisterContextLinux_i386.h"
 #include "Plugins/Process/Utility/RegisterContextLinux_s390x.h"
 #include "Plugins/Process/Utility/RegisterContextLinux_x86_64.h"
+#include "Plugins/Process/Utility/RegisterContextNetBSD_i386.h"
 #include "Plugins/Process/Utility/RegisterContextNetBSD_x86_64.h"
 #include "Plugins/Process/Utility/RegisterContextOpenBSD_i386.h"
 #include "Plugins/Process/Utility/RegisterContextOpenBSD_x86_64.h"
@@ -107,6 +108,9 @@
   switch (arch.GetMachine()) {
   case llvm::Triple::aarch64:
 break;
+  case llvm::Triple::x86:
+reg_interface = new RegisterContextNetBSD_i386(arch);
+break;
   case llvm::Triple::x86_64:
 reg_interface = new RegisterContextNetBSD_x86_64(arch);
 break;
Index: lldb/source/Plugins/Process/elf-core/RegisterUtilities.h
===
--- lldb/source/Plugins/Process/elf-core/RegisterUtilities.h
+++ lldb/source/Plugins/Process/elf-core/RegisterUtilities.h
@@ -55,6 +55,10 @@
 enum { NT_REGS = 33, NT_FPREGS = 35 };
 }
 
+namespace I386 {
+enum { NT_REGS = 33, NT_FPREGS = 35 };
+}
+
 } // namespace NETBSD
 
 namespace OPENBSD {
@@ -106,6 +110,7 @@
 {llvm::Triple::Linux, llvm::Triple::x86, llvm::ELF::NT_PRXFPREG},
 {llvm::Triple::Linux, llvm::Triple::UnknownArch, llvm::ELF::NT_FPREGSET},
 {llvm::Triple::NetBSD, llvm::Triple::aarch64, NETBSD::AARCH64::NT_FPREGS},
+{llvm::Triple::NetBSD, llvm::Triple::x86, NETBSD::I386::NT_FPREGS},
 {llvm::Triple::NetBSD, llvm::Triple::x86_64, NETBSD::AMD64::NT_FPREGS},
 {llvm::Triple::OpenBSD, llvm::Triple::UnknownArch, OPENBSD::NT_FPREGS},
 };
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
@@ -664,6 +664,32 @@
   thread_data.notes.push_back(note);
 }
   } break;
+  case llvm::Triple::x86: {
+// Assume order PT_GETREGS, PT_GETFPREGS
+if (note.info.n_type == NETBSD::I386::NT_REGS) {
+  // If this is the next thread, push the previous one first.
+  if (had_nt_regs) {
+m_thread_data.push_back(thread_data);
+thread_data = ThreadData();
+had_nt_regs = false;
+  }
+
+  thread_data.gpregset = note.data;
+  thread_data.tid = tid;
+  if (thread_data.gpregset.GetByteSize() == 0)
+return llvm::make_error(
+"Could not find general purpose registers note in core file.",
+llvm::inconvertibleErrorCode());
+  had_nt_regs = true;
+} else if (note.info.n_type == NETBSD::I386::NT_FPREGS) {
+  if (!had_nt_regs || tid != thread_data.tid)
+return llvm::make_error(
+"Error parsing NetBSD core(5) notes: Unexpected order "
+"of NOTEs PT_GETFPREG before PT_GETREG",
+llvm::inconvertibleErrorCode())

[Lldb-commits] [PATCH] D88387: Create "skinny corefiles" for Mach-O with process save-core / reading

2021-06-20 Thread Jason Molenda via Phabricator via lldb-commits
This revision was not accepted when it landed; it landed in state "Needs 
Review".
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG9ea6dd5cfac0: Add a corefile style option to process 
save-core; skinny corefiles (authored by jasonmolenda).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D88387

Files:
  lldb/bindings/interface/SBMemoryRegionInfo.i
  lldb/docs/lldb-gdb-remote.txt
  lldb/include/lldb/API/SBMemoryRegionInfo.h
  lldb/include/lldb/Core/PluginManager.h
  lldb/include/lldb/Symbol/ObjectFile.h
  lldb/include/lldb/Target/MemoryRegionInfo.h
  lldb/include/lldb/lldb-enumerations.h
  lldb/include/lldb/lldb-private-interfaces.h
  lldb/packages/Python/lldbsuite/test/tools/lldb-server/gdbremote_testcase.py
  lldb/source/API/SBMemoryRegionInfo.cpp
  lldb/source/API/SBProcess.cpp
  lldb/source/Commands/CommandObjectMemory.cpp
  lldb/source/Commands/CommandObjectProcess.cpp
  lldb/source/Commands/Options.td
  lldb/source/Core/PluginManager.cpp
  lldb/source/Interpreter/CommandObject.cpp
  lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp
  lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.h
  lldb/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp
  lldb/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.h
  lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp
  lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.h
  lldb/source/Plugins/Process/mach-core/ProcessMachCore.cpp
  lldb/test/API/functionalities/gdb_remote_client/TestMemoryRegionDirtyPages.py
  lldb/test/API/functionalities/gdb_remote_client/gdbclientutils.py
  lldb/test/API/macosx/skinny-corefile/Makefile
  lldb/test/API/macosx/skinny-corefile/TestSkinnyCorefile.py
  lldb/test/API/macosx/skinny-corefile/main.c
  lldb/test/API/macosx/skinny-corefile/present.c
  lldb/test/API/macosx/skinny-corefile/present.h
  lldb/test/API/macosx/skinny-corefile/to-be-removed.c
  lldb/test/API/macosx/skinny-corefile/to-be-removed.h
  lldb/test/API/tools/lldb-server/TestGdbRemoteHostInfo.py
  lldb/tools/debugserver/source/DNBDefs.h
  lldb/tools/debugserver/source/MacOSX/MachVMMemory.cpp
  lldb/tools/debugserver/source/RNBRemote.cpp

Index: lldb/tools/debugserver/source/RNBRemote.cpp
===
--- lldb/tools/debugserver/source/RNBRemote.cpp
+++ lldb/tools/debugserver/source/RNBRemote.cpp
@@ -19,6 +19,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -4447,7 +4448,7 @@
 __FILE__, __LINE__, p, "Invalid address in qMemoryRegionInfo packet");
   }
 
-  DNBRegionInfo region_info = {0, 0, 0};
+  DNBRegionInfo region_info;
   DNBProcessMemoryRegionInfo(m_ctx.ProcessID(), address, ®ion_info);
   std::ostringstream ostrm;
 
@@ -4467,6 +4468,18 @@
 if (region_info.permissions & eMemoryPermissionsExecutable)
   ostrm << 'x';
 ostrm << ';';
+
+ostrm << "dirty-pages:";
+if (region_info.dirty_pages.size() > 0) {
+  bool first = true;
+  for (nub_addr_t addr : region_info.dirty_pages) {
+if (!first)
+  ostrm << ",";
+first = false;
+ostrm << "0x" << std::hex << addr;
+  }
+}
+ostrm << ";";
   }
   return SendPacket(ostrm.str());
 }
@@ -4993,6 +5006,8 @@
   strm << "default_packet_timeout:10;";
 #endif
 
+  strm << "vm-page-size:" << std::dec << vm_page_size << ";";
+
   return SendPacket(strm.str());
 }
 
Index: lldb/tools/debugserver/source/MacOSX/MachVMMemory.cpp
===
--- lldb/tools/debugserver/source/MacOSX/MachVMMemory.cpp
+++ lldb/tools/debugserver/source/MacOSX/MachVMMemory.cpp
@@ -72,6 +72,49 @@
   return count;
 }
 
+#define MAX_STACK_ALLOC_DISPOSITIONS   \
+  (16 * 1024 / sizeof(int)) // 16K of allocations
+
+std::vector get_dirty_pages(task_t task, mach_vm_address_t addr,
+mach_vm_size_t size) {
+  std::vector dirty_pages;
+
+  int pages_to_query = size / vm_page_size;
+  // Don't try to fetch too many pages' dispositions in a single call or we
+  // could blow our stack out.
+  mach_vm_size_t dispositions_size =
+  std::min(pages_to_query, (int)MAX_STACK_ALLOC_DISPOSITIONS);
+  int dispositions[dispositions_size];
+
+  mach_vm_size_t chunk_count =
+  ((pages_to_query + MAX_STACK_ALLOC_DISPOSITIONS - 1) /
+   MAX_STACK_ALLOC_DISPOSITIONS);
+
+  for (mach_vm_size_t cur_disposition_chunk = 0;
+   cur_disposition_chunk < chunk_count; cur_disposition_chunk++) {
+mach_vm_size_t dispositions_already_queried =
+cur_disposition_chunk * MAX_STACK_ALLOC_DISPOSITIONS;
+
+mach_vm_size_t chunk_pages_to_query = std::min(
+pages_to_query - dispositions_already_queried, dispositions_size);
+mach_vm_addre

[Lldb-commits] [lldb] 9ea6dd5 - Add a corefile style option to process save-core; skinny corefiles

2021-06-20 Thread Jason Molenda via lldb-commits

Author: Jason Molenda
Date: 2021-06-20T12:26:54-07:00
New Revision: 9ea6dd5cfac0b233fbb148c1e2d0f81f816737c8

URL: 
https://github.com/llvm/llvm-project/commit/9ea6dd5cfac0b233fbb148c1e2d0f81f816737c8
DIFF: 
https://github.com/llvm/llvm-project/commit/9ea6dd5cfac0b233fbb148c1e2d0f81f816737c8.diff

LOG: Add a corefile style option to process save-core; skinny corefiles

Add a new feature to process save-core on Darwin systems -- for
lldb to create a user process corefile with only the dirty (modified
memory) pages included.  All of the binaries that were used in the
corefile are assumed to still exist on the system for the duration
of the use of the corefile.  A new --style option to process save-core
is added, so a full corefile can be requested if portability across
systems, or across time, is needed for this corefile.

debugserver can now identify the dirty pages in a memory region
when queried with qMemoryRegionInfo, and the size of vm pages is
given in qHostInfo.

Create a new "all image infos" LC_NOTE for Mach-O which allows us
to describe all of the binaries that were loaded in the process --
load address, UUID, file path, segment load addresses, and optionally
whether code from the binary was executing on any thread.  The old
"read dyld_all_image_infos and then the in-memory Mach-O load
commands to get segment load addresses" no longer works when we
only have dirty memory.

rdar://69670807
Differential Revision: https://reviews.llvm.org/D88387

Added: 

lldb/test/API/functionalities/gdb_remote_client/TestMemoryRegionDirtyPages.py
lldb/test/API/macosx/skinny-corefile/Makefile
lldb/test/API/macosx/skinny-corefile/TestSkinnyCorefile.py
lldb/test/API/macosx/skinny-corefile/main.c
lldb/test/API/macosx/skinny-corefile/present.c
lldb/test/API/macosx/skinny-corefile/present.h
lldb/test/API/macosx/skinny-corefile/to-be-removed.c
lldb/test/API/macosx/skinny-corefile/to-be-removed.h

Modified: 
lldb/bindings/interface/SBMemoryRegionInfo.i
lldb/docs/lldb-gdb-remote.txt
lldb/include/lldb/API/SBMemoryRegionInfo.h
lldb/include/lldb/Core/PluginManager.h
lldb/include/lldb/Symbol/ObjectFile.h
lldb/include/lldb/Target/MemoryRegionInfo.h
lldb/include/lldb/lldb-enumerations.h
lldb/include/lldb/lldb-private-interfaces.h
lldb/packages/Python/lldbsuite/test/tools/lldb-server/gdbremote_testcase.py
lldb/source/API/SBMemoryRegionInfo.cpp
lldb/source/API/SBProcess.cpp
lldb/source/Commands/CommandObjectMemory.cpp
lldb/source/Commands/CommandObjectProcess.cpp
lldb/source/Commands/Options.td
lldb/source/Core/PluginManager.cpp
lldb/source/Interpreter/CommandObject.cpp
lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp
lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.h
lldb/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp
lldb/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.h
lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp
lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.h
lldb/source/Plugins/Process/mach-core/ProcessMachCore.cpp
lldb/test/API/functionalities/gdb_remote_client/gdbclientutils.py
lldb/test/API/tools/lldb-server/TestGdbRemoteHostInfo.py
lldb/tools/debugserver/source/DNBDefs.h
lldb/tools/debugserver/source/MacOSX/MachVMMemory.cpp
lldb/tools/debugserver/source/RNBRemote.cpp

Removed: 




diff  --git a/lldb/bindings/interface/SBMemoryRegionInfo.i 
b/lldb/bindings/interface/SBMemoryRegionInfo.i
index 6a2ad6a3e3649..3460dc0d06e22 100644
--- a/lldb/bindings/interface/SBMemoryRegionInfo.i
+++ b/lldb/bindings/interface/SBMemoryRegionInfo.i
@@ -46,6 +46,42 @@ public:
 const char *
 GetName ();
 
+%feature("autodoc", "
+GetRegionEnd(SBMemoryRegionInfo self) -> lldb::addr_t
+Returns whether this memory region has a list of modified (dirty)
+pages available or not.  When calling GetNumDirtyPages(), you will
+have 0 returned for both \"dirty page list is not known\" and 
+\"empty dirty page list\" (that is, no modified pages in this
+memory region).  You must use this method to disambiguate.") 
HasDirtyMemoryPageList;
+bool 
+HasDirtyMemoryPageList();
+
+%feature("autodoc", "
+GetNumDirtyPages(SBMemoryRegionInfo self) -> uint32_t
+Return the number of dirty (modified) memory pages in this
+memory region, if available.  You must use the 
+SBMemoryRegionInfo::HasDirtyMemoryPageList() method to
+determine if a dirty memory list is available; it will depend
+on the target system can provide this information.") GetNumDirtyPages;
+uint32_t 
+GetNumDirtyPages();
+
+%feature("autodoc", "
+GetDirtyPageAddressAtIndex(SBMemoryRegionInfo self, uint32_t idx) -> 
lldb::addr_t
+Return the address of a modified, or

[Lldb-commits] [lldb] af91388 - Try to unbreak the windows CI

2021-06-20 Thread Jason Molenda via lldb-commits

Author: Jason Molenda
Date: 2021-06-20T13:13:46-07:00
New Revision: af913881e33c30d34c806efc586360d3bfc3a5ca

URL: 
https://github.com/llvm/llvm-project/commit/af913881e33c30d34c806efc586360d3bfc3a5ca
DIFF: 
https://github.com/llvm/llvm-project/commit/af913881e33c30d34c806efc586360d3bfc3a5ca.diff

LOG: Try to unbreak the windows CI

MSVC and clang seem to disagree with whether I can do this.

Added: 


Modified: 
lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp

Removed: 




diff  --git a/lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp 
b/lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp
index eb32a2480e430..e7652cffb1c81 100644
--- a/lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp
+++ b/lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp
@@ -6516,12 +6516,17 @@ bool ObjectFileMachO::SaveCore(const lldb::ProcessSP 
&process_sp,
 dirty_page_list.hasValue()) {
   core_style = SaveCoreStyle::eSaveCoreDirtyOnly;
   for (addr_t dirtypage : dirty_page_list.getValue()) {
-page_object obj = {
-.addr = dirtypage, .size = pagesize, .prot = prot};
+page_object obj;
+obj.addr = dirtypage;
+obj.size = pagesize;
+obj.prot = prot;
 pages_to_copy.push_back(obj);
   }
 } else {
-  page_object obj = {.addr = addr, .size = size, .prot = prot};
+  page_object obj;
+  obj.addr = addr;
+  obj.size = size;
+  obj.prot = prot;
   pages_to_copy.push_back(obj);
 }
   }



___
lldb-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits