This is the mail archive of the
systemtap@sourceware.org
mailing list for the systemtap project.
Re: How do I trap the return of a function in a user space process?
- From: Mark Wielaard <mjw at redhat dot com>
- To: Martin Martin <martin at infinio dot com>
- Cc: "Frank Ch. Eigler" <fche at redhat dot com>, "Yichun Zhang (agentzh)" <agentzh at gmail dot com>, systemtap at sourceware dot org
- Date: Mon, 9 Sep 2013 20:13:34 +0200
- Subject: Re: How do I trap the return of a function in a user space process?
- Authentication-results: sourceware.org; auth=none
- References: <CAAQ0mPjJeQcYoKNc=1PhgCF1Z=iQjPuueTxAwQxNnzwCaCY_Hg at mail dot gmail dot com> <CAB4Tn6Oq8O_NVvfWNyrEqaNWuARMDAtK_FGWjLGHd4YaJiNMLw at mail dot gmail dot com> <CAAQ0mPjgOx3oNy5K0iXKj4wiNgC64Xy-dE_K=AeFTJB+3b4bVw at mail dot gmail dot com> <CAAQ0mPi5YLS9uv8EismftJvDcpbQHk2_eqikZsgXpDZBEXX7Lw at mail dot gmail dot com> <CAAQ0mPgQs59g7DCUZEeViKJJZKLuua4ErrBYLVc0-RMKp6xMWw at mail dot gmail dot com> <y0mppslec1l dot fsf at fche dot csb> <CAAQ0mPg4CGgNhg9TboiqUjEdBW_DMN6zdUzbi-ua7byzSK-dug at mail dot gmail dot com>
On Mon, Sep 09, 2013 at 08:23:11AM -0400, Martin Martin wrote:
> Here's a simple one. If you remove the namespace, stap -l shows fun,
> but as below, it doesn't:
>
> namespace yummy {
> class Foo {
> int fun();
> };
>
> int Foo::fun() { return 23; }
> }
>
>
> int main()
> {
> }
>
> A quick google search shows Clang doesn't pass the GDB 7.5 test suite,
> so it seems there are known errors with DWARF generation, but
> presumably something this basic should work?
The problem is that clang generates both the foo declaration TAG and
the actual foo subprogram TAG under the namespace and class_type TAG.
That isn't technically invalid DWARF, but it is somewhat cumbersome
for a DWARF consumer because it mixes the type entries and the code
entries hierarchy. That makes it much harder for the DWARF consumer
to find the actual code entry TAGs.
stap (dwflcpp.cxx) uses elfutils libdw dwarf_funcs which finds all
subprograms for a DIE tree that are direct children of the root CU die.
dwarf_funcs expects all functions of a compile unit to be represented by
subprogram DIEs that are direct children of the compile unit.
We could support the DWARF that clang outputs in this case, but that
does mean a somewhat expensive walk of the whole DIE tree. We might get
away with only looking for (nested) DW_TAG_namespace, DW_TAG_class_type
and DW_TAG_structure_type DIEs. But if so we probably also need to update
dwarf_getfuncs to handle imported_units. Which currently aren't an
issue since dwz will never place the top-level DW_TAG_subprograms
in a partial unit, but might do so when DW_TAG_subprograms are nested
in the type hierarchy like here.
Cheers,
Mark