Collectives™ on Stack Overflow

Find centralized, trusted content and collaborate around the technologies you use most.

Learn more about Collectives

Teams

Q&A for work

Connect and share knowledge within a single location that is structured and easy to search.

Learn more about Teams

while trying to print map iterator value in gdb, I got following error:

(gdb) p map_it->first
operator-> konnte nicht gefunden werden. (English: operator-> could not be found.)
(gdb) p map_it->second.startVal
operator-> konnte nicht gefunden werden.

But the same expression can be used without any problem:

    while (map_it != lineData.end()) {
        colStart[map_it->first] = map_it->second.startVal;
        ++map_it;

I use gdb on Ubuntu: GNU gdb (Ubuntu 9.2-0ubuntu1~20.04) 9.2

How can this problem be avoided? Many thanks for any suggestion! Weichao

try building your app with debug symbols and -O0 (no optimization), then I think you can easily print it. It is probably getting inlined. – fadedreamz Aug 21, 2022 at 7:32 @fadedreamz Your suggestion solved my problem! Many thanks! Could you please explain what "getting inlined" means? Many thanks in advance! – W. Wang Aug 23, 2022 at 17:13 Its an optimization that compiler does to make the code execute faster. In a simplified world, the inlining process will generate code that actually put the address of map_it instead of generating a symbol (read a variable - map_it) for it. That makes the code executes a lot faster than it would've without any runtime penalty. So, when the inlining is happening, the map_it symbol may not be generated and thus gdb can not find anything named map_it when you are trying to print it. You can still print it, but it is a little bit involved process. Hope this helps. – fadedreamz Aug 26, 2022 at 0:59 @fadedreamz Many thanks again! You've help me out from the difficulty and understand the background. Thank you! – W. Wang Aug 26, 2022 at 20:33

Thanks for contributing an answer to Stack Overflow!

  • Please be sure to answer the question. Provide details and share your research!

But avoid

  • Asking for help, clarification, or responding to other answers.
  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.