public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
* [PATCH v2 0/3] Completer C++ template support
@ 2020-04-20 21:57 Keith Seitz
  2020-04-20 21:57 ` [PATCH v2 1/3] Move find_toplevel_char to utils.[ch] Keith Seitz
                   ` (4 more replies)
  0 siblings, 5 replies; 12+ messages in thread
From: Keith Seitz @ 2020-04-20 21:57 UTC (permalink / raw)
  To: gdb-patches

This small patch series fell of the map two years ago, but a recently
reported bug on the subject has spurred me into reviving this.
The original series is here

https://sourceware.org/pipermail/gdb-patches/2018-February/146790.html

This patch doesn't fix the newly reported bug (which I will follow-up with
in a later patch), but it does address a number of shortcomings when
completing on template parameters.

For example, consider this example:

struct Foozle
{
  int x;
  T1 t;
  template <typename T2>
  T2 fogey (T2 plop);
};

If we have several instantiations of this template and the member
function `fogey',

Foozle<int>::fogey<int>(int)
Foozle<char>::fogey<int>(int)
Foozle<Empty<int> >::fogey<int>(int)
[and other non-int instances of `Foozle' and `fogey']

If we want to set a breakpoint on all integer instances fo `fogey'
in class `Foozle', we cannot do that:

(gdb) b Foozle::fogey<int>(int)
Function "Foozle::fogey<int>(int)" not defined.
Make breakpoint pending on future shared library load? (y or [n]) n

[GDB *can* make this work with simply "b fogey<int>(int)", but that would
also get any other class with a member function named `fogey'.]

However, with this patch series, we can do a little better:

(gdb) b Foozle::fogey<int>(int) 
Breakpoint 3 at 0x402799: Foozle::fogey<int>(int). (3 locations)
(gdb) i b
Num     Type           Disp Enb Address            What
3       breakpoint     keep y   <MULTIPLE>         
3.1                         y   0x0000000000402799 in Foozle<int>::fogey<int>(int) 
                                                   at templates.cc:763
3.2                         y   0x00000000004027db in Foozle<char>::fogey<int>(int) 
                                                   at templates.cc:763
3.3                         y   0x0000000000402813 in Foozle<Empty<int> >::fogey<int>(int) 
                                                   at templates.cc:763

Keith Seitz (3):
  Move find_toplevel_char to utils.[ch]
  Remove hard-coded line number from templates.exp
  Support template lookups in strncmp_iw_with_mode

 gdb/NEWS                                    |   4 +
 gdb/cp-support.c                            |   8 +-
 gdb/doc/gdb.texinfo                         |  46 +++
 gdb/linespec.c                              |  77 ----
 gdb/linespec.h                              |   7 -
 gdb/testsuite/gdb.cp/templates.cc           |  66 ++-
 gdb/testsuite/gdb.cp/templates.exp          |  75 +++-
 gdb/testsuite/gdb.linespec/cpcompletion.exp | 437 +++++++++++++++++++-
 gdb/testsuite/gdb.linespec/cpls-ops.exp     |  53 ++-
 gdb/testsuite/gdb.linespec/cpls.cc          | 110 ++++-
 gdb/utils.c                                 | 156 ++++++-
 gdb/utils.h                                 |  14 +-
 12 files changed, 922 insertions(+), 131 deletions(-)

-- 
2.25.2


^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2020-04-24 20:15 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-04-20 21:57 [PATCH v2 0/3] Completer C++ template support Keith Seitz
2020-04-20 21:57 ` [PATCH v2 1/3] Move find_toplevel_char to utils.[ch] Keith Seitz
2020-04-24 19:57   ` Tom Tromey
2020-04-20 21:57 ` [PATCH v2 2/3] Remove hard-coded line number from templates.exp Keith Seitz
2020-04-24 19:58   ` Tom Tromey
2020-04-20 21:57 ` [PATCH v2 3/3] Support template lookups in strncmp_iw_with_mode Keith Seitz
2020-04-22 15:26   ` Simon Marchi
2020-04-24 20:14     ` Tom Tromey
2020-04-22 15:15 ` [PATCH v2 0/3] Completer C++ template support Simon Marchi
2020-04-22 17:27   ` Keith Seitz
2020-04-22 17:45     ` Simon Marchi
2020-04-24 20:15 ` Tom Tromey

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).