All of lore.kernel.org
 help / color / mirror / Atom feed
* Callgraph access from python script
@ 2015-09-28 17:12 Milian Wolff
  2015-09-28 21:08 ` Milian Wolff
  0 siblings, 1 reply; 3+ messages in thread
From: Milian Wolff @ 2015-09-28 17:12 UTC (permalink / raw)
  To: linux-perf-users

[-- Attachment #1: Type: text/plain, Size: 994 bytes --]

Hey all,

This was asked before, but I still cannot find any good documentation on the 
matter. How does one access the callgraph from a python script generated by 
perf script? The export-to-postgresql.py seems to indicate that this feature 
was added, but the code is too convoluted for me to grasp.

Looking at the code for trace-event-python.c I see that there is a 
common_callchain, but I don't get such code generate:

perf record --call-graph dwarf kwrite
perf script -g python

the result is: https://paste.kde.org/p0uazuubi

Note how the `while ((event = trace_find_next_event(pevent, event)))` loop has 
not triggered any output. The reason is that pevent is NULL - where is that 
supposed to be set when looking at builtin-script.c?

Can someone explain me what I'm doing wrong? Can someone reproduce the odd 
behavior above?
-- 
Milian Wolff | milian.wolff@kdab.com | Software Engineer
KDAB (Deutschland) GmbH&Co KG, a KDAB Group company
Tel: +49-30-521325470
KDAB - The Qt Experts

[-- Attachment #2: smime.p7s --]
[-- Type: application/pkcs7-signature, Size: 5903 bytes --]

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

* Re: Callgraph access from python script
  2015-09-28 17:12 Callgraph access from python script Milian Wolff
@ 2015-09-28 21:08 ` Milian Wolff
  2015-09-28 21:32   ` Milian Wolff
  0 siblings, 1 reply; 3+ messages in thread
From: Milian Wolff @ 2015-09-28 21:08 UTC (permalink / raw)
  To: linux-perf-users

[-- Attachment #1: Type: text/plain, Size: 1629 bytes --]

On Montag, 28. September 2015 19:12:27 CEST Milian Wolff wrote:
> Hey all,
> 
> This was asked before, but I still cannot find any good documentation on the
> matter. How does one access the callgraph from a python script generated by
> perf script? The export-to-postgresql.py seems to indicate that this
> feature was added, but the code is too convoluted for me to grasp.
> 
> Looking at the code for trace-event-python.c I see that there is a
> common_callchain, but I don't get such code generate:
> 
> perf record --call-graph dwarf kwrite
> perf script -g python
> 
> the result is: https://paste.kde.org/p0uazuubi
> 
> Note how the `while ((event = trace_find_next_event(pevent, event)))` loop
> has not triggered any output. The reason is that pevent is NULL - where is
> that supposed to be set when looking at builtin-script.c?
> 
> Can someone explain me what I'm doing wrong? Can someone reproduce the odd
> behavior above?

OK, so it seems the above only cares for trace points, as the name suggests. 
I.e. it works for files where I trace e.g. -e syscalls:sys_enter_open.

Why is it not possible to script perf for data obtained from counters? I'd 
hoped to use that to convert the perf output to callgrind format, in order to 
open it with kcachegrind.

Considering that `perf script` without any arguments prints out all the 
required information, I can of course write a wrapper script around it, but 
using it directly would have been much better.

Bye

-- 
Milian Wolff | milian.wolff@kdab.com | Software Engineer
KDAB (Deutschland) GmbH&Co KG, a KDAB Group company
Tel: +49-30-521325470
KDAB - The Qt Experts

[-- Attachment #2: smime.p7s --]
[-- Type: application/pkcs7-signature, Size: 5903 bytes --]

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

* Re: Callgraph access from python script
  2015-09-28 21:08 ` Milian Wolff
@ 2015-09-28 21:32   ` Milian Wolff
  0 siblings, 0 replies; 3+ messages in thread
From: Milian Wolff @ 2015-09-28 21:32 UTC (permalink / raw)
  To: linux-perf-users

[-- Attachment #1: Type: text/plain, Size: 2025 bytes --]

On Montag, 28. September 2015 23:08:39 CEST Milian Wolff wrote:
> On Montag, 28. September 2015 19:12:27 CEST Milian Wolff wrote:
> > Hey all,
> > 
> > This was asked before, but I still cannot find any good documentation on
> > the matter. How does one access the callgraph from a python script
> > generated by perf script? The export-to-postgresql.py seems to indicate
> > that this feature was added, but the code is too convoluted for me to
> > grasp.
> > 
> > Looking at the code for trace-event-python.c I see that there is a
> > common_callchain, but I don't get such code generate:
> > 
> > perf record --call-graph dwarf kwrite
> > perf script -g python
> > 
> > the result is: https://paste.kde.org/p0uazuubi
> > 
> > Note how the `while ((event = trace_find_next_event(pevent, event)))` loop
> > has not triggered any output. The reason is that pevent is NULL - where is
> > that supposed to be set when looking at builtin-script.c?
> > 
> > Can someone explain me what I'm doing wrong? Can someone reproduce the odd
> > behavior above?
> 
> OK, so it seems the above only cares for trace points, as the name suggests.
> I.e. it works for files where I trace e.g. -e syscalls:sys_enter_open.
> 
> Why is it not possible to script perf for data obtained from counters? I'd
> hoped to use that to convert the perf output to callgrind format, in order
> to open it with kcachegrind.
> 
> Considering that `perf script` without any arguments prints out all the
> required information, I can of course write a wrapper script around it, but
> using it directly would have been much better.

Studying the code further I stumbled upon process_event which seems to do what 
I want. At least that function get a dict with all information, including 
callchain, and also works with perf data files obtained from a counter.

Could someone please document that?

Thanks
-- 
Milian Wolff | milian.wolff@kdab.com | Software Engineer
KDAB (Deutschland) GmbH&Co KG, a KDAB Group company
Tel: +49-30-521325470
KDAB - The Qt Experts

[-- Attachment #2: smime.p7s --]
[-- Type: application/pkcs7-signature, Size: 5903 bytes --]

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

end of thread, other threads:[~2015-09-28 21:32 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-09-28 17:12 Callgraph access from python script Milian Wolff
2015-09-28 21:08 ` Milian Wolff
2015-09-28 21:32   ` Milian Wolff

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.