Author Topic: How to debug  (Read 9195 times)

Offline Vic

  • Single posting newcomer
  • *
  • Posts: 4
How to debug
« on: December 31, 2009, 01:53:33 pm »
I am new to CodeBlocks, and try to work with the debugger an de following simple code.

Code
#include <iostream>
using namespace std;

int main()
{

    int q=100;
    int *p;
    char c;
   
    cout << "Hello world!" << endl;                                              //Breakpoint 1
    p= new (nothrow) int [q];
    if (p == 0)
    cout << "Error: memory could not be allocated";
    else {
    for (int i=0; i<q; i++)
        p[i]= i+1;

    for (int i=q-10; i<q; i++)
        cout << "P " << i << " = " << p[i] << endl;
    }
    delete [] p;
    cout << "Hello C++" << endl;                                                  //Breakpoint 2
    cin >> c;

    return 0;
}

When i press F8 (Start debugger) the debug windows show following
Quote
Building to ensure sources are up-to-date
Build succeeded
Selecting target:
Debug
Adding source dir: G:\Jo\documents\TestDebug\
Adding source dir: G:\Jo\documents\TestDebug\
Adding file: bin\Debug\TestDebug.exe
Starting debugger:
done
Registered new type: wxString
Registered new type: STL String
Registered new type: STL Vector
Setting breakpoints
Debugger name and version: GNU gdb 6.7.50.20071127
Function "G:/Jo/Programmeren I (Van Laethem)" not defined.
Breakpoint 1 ("G:/Jo/Programmeren I (Van Laethem)/documents/CurusTest/TestDebug/main.cpp:28) pending.
Function "G:/Jo/Programmeren I (Van Laethem)" not defined.
Breakpoint 2 ("G:/Jo/Programmeren I (Van Laethem)/documents/CurusTest/TestDebug/main.cpp:12) pending.
Child process PID: 3864
Error while reading shared library symbols:
Error while reading shared library symbols:
Program exited normally.
Error while reading shared library symbols:
Error while reading shared library symbols:
Error while reading shared library symbols:
Error while reading shared library symbols:
Error while reading shared library symbols:
Error while reading shared library symbols:
Debugger finished with status 0

The program run without stop on the breakpoints .
What i do wrong, cane somebody help me.

Best Regards, Vic

Offline Jenna

  • Administrator
  • Lives here!
  • *****
  • Posts: 7255
Re: How to debug
« Reply #1 on: December 31, 2009, 03:21:49 pm »
Do not use braces ( "(" and ")" ) in your path !

Offline Vic

  • Single posting newcomer
  • *
  • Posts: 4
Re: How to debug
« Reply #2 on: December 31, 2009, 04:31:54 pm »
Thx for the replay.
I changed the path, but still have the same problem.

The output of the debug Window is now,
Quote
Building to ensure sources are up-to-date
Build succeeded
Selecting target:
Debug
Adding source dir: G:\Jo\ProgOef\TestDebug\
Adding source dir: G:\Jo\ProgOef\TestDebug\
Adding file: bin\Debug\TestDebug.exe
Starting debugger:
done
Registered new type: wxString
Registered new type: STL String
Registered new type: STL Vector
Setting breakpoints
Debugger name and version: GNU gdb 6.7.50.20071127
No source file named G:/Jo/ProgOef/TestDebug/main.cpp.
Breakpoint 1 ("G:/Jo/ProgOef/TestDebug/main.cpp:28) pending.
No source file named G:/Jo/ProgOef/TestDebug/main.cpp.
Breakpoint 2 ("G:/Jo/ProgOef/TestDebug/main.cpp:12) pending.
Child process PID: 4872
Error while reading shared library symbols:
Error while reading shared library symbols:
Program exited normally.
Error while reading shared library symbols:
Error while reading shared library symbols:
Error while reading shared library symbols:
Error while reading shared library symbols:
Error while reading shared library symbols:
Error while reading shared library symbols:
Debugger finished with status 0

I hope somebody can help me.
Best Regards, Vic

Offline Jenna

  • Administrator
  • Lives here!
  • *****
  • Posts: 7255
Re: How to debug
« Reply #3 on: December 31, 2009, 05:00:42 pm »
Which version of C::B, MinGW and which OS (and version) are you using ?

Did you read this : http://wiki.codeblocks.org/index.php?title=Debugging_with_Code::Blocks?
Turning on full commandline logging (and post the build log)  might also help to track down the problem: http://wiki.codeblocks.org/index.php?title=FAQ#Q:_How_do_I_troubleshoot_an_compiler_problem.3F

Offline Vic

  • Single posting newcomer
  • *
  • Posts: 4
Re: How to debug
« Reply #4 on: January 02, 2010, 10:17:38 am »
Changing the Compiler logging setting to full command line was the solution for the problem. But i have seen that when i set this back to the default setting the debugger function are still working. I can't not well understand this, but all right the functions are working that is the most important thing.

I still have a small question what is the difference between the debugger function Next Line and Next Instruction? And when i use the Next Instuction function automatic the disasemby window is opend is this normal or due to a setting?

PS. The version of codeblocks 8.02, OS = Windows XP and MinGW i don't no where do i find that. It is de version skip with the download of  Codeblocks 8.02


In every way thanks for the tips
Best Regards,

Vic

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13413
    • Travis build status
Re: How to debug
« Reply #5 on: January 02, 2010, 11:34:21 am »
Next line - means goto next source (c/c++) line
Next instruction - goto next assembly/machine instruction
(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 Vic

  • Single posting newcomer
  • *
  • Posts: 4
Re: How to debug
« Reply #6 on: January 02, 2010, 12:44:08 pm »
Ok thx for the info.


Best Regards,
Vic