Skip to content

Commit e018988

Browse files
committed
[rebranch][lldb] Use front-loaded function address range
c1055f0 now passes in a valid `lldb_private::AddressRange` rather than implementations needing to query for it.
1 parent 0539008 commit e018988

File tree

2 files changed

+44
-56
lines changed

2 files changed

+44
-56
lines changed

lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserSwift.cpp

Lines changed: 42 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,10 @@ lldb::TypeSP DWARFASTParserSwift::ParseTypeFromDWARF(const SymbolContext &sc,
212212
}
213213

214214
Function *DWARFASTParserSwift::ParseFunctionFromDWARF(
215-
lldb_private::CompileUnit &comp_unit, const DWARFDIE &die) {
215+
lldb_private::CompileUnit &comp_unit, const DWARFDIE &die,
216+
const lldb_private::AddressRange &func_range) {
217+
assert(func_range.GetBaseAddress().IsValid());
218+
216219
DWARFRangeList func_ranges;
217220
const char *name = NULL;
218221
const char *mangled = NULL;
@@ -232,63 +235,47 @@ Function *DWARFASTParserSwift::ParseFunctionFromDWARF(
232235
&frame_base)) {
233236
// Union of all ranges in the function DIE (if the function is
234237
// discontiguous)
235-
SymbolFileDWARF *dwarf = die.GetDWARF();
236-
AddressRange func_range;
237-
lldb::addr_t lowest_func_addr = func_ranges.GetMinRangeBase(0);
238-
lldb::addr_t highest_func_addr = func_ranges.GetMaxRangeEnd(0);
239-
if (lowest_func_addr != LLDB_INVALID_ADDRESS &&
240-
lowest_func_addr <= highest_func_addr) {
241-
ModuleSP module_sp(dwarf->GetObjectFile()->GetModule());
242-
func_range.GetBaseAddress().ResolveAddressUsingFileSections(
243-
lowest_func_addr, module_sp->GetSectionList());
244-
if (func_range.GetBaseAddress().IsValid())
245-
func_range.SetByteSize(highest_func_addr - lowest_func_addr);
246-
}
247238

248-
if (func_range.GetBaseAddress().IsValid()) {
249-
Mangled func_name;
250-
if (mangled)
251-
func_name.SetValue(ConstString(mangled), true);
252-
else
253-
func_name.SetValue(ConstString(name), false);
254-
255-
// See if this function can throw. We can't get that from the
256-
// mangled name (even though the information is often there)
257-
// because Swift reserves the right to omit it from the name
258-
// if it doesn't need it. So instead we look for the
259-
// DW_TAG_thrown_type:
260-
261-
bool can_throw = false;
262-
263-
DWARFDebugInfoEntry *child(die.GetFirstChild().GetDIE());
264-
while (child) {
265-
if (child->Tag() == DW_TAG_thrown_type) {
266-
can_throw = true;
267-
break;
268-
}
269-
child = child->GetSibling();
239+
Mangled func_name;
240+
if (mangled)
241+
func_name.SetValue(ConstString(mangled), true);
242+
else
243+
func_name.SetValue(ConstString(name), false);
244+
245+
// See if this function can throw. We can't get that from the
246+
// mangled name (even though the information is often there)
247+
// because Swift reserves the right to omit it from the name
248+
// if it doesn't need it. So instead we look for the
249+
// DW_TAG_thrown_type:
250+
251+
bool can_throw = false;
252+
253+
DWARFDebugInfoEntry *child(die.GetFirstChild().GetDIE());
254+
while (child) {
255+
if (child->Tag() == DW_TAG_thrown_type) {
256+
can_throw = true;
257+
break;
270258
}
259+
child = child->GetSibling();
260+
}
271261

272-
FunctionSP func_sp;
273-
std::unique_ptr<Declaration> decl_ap;
274-
if (decl_file != 0 || decl_line != 0 || decl_column != 0)
275-
decl_ap.reset(new Declaration(
276-
comp_unit.GetSupportFiles().GetFileSpecAtIndex(decl_file),
277-
decl_line, decl_column));
278-
279-
if (dwarf->FixupAddress(func_range.GetBaseAddress())) {
280-
const user_id_t func_user_id = die.GetID();
281-
func_sp.reset(new Function(&comp_unit, func_user_id, func_user_id,
282-
func_name, nullptr, func_range,
283-
can_throw)); // first address range
284-
285-
if (func_sp.get() != NULL) {
286-
if (frame_base.IsValid())
287-
func_sp->GetFrameBaseExpression() = frame_base;
288-
comp_unit.AddFunction(func_sp);
289-
return func_sp.get();
290-
}
291-
}
262+
FunctionSP func_sp;
263+
std::unique_ptr<Declaration> decl_ap;
264+
if (decl_file != 0 || decl_line != 0 || decl_column != 0)
265+
decl_ap.reset(new Declaration(
266+
comp_unit.GetSupportFiles().GetFileSpecAtIndex(decl_file), decl_line,
267+
decl_column));
268+
269+
const user_id_t func_user_id = die.GetID();
270+
func_sp.reset(new Function(&comp_unit, func_user_id, func_user_id,
271+
func_name, nullptr, func_range,
272+
can_throw)); // first address range
273+
274+
if (func_sp.get() != NULL) {
275+
if (frame_base.IsValid())
276+
func_sp->GetFrameBaseExpression() = frame_base;
277+
comp_unit.AddFunction(func_sp);
278+
return func_sp.get();
292279
}
293280
}
294281
return NULL;

lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserSwift.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,8 @@ class DWARFASTParserSwift : public DWARFASTParser {
3333

3434
lldb_private::Function *
3535
ParseFunctionFromDWARF(lldb_private::CompileUnit &comp_unit,
36-
const DWARFDIE &die) override;
36+
const DWARFDIE &die,
37+
const lldb_private::AddressRange &func_range) override;
3738

3839
bool
3940
CompleteTypeFromDWARF(const DWARFDIE &die, lldb_private::Type *type,

0 commit comments

Comments
 (0)