This is the mail archive of the
systemtap@sourceware.org
mailing list for the systemtap project.
WIP fix for PR 12997
- From: Tom Tromey <tromey at redhat dot com>
- To: systemtap at sourceware dot org
- Date: Fri, 16 Mar 2012 10:54:53 -0600
- Subject: WIP fix for PR 12997
I tried stap on an executable that uses the new DWARF 4 .debug_types
section. This failed, but the appended patch seems sufficient to make
it work for me.
I didn't try to solve the ET_REL case pointed out in the PR.
I wasn't sure if there are other code paths that are important to test.
This fixed the simple initial case I came up with; details in the commit
message. Are there other things I should look at?
I did look at the other places mentioning DW_TAG_compile_unit, and of
these, only dwflpp::cache_die_parents seemed like it might possibly need
to also mention DW_TAG_type_unit. I didn't look into making a test case
for this.
Tom
>From 6dbd77fef349172f478302ba6fff28dde090a049 Mon Sep 17 00:00:00 2001
From: Tom Tromey <tromey@redhat.com>
Date: Fri, 16 Mar 2012 10:44:14 -0600
Subject: [PATCH] Partial fix for PR12997 - support dwarf4 .debug_types
This fix does not solve the ET_REL case pointed out in the PR.
However, it does work ok for ordinary code.
* dwflpp.cxx (dwflpp::iterate_over_cus): Iterate over type units.
(dwflpp::iterate_over_globals): Also allow DW_TAG_type_unit.
I built gdb with '-gdwarf-4 -fdebug-types-section'.
Then I tried this stap script:
probe process("/home/tromey/gnu/archer/build/gdb/gdb").function("dwarf2_attr") {
println(@cast($dwarf2_per_objfile, "struct dwarf2_per_objfile")->objfile)
}
With Fedora 16 stap:
barimba. stap -p2 /tmp/q.stp
semantic error: type definition 'struct dwarf2_per_objfile' not found: identifier '@cast' at /tmp/q.stp:2:15
source: println(@cast($dwarf2_per_objfile, "struct dwarf2_per_objfile")->objfile)
^
Pass 2: analysis failed. Try again with another '--vp 01' option.
After the patch, this works.
---
dwflpp.cxx | 19 +++++++++++++++++--
1 files changed, 17 insertions(+), 2 deletions(-)
diff --git a/dwflpp.cxx b/dwflpp.cxx
index 7a659c4..758af8a 100644
--- a/dwflpp.cxx
+++ b/dwflpp.cxx
@@ -1,5 +1,5 @@
// C++ interface to dwfl
-// Copyright (C) 2005-2011 Red Hat Inc.
+// Copyright (C) 2005-2012 Red Hat Inc.
// Copyright (C) 2005-2007 Intel Corporation.
// Copyright (C) 2008 James.Bottomley@HansenPartnership.com
//
@@ -429,6 +429,20 @@ dwflpp::iterate_over_cus (int (*callback)(Dwarf_Die * die, void * arg),
v->push_back (*die); /* copy */
off = noff;
}
+
+ // Process type units.
+ off = 0;
+ uint64_t type_signature;
+ while (dwarf_next_unit (dw, off, &noff, &cuhl, NULL, NULL, NULL, NULL,
+ &type_signature, NULL) == 0)
+ {
+ if (pending_interrupts) return;
+ Dwarf_Die die_mem;
+ Dwarf_Die *die;
+ die = dwarf_offdie_types (dw, off + cuhl, &die_mem);
+ v->push_back (*die); /* copy */
+ off = noff;
+ }
}
for (vector<Dwarf_Die>::iterator i = v->begin(); i != v->end(); ++i)
@@ -1031,7 +1045,8 @@ dwflpp::iterate_over_globals (Dwarf_Die *cu_die,
void * data)
{
assert (cu_die);
- assert (dwarf_tag(cu_die) == DW_TAG_compile_unit);
+ assert (dwarf_tag(cu_die) == DW_TAG_compile_unit
+ || dwarf_tag(cu_die) == DW_TAG_type_unit);
// If this is C++, recurse for any inner types
bool has_inner_types = dwarf_srclang(cu_die) == DW_LANG_C_plus_plus;
--
1.7.7.6