public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Arnaldo Carvalho de Melo <acme@infradead.org>
To: Masami Hiramatsu <mhiramat@redhat.com>
Cc: Ingo Molnar <mingo@elte.hu>, lkml <linux-kernel@vger.kernel.org>,
	systemtap <systemtap@sources.redhat.com>,
	DLE <dle-develop@lists.sourceforge.net>,
	Paul Mackerras <paulus@samba.org>,
	Peter Zijlstra <peterz@infradead.org>,
	Mike Galbraith <efault@gmx.de>,
	Frederic Weisbecker <fweisbec@gmail.com>
Subject: Re: [PATCH -tip v2 7/8] perf probe: Remove die() from probe-finder code
Date: Fri, 9 Apr 2010 22:28:15 -0300	[thread overview]
Message-ID: <20100410012815.GC16721@ghostprotocols.net> (raw)
In-Reply-To: <4BBFB5CE.7070104@redhat.com>

Em Fri, Apr 09, 2010 at 07:18:38PM -0400, Masami Hiramatsu escreveu:
> Hi Arnaldo,
> 
> Has this code done what you suggested? :)
> I'd like to have your comment.

It improves the current situation, yes, but there are still cases there
where die() is called, I assume that is left for later, right?

More comments below.
 
> Thank you,
> 
> Masami Hiramatsu wrote:
> > Remove die() and DIE_IF() code from util/probe-finder.c since
> > these 'sudden death' in utility functions make reusing it from
> > other code (especially tui/gui) difficult.
> > 
> > Signed-off-by: Masami Hiramatsu <mhiramat@redhat.com>
> > Cc: Ingo Molnar <mingo@elte.hu>
> > Cc: Paul Mackerras <paulus@samba.org>
> > Cc: Arnaldo Carvalho de Melo <acme@redhat.com>
> > Cc: Peter Zijlstra <peterz@infradead.org>
> > Cc: Mike Galbraith <efault@gmx.de>
> > Cc: Frederic Weisbecker <fweisbec@gmail.com>
> > ---
> > 
> >  tools/perf/util/probe-event.c  |    4 
> >  tools/perf/util/probe-finder.c |  517 +++++++++++++++++++++++++---------------
> >  2 files changed, 322 insertions(+), 199 deletions(-)
> > 
> > diff --git a/tools/perf/util/probe-event.c b/tools/perf/util/probe-event.c
> > index bef2805..7893b32 100644
> > --- a/tools/perf/util/probe-event.c
> > +++ b/tools/perf/util/probe-event.c
> > @@ -151,10 +151,10 @@ static int try_to_find_kprobe_trace_events(struct perf_probe_event *pev,
> >  
> >  	/* Error path */
> >  	if (need_dwarf) {
> > -		if (ntevs == -ENOENT)
> > +		if (ntevs == -EBADF)
> >  			pr_warning("No dwarf info found in the vmlinux - "
> >  				"please rebuild with CONFIG_DEBUG_INFO=y.\n");
> > -		die("Could not analyze debuginfo.");
> > +		die("Failed to analyze debuginfo.");

Like here, the TUI/GUI can try to add a probe but if it fails it can
still continue providing things like a "perf top" window, analysing
perf.data files, doing 'perf diffs', etc.

> >  	}
> >  	pr_debug("An error occurred in debuginfo analysis."
> >  		 " Try to use symbols.\n");
> > diff --git a/tools/perf/util/probe-finder.c b/tools/perf/util/probe-finder.c
> > index 1f45285..4a57504 100644
> > --- a/tools/perf/util/probe-finder.c
> > +++ b/tools/perf/util/probe-finder.c
> > @@ -196,19 +196,7 @@ static bool die_compare_name(Dwarf_Die *dw_die, const char *tname)
> >  {
> >  	const char *name;
> >  	name = dwarf_diename(dw_die);
> > -	DIE_IF(name == NULL);
> > -	return strcmp(tname, name);
> > -}
> > -
> > -/* Get entry pc(or low pc, 1st entry of ranges)  of the die */
> > -static Dwarf_Addr die_get_entrypc(Dwarf_Die *dw_die)
> > -{
> > -	Dwarf_Addr epc;
> > -	int ret;
> > -
> > -	ret = dwarf_entrypc(dw_die, &epc);
> > -	DIE_IF(ret == -1);
> > -	return epc;
> > +	return name ? strcmp(tname, name) : -1;

This change is correct, with the stated intent :-)

> >  }
> >  
> >  /* Get type die, but skip qualifiers and typedef */
> > @@ -390,7 +378,7 @@ static Dwarf_Die *die_find_member(Dwarf_Die *st_die, const char *name,
> >   */
> >  
> >  /* Show a location */
> > -static void convert_location(Dwarf_Op *op, struct probe_finder *pf)
> > +static int convert_location(Dwarf_Op *op, struct probe_finder *pf)

Yeah, there are still lots of places, in other areas that don't return a
status, just printing a warning and silently failing, like in the trace
parsing routines

> >  {
> >  	unsigned int regn;
> >  	Dwarf_Word offs = 0;
> > @@ -400,8 +388,11 @@ static void convert_location(Dwarf_Op *op, struct probe_finder *pf)
> >  
> >  	/* If this is based on frame buffer, set the offset */
> >  	if (op->atom == DW_OP_fbreg) {
> > -		if (pf->fb_ops == NULL)
> > -			die("The attribute of frame base is not supported.\n");
> > +		if (pf->fb_ops == NULL) {
> > +			pr_warning("The attribute of frame base is not "
> > +				   "supported.\n");
> > +			return -ENOTSUP;
> > +		}

Correct, if you look at tools/perf/util/debug.c, eprintf() looks if
we're in TUI mode, use_browser is true and either fprintfs(stderr) if
not or calls a routine to put it at the "status line" (bottom) in the
TUI.

Having a list with the last messages so that we can have a log window,
or keeping it in a log file that would then be browser is an enhancement
to be made.

> >  		ref = true;
> >  		offs = op->number;
> >  		op = &pf->fb_ops[0];
> > @@ -419,50 +410,63 @@ static void convert_location(Dwarf_Op *op, struct probe_finder *pf)
> >  		ref = true;
> >  	} else if (op->atom == DW_OP_regx) {
> >  		regn = op->number;
> > -	} else
> > -		die("DW_OP %d is not supported.", op->atom);
> > +	} else {
> > +		pr_warning("DW_OP %d is not supported.\n", op->atom);
> > +		return -ENOTSUP;
> > +	}

correct

> >  	regs = get_arch_regstr(regn);
> > -	if (!regs)
> > -		die("%u exceeds max register number.", regn);
> > +	if (!regs) {
> > +		pr_warning("%u exceeds max register number.\n", regn);
> > +		return -ERANGE;
> > +	}
> >  
> >  	tvar->value = xstrdup(regs);
> >  	if (ref) {
> >  		tvar->ref = xzalloc(sizeof(struct kprobe_trace_arg_ref));

We have to kill those xzcalloc, etc, too they are die() in disguise :-)

- Arnaldo

  reply	other threads:[~2010-04-10  1:28 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-04-06 22:05 [PATCH -tip v2 0/8] perf-probe updates - data-structure support improvements, etc Masami Hiramatsu
2010-04-06 22:05 ` [PATCH -tip v2 1/8] perf probe: Support argument name Masami Hiramatsu
2010-04-06 22:05 ` [PATCH -tip v2 2/8] perf probe: Use the last field name as the " Masami Hiramatsu
2010-04-06 22:06 ` [PATCH -tip v2 3/8] tracing/kprobes: Support basic types on dynamic events Masami Hiramatsu
2010-04-06 22:06 ` [PATCH -tip v2 4/8] perf probe: Query basic types from debuginfo Masami Hiramatsu
2010-04-06 22:06 ` [PATCH -tip v2 5/8] perf probe: Support basic type casting Masami Hiramatsu
2010-04-06 22:06 ` [PATCH -tip v2 6/8] perf probe: Support DW_OP_call_frame_cfa in debuginfo Masami Hiramatsu
2010-04-06 22:06 ` [PATCH -tip v2 7/8] perf probe: Remove die() from probe-finder code Masami Hiramatsu
2010-04-09 23:18   ` Masami Hiramatsu
2010-04-10  1:28     ` Arnaldo Carvalho de Melo [this message]
2010-04-10  4:20       ` Masami Hiramatsu
2010-04-10 14:27         ` Arnaldo Carvalho de Melo
2010-04-10 16:48           ` Masami Hiramatsu
2010-04-10 18:10             ` Arnaldo Carvalho de Melo
2010-04-06 22:06 ` [PATCH -tip v2 8/8] perf probe: Remove die() from probe-event code Masami Hiramatsu

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=20100410012815.GC16721@ghostprotocols.net \
    --to=acme@infradead.org \
    --cc=dle-develop@lists.sourceforge.net \
    --cc=efault@gmx.de \
    --cc=fweisbec@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mhiramat@redhat.com \
    --cc=mingo@elte.hu \
    --cc=paulus@samba.org \
    --cc=peterz@infradead.org \
    --cc=systemtap@sources.redhat.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