exp/2070: gdb doesn't resolve namespace when print expression

myan@microstrategy.com myan@microstrategy.com
Thu Jan 19 17:08:00 GMT 2006


>Number:         2070
>Category:       exp
>Synopsis:       gdb doesn't resolve namespace when print expression
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    unassigned
>State:          open
>Class:          change-request
>Submitter-Id:   net
>Arrival-Date:   Thu Jan 19 17:08:01 GMT 2006
>Closed-Date:
>Last-Modified:
>Originator:     myan@microstrategy.com
>Release:        GNU gdb 6.4
>Organization:
>Environment:
RedHat AS3
Linux 2.4.21-20.Elsmp x86_64
>Description:
gdb doesn't resolve class name if it is in user namescape.

(gdb) p *(NBase::Frog *) 0x501010
No symbol "NBase" in current context.
(gdb) p *(Frog *) 0x501010
A syntax error in expression, near `) 0x501010'.

It appears, gdb doesn't understand either (Frog *) or (NBase::Frog *) correctly.
>How-To-Repeat:
Compile the test file.
> g++ -c -g -I. foo.C
> g++ -o foo foo.o

Start gdb
> gdb foo
(gdb) b 43
Breakpoint 1 at 0x40078b: file foo.C, line 43.
(gdb) run
(gdb) print f
$1 = (NBase::Frog *) 0x501010
(gdb) print t
$2 = (Toad *) 0x501030
(gdb) step
func (i=-1) at foo.C:30
30              printf("input = %d\n", i);
(gdb) p *(NBase::Frog *) 0x501010
No symbol "NBase" in current context.
(gdb) p *(Frog *) 0x501010
A syntax error in expression, near `) 0x501010'.
(gdb) p *(Toad *) 0x501030
$4 = {
  mData = 1
}
>Fix:

>Release-Note:
>Audit-Trail:
>Unformatted:
----gnatsweb-attachment----
Content-Type: text/plain; name="foo.C"
Content-Disposition: inline; filename="foo.C"


#include <stdio.h>


namespace NBase
{
	class Frog
	{
	public:
		Frog() : mData(-1) {}
		Frog(int i): mData(i) {}

	private:
		int mData;
	};
}

class Toad
{
public:
	Toad() : mData(1) {}
	Toad(int i): mData(i) {}

private:
	int mData;
};

void func(int i)
{
	printf("input = %d\n", i);

	return;
}

int main()
{
	int rc=0;

	NBase::Frog* f = new NBase::Frog;

	Toad* t = new Toad;

	func(-1);

	return rc;
}



More information about the Gdb-prs mailing list