Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Stan Shebs <stan@codesourcery.com>
To: Pedro Alves <pedro@codesourcery.com>
Cc: gdb-patches@sourceware.org, Stan Shebs <stan@codesourcery.com>
Subject: Re: [commit/RFC] fix gdb.trace/collection.exp bitrot
Date: Wed, 31 Mar 2010 21:31:00 -0000	[thread overview]
Message-ID: <4BB3BF38.3020102@codesourcery.com> (raw)
In-Reply-To: <201003290045.17238.pedro@codesourcery.com>

Pedro Alves wrote:
> That is, the tracepoint was set to collect the `argarray' argument, of:
>
>  /* Test collecting args. */
>  int args_test_func (argc, argi, argf, argd, argstruct, argarray)
>       char   argc;
>       int    argi;
>       float  argf;
>       double argd;
>       test_struct argstruct;
>       int argarray[4];
>  {
>
> But, array passing in C is special; even though the argument is
> declared like an array, only a pointer to the array passed in.
>
> So, collecting `argarray' only collects the array address, not its
> contents.  But, the test tried to print the array's contents, and,
> that fails.
>
> The question is.  What to do then?  Should the test just be
> fixed to not assume that collecting an array argument, collects
> the whole array?  I believe so.
>   

My offhand guess is that the ABI is playing a role somehow, where 
sufficiently large arrays are being passed by reference, and the type 
info going into the collection is describing it as a pointer, rather 
than an array.

I don't have a good sense about what collection *should* do though.  For 
instance, in the case of structures, a field that is an array is 
collected in its entirety.  Now collection does that as a sort of 
accident of the implementation; an array in a struct occupies bytes M 
through N of the struct's value, and so it just happens to ride along 
with the rest of the struct's fields.  But conversely, when it comes to 
strings, collection doesn't try to guess at how many bytes of the string 
to collect, it just takes the pointer.

There are a couple user-friendliness reasons to collect all the array 
elements. One, it matches what the user sees in the source code - users 
don't want to have to guess at the implementation du jour, or worse, 
have to write different tracepoint actions depending on whether a 
#define for array size expands into 2 or 20.  Second, "collect $args" 
will work as expected, and not have to be written as "collect $args, 
argarray[0]@4" (which would be hard to get right if the 4 came from a 
macro).  Third, if collection collects a little more than is strictly 
necessary, then it improves the chances that trace frames will have the 
right data on the first try, instead of requiring a re-run.

My inclination for now is just to mark as known failures, so as not to 
get too bogged down.

Stan


  parent reply	other threads:[~2010-03-31 21:31 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-03-28 23:45 Pedro Alves
2010-03-28 23:47 ` Pedro Alves
2010-03-31 21:31 ` Stan Shebs [this message]
2010-04-01  1:32   ` Pedro Alves

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=4BB3BF38.3020102@codesourcery.com \
    --to=stan@codesourcery.com \
    --cc=gdb-patches@sourceware.org \
    --cc=pedro@codesourcery.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