This is the mail archive of the
elfutils-devel@sourceware.org
mailing list for the elfutils project.
Some elfutils tweaks for typed DWARF stack
- From: Mark Wielaard <mjw at redhat dot com>
- To: elfutils-devel at lists dot fedorahosted dot org
- Date: Tue, 17 May 2011 23:22:51 +0200
- Subject: Some elfutils tweaks for typed DWARF stack
Hi,
Here is a patch from Jakub (with some small tweaks to the output
from me). It adds typed DWARF stack support (which is now in gcc trunk)
where DW_OP_GNU_entry_value is supported. readelf -w works. For more
background on the new ops see http://www.dwarfstd.org/doc/040408.1.html
Here is some example output:
[ f582] GNU_call_site_parameter
location (block1)
[ 0] reg17
GNU_call_site_value (block1)
[ 0] breg15 0
[ 2] const1u 32
[ 4] shl
[ 5] const1u 32
[ 7] shr
[ 8] GNU_convert [ 38]
[ 10] GNU_convert [ 31]
[ 12] GNU_const_type [ 31] 8 byte block: 00 00 00 00 00 00
59 40
[ 23] mul
[ 24] fbreg -168
[ 27] GNU_deref_type 8 [ 31]
[ 30] div
We haven't figured out yet how to adjust dwarf_getlocation to handle
these 5 new ops and DW_OP_GNU_entry_value.
I'll push the first patch to master, merge master into the dwarf branch
and then apply the second patch on the branch.
Cheers,
Mark
commit 0312424b6f374dac5c72b86791745d80b38049fb
Author: Jakub Jelinek <jakub@redhat.com>
Date: Tue May 17 17:00:14 2011 +0200
Add DW_OP_GNU_const_type/regval_type/deref_type/convert/reinterpret.
diff --git a/libdw/ChangeLog b/libdw/ChangeLog
index 8febd42..fc7d629 100644
--- a/libdw/ChangeLog
+++ b/libdw/ChangeLog
@@ -1,3 +1,9 @@
+2011-05-16 Jakub Jelinek <jakub@redhat.com>
+
+ * dwarf.h (DW_OP_GNU_const_type, DW_OP_GNU_regval_type,
+ DW_OP_GNU_deref_type, DW_OP_GNU_convert, DW_OP_GNU_reinterpret):
+ New.
+
2011-04-26 Mark Wielaard <mjw@redhat.com>
* dwarf_child (dwarf_child): Sanity check end of section against
diff --git a/libdw/dwarf.h b/libdw/dwarf.h
index c0dcbdd..e6a8367 100644
--- a/libdw/dwarf.h
+++ b/libdw/dwarf.h
@@ -1,5 +1,5 @@
/* This file defines standard DWARF types, structures, and macros.
- Copyright (C) 2000-2010 Red Hat, Inc.
+ Copyright (C) 2000-2011 Red Hat, Inc.
This file is part of Red Hat elfutils.
Red Hat elfutils is free software; you can redistribute it and/or modify
@@ -487,6 +487,11 @@ enum
DW_OP_GNU_encoded_addr = 0xf1,
DW_OP_GNU_implicit_pointer = 0xf2,
DW_OP_GNU_entry_value = 0xf3,
+ DW_OP_GNU_const_type = 0xf4,
+ DW_OP_GNU_regval_type = 0xf5,
+ DW_OP_GNU_deref_type = 0xf6,
+ DW_OP_GNU_convert = 0xf7,
+ DW_OP_GNU_reinterpret = 0xf9,
DW_OP_lo_user = 0xe0, /* Implementation-defined range start. */
DW_OP_hi_user = 0xff /* Implementation-defined range end. */
diff --git a/src/ChangeLog b/src/ChangeLog
index 4de8162..5f164e0 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,9 @@
+2011-05-16 Jakub Jelinek <jakub@redhat.com>
+
+ * readelf.c (print_ops): Handle DW_OP_GNU_const_type,
+ DW_OP_GNU_regval_type, DW_OP_GNU_deref_type, DW_OP_GNU_convert
+ and DW_OP_GNU_reinterpret.
+
2011-05-17 Mark Wielaard <mjw@redhat.com>
* readelf.c (dwarf_tag_string): Fixup DW_TAG_GNU_call_site and
diff --git a/src/readelf.c b/src/readelf.c
index 72be502..1d92491 100644
--- a/src/readelf.c
+++ b/src/readelf.c
@@ -4064,6 +4064,11 @@ print_ops (Dwfl_Module *dwflmod, Dwarf *dbg, int indent, int indentrest,
[DW_OP_stack_value] = "stack_value",
[DW_OP_GNU_implicit_pointer] = "GNU_implicit_pointer",
[DW_OP_GNU_entry_value] = "GNU_entry_value",
+ [DW_OP_GNU_const_type] = "GNU_const_type",
+ [DW_OP_GNU_regval_type] = "GNU_regval_type",
+ [DW_OP_GNU_deref_type] = "GNU_deref_type",
+ [DW_OP_GNU_convert] = "GNU_convert",
+ [DW_OP_GNU_reinterpret] = "GNU_reinterpret",
};
if (len == 0)
@@ -4343,6 +4348,55 @@ print_ops (Dwfl_Module *dwflmod, Dwarf *dbg, int indent, int indentrest,
offset += 1 + (data - start);
break;
+ case DW_OP_GNU_const_type:
+ /* DIE offset, size plus block. */
+ start = data;
+ NEED (2);
+ get_uleb128 (uleb, data); /* XXX check overrun */
+ uint8_t usize = *(uint8_t *) data++;
+ NEED (usize);
+ printf ("%*s[%4" PRIuMAX "] %s [%6" PRIxMAX "] ",
+ indent, "", (uintmax_t) offset, known[op], uleb);
+ print_block (usize, data);
+ data += usize;
+ CONSUME (data - start);
+ offset += 1 + (data - start);
+ break;
+
+ case DW_OP_GNU_regval_type:
+ start = data;
+ NEED (2);
+ get_uleb128 (uleb, data); /* XXX check overrun */
+ get_uleb128 (uleb2, data); /* XXX check overrun */
+ printf ("%*s[%4" PRIuMAX "] %s %" PRIu64 " %#" PRIx64 "\n",
+ indent, "", (uintmax_t) offset, known[op], uleb, uleb2);
+ CONSUME (data - start);
+ offset += 1 + (data - start);
+ break;
+
+ case DW_OP_GNU_deref_type:
+ start = data;
+ NEED (2);
+ usize = *(uint8_t *) data++;
+ get_uleb128 (uleb, data); /* XXX check overrun */
+ printf ("%*s[%4" PRIuMAX "] %s %" PRIu8 " [%6" PRIxMAX "]\n",
+ indent, "", (uintmax_t) offset,
+ known[op], usize, uleb);
+ CONSUME (data - start);
+ offset += 1 + (data - start);
+ break;
+
+ case DW_OP_GNU_convert:
+ case DW_OP_GNU_reinterpret:
+ start = data;
+ NEED (1);
+ get_uleb128 (uleb, data); /* XXX check overrun */
+ printf ("%*s[%4" PRIuMAX "] %s [%6" PRIxMAX "]\n",
+ indent, "", (uintmax_t) offset, known[op], uleb);
+ CONSUME (data - start);
+ offset += 1 + (data - start);
+ break;
+
default:
/* No Operand. */
if (op < sizeof known / sizeof known[0] && known[op] != NULL)
commit 99cd353bdb68e74d5dad5869b2fa6b4a4aaefd72
Author: Jakub Jelinek <jakub@redhat.com>
Date: Tue May 17 22:55:50 2011 +0200
dwarf-opcodes.h add GNU_const_type/regval_type/deref_type/convert/reinterpret.
diff --git a/src/dwarf-opcodes.h b/src/dwarf-opcodes.h
index 3631bef..f615cb8 100644
--- a/src/dwarf-opcodes.h
+++ b/src/dwarf-opcodes.h
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2009 Red Hat, Inc.
+ Copyright (C) 2009-2011 Red Hat, Inc.
This file is part of Red Hat elfutils.
Red Hat elfutils is free software; you can redistribute it and/or modify
@@ -209,4 +209,11 @@
DW_OP_2 (DW_OP_GNU_implicit_pointer, DW_FORM_ref_addr, DW_FORM_sdata) \
/* GNU variant for tracking of values passed as arguments to functions. */ \
/* http://www.dwarfstd.org/ShowIssue.php?issue=100909.1 */ \
- DW_OP_1 (DW_OP_GNU_entry_value, DW_FORM_block)
+ DW_OP_1 (DW_OP_GNU_entry_value, DW_FORM_block) \
+ /* The GNU typed stack extension. */ \
+ /* See http://www.dwarfstd.org/doc/040408.1.html */ \
+ DW_OP_2 (DW_OP_GNU_const_type, DW_FORM_udata, DW_FORM_block1) \
+ DW_OP_2 (DW_OP_GNU_regval_type, DW_FORM_udata, DW_FORM_udata) \
+ DW_OP_2 (DW_OP_GNU_deref_type, DW_FORM_data1, DW_FORM_udata) \
+ DW_OP_1 (DW_OP_GNU_convert, DW_FORM_udata) \
+ DW_OP_1 (DW_OP_GNU_reinterpret, DW_FORM_udata)