Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: jose.marchesi@oracle.com (Jose E. Marchesi)
To: Sergio Durigan Junior <sergiodj@redhat.com>
Cc: gdb-patches@sourceware.org
Subject: Re: [PATCH 5/9] New probe type: DTrace USDT probes.
Date: Fri, 10 Oct 2014 16:38:00 -0000	[thread overview]
Message-ID: <87iojrevbz.fsf@oracle.com> (raw)
In-Reply-To: <87y4syt5zn.fsf@redhat.com> (Sergio Durigan Junior's message of	"Thu, 02 Oct 2014 19:19:08 -0400")


Hi Sergio.

    > +/* The type of the ELF sections where we will find the DOF programs
    > +   with information about probes.  */
    > +
    > +#ifndef SHT_SUNW_dof
    > +# define SHT_SUNW_dof	0x6ffffff4
    > +#endif
    
    Can this macro exist in another header file that you are including?

That macro is defined in elf.h in Solaris, Minix, and probably other
systems too.  I would not be surprised if it is eventually added to the
elf headers in GNU/Linux, and also in binutils.  I strongly recommend to
keep that sentinel in place to avoid potential problems with indirect
includes in the future.

    > +
    > +      /* Number of arguments in the probe.  */
    > +      ret->probe_argc = DOF_UINT (dof, probe->dofpr_nargc);
    > +
    > +      /* Store argument type descriptions.  A description of the type
    > +         of the argument is in the (J+1)th null-terminated string
    > +         starting at `strtab' + `probe->dofpr_nargv'.  */
    
    We're not using `' anymore; instead, we're using '' (GNU Coding Style
    has been updated).

A hard-to-die habit after so many years... :)
    
    > +      ret->args = NULL;
    > +      p = strtab + DOF_UINT (dof, probe->dofpr_nargv);
    > +      for (j = 0; j < ret->probe_argc; j++)
    > +	{
    > +	  struct dtrace_probe_arg arg;
    > +	  struct expression *expr;
    > +
    > +	  arg.type_str = xstrdup (p);
    > +	  while (((p - strtab) < strtab_size) /* sentinel.  */
    > +		 && *p++);
    
    Again a matter of style, but for readability I prefer to write this loop
    as:
    
      /* Use strtab_size as a sentinel.  */
      while (*p != '\0' && p - strtab < strtab_size)
        ++p;

What you are suggesting is not exactly equivalent: it leaves `p' at the
blank character, while the idea is to leave `p' at the character next ot
the blank character.  I changed the loop to:

/* Use strtab_size as a sentinel.  */
while (*p++ != '\0' && p - strtab < strtab_size);

Which makes the comparison explicit and thus may be more palatable for
you :)
    
    > +	  VEC_safe_push (dtrace_probe_arg_s, ret->args, &arg);
    > +	}
    > +
    > +      /* Add the vector of enablers to this probe, if any.  */
    > +      ret->enablers = VEC_copy (dtrace_probe_enabler_s, enablers);
    
    You should free the enablers VEC in the end of the function.  You could
    probably make a cleanup and call it later.

Hmm, I don't see the need of doing a deep copy of the vector, nor I
remember why I felt it was necessary to do it when I wrote the original
code.

I changed that to:

/* Add the vector of enablers to this probe, if any.  */
ret->enablers = enablers;

But maybe(probably) I am missing something? :?

    > +/* Implementation of the get_probes method.  */
    > +
    > +static void
    > +dtrace_get_probes (VEC (probe_p) **probesp, struct objfile *objfile)
    > +{
    > +  bfd *abfd = objfile->obfd;
    > +  asection *sect = NULL;
    > +
    > +  /* Do nothing in case this is a .debug file, instead of the objfile
    > +     itself.  */
    > +  if (objfile->separate_debug_objfile_backlink != NULL)
    > +    return;
    > +
    > +  /* Iterate over the sections in OBJFILE looking for DTrace
    > +     information.  */
    > +  for (sect = abfd->sections; sect != NULL; sect = sect->next)
    > +    {
    > +      if (elf_section_data (sect)->this_hdr.sh_type == SHT_SUNW_dof)
    > +	{
    > +	  struct dtrace_dof_hdr *dof;
    > +
    > +	  /* Read the contents of the DOF section and then process it to
    > +	     extract the information of any probe defined into it.  */
    > +	  if (!bfd_malloc_and_get_section (abfd, sect, (bfd_byte **) &dof))
    > +	    {
    > +	      complaint (&symfile_complaints,
    > +			 _("could not obtain the contents of"
    > +			   "section '%s' in objfile `%s'."),
    > +			 sect->name, abfd->filename);
    > +	      return;
    
    Why return here?  Is there only one section whose type is SHT_SUNW_dof?
    If no, then I guess the loop should keep rolling.  Otherwise, then
    besides calling return here you should call return after the "xfree"
    below.  Am I getting it right?

Yeah, in principle there can be more than one sections of type
SHT_SUNW_dof.  I changed the code as suggested.
    
    > +	    }
    > +	  
    > +	  dtrace_process_dof (sect, objfile, probesp, dof);
    > +	  xfree (dof);
    > +	}
    > +    }
    
    What about using bfd_map_over_sections instead of this for loop?  I know
    there is precedence of iterating over BFD sections by hand on GDB code,
    but bfd_map_over_sections exists for this very purpose.

I considered that, but the need to define a new structure type for
passing `objfile' and `probesp' to the handler (not to mention the
handler itself) makes it a bit overkill to use bfd_map_over_sections in
this specific case IMO...  especially considering that
dtrace_process_dof is only called by this function.

    > +/* Implementation of the clear_semaphore method.  */
    > +
    > +static void
    > +dtrace_clear_semaphore (struct probe *probe_generic, struct objfile *objfile,
    > +			struct gdbarch *gdbarch)
    > +{
    > +  gdb_assert (probe_generic->pops == &dtrace_probe_ops);
    > +}
    
    This shouldn't be needed, because USDT probes don't have the concept of
    a semaphore, right?  I will submit a patch soon to fix the fact that the
    set/clear_semaphore functions are being called inconditionally.

Correct, that should not be needed and can go away as soon as you do
that change.


  reply	other threads:[~2014-10-10 16:38 UTC|newest]

Thread overview: 42+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <no>
2012-04-18  9:27 ` [RFA] Add proper handling for internal functions and STT_GNU_IFUNC symbols in Ada mode Paul Hilfinger
2012-04-18 14:45   ` Joel Brobecker
2012-04-22 15:33   ` [committed] " Paul Hilfinger
2014-09-26  9:43 ` [PATCH 0/9] Add support for DTrace USDT probes to gdb Jose E. Marchesi
2014-09-26  9:43   ` [PATCH 4/9] New gdbarch functions: dtrace_probe_argument, dtrace_probe_is_enabled, dtrace_enable_probe, dtrace_disable_probe Jose E. Marchesi
2014-10-02 21:34     ` Sergio Durigan Junior
2014-10-10 16:38       ` Jose E. Marchesi
2014-09-26  9:43   ` [PATCH 9/9] Announce the DTrace USDT probes support in NEWS Jose E. Marchesi
2014-09-26 13:12     ` Eli Zaretskii
2014-09-29 10:29       ` Jose E. Marchesi
2014-09-26  9:43   ` [PATCH 1/9] Adapt `info probes' to support printing probes of different types Jose E. Marchesi
2014-09-29 21:15     ` Sergio Durigan Junior
2014-10-10 16:38       ` Jose E. Marchesi
2014-09-26  9:43   ` [PATCH 5/9] New probe type: DTrace USDT probes Jose E. Marchesi
2014-09-26 13:19     ` Eli Zaretskii
2014-10-02 23:19     ` Sergio Durigan Junior
2014-10-10 16:38       ` Jose E. Marchesi [this message]
2014-10-10 18:13         ` Sergio Durigan Junior
2014-10-10 18:32           ` Jose E. Marchesi
2014-10-10 18:44             ` Sergio Durigan Junior
2014-09-26  9:43   ` [PATCH 7/9] Simple testsuite for " Jose E. Marchesi
2014-10-08 19:30     ` Sergio Durigan Junior
2014-10-10 16:38       ` Jose E. Marchesi
2014-09-26  9:43   ` [PATCH 6/9] Support for DTrace USDT probes in x86_64 targets Jose E. Marchesi
2014-10-08 19:32     ` Sergio Durigan Junior
2014-10-10 16:38       ` Jose E. Marchesi
2014-09-26  9:43   ` [PATCH 3/9] New commands `enable probe' and `disable probe' Jose E. Marchesi
2014-09-26 13:11     ` Eli Zaretskii
2014-09-29 10:26       ` Jose E. Marchesi
2014-09-30 23:13     ` Sergio Durigan Junior
2014-09-30 23:20       ` Sergio Durigan Junior
2014-10-10 16:38       ` Jose E. Marchesi
2014-09-26  9:43   ` [PATCH 8/9] Documentation for DTrace USDT probes Jose E. Marchesi
2014-09-26 13:18     ` Eli Zaretskii
2014-09-29 10:26       ` Jose E. Marchesi
2014-09-29 13:35         ` Eli Zaretskii
2014-09-29 13:53           ` Jose E. Marchesi
2014-09-26  9:43   ` [PATCH 2/9] Move `compute_probe_arg' and `compile_probe_arg' to probe.c Jose E. Marchesi
2014-09-30  0:02     ` Sergio Durigan Junior
2014-10-10 16:38       ` Jose E. Marchesi
2014-10-08 19:40   ` [PATCH 0/9] Add support for DTrace USDT probes to gdb Sergio Durigan Junior
2014-10-09  8:05     ` Jose E. Marchesi

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=87iojrevbz.fsf@oracle.com \
    --to=jose.marchesi@oracle.com \
    --cc=gdb-patches@sourceware.org \
    --cc=sergiodj@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