linux-perf-users.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Christian Convey <christian.convey@gmail.com>
To: Milian Wolff <milian.wolff@kdab.com>
Cc: linux-perf-users@vger.kernel.org
Subject: Re: newbie question: tracing userspace call/return sequences
Date: Fri, 6 Jan 2017 15:05:05 -0500	[thread overview]
Message-ID: <CAPfS4ZyBOz_E5k3DKf8qqMbrKacCpijBM4-aUsgeL5LJTnxNyw@mail.gmail.com> (raw)
In-Reply-To: <3722511.TPbTubHR2j@milian-kdab2>

On Fri, Jan 6, 2017 at 5:16 AM, Milian Wolff <milian.wolff@kdab.com> wrote:
...
> There is a catch-all handler:
>
> *trace_unhandled*, if defined, is called after for any event that
>  doesn't have a handler explicitly defined for it.  The standard set
>  of common arguments are passed into it:
>
> ----
> def trace_unhandled(event_name, context, common_cpu, common_secs,
>         common_nsecs, common_pid, common_comm):
>     pass
> ----
>
> Maybe you can use that one instead? I'd still be interested to know whether
> you can get all required information. If not, extending the API is doable.

Hi Milian,

Thanks for the idea - I tried it out.  My Python script was a bit ugly
/ hackish, but it did allow me to trace basic call/return information.

With your approach, it was also easy to trace the return-value of each
function call: I modified my return-probe definition to be "*:%return
$retval".  After that, the "trace_unhandled" function can access the
return value via "event_fields_dict['arg1']".

There are two more improvements I'd like to make, but they're less important:

(1) For each function being traced, I'd like to report the values of
all of its parameters.  (SystemTap makes this easy.)  Unfortunately,
`perf probe`'s probe-argument syntax seems to require that I know the
name of every function-parameter I want to probe.  So I may end up
having to write a script that parses either (a) the target program's
DWARF info, or (b) the output of `perf probe --vars`.

(2) I want the tracing to be robust even if the target program
dynamically links to `.so` files that I didn't anticipate when
creating the probes.  I haven't found any documentation regarding how
gracefully perf, SystemTap, etc. handle that situation.  I'm not sure
how I'd solve this problem.  Perhaps hooking `dlopen` is an option.

- Christian

  reply	other threads:[~2017-01-06 20:05 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-01-06  3:49 newbie question: tracing userspace call/return sequences Christian Convey
2017-01-06 10:16 ` Milian Wolff
2017-01-06 20:05   ` Christian Convey [this message]
2017-01-07 23:44     ` Masami Hiramatsu
2017-01-09 15:19       ` Christian Convey
2017-01-09 17:03         ` Naveen N. Rao
2017-01-09 17:59           ` Christian Convey
2017-01-10  0:25             ` Masami Hiramatsu
2017-01-10  2:32               ` Christian Convey
2017-01-06 18:49 ` Andi Kleen
2017-01-06 19:07   ` Christian Convey
2017-01-07  4:37     ` Namhyung Kim
2017-01-07 18:26       ` Christian Convey
2017-01-07 19:08       ` Andi Kleen
2017-01-08  8:08         ` Namhyung Kim
2017-01-06 19:23   ` Arnaldo Carvalho de Melo
2017-01-09 17:20 ` Frank Ch. Eigler
2017-01-09 18:08   ` Christian Convey

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CAPfS4ZyBOz_E5k3DKf8qqMbrKacCpijBM4-aUsgeL5LJTnxNyw@mail.gmail.com \
    --to=christian.convey@gmail.com \
    --cc=linux-perf-users@vger.kernel.org \
    --cc=milian.wolff@kdab.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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 NNTP newsgroup(s).