Author Topic: iostream keeps appearing in debugger  (Read 4323 times)

Offline anonymous_dan2015

  • Single posting newcomer
  • *
  • Posts: 3
iostream keeps appearing in debugger
« on: July 16, 2015, 01:05:19 pm »
Hi all,

I am relatively new to C++ and to code:blocks. I have just experienced what debugging code is all about. I have written this small program but this is what is happening:
So i place a breakpoint in my program (as I was shown to do when debugging)
I press the debug start/continue button
An empty console window is displayed as normal but an iostream tab is displayed with code inside. The debug stops at line 77 in that code and even when I press the 'step into' debug button, the debug just stays at line 77 in the iostream code.

Here is the code I wrote for the C++ program:
#include <iostream>

using namespace std;

int main()
{
    int x = 3;

    while (x==3)
    {
        cout << "X value is: " << x << endl;
        cout << "New x value: " << endl;
        cin >> x;
    }
        cout << "Loop terminated as condition is false" << endl;
    return 0;
}

As, I said, an iostream tab is displayed with code and the debugger stops on line 77 which shows this:

  static ios_base::Init __ioinit;

and this is shown in the debugger log:

In msvcrt!fwrite () (C:\WINDOWS\system32\msvcrt.dll)
#1  0x0041144b in __gnu_cxx::stdio_sync_filebuf<char, std::char_traits<char> >::xsputn(char const*, int) () at C:/Dev-Cpp/bin/../lib/gcc/mingw32/3.4.2/../../../../include/c++/3.4.2/iostream:77
C:\Dev-Cpp\include\c++\3.4.2\iostream:77:2988:beg:0x41144b
At C:\Dev-Cpp\include\c++\3.4.2\iostream:77



I searched online and deselected the 'catch C++ exceptions' in Settings>>Debugger>>Default but this didn't work.

This problem doesnt occur when the code is C; only C++.

Can anyone please help with this issue?

Thanks in advance

Dan

Offline anonymous_dan2015

  • Single posting newcomer
  • *
  • Posts: 3
Re: iostream keeps appearing in debugger
« Reply #1 on: July 16, 2015, 01:07:03 pm »
Sorry, forgot to mention that I wish to get rid of the iostream code. I just want it to debug my program code.

Thanks

Offline BlueHazzard

  • Developer
  • Lives here!
  • *****
  • Posts: 3353
Re: iostream keeps appearing in debugger
« Reply #2 on: July 16, 2015, 01:39:34 pm »
hi!
can you please put your code and the log outputs in code tags (the # symbol in the topic editor)

then: I have tried to debug your code, and here it works. Can you pleas turn on full debugger loging (Settings->Common->Full (Debug) log )
and post  the result from the "Debugger" tab here?

Where do you set the breakpoint (line)? And what do you use to step through (run, continue, step over, step in) ?

Are you getting a yellow warning the the bottom right  corner, something about "sigseg" or alike?


greetings

Offline anonymous_dan2015

  • Single posting newcomer
  • *
  • Posts: 3
Re: iostream keeps appearing in debugger
« Reply #3 on: July 16, 2015, 02:14:19 pm »
Hi BlueHazzard,

Thanks for your reply.

The code is as follows:

#include <iostream>

using namespace std;

int main()
{
    int x = 3;

    while (x==3)
    {
        cout << "X value is: " << x << endl;
        cout << "New x value: " << endl;
        cin >> x;
    }
        cout << "Loop terminated as condition is false" << endl;
    return 0;
}

I put the breakpoint on the cout << "X value is: " << x << endl; line

I have turned on the full debug log as you said an this is the log of what I got:

#
Building to ensure sources are up-to-date
Selecting target:
Debug
Adding source dir: C:\Documents and Settings\Daniel Travers\Desktop\5M0529\Teaching Modules\OOP\Random Programs\here\
Adding source dir: C:\Documents and Settings\Daniel Travers\Desktop\5M0529\Teaching Modules\OOP\Random Programs\here\
Adding file: C:\Documents and Settings\Daniel Travers\Desktop\5M0529\Teaching Modules\OOP\Random Programs\here\bin\Debug\here.exe
Changing directory to: C:/DOCUME~1/DANIEL~1/Desktop/5M0529/TEACHI~1/OOP/RANDOM~1/here/.
Set variable: PATH=.;C:\Dev-Cpp\bin;C:\Dev-Cpp;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\system32\wbem;C:\Program Files\QuickTime\QTSystem;C:\j2sdk1.4.2_11\bin;C:\Program Files\Calibre2;c:\Program Files\Microsoft SQL Server\100\Tools\Binn;c:\Program Files\Microsoft SQL Server\100\DTS\Binn;C:\Program Files\Microsoft Visual Studio\Common\Tools\WinNT;C:\Program Files\Microsoft Visual Studio\Common\MSDev98\Bin;C:\Program Files\Microsoft Visual Studio\Common\Tools;C:\Program Files\Microsoft Visual Studio\VC98\Bin;C:\WINDOWS\system32\glut.h;C:\WINDOWS\system32\glut32.lib

[debug]Command-line: C:\Program Files\CodeBlocks\MINGW\bin\gdb.exe -nx -fullname  -quiet  -args C:/DOCUME~1/DANIEL~1/Desktop/5M0529/TEACHI~1/OOP/RANDOM~1/here/bin/Debug/here.exe
[debug]Working dir : C:\DOCUME~1\DANIEL~1\Desktop\5M0529\TEACHI~1\OOP\RANDOM~1\here

Starting debugger: C:\Program Files\CodeBlocks\MINGW\bin\gdb.exe -nx -fullname  -quiet  -args C:/DOCUME~1/DANIEL~1/Desktop/5M0529/TEACHI~1/OOP/RANDOM~1/here/bin/Debug/here.exe
done

[debug]> set prompt >>>>>>cb_gdb:

Registered new type: wxString
Registered new type: STL String
Registered new type: STL Vector
Setting breakpoints

[debug]Reading symbols from C:\DOCUME~1\DANIEL~1\Desktop\5M0529\TEACHI~1\OOP\RANDOM~1\here\bin\Debug\here.exe...done.
[debug](gdb) >>>>>>cb_gdb:
[debug]> show version
[debug]GNU gdb (GDB) 7.5
[debug]Copyright (C) 2012 Free Software Foundation, Inc.
[debug]License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
[debug]This is free software: you are free to change and redistribute it.
[debug]There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
[debug]and "show warranty" for details.
[debug]This GDB was configured as "i686-pc-mingw32".
[debug]For bug reporting instructions, please see:
[debug]<http://www.gnu.org/software/gdb/bugs/>.
[debug]>>>>>>cb_gdb:
[debug]> set confirm off

Debugger name and version: GNU gdb (GDB) 7.5

[debug]>>>>>>cb_gdb:
[debug]> set width 0
[debug]>>>>>>cb_gdb:
[debug]> set height 0
[debug]>>>>>>cb_gdb:
[debug]> set breakpoint pending on
[debug]>>>>>>cb_gdb:
[debug]> set print asm-demangle on
[debug]>>>>>>cb_gdb:
[debug]> set unwindonsignal on
[debug]>>>>>>cb_gdb:
[debug]> set print elements 0
[debug]>>>>>>cb_gdb:
[debug]> set new-console on
[debug]>>>>>>cb_gdb:
[debug]> set disassembly-flavor att
[debug]>>>>>>cb_gdb:
[debug]> source C:\Program Files\CodeBlocks\share\codeblocks/scripts/stl-views-1.0.3.gdb
[debug]>>>>>>cb_gdb:
[debug]> directory C:/DOCUME~1/DANIEL~1/Desktop/5M0529/TEACHI~1/OOP/RANDOM~1/here/
[debug]Source directories searched: C:/DOCUME~1/DANIEL~1/Desktop/5M0529/TEACHI~1/OOP/RANDOM~1/here;$cdir;$cwd
[debug]>>>>>>cb_gdb:
[debug]> break "C:/Documents and Settings/Daniel Travers/Desktop/5M0529/Teaching Modules/OOP/Random Programs/here/main.cpp:11"
[debug]Breakpoint 1 at 0x4013c7: file C:/Documents and Settings/Daniel Travers/Desktop/5M0529/Teaching Modules/OOP/Random Programs/here/main.cpp, line 11.
[debug]>>>>>>cb_gdb:
[debug]> start
[debug]Temporary breakpoint 2 at 0x4013ba: file C:/Documents and Settings/Daniel Travers/Desktop/5M0529/Teaching Modules/OOP/Random Programs/here/main.cpp, line 7.
[debug]Starting program: C:\DOCUME~1\DANIEL~1\Desktop\5M0529\TEACHI~1\OOP\RANDOM~1\here\bin\Debug\here.exe

Child process PID: 5376

[debug][New Thread 5376.0x240]
[debug]Temporary breakpoint 2, main () at C:/Documents and Settings/Daniel Travers/Desktop/5M0529/Teaching Modules/OOP/Random Programs/here/main.cpp:7
[debug]C:\Documents and Settings\Daniel Travers\Desktop\5M0529\Teaching Modules\OOP\Random Programs\here\main.cpp:7:62:beg:0x4013ba
[debug]>>>>>>cb_gdb:

At C:\Documents and Settings\Daniel Travers\Desktop\5M0529\Teaching Modules\OOP\Random Programs\here\main.cpp:7

[debug]> info program
[debug]   Using the running image of child Thread 5376.0x240.
[debug]Program stopped at 0x4013ba.
[debug]It stopped at a breakpoint that has since been deleted.
[debug]>>>>>>cb_gdb:
[debug]> step
[debug]C:\Documents and Settings\Daniel Travers\Desktop\5M0529\Teaching Modules\OOP\Random Programs\here\main.cpp:9:80:beg:0x4013c1
[debug]>>>>>>cb_gdb:

At C:\Documents and Settings\Daniel Travers\Desktop\5M0529\Teaching Modules\OOP\Random Programs\here\main.cpp:9
#

I constantly pressed the 'step into' button when the debugger is working. It constantly hops from my code to iostream code. The only way around it is if i press the'step into' button to debug a liine of my code and then press 'step out of' when it tries to debug the iostream code.

Offline scarphin

  • Lives here!
  • ****
  • Posts: 644
Re: iostream keeps appearing in debugger
« Reply #4 on: July 16, 2015, 04:11:24 pm »
Code tags doesn't work when you put the '#' symbol at the beginning and end of your code. There is a dedicated icon in the topic editor with the '#' sign on it, please use that next time and even better please edit your post. It should output something like
Code
your code here
and place your code between these 2.

And for your problem did you try 'next line' in the debugger menu to step through your code?

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13413
    • Travis build status
Re: iostream keeps appearing in debugger
« Reply #5 on: July 18, 2015, 01:29:40 pm »
It seems you're using really old mingw release.
Can you please try to use one a bit newer?
GCC 3.4.x is really old these days, there are GCC 4.7, 4.8, 4.9 and even 5.1 that should work a bit better.
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

Offline papagym

  • Multiple posting newcomer
  • *
  • Posts: 41
Re: iostream keeps appearing in debugger
« Reply #6 on: July 19, 2015, 04:41:42 pm »
I'm new here too, so this may not solve your problem.

I think you need to set the debugger on the first line of code you want to start the debug on, (But I don't know how to set the start point in Codeblocks) and use break points after that.  So I would think it needs to start on the line after (int main () ) or later.  That may be why your seeing the #include <iostream>

Good Luck

« Last Edit: July 19, 2015, 04:55:37 pm by James Guth »

Offline BlueHazzard

  • Developer
  • Lives here!
  • *****
  • Posts: 3353
Re: iostream keeps appearing in debugger
« Reply #7 on: July 19, 2015, 05:56:16 pm »
Quote
I constantly pressed the 'step into' button when the debugger is working. It constantly hops from my code to iostream code. The only way around it is if i press the'step into' button to debug a liine of my code and then press 'step out of' when it tries to debug the iostream code.

his problem is clearly that he is stepping "into" the iostram code... He has to use step over (aka "next line" ) or set a break point on every line and use continue....
if i step into a function a will land into that function....

greetings