This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH v2 1/1] don't list typedef symbols in C++, d and ada


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]