Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Doug Evans <dje@google.com>
To: Pedro Alves <palves@redhat.com>
Cc: gdb-patches@sourceware.org, ratmice@gmail.com
Subject: Re: [RFA] massively speed up "info var foo" on large programs
Date: Mon, 04 Jun 2012 04:06:00 -0000	[thread overview]
Message-ID: <CADPb22Tp5auHhj+-=qHW9XDEJfh-N1HjSBGYYYKVXutT-S0Zpw@mail.gmail.com> (raw)
In-Reply-To: <4FC91A33.5040900@redhat.com>

On Fri, Jun 1, 2012 at 12:38 PM, Pedro Alves <palves@redhat.com> wrote:
> On 05/28/2012 05:49 AM, Doug Evans wrote:
>
>> On Fri, May 25, 2012 at 1:50 AM, Pedro Alves <palves@redhat.com> wrote:
>>> On 05/25/2012 09:21 AM, Doug Evans wrote:
>>>
>>>>
>>>> The output is different from the previous code, I didn't take into
>>>> account the symbols that gdb creates for @plt entries.  I think if we
>>>> want to continue to provide the current output, we should add an
>>>> option to "info var|fun|type" to produce it: the normal case shouldn't
>>>> be that slow.
>>>
>>>
>>> Different how?  The patch has no testsuite updates, so the email reader is
>>> left wondering.  ;-)
>>
>> In the "Non-debugging symbols" section of the output, when a symbol
>> would have been found in another objfile, the code would have not
>> printed the non-@plt form of the function name.
>> With this patch we have a decision to make.  Searching all the other
>> objfiles is not reasonable (IMO) so what to do?  I can think of two
>> possibilities: always print it or never print it.  Since the symbol in
>> question is an artificial symbol created by gdb I have opted for never
>> printing it.
>>
>> Thus instead of seeing this in the "Non-debugging symbols" section of
>> the output:
>>
>> 0x1234 foo@plt
>> 0x1234 foo
>>
>> the output will contain:
>>
>> 0x1234 foo@plt
>>
>> Here is v3 of the patch.  I added a testcase.
>> Regression tested on amd64-linux.
>>
>
>
> Took me a while, and a gdb.log diff of the new testcase between
> patched and unpatched gdb to grok this.  I think this output change
> is okay.
>
>> @@ -3463,21 +3505,13 @@ search_symbols (char *regexp, enum searc
>>               || regexec (&datum.preg, SYMBOL_NATURAL_NAME (msymbol), 0,
>>                           NULL, 0) == 0)
>>             {
>> -             if (0 == find_pc_symtab (SYMBOL_VALUE_ADDRESS (msymbol)))
>> -               {
>> -                 /* FIXME: carlton/2003-02-04: Given that the
>> -                    semantics of lookup_symbol keeps on changing
>> -                    slightly, it would be a nice idea if we had a
>> -                    function lookup_symbol_minsym that found the
>> -                    symbol associated to a given minimal symbol (if
>> -                    any).  */
>> -                 if (kind == FUNCTIONS_DOMAIN
>> -                     || lookup_symbol (SYMBOL_LINKAGE_NAME (msymbol),
>> -                                       (struct block *) NULL,
>> -                                       VAR_DOMAIN, 0)
>
> There's a comment above all this that talks about "lookup_symbol" that needs
> updating.

Yeah, already updated in my sandbox.

>> -                     == NULL)
>> -                   found_misc = 1;
>> -               }
>> +             /* Note: An important side-effect of these lookup functions
>> +                is to expand the symbol table if msymbol is found.  */
>
> Okay, it's an important side-effect, but why do we want the side effect
> should IMO be mentioned. It's not obvious to me (a casual reader).

Most of gdb's symbol handling is arguably non-obvious.   1/2 :-)
I've expanded the comment.

>> +             if (kind == FUNCTIONS_DOMAIN
>> +                 ? find_pc_symtab (SYMBOL_VALUE_ADDRESS (msymbol)) == NULL
>> +                 : lookup_msymbol_in_objfile (objfile, msymbol,
>> +                                              VAR_DOMAIN) == NULL)
>
> The "lookup_msymbol_in_objfile" function name threw me off for a few
> minutes, as in, "if we already know the msymbol exists in objfile, wth
> are we looking it up again?  For those important side-effects perhaps?"
> More below.

The comment for the function is pretty unambiguous.

>
>> +               found_misc = 1;
>>             }
>>
>> +/* Wrapper around lookup_symbol_aux_objfile for search_symbols.
>> + Look up MSYMBOL in DOMAIN in the global and static blocks of OBJFILE
>> + and all related objfiles. */
>> +
>> +static struct symbol *
>> +lookup_msymbol_in_objfile (struct objfile *objfile,
>> + struct minimal_symbol *msymbol,
>> + domain_enum domain)
>> +{
>> + const char *name = SYMBOL_LINKAGE_NAME (msymbol);
>
> Ah, MSYMBOL is the input, not the output!  The lookup_symbol_xxx
> functions return a symbol, so I was naively expecting this to return
> an msymbol.  IMO it'd be clearer if it'd be called something like
> lookup_symbol_of_msymbol_in_objfile then.  But, the only usage of MSYMBOL
> in the entire function is extracting its name. This would then be much
> simpler, clearer and reusable IMO if the prototype and name of
> the function was:
>
> static struct symbol *
> lookup_symbol_in_objfile (struct objfile *objfile,
>                          const char *name,
>                          domain_enum domain);
>
> And the caller did the SYMBOL_LINKAGE_NAME (msymbol) thing.

Actually, I had a similarly named function and prototype early on, but
I didn't like it.  GDB's symbol support is a mess (IMO), and I wanted
a name and usage to restrict it to the task at hand.  Anything more
general and I was pretty sure this patch would get bogged down.
Later on I want to revamp the symbol API, but I don't want this patch
tied down by that.
(For example, I don't want to bubble up the semantics of
demangle_for_lookup to the caller of this function.   Here we have an
msymbol, we know we have a mangled name.  If you want, I can go with
lookup_symbol_in_objfile but rename it to
lookup_symbol_in_objfile_from_linkage_name or some such.)


  reply	other threads:[~2012-06-04  4:06 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-05-24 17:59 Doug Evans
2012-05-24 21:28 ` Doug Evans
2012-05-25  4:29   ` Matt Rice
2012-05-25  8:21   ` Doug Evans
2012-05-25  8:51     ` Pedro Alves
2012-05-28  4:49       ` Doug Evans
2012-05-31 18:53         ` Doug Evans
2012-06-01 19:38         ` Pedro Alves
2012-06-04  4:06           ` Doug Evans [this message]
2012-06-04 15:03             ` Pedro Alves
2012-06-19  0:58               ` Doug Evans
2012-07-19  9:18                 ` Andreas Schwab
2012-07-30 17:29                   ` dje
2012-07-31  7:19                     ` Sergio Durigan Junior
2012-08-01  5:18                       ` Sergio Durigan Junior
2012-08-01 19:30                         ` dje
2012-05-25 10:04     ` Matt Rice

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='CADPb22Tp5auHhj+-=qHW9XDEJfh-N1HjSBGYYYKVXutT-S0Zpw@mail.gmail.com' \
    --to=dje@google.com \
    --cc=gdb-patches@sourceware.org \
    --cc=palves@redhat.com \
    --cc=ratmice@gmail.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