Hi everyone,
I have a flag defined like this:
#define TMSK1 *(volatile char*)0x1022
I would like to print its value but I'm not sure how to do this in GDB
every time I try it, I get an error:
"No symbol TMSK1 in current context."
Ted
Hi everyone,
I have a flag defined like this:
#define TMSK1 *(volatile char*)0x1022
I would like to print its value but I'm not sure how to do this in GDB
every time I try it, I get an error:
"No symbol TMSK1 in current context."
Ted
Remember that #define directives are handled by the preprocessor - it's pretty much an automated search & replace that runs before the compiler. So in the text of your source file, every occurrence of the sequence "TMSK1" is literally replaced by "*(volatile char*)0x1022" before the compiler looks at the code. So really - there is no TMSK1 symbol.
I'm not a big GDB user, so I have no idea if there's an easy way to see what's in memory at a certain location (though I'd imagine there is).
I have never used gdb so don't shoot the messenger if this turns out to be wrong
But a quick google search and this came up
RMS's gdb Tutorial: Advanced gdb Features
so tryUse the x command to examine memory. The syntax for the x command is x/FMT ADDRESS. The FMT field is a count followed by a format letter and a size letter. There are many options here, use the help command 'help x' to see them all. The ADDRESS argument can either be a symbol name, such as a variable, or a memory address.
x/c 0x1022
Why not change it to something like:
Code:volatile const char* TMSK1 = 0x1022;
"I am probably the laziest programmer on the planet, a fact with which anyone who has ever seen my code will agree." - esbo, 11/15/2008
"the internet is a scary place to be thats why i dont use it much." - billet, 03/17/2010