diff options
| author | Dimitry Andric <dim@FreeBSD.org> | 2022-02-18 22:37:06 +0000 |
|---|---|---|
| committer | Dimitry Andric <dim@FreeBSD.org> | 2022-02-18 22:37:06 +0000 |
| commit | 7eff647615f93a9aaff1997e1880b195dc3aabe6 (patch) | |
| tree | ae348c384d518be05d73326fbfc22a1f66eb56d0 /lldb | |
| parent | 1e9a9d6d056506b23ad26952df45eaac949385c7 (diff) | |
Diffstat (limited to 'lldb')
18 files changed, 177 insertions, 113 deletions
diff --git a/lldb/include/lldb/Core/Mangled.h b/lldb/include/lldb/Core/Mangled.h index 4e4f75e18e34..aaefb69f017b 100644 --- a/lldb/include/lldb/Core/Mangled.h +++ b/lldb/include/lldb/Core/Mangled.h @@ -226,10 +226,9 @@ public: /// Function signature for filtering mangled names. using SkipMangledNameFn = bool(llvm::StringRef, ManglingScheme); - /// Trigger explicit demangling to obtain rich mangling information. This is - /// optimized for batch processing while populating a name index. To get the - /// pure demangled name string for a single entity, use GetDemangledName() - /// instead. + /// Get rich mangling information. This is optimized for batch processing + /// while populating a name index. To get the pure demangled name string for + /// a single entity, use GetDemangledName() instead. /// /// For names that match the Itanium mangling scheme, this uses LLVM's /// ItaniumPartialDemangler. All other names fall back to LLDB's builtin @@ -248,8 +247,8 @@ public: /// /// \return /// True on success, false otherwise. - bool DemangleWithRichManglingInfo(RichManglingContext &context, - SkipMangledNameFn *skip_mangled_name); + bool GetRichManglingInfo(RichManglingContext &context, + SkipMangledNameFn *skip_mangled_name); /// Try to identify the mangling scheme used. /// \param[in] name diff --git a/lldb/include/lldb/Core/RichManglingContext.h b/lldb/include/lldb/Core/RichManglingContext.h index a6b7af8d8d7e..ecd11e93f044 100644 --- a/lldb/include/lldb/Core/RichManglingContext.h +++ b/lldb/include/lldb/Core/RichManglingContext.h @@ -43,25 +43,15 @@ public: bool IsCtorOrDtor() const; /// Get the base name of a function. This doesn't include trailing template - /// arguments, ie "a::b<int>" gives "b". The result will overwrite the - /// internal buffer. It can be obtained via GetBufferRef(). - void ParseFunctionBaseName(); + /// arguments, ie "a::b<int>" gives "b". + llvm::StringRef ParseFunctionBaseName(); /// Get the context name for a function. For "a::b::c", this function returns - /// "a::b". The result will overwrite the internal buffer. It can be obtained - /// via GetBufferRef(). - void ParseFunctionDeclContextName(); + /// "a::b". + llvm::StringRef ParseFunctionDeclContextName(); - /// Get the entire demangled name. The result will overwrite the internal - /// buffer. It can be obtained via GetBufferRef(). - void ParseFullName(); - - /// Obtain a StringRef to the internal buffer that holds the result of the - /// most recent ParseXy() operation. The next ParseXy() call invalidates it. - llvm::StringRef GetBufferRef() const { - assert(m_provider != None && "Initialize a provider first"); - return m_buffer; - } + /// Get the entire demangled name. + llvm::StringRef ParseFullName(); private: enum InfoProvider { None, ItaniumPartialDemangler, PluginCxxLanguage }; @@ -69,9 +59,6 @@ private: /// Selects the rich mangling info provider. InfoProvider m_provider = None; - /// Reference to the buffer used for results of ParseXy() operations. - llvm::StringRef m_buffer; - /// Members for ItaniumPartialDemangler llvm::ItaniumPartialDemangler m_ipd; /// Note: m_ipd_buf is a raw pointer due to being resized by realloc via @@ -93,7 +80,7 @@ private: void ResetProvider(InfoProvider new_provider); /// Uniform handling of string buffers for ItaniumPartialDemangler. - void processIPDStrResult(char *ipd_res, size_t res_len); + llvm::StringRef processIPDStrResult(char *ipd_res, size_t res_len); /// Cast the given parser to the given type. Ideally we would have a type /// trait to deduce \a ParserT from a given InfoProvider, but unfortunately we diff --git a/lldb/include/lldb/Target/Process.h b/lldb/include/lldb/Target/Process.h index 12ed1e09227c..7911dac40b70 100644 --- a/lldb/include/lldb/Target/Process.h +++ b/lldb/include/lldb/Target/Process.h @@ -1759,7 +1759,7 @@ public: /// /// If load_addr is within the address space the process has mapped /// range_info will be filled in with the start and end of that range as - /// well as the permissions for that range and range_info.GetMapped will + /// well as the permissions for that range and range_info. GetMapped will /// return true. /// /// If load_addr is outside any mapped region then range_info will have its @@ -1768,23 +1768,21 @@ public: /// there are no valid mapped ranges between load_addr and the end of the /// process address space. /// - /// GetMemoryRegionInfo will only return an error if it is unimplemented for - /// the current process. + /// GetMemoryRegionInfo calls DoGetMemoryRegionInfo. Override that function in + /// process subclasses. /// /// \param[in] load_addr - /// The load address to query the range_info for. + /// The load address to query the range_info for. May include non + /// address bits, these will be removed by the the ABI plugin if there is + /// one. /// /// \param[out] range_info /// An range_info value containing the details of the range. /// /// \return /// An error value. - virtual Status GetMemoryRegionInfo(lldb::addr_t load_addr, - MemoryRegionInfo &range_info) { - Status error; - error.SetErrorString("Process::GetMemoryRegionInfo() not supported"); - return error; - } + Status GetMemoryRegionInfo(lldb::addr_t load_addr, + MemoryRegionInfo &range_info); /// Obtain all the mapped memory regions within this process. /// @@ -2604,6 +2602,26 @@ protected: virtual size_t DoReadMemory(lldb::addr_t vm_addr, void *buf, size_t size, Status &error) = 0; + /// DoGetMemoryRegionInfo is called by GetMemoryRegionInfo after it has + /// removed non address bits from load_addr. Override this method in + /// subclasses of Process. + /// + /// See GetMemoryRegionInfo for details of the logic. + /// + /// \param[in] load_addr + /// The load address to query the range_info for. (non address bits + /// removed) + /// + /// \param[out] range_info + /// An range_info value containing the details of the range. + /// + /// \return + /// An error value. + virtual Status DoGetMemoryRegionInfo(lldb::addr_t load_addr, + MemoryRegionInfo &range_info) { + return Status("Process::DoGetMemoryRegionInfo() not supported"); + } + lldb::StateType GetPrivateState(); /// The "private" side of resuming a process. This doesn't alter the state diff --git a/lldb/source/Commands/CommandObjectMemory.cpp b/lldb/source/Commands/CommandObjectMemory.cpp index 1b44a1bd709a..1033d13f9f26 100644 --- a/lldb/source/Commands/CommandObjectMemory.cpp +++ b/lldb/source/Commands/CommandObjectMemory.cpp @@ -1665,14 +1665,11 @@ protected: m_prev_end_addr = LLDB_INVALID_ADDRESS; const size_t argc = command.GetArgumentCount(); - if (argc > 1 || (argc == 0 && load_addr == LLDB_INVALID_ADDRESS)) { - result.AppendErrorWithFormat("'%s' takes one argument:\nUsage: %s\n", - m_cmd_name.c_str(), m_cmd_syntax.c_str()); - return false; - } + const lldb::ABISP &abi = process_sp->GetABI(); if (argc == 1) { auto load_addr_str = command[0].ref(); + // Non-address bits in this will be handled later by GetMemoryRegion load_addr = OptionArgParser::ToAddress(&m_exe_ctx, load_addr_str, LLDB_INVALID_ADDRESS, &error); if (error.Fail() || load_addr == LLDB_INVALID_ADDRESS) { @@ -1680,6 +1677,19 @@ protected: command[0].c_str(), error.AsCString()); return false; } + } else if (argc > 1 || + // When we're repeating the command, the previous end address is + // used for load_addr. If that was 0xF...F then we must have + // reached the end of memory. + (argc == 0 && load_addr == LLDB_INVALID_ADDRESS) || + // If the target has non-address bits (tags, limited virtual + // address size, etc.), the end of mappable memory will be lower + // than that. So if we find any non-address bit set, we must be + // at the end of the mappable range. + (abi && (abi->FixDataAddress(load_addr) != load_addr))) { + result.AppendErrorWithFormat("'%s' takes one argument:\nUsage: %s\n", + m_cmd_name.c_str(), m_cmd_syntax.c_str()); + return false; } lldb_private::MemoryRegionInfo range_info; diff --git a/lldb/source/Commands/CommandObjectThread.cpp b/lldb/source/Commands/CommandObjectThread.cpp index 137aaa81c61a..f6042937a4ff 100644 --- a/lldb/source/Commands/CommandObjectThread.cpp +++ b/lldb/source/Commands/CommandObjectThread.cpp @@ -1320,6 +1320,53 @@ public: } }; +class CommandObjectThreadSiginfo : public CommandObjectIterateOverThreads { +public: + CommandObjectThreadSiginfo(CommandInterpreter &interpreter) + : CommandObjectIterateOverThreads( + interpreter, "thread siginfo", + "Display the current siginfo object for a thread. Defaults to " + "the current thread.", + "thread siginfo", + eCommandRequiresProcess | eCommandTryTargetAPILock | + eCommandProcessMustBeLaunched | eCommandProcessMustBePaused) {} + + ~CommandObjectThreadSiginfo() override = default; + + void + HandleArgumentCompletion(CompletionRequest &request, + OptionElementVector &opt_element_vector) override { + CommandCompletions::InvokeCommonCompletionCallbacks( + GetCommandInterpreter(), CommandCompletions::eThreadIndexCompletion, + request, nullptr); + } + + bool HandleOneThread(lldb::tid_t tid, CommandReturnObject &result) override { + ThreadSP thread_sp = + m_exe_ctx.GetProcessPtr()->GetThreadList().FindThreadByID(tid); + if (!thread_sp) { + result.AppendErrorWithFormat("thread no longer exists: 0x%" PRIx64 "\n", + tid); + return false; + } + + Stream &strm = result.GetOutputStream(); + if (!thread_sp->GetDescription(strm, eDescriptionLevelFull, false, false)) { + result.AppendErrorWithFormat("error displaying info for thread: \"%d\"\n", + thread_sp->GetIndexID()); + return false; + } + ValueObjectSP exception_object_sp = thread_sp->GetSiginfoValue(); + if (exception_object_sp) + exception_object_sp->Dump(strm); + else + strm.Printf("(no siginfo)\n"); + strm.PutChar('\n'); + + return true; + } +}; + // CommandObjectThreadReturn #define LLDB_OPTIONS_thread_return #include "CommandOptions.inc" @@ -2293,6 +2340,8 @@ CommandObjectMultiwordThread::CommandObjectMultiwordThread( CommandObjectSP(new CommandObjectThreadInfo(interpreter))); LoadSubCommand("exception", CommandObjectSP(new CommandObjectThreadException( interpreter))); + LoadSubCommand("siginfo", + CommandObjectSP(new CommandObjectThreadSiginfo(interpreter))); LoadSubCommand("step-in", CommandObjectSP(new CommandObjectThreadStepWithTypeAndScope( interpreter, "thread step-in", diff --git a/lldb/source/Core/Mangled.cpp b/lldb/source/Core/Mangled.cpp index 4e10324401dc..b8e405544b33 100644 --- a/lldb/source/Core/Mangled.cpp +++ b/lldb/source/Core/Mangled.cpp @@ -195,8 +195,8 @@ static char *GetDLangDemangledStr(const char *M) { // Explicit demangling for scheduled requests during batch processing. This // makes use of ItaniumPartialDemangler's rich demangle info -bool Mangled::DemangleWithRichManglingInfo( - RichManglingContext &context, SkipMangledNameFn *skip_mangled_name) { +bool Mangled::GetRichManglingInfo(RichManglingContext &context, + SkipMangledNameFn *skip_mangled_name) { // Others are not meant to arrive here. ObjC names or C's main() for example // have their names stored in m_demangled, while m_mangled is empty. assert(m_mangled); @@ -214,25 +214,16 @@ bool Mangled::DemangleWithRichManglingInfo( case eManglingSchemeItanium: // We want the rich mangling info here, so we don't care whether or not // there is a demangled string in the pool already. - if (context.FromItaniumName(m_mangled)) { - // If we got an info, we have a name. Copy to string pool and connect the - // counterparts to accelerate later access in GetDemangledName(). - context.ParseFullName(); - m_demangled.SetStringWithMangledCounterpart(context.GetBufferRef(), - m_mangled); - return true; - } else { - m_demangled.SetCString(""); - return false; - } + return context.FromItaniumName(m_mangled); case eManglingSchemeMSVC: { // We have no rich mangling for MSVC-mangled names yet, so first try to // demangle it if necessary. if (!m_demangled && !m_mangled.GetMangledCounterpart(m_demangled)) { if (char *d = GetMSVCDemangledStr(m_mangled.GetCString())) { - // If we got an info, we have a name. Copy to string pool and connect - // the counterparts to accelerate later access in GetDemangledName(). + // Without the rich mangling info we have to demangle the full name. + // Copy it to string pool and connect the counterparts to accelerate + // later access in GetDemangledName(). m_demangled.SetStringWithMangledCounterpart(llvm::StringRef(d), m_mangled); ::free(d); diff --git a/lldb/source/Core/RichManglingContext.cpp b/lldb/source/Core/RichManglingContext.cpp index 63170feb6231..cecb5c6a2e54 100644 --- a/lldb/source/Core/RichManglingContext.cpp +++ b/lldb/source/Core/RichManglingContext.cpp @@ -83,15 +83,15 @@ bool RichManglingContext::IsCtorOrDtor() const { llvm_unreachable("Fully covered switch above!"); } -void RichManglingContext::processIPDStrResult(char *ipd_res, size_t res_size) { +llvm::StringRef RichManglingContext::processIPDStrResult(char *ipd_res, + size_t res_size) { // Error case: Clear the buffer. if (LLVM_UNLIKELY(ipd_res == nullptr)) { assert(res_size == m_ipd_buf_size && "Failed IPD queries keep the original size in the N parameter"); m_ipd_buf[0] = '\0'; - m_buffer = llvm::StringRef(m_ipd_buf, 0); - return; + return llvm::StringRef(m_ipd_buf, 0); } // IPD's res_size includes null terminator. @@ -109,60 +109,54 @@ void RichManglingContext::processIPDStrResult(char *ipd_res, size_t res_size) { } // 99% case: Just remember the string length. - m_buffer = llvm::StringRef(m_ipd_buf, res_size - 1); + return llvm::StringRef(m_ipd_buf, res_size - 1); } -void RichManglingContext::ParseFunctionBaseName() { +llvm::StringRef RichManglingContext::ParseFunctionBaseName() { assert(m_provider != None && "Initialize a provider first"); switch (m_provider) { case ItaniumPartialDemangler: { auto n = m_ipd_buf_size; auto buf = m_ipd.getFunctionBaseName(m_ipd_buf, &n); - processIPDStrResult(buf, n); - return; + return processIPDStrResult(buf, n); } case PluginCxxLanguage: - m_buffer = - get<CPlusPlusLanguage::MethodName>(m_cxx_method_parser)->GetBasename(); - return; + return get<CPlusPlusLanguage::MethodName>(m_cxx_method_parser) + ->GetBasename(); case None: - return; + return {}; } } -void RichManglingContext::ParseFunctionDeclContextName() { +llvm::StringRef RichManglingContext::ParseFunctionDeclContextName() { assert(m_provider != None && "Initialize a provider first"); switch (m_provider) { case ItaniumPartialDemangler: { auto n = m_ipd_buf_size; auto buf = m_ipd.getFunctionDeclContextName(m_ipd_buf, &n); - processIPDStrResult(buf, n); - return; + return processIPDStrResult(buf, n); } case PluginCxxLanguage: - m_buffer = - get<CPlusPlusLanguage::MethodName>(m_cxx_method_parser)->GetContext(); - return; + return get<CPlusPlusLanguage::MethodName>(m_cxx_method_parser) + ->GetContext(); case None: - return; + return {}; } } -void RichManglingContext::ParseFullName() { +llvm::StringRef RichManglingContext::ParseFullName() { assert(m_provider != None && "Initialize a provider first"); switch (m_provider) { case ItaniumPartialDemangler: { auto n = m_ipd_buf_size; auto buf = m_ipd.finishDemangle(m_ipd_buf, &n); - processIPDStrResult(buf, n); - return; + return processIPDStrResult(buf, n); } case PluginCxxLanguage: - m_buffer = get<CPlusPlusLanguage::MethodName>(m_cxx_method_parser) - ->GetFullName() - .GetStringRef(); - return; + return get<CPlusPlusLanguage::MethodName>(m_cxx_method_parser) + ->GetFullName() + .GetStringRef(); case None: - return; + return {}; } } diff --git a/lldb/source/Plugins/InstrumentationRuntime/ASan/InstrumentationRuntimeASan.cpp b/lldb/source/Plugins/InstrumentationRuntime/ASan/InstrumentationRuntimeASan.cpp index 8d8b5c68e41b..33b2b5dd5155 100644 --- a/lldb/source/Plugins/InstrumentationRuntime/ASan/InstrumentationRuntimeASan.cpp +++ b/lldb/source/Plugins/InstrumentationRuntime/ASan/InstrumentationRuntimeASan.cpp @@ -281,7 +281,7 @@ void InstrumentationRuntimeASan::Activate() { if (!process_sp) return; - ConstString symbol_name("__asan::AsanDie()"); + ConstString symbol_name("_ZN6__asanL7AsanDieEv"); const Symbol *symbol = GetRuntimeModuleSP()->FindFirstSymbolWithNameAndType( symbol_name, eSymbolTypeCode); diff --git a/lldb/source/Plugins/Process/elf-core/ProcessElfCore.cpp b/lldb/source/Plugins/Process/elf-core/ProcessElfCore.cpp index 65dbc8ea95b3..043544f05665 100644 --- a/lldb/source/Plugins/Process/elf-core/ProcessElfCore.cpp +++ b/lldb/source/Plugins/Process/elf-core/ProcessElfCore.cpp @@ -285,8 +285,8 @@ size_t ProcessElfCore::ReadMemory(lldb::addr_t addr, void *buf, size_t size, return DoReadMemory(addr, buf, size, error); } -Status ProcessElfCore::GetMemoryRegionInfo(lldb::addr_t load_addr, - MemoryRegionInfo ®ion_info) { +Status ProcessElfCore::DoGetMemoryRegionInfo(lldb::addr_t load_addr, + MemoryRegionInfo ®ion_info) { region_info.Clear(); const VMRangeToPermissions::Entry *permission_entry = m_core_range_infos.FindEntryThatContainsOrFollows(load_addr); diff --git a/lldb/source/Plugins/Process/elf-core/ProcessElfCore.h b/lldb/source/Plugins/Process/elf-core/ProcessElfCore.h index 67df3c5fac76..fd36e5027816 100644 --- a/lldb/source/Plugins/Process/elf-core/ProcessElfCore.h +++ b/lldb/source/Plugins/Process/elf-core/ProcessElfCore.h @@ -86,10 +86,6 @@ public: size_t DoReadMemory(lldb::addr_t addr, void *buf, size_t size, lldb_private::Status &error) override; - lldb_private::Status - GetMemoryRegionInfo(lldb::addr_t load_addr, - lldb_private::MemoryRegionInfo ®ion_info) override; - lldb::addr_t GetImageInfoAddress() override; lldb_private::ArchSpec GetArchitecture(); @@ -105,6 +101,10 @@ protected: bool DoUpdateThreadList(lldb_private::ThreadList &old_thread_list, lldb_private::ThreadList &new_thread_list) override; + lldb_private::Status + DoGetMemoryRegionInfo(lldb::addr_t load_addr, + lldb_private::MemoryRegionInfo ®ion_info) override; + private: struct NT_FILE_Entry { lldb::addr_t start; diff --git a/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp b/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp index 82357cd117d7..fee2071a0780 100644 --- a/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp +++ b/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp @@ -2962,8 +2962,8 @@ lldb::addr_t ProcessGDBRemote::DoAllocateMemory(size_t size, return allocated_addr; } -Status ProcessGDBRemote::GetMemoryRegionInfo(addr_t load_addr, - MemoryRegionInfo ®ion_info) { +Status ProcessGDBRemote::DoGetMemoryRegionInfo(addr_t load_addr, + MemoryRegionInfo ®ion_info) { Status error(m_gdb_comm.GetMemoryRegionInfo(load_addr, region_info)); return error; diff --git a/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.h b/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.h index bdf130e3ec11..dd907042608d 100644 --- a/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.h +++ b/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.h @@ -143,9 +143,6 @@ public: lldb::addr_t DoAllocateMemory(size_t size, uint32_t permissions, Status &error) override; - Status GetMemoryRegionInfo(lldb::addr_t load_addr, - MemoryRegionInfo ®ion_info) override; - Status DoDeallocateMemory(lldb::addr_t ptr) override; // Process STDIO @@ -415,6 +412,9 @@ protected: Status DoWriteMemoryTags(lldb::addr_t addr, size_t len, int32_t type, const std::vector<uint8_t> &tags) override; + Status DoGetMemoryRegionInfo(lldb::addr_t load_addr, + MemoryRegionInfo ®ion_info) override; + private: // For ProcessGDBRemote only std::string m_partial_profile_data; diff --git a/lldb/source/Plugins/Process/minidump/ProcessMinidump.cpp b/lldb/source/Plugins/Process/minidump/ProcessMinidump.cpp index 37ee5466c5b9..162697bed7e9 100644 --- a/lldb/source/Plugins/Process/minidump/ProcessMinidump.cpp +++ b/lldb/source/Plugins/Process/minidump/ProcessMinidump.cpp @@ -439,8 +439,8 @@ void ProcessMinidump::BuildMemoryRegions() { llvm::sort(*m_memory_regions); } -Status ProcessMinidump::GetMemoryRegionInfo(lldb::addr_t load_addr, - MemoryRegionInfo ®ion) { +Status ProcessMinidump::DoGetMemoryRegionInfo(lldb::addr_t load_addr, + MemoryRegionInfo ®ion) { BuildMemoryRegions(); region = MinidumpParser::GetMemoryRegionInfo(*m_memory_regions, load_addr); return Status(); diff --git a/lldb/source/Plugins/Process/minidump/ProcessMinidump.h b/lldb/source/Plugins/Process/minidump/ProcessMinidump.h index 3501d38a0f27..5360269199cd 100644 --- a/lldb/source/Plugins/Process/minidump/ProcessMinidump.h +++ b/lldb/source/Plugins/Process/minidump/ProcessMinidump.h @@ -75,9 +75,6 @@ public: ArchSpec GetArchitecture(); - Status GetMemoryRegionInfo(lldb::addr_t load_addr, - MemoryRegionInfo &range_info) override; - Status GetMemoryRegions( lldb_private::MemoryRegionInfos ®ion_list) override; @@ -98,6 +95,9 @@ protected: bool DoUpdateThreadList(ThreadList &old_thread_list, ThreadList &new_thread_list) override; + Status DoGetMemoryRegionInfo(lldb::addr_t load_addr, + MemoryRegionInfo &range_info) override; + void ReadModuleList(); lldb::ModuleSP GetOrCreateModule(lldb_private::UUID minidump_uuid, diff --git a/lldb/source/Plugins/Process/scripted/ScriptedProcess.cpp b/lldb/source/Plugins/Process/scripted/ScriptedProcess.cpp index 5eb7cb0e6a5c..c231ea6b0d10 100644 --- a/lldb/source/Plugins/Process/scripted/ScriptedProcess.cpp +++ b/lldb/source/Plugins/Process/scripted/ScriptedProcess.cpp @@ -245,8 +245,8 @@ ArchSpec ScriptedProcess::GetArchitecture() { return GetTarget().GetArchitecture(); } -Status ScriptedProcess::GetMemoryRegionInfo(lldb::addr_t load_addr, - MemoryRegionInfo ®ion) { +Status ScriptedProcess::DoGetMemoryRegionInfo(lldb::addr_t load_addr, + MemoryRegionInfo ®ion) { CheckInterpreterAndScriptObject(); Status error; diff --git a/lldb/source/Plugins/Process/scripted/ScriptedProcess.h b/lldb/source/Plugins/Process/scripted/ScriptedProcess.h index d56658a2e48a..c8355f35548a 100644 --- a/lldb/source/Plugins/Process/scripted/ScriptedProcess.h +++ b/lldb/source/Plugins/Process/scripted/ScriptedProcess.h @@ -84,9 +84,6 @@ public: ArchSpec GetArchitecture(); - Status GetMemoryRegionInfo(lldb::addr_t load_addr, - MemoryRegionInfo &range_info) override; - Status GetMemoryRegions(lldb_private::MemoryRegionInfos ®ion_list) override; @@ -100,6 +97,9 @@ protected: bool DoUpdateThreadList(ThreadList &old_thread_list, ThreadList &new_thread_list) override; + Status DoGetMemoryRegionInfo(lldb::addr_t load_addr, + MemoryRegionInfo &range_info) override; + private: friend class ScriptedThread; diff --git a/lldb/source/Symbol/Symtab.cpp b/lldb/source/Symbol/Symtab.cpp index 97dc31bc9766..d148706003ad 100644 --- a/lldb/source/Symbol/Symtab.cpp +++ b/lldb/source/Symbol/Symtab.cpp @@ -328,8 +328,10 @@ void Symtab::InitNameIndexes() { const SymbolType type = symbol->GetType(); if (type == eSymbolTypeCode || type == eSymbolTypeResolver) { - if (mangled.DemangleWithRichManglingInfo(rmc, lldb_skip_name)) + if (mangled.GetRichManglingInfo(rmc, lldb_skip_name)) { RegisterMangledNameEntry(value, class_contexts, backlog, rmc); + continue; + } } } @@ -383,16 +385,13 @@ void Symtab::RegisterMangledNameEntry( std::vector<std::pair<NameToIndexMap::Entry, const char *>> &backlog, RichManglingContext &rmc) { // Only register functions that have a base name. - rmc.ParseFunctionBaseName(); - llvm::StringRef base_name = rmc.GetBufferRef(); + llvm::StringRef base_name = rmc.ParseFunctionBaseName(); if (base_name.empty()) return; // The base name will be our entry's name. NameToIndexMap::Entry entry(ConstString(base_name), value); - - rmc.ParseFunctionDeclContextName(); - llvm::StringRef decl_context = rmc.GetBufferRef(); + llvm::StringRef decl_context = rmc.ParseFunctionDeclContextName(); // Register functions with no context. if (decl_context.empty()) { diff --git a/lldb/source/Target/Process.cpp b/lldb/source/Target/Process.cpp index 94f378886e50..6a306ab762da 100644 --- a/lldb/source/Target/Process.cpp +++ b/lldb/source/Target/Process.cpp @@ -5853,12 +5853,18 @@ Process::AdvanceAddressToNextBranchInstruction(Address default_stop_addr, return retval; } -Status -Process::GetMemoryRegions(lldb_private::MemoryRegionInfos ®ion_list) { +Status Process::GetMemoryRegionInfo(lldb::addr_t load_addr, + MemoryRegionInfo &range_info) { + if (const lldb::ABISP &abi = GetABI()) + load_addr = abi->FixDataAddress(load_addr); + return DoGetMemoryRegionInfo(load_addr, range_info); +} +Status Process::GetMemoryRegions(lldb_private::MemoryRegionInfos ®ion_list) { Status error; lldb::addr_t range_end = 0; + const lldb::ABISP &abi = GetABI(); region_list.clear(); do { @@ -5870,11 +5876,22 @@ Process::GetMemoryRegions(lldb_private::MemoryRegionInfos ®ion_list) { break; } + // We only check the end address, not start and end, because we assume that + // the start will not have non-address bits until the first unmappable + // region. We will have exited the loop by that point because the previous + // region, the last mappable region, will have non-address bits in its end + // address. range_end = region_info.GetRange().GetRangeEnd(); if (region_info.GetMapped() == MemoryRegionInfo::eYes) { region_list.push_back(std::move(region_info)); } - } while (range_end != LLDB_INVALID_ADDRESS); + } while ( + // For a process with no non-address bits, all address bits + // set means the end of memory. + range_end != LLDB_INVALID_ADDRESS && + // If we have non-address bits and some are set then the end + // is at or beyond the end of mappable memory. + !(abi && (abi->FixDataAddress(range_end) != range_end))); return error; } |
