diff options
author | Dimitry Andric <dim@FreeBSD.org> | 2020-01-23 21:36:25 +0000 |
---|---|---|
committer | Dimitry Andric <dim@FreeBSD.org> | 2020-01-23 21:36:25 +0000 |
commit | 9dba64be9536c28e4800e06512b7f29b43ade345 (patch) | |
tree | 7f0f30947225ecb30ab0fdae8059a936537b0dfe /contrib/llvm-project/lldb/source/Core/Address.cpp | |
parent | 85868e8a1daeaae7a0e48effb2ea2310ae3b02c6 (diff) | |
parent | ead246455adf1a215ec2715dad6533073a6beb4e (diff) |
Notes
Diffstat (limited to 'contrib/llvm-project/lldb/source/Core/Address.cpp')
-rw-r--r-- | contrib/llvm-project/lldb/source/Core/Address.cpp | 55 |
1 files changed, 34 insertions, 21 deletions
diff --git a/contrib/llvm-project/lldb/source/Core/Address.cpp b/contrib/llvm-project/lldb/source/Core/Address.cpp index 0da83eb98edb..a3912bef5a6e 100644 --- a/contrib/llvm-project/lldb/source/Core/Address.cpp +++ b/contrib/llvm-project/lldb/source/Core/Address.cpp @@ -261,6 +261,24 @@ bool Address::ResolveAddressUsingFileSections(addr_t file_addr, return false; // Failed to resolve this address to a section offset value } +/// if "addr_range_ptr" is not NULL, then fill in with the address range of the function. +bool Address::ResolveFunctionScope(SymbolContext &sym_ctx, + AddressRange *addr_range_ptr) { + constexpr SymbolContextItem resolve_scope = + eSymbolContextFunction | eSymbolContextSymbol; + + if (!(CalculateSymbolContext(&sym_ctx, resolve_scope) & resolve_scope)) { + if (addr_range_ptr) + addr_range_ptr->Clear(); + return false; + } + + if (!addr_range_ptr) + return true; + + return sym_ctx.GetAddressRange(resolve_scope, 0, false, *addr_range_ptr); +} + ModuleSP Address::GetModule() const { lldb::ModuleSP module_sp; SectionSP section_sp(GetSection()); @@ -475,23 +493,19 @@ bool Address::Dump(Stream *s, ExecutionContextScope *exe_scope, DumpStyle style, switch (sect_type) { case eSectionTypeData: if (module_sp) { - SymbolVendor *sym_vendor = module_sp->GetSymbolVendor(); - if (sym_vendor) { - Symtab *symtab = sym_vendor->GetSymtab(); - if (symtab) { - const addr_t file_Addr = GetFileAddress(); - Symbol *symbol = - symtab->FindSymbolContainingFileAddress(file_Addr); - if (symbol) { - const char *symbol_name = symbol->GetName().AsCString(); - if (symbol_name) { - s->PutCString(symbol_name); - addr_t delta = - file_Addr - symbol->GetAddressRef().GetFileAddress(); - if (delta) - s->Printf(" + %" PRIu64, delta); - showed_info = true; - } + if (Symtab *symtab = module_sp->GetSymtab()) { + const addr_t file_Addr = GetFileAddress(); + Symbol *symbol = + symtab->FindSymbolContainingFileAddress(file_Addr); + if (symbol) { + const char *symbol_name = symbol->GetName().AsCString(); + if (symbol_name) { + s->PutCString(symbol_name); + addr_t delta = + file_Addr - symbol->GetAddressRef().GetFileAddress(); + if (delta) + s->Printf(" + %" PRIu64, delta); + showed_info = true; } } } @@ -985,10 +999,9 @@ AddressClass Address::GetAddressClass() const { if (module_sp) { ObjectFile *obj_file = module_sp->GetObjectFile(); if (obj_file) { - // Give the symbol vendor a chance to add to the unified section list - // and to symtab from symbol file - if (SymbolVendor *vendor = module_sp->GetSymbolVendor()) - vendor->GetSymtab(); + // Give the symbol file a chance to add to the unified section list + // and to the symtab. + module_sp->GetSymtab(); return obj_file->GetAddressClass(GetFileAddress()); } } |