diff options
Diffstat (limited to 'lldb/source/Target')
| -rw-r--r-- | lldb/source/Target/Target.cpp | 12 | ||||
| -rw-r--r-- | lldb/source/Target/Thread.cpp | 24 |
2 files changed, 31 insertions, 5 deletions
diff --git a/lldb/source/Target/Target.cpp b/lldb/source/Target/Target.cpp index 01e51c0577aa..6d33db6554d2 100644 --- a/lldb/source/Target/Target.cpp +++ b/lldb/source/Target/Target.cpp @@ -1829,13 +1829,14 @@ size_t Target::ReadMemory(const Address &addr, void *dst, size_t dst_len, } size_t Target::ReadCStringFromMemory(const Address &addr, std::string &out_str, - Status &error) { + Status &error, bool force_live_memory) { char buf[256]; out_str.clear(); addr_t curr_addr = addr.GetLoadAddress(this); Address address(addr); while (true) { - size_t length = ReadCStringFromMemory(address, buf, sizeof(buf), error); + size_t length = ReadCStringFromMemory(address, buf, sizeof(buf), error, + force_live_memory); if (length == 0) break; out_str.append(buf, length); @@ -1851,7 +1852,8 @@ size_t Target::ReadCStringFromMemory(const Address &addr, std::string &out_str, } size_t Target::ReadCStringFromMemory(const Address &addr, char *dst, - size_t dst_max_len, Status &result_error) { + size_t dst_max_len, Status &result_error, + bool force_live_memory) { size_t total_cstr_len = 0; if (dst && dst_max_len) { result_error.Clear(); @@ -1874,8 +1876,8 @@ size_t Target::ReadCStringFromMemory(const Address &addr, char *dst, cache_line_size - (curr_addr % cache_line_size); addr_t bytes_to_read = std::min<addr_t>(bytes_left, cache_line_bytes_left); - size_t bytes_read = - ReadMemory(address, curr_dst, bytes_to_read, error, true); + size_t bytes_read = ReadMemory(address, curr_dst, bytes_to_read, error, + force_live_memory); if (bytes_read == 0) { result_error = error; diff --git a/lldb/source/Target/Thread.cpp b/lldb/source/Target/Thread.cpp index c5f16b4e6c1d..bde6dad554e7 100644 --- a/lldb/source/Target/Thread.cpp +++ b/lldb/source/Target/Thread.cpp @@ -13,6 +13,7 @@ #include "lldb/Core/Module.h" #include "lldb/Core/StructuredDataImpl.h" #include "lldb/Core/ValueObject.h" +#include "lldb/Core/ValueObjectConstResult.h" #include "lldb/Host/Host.h" #include "lldb/Interpreter/OptionValueFileSpecList.h" #include "lldb/Interpreter/OptionValueProperties.h" @@ -2005,3 +2006,26 @@ ThreadSP Thread::GetCurrentExceptionBacktrace() { return ThreadSP(); } + +lldb::ValueObjectSP Thread::GetSiginfoValue() { + ProcessSP process_sp = GetProcess(); + assert(process_sp); + Target &target = process_sp->GetTarget(); + PlatformSP platform_sp = target.GetPlatform(); + assert(platform_sp); + ArchSpec arch = target.GetArchitecture(); + + CompilerType type = platform_sp->GetSiginfoType(arch.GetTriple()); + if (!type.IsValid()) + return ValueObjectConstResult::Create(&target, Status("no siginfo_t for the platform")); + + llvm::Optional<uint64_t> type_size = type.GetByteSize(nullptr); + assert(type_size); + llvm::Expected<std::unique_ptr<llvm::MemoryBuffer>> data = GetSiginfo(type_size.getValue()); + if (!data) + return ValueObjectConstResult::Create(&target, Status(data.takeError())); + + DataExtractor data_extractor{data.get()->getBufferStart(), data.get()->getBufferSize(), + process_sp->GetByteOrder(), arch.GetAddressByteSize()}; + return ValueObjectConstResult::Create(&target, type, ConstString("__lldb_siginfo"), data_extractor); +} |
