[Lldb-commits] [PATCH] D107625: Add a stack-memory-only style for Darwin process save-core

Jason Molenda via Phabricator via lldb-commits lldb-commits at lists.llvm.org
Fri Aug 6 01:38:16 PDT 2021


jasonmolenda created this revision.
jasonmolenda added a project: LLDB.
Herald added a subscriber: JDevlieghere.
jasonmolenda requested review of this revision.

After adding the "dirty memory only" coredump style, I've been wondering how small a corefile I could get by only saving stack memory.  I took a little time today to find out.  A normal macOS corefile is a couple of GB, a dirty-memory corefile is around 440kb for a test binary.  A stack memory corefile is about 20kb for that test binary.

I added a new "type" key-value pair to the qMemoryRegionInfo packet, and add "stack" to stack memory regions.  David added a "flags" k-v pair for MTE but that has a specially formatted string of MTE flags in it (space separated) so I didn't want to mix in with that.  It's straightforward to detect different memory types on Darwin systems, but I haven't thought of anything useful I could do by writing out heap dirty memory only or something.  Maybe someone will think of some interesting way to use the memory region types.

In the test case, I create a stack-memory-only corefile, then read it back into lldb and fetch some stack & heap objects.  SBValue has the unfortunate behavior (IMO) that it doesn't surface memory read errors in any way - so you can ask for a summary or a value of an SBValue object that couldn't read anything, and it will return 0/empty-string.  We need to surface memory read errors better in lldb in these cases, this is just one of the issues with that.

I'm not sure a stack-memory-only corefile is especially useful for real C++/ObjC/Swift programs where many objects live on the heap.  One thing I've thought about is trying to get a very tiny corefile showing interesting unwind states for writing tests against.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D107625

Files:
  lldb/docs/lldb-gdb-remote.txt
  lldb/include/lldb/Target/MemoryRegionInfo.h
  lldb/include/lldb/lldb-enumerations.h
  lldb/source/Commands/CommandObjectProcess.cpp
  lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp
  lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp
  lldb/test/API/macosx/skinny-corefile/TestSkinnyCorefile.py
  lldb/test/API/macosx/stack-corefile/Makefile
  lldb/test/API/macosx/stack-corefile/TestStackCorefile.py
  lldb/test/API/macosx/stack-corefile/main.c
  lldb/tools/debugserver/source/DNBDefs.h
  lldb/tools/debugserver/source/MacOSX/MachVMMemory.cpp
  lldb/tools/debugserver/source/MacOSX/MachVMRegion.cpp
  lldb/tools/debugserver/source/MacOSX/MachVMRegion.h
  lldb/tools/debugserver/source/RNBRemote.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D107625.364718.patch
Type: text/x-patch
Size: 17737 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20210806/f8491ff8/attachment-0001.bin>


More information about the lldb-commits mailing list