I would check your source directories:
Source directories searched: /cygdrive/c/test_project/C:/test_project:$cdir:$cwd
because that looks messed up...
Ok, I know the problem.
Source directories searched: /cygdrive/c/test_project/C:/test_project:$cdir:$cwd
This is not the issue, never mind about this.
[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
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:
set filename-display relative
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
set filename-display relative
can affect the file name format of the breakpoint, it does change the filename display format for backtrace command.
Look, I just test it, I create a simple app, and build it with relative paths(advanced settings in compiler setting dialog)
[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
Then "source E:\code\gdb\mybuild\bin\my.gdb" contains the "set filename-display relative", and look, the return file name is now relative:
Breakpoint 1, main () at main.cpp:12
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???
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.
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
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).
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:
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.
I just read the C::B source code, and I found several functions to handle cygdrive related paths:
// Cygwin check code
#ifdef __WXMSW__
enum{ BUFSIZE = 64 };
// routines to handle cygwin compiled programs on a Windows compiled C::B IDE
void GDB_driver::DetectCygwinMount(void)
{
....
m_CygwinPresent = true; // if we end up here all was OK
m_CygdrivePrefix = (szCygwinRoot); // convert to wxString type for later use
}
void GDB_driver::CorrectCygwinPath(wxString& path)
{
...
}
#else
void GDB_driver::DetectCygwinMount(void){/* dummy */}
void GDB_driver::CorrectCygwinPath(cb_unused wxString& path){/* dummy */}
#endif
So, normally, the cygwin installation is detected.
Especially, there are code to do the translation:
// Check for possibility of a cygwin compiled program
// convert to valid path
if (platform::windows && m_CygwinPresent)
CorrectCygwinPath(lines.Item(i));
Now, here comes my guess, you have installed the cygwin 64 bit, which our function: void GDB_driver::DetectCygwinMount(void) failed to detect as a cygwin. The detecting algorithm is simply check the Windows registry like:
// routines to handle cygwin compiled programs on a Windows compiled C::B IDE
void GDB_driver::DetectCygwinMount(void)
{
LONG lRegistryAPIresult;
HKEY hKey_CU;
HKEY hKey_LM;
TCHAR szCygwinRoot[BUFSIZE];
DWORD dwBufLen=BUFSIZE*sizeof(TCHAR);
// checking if cygwin mounts are present under HKCU
lRegistryAPIresult = RegOpenKeyEx( HKEY_CURRENT_USER,
TEXT("Software\\Cygnus Solutions\\Cygwin\\mounts v2"),
0, KEY_QUERY_VALUE, &hKey_CU );
if ( lRegistryAPIresult == ERROR_SUCCESS )
{
// try to readback cygwin root (might not exist!)
lRegistryAPIresult = RegQueryValueEx( hKey_CU, TEXT("cygdrive prefix"), NULL, NULL,
(LPBYTE) szCygwinRoot, &dwBufLen);
}
// lRegistryAPIresult can be erroneous for two reasons:
// 1.) Cygwin entry is not present (could not be opened) in HKCU
// 2.) "cygdrive prefix" is not present (could not be read) in HKCU
if ( lRegistryAPIresult != ERROR_SUCCESS )
{
// Now check if probably present under HKLM
lRegistryAPIresult = RegOpenKeyEx( HKEY_LOCAL_MACHINE,
TEXT("SOFTWARE\\Cygnus Solutions\\Cygwin\\mounts v2"),
0, KEY_QUERY_VALUE, &hKey_LM );
if ( lRegistryAPIresult != ERROR_SUCCESS )
{
// cygwin definitely not installed
m_CygwinPresent = false;
return;
}
// try to readback cygwin root (now it really should exist here)
lRegistryAPIresult = RegQueryValueEx( hKey_LM, TEXT("cygdrive prefix"), NULL, NULL,
(LPBYTE) szCygwinRoot, &dwBufLen);
}
// handle a possible query error
if ( (lRegistryAPIresult != ERROR_SUCCESS) || (dwBufLen > BUFSIZE*sizeof(TCHAR)) )
{
// bit of an assumption, but we won't be able to find the root without it
m_CygwinPresent = false;
return;
}
// close opened keys
RegCloseKey( hKey_CU ); // ignore key close errors
RegCloseKey( hKey_LM ); // ignore key close errors
m_CygwinPresent = true; // if we end up here all was OK
m_CygdrivePrefix = (szCygwinRoot); // convert to wxString type for later use
}
Can you try to see in your Windows registry that those expect value exist? If not, can you create some dummy ones to cheat C::B's DetectCygwinMount function?
Ok, I tried your solution and created a registry entry as described on this page: http://forums.codeblocks.org/index.php/topic,13791.msg92903.html and this is the output I received when I retried debugging the program (the compiler and debugger have the exact settings restored, including the set filename-display relative initialisation command and the Use full path for source files(GDB workaround) checkbox)
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: 132
[debug][New Thread 132.0x88c]
[debug][New Thread 132.0x1808]
[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