How can I see the address of a variable while debugging?

Need help? Post your issues and bugs here. We will try to fix them.
FAQs

4 posts | Page 1 of 1


Arty29

Posts: 3
Joined: 07 Nov 2014 01:59

How can I see the address of a variable while debugging?
Postby Arty29 » 10 Dec 2014 19:54

Hello,

Does anyone know if there is a convenient way to see the address of a variable when debugging? For example, I have a module that contains declarations (made at file scope) such as:

Code: Select all

const uint8_t ArrayA[] = {1, 2, 3, 4, 5};
static const uint8_t ArrayB[] = {6, 7, 8, 9, 10};




I can add these arrays to the watch window and see their contents but nowhere in the watch window is there any indication of the address at which each is located. The only way that I have found to do it is to, for example enter "&ArrayA" into a line in the watch window.

I thought for sure that there would be a way to see the address, or even better be able to mouse-over the variable in the source code and see address information.

Can anyone suggest ways to do this?

Thank you.

Top


harper

Posts: 131
Joined: 12 Mar 2013 14:03
Location: Germany

ICQ

Re: How can I see the address of a variable while debugging?
Postby harper » 11 Dec 2014 10:51

You find the address of the variable in the MAP file.

The debugger GUI communicates with the GDB server. It can only display what is requested from the GDB server. If you don't add &variable to the watch windows then the GDB server doesn't send this information. So I see no convenient way to do this.

Sometimes I use the GDB command window to query additional information. you could enter the command

Code: Select all

p &variable

. This would not affect the watch window and you don't have to revert the change after seeing the address. But I doubt that this is "convenient".

Top


Arty29

Posts: 3
Joined: 07 Nov 2014 01:59

Re: How can I see the address of a variable while debugging?
Postby Arty29 » 15 Dec 2014 18:16

harper wrote:

You find the address of the variable in the MAP file.

The debugger GUI communicates with the GDB server. It can only display what is requested from the GDB server. If you don't add &variable to the watch windows then the GDB server doesn't send this information. So I see no convenient way to do this.

Sometimes I use the GDB command window to query additional information. you could enter the command

Code: Select all

p &variable

. This would not affect the watch window and you don't have to revert the change after seeing the address. But I doubt that this is "convenient".



Thanks for the reply.
Actually the variables declared as static don't appear in the MAP file, although the symbols are available to the debugger. I have used several different IDEs over the years and I don't recall ever not being able to see easily see the address of a variable in the watch window. Perhaps those IDEs implicitly also fetch the address of the variable when it is added to the watch window. In any case, I like you suggestion of using the GDB command window and will definitely try that.

Top


Sumer

Posts: 1
Joined: 28 Mar 2015 14:44

Re: How can I see the address of a variable while debugging?
Postby Sumer » 28 Mar 2015 14:47

Yes, it got me a few more steps into it. Thanks! But it looks like I start getting linker errors, saying it cannot resolve this or that reference. Did you all build the libraries as static libraries to be linked?

Sumer

Top



4 posts | Page 1 of 1


Jump to:


Who is online

Users browsing this forum: No registered users and 1 guest