public inbox for systemtap@sourceware.org
 help / color / mirror / Atom feed
* Line numbers reported by pp() do not respond to the reality
@ 2010-09-05 10:09 Tim Beaulen
  2010-09-05 13:08 ` Frank Ch. Eigler
  0 siblings, 1 reply; 7+ messages in thread
From: Tim Beaulen @ 2010-09-05 10:09 UTC (permalink / raw)
  To: systemtap

When using the following script:

# --- testpp.stp ---
global calls

probe process("/home/kdesystemtap/kdeinstall/lib/kde4/plugins/styles/oxygen.so").statement("drawScrollBarSliderControl@*:*")
{
    if (execname() == "src") {
        calls[pp()] <<< 1;
    }
}

probe end
{
  printf("\n");
  foreach (call in calls) {
    printf("%s\n    calls: %10d\n", call, @count(calls[call]));
  }
}
# --------------------


And running it like this:
sudo stap ./testpp.stp

I get these results:
process("/home/kdesystemtap/kdeinstall/lib/kde4/plugins/styles/oxygen.so").statement("drawScrollBarSliderControl@/home/kdesystemtap/kde/src/trunk/KDE/kdebase/workspace/kstyles/oxygen/oxygenstyle.cpp:5024")
    calls:       2000
process("/home/kdesystemtap/kdeinstall/lib/kde4/plugins/styles/oxygen.so").statement("drawScrollBarSliderControl@/home/kdesystemtap/kde/src/trunk/KDE/kdebase/workspace/kstyles/oxygen/oxygenstyle.cpp:5018")
    calls:       2000
process("/home/kdesystemtap/kdeinstall/lib/kde4/plugins/styles/oxygen.so").statement("drawScrollBarSliderControl@/home/kdesystemtap/kde/src/trunk/KDE/kdebase/workspace/kstyles/oxygen/oxygenstyle.cpp:5011")
    calls:       2000
process("/home/kdesystemtap/kdeinstall/lib/kde4/plugins/styles/oxygen.so").statement("drawScrollBarSliderControl@/home/kdesystemtap/kde/src/trunk/KDE/kdebase/workspace/kstyles/oxygen/oxygenstyle.cpp:5009")
    calls:       2000
process("/home/kdesystemtap/kdeinstall/lib/kde4/plugins/styles/oxygen.so").statement("drawScrollBarSliderControl@/home/kdesystemtap/kde/src/trunk/KDE/kdebase/workspace/kstyles/oxygen/oxygenstyle.cpp:5004")
    calls:       2000
process("/home/kdesystemtap/kdeinstall/lib/kde4/plugins/styles/oxygen.so").statement("drawScrollBarSliderControl@/home/kdesystemtap/kde/src/trunk/KDE/kdebase/workspace/kstyles/oxygen/oxygenstyle.cpp:5003")
    calls:       2000
process("/home/kdesystemtap/kdeinstall/lib/kde4/plugins/styles/oxygen.so").statement("drawScrollBarSliderControl@/home/kdesystemtap/kde/src/trunk/KDE/kdebase/workspace/kstyles/oxygen/oxygenstyle.cpp:5002")
    calls:       2000
process("/home/kdesystemtap/kdeinstall/lib/kde4/plugins/styles/oxygen.so").statement("drawScrollBarSliderControl@/home/kdesystemtap/kde/src/trunk/KDE/kdebase/workspace/kstyles/oxygen/oxygenstyle.cpp:5001")
    calls:       2000
process("/home/kdesystemtap/kdeinstall/lib/kde4/plugins/styles/oxygen.so").statement("drawScrollBarSliderControl@/home/kdesystemtap/kde/src/trunk/KDE/kdebase/workspace/kstyles/oxygen/oxygenstyle.cpp:4998")
    calls:       2000
process("/home/kdesystemtap/kdeinstall/lib/kde4/plugins/styles/oxygen.so").statement("drawScrollBarSliderControl@/home/kdesystemtap/kde/src/trunk/KDE/kdebase/workspace/kstyles/oxygen/oxygenstyle.cpp:4999")
    calls:       2000
process("/home/kdesystemtap/kdeinstall/lib/kde4/plugins/styles/oxygen.so").statement("drawScrollBarSliderControl@/home/kdesystemtap/kde/src/trunk/KDE/kdebase/workspace/kstyles/oxygen/oxygenstyle.cpp:4996")
    calls:       2000
process("/home/kdesystemtap/kdeinstall/lib/kde4/plugins/styles/oxygen.so").statement("drawScrollBarSliderControl@/home/kdesystemtap/kde/src/trunk/KDE/kdebase/workspace/kstyles/oxygen/oxygenstyle.cpp:4995")
    calls:       2000



As you can see, the line numbers start at 4995 and end at 5024.

The actual part of the .cpp file including the line numbers:

4947    bool Style::drawScrollBarSliderControl( const QStyleOption*
option, QPainter* painter, const QWidget* widget ) const
4948    {
4949
4950        // cast option and check
4951        const QStyleOptionSlider *slider = qstyleoption_cast<const
QStyleOptionSlider *>( option );
4952        if( !slider ) return true;
4953
4954        const QRect& r( option->rect );
4955        const QPalette& palette( option->palette );
4956
4957        const State& flags( option->state );
4958        const bool horizontal( flags & State_Horizontal );
4959        const bool enabled( flags&State_Enabled );
4960        const bool mouseOver( enabled && (flags&State_MouseOver) );
4961
4962        // enable animation state
4963        animations().scrollBarEngine().updateState( widget,
enabled && slider && (slider->activeSubControls & SC_ScrollBarSlider)
);
4964
4965        const bool animated( enabled &&
animations().scrollBarEngine().isAnimated( widget, SC_ScrollBarSlider
) );
4966
4967        if( horizontal )
4968        {
4969            if( animated ) renderScrollBarHandle( painter, r,
palette, Qt::Horizontal, mouseOver,
animations().scrollBarEngine().opacity( widget, SC_ScrollBarSlider )
);
4970            else renderScrollBarHandle( painter, r, palette,
Qt::Horizontal, mouseOver );
4971
4972        } else {
4973
4974            if( animated ) renderScrollBarHandle( painter, r,
palette, Qt::Vertical, mouseOver,
animations().scrollBarEngine().opacity( widget, SC_ScrollBarSlider )
);
4975            else renderScrollBarHandle( painter, r, palette,
Qt::Vertical, mouseOver );
4976
4977        }
4978
4979        return true;
4980    }

As you can see, the line numbers differ. Why is that? Maybe I don not
understand the line numbers reported by pp().
I was hoping to make some sort of automatic report generator that
would be able to parse the correct line from the source file, but this
difference makes this impossible.

I am using Systemtap 1.2.

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Line numbers reported by pp() do not respond to the reality
  2010-09-05 10:09 Line numbers reported by pp() do not respond to the reality Tim Beaulen
@ 2010-09-05 13:08 ` Frank Ch. Eigler
  2010-09-05 18:11   ` Tim Beaulen
  0 siblings, 1 reply; 7+ messages in thread
From: Frank Ch. Eigler @ 2010-09-05 13:08 UTC (permalink / raw)
  To: Tim Beaulen; +Cc: systemtap

Tim Beaulen <tbscope@gmail.com> writes:

> I get these results: [...]
> As you can see, the line numbers start at 4995 and end at 5024.
>
> The actual part of the .cpp file including the line numbers:
> 4947    bool Style::drawScrollBarSliderControl( const QStyleOption*
> option, QPainter* painter, const QWidget* widget ) const
> [...]
> 4980    }
>
> As you can see, the line numbers differ. Why is that?

They should not, something odd is going on.  When you run stap -p2 on
your script, you should get some PC addresses for the actual statement
probes.  Running binutils' addr2line on those addresses should resolve
to the same source file / line that stap.  Similarly, putting a gdb
breakpoint on the same file / line should resolve to basically the same
addresses (modulo shared library relocation type complications).

Can you compare some of the systemtap-computed values to addr2line &
gdb?

- FChE

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Line numbers reported by pp() do not respond to the reality
  2010-09-05 13:08 ` Frank Ch. Eigler
@ 2010-09-05 18:11   ` Tim Beaulen
       [not found]     ` <AANLkTi=PcchooJZCTkurLpYsWEhGwc=kdsdXmJ=F3bkq@mail.gmail.com>
  2010-09-06  7:59     ` Tim Beaulen
  0 siblings, 2 replies; 7+ messages in thread
From: Tim Beaulen @ 2010-09-05 18:11 UTC (permalink / raw)
  To: Frank Ch. Eigler; +Cc: systemtap

sudo stap -p2 ./testpp.stp
...
# probes
process("/home/kdesystemtap/kdeinstall/lib/kde4/plugins/styles/oxygen.so").statement("drawScrollBarSliderControl@/home/kdesystemtap/kde/src/trunk/KDE/kdebase/workspace/kstyles/oxygen/oxygenstyle.cpp:4995")
/* pc=.dynamic+0x92035 */ /* <-
process("/home/kdesystemtap/kdeinstall/lib/kde4/plugins/styles/oxygen.so").statement("drawScrollBarSliderControl@*:*")
*/
...


addr2line -e /home/kdesystemtap/kdeinstall/lib/kde4/plugins/styles/oxygen.so
0x92035
/home/kdesystemtap/kde/src/trunk/KDE/kdebase/workspace/kstyles/oxygen/oxygenstyle.cpp:4995


I also checked with:
readelf --debug-dump=decodedline
/home/kdesystemtap/kdeinstall/lib/kde4/plugins/styles/oxygen.so
When I look up the address in this table, I get the same line number: 4995


I haven't checked with GDB yet but since this is the information in
the debug sections, I don't think GDB will report the correct line
number either.


I compiled everything as usual, I only added the -g compiler option.

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Line numbers reported by pp() do not respond to the reality
       [not found]     ` <AANLkTi=PcchooJZCTkurLpYsWEhGwc=kdsdXmJ=F3bkq@mail.gmail.com>
@ 2010-09-05 18:39       ` Tim Beaulen
  0 siblings, 0 replies; 7+ messages in thread
From: Tim Beaulen @ 2010-09-05 18:39 UTC (permalink / raw)
  To: systemtap

After reading the gcc man page, I think the problem is optimisation.
Like I said, I didn't change any compiler options, I only added -g.

I'll try again without optimisation.

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Line numbers reported by pp() do not respond to the reality
  2010-09-05 18:11   ` Tim Beaulen
       [not found]     ` <AANLkTi=PcchooJZCTkurLpYsWEhGwc=kdsdXmJ=F3bkq@mail.gmail.com>
@ 2010-09-06  7:59     ` Tim Beaulen
  2010-09-06 12:18       ` Frank Ch. Eigler
  1 sibling, 1 reply; 7+ messages in thread
From: Tim Beaulen @ 2010-09-06  7:59 UTC (permalink / raw)
  To: Frank Ch. Eigler; +Cc: systemtap

I tried without optimising and everything is correct.

I know this is basic knowledge, I'm learning it by doing and making mistakes.
Sorry for the noise.

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Line numbers reported by pp() do not respond to the reality
  2010-09-06  7:59     ` Tim Beaulen
@ 2010-09-06 12:18       ` Frank Ch. Eigler
  2010-09-12  8:26         ` Tim Beaulen
  0 siblings, 1 reply; 7+ messages in thread
From: Frank Ch. Eigler @ 2010-09-06 12:18 UTC (permalink / raw)
  To: Tim Beaulen; +Cc: systemtap

Hi -

> I tried without optimising and everything is correct.

OK, but ...

> I know this is basic knowledge, I'm learning it by doing and making mistakes.
> Sorry for the noise.

Not at all.  I don't think this represents pilot error.  Tools like
systemtap are meant to opeate in the face of optimized, deployed
applications, not just -O0 -g ones.  It would be good to fully
understand the phenomenon here.

To that end, would you be able to share the .i file, and the object
file in question with and without -O*, along with exact gcc version
data?


- FChE

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Line numbers reported by pp() do not respond to the reality
  2010-09-06 12:18       ` Frank Ch. Eigler
@ 2010-09-12  8:26         ` Tim Beaulen
  0 siblings, 0 replies; 7+ messages in thread
From: Tim Beaulen @ 2010-09-12  8:26 UTC (permalink / raw)
  To: Frank Ch. Eigler; +Cc: systemtap

On Mon, Sep 6, 2010 at 2:18 PM, Frank Ch. Eigler <fche@redhat.com> wrote:
>
> Not at all.  I don't think this represents pilot error.  Tools like
> systemtap are meant to opeate in the face of optimized, deployed
> applications, not just -O0 -g ones.  It would be good to fully
> understand the phenomenon here.
>
> To that end, would you be able to share the .i file, and the object
> file in question with and without -O*, along with exact gcc version
> data?
>
>
> - FChE
>

Sorry for the delay. I didn't have time in the past week.

I tried to reproduce the difference, but now I get the same results
with and without optimisation.
I need to do some more research.

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2010-09-12  8:26 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-09-05 10:09 Line numbers reported by pp() do not respond to the reality Tim Beaulen
2010-09-05 13:08 ` Frank Ch. Eigler
2010-09-05 18:11   ` Tim Beaulen
     [not found]     ` <AANLkTi=PcchooJZCTkurLpYsWEhGwc=kdsdXmJ=F3bkq@mail.gmail.com>
2010-09-05 18:39       ` Tim Beaulen
2010-09-06  7:59     ` Tim Beaulen
2010-09-06 12:18       ` Frank Ch. Eigler
2010-09-12  8:26         ` Tim Beaulen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).