User forums > Using Code::Blocks
Cygwin with CodeBlocks gdb error
ollydbg:
I just read the C::B source code, and I found several functions to handle cygdrive related paths:
--- Code: ---// 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
--- End code ---
So, normally, the cygwin installation is detected.
Especially, there are code to do the translation:
--- Code: --- // Check for possibility of a cygwin compiled program
// convert to valid path
if (platform::windows && m_CygwinPresent)
CorrectCygwinPath(lines.Item(i));
--- End code ---
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:
--- Code: ---// 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
}
--- End code ---
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?
venom4u31:
I don't have those registers... I'll create some dummy ones and let you know if it worked.
ollydbg:
--- Quote from: venom4u31 on December 10, 2013, 08:37:21 am ---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: ---...
[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 ---
--- End quote ---
yes, the change filename display command works OK.
--- Quote ---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
....
--- End code ---
--- End quote ---
You are still using cygwin GDB 64 bit, right? see "Starting debugger: C:\cygwin64\bin\gdb.exe".
Please see my previous posts, there I think you can have a workaround, C::B already have mechanisms to translate the cygdrive style drive to normal windows path.
venom4u31:
Yes, I did install the 64-bit Cygwin. However, when I add them to C::B, and try to use the MinGW compiler it produces that output (it fails to read the file). After I removed it it works just fine, even though I didn't modify anything to the MinGW compiler/debugger settings.
Ok, I'll re-add the compiler and debugger to C::B and try your suggestions. I'll let you know of the results.
venom4u31:
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)
--- 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: 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
--- End code ---
Navigation
[0] Message Index
[#] Next page
[*] Previous page
Go to full version