llvm-project/lldb/source/API
Med Ismail Bennani a758c9f720 [lldb/Plugins] Add memory region support in ScriptedProcess
This patch adds support for memory regions in Scripted Processes.
This is necessary to read the stack memory region in order to
reconstruct each stackframe of the program.

In order to do so, this patch makes some changes to the SBAPI, namely:
- Add a new constructor for `SBMemoryRegionInfo` that takes arguments
  such as the memory region name, address range, permissions ...
  This is used when reading memory at some address to compute the offset
  in the binary blob provided by the user.
- Add a `GetMemoryRegionContainingAddress` method to `SBMemoryRegionInfoList`
  to simplify the access to a specific memory region.

With these changes, lldb is now able to unwind the stack and reconstruct
each frame. On top of that, reloading the target module at offset 0 allows
lldb to symbolicate the `ScriptedProcess` using debug info, similarly to an
ordinary Process.

To test this, I wrote a simple program with multiple function calls, ran it in
lldb, stopped at a leaf function and read the registers values and copied
the stack memory into a binary file. These are then used in the python script.

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

Signed-off-by: Med Ismail Bennani <medismail.bennani@gmail.com>
2021-10-08 14:54:07 +02:00
..
CMakeLists.txt [trace][intel-pt] Create basic SB API 2021-06-17 15:14:47 -07:00
SBAddress.cpp [lldb] Pass reference instead of pointer in protected SBAddress methods. 2020-09-25 11:47:05 -07:00
SBAttachInfo.cpp [lldb] Replace empty ctor en dtor bodies with =default (NFC) 2020-02-17 22:58:26 -08:00
SBBlock.cpp [lldb] Use C++11 default member initializers 2021-06-09 09:43:13 -07:00
SBBreakpoint.cpp Convert functions that were returning BreakpointOption * to BreakpointOption &. 2021-06-15 14:34:02 -07:00
SBBreakpointLocation.cpp Convert functions that were returning BreakpointOption * to BreakpointOption &. 2021-06-15 14:34:02 -07:00
SBBreakpointName.cpp Convert functions that were returning BreakpointOption * to BreakpointOption &. 2021-06-15 14:34:02 -07:00
SBBreakpointOptionCommon.cpp
SBBreakpointOptionCommon.h [lldb] Update header guards to be consistent and compliant with LLVM (NFC) 2020-02-17 23:15:40 -08:00
SBBroadcaster.cpp [lldb] Use C++11 default member initializers 2021-06-09 09:43:13 -07:00
SBCommandInterpreter.cpp [lldb] Remove redundant calls to set eReturnStatusFailed 2021-06-17 12:21:54 +01:00
SBCommandInterpreterRunOptions.cpp [lldb/API] Add CommandInterpreter::{Get,Set}PrintErrors to SBAPI (NFC) 2021-03-05 19:33:33 +01:00
SBCommandReturnObject.cpp [lldb] Remove CommandReturnObject's SetError(StringRef) 2021-06-23 11:25:10 +00:00
SBCommunication.cpp [lldb] Use C++11 default member initializers 2021-06-09 09:43:13 -07:00
SBCompileUnit.cpp [lldb] Use C++11 default member initializers 2021-06-09 09:43:13 -07:00
SBData.cpp [lldb] Replace empty ctor en dtor bodies with =default (NFC) 2020-02-17 22:58:26 -08:00
SBDebugger.cpp [lldb][NFC] Remove unused var in SBDebugger::GetInternalVariableValue 2021-05-31 11:19:02 +02:00
SBDeclaration.cpp [lldb][NFC] Use C++ versions of the deprecated C standard library headers 2021-05-26 12:46:12 +02:00
SBEnvironment.cpp [lldb/Reproducers] Add instrumentation to SBEnvironment 2020-05-20 13:02:20 -07:00
SBError.cpp [lldb][NFC] Use C++ versions of the deprecated C standard library headers 2021-05-26 12:46:12 +02:00
SBEvent.cpp [lldb] Use C++11 default member initializers 2021-06-09 09:43:13 -07:00
SBExecutionContext.cpp [lldb] Replace empty ctor en dtor bodies with =default (NFC) 2020-02-17 22:58:26 -08:00
SBExpressionOptions.cpp [lldb/API] Add missing LLDB_REGISTER_METHOD macros 2020-04-06 16:09:40 -07:00
SBFile.cpp [lldb] Replace empty ctor en dtor bodies with =default (NFC) 2020-02-17 22:58:26 -08:00
SBFileSpec.cpp [lldb][NFC] Use C++ versions of the deprecated C standard library headers 2021-05-26 12:46:12 +02:00
SBFileSpecList.cpp [lldb][NFC] Use C++ versions of the deprecated C standard library headers 2021-05-26 12:46:12 +02:00
SBFrame.cpp [lldb] Support querying registers via generic names without alt_names 2021-09-13 13:05:06 +02:00
SBFunction.cpp [lldb] Use C++11 default member initializers 2021-06-09 09:43:13 -07:00
SBHostOS.cpp [lldb] Provide GetHomeDirectory wrapper in Host::FileSystem (NFC) 2020-08-20 14:07:05 -07:00
SBInstruction.cpp [lldb] Pass reference instead of pointer in protected SBAddress methods. 2020-09-25 11:47:05 -07:00
SBInstructionList.cpp [lldb] Replace empty ctor en dtor bodies with =default (NFC) 2020-02-17 22:58:26 -08:00
SBLanguageRuntime.cpp [lldb][NFC] Remove all uses of StringRef::withNullAsEmpty in LLDB 2021-05-18 09:41:20 +02:00
SBLaunchInfo.cpp [lldb/Commands] Add command options for ScriptedProcess to ProcessLaunch 2021-03-23 18:24:47 +01:00
SBLineEntry.cpp [lldb][NFC] Use C++ versions of the deprecated C standard library headers 2021-05-26 12:46:12 +02:00
SBListener.cpp [lldb] Use C++11 default member initializers 2021-06-09 09:43:13 -07:00
SBMemoryRegionInfo.cpp [lldb/Plugins] Add memory region support in ScriptedProcess 2021-10-08 14:54:07 +02:00
SBMemoryRegionInfoList.cpp [lldb/Plugins] Add memory region support in ScriptedProcess 2021-10-08 14:54:07 +02:00
SBModule.cpp [lldb] Use a struct to pass function search options to Module::FindFunction 2021-08-05 10:18:14 -07:00
SBModuleSpec.cpp [lldb] Replace empty ctor en dtor bodies with =default (NFC) 2020-02-17 22:58:26 -08:00
SBPlatform.cpp [lldb] Use C++11 default member initializers 2021-06-09 09:43:13 -07:00
SBProcess.cpp [lldb] Add minidump save-core functionality to ELF object files 2021-09-01 15:14:29 +02:00
SBProcessInfo.cpp Revert "[LLDB/API] Expose args and env from SBProcessInfo." 2021-06-05 15:50:49 +07:00
SBQueue.cpp [lldb] Use C++11 default member initializers 2021-06-09 09:43:13 -07:00
SBQueueItem.cpp [lldb] Pass reference instead of pointer in protected SBAddress methods. 2020-09-25 11:47:05 -07:00
SBReproducer.cpp [trace][intel-pt] Create basic SB API 2021-06-17 15:14:47 -07:00
SBReproducerPrivate.h [lldb] Extract reproducer providers & co into their own header. 2020-08-22 10:04:27 -07:00
SBSection.cpp [lldb] Switch Section-dumping code to raw_ostream 2020-05-14 11:59:18 +02:00
SBSourceManager.cpp [lldb/API] Use std::make_unique<> (NFC) 2020-06-24 16:29:30 -07:00
SBStream.cpp [lldb] [gdb-remote] Add eOpenOptionReadWrite for future gdb compat 2021-08-09 12:06:59 +02:00
SBStringList.cpp [lldb/API] Use std::make_unique<> (NFC) 2020-06-24 16:29:30 -07:00
SBStructuredData.cpp [trace][intel-pt] Create basic SB API 2021-06-17 15:14:47 -07:00
SBSymbol.cpp [lldb] Use C++11 default member initializers 2021-06-09 09:43:13 -07:00
SBSymbolContext.cpp [lldb/API] Use std::make_unique<> (NFC) 2020-06-24 16:29:30 -07:00
SBSymbolContextList.cpp [lldb] Replace empty ctor en dtor bodies with =default (NFC) 2020-02-17 22:58:26 -08:00
SBTarget.cpp [lldb] Remove some anonymous namespaces 2021-10-05 08:35:18 +02:00
SBThread.cpp [lldb] Refactor argument group by SourceLocationSpec (NFCI) 2021-05-04 23:04:31 +00:00
SBThreadCollection.cpp [lldb] Replace empty ctor en dtor bodies with =default (NFC) 2020-02-17 22:58:26 -08:00
SBThreadPlan.cpp Add a setting to force stepping to always run all threads. 2020-08-07 14:47:31 -07:00
SBTrace.cpp [trace][intel-pt] Create basic SB API 2021-06-17 15:14:47 -07:00
SBType.cpp [lldb] Add SBType::GetEnumerationIntegerType method 2020-12-22 10:08:22 -08:00
SBTypeCategory.cpp [lldb][NFC] Remove all uses of StringRef::withNullAsEmpty in LLDB 2021-05-18 09:41:20 +02:00
SBTypeEnumMember.cpp [lldb/API] Use std::make_unique<> (NFC) 2020-06-24 16:29:30 -07:00
SBTypeFilter.cpp [lldb] Replace empty ctor en dtor bodies with =default (NFC) 2020-02-17 22:58:26 -08:00
SBTypeFormat.cpp [lldb] Replace empty ctor en dtor bodies with =default (NFC) 2020-02-17 22:58:26 -08:00
SBTypeNameSpecifier.cpp [lldb] Replace empty ctor en dtor bodies with =default (NFC) 2020-02-17 22:58:26 -08:00
SBTypeSummary.cpp [lldb/API] Use std::make_unique<> (NFC) 2020-06-24 16:29:30 -07:00
SBTypeSynthetic.cpp [lldb] Replace empty ctor en dtor bodies with =default (NFC) 2020-02-17 22:58:26 -08:00
SBUnixSignals.cpp [lldb] Replace empty ctor en dtor bodies with =default (NFC) 2020-02-17 22:58:26 -08:00
SBValue.cpp [lldb] Move and clean-up the Declaration class (NFC) 2021-05-04 16:34:44 +00:00
SBValueList.cpp [lldb/API] Use std::make_unique<> (NFC) 2020-06-24 16:29:30 -07:00
SBVariablesOptions.cpp [lldb] Use C++11 default member initializers 2021-06-09 09:43:13 -07:00
SBWatchpoint.cpp [lldb] Replace empty ctor en dtor bodies with =default (NFC) 2020-02-17 22:58:26 -08:00
SystemInitializerFull.cpp [lldb] Prevent that LLDB randomly crashes in CommandLineParser::addOption by initializing LLVM's command line parser 2021-04-01 20:17:54 +02:00
SystemInitializerFull.h [lldb] Update header guards to be consistent and compliant with LLVM (NFC) 2020-02-17 23:15:40 -08:00
Utils.h [lldb] Update header guards to be consistent and compliant with LLVM (NFC) 2020-02-17 23:15:40 -08:00
liblldb-private.exports
liblldb.exports