public inbox for gdb-prs@sourceware.org
help / color / mirror / Atom feed
* c++/2477: print object on + NULL pointer => gdb error
@ 2008-07-14 16:08 ppluzhnikov
  0 siblings, 0 replies; only message in thread
From: ppluzhnikov @ 2008-07-14 16:08 UTC (permalink / raw)
  To: gdb-gnats


>Number:         2477
>Category:       c++
>Synopsis:       print object on + NULL pointer => gdb error
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    unassigned
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Mon Jul 14 16:08:01 UTC 2008
>Closed-Date:
>Last-Modified:
>Originator:     ppluzhnikov@google.com
>Release:        6.8.50.20080711-cvs
>Organization:
>Environment:
x86_64-unknown-linux-gnu
>Description:
With "set print object on" (which is very useful when dealing with
pointers to base classes), one can't print NULL pointers:

cat foo.cc
struct Foo {
 Foo() : next(0) { }
 virtual ~Foo() { }
 Foo *next;
};

void fn(Foo *p) { }
int main()
{
 Foo foo;
 fn(&foo);
}


g++ -g foo.cc
gdb64 -q a.out

(gdb) b fn
Breakpoint 1 at 0x4002e0: file foo.cc, line 7.
(gdb) r

Breakpoint 1, fn (p=0x7fffffffe6b0) at foo.cc:7
7       void fn(Foo *p) { }
(gdb) set print object on
(gdb) p p
$1 = (Foo *) 0x7fffffffe6b0
(gdb) p p.next
$2 = (Cannot access memory at address 0x0


This in itself is a minor annoyance; but it also aborts "canned
commands", which is a major annoyance. For example:


(gdb) b fn
Breakpoint 1 at 0x4002e0: file foo.cc, line 7.
(gdb) commands 1
> p p
> p p->next
> cont
> end

(gdb) r

Breakpoint 1, fn (p=0x7fffffffe6b0) at foo.cc:7
7       void fn(Foo *p) { }
$1 = (Foo *) 0x7fffffffe6b0
$2 = (Foo *) 0x0

Program exited normally.

(gdb) commands 1
> set print object on
> p p
> p p->next
> c
> end
(gdb) r

Breakpoint 1, fn (p=0x7fffffffe6b0) at foo.cc:7
7       void fn(Foo *p) { }
$3 = (Foo *) 0x7fffffffe6b0
$4 = (Cannot access memory at address 0x0
(gdb)             # command sequence aborted, continue not done :(
>How-To-Repeat:

>Fix:

>Release-Note:
>Audit-Trail:
>Unformatted:


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2008-07-14 16:08 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-07-14 16:08 c++/2477: print object on + NULL pointer => gdb error ppluzhnikov

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).