Thomas Phan
Thomas Phan

Reputation: 247

Understanding GDB syntax for C++ program

After performing the command x/64ga $rsp, I get this as one of the line output:

<Hex-addr-val> <Hex-addr-val> <Hex-addr-val> <Class_Name::Foo(Data_Type const&)+662>

So I understand everything on that line excepts for the '+662' part at the end. What does that number means in relation to the function? Is it a positive value at the time of crash? Or something else?

Upvotes: 3

Views: 96

Answers (1)

Employed Russian
Employed Russian

Reputation: 213375

What does that number means in relation to the function?

It means that at location $rsp+24 GDB found a value which looks like an address that points 662 bytes inside the code for Class_Name::Foo().

It could be a coincidence, or it could be that that address was pushed onto the stack (e.g. because Foo() called some other function).

Using x/i '&Class_Name::Foo(Data_Type const&)+662-5 may show that there is a CALL instruction at that address, which would be a strong indication that this is not just a random coincidence.

Upvotes: 1

Related Questions