diff options
author | Zequan Wu <zequanwu@google.com> | 2022-02-16 11:18:54 -0800 |
---|---|---|
committer | Zequan Wu <zequanwu@google.com> | 2022-03-02 13:44:19 -0800 |
commit | 15983c28aa819031e08a2b3fe49d02c41839b22c (patch) | |
tree | a7a04167ef981db6da7314da3883ea3cfc03b56e /lldb/source/Commands/CommandObjectTarget.cpp | |
parent | c33dbc2a2dfcdaed22f156efdc38e4ff215c972f (diff) | |
download | llvm-15983c28aa819031e08a2b3fe49d02c41839b22c.zip llvm-15983c28aa819031e08a2b3fe49d02c41839b22c.tar.gz llvm-15983c28aa819031e08a2b3fe49d02c41839b22c.tar.bz2 |
[LLDB] Dump valid ranges of variables
This allows `image lookup -a ... -v` to print variables only if the given
address is covered by the valid ranges of the variables. Since variables created
in dwarf plugin always has empty scope range, print the variable if it has
empty scope.
Differential Revision: https://reviews.llvm.org/D119963
Diffstat (limited to 'lldb/source/Commands/CommandObjectTarget.cpp')
-rw-r--r-- | lldb/source/Commands/CommandObjectTarget.cpp | 45 |
1 files changed, 29 insertions, 16 deletions
diff --git a/lldb/source/Commands/CommandObjectTarget.cpp b/lldb/source/Commands/CommandObjectTarget.cpp index 38aa841..3af2c73 100644 --- a/lldb/source/Commands/CommandObjectTarget.cpp +++ b/lldb/source/Commands/CommandObjectTarget.cpp @@ -50,6 +50,7 @@ #include "lldb/Utility/LLDBLog.h" #include "lldb/Utility/State.h" #include "lldb/Utility/Timer.h" +#include "lldb/lldb-private-enumerations.h" #include "llvm/ADT/ScopeExit.h" #include "llvm/Support/FileSystem.h" @@ -1429,7 +1430,8 @@ static bool DumpModuleSymbolFile(Stream &strm, Module *module) { } static void DumpAddress(ExecutionContextScope *exe_scope, - const Address &so_addr, bool verbose, Stream &strm) { + const Address &so_addr, bool verbose, bool all_ranges, + Stream &strm) { strm.IndentMore(); strm.Indent(" Address: "); so_addr.Dump(&strm, exe_scope, Address::DumpStyleModuleWithFileAddress); @@ -1444,7 +1446,8 @@ static void DumpAddress(ExecutionContextScope *exe_scope, // Print out detailed address information when verbose is enabled if (verbose) { strm.EOL(); - so_addr.Dump(&strm, exe_scope, Address::DumpStyleDetailedSymbolContext); + so_addr.Dump(&strm, exe_scope, Address::DumpStyleDetailedSymbolContext, + Address::DumpStyleInvalid, UINT32_MAX, all_ranges); } strm.IndentLess(); } @@ -1452,7 +1455,7 @@ static void DumpAddress(ExecutionContextScope *exe_scope, static bool LookupAddressInModule(CommandInterpreter &interpreter, Stream &strm, Module *module, uint32_t resolve_mask, lldb::addr_t raw_addr, lldb::addr_t offset, - bool verbose) { + bool verbose, bool all_ranges) { if (module) { lldb::addr_t addr = raw_addr - offset; Address so_addr; @@ -1470,7 +1473,7 @@ static bool LookupAddressInModule(CommandInterpreter &interpreter, Stream &strm, ExecutionContextScope *exe_scope = interpreter.GetExecutionContext().GetBestExecutionContextScope(); - DumpAddress(exe_scope, so_addr, verbose, strm); + DumpAddress(exe_scope, so_addr, verbose, all_ranges, strm); // strm.IndentMore(); // strm.Indent (" Address: "); // so_addr.Dump (&strm, exe_scope, @@ -1502,7 +1505,7 @@ static bool LookupAddressInModule(CommandInterpreter &interpreter, Stream &strm, static uint32_t LookupSymbolInModule(CommandInterpreter &interpreter, Stream &strm, Module *module, const char *name, bool name_is_regex, - bool verbose) { + bool verbose, bool all_ranges) { if (!module) return 0; @@ -1535,7 +1538,7 @@ static uint32_t LookupSymbolInModule(CommandInterpreter &interpreter, if (symbol && symbol->ValueIsAddress()) { DumpAddress( interpreter.GetExecutionContext().GetBestExecutionContextScope(), - symbol->GetAddressRef(), verbose, strm); + symbol->GetAddressRef(), verbose, all_ranges, strm); } } strm.IndentLess(); @@ -1545,7 +1548,7 @@ static uint32_t LookupSymbolInModule(CommandInterpreter &interpreter, static void DumpSymbolContextList(ExecutionContextScope *exe_scope, Stream &strm, SymbolContextList &sc_list, - bool verbose) { + bool verbose, bool all_ranges) { strm.IndentMore(); const uint32_t num_matches = sc_list.GetSize(); @@ -1557,7 +1560,7 @@ static void DumpSymbolContextList(ExecutionContextScope *exe_scope, sc.GetAddressRange(eSymbolContextEverything, 0, true, range); - DumpAddress(exe_scope, range.GetBaseAddress(), verbose, strm); + DumpAddress(exe_scope, range.GetBaseAddress(), verbose, all_ranges, strm); } } strm.IndentLess(); @@ -1567,7 +1570,7 @@ static size_t LookupFunctionInModule(CommandInterpreter &interpreter, Stream &strm, Module *module, const char *name, bool name_is_regex, const ModuleFunctionSearchOptions &options, - bool verbose) { + bool verbose, bool all_ranges) { if (module && name && name[0]) { SymbolContextList sc_list; size_t num_matches = 0; @@ -1588,7 +1591,7 @@ static size_t LookupFunctionInModule(CommandInterpreter &interpreter, strm.PutCString(":\n"); DumpSymbolContextList( interpreter.GetExecutionContext().GetBestExecutionContextScope(), - strm, sc_list, verbose); + strm, sc_list, verbose, all_ranges); } return num_matches; } @@ -1693,7 +1696,7 @@ static uint32_t LookupFileAndLineInModule(CommandInterpreter &interpreter, Stream &strm, Module *module, const FileSpec &file_spec, uint32_t line, bool check_inlines, - bool verbose) { + bool verbose, bool all_ranges) { if (module && file_spec) { SymbolContextList sc_list; const uint32_t num_matches = module->ResolveSymbolContextsForFileSpec( @@ -1710,7 +1713,7 @@ static uint32_t LookupFileAndLineInModule(CommandInterpreter &interpreter, strm.PutCString(":\n"); DumpSymbolContextList( interpreter.GetExecutionContext().GetBestExecutionContextScope(), - strm, sc_list, verbose); + strm, sc_list, verbose, all_ranges); return num_matches; } } @@ -3598,6 +3601,10 @@ public: case 'r': m_use_regex = true; break; + + case '\x01': + m_all_ranges = true; + break; default: llvm_unreachable("Unimplemented option"); } @@ -3614,6 +3621,7 @@ public: m_line_number = 0; m_use_regex = false; m_include_inlines = true; + m_all_ranges = false; m_verbose = false; m_print_all = false; } @@ -3632,6 +3640,7 @@ public: bool m_use_regex; // Name lookups in m_str are regular expressions. bool m_include_inlines; // Check for inline entries when looking up by // file/line. + bool m_all_ranges; // Print all ranges or single range. bool m_verbose; // Enable verbose lookup info bool m_print_all; // Print all matches, even in cases where there's a best // match. @@ -3714,7 +3723,8 @@ public: (m_options.m_verbose ? static_cast<int>(eSymbolContextVariable) : 0), - m_options.m_addr, m_options.m_offset, m_options.m_verbose)) { + m_options.m_addr, m_options.m_offset, m_options.m_verbose, + m_options.m_all_ranges)) { result.SetStatus(eReturnStatusSuccessFinishResult); return true; } @@ -3725,7 +3735,8 @@ public: if (!m_options.m_str.empty()) { if (LookupSymbolInModule(m_interpreter, result.GetOutputStream(), module, m_options.m_str.c_str(), - m_options.m_use_regex, m_options.m_verbose)) { + m_options.m_use_regex, m_options.m_verbose, + m_options.m_all_ranges)) { result.SetStatus(eReturnStatusSuccessFinishResult); return true; } @@ -3737,7 +3748,8 @@ public: if (LookupFileAndLineInModule( m_interpreter, result.GetOutputStream(), module, m_options.m_file, m_options.m_line_number, - m_options.m_include_inlines, m_options.m_verbose)) { + m_options.m_include_inlines, m_options.m_verbose, + m_options.m_all_ranges)) { result.SetStatus(eReturnStatusSuccessFinishResult); return true; } @@ -3755,7 +3767,8 @@ public: if (LookupFunctionInModule(m_interpreter, result.GetOutputStream(), module, m_options.m_str.c_str(), m_options.m_use_regex, function_options, - m_options.m_verbose)) { + m_options.m_verbose, + m_options.m_all_ranges)) { result.SetStatus(eReturnStatusSuccessFinishResult); return true; } |