* readelf.c (decode_location_expression): Loop through multiple
operations. (read_and_display_attr): Pass in length.
This commit is contained in:
parent
1fa3730664
commit
eb6bd4d38e
2 changed files with 309 additions and 465 deletions
|
@ -1,4 +1,8 @@
|
|||
2000-04-06 Jason Merrill <jason@casey.cygnus.com>
|
||||
2000-04-06 Jason Merrill <jason@yorick.cygnus.com>
|
||||
|
||||
* readelf.c (decode_location_expression): Loop through multiple
|
||||
operations.
|
||||
(read_and_display_attr): Pass in length.
|
||||
|
||||
* readelf.c (read_and_display_attr): Add CU offset to references.
|
||||
(display_debug_info): Pass it in.
|
||||
|
|
|
@ -212,7 +212,7 @@ static void add_abbrev PARAMS ((unsigned long, un
|
|||
static void add_abbrev_attr PARAMS ((unsigned long, unsigned long));
|
||||
static unsigned char * read_and_display_attr PARAMS ((unsigned long, unsigned long, unsigned char *, unsigned long, unsigned long));
|
||||
static unsigned char * display_block PARAMS ((unsigned char *, unsigned long));
|
||||
static void decode_location_expression PARAMS ((unsigned char *, unsigned int));
|
||||
static void decode_location_expression PARAMS ((unsigned char *, unsigned int, unsigned long));
|
||||
static void request_dump PARAMS ((unsigned int, char));
|
||||
static const char * get_elf_class PARAMS ((unsigned char));
|
||||
static const char * get_data_encoding PARAMS ((unsigned char));
|
||||
|
@ -5596,55 +5596,69 @@ display_block (data, length)
|
|||
}
|
||||
|
||||
static void
|
||||
decode_location_expression (data, pointer_size)
|
||||
decode_location_expression (data, pointer_size, length)
|
||||
unsigned char * data;
|
||||
unsigned int pointer_size;
|
||||
unsigned long length;
|
||||
{
|
||||
unsigned char op;
|
||||
unsigned op;
|
||||
int bytes_read;
|
||||
unsigned long uvalue;
|
||||
unsigned char *end = data + length;
|
||||
|
||||
while (data < end)
|
||||
{
|
||||
op = * data ++;
|
||||
|
||||
switch (op)
|
||||
{
|
||||
case DW_OP_addr:
|
||||
printf ("DW_OP_addr: %lx", (unsigned long) byte_get (data, pointer_size));
|
||||
printf ("DW_OP_addr: %lx",
|
||||
(unsigned long) byte_get (data, pointer_size));
|
||||
data += pointer_size;
|
||||
break;
|
||||
case DW_OP_deref:
|
||||
printf ("DW_OP_deref");
|
||||
break;
|
||||
case DW_OP_const1u:
|
||||
printf ("DW_OP_const1u: %lu", (unsigned long) byte_get (data, 1));
|
||||
printf ("DW_OP_const1u: %lu", (unsigned long) byte_get (data++, 1));
|
||||
break;
|
||||
case DW_OP_const1s:
|
||||
printf ("DW_OP_const1s: %ld", (long) byte_get (data, 1));
|
||||
printf ("DW_OP_const1s: %ld", (long) byte_get (data++, 1));
|
||||
break;
|
||||
case DW_OP_const2u:
|
||||
printf ("DW_OP_const2u: %lu", (unsigned long) byte_get (data, 2));
|
||||
data += 2;
|
||||
break;
|
||||
case DW_OP_const2s:
|
||||
printf ("DW_OP_const2s: %ld", (long) byte_get (data, 2));
|
||||
data += 2;
|
||||
break;
|
||||
case DW_OP_const4u:
|
||||
printf ("DW_OP_const4u: %lu", (unsigned long) byte_get (data, 4));
|
||||
data += 4;
|
||||
break;
|
||||
case DW_OP_const4s:
|
||||
printf ("DW_OP_const4s: %ld", (long) byte_get (data, 4));
|
||||
data += 4;
|
||||
break;
|
||||
case DW_OP_const8u:
|
||||
printf ("DW_OP_const8u: %lu %lu", (unsigned long) byte_get (data, 4),
|
||||
(unsigned long) byte_get (data + 4, 4));
|
||||
data += 8;
|
||||
break;
|
||||
case DW_OP_const8s:
|
||||
printf ("DW_OP_const8s: %ld %ld", (long) byte_get (data, 4),
|
||||
(long) byte_get (data + 4, 4));
|
||||
data += 8;
|
||||
break;
|
||||
case DW_OP_constu:
|
||||
printf ("DW_OP_constu: %lu", read_leb128 (data, NULL, 0));
|
||||
printf ("DW_OP_constu: %lu", read_leb128 (data, &bytes_read, 0));
|
||||
data += bytes_read;
|
||||
break;
|
||||
case DW_OP_consts:
|
||||
printf ("DW_OP_consts: %ld", read_leb128 (data, NULL, 1));
|
||||
printf ("DW_OP_consts: %ld", read_leb128 (data, &bytes_read, 1));
|
||||
data += bytes_read;
|
||||
break;
|
||||
case DW_OP_dup:
|
||||
printf ("DW_OP_dup");
|
||||
|
@ -5656,7 +5670,7 @@ decode_location_expression (data, pointer_size)
|
|||
printf ("DW_OP_over");
|
||||
break;
|
||||
case DW_OP_pick:
|
||||
printf ("DW_OP_pick: %ld", (unsigned long) byte_get (data, 1));
|
||||
printf ("DW_OP_pick: %ld", (unsigned long) byte_get (data++, 1));
|
||||
break;
|
||||
case DW_OP_swap:
|
||||
printf ("DW_OP_swap");
|
||||
|
@ -5698,7 +5712,9 @@ decode_location_expression (data, pointer_size)
|
|||
printf ("DW_OP_plus");
|
||||
break;
|
||||
case DW_OP_plus_uconst:
|
||||
printf ("DW_OP_plus_uconst: %lu", read_leb128 (data, NULL, 0));
|
||||
printf ("DW_OP_plus_uconst: %lu",
|
||||
read_leb128 (data, &bytes_read, 0));
|
||||
data += bytes_read;
|
||||
break;
|
||||
case DW_OP_shl:
|
||||
printf ("DW_OP_shl");
|
||||
|
@ -5714,6 +5730,7 @@ decode_location_expression (data, pointer_size)
|
|||
break;
|
||||
case DW_OP_bra:
|
||||
printf ("DW_OP_bra: %ld", (long) byte_get (data, 2));
|
||||
data += 2;
|
||||
break;
|
||||
case DW_OP_eq:
|
||||
printf ("DW_OP_eq");
|
||||
|
@ -5735,314 +5752,140 @@ decode_location_expression (data, pointer_size)
|
|||
break;
|
||||
case DW_OP_skip:
|
||||
printf ("DW_OP_skip: %ld", (long) byte_get (data, 2));
|
||||
data += 2;
|
||||
break;
|
||||
|
||||
case DW_OP_lit0:
|
||||
printf ("DW_OP_lit0");
|
||||
break;
|
||||
case DW_OP_lit1:
|
||||
printf ("DW_OP_lit1");
|
||||
break;
|
||||
case DW_OP_lit2:
|
||||
printf ("DW_OP_lit2");
|
||||
break;
|
||||
case DW_OP_lit3:
|
||||
printf ("DW_OP_lit3");
|
||||
break;
|
||||
case DW_OP_lit4:
|
||||
printf ("DW_OP_lit4");
|
||||
break;
|
||||
case DW_OP_lit5:
|
||||
printf ("DW_OP_lit5");
|
||||
break;
|
||||
case DW_OP_lit6:
|
||||
printf ("DW_OP_lit6");
|
||||
break;
|
||||
case DW_OP_lit7:
|
||||
printf ("DW_OP_lit7");
|
||||
break;
|
||||
case DW_OP_lit8:
|
||||
printf ("DW_OP_lit8");
|
||||
break;
|
||||
case DW_OP_lit9:
|
||||
printf ("DW_OP_lit9");
|
||||
break;
|
||||
case DW_OP_lit10:
|
||||
printf ("DW_OP_lit10");
|
||||
break;
|
||||
case DW_OP_lit11:
|
||||
printf ("DW_OP_lit11");
|
||||
break;
|
||||
case DW_OP_lit12:
|
||||
printf ("DW_OP_lit12");
|
||||
break;
|
||||
case DW_OP_lit13:
|
||||
printf ("DW_OP_lit13");
|
||||
break;
|
||||
case DW_OP_lit14:
|
||||
printf ("DW_OP_lit14");
|
||||
break;
|
||||
case DW_OP_lit15:
|
||||
printf ("DW_OP_lit15");
|
||||
break;
|
||||
case DW_OP_lit16:
|
||||
printf ("DW_OP_lit16");
|
||||
break;
|
||||
case DW_OP_lit17:
|
||||
printf ("DW_OP_lit17");
|
||||
break;
|
||||
case DW_OP_lit18:
|
||||
printf ("DW_OP_lit18");
|
||||
break;
|
||||
case DW_OP_lit19:
|
||||
printf ("DW_OP_lit19");
|
||||
break;
|
||||
case DW_OP_lit20:
|
||||
printf ("DW_OP_lit20");
|
||||
break;
|
||||
case DW_OP_lit21:
|
||||
printf ("DW_OP_lit21");
|
||||
break;
|
||||
case DW_OP_lit22:
|
||||
printf ("DW_OP_lit22");
|
||||
break;
|
||||
case DW_OP_lit23:
|
||||
printf ("DW_OP_lit23");
|
||||
break;
|
||||
case DW_OP_lit24:
|
||||
printf ("DW_OP_lit24");
|
||||
break;
|
||||
case DW_OP_lit25:
|
||||
printf ("DW_OP_lit25");
|
||||
break;
|
||||
case DW_OP_lit26:
|
||||
printf ("DW_OP_lit26");
|
||||
break;
|
||||
case DW_OP_lit27:
|
||||
printf ("DW_OP_lit27");
|
||||
break;
|
||||
case DW_OP_lit28:
|
||||
printf ("DW_OP_lit28");
|
||||
break;
|
||||
case DW_OP_lit29:
|
||||
printf ("DW_OP_lit29");
|
||||
break;
|
||||
case DW_OP_lit30:
|
||||
printf ("DW_OP_lit30");
|
||||
break;
|
||||
case DW_OP_lit31:
|
||||
printf ("DW_OP_lit31");
|
||||
printf ("DW_OP_lit%d", op - DW_OP_lit0);
|
||||
break;
|
||||
|
||||
case DW_OP_reg0:
|
||||
printf ("DW_OP_reg0");
|
||||
break;
|
||||
case DW_OP_reg1:
|
||||
printf ("DW_OP_reg1");
|
||||
break;
|
||||
case DW_OP_reg2:
|
||||
printf ("DW_OP_reg2");
|
||||
break;
|
||||
case DW_OP_reg3:
|
||||
printf ("DW_OP_reg3");
|
||||
break;
|
||||
case DW_OP_reg4:
|
||||
printf ("DW_OP_reg4");
|
||||
break;
|
||||
case DW_OP_reg5:
|
||||
printf ("DW_OP_reg5");
|
||||
break;
|
||||
case DW_OP_reg6:
|
||||
printf ("DW_OP_reg6");
|
||||
break;
|
||||
case DW_OP_reg7:
|
||||
printf ("DW_OP_reg7");
|
||||
break;
|
||||
case DW_OP_reg8:
|
||||
printf ("DW_OP_reg8");
|
||||
break;
|
||||
case DW_OP_reg9:
|
||||
printf ("DW_OP_reg9");
|
||||
break;
|
||||
case DW_OP_reg10:
|
||||
printf ("DW_OP_reg10");
|
||||
break;
|
||||
case DW_OP_reg11:
|
||||
printf ("DW_OP_reg11");
|
||||
break;
|
||||
case DW_OP_reg12:
|
||||
printf ("DW_OP_reg12");
|
||||
break;
|
||||
case DW_OP_reg13:
|
||||
printf ("DW_OP_reg13");
|
||||
break;
|
||||
case DW_OP_reg14:
|
||||
printf ("DW_OP_reg14");
|
||||
break;
|
||||
case DW_OP_reg15:
|
||||
printf ("DW_OP_reg15");
|
||||
break;
|
||||
case DW_OP_reg16:
|
||||
printf ("DW_OP_reg16");
|
||||
break;
|
||||
case DW_OP_reg17:
|
||||
printf ("DW_OP_reg17");
|
||||
break;
|
||||
case DW_OP_reg18:
|
||||
printf ("DW_OP_reg18");
|
||||
break;
|
||||
case DW_OP_reg19:
|
||||
printf ("DW_OP_reg19");
|
||||
break;
|
||||
case DW_OP_reg20:
|
||||
printf ("DW_OP_reg20");
|
||||
break;
|
||||
case DW_OP_reg21:
|
||||
printf ("DW_OP_reg21");
|
||||
break;
|
||||
case DW_OP_reg22:
|
||||
printf ("DW_OP_reg22");
|
||||
break;
|
||||
case DW_OP_reg23:
|
||||
printf ("DW_OP_reg23");
|
||||
break;
|
||||
case DW_OP_reg24:
|
||||
printf ("DW_OP_reg24");
|
||||
break;
|
||||
case DW_OP_reg25:
|
||||
printf ("DW_OP_reg25");
|
||||
break;
|
||||
case DW_OP_reg26:
|
||||
printf ("DW_OP_reg26");
|
||||
break;
|
||||
case DW_OP_reg27:
|
||||
printf ("DW_OP_reg27");
|
||||
break;
|
||||
case DW_OP_reg28:
|
||||
printf ("DW_OP_reg28");
|
||||
break;
|
||||
case DW_OP_reg29:
|
||||
printf ("DW_OP_reg29");
|
||||
break;
|
||||
case DW_OP_reg30:
|
||||
printf ("DW_OP_reg30");
|
||||
break;
|
||||
case DW_OP_reg31:
|
||||
printf ("DW_OP_reg31");
|
||||
printf ("DW_OP_reg%d", op - DW_OP_reg0);
|
||||
break;
|
||||
|
||||
case DW_OP_breg0:
|
||||
printf ("DW_OP_breg0: %ld", read_leb128 (data, NULL, 1));
|
||||
break;
|
||||
case DW_OP_breg1:
|
||||
printf ("DW_OP_breg1: %ld", read_leb128 (data, NULL, 1));
|
||||
break;
|
||||
case DW_OP_breg2:
|
||||
printf ("DW_OP_breg2: %ld", read_leb128 (data, NULL, 1));
|
||||
break;
|
||||
case DW_OP_breg3:
|
||||
printf ("DW_OP_breg3: %ld", read_leb128 (data, NULL, 1));
|
||||
break;
|
||||
case DW_OP_breg4:
|
||||
printf ("DW_OP_breg4: %ld", read_leb128 (data, NULL, 1));
|
||||
break;
|
||||
case DW_OP_breg5:
|
||||
printf ("DW_OP_breg5: %ld", read_leb128 (data, NULL, 1));
|
||||
break;
|
||||
case DW_OP_breg6:
|
||||
printf ("DW_OP_breg6: %ld", read_leb128 (data, NULL, 1));
|
||||
break;
|
||||
case DW_OP_breg7:
|
||||
printf ("DW_OP_breg7: %ld", read_leb128 (data, NULL, 1));
|
||||
break;
|
||||
case DW_OP_breg8:
|
||||
printf ("DW_OP_breg8: %ld", read_leb128 (data, NULL, 1));
|
||||
break;
|
||||
case DW_OP_breg9:
|
||||
printf ("DW_OP_breg9: %ld", read_leb128 (data, NULL, 1));
|
||||
break;
|
||||
case DW_OP_breg10:
|
||||
printf ("DW_OP_breg10: %ld", read_leb128 (data, NULL, 1));
|
||||
break;
|
||||
case DW_OP_breg11:
|
||||
printf ("DW_OP_breg11: %ld", read_leb128 (data, NULL, 1));
|
||||
break;
|
||||
case DW_OP_breg12:
|
||||
printf ("DW_OP_breg12: %ld", read_leb128 (data, NULL, 1));
|
||||
break;
|
||||
case DW_OP_breg13:
|
||||
printf ("DW_OP_breg13: %ld", read_leb128 (data, NULL, 1));
|
||||
break;
|
||||
case DW_OP_breg14:
|
||||
printf ("DW_OP_breg14: %ld", read_leb128 (data, NULL, 1));
|
||||
break;
|
||||
case DW_OP_breg15:
|
||||
printf ("DW_OP_breg15: %ld", read_leb128 (data, NULL, 1));
|
||||
break;
|
||||
case DW_OP_breg16:
|
||||
printf ("DW_OP_breg16: %ld", read_leb128 (data, NULL, 1));
|
||||
break;
|
||||
case DW_OP_breg17:
|
||||
printf ("DW_OP_breg17: %ld", read_leb128 (data, NULL, 1));
|
||||
break;
|
||||
case DW_OP_breg18:
|
||||
printf ("DW_OP_breg18: %ld", read_leb128 (data, NULL, 1));
|
||||
break;
|
||||
case DW_OP_breg19:
|
||||
printf ("DW_OP_breg19: %ld", read_leb128 (data, NULL, 1));
|
||||
break;
|
||||
case DW_OP_breg20:
|
||||
printf ("DW_OP_breg20: %ld", read_leb128 (data, NULL, 1));
|
||||
break;
|
||||
case DW_OP_breg21:
|
||||
printf ("DW_OP_breg21: %ld", read_leb128 (data, NULL, 1));
|
||||
break;
|
||||
case DW_OP_breg22:
|
||||
printf ("DW_OP_breg22: %ld", read_leb128 (data, NULL, 1));
|
||||
break;
|
||||
case DW_OP_breg23:
|
||||
printf ("DW_OP_breg23: %ld", read_leb128 (data, NULL, 1));
|
||||
break;
|
||||
case DW_OP_breg24:
|
||||
printf ("DW_OP_breg24: %ld", read_leb128 (data, NULL, 1));
|
||||
break;
|
||||
case DW_OP_breg25:
|
||||
printf ("DW_OP_breg25: %ld", read_leb128 (data, NULL, 1));
|
||||
break;
|
||||
case DW_OP_breg26:
|
||||
printf ("DW_OP_breg26: %ld", read_leb128 (data, NULL, 1));
|
||||
break;
|
||||
case DW_OP_breg27:
|
||||
printf ("DW_OP_breg27: %ld", read_leb128 (data, NULL, 1));
|
||||
break;
|
||||
case DW_OP_breg28:
|
||||
printf ("DW_OP_breg28: %ld", read_leb128 (data, NULL, 1));
|
||||
break;
|
||||
case DW_OP_breg29:
|
||||
printf ("DW_OP_breg29: %ld", read_leb128 (data, NULL, 1));
|
||||
break;
|
||||
case DW_OP_breg30:
|
||||
printf ("DW_OP_breg30: %ld", read_leb128 (data, NULL, 1));
|
||||
break;
|
||||
case DW_OP_breg31:
|
||||
printf ("DW_OP_breg31: %ld", read_leb128 (data, NULL, 1));
|
||||
printf ("DW_OP_breg%d: %ld", op - DW_OP_breg0,
|
||||
read_leb128 (data, &bytes_read, 1));
|
||||
data += bytes_read;
|
||||
break;
|
||||
|
||||
case DW_OP_regx:
|
||||
printf ("DW_OP_regx: %lu", read_leb128 (data, NULL, 0));
|
||||
printf ("DW_OP_regx: %lu", read_leb128 (data, &bytes_read, 0));
|
||||
data += bytes_read;
|
||||
break;
|
||||
case DW_OP_fbreg:
|
||||
printf ("DW_OP_fbreg: %ld", read_leb128 (data, NULL, 1));
|
||||
printf ("DW_OP_fbreg: %ld", read_leb128 (data, &bytes_read, 1));
|
||||
data += bytes_read;
|
||||
break;
|
||||
case DW_OP_bregx:
|
||||
uvalue = read_leb128 (data, &bytes_read, 0);
|
||||
data += bytes_read;
|
||||
printf ("DW_OP_bregx: %lu %ld", uvalue,
|
||||
read_leb128 (data + bytes_read, NULL, 1));
|
||||
read_leb128 (data, &bytes_read, 1));
|
||||
data += bytes_read;
|
||||
break;
|
||||
case DW_OP_piece:
|
||||
printf ("DW_OP_piece: %lu", read_leb128 (data, NULL, 0));
|
||||
printf ("DW_OP_piece: %lu", read_leb128 (data, &bytes_read, 0));
|
||||
data += bytes_read;
|
||||
break;
|
||||
case DW_OP_deref_size:
|
||||
printf ("DW_OP_deref_size: %ld", (long) byte_get (data, 1));
|
||||
printf ("DW_OP_deref_size: %ld", (long) byte_get (data++, 1));
|
||||
break;
|
||||
case DW_OP_xderef_size:
|
||||
printf ("DW_OP_xderef_size: %ld", (long) byte_get (data, 1));
|
||||
printf ("DW_OP_xderef_size: %ld", (long) byte_get (data++, 1));
|
||||
break;
|
||||
case DW_OP_nop:
|
||||
printf ("DW_OP_nop");
|
||||
|
@ -6054,7 +5897,9 @@ decode_location_expression (data, pointer_size)
|
|||
printf (_("(User defined location op)"));
|
||||
else
|
||||
printf (_("(Unknown location op)"));
|
||||
break;
|
||||
/* No way to tell where the next op is, so just bail. */
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -6153,28 +5998,24 @@ read_and_display_attr (attribute, form, data, cu_offset, pointer_size)
|
|||
uvalue = read_leb128 (data, & bytes_read, 0);
|
||||
block_start = data + bytes_read;
|
||||
data = display_block (block_start, uvalue);
|
||||
uvalue = * block_start;
|
||||
break;
|
||||
|
||||
case DW_FORM_block1:
|
||||
uvalue = byte_get (data, 1);
|
||||
block_start = data + 1;
|
||||
data = display_block (block_start, uvalue);
|
||||
uvalue = * block_start;
|
||||
break;
|
||||
|
||||
case DW_FORM_block2:
|
||||
uvalue = byte_get (data, 2);
|
||||
block_start = data + 2;
|
||||
data = display_block (block_start, uvalue);
|
||||
uvalue = * block_start;
|
||||
break;
|
||||
|
||||
case DW_FORM_block4:
|
||||
uvalue = byte_get (data, 4);
|
||||
block_start = data + 4;
|
||||
data = display_block (block_start, uvalue);
|
||||
uvalue = * block_start;
|
||||
break;
|
||||
|
||||
case DW_FORM_strp:
|
||||
|
@ -6204,11 +6045,6 @@ read_and_display_attr (attribute, form, data, cu_offset, pointer_size)
|
|||
}
|
||||
break;
|
||||
|
||||
case DW_AT_frame_base:
|
||||
if (uvalue >= DW_OP_reg0 && uvalue <= DW_OP_reg31)
|
||||
printf ("(reg %ld)", uvalue - DW_OP_reg0);
|
||||
break;
|
||||
|
||||
case DW_AT_language:
|
||||
switch (uvalue)
|
||||
{
|
||||
|
@ -6305,12 +6141,16 @@ read_and_display_attr (attribute, form, data, cu_offset, pointer_size)
|
|||
}
|
||||
break;
|
||||
|
||||
case DW_AT_frame_base:
|
||||
case DW_AT_location:
|
||||
case DW_AT_data_member_location:
|
||||
case DW_AT_vtable_elem_location:
|
||||
if (block_start)
|
||||
{
|
||||
printf ("(");
|
||||
decode_location_expression (block_start, pointer_size);
|
||||
decode_location_expression (block_start, pointer_size, uvalue);
|
||||
printf (")");
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
|
|
Loading…
Reference in a new issue