Mirror of the gdb mailing list
 help / color / mirror / Atom feed
* [BUG] Tab Expansion for C++
@ 2007-02-13 16:28 Thomas Richter
  2007-02-13 16:56 ` Daniel Jacobowitz
  2007-02-13 19:00 ` Andreas Schwab
  0 siblings, 2 replies; 10+ messages in thread
From: Thomas Richter @ 2007-02-13 16:28 UTC (permalink / raw)
  To: gdb

Hi folks,

the TAB expansion for C++ class members in GDB is - unfortunately - close
to useless. Here's an example how to reproduce the problem:

Type in the following program:

/* snip */

class A {
  //
  int x;
public:
  A(int i)
  {
    x = i;
  }
  ~A(void)
  {
  }
  //
  int getA(void) const
  {
    return x;
  }
};

int main(int argc,char **argv)
{
  A a(5);

  return a.getA();
}

/* snip */

Compile with:

thor@mersenne:~/src> g++-4.1 -O0 -fno-inline -ggdb3 gdbtest.cpp -o gdbtest

Then run GDB:
thor@mersenne:~/src> gdb gdbtest
GNU gdb 6.6
Copyright (C) 2006 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB.  Type "show warranty" for details.
This GDB was configured as "i686-pc-linux-gnu"...
Using host libthread_db library "/lib/tls/libthread_db.so.1".

Consider finding the constructor of A (clearly, a contrived example)

(gdb) break A::

now type TAB to get the members of A:

A                       __do_global_dtors_aux   char
A::A(int)               __dso_handle            completed.5556
A::getA() const         __fini_array_end        data_start
A::~A()                 __fini_array_start      frame_dummy
_DYNAMIC                __i686.get_pc_thunk.bx  int
_GLOBAL_OFFSET_TABLE_   __init_array_end        long int
_IO_stdin_used          __init_array_start      long long int
__CTOR_END__            __libc_csu_fini         long long unsigned int
__CTOR_LIST__           __libc_csu_init         long unsigned int
__DTOR_END__            __libc_start_main@plt   main
__DTOR_LIST__           _edata                  p.5554
__FRAME_END__           _end                    short int
__JCR_END__             _fini                   short unsigned int
__JCR_LIST__            _fp_hw                  signed char
__bss_start             _init                   unsigned char
__data_start            _start                  unsigned int
__do_global_ctors_aux   call_gmon_start         ~A
(gdb) 

Given that this is really a pretty short program, the output can grow
enourmous for any realistically sized code since *all* functions are
shown here, not only those that are members of A. Interestingly, gdb *does*
know that, as can be seen from the above list.

Could you please, please fix this? It's a long-standing bug, and it's
pretty anoying.

Thanks,
	Thomas


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

* Re: [BUG] Tab Expansion for C++
  2007-02-13 16:28 [BUG] Tab Expansion for C++ Thomas Richter
@ 2007-02-13 16:56 ` Daniel Jacobowitz
  2007-02-13 17:08   ` Thomas Richter
  2007-02-13 19:00 ` Andreas Schwab
  1 sibling, 1 reply; 10+ messages in thread
From: Daniel Jacobowitz @ 2007-02-13 16:56 UTC (permalink / raw)
  To: Thomas Richter; +Cc: gdb

On Tue, Feb 13, 2007 at 05:13:32PM +0100, Thomas Richter wrote:
> the TAB expansion for C++ class members in GDB is - unfortunately - close
> to useless.

That's your misunderstanding right there - GDB doesn't support context
sensitive tab completion at all.

I think Pierre implemented this for Pascal once, but it was never
merged.  Aha, there's the patch - April 2002.  There's a bit of yacc
hacking required.  I'm not really sure how it would work for C++,
but I think badly: the grammar will not gracefully handle partially
typed expressions, like "p ( x.<tab>".

-- 
Daniel Jacobowitz
CodeSourcery


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

* Re: [BUG] Tab Expansion for C++
  2007-02-13 16:56 ` Daniel Jacobowitz
@ 2007-02-13 17:08   ` Thomas Richter
  2007-02-13 19:33     ` Daniel Jacobowitz
  0 siblings, 1 reply; 10+ messages in thread
From: Thomas Richter @ 2007-02-13 17:08 UTC (permalink / raw)
  To: Daniel Jacobowitz; +Cc: gdb

Hi Daniel,

> > the TAB expansion for C++ class members in GDB is - unfortunately - close
> > to useless.
> 
> That's your misunderstanding right there - GDB doesn't support context
> sensitive tab completion at all.
> 
> I think Pierre implemented this for Pascal once, but it was never
> merged.  Aha, there's the patch - April 2002.  There's a bit of yacc
> hacking required.  I'm not really sure how it would work for C++,
> but I think badly: the grammar will not gracefully handle partially
> typed expressions, like "p ( x.<tab>".

Well, interested in a patch? It might need some tweaking to be sensitive
to the language (i.e. to accept the :: in C++ code only). Sure enough,
it won't fix *all* the problems, but I'm using it here daily and it is
a big improvement. I would need some help of the gdb gurus though to integrate
it "nicely".

So long,
	Thomas


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

* Re: [BUG] Tab Expansion for C++
  2007-02-13 16:28 [BUG] Tab Expansion for C++ Thomas Richter
  2007-02-13 16:56 ` Daniel Jacobowitz
@ 2007-02-13 19:00 ` Andreas Schwab
  1 sibling, 0 replies; 10+ messages in thread
From: Andreas Schwab @ 2007-02-13 19:00 UTC (permalink / raw)
  To: Thomas Richter; +Cc: gdb

Thomas Richter <thor@mail.math.tu-berlin.de> writes:

> Consider finding the constructor of A (clearly, a contrived example)
>
> (gdb) break A::
>
> now type TAB to get the members of A:
>
> A                       __do_global_dtors_aux   char
> A::A(int)               __dso_handle            completed.5556
> A::getA() const         __fini_array_end        data_start
> A::~A()                 __fini_array_start      frame_dummy
> _DYNAMIC                __i686.get_pc_thunk.bx  int
> _GLOBAL_OFFSET_TABLE_   __init_array_end        long int
> _IO_stdin_used          __init_array_start      long long int
> __CTOR_END__            __libc_csu_fini         long long unsigned int
> __CTOR_LIST__           __libc_csu_init         long unsigned int
> __DTOR_END__            __libc_start_main@plt   main
> __DTOR_LIST__           _edata                  p.5554
> __FRAME_END__           _end                    short int
> __JCR_END__             _fini                   short unsigned int
> __JCR_LIST__            _fp_hw                  signed char
> __bss_start             _init                   unsigned char
> __data_start            _start                  unsigned int
> __do_global_ctors_aux   call_gmon_start         ~A
> (gdb) 

See (gdb)Completion, you need to put a single quote before the word to be
completed, so that gdb know where it starts.

Andreas.

-- 
Andreas Schwab, SuSE Labs, schwab@suse.de
SuSE Linux Products GmbH, Maxfeldstraße 5, 90409 Nürnberg, Germany
PGP key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5
"And now for something completely different."


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

* Re: [BUG] Tab Expansion for C++
  2007-02-13 17:08   ` Thomas Richter
@ 2007-02-13 19:33     ` Daniel Jacobowitz
  2007-02-14 12:08       ` Thomas Richter
  0 siblings, 1 reply; 10+ messages in thread
From: Daniel Jacobowitz @ 2007-02-13 19:33 UTC (permalink / raw)
  To: Thomas Richter; +Cc: gdb

On Tue, Feb 13, 2007 at 05:55:01PM +0100, Thomas Richter wrote:
> Well, interested in a patch? It might need some tweaking to be sensitive
> to the language (i.e. to accept the :: in C++ code only). Sure enough,
> it won't fix *all* the problems, but I'm using it here daily and it is
> a big improvement. I would need some help of the gdb gurus though to integrate
> it "nicely".

Do you have an FSF copyright assignment, or are you able / willing to
get one?  If so, I'd be glad to look at what you've done - otherwise
it may be best if I don't.

-- 
Daniel Jacobowitz
CodeSourcery


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

* Re: [BUG] Tab Expansion for C++
  2007-02-13 19:33     ` Daniel Jacobowitz
@ 2007-02-14 12:08       ` Thomas Richter
  2007-02-14 12:36         ` Daniel Jacobowitz
  0 siblings, 1 reply; 10+ messages in thread
From: Thomas Richter @ 2007-02-14 12:08 UTC (permalink / raw)
  To: Daniel Jacobowitz; +Cc: gdb

Hi Daniel,

> > Well, interested in a patch? It might need some tweaking to be sensitive
> > to the language (i.e. to accept the :: in C++ code only). Sure enough,
> > it won't fix *all* the problems, but I'm using it here daily and it is
> > a big improvement. I would need some help of the gdb gurus though to integrate
> > it "nicely".
> 
> Do you have an FSF copyright assignment, or are you able / willing to
> get one?  

Could you provide some details on this? My impression is that gdb is GPL,
and as soon as I agree on this, we're ready to go?

Not that I think GPL is perfect, but that's a different discussion. I'm
using the gdb, so it's only fair to provide any modifications under the
same licence. Thus, no problem for me.

It's not a major patch - it's currently more a hack, but as said, I do
not have enough insight into the design of gdb to improve it without
further help.

So long,
	Thomas


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

* Re: [BUG] Tab Expansion for C++
  2007-02-14 12:08       ` Thomas Richter
@ 2007-02-14 12:36         ` Daniel Jacobowitz
  2007-02-19 11:48           ` Thomas Richter
  0 siblings, 1 reply; 10+ messages in thread
From: Daniel Jacobowitz @ 2007-02-14 12:36 UTC (permalink / raw)
  To: Thomas Richter; +Cc: gdb

On Wed, Feb 14, 2007 at 09:51:04AM +0100, Thomas Richter wrote:
> Could you provide some details on this? My impression is that gdb is GPL,
> and as soon as I agree on this, we're ready to go?

No, see http://www.gnu.org/licenses/why-assign.html.  This is
something quite different; it's a document that you'll have to sign,
and possibly another one that your employer would also, depending on
circumstances.

It's an inconenience for new contributors, but sufficiently important
to the FSF that we insist on it.

-- 
Daniel Jacobowitz
CodeSourcery


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

* Re: [BUG] Tab Expansion for C++
  2007-02-14 12:36         ` Daniel Jacobowitz
@ 2007-02-19 11:48           ` Thomas Richter
  2007-02-19 12:28             ` Daniel Jacobowitz
  2007-02-19 13:03             ` Robert Dewar
  0 siblings, 2 replies; 10+ messages in thread
From: Thomas Richter @ 2007-02-19 11:48 UTC (permalink / raw)
  To: Daniel Jacobowitz; +Cc: gdb

Hi again,

> > Could you provide some details on this? My impression is that gdb is GPL,
> > and as soon as I agree on this, we're ready to go?
> 
> No, see http://www.gnu.org/licenses/why-assign.html.  This is
> something quite different; it's a document that you'll have to sign,
> and possibly another one that your employer would also, depending on
> circumstances.
> 
> It's an inconenience for new contributors, but sufficiently important
> to the FSF that we insist on it.

All fine, but *which* document would need to be signed? Is there a template
of sorts you can provide? The page above doesn't seem to provide details
on this.

Furthermore, I cannot develop under US copyright law. I can only develop
under German copyright law, which is again different. I can hand you the
copyright, but according to German law, I still have rights as the creator
of an entity that I cannot transfer to other people. (German: Urheberrecht)
It doesn't give me any major rights, though (as, it doesn't include the
right to copy the work, which is part of the copyright.).

Folks, that's getting ridiculously complicated... I don't want to contact
a lawer just to provide a patch. I really don't care - I just want a usable
gdb, that's all.

So long,
	Thomas



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

* Re: [BUG] Tab Expansion for C++
  2007-02-19 11:48           ` Thomas Richter
@ 2007-02-19 12:28             ` Daniel Jacobowitz
  2007-02-19 13:03             ` Robert Dewar
  1 sibling, 0 replies; 10+ messages in thread
From: Daniel Jacobowitz @ 2007-02-19 12:28 UTC (permalink / raw)
  To: gdb

On Mon, Feb 19, 2007 at 10:43:26AM +0100, Thomas Richter wrote:
> All fine, but *which* document would need to be signed? Is there a template
> of sorts you can provide? The page above doesn't seem to provide details
> on this.

I sent Thomas the details off-list.

-- 
Daniel Jacobowitz
CodeSourcery


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

* Re: [BUG] Tab Expansion for C++
  2007-02-19 11:48           ` Thomas Richter
  2007-02-19 12:28             ` Daniel Jacobowitz
@ 2007-02-19 13:03             ` Robert Dewar
  1 sibling, 0 replies; 10+ messages in thread
From: Robert Dewar @ 2007-02-19 13:03 UTC (permalink / raw)
  To: Thomas Richter; +Cc: Daniel Jacobowitz, gdb

Thomas Richter wrote:

> Furthermore, I cannot develop under US copyright law. I can only develop
> under German copyright law, which is again different. I can hand you the
> copyright, but according to German law, I still have rights as the creator
> of an entity that I cannot transfer to other people. (German: Urheberrecht)
> It doesn't give me any major rights, though (as, it doesn't include the
> right to copy the work, which is part of the copyright.).

Assigning the copyright to the FSF does not remove rights from the
assigner, many people in Europe have found they can sign this form
without problems. Note that it is not online, precisely because the
FSF has found they really need to be in touch with people regarding
signing the form to resolve issues such as this one.

> Folks, that's getting ridiculously complicated... I don't want to contact
> a lawer just to provide a patch. I really don't care - I just want a usable
> gdb, that's all.

The complication is inevitable given the complexities of copyright
law. We all want a usable GDB, but to be usable, it must not only
be technically strong, but the licensing and copyright situation
must be clear as well.
> 
> So long,
> 	Thomas
> 


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

end of thread, other threads:[~2007-02-19 12:28 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-02-13 16:28 [BUG] Tab Expansion for C++ Thomas Richter
2007-02-13 16:56 ` Daniel Jacobowitz
2007-02-13 17:08   ` Thomas Richter
2007-02-13 19:33     ` Daniel Jacobowitz
2007-02-14 12:08       ` Thomas Richter
2007-02-14 12:36         ` Daniel Jacobowitz
2007-02-19 11:48           ` Thomas Richter
2007-02-19 12:28             ` Daniel Jacobowitz
2007-02-19 13:03             ` Robert Dewar
2007-02-13 19:00 ` Andreas Schwab

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox