@@ -212,7 +212,10 @@ lldb::TypeSP DWARFASTParserSwift::ParseTypeFromDWARF(const SymbolContext &sc,
212
212
}
213
213
214
214
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
+
216
219
DWARFRangeList func_ranges;
217
220
const char *name = NULL ;
218
221
const char *mangled = NULL ;
@@ -232,63 +235,47 @@ Function *DWARFASTParserSwift::ParseFunctionFromDWARF(
232
235
&frame_base)) {
233
236
// Union of all ranges in the function DIE (if the function is
234
237
// 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
- }
247
238
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 ;
270
258
}
259
+ child = child->GetSibling ();
260
+ }
271
261
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 ();
292
279
}
293
280
}
294
281
return NULL ;
0 commit comments