User forums > Using Code::Blocks

Cygwin with CodeBlocks gdb error

<< < (2/5) > >>

venom4u31:

--- Quote from: ollydbg on December 10, 2013, 04:57:42 am ---I have no experience with cygwin(gcc+gdb), but for your problem, I think it is good to build your exe with "relative path" enabled, so that C::B or GDB can try to search/open a file with relative path.

To use the relative path, you can try Settings->compilers->other settings->advanced options button->Others

Then, De-select the option "Use full path for source files(GDB workaround)".

BTW: it was a GDB workaround option, but with modern GDB(I think version >7.0) handles source file paths very well. So, it is safe to de-select this option.

--- End quote ---

I tried your suggestion, but got the same error, even after I restarted and rebuilt the project. Here's the log information:


--- Quote ---Building to ensure sources are up-to-date
Selecting target:
Debug
Adding source dir: C:\test_project\
Adding source dir: C:\test_project\
Adding file: C:\test_project\bin\Debug\test_project.exe
Changing directory to: C:/test_project/.
Set variable: PATH=.;C:\cygwin64\bin;C:\cygwin64;C:\Program Files (x86)\CodeBlocks\MinGW\bin;C:\Program Files (x86)\CodeBlocks\MinGW;C:\Program Files\Common Files\Microsoft Shared\Windows Live

[debug]Command-line: C:\cygwin64\bin\gdb.exe -nx -fullname  -quiet  -args C:/test_project/bin/Debug/test_project.exe
[debug]Working dir : C:\test_project

Starting debugger: C:\cygwin64\bin\gdb.exe -nx -fullname  -quiet  -args C:/test_project/bin/Debug/test_project.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 /cygdrive/c/test_project/bin/Debug/test_project.exe...done.
[debug](gdb) >>>>>>cb_gdb:
[debug]> show version
[debug]GNU gdb (GDB) 7.6.50.20130728-cvs (cygwin-special)
[debug]Copyright (C) 2013 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 "x86_64-pc-cygwin".
[debug]Type "show configuration" for configuration details.
[debug]For bug reporting instructions, please see:
[debug]<http://www.gnu.org/software/gdb/bugs/>.
[debug]Find the GDB manual and other documentation resources online at:
[debug]<http://www.gnu.org/software/gdb/documentation/>.
[debug]For help, type "help".
[debug]Type "apropos word" to search for commands related to "word".
[debug]>>>>>>cb_gdb:
[debug]> set confirm off

Debugger name and version: GNU gdb (GDB) 7.6.50.20130728-cvs (cygwin-special)

[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]> catch throw
[debug]Catchpoint 1 (throw)
[debug]>>>>>>cb_gdb:
[debug]> source C:\Program Files (x86)\CodeBlocks\share\codeblocks/scripts/stl-views-1.0.3.gdb
[debug]>>>>>>cb_gdb:
[debug]> directory C:/test_project/
[debug]Source directories searched: /cygdrive/c/test_project/C:/test_project:$cdir:$cwd
[debug]>>>>>>cb_gdb:
[debug]> break "C:/test_project/main.c:6"
[debug]Breakpoint 2 at 0x1004010dd: file C:\test_project\main.c, line 6.
[debug]>>>>>>cb_gdb:
[debug]> run
[debug]Starting program: /cygdrive/c/test_project/bin/Debug/test_project.exe

Child process PID: 1448

[debug][New Thread 1448.0x181c]
[debug][New Thread 1448.0x179c]
[debug]Breakpoint 2, main () at C:\test_project\main.c:6
[debug]/cygdrive/c/test_project/main.c:6:58:beg:0x1004010dd
[debug]>>>>>>cb_gdb:

Cannot open file: /cygdrive/c/test_project/main.c
At /cygdrive/c/test_project/main.c:6
--- End quote ---

venom4u31:

--- Quote from: ouch on December 10, 2013, 02:14:47 am ---I would check your source directories:


--- Code: ---Source directories searched: /cygdrive/c/test_project/C:/test_project:$cdir:$cwd
--- End code ---

because that looks messed up...

--- End quote ---

I agree that this looks messed up, but I have no idea of what to do about it.

ollydbg:
Ok, I know the problem.

--- Code: ---Source directories searched: /cygdrive/c/test_project/C:/test_project:$cdir:$cwd

--- End code ---
This is not the issue, never mind about this.


--- Code: ---[debug]Breakpoint 2, main () at C:\test_project\main.c:6
[debug]/cygdrive/c/test_project/main.c:6:58:beg:0x1004010dd
[debug]>>>>>>cb_gdb:

Cannot open file: /cygdrive/c/test_project/main.c
At /cygdrive/c/test_project/main.c:6

--- End code ---
This is the core point, you see, GDB still return the full path of "/cygdrive/c/test_project/main.c:...."

Now, If I remember correct, there is an option to change this behavior under GDB, like:


--- Code: ---set filename-display relative

--- End code ---
SEE: http://visualgdb.com/gdbreference/commands/set_filename-display

Now, this will let GDB only print the relative file path, in your case maybe "main.c".

You can put this command in: Debugger settings->Debugger initialization commands.

NOTE: I'm not sure whether the comman

--- Code: ---set filename-display relative

--- End code ---
can affect the file name format of the breakpoint, it does change the filename display format for backtrace command.





ollydbg:
Look, I just test it, I create a simple app, and build it with relative paths(advanced settings in compiler setting dialog)

--- Code: ---[debug]> set new-console on
[debug]>>>>>>cb_gdb:
[debug]> set disassembly-flavor intel
[debug]>>>>>>cb_gdb:
[debug]> source E:\code\gdb\mybuild\bin\my.gdb
[debug]>>>>>>cb_gdb:
[debug]> directory E:/code/cb/test_code/test-memory-leak/
[debug]Source directories searched: E:/code/cb/test_code/test-memory-leak;$cdir;$cwd
[debug]>>>>>>cb_gdb:
[debug]> break "E:/code/cb/test_code/test-memory-leak/main.cpp:12"
[debug]Breakpoint 1 at 0x401613: file main.cpp, line 12.
[debug]>>>>>>cb_gdb:
[debug]> run
[debug]Starting program: E:\code\cb\test_code\test-memory-leak\bin\Debug\test-memory-leak.exe

Child process PID: 304

[debug][New Thread 304.0xdf4]
[debug]Breakpoint 1, main () at main.cpp:12
[debug]E:\code\cb\test_code\test-memory-leak\main.cpp:12:172:beg:0x401613
[debug]>>>>>>cb_gdb:

At E:\code\cb\test_code\test-memory-leak\main.cpp:12

--- End code ---

Then "source E:\code\gdb\mybuild\bin\my.gdb" contains the "set filename-display relative", and look, the return file name is now relative:


--- Code: ---Breakpoint 1, main () at main.cpp:12

--- End code ---

But the bad thing is, the next line is still full path: "E:\code\cb\test_code\test-memory-leak\main.cpp:12:172:beg:0x401613", C::B need to parse this line to locate the caret. In your case, it is "/cygdrive/c/test_project/main.c", which C::B don't know to translate to "c:test_project/main.c"

One question: can you just try a Mingw version of GDB to debug your problem (Not the one shipped with cygwin).

EDIT:
I see your are using a cygwin 64bit GDB (This GDB was configured as "x86_64-pc-cygwin".), so you are using 64bit GDB, I think TDM-GCC-64bit maybe contains 64bit GDB.exe, since the cygwin GDB will always return a full path which has a prefix "/cygdrive/c/....", can you try to find an option to remove them???



venom4u31:
I tried adding the command to the initialization command list, and this is the output... the outcome is the same though. However, the command seems to be called.


--- Code: ---Building to ensure sources are up-to-date
Selecting target:
Debug
Adding source dir: C:\test_project\
Adding source dir: C:\test_project\
Adding file: C:\test_project\bin\Debug\test_project.exe
Changing directory to: C:/test_project/.
Set variable: PATH=.;C:\cygwin64\bin;C:\cygwin64;C:\Program Files (x86)\CodeBlocks\MinGW\bin;C:\Program Files (x86)\CodeBlocks\MinGW;C:\Program Files\Common Files\Microsoft Shared\Windows Live

[debug]Command-line: C:\cygwin64\bin\gdb.exe -nx -fullname  -quiet  -args C:/test_project/bin/Debug/test_project.exe
[debug]Working dir : C:\test_project

Starting debugger: C:\cygwin64\bin\gdb.exe -nx -fullname  -quiet  -args C:/test_project/bin/Debug/test_project.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 /cygdrive/c/test_project/bin/Debug/test_project.exe...done.
[debug](gdb) >>>>>>cb_gdb:
[debug]> show version
[debug]GNU gdb (GDB) 7.6.50.20130728-cvs (cygwin-special)
[debug]Copyright (C) 2013 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 "x86_64-pc-cygwin".
[debug]Type "show configuration" for configuration details.
[debug]For bug reporting instructions, please see:
[debug]<http://www.gnu.org/software/gdb/bugs/>.
[debug]Find the GDB manual and other documentation resources online at:
[debug]<http://www.gnu.org/software/gdb/documentation/>.
[debug]For help, type "help".
[debug]Type "apropos word" to search for commands related to "word".
[debug]>>>>>>cb_gdb:
[debug]> set confirm off

Debugger name and version: GNU gdb (GDB) 7.6.50.20130728-cvs (cygwin-special)

[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]> catch throw
[debug]Catchpoint 1 (throw)
[debug]>>>>>>cb_gdb:
[debug]> source C:\Program Files (x86)\CodeBlocks\share\codeblocks/scripts/stl-views-1.0.3.gdb
[debug]>>>>>>cb_gdb:
[debug]> set filename-display relative
[debug]>>>>>>cb_gdb:
[debug]> directory C:/test_project/
[debug]Source directories searched: /cygdrive/c/test_project/C:/test_project:$cdir:$cwd
[debug]>>>>>>cb_gdb:
[debug]> break "C:/test_project/main.c:6"
[debug]Breakpoint 2 at 0x1004010dd: file main.c, line 6.
[debug]>>>>>>cb_gdb:
[debug]> run
[debug]Starting program: /cygdrive/c/test_project/bin/Debug/test_project.exe

Child process PID: 3920

[debug][New Thread 3920.0x19d8]
[debug][New Thread 3920.0x11a8]
[debug]Breakpoint 2, main () at main.c:6
[debug]/cygdrive/c/test_project/main.c:6:58:beg:0x1004010dd
[debug]>>>>>>cb_gdb:

Cannot open file: /cygdrive/c/test_project/main.c
At /cygdrive/c/test_project/main.c:6
--- End code ---


This is the output from the minGW debugger: There also seems to be some problem with it that hasn't occurred before trying out the cygwin debugger (it has no modification done to it, and it produces the same output to older projects as well).


--- Code: ---Building to ensure sources are up-to-date
Selecting target:
Debug
Adding source dir: C:\test_project\
Adding source dir: C:\test_project\
Adding file: C:\test_project\bin\Debug\test_project.exe
Changing directory to: C:/test_project/.
Set variable: PATH=.;C:\Program Files (x86)\CodeBlocks\MinGW\bin;C:\Program Files (x86)\CodeBlocks\MinGW;C:\cygwin64\bin;C:\cygwin64;C:\Program Files\Common Files\Microsoft Shared\Windows Live

[debug]Command-line: C:\cygwin64\bin\gdb.exe -nx -fullname  -quiet  -args C:/test_project/bin/Debug/test_project.exe
[debug]Working dir : C:\test_project

Starting debugger: C:\cygwin64\bin\gdb.exe -nx -fullname  -quiet  -args C:/test_project/bin/Debug/test_project.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 /cygdrive/c/test_project/bin/Debug/test_project.exe...done.
[debug](gdb) >>>>>>cb_gdb:
[debug]> show version
[debug]GNU gdb (GDB) 7.6.50.20130728-cvs (cygwin-special)
[debug]Copyright (C) 2013 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 "x86_64-pc-cygwin".
[debug]Type "show configuration" for configuration details.
[debug]For bug reporting instructions, please see:
[debug]<http://www.gnu.org/software/gdb/bugs/>.
[debug]Find the GDB manual and other documentation resources online at:
[debug]<http://www.gnu.org/software/gdb/documentation/>.
[debug]For help, type "help".
[debug]Type "apropos word" to search for commands related to "word".
[debug]>>>>>>cb_gdb:
[debug]> set confirm off

Debugger name and version: GNU gdb (GDB) 7.6.50.20130728-cvs (cygwin-special)

[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]> catch throw
[debug]Catchpoint 1 (throw)
[debug]>>>>>>cb_gdb:
[debug]> source C:\Program Files (x86)\CodeBlocks\share\codeblocks/scripts/stl-views-1.0.3.gdb
[debug]>>>>>>cb_gdb:
[debug]> set filename-display relative
[debug]>>>>>>cb_gdb:
[debug]> directory C:/test_project/
[debug]Source directories searched: /cygdrive/c/test_project/C:/test_project:$cdir:$cwd
[debug]>>>>>>cb_gdb:
[debug]> break "C:/test_project/main.c:6"
[debug]Breakpoint 2 at 0x401342: file C:\test_project\main.c, line 6.
[debug]>>>>>>cb_gdb:
[debug]> run
[debug]dll path too long
[debug]dll path too long
[debug]dll path too long
[debug]dll path too long
[debug]dll path too long
[debug]Starting program: /cygdrive/c/test_project/bin/Debug/test_project.exe

Child process PID: 7016

[debug][New Thread 7016.0x10f4]
[debug]Program received signal ?, Unknown signal.
[debug]0x0008da98 in ?? ()
[debug]>>>>>>cb_gdb:

In ?? () ()

[debug]> bt 30
[debug]#0  0x0008da98 in ?? ()
[debug]>>>>>>cb_gdb:

--- End code ---

EDIT:

I deleted the Cygwin compiler and debogger from C::B and everything works normally. I am going to remove the 64-bit cygwin and install the 32-bit one and see what happens then.

Navigation

[0] Message Index

[#] Next page

[*] Previous page

Go to full version