Reputation: 970
While debugging the main function in Debug Console, I want to create a new variable called 'b' and assign a integer value 9 to it, but it compalins about 'b' being undefined. Why am I getting this error and how can I get around it?
-> int b = 9;
identifier "b" is undefined
#include <stdio.h>
#include <stdint.h>
int main()
{
int i = 0;
printf("i is %d", i);
return 0;
}
Upvotes: 2
Views: 1816
Reputation: 5512
In gdb in general, you can define convenience variables like so:
set $b = 9
in order to do this from the Debug Console, you must use the -exec
prefix:
-exec set $b = 9
and you can then write lines like
-exec p i + $b
(where i
is your C variable).
In picture:
and you can even use these convenience variables in places like the Watch interface:
Upvotes: 1