2

I have a std::map data member inside a class called ExecState:

class ExecState { // ...
std::map<int,ref<Expr> > ab_size;
// ...
};

When I print it from gdb I see the expected values:

(gdb) print state.ab_size
$1 = std::map with 1 elements = {[1] = {ptr = 0x2a221d0}}

However, when I try to access the element itself, gdb fails:

(gdb) print state.ab_size[1]
Attempt to take address of value not located in memory.

What am I doing wrong here? thanks!

1 Answer 1

2

When I print it from gdb I see the expected values:

You see this because of the magic of pretty-printers. To see the actual contents of the variable, try print/r state.ab_size.

However, when I try to access the element itself, gdb fails:

GDB didn't fail, but the pretty printers aren't magical enough to grant your wish. You'll have to "fish out" the value by using the actual data elements, not the illusion that pretty printers create (and this is hard).

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.