This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: [PATCH v2 1/1] don't list typedef symbols in C++, d and ada
- From: Pedro Alves <palves at redhat dot com>
- To: Zhouyi Zhou <zhouzhouyi at gmail dot com>, gdb-patches at sourceware dot org
- Date: Tue, 18 Jul 2017 17:16:43 +0100
- Subject: Re: [PATCH v2 1/1] don't list typedef symbols in C++, d and ada
- Authentication-results: sourceware.org; auth=none
- Authentication-results: ext-mx05.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com
- Authentication-results: ext-mx05.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=palves at redhat dot com
- Dkim-filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 68F072F86C7
- Dmarc-filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 68F072F86C7
- References: <1500163721-9343-1-git-send-email-zhouzhouyi@gmail.com>
On 07/16/2017 01:08 AM, Zhouyi Zhou wrote:
> However the command "list foo" will invoke symbol_matches_domain,
> which results in odd result when execute command "list foo".
>
> (gdb) list foo
> file: "example.c", line number: 1
> file: "example.c", line number: 13
GDB is showing this odd output whenever "list" finds more than
one thing to list. For example, with a couple overloads:
int bar() { return 0;}
int bar(int) { return 0; }
and no "bar" typedef in sight, you get the same:
(gdb) list bar
file: "overload.cc", line number: 1
file: "overload.cc", line number: 2
Note you can explicitly tell GDB about the overload
you want to list, with
(gdb) list bar()
(gdb) list bar(int)
and likewise in your original example, you can do
"list foo()" to disambiguate with the typedef.
It might be pretty handy to list the definition of actual
typedefs (and classes). So IMO, it'd be nice to go in the
other direction, and make "list TYPE" work properly, if
it doesn't. Note that linespecs already purposely work
differently in list mode, see, in linespec.c:
bool
collect_info::add_symbol (symbol *sym)
{
/* In list mode, add all matching symbols, regardless of class.
This allows the user to type "list a_global_variable". */
if (SYMBOL_CLASS (sym) == LOC_BLOCK || this->state->list_mode)
VEC_safe_push (symbolp, this->result.symbols, sym);
}
This, however:
(gdb) list bar
file: "overload.cc", line number: 1
file: "overload.cc", line number: 2
does look like a plain bug that should be fixed to me.
I.e., IMO GDB should list the actual code around those
two locations, not just print the location.
Thanks,
Pedro Alves