| ... | @@ -937,7 +937,7 @@ fn openMachODebugInfo(allocator: *mem.Allocator, macho_file_path: []const u8) !M | ... | @@ -937,7 +937,7 @@ fn openMachODebugInfo(allocator: *mem.Allocator, macho_file_path: []const u8) !M |
| 937 | return error.MissingDebugInfo; | 937 | return error.MissingDebugInfo; |
| 938 | }; | 938 | }; |
| 939 | const syms = @ptrCast([*]const macho.nlist_64, @alignCast(@alignOf(macho.nlist_64), hdr_base + symtab.symoff))[0..symtab.nsyms]; | 939 | const syms = @ptrCast([*]const macho.nlist_64, @alignCast(@alignOf(macho.nlist_64), hdr_base + symtab.symoff))[0..symtab.nsyms]; |
| 940 | const strings = @ptrCast([*]const u8, hdr_base + symtab.stroff)[0..symtab.strsize :0]; | 940 | const strings = @ptrCast([*]const u8, hdr_base + symtab.stroff)[0 .. symtab.strsize - 1 :0]; |
| 941 | | 941 | |
| 942 | const symbols_buf = try allocator.alloc(MachoSymbol, syms.len); | 942 | const symbols_buf = try allocator.alloc(MachoSymbol, syms.len); |
| 943 | | 943 | |
| ... | @@ -1418,19 +1418,23 @@ pub const ModuleDebugInfo = switch (builtin.os.tag) { | ... | @@ -1418,19 +1418,23 @@ pub const ModuleDebugInfo = switch (builtin.os.tag) { |
| 1418 | const symbol = machoSearchSymbols(self.symbols, relocated_address) orelse | 1418 | const symbol = machoSearchSymbols(self.symbols, relocated_address) orelse |
| 1419 | return SymbolInfo{}; | 1419 | return SymbolInfo{}; |
| 1420 | | 1420 | |
| 1421 | // XXX: Return the symbol name | 1421 | // Take the symbol name from the N_FUN STAB entry, we're going to |
| | 1422 | // use it if we fail to find the DWARF infos |
| | 1423 | const stab_symbol = mem.spanZ(self.strings[symbol.nlist.n_strx..]); |
| | 1424 | |
| 1422 | if (symbol.ofile == null) | 1425 | if (symbol.ofile == null) |
| 1423 | return SymbolInfo{}; | 1426 | return SymbolInfo{ .symbol_name = stab_symbol }; |
| 1424 | | 1427 | |
| 1425 | assert(symbol.ofile.?.n_strx < self.strings.len); | 1428 | const o_file_path = mem.spanZ(self.strings[symbol.ofile.?.n_strx..]); |
| 1426 | const o_file_path = mem.spanZ(self.strings.ptr + symbol.ofile.?.n_strx); | | |
| 1427 | | 1429 | |
| 1428 | // Check if its debug infos are already in the cache | 1430 | // Check if its debug infos are already in the cache |
| 1429 | var o_file_di = self.ofiles.getValue(o_file_path) orelse | 1431 | var o_file_di = self.ofiles.getValue(o_file_path) orelse |
| 1430 | (self.loadOFile(o_file_path) catch |err| switch (err) { | 1432 | (self.loadOFile(o_file_path) catch |err| switch (err) { |
| 1431 | error.MissingDebugInfo, error.InvalidDebugInfo => { | 1433 | error.FileNotFound, |
| 1432 | // XXX: Return the symbol name | 1434 | error.MissingDebugInfo, |
| 1433 | return SymbolInfo{}; | 1435 | error.InvalidDebugInfo, |
| | 1436 | => { |
| | 1437 | return SymbolInfo{ .symbol_name = stab_symbol }; |
| 1434 | }, | 1438 | }, |
| 1435 | else => return err, | 1439 | else => return err, |
| 1436 | }); | 1440 | }); |
| ... | @@ -1453,7 +1457,7 @@ pub const ModuleDebugInfo = switch (builtin.os.tag) { | ... | @@ -1453,7 +1457,7 @@ pub const ModuleDebugInfo = switch (builtin.os.tag) { |
| 1453 | }; | 1457 | }; |
| 1454 | } else |err| switch (err) { | 1458 | } else |err| switch (err) { |
| 1455 | error.MissingDebugInfo, error.InvalidDebugInfo => { | 1459 | error.MissingDebugInfo, error.InvalidDebugInfo => { |
| 1456 | return SymbolInfo{}; | 1460 | return SymbolInfo{ .symbol_name = stab_symbol }; |
| 1457 | }, | 1461 | }, |
| 1458 | else => return err, | 1462 | else => return err, |
| 1459 | } | 1463 | } |