mirror of
https://github.com/radareorg/radare2.git
synced 2024-11-24 05:40:10 +00:00
Store column information in the addr2line database ##dwarf
This commit is contained in:
parent
49f896e419
commit
8a378cca41
@ -869,15 +869,14 @@ static const ut8 *parse_line_header(RBinFile *bf, const ut8 *buf, const ut8 *buf
|
||||
return buf;
|
||||
}
|
||||
|
||||
static inline void add_sdb_addrline(Sdb *s, ut64 addr, const char *file, ut64 line, int mode, PrintfCallback print) {
|
||||
const char *p;
|
||||
static inline void add_sdb_addrline(Sdb *s, ut64 addr, const char *file, ut64 line, ut64 column, int mode, PrintfCallback print) {
|
||||
char offset[SDB_NUM_BUFSZ];
|
||||
char *offset_ptr;
|
||||
|
||||
if (!s || !file) {
|
||||
if (!s || R_STR_ISEMPTY (file)) {
|
||||
return;
|
||||
}
|
||||
p = r_str_rchr (file, NULL, '/');
|
||||
|
||||
const char *p = r_str_rchr (file, NULL, '/');
|
||||
if (p) {
|
||||
p++;
|
||||
} else {
|
||||
@ -888,7 +887,16 @@ static inline void add_sdb_addrline(Sdb *s, ut64 addr, const char *file, ut64 li
|
||||
case 1:
|
||||
case 'r':
|
||||
case '*':
|
||||
print ("CL %s:%d 0x%08"PFMT64x"\n", p, (int)line, addr);
|
||||
#if R2_590
|
||||
/// XXX CL must take filename as last argument to support spaces imho
|
||||
print ("\"\"CL %s|%d|%d 0x%08"PFMT64x"\n", p, (int)line, (int)column, addr);
|
||||
#else
|
||||
if (column) {
|
||||
print ("\"\"CL %s:%d:%d 0x%08"PFMT64x"\n", p, (int)line, (int)column, addr);
|
||||
} else if (line > 0) {
|
||||
print ("\"\"CL %s:%d 0x%08"PFMT64x"\n", p, (int)line, addr);
|
||||
}
|
||||
#endif
|
||||
break;
|
||||
}
|
||||
#if 0
|
||||
@ -899,7 +907,9 @@ static inline void add_sdb_addrline(Sdb *s, ut64 addr, const char *file, ut64 li
|
||||
#else
|
||||
p = file;
|
||||
#endif
|
||||
char *fileline = r_str_newf ("%s|%"PFMT64d, p, line);
|
||||
char *fileline = (column > 0)
|
||||
? r_str_newf ("%s|%"PFMT64d"|%"PFMT64d, p, line, column)
|
||||
: r_str_newf ("%s|%"PFMT64d, p, line);
|
||||
r_str_ansi_strip (fileline);
|
||||
r_str_replace_ch (fileline, '\n', 0, true);
|
||||
r_str_replace_ch (fileline, '\t', 0, true);
|
||||
@ -945,7 +955,8 @@ static const ut8 *parse_ext_opcode(RBin *bin, const ut8 *obuf, size_t len, const
|
||||
int fnidx = regs->file - 1;
|
||||
if (fnidx >= 0 && fnidx < hdr->file_names_count) {
|
||||
add_sdb_addrline (binfile->sdb_addrinfo, regs->address,
|
||||
hdr->file_names[fnidx].name, regs->line, mode, print);
|
||||
hdr->file_names[fnidx].name,
|
||||
regs->line, regs->column, mode, print);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1036,7 +1047,7 @@ static const ut8 *parse_spec_opcode(
|
||||
if (idx >= 0 && idx < hdr->file_names_count) {
|
||||
add_sdb_addrline (binfile->sdb_addrinfo, regs->address,
|
||||
hdr->file_names[idx].name,
|
||||
regs->line, mode, print);
|
||||
regs->line, regs->column, mode, print);
|
||||
}
|
||||
}
|
||||
regs->basic_block = DWARF_FALSE;
|
||||
@ -1075,7 +1086,7 @@ static const ut8 *parse_std_opcode(RBin *bin, const ut8 *obuf, size_t len, const
|
||||
add_sdb_addrline (binfile->sdb_addrinfo,
|
||||
regs->address,
|
||||
hdr->file_names[fnidx].name,
|
||||
regs->line, mode, print);
|
||||
regs->line, regs->column, mode, print);
|
||||
}
|
||||
}
|
||||
regs->basic_block = DWARF_FALSE;
|
||||
@ -1301,7 +1312,7 @@ static int parse_aranges_raw(RBin *bin, const ut8 *obuf, int len, int mode) {
|
||||
const ut8 *buf = obuf;
|
||||
int idx = 0;
|
||||
|
||||
if (!buf || len< 4) {
|
||||
if (!buf || len < 4) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -1314,27 +1325,22 @@ static int parse_aranges_raw(RBin *bin, const ut8 *obuf, int len, int mode) {
|
||||
if (idx + 12 >= len) {
|
||||
return false;
|
||||
}
|
||||
|
||||
READ_BUF16 (version);
|
||||
if (mode == R_MODE_PRINT) {
|
||||
print ("Version %d\n", version);
|
||||
}
|
||||
|
||||
READ_BUF32 (debug_info_offset);
|
||||
if (mode == R_MODE_PRINT) {
|
||||
print ("Debug info offset %d\n", debug_info_offset);
|
||||
}
|
||||
|
||||
READ_BUF (address_size, ut8);
|
||||
if (mode == R_MODE_PRINT) {
|
||||
print ("address size %d\n", (int)address_size);
|
||||
}
|
||||
|
||||
READ_BUF (segment_size, ut8);
|
||||
if (mode == R_MODE_PRINT) {
|
||||
print ("segment size %d\n", (int)segment_size);
|
||||
}
|
||||
|
||||
offset = segment_size + address_size * 2;
|
||||
if (offset) {
|
||||
ut64 n = (((ut64) (size_t)buf / offset) + 1) * offset - ((ut64)(size_t)buf);
|
||||
@ -1406,14 +1412,14 @@ static int expand_cu(RBinDwarfCompUnit *cu) {
|
||||
return false;
|
||||
}
|
||||
RBinDwarfDie *tmp = (RBinDwarfDie *)realloc (cu->dies, cu->capacity * 2 * sizeof (RBinDwarfDie));
|
||||
if (!tmp) {
|
||||
return false;
|
||||
if (tmp) {
|
||||
memset ((ut8 *)tmp + cu->capacity * sizeof (RBinDwarfDie),
|
||||
0, cu->capacity * sizeof (RBinDwarfDie));
|
||||
cu->dies = tmp;
|
||||
cu->capacity *= 2;
|
||||
return true;
|
||||
}
|
||||
memset ((ut8 *)tmp + cu->capacity * sizeof (RBinDwarfDie),
|
||||
0, cu->capacity * sizeof (RBinDwarfDie));
|
||||
cu->dies = tmp;
|
||||
cu->capacity *= 2;
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
static bool init_abbrev_decl(RBinDwarfAbbrevDecl *ad) {
|
||||
@ -2526,6 +2532,10 @@ R_API RList *r_bin_dwarf_parse_line(RBin *bin, int mode) {
|
||||
*tok++ = 0;
|
||||
int line = atoi (tok);
|
||||
int column = 0;
|
||||
char *tok2 = strchr (tok, '|');
|
||||
if (tok2) {
|
||||
column = atoi (tok2 + 1);
|
||||
}
|
||||
ut64 addr = r_num_get (NULL, key);
|
||||
RBinDwarfRow *row = row_new (addr, file, line, column);
|
||||
if (row) {
|
||||
|
Loading…
Reference in New Issue
Block a user