Project

General

Profile

Bug #17052 » ruby-addr2line-abbrev_table.patch

addr2line.c: Correct `abbrev_table` entries - xtkoba (Tee KOBAYASHI), 08/17/2021 07:42 AM

View differences:

addr2line.c
static void
di_read_debug_abbrev_cu(DebugInfoReader *reader)
{
uint64_t prev = 0;
const char *p = reader->q0;
size_t i;
for (i = 0; i < ABBREV_TABLE_SIZE; i++)
reader->abbrev_table[i] = NULL;
for (;;) {
uint64_t abbrev_number = uleb128(&p);
if (abbrev_number <= prev) break;
if (abbrev_number == 0) break;
if (abbrev_number < ABBREV_TABLE_SIZE) {
reader->abbrev_table[abbrev_number] = p;
}
prev = abbrev_number;
uleb128(&p); /* tag */
p++; /* has_children */
di_skip_die_attributes(&p);
......
exit(1);
}
static const char *
di_abbrev_table(DebugInfoReader *reader, uint64_t abbrev_number)
{
const char *p = reader->abbrev_table[abbrev_number];
if (!p) {
fprintf(stderr,"%d: Abbrev Number %"PRId64" not found\n",__LINE__, abbrev_number);
abort();
}
return p;
}
/* find abbrev in current compilation unit */
static const char *
di_find_abbrev(DebugInfoReader *reader, uint64_t abbrev_number)
{
const char *p;
if (abbrev_number < ABBREV_TABLE_SIZE) {
return reader->abbrev_table[abbrev_number];
return di_abbrev_table(reader, abbrev_number);
}
p = reader->abbrev_table[ABBREV_TABLE_SIZE-1];
p = di_abbrev_table(reader, ABBREV_TABLE_SIZE-1);
/* skip 255th record */
uleb128(&p); /* tag */
p++; /* has_children */
(3-3/5)