Skip to content

[lldb][Target] Refactor Target::FindLoadAddr #7544

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 0 additions & 8 deletions lldb/include/lldb/Target/Target.h
Original file line number Diff line number Diff line change
Expand Up @@ -1355,14 +1355,6 @@ class Target : public std::enable_shared_from_this<Target>,
const EvaluateExpressionOptions &options = EvaluateExpressionOptions(),
std::string *fixed_expression = nullptr, ValueObject *ctx_obj = nullptr);

// Look up a symbol by name and type in both the target's symbols and the
// persistent symbols from the
// expression parser. The symbol_type is ignored in that case, for now we
// don't have symbol types for the
// persistent variables.
lldb::addr_t FindLoadAddrForNameInSymbolsAndPersistentVariables(
ConstString name_const_str, lldb::SymbolType symbol_type);

lldb::ExpressionVariableSP GetPersistentVariable(ConstString name);

lldb::addr_t GetPersistentSymbol(ConstString name);
Expand Down
46 changes: 0 additions & 46 deletions lldb/source/Target/Target.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3693,52 +3693,6 @@ bool Target::SetSectionUnloaded(const lldb::SectionSP &section_sp,

void Target::ClearAllLoadedSections() { m_section_load_history.Clear(); }

lldb::addr_t Target::FindLoadAddrForNameInSymbolsAndPersistentVariables(
ConstString name_const_str, SymbolType symbol_type) {
lldb::addr_t symbol_addr = LLDB_INVALID_ADDRESS;
SymbolContextList sc_list;

GetImages().FindSymbolsWithNameAndType(name_const_str, symbol_type, sc_list);
if (!sc_list.IsEmpty()) {
SymbolContext desired_symbol;

if (sc_list.GetSize() == 1 &&
sc_list.GetContextAtIndex(0, desired_symbol)) {
if (desired_symbol.symbol) {
symbol_addr = desired_symbol.symbol->GetAddress().GetLoadAddress(this);
}
} else if (sc_list.GetSize() > 1) {
for (size_t i = 0; i < sc_list.GetSize(); i++) {
if (sc_list.GetContextAtIndex(i, desired_symbol)) {
if (desired_symbol.symbol) {
symbol_addr =
desired_symbol.symbol->GetAddress().GetLoadAddress(this);
if (symbol_addr != LLDB_INVALID_ADDRESS)
break;
}
}
}
}
}

if (symbol_addr == LLDB_INVALID_ADDRESS) {
// If we didn't find it in the symbols, check the ClangPersistentVariables,
// 'cause we may have
// made it by hand.
ConstString mangled_const_str;
if (name_const_str.GetMangledCounterpart(mangled_const_str))
symbol_addr = GetPersistentSymbol(mangled_const_str);
}

if (symbol_addr == LLDB_INVALID_ADDRESS) {
// Let's try looking for the name passed-in itself, as it might be a mangled
// name
symbol_addr = GetPersistentSymbol(name_const_str);
}

return symbol_addr;
}

void Target::SaveScriptedLaunchInfo(lldb_private::ProcessInfo &process_info) {
if (process_info.IsScriptedProcess()) {
// Only copy scripted process launch options.
Expand Down