Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Keith Seitz <keiths@redhat.com>
To: Tom de Vries <tdevries@suse.de>, gdb-patches@sourceware.org
Subject: Re: [PATCH][gdb/symtab] Fix language of duplicate static minimal symbol
Date: Tue, 30 Oct 2018 21:21:00 -0000	[thread overview]
Message-ID: <07e42727-0d74-7f04-ef7c-39e180f71da8@redhat.com> (raw)
In-Reply-To: <20181030191142.GA13785@delia>

On 10/30/18 12:11 PM, Tom de Vries wrote:
> However, when we use gdb to print info on foo, both foos are listed, but we
> get one symbol mangled and one symbol demangled:
> ...
> $ gdb ./a.out -batch -ex "info func foo"
> All functions matching regular expression "foo":
> 
> Non-debugging symbols:
> 0x00000000004004c7  foo()
> 0x00000000004004dd  _ZL3foov
> ...
> 

Good catch!

> Build and reg-tested on x86_64-linux.
> 
> OK for trunk?

I have just a few comments.

> 2018-10-30  Tom de Vries  <tdevries@suse.de>
> 
> 	* symtab.c (symbol_set_names): Call symbol_find_demangled_name
> 	unconditionally, to get the language of the symbol.

s/get/set/ ? When reading the patch, I originally wondered how that would help,
but symbol_find_demangled_name actually *sets* the gsymbol's language if
it is language_auto.

> 
> 	* gdb.base/msym.c: New test.
> 	* gdb.base/msym.exp: New file.
> 	* gdb.base/msym_main.c: New test.

These entries should be listed under the testsuite ChangeLog, like:

testsuite/ChangeLog:
YYYY-MM-DD ....

	* gdb.xyz/file1.c: ...
	* gdb.xyz/file1.exp: ....

[https://sourceware.org/gdb/wiki/ContributionChecklist#Properly_Formatted_GNU_ChangeLog]

"msym.c" et al aren't particularly descriptive, though. Can we devise a better,
more explicit name? Something along the lines of "multiple-language-msyms.exp".
It's long, but it describes things better. [I'm not saying you should use
this name, but something other than just "msym.{c,exp}".]

Sorry, some of that is kinda nitpicky.

> diff --git a/gdb/symtab.c b/gdb/symtab.c
> index cd27a75e8c..481428f733 100644
> --- a/gdb/symtab.c
> +++ b/gdb/symtab.c
> @@ -818,6 +818,10 @@ symbol_set_names (struct general_symbol_info *gsymbol,
>    else
>      linkage_name_copy = linkage_name;
>  
> +  /* Set the symbol language.  */
> +  char *demangled_name = symbol_find_demangled_name (gsymbol,
> +						     linkage_name_copy);
> +
>    entry.mangled = linkage_name_copy;
>    slot = ((struct demangled_name_entry **)
>  	  htab_find_slot (per_bfd->demangled_names_hash,

symbol_find_demangled_name returns a malloc'd string which will leak here unless
the code goes through the branch. You'll need to save the result into a
unique_xmalloc_ptr and adjust the code accordingly.

Otherwise, LGTM. Thanks very much for the patch.

Keith (IANAM*)

* I am not a maintainer, you'll need to await final review by a global maintainer.


  reply	other threads:[~2018-10-30 21:21 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-10-30 19:11 Tom de Vries
2018-10-30 21:21 ` Keith Seitz [this message]
2018-10-31  9:09   ` Tom de Vries
2018-11-07  9:59     ` [PING][PATCH][gdb/symtab] " Tom de Vries
2018-11-07 15:24     ` [PATCH][gdb/symtab] " Simon Marchi

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=07e42727-0d74-7f04-ef7c-39e180f71da8@redhat.com \
    --to=keiths@redhat.com \
    --cc=gdb-patches@sourceware.org \
    --cc=tdevries@suse.de \
    /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