User forums > Using Code::Blocks

Don't understand debugging..???

<< < (3/8) > >>

Jenna:
@johne53
Have you ever tried to place the cursor on your first breakpoint and say run to cursor from menu.
Another problem is/was that gdb cannot stop on breakpoints in constructors (I don't know which version of gdb fixed this, or if it is fixed for Win).
If that's the problem you can call a dummy function dorm ctor and place the breakpoint in it and from there step through your code with F7.

johne53:

--- Quote from: jens on October 26, 2007, 07:56:09 am ---@johne53
Have you ever tried to place the cursor on your first breakpoint and say run to cursor from menu.
--- End quote ---
Yes, I tried that but it didn't make a difference.


--- Quote from: jens on October 26, 2007, 07:56:09 am ---Another problem is/was that gdb cannot stop on breakpoints in constructors (I don't know which version of gdb fixed this, or if it is fixed for Win).
--- End quote ---
I must admit, I didn't know that. But some time ago (when it used to work) I successfully placed breakpoints inside a c'tor using gcc 4.1.1, so I assume it must have been fixed by then.

In fact, even if I don't have any break points at all, I would expect that Debug->Start would just launch my app - but it doesn't....  :(

Jenna:

--- Quote from: johne53 on October 24, 2007, 10:41:05 am ---"No symbol table is loaded: Use the 'file' command". Should that mean something to me?

--- End quote ---
Normally that means that there are no debugging symbols in the source file.
Is the "-g" option (Produce debugging symbols set in the Build options for the Debug target ?
You can also try to put "-gstabs+" in "Build options... -> Compiler Settings -> Other Options" instead of (or additionally to) using "-g" .

johne53:
Good grief.... I decided to check on the actual version of gdb (rather than gcc) and it turns out that I'm using gdb version 6.5 - but guess what.... debugging is suddenly working this morning!!

I created the following 'Hello World' type app....


--- Code: ---#include <iostream>
#include <stdio.h>

int main()
{
char x;

    printf("Hello World\n"); // 1st breakpoint here
    printf("Hello Earth\n");
   printf("Hello Venus\n"); // and 2nd breakpoint here

    std::cin >> x;
    return (0);
}
--- End code ---

I placed break points on the indicated lines. C::B consistently refuses to stop at the first break point - but it does stop at the second break point, every time!!

Knowing this, I loaded up the same project that I was trying to debug a couple of days ago and placed more than one breakpoint. Surprise, surprise - it suddenly works!! I haven't rebuilt the project or changed it in any way (in fact I haven't used C::B or Linux. I've been using VC++ under Windows for the past couple of days).

This is exactly the kind of unreliability that I mean.... If I just shut down and don't use Linux for the rest of today, I'm prepared to bet that it won't be working tomorrow!!

Jenna:
Exactly the same here svn4561 on debian.

<Edit>
No, not exactly the same. Only with the simple example, not in a bigger wxWidgets project.
</Edit>

This is the source code:

--- Code: ---#include <iostream>

using namespace std;

int main()
{
    unsigned char c;
    cout << "Hello world!" << endl;
    cout << "Again, hello world!" << endl;
    cout << "Hey world, why don't you answer to my call!" << endl;
    cin >> c;
    return 0;
}

--- End code ---

Breakpoints in Line 8 and 10

Works with gdb on console, but not in C::B.
In C::B it stops in line 10, but not line 8.

Here's the gdb.log from C::B:

--- Code: ---LD_LIBRARY_PATH=.:
Command-line: /usr/bin/gdb -nx -fullname  -quiet -args bin/Debug/test2
Working dir : /tmp/test2/
> set prompt >>>>>>cb_gdb:
Executing: xterm -T 'Program Console' -e sleep 88970
Using host libthread_db library "/lib/i686/cmov/libthread_db.so.1".
(gdb) >>>>>>cb_gdb:
> show version
GNU gdb 6.6.90.20070912-debian
Copyright (C) 2007 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "i486-linux-gnu".
>>>>>>cb_gdb:
> set confirm off
>>>>>>cb_gdb:
> set width 0
>>>>>>cb_gdb:
> set height 0
>>>>>>cb_gdb:
> set breakpoint pending on
>>>>>>cb_gdb:
> set print asm-demangle on
>>>>>>cb_gdb:
> set unwindonsignal on
>>>>>>cb_gdb:
> set disassembly-flavor intel
>>>>>>cb_gdb:
> directory /tmp/test2/
>>>>>>cb_gdb:
> break "/tmp/test2/main.cpp:10"
Breakpoint 1 at 0x8048a99: file /tmp/test2/main.cpp, line 10.
>>>>>>cb_gdb:
> break "/tmp/test2/main.cpp:8"
Breakpoint 2 at 0x8048a51: file /tmp/test2/main.cpp, line 8.
>>>>>>cb_gdb:
Executing: ps x -o tty,pid,command
PS result: tty3     32076 bash
PS result: tty3     32075 su jens
PS result: tty2     32068 bash
PS result: tty2     32067 su jens
PS result: tty1     32064 bash
PS result: tty1     32063 su jens
PS result: ?         9059 ps x -o tty,pid,command
PS result: pts/1     9058 sleep 88970
TTY is[/dev/pts/1]
GetConsoleTTY[/dev/pts/1]ConsolePid[9057]
> tty /dev/pts/1
Queued:[tty /dev/pts/1]
>>>>>>cb_gdb:
> start
Breakpoint 3 at 0x8048a51: file /tmp/test2/main.cpp, line 8.
[Thread debugging using libthread_db enabled]
[New Thread 0xb69b8a10 (LWP 9060)]
[Switching to Thread 0xb69b8a10 (LWP 9060)]
Breakpoint 2, main () at /tmp/test2/main.cpp:8
/tmp/test2/main.cpp:8:81:beg:0x8048a51
>>>>>>cb_gdb:
> info program
Using the running image of child Thread 0xb69b8a10 (LWP 9060).
Program stopped at 0x8048a51.
It stopped at breakpoint 2.
It stopped at a breakpoint that has since been deleted.
Type "info stack" or "info registers" for more information.
>>>>>>cb_gdb:
> cont
Breakpoint 1, main () at /tmp/test2/main.cpp:10
/tmp/test2/main.cpp:10:162:beg:0x8048a99
>>>>>>cb_gdb:
> cont
--- End code ---

In windows gdb works correctly (svn4551, W2K, MinGW 5.1.3 and gdb 6.3.2).

gdb's log from windows:

--- Code: ---PATH=.;C:\WINNT\system32;C:\WINNT;C:\WINNT\System32\Wbem;C:\MinGW\bin;C:\Programme\codeblocks
Command-line: C:\MinGW\bin\gdb.exe -nx -fullname  -quiet -args bin/Debug/test2.exe
Working dir : C:\Dokumente und Einstellungen\Administrator\Eigene Dateien\new\test2\
> set prompt >>>>>>cb_gdb:
(gdb) >>>>>>cb_gdb:
> show version
GNU gdb 6.3
Copyright 2004 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB.  Type "show warranty" for details.
This GDB was configured as "i686-pc-mingw32".
>>>>>>cb_gdb:
> set confirm off
>>>>>>cb_gdb:
> set width 0
>>>>>>cb_gdb:
> set height 0
>>>>>>cb_gdb:
> set breakpoint pending on
>>>>>>cb_gdb:
> set print asm-demangle on
>>>>>>cb_gdb:
> set unwindonsignal on
>>>>>>cb_gdb:
> set debugevents on
>>>>>>cb_gdb:
> set new-console on
>>>>>>cb_gdb:
> set disassembly-flavor att
>>>>>>cb_gdb:
> directory C:/DOKUME~1/ADMINI~1/EIGENE~1/new/test2/
>>>>>>cb_gdb:
> break "C:/Dokumente und Einstellungen/Administrator/Eigene Dateien/new/test2/main.cpp:10"
Breakpoint 1 at 0x401460: file C:/Dokumente und Einstellungen/Administrator/Eigene Dateien/new/test2/main.cpp, line 10.
>>>>>>cb_gdb:
> break "C:/Dokumente und Einstellungen/Administrator/Eigene Dateien/new/test2/main.cpp:8"
Breakpoint 2 at 0x401418: file C:/Dokumente und Einstellungen/Administrator/Eigene Dateien/new/test2/main.cpp, line 8.
>>>>>>cb_gdb:
> run
Breakpoint 2, main () at C:/Dokumente und Einstellungen/Administrator/Eigene Dateien/new/test2/main.cpp:8
C:/Dokumente und Einstellungen/Administrator/Eigene Dateien/new/test2/main.cpp:8:84:beg:0x401418
>>>>>>cb_gdb:
> set debugevents off
>>>>>>cb_gdb:
> cont
Breakpoint 1, main () at C:/Dokumente und Einstellungen/Administrator/Eigene Dateien/new/test2/main.cpp:10
C:/Dokumente und Einstellungen/Administrator/Eigene Dateien/new/test2/main.cpp:10:165:beg:0x401460
>>>>>>cb_gdb:
> cont
Program exited normally.
>>>>>>cb_gdb:
> quit

--- End code ---

Navigation

[0] Message Index

[#] Next page

[*] Previous page

Go to full version