Correctly handle DW_FORM_flag and add DW_FORM_flag_present support

Before this patch, running pahole on an executable compiled
with -gdwarf-4 gave:

DW_AT_<0x3c>=0x19

0x19 is DW_FORM_flag_present.
Also, DW_FORM_flag takes an argument.
Changing attr_numeric to call dwarf_formflag fixes both problems.
This commit is contained in:
Tom Tromey 2012-03-20 12:20:44 -06:00
parent 4fa85d5b70
commit 7defe84d73
1 changed files with 6 additions and 1 deletions

View File

@ -241,7 +241,12 @@ static uint64_t attr_numeric(Dwarf_Die *die, uint32_t name)
}
break;
case DW_FORM_flag:
return 1;
case DW_FORM_flag_present: {
bool value;
if (dwarf_formflag(&attr, &value) == 0)
return value;
}
break;
default:
fprintf(stderr, "DW_AT_<0x%x>=0x%x\n", name, form);
break;