2

I'm debugging a program with gdb: gdb --args ...
I added a breakpoint to check the new variables(vectors) that have the right dimensions,
p myvector.size(), works ok but when I try to do:

p myvector.at(i) to check the values(which would be helpful) gdb answers:

Cannot evaluate function -- may be inlined

Does anyone have any hint or idea?

cassepipe
  • 371
  • 6
  • 16
Rodrigo
  • 21
  • 2
  • gdb is able to call a function in the running process, but not if the linker discards this function or if it is inlined. This often occurs with access methods such as `operator[]` and `.at`. Just printing the vector should use the pretty-printer, which is enough for small vectors. You can also directly access the internal variables in vector to get the pointer storing the elements and print from there. For instance, with a vector `v` you could try `v._M_impl._M_start[i]`. Knowing this is also useful when you are debugging from a core file, without a process running. – darcamo Apr 22 '21 at 14:02
  • Does this answer your question? [C++, STL, GDB: Cannot evaluate function maybe inlined](https://stackoverflow.com/questions/40633787/c-stl-gdb-cannot-evaluate-function-maybe-inlined) – user202729 Dec 06 '21 at 15:57
  • 2
    (tl;dr: Explicitly instantiate the class. `template class std::vector`. – user202729 Dec 06 '21 at 15:58

0 Answers0