[Lldb-commits] [PATCH] D113163: [LLDB][Breakpad] Create a function for each compilation unit.
Zequan Wu via Phabricator via lldb-commits
lldb-commits at lists.llvm.org
Wed Nov 3 19:25:34 PDT 2021
zequanwu created this revision.
zequanwu added a reviewer: labath.
zequanwu requested review of this revision.
Herald added a reviewer: jdoerfert.
Herald added subscribers: lldb-commits, sstefan1.
Herald added a project: LLDB.
Since every FUNC record (in breakpad) is a compilation unit, creating the
function for the CU allows `ResolveSymbolContext` to resolve
`eSymbolContextFunction`.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D113163
Files:
lldb/source/Plugins/SymbolFile/Breakpad/SymbolFileBreakpad.cpp
lldb/source/Plugins/SymbolFile/Breakpad/SymbolFileBreakpad.h
lldb/test/Shell/SymbolFile/Breakpad/line-table.test
Index: lldb/test/Shell/SymbolFile/Breakpad/line-table.test
===================================================================
--- lldb/test/Shell/SymbolFile/Breakpad/line-table.test
+++ lldb/test/Shell/SymbolFile/Breakpad/line-table.test
@@ -42,4 +42,4 @@
breakpoint set -f c.c -l 2
# CHECK-LABEL: breakpoint set -f c.c -l 2
-# CHECK: Breakpoint 1: where = line-table.out`func + 2, address = 0x00000000004000b2
+# CHECK: Breakpoint 1: where = line-table.out`func + 2 at c.c:2, address = 0x00000000004000b2
Index: lldb/source/Plugins/SymbolFile/Breakpad/SymbolFileBreakpad.h
===================================================================
--- lldb/source/Plugins/SymbolFile/Breakpad/SymbolFileBreakpad.h
+++ lldb/source/Plugins/SymbolFile/Breakpad/SymbolFileBreakpad.h
@@ -63,6 +63,8 @@
return lldb::eLanguageTypeUnknown;
}
+ lldb::FunctionSP GetOrCreateFunction(CompileUnit &comp_unit);
+
size_t ParseFunctions(CompileUnit &comp_unit) override;
bool ParseLineTable(CompileUnit &comp_unit) override;
Index: lldb/source/Plugins/SymbolFile/Breakpad/SymbolFileBreakpad.cpp
===================================================================
--- lldb/source/Plugins/SymbolFile/Breakpad/SymbolFileBreakpad.cpp
+++ lldb/source/Plugins/SymbolFile/Breakpad/SymbolFileBreakpad.cpp
@@ -219,9 +219,40 @@
return cu_sp;
}
+FunctionSP SymbolFileBreakpad::GetOrCreateFunction(CompileUnit &comp_unit) {
+ user_id_t id = comp_unit.GetID();
+ if (FunctionSP func_sp = comp_unit.FindFunctionByUID(id))
+ return func_sp;
+
+ Log *log = GetLogIfAllCategoriesSet(LIBLLDB_LOG_SYMBOLS);
+ FunctionSP func_sp;
+ addr_t base = GetBaseFileAddress();
+ if (base == LLDB_INVALID_ADDRESS) {
+ LLDB_LOG(log, "Unable to fetch the base address of object file. Skipping "
+ "symtab population.");
+ return func_sp;
+ }
+
+ const SectionList *list = comp_unit.GetModule()->GetSectionList();
+ CompUnitData &data = m_cu_data->GetEntryRef(id).data;
+ LineIterator It(*m_objfile_sp, Record::Func, data.bookmark);
+ assert(Record::classify(*It) == Record::Func);
+
+ if (auto record = FuncRecord::parse(*It)) {
+ addr_t address = record->Address + base;
+ SectionSP section_sp = list->FindSectionContainingFileAddress(address);
+ AddressRange func_range(section_sp, address - section_sp->GetFileAddress(),
+ record->Size);
+ func_sp = std::make_shared<Function>(
+ &comp_unit, id, 0, Mangled(record->Name), nullptr, func_range);
+ comp_unit.AddFunction(func_sp);
+ }
+ return func_sp;
+}
+
size_t SymbolFileBreakpad::ParseFunctions(CompileUnit &comp_unit) {
- // TODO
- return 0;
+ std::lock_guard<std::recursive_mutex> guard(GetModuleMutex());
+ return GetOrCreateFunction(comp_unit) ? 1 : 0;
}
bool SymbolFileBreakpad::ParseLineTable(CompileUnit &comp_unit) {
@@ -251,7 +282,8 @@
SymbolContextItem resolve_scope,
SymbolContext &sc) {
std::lock_guard<std::recursive_mutex> guard(GetModuleMutex());
- if (!(resolve_scope & (eSymbolContextCompUnit | eSymbolContextLineEntry)))
+ if (!(resolve_scope & (eSymbolContextCompUnit | eSymbolContextLineEntry |
+ eSymbolContextFunction)))
return 0;
ParseCUData();
@@ -268,6 +300,13 @@
result |= eSymbolContextLineEntry;
}
}
+ if (resolve_scope & eSymbolContextFunction) {
+ FunctionSP func_sp = GetOrCreateFunction(*sc.comp_unit);
+ if (func_sp) {
+ sc.function = func_sp.get();
+ result |= eSymbolContextFunction;
+ }
+ }
return result;
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D113163.384638.patch
Type: text/x-patch
Size: 3638 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20211104/349b01dc/attachment.bin>
More information about the lldb-commits
mailing list