2

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;
}

1 Answer 1

1

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:

enter image description here

and you can even use these convenience variables in places like the Watch interface:

enter image description here

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.