Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Sergio Durigan Junior <sergiodj@redhat.com>
To: gdb-patches@sourceware.org
Subject: Re: [RFA 4/4] Improved linker-debugger interface
Date: Tue, 17 Jul 2012 18:11:00 -0000	[thread overview]
Message-ID: <m3mx2yqmv8.fsf@redhat.com> (raw)
In-Reply-To: <20120713094150.GB2689@redhat.com> (Gary Benson's message of	"Fri, 13 Jul 2012 10:41:50 +0100")

On Friday, July 13 2012, Gary Benson wrote:

> diff --git a/gdb/solib-svr4.c b/gdb/solib-svr4.c
> index c111f04..ebb8c3c 100644
> --- a/gdb/solib-svr4.c
> +++ b/gdb/solib-svr4.c

> +/* Decide what action to take when the specified solib event probe is
> +   hit.  */
> +
> +static enum probe_action
> +solib_event_probe_action (struct probe_and_info *pi)
> +{
> +  enum probe_action action;
> +  int update;
> +  struct obj_section *os;
> +  unsigned probe_argc;
> +  struct svr4_info *info;
> +  CORE_ADDR debug_base;
> +
> +  action = pi->info->action;
> +  if (action == LM_CACHE_NO_ACTION || action == LM_CACHE_INVALIDATE)
> +    return action;
> +
> +  gdb_assert (action == LM_CACHE_RELOAD
> +	      || action == LM_CACHE_UPDATE_OR_RELOAD);
> +
> +  os = find_pc_section (pi->probe->address);
> +  if (os == NULL)
> +    return LM_CACHE_INVALIDATE;
> +
> +  /* Check that an appropriate number of arguments has been supplied.
> +     We expect:
> +       arg1: Lmid_t lmid (mandatory)
> +       arg2: struct r_debug *r_debug (mandatory)
> +       arg3: struct link_map *new (optional, for incremental updates)  */

I guess you could rename the arguments listed here to 'arg0', 'arg1' and
'arg2', because `evaluate_probe_argument' takes these numbers as
arguments.  Or you could explicitly say that here.  Otherwise it will
confuse the reader, IMO.

> +  probe_argc = get_probe_argument_count (os->objfile, pi->probe);
> +  if (probe_argc == 2)
> +    action = LM_CACHE_RELOAD;
> +  else if (probe_argc < 2)
> +    return LM_CACHE_INVALIDATE;

This is OK...

> +  /* We only currently support the global namespace (PR gdb/11839).
> +     If the probe's r_debug doesn't match the global r_debug then
> +     this event refers to some other namespace and must be ignored.  */
> +  info = get_svr4_info ();
> +
> +  /* Always locate the debug struct, in case it has moved.  */
> +  info->debug_base = 0;
> +  locate_base (info);
> +
> +  debug_base = value_as_address (evaluate_probe_argument (os->objfile,
> +							  pi->probe, 1));

...but what would happen if `evaluate_probe_argument' returned NULL?
It's better to check this, because `value_as_address' calls `value_type'
which does not check NULL pointers.

Currently, only the SystemTap backend is implemented, and if it returns
NULL in this case it would be an error, but it's better to guard your
code IMO.

Thanks,

-- 
Sergio


  parent reply	other threads:[~2012-07-17 18:11 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-07-12 12:34 [RFA 0/4] " Gary Benson
2012-07-12 12:35 ` [RFA 1/4] " Gary Benson
2012-07-12 12:36 ` [RFA 3/4] " Gary Benson
2012-07-17 18:01   ` Sergio Durigan Junior
2012-07-17 21:57   ` Jan Kratochvil
2012-07-17 23:42     ` Sergio Durigan Junior
2012-07-18  7:02       ` Jan Kratochvil
2012-07-18 10:36         ` Gary Benson
2012-07-19 14:36     ` Gary Benson
2012-07-12 12:36 ` [RFA 4/4] " Gary Benson
2012-07-13  9:42   ` Gary Benson
2012-07-13 12:20     ` Gary Benson
2012-07-17 18:11     ` Sergio Durigan Junior [this message]
2012-07-18 14:28       ` Jan Kratochvil
2012-07-18 15:11         ` Sergio Durigan Junior
2012-07-19 14:38       ` Gary Benson
2012-07-12 12:36 ` [RFA 2/4] " Gary Benson
2012-07-13  9:41   ` Gary Benson
2012-07-18 14:08 ` [RFA 0/4] " Gary Benson

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=m3mx2yqmv8.fsf@redhat.com \
    --to=sergiodj@redhat.com \
    --cc=gdb-patches@sourceware.org \
    /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