Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why gdb casting is not working?

Tags:

gdb

I use print (CEthPacket*) 0xeb609a0 to examine an object at the given address and get A syntax error in expression, near ') 0xeb609a0'.

What am I doing wrong?

EDIT: CEthPacket is a C++ class and I'm on gdb Fedora (6.8-37.el5).

like image 650
jackhab Avatar asked Jan 04 '11 13:01

jackhab


3 Answers

I just ran in to similar issue, and, from a colleague of mine, I learnt that you need to provide the namespace that the class belongs to within a single quotes as following:

(gdb) p ('MyScope::MyClass'*) ptr; 
like image 168
Tsh Avatar answered Oct 24 '22 05:10

Tsh


You didn't say on which platform, which version of GDB, or what CEthPacket is.

My first guess is that you should try print (struct CEthPacket *) 0xeb609a0 instead.

like image 7
Employed Russian Avatar answered Oct 24 '22 06:10

Employed Russian


Also your starting namespace is the one from current stack. If you want to start from root you have to use ::NS1::NS2::Obj.

like image 2
Mamue Avatar answered Oct 24 '22 06:10

Mamue