title: GDB debugger hanging on std::cout
body: <p>I have been coding C and C++ for a while now due to my studies. We used to use Visual Studio as an IDE during coding lessons at school.</p>
  
  <p>I am now trying to learn to use GNU Compiler tools and Debugger. I am using CodeLite IDE version 9.1.8, with TDM-GCC-64 5.1.0 compiler.</p>
  
  <p>My specific problem is the GDB debugger. I am somewhat familiar with its usage (Step into, Step over etc.). Everytime I try to debug ANY of my own code, the debugger stops fine at breakpoint(s) and lets me continue from there.</p>
  
  <p>However, every single time I hit "cout" with the debugger, it refuses to step to the next line. When hitting some line with "cout" on it, I press "F10" to go to the next line, but the debugger will not continue from there. It always freezes, does not respond to any command, and I have to force shutdown the debugger. Every other imaginable statement is fine, but not "cout" in any form.</p>
  
  <p>Those who are familiar with CodeLite probably know the green arrow at the left edge of the text editor window when debugging. When the arrow hits "cout" and I press "F10" to step to next line, the arrow flashes. When I hit "F10" again, the arrow flashes again. This can be done for about 3-4 times before the arrow disappeares completely from the left sidebar and the debugger hangs there.</p>
  
  <p><a href="http://i.stack.imgur.com/FcVX4.jpg" rel="nofollow">Starting debugger</a></p>
  
  <p><a href="http://i.stack.imgur.com/bsP5x.jpg" rel="nofollow">Debugger hanging and arrow disappeared</a></p>
  
  <p>Here is an example code. It is in Finnish, so you may not understand what I am trying to print, but that's not important.</p>
  
  <p>The class "Henkilo" contains two private variables, string for name and int for age. Also <code>&lt;&lt;</code> operator is overloaded, allowing the object to be directly printed by cout.The assignment on this piece of code was to demonstrate usage of copy constructor.</p>
  
  <pre><code>#include &lt;iostream&gt;
  #include "Henkilo.h"
  
  
  int main()
  {
      Henkilo henkilo1;
  
      henkilo1.setName("Jaakko");
      henkilo1.setAge(24);
  
      Henkilo henkilo2(henkilo1);
  
      std::cout &lt;&lt; "\nLuotiin henkil\2241, jonka tiedot ovat: " &lt;&lt; std::endl &lt;&lt; henkilo1 &lt;&lt; std::endl;
      std::cout &lt;&lt; "Kopioitiin henkil\2241 objektiin henkil\2242. Henkil\224n 2 tiedot ovat: " &lt;&lt; henkilo2 &lt;&lt; std::endl;
      return 0;
  }
  </code></pre>
  
  <p>Please forgive whatever errors I may have done posting this, this is my first time. </p>
  
  <p>EDIT:</p>
  
  <p>@KennyOstrom </p>
  
  <p>Yes, I am able to step into the function, now that I tested it. It also seems to hang in there too. </p>
  
  <pre><code>std::ostream&amp; operator&lt;&lt; (std::ostream&amp; os, const Henkilo&amp; obj) 
      os &lt;&lt; "\nNimi : " &lt;&lt; obj.name&lt;&lt; std::endl &lt;&lt; "Ik\204 : " &lt;&lt; obj.age &lt;&lt; std::endl; 
      return os;
  }
  </code></pre>
  
  <p>It seems to hang at the line where you insert string literals to the "os" object.</p>
  
  <p>EDIT:</p>
  
  <p>@PaulMcKenzie</p>
  
  <p>Sorry, didn't think about that point at all. Here is the implementation of the class. It is a basic class for person, with fields for name and age.</p>
  
  <p>Henkilo.h</p>
  
  <pre><code>#include &lt;string&gt;
  #include &lt;iostream&gt;
  
  class Henkilo
  {
  private:
      std::string name;
      int age;
  public:
      Henkilo();
      Henkilo(std::string initName, int initAge);
      Henkilo(const Henkilo&amp; henkilo);
      void setName(std::string newName);
      std::string getName();
      void setAge(int newAge);
      int getAge();
      friend std::ostream&amp; operator&lt;&lt; (std::ostream&amp; os, const Henkilo&amp; obj);
      ~Henkilo();
  
  };
  </code></pre>
  
  <p>Henkilo.cpp</p>
  
  <pre><code>#include "Henkilo.h"
  
  Henkilo::Henkilo() : name(""), age(0) {};
  Henkilo::Henkilo(std::string initName, int initAge) : name(initName), age(initAge) {};
  Henkilo::Henkilo(const Henkilo&amp; henkilo) : name(henkilo.name), age(henkilo.age) {};
  
  void Henkilo::setName(std::string newName) { name = newName; };
  std::string Henkilo::getName() { return name; };
  void Henkilo::setAge(int newAge) { age = newAge; };
  int Henkilo::getAge() { return age; };
  
  std::ostream&amp; operator&lt;&lt; (std::ostream&amp; os, const Henkilo&amp; obj) 
  { 
      os &lt;&lt; "\nNimi : " &lt;&lt; obj.name&lt;&lt; std::endl &lt;&lt; "Ik\204 : " &lt;&lt; obj.age &lt;&lt; std::endl;
      return os;
  }
  Henkilo::~Henkilo() {};
  </code></pre>