On Mon, 15 May 2017 17:04:44 +0200, Milian Wolff wrote:
commit 1982ad48fc82c284a5cc55697a012d3357e84d01
Author: Milian Wolff <[email protected]>
Date: Wed May 24 15:21:25 2017 +0900
> --- a/tools/perf/util/unwind-libdw.c
> +++ b/tools/perf/util/unwind-libdw.c
> @@ -168,12 +168,16 @@ frame_callback(Dwfl_Frame *state, void *arg)
...
> + if (!isactivation)
> + --pc;
> +
FYI I find it as a regression a bit:
perf-4.11.4-200.fc25.x86_64
30c563 gdb_main (/usr/libexec/gdb)
fae48 main (/usr/libexec/gdb)
0x000055555564ee43 <+51>: callq 0x55555585f340 <gdb_main(captured_main_args*)>
0x000055555564ee48 <+56>: mov 0x18(%rsp),%rcx
perf-4.12.0-0.rc5.git0.1.fc27.x86_64
39e32e gdb_main (/usr/libexec/gdb)
10b6fa main (/usr/libexec/gdb)
0x000055555565f6f6 <+54>: callq 0x5555558f17a0 <gdb_main(captured_main_args*)>
0x000055555565f6fb <+59>: mov 0x18(%rsp),%rcx
In backtraces it is correct to show the source line of the calling line - as
perf does now after your fix - but one still should report PC address of the
start of the next instruction. At least this is what debuggers are used to
do:
#9 gdb_main (args=0x7fffffffe2e0) at ../../gdb/main.c:1257
#10 0x000055555565f6fb in main (argc=<optimized out>, argv=<optimized out>) at ../../gdb/gdb.c:40
0x000055555565f6f6 <+54>: callq 0x5555558f17a0 <gdb_main(captured_main_args*)>
=> 0x000055555565f6fb <+59>: mov 0x18(%rsp),%rcx
Line 40 of "../../gdb/gdb.c" starts at address 0x55555565f6f6 <main(int, char**)+54> and ends at 0x55555565f6fb <main(int, char**)+59>.
Line 41 of "../../gdb/gdb.c" starts at address 0x55555565f6fb <main(int, char**)+59> and ends at 0x55555565f715.
You see "gdb.c:40" and 0x000055555565f6fb in the backtrace despite
0x55555565f6fb is already line 41.
This is also why elfutils reports separately PC and 'isactivation' flag.
Instead of just reporting decreased PC.
Jan
On Freitag, 16. Juni 2017 08:14:56 CEST Jan Kratochvil wrote:
> On Mon, 15 May 2017 17:04:44 +0200, Milian Wolff wrote:
>
> commit 1982ad48fc82c284a5cc55697a012d3357e84d01
> Author: Milian Wolff <[email protected]>
> Date: Wed May 24 15:21:25 2017 +0900
>
> > --- a/tools/perf/util/unwind-libdw.c
> > +++ b/tools/perf/util/unwind-libdw.c
> > @@ -168,12 +168,16 @@ frame_callback(Dwfl_Frame *state, void *arg)
>
> ...
>
> > + if (!isactivation)
> > + --pc;
> > +
>
> FYI I find it as a regression a bit:
>
> perf-4.11.4-200.fc25.x86_64
> 30c563 gdb_main (/usr/libexec/gdb)
> fae48 main (/usr/libexec/gdb)
> 0x000055555564ee43 <+51>: callq 0x55555585f340
> <gdb_main(captured_main_args*)> 0x000055555564ee48 <+56>: mov
> 0x18(%rsp),%rcx
>
> perf-4.12.0-0.rc5.git0.1.fc27.x86_64
> 39e32e gdb_main (/usr/libexec/gdb)
> 10b6fa main (/usr/libexec/gdb)
> 0x000055555565f6f6 <+54>: callq 0x5555558f17a0
> <gdb_main(captured_main_args*)> 0x000055555565f6fb <+59>: mov
> 0x18(%rsp),%rcx
>
> In backtraces it is correct to show the source line of the calling line - as
> perf does now after your fix - but one still should report PC address of
> the start of the next instruction. At least this is what debuggers are
> used to do:
>
> #9 gdb_main (args=0x7fffffffe2e0) at ../../gdb/main.c:1257
> #10 0x000055555565f6fb in main (argc=<optimized out>, argv=<optimized out>)
> at ../../gdb/gdb.c:40 0x000055555565f6f6 <+54>: callq 0x5555558f17a0
> <gdb_main(captured_main_args*)> => 0x000055555565f6fb <+59>: mov
> 0x18(%rsp),%rcx
> Line 40 of "../../gdb/gdb.c" starts at address 0x55555565f6f6 <main(int,
> char**)+54> and ends at 0x55555565f6fb <main(int, char**)+59>. Line 41 of
> "../../gdb/gdb.c" starts at address 0x55555565f6fb <main(int, char**)+59>
> and ends at 0x55555565f715.
>
> You see "gdb.c:40" and 0x000055555565f6fb in the backtrace despite
> 0x55555565f6fb is already line 41.
>
> This is also why elfutils reports separately PC and 'isactivation' flag.
> Instead of just reporting decreased PC.
Excuse me, but I'm having trouble following you. The non-GDB backtraces you
are pasting do not show srcline information. So what exactly is broken? Can
you show me the differences a bit more clearly? Maybe paste the perf output
you get now and highlight what you'd expect instead? Best would be an
accompanying test case that I can use to improve the situation, if possible?
Thanks
--
Milian Wolff | [email protected] | Senior Software Engineer
KDAB (Deutschland) GmbH&Co KG, a KDAB Group company
Tel: +49-30-521325470
KDAB - The Qt Experts
On Fri, 16 Jun 2017 13:51:37 +0200, Milian Wolff wrote:
> > perf-4.12.0-0.rc5.git0.1.fc27.x86_64
> > 39e32e gdb_main (/usr/libexec/gdb)
> > 10b6fa main (/usr/libexec/gdb)
> > 0x000055555565f6f6 <+54>: callq 0x5555558f17a0 <gdb_main(captured_main_args*)
> > 0x000055555565f6fb <+59>: mov 0x18(%rsp),%rcx
[...]
> Excuse me, but I'm having trouble following you. The non-GDB backtraces you
> are pasting do not show srcline information. So what exactly is broken?
There is broken that perf now reports address 10b6fa (corresponding to
relocated address 0x000055555565f6fa) but there is no instruction on address
0x000055555565f6fa. If you 'objdump -d' it you cannot find any instruction on
adress 0x000055555565f6fa (or on address 0x10b6fa). There is instruction on
address 0x000055555565f6fb.
> Maybe paste the perf output you get now and highlight what you'd expect
> instead?
Actual:
39e32e gdb_main (/usr/libexec/gdb)
10b6fa main (/usr/libexec/gdb)
Expected:
39e32f gdb_main (/usr/libexec/gdb)
10b6fb main (/usr/libexec/gdb)
I agree perf needs to calculate with 39e32e and 10b6fa. But it should display
to user 39e32f and 10b6fb.
Jan
On Freitag, 16. Juni 2017 13:57:44 CEST Jan Kratochvil wrote:
> On Fri, 16 Jun 2017 13:51:37 +0200, Milian Wolff wrote:
> > > perf-4.12.0-0.rc5.git0.1.fc27.x86_64
> > >
> > > 39e32e gdb_main (/usr/libexec/gdb)
> > > 10b6fa main (/usr/libexec/gdb)
> > >
> > > 0x000055555565f6f6 <+54>: callq 0x5555558f17a0
> > > <gdb_main(captured_main_args*) 0x000055555565f6fb <+59>: mov
> > > 0x18(%rsp),%rcx
>
> [...]
>
> > Excuse me, but I'm having trouble following you. The non-GDB backtraces
> > you
> > are pasting do not show srcline information. So what exactly is broken?
>
> There is broken that perf now reports address 10b6fa (corresponding to
> relocated address 0x000055555565f6fa) but there is no instruction on address
> 0x000055555565f6fa. If you 'objdump -d' it you cannot find any instruction
> on adress 0x000055555565f6fa (or on address 0x10b6fa). There is
> instruction on address 0x000055555565f6fb.
>
> > Maybe paste the perf output you get now and highlight what you'd expect
> > instead?
>
> Actual:
> 39e32e gdb_main (/usr/libexec/gdb)
> 10b6fa main (/usr/libexec/gdb)
> Expected:
> 39e32f gdb_main (/usr/libexec/gdb)
> 10b6fb main (/usr/libexec/gdb)
>
> I agree perf needs to calculate with 39e32e and 10b6fa. But it should
> display to user 39e32f and 10b6fb.
Hmmm this will require some more changes throughout the stack then. I.e. we'll
have to remember the "isactivation" flag along with the original IP, and only
apply the offset then when we query for inliners or srcline information. Maybe
I can pull that off somehow in the patch series I'm working on currently,
which refactors the whole inline/srcline/callchain logic anyways.
I don't see an easy way to fix the behavior. Does anyone else? So how do we
deal with this situation in the interim? I'd prefer we keep the current
"broken" state, as I consider it less broken than what we had before... I
guess some of the core perf developers should decide how to handle this.
Thanks
--
Milian Wolff | [email protected] | Senior Software Engineer
KDAB (Deutschland) GmbH&Co KG, a KDAB Group company
Tel: +49-30-521325470
KDAB - The Qt Experts
On Sat, Jun 17, 2017 at 4:54 AM, Milian Wolff <[email protected]> wrote:
> On Freitag, 16. Juni 2017 13:57:44 CEST Jan Kratochvil wrote:
>> On Fri, 16 Jun 2017 13:51:37 +0200, Milian Wolff wrote:
>> > > perf-4.12.0-0.rc5.git0.1.fc27.x86_64
>> > >
>> > > 39e32e gdb_main (/usr/libexec/gdb)
>> > > 10b6fa main (/usr/libexec/gdb)
>> > >
>> > > 0x000055555565f6f6 <+54>: callq 0x5555558f17a0
>> > > <gdb_main(captured_main_args*) 0x000055555565f6fb <+59>: mov
>> > > 0x18(%rsp),%rcx
>>
>> [...]
>>
>> > Excuse me, but I'm having trouble following you. The non-GDB backtraces
>> > you
>> > are pasting do not show srcline information. So what exactly is broken?
>>
>> There is broken that perf now reports address 10b6fa (corresponding to
>> relocated address 0x000055555565f6fa) but there is no instruction on address
>> 0x000055555565f6fa. If you 'objdump -d' it you cannot find any instruction
>> on adress 0x000055555565f6fa (or on address 0x10b6fa). There is
>> instruction on address 0x000055555565f6fb.
>>
>> > Maybe paste the perf output you get now and highlight what you'd expect
>> > instead?
>>
>> Actual:
>> 39e32e gdb_main (/usr/libexec/gdb)
>> 10b6fa main (/usr/libexec/gdb)
>> Expected:
>> 39e32f gdb_main (/usr/libexec/gdb)
>> 10b6fb main (/usr/libexec/gdb)
>>
>> I agree perf needs to calculate with 39e32e and 10b6fa. But it should
>> display to user 39e32f and 10b6fb.
>
> Hmmm this will require some more changes throughout the stack then. I.e. we'll
> have to remember the "isactivation" flag along with the original IP, and only
> apply the offset then when we query for inliners or srcline information. Maybe
> I can pull that off somehow in the patch series I'm working on currently,
> which refactors the whole inline/srcline/callchain logic anyways.
>
> I don't see an easy way to fix the behavior. Does anyone else? So how do we
> deal with this situation in the interim? I'd prefer we keep the current
> "broken" state, as I consider it less broken than what we had before... I
> guess some of the core perf developers should decide how to handle this.
Not sure whether it needs be fixed or not. If we fix it, srcline and
address would not match so it can give its own confusion to users.
Ideally it should display an addressof the instruction before the
address IMHO.
Thanks,
Namhyung
On Sat, 17 Jun 2017 09:56:57 +0200, Namhyung Kim wrote:
> Not sure whether it needs be fixed or not. If we fix it, srcline and
> address would not match so it can give its own confusion to users.
> Ideally it should display an addressof the instruction before the
> address IMHO.
One can figure million ways how it can behave and each one has its pros and
cons. I was just describing the current behavior of GDB and LLDB which people
are used to already.
Jan
On Samstag, 17. Juni 2017 10:04:02 CEST Jan Kratochvil wrote:
> On Sat, 17 Jun 2017 09:56:57 +0200, Namhyung Kim wrote:
> > Not sure whether it needs be fixed or not. If we fix it, srcline and
> > address would not match so it can give its own confusion to users.
> > Ideally it should display an addressof the instruction before the
> > address IMHO.
>
> One can figure million ways how it can behave and each one has its pros and
> cons. I was just describing the current behavior of GDB and LLDB which
> people are used to already.
Personally, I agree with Jan that we should mimick existing tool's behavior. I
just fear that it's not trivial to do it with the current code base...
--
Milian Wolff | [email protected] | Senior Software Engineer
KDAB (Deutschland) GmbH&Co KG, a KDAB Group company
Tel: +49-30-521325470
KDAB - The Qt Experts
Em Sat, Jun 17, 2017 at 01:13:11PM +0200, Milian Wolff escreveu:
> On Samstag, 17. Juni 2017 10:04:02 CEST Jan Kratochvil wrote:
> > On Sat, 17 Jun 2017 09:56:57 +0200, Namhyung Kim wrote:
> > > Not sure whether it needs be fixed or not. If we fix it, srcline and
> > > address would not match so it can give its own confusion to users.
> > > Ideally it should display an addressof the instruction before the
> > > address IMHO.
> >
> > One can figure million ways how it can behave and each one has its pros and
> > cons. I was just describing the current behavior of GDB and LLDB which
> > people are used to already.
>
> Personally, I agree with Jan that we should mimick existing tool's behavior. I
> just fear that it's not trivial to do it with the current code base...
But we agree it is a worthwhile change (have backtraces in perf match
what gdb, etc show), right?
If you can, please try to do this, your attempt will help us understand
more the extent of the changes needed and perhaps someonw can come up
with simplifications...
- Arnaldo
On Monday, June 19, 2017 8:59:39 PM CEST Arnaldo Carvalho de Melo wrote:
> Em Sat, Jun 17, 2017 at 01:13:11PM +0200, Milian Wolff escreveu:
> > On Samstag, 17. Juni 2017 10:04:02 CEST Jan Kratochvil wrote:
> > > On Sat, 17 Jun 2017 09:56:57 +0200, Namhyung Kim wrote:
> > > > Not sure whether it needs be fixed or not. If we fix it, srcline and
> > > > address would not match so it can give its own confusion to users.
> > > > Ideally it should display an addressof the instruction before the
> > > > address IMHO.
> > >
> > > One can figure million ways how it can behave and each one has its pros
> > > and
> > > cons. I was just describing the current behavior of GDB and LLDB which
> > > people are used to already.
> >
> > Personally, I agree with Jan that we should mimick existing tool's
> > behavior. I just fear that it's not trivial to do it with the current
> > code base...
> But we agree it is a worthwhile change (have backtraces in perf match
> what gdb, etc show), right?
>
> If you can, please try to do this, your attempt will help us understand
> more the extent of the changes needed and perhaps someonw can come up
> with simplifications...
Sorry for the (long) delay, but I'm sadly busy on other things right now. I
have this on my radar and will try to find time to look into it. But it
probably won't happen before end of July. If this is urgent, maybe someone
else needs to look into it before me.
Cheers
--
Milian Wolff | [email protected] | Senior Software Engineer
KDAB (Deutschland) GmbH&Co KG, a KDAB Group company
Tel: +49-30-521325470
KDAB - The Qt Experts