title: Debugging with gdb on a program with no optimization but still there is no symbol in the current context for local variables
body: <p>I've been having this problem for while now, but always seem to put off asking this question because it seems like I am doing something wrong... but right now I feel otherwise... taken this code:</p>
  
  <pre><code>#include &lt;string&gt;
  #include &lt;iostream&gt;
  #include &lt;algorithm&gt;
  int main(int argc, char** argv)
  {
    if(argc &lt; 2)
    {
      std::cout &lt;&lt; "usage: " &lt;&lt; argv[0] &lt;&lt; " &lt;string&gt;" &lt;&lt; std::endl;
      return 1;
    }
    std::string str = argv[1];
    std::reverse(str.begin(), str.end());
    std::cout &lt;&lt; str &lt;&lt; std::endl;
    return 0;
  }
  </code></pre>
  
  <p>Compiled with the command:</p>
  
  <pre><code>g++ -std=c++11 -Wall main.cpp -o main -O0 -ggdb3
  </code></pre>
  
  <p>I am using a very recent trunk version of gcc, I the trunk was taken around September 23rd ish... Also note that I am not compiling with optimization!</p>
  
  <p>Now anyway, I start debugging, like this:</p>
  
  <pre><code>gdb --quiet --args ./main string
  </code></pre>
  
  <p>I set a break point at line 12 (the reverse algorithm)</p>
  
  <pre><code>b 12
  </code></pre>
  
  <p>then I run the program</p>
  
  <pre><code>run
  </code></pre>
  
  <p>then I try to print out the string, to see what it is</p>
  
  <pre><code>print str
  </code></pre>
  
  <p>And this, my dear friends, is what seems strange to me:
  The output of that previous command is:</p>
  
  <pre><code>No symbol "str" in current context.
  </code></pre>
  
  <p>a quick check to the local variables doesn't show the string either</p>
  
  <pre><code>info locals
  </code></pre>
  
  <p>all I get is</p>
  
  <pre><code>std::__ioinit = {static _S_refcount = 2, static _S_synced_with_stdio = true}
  </code></pre>
  
  <p>so I'm wondering, am I at fault, or is the compiler or debugger at fault... this has been a pretty pain in the ass problem for a long time for me... so thanks for even reading this question... :)</p>
  
  <p>EDIT: now that it has become clear that there is something wrong with my gcc build, I'm wondering if anyone has come across a bug report or any other case where there seems to a be a problem similar to this... I will also try checking with a recent build of gdb to make sure that there is definitely not a problem with my current debugger (that comes with ubuntu)... does that make sense?</p>
  
  <p>EDIT2: So after compiling gdb v7.5, I got relatively the same result except there were no locals present at all... I guess that means it's a gcc issue, thanks everyone...</p>