Author Topic: Cygwin with CodeBlocks gdb error  (Read 21403 times)

Offline ollydbg

  • Developer
  • Lives here!
  • *****
  • Posts: 5913
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
Re: Cygwin with CodeBlocks gdb error
« Reply #15 on: December 10, 2013, 09:36:06 am »
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
Yes, the above link shows a work around, the author said that the debugging works OK with his change to Windows registry.

Quote
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)
Yes, you can leave these two settings to their default value.

Quote
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

OK, it looks like the GDB_driver::DetectCygwinMount functions does not works Ok in your case. Read the function source, it looks like there are some regestries in HKEY_CURRENT_USER? Can you try again?

I don't have more ways now, also I think the simplest way is to add an option (translate the cygdrive) in debugger setting dialog of C::B.


If some piece of memory should be reused, turn them to variables (or const variables).
If some piece of operations should be reused, turn them to functions.
If they happened together, then turn them to classes.

Offline ollydbg

  • Developer
  • Lives here!
  • *****
  • Posts: 5913
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
Re: Cygwin with CodeBlocks gdb error
« Reply #16 on: December 10, 2013, 09:55:47 am »
For the record, currently, the GDB debugger plugin use an old GDB interface called annotated interface, see http://www.sourceware.org/gdb/onlinedocs/annotate.html

Here, the full(absolute path) is always used:

Quote
13 Displaying Source

The following annotation is used instead of displaying source code:

     ^Z^Zsource filename:line:character:middle:addr

where filename is an absolute file name indicating which source file, line is the line number within that file (where 1 is the first line in the file), character is the character position within the file (where 0 is the first character in the file) (for most debug formats this will necessarily point to the beginning of a line), middle is ‘middle’ if addr is in the middle of the line, or ‘beg’ if addr is at the beginning of the line, and addr is the address in the target program associated with the source which is being displayed. addr is in the form ‘0x’ followed by one or more lowercase hex digits (note that this does not depend on the language).

So, I'm wondering there is an options to change this.... Can't find one.

The debugger plugin for GDB-MI mode is still under development, so I think we still need a solution currently.

If some piece of memory should be reused, turn them to variables (or const variables).
If some piece of operations should be reused, turn them to functions.
If they happened together, then turn them to classes.

Offline venom4u31

  • Multiple posting newcomer
  • *
  • Posts: 19
Re: Cygwin with CodeBlocks gdb error
« Reply #17 on: December 10, 2013, 10:02:08 am »
Wow, your suggestion absolutely worked.

For the record, to solve this problem I have created two registers under

HKEY_CURRENT_USER\\Software\\Cygnus Solutions\\Cygwin\\mounts v2

HKEY_LOCAL_MACHINE\\Software\\Cygnus Solutions\\Cygwin\\mounts v2

(the folders were manually created)

with the name cygdrive prefix
and the value /cygdrive

That's it. It worked.

However, the problem with the MinGW debugger has persisted. Apparently it's fixed if I just remove the Cygwin compiler and debugger settings from C::B, so it's not such a big problem.

Thank you so much for the support. You have been a huge help.

Offline ollydbg

  • Developer
  • Lives here!
  • *****
  • Posts: 5913
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
Re: Cygwin with CodeBlocks gdb error
« Reply #18 on: December 10, 2013, 10:08:12 am »
Wow, your suggestion absolutely worked.

For the record, to solve this problem I have created two registers under

HKEY_CURRENT_USER\\Software\\Cygnus Solutions\\Cygwin\\mounts v2

HKEY_LOCAL_MACHINE\\Software\\Cygnus Solutions\\Cygwin\\mounts v2

(the folders were manually created)

with the name cygdrive prefix
and the value /cygdrive

That's it. It worked.

Nice to hear!!

Quote
However, the problem with the MinGW debugger has persisted. Apparently it's fixed if I just remove the Cygwin compiler and debugger settings from C::B, so it's not such a big problem.
In-fact, I don't understand this problem, what's exactly the MinGW GDB problem??

I just see you have a problem when you try use GDB.exe(64bit, cygwin) to debug a program(build from GCC 64bit, cygwin), and now this problem is solved.

Basically, you should use a MinGW GDB to debug the application build from MinGW GCC compiler, never mixed the different type of GDB and GCC. (unless you are using cross building)

Quote
Thank you so much for the support. You have been a huge help.
You are welcome, hope you will enjoy the Free/Open Source C::B IDE.
If some piece of memory should be reused, turn them to variables (or const variables).
If some piece of operations should be reused, turn them to functions.
If they happened together, then turn them to classes.

Offline venom4u31

  • Multiple posting newcomer
  • *
  • Posts: 19
Re: Cygwin with CodeBlocks gdb error
« Reply #19 on: December 10, 2013, 10:18:16 am »
Quote
In-fact, I don't understand this problem, what's exactly the MinGW GDB problem??
Well, the problem is the one I mentioned in http://forums.codeblocks.org/index.php/topic,18663.msg127883.html#msg127883
The output is when I try to debug any program that uses the MinGW debugger.
The debugger seems to be stuck. I can't figure out why. This only happens if I have the Cygwin debug configuration in the Settings->Debugger window (asside the default one). After I delete it it works fine.

I have no idea of why this would happen.
« Last Edit: December 10, 2013, 10:20:07 am by venom4u31 »

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13413
    • Travis build status
Re: Cygwin with CodeBlocks gdb error
« Reply #20 on: December 10, 2013, 10:37:09 am »
venom4u31: Can you tell me what are the new default regkeys that C::B should look for, instead of the old ones that you've added manually?
(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 venom4u31

  • Multiple posting newcomer
  • *
  • Posts: 19
Re: Cygwin with CodeBlocks gdb error
« Reply #21 on: December 10, 2013, 10:50:19 am »
Well, the only registers I had when Cygwin was installed were the ones in

HKLM\SOFTWARE\Cygwin\

and

HKCU\Software\Cygwin

the HKCU Cygwin key had two keys called Program Options and Setup which were empty (they only contained the (Default) REG_SZ which was empty)

The HKLM Cygwin key had the following sub-keys:

Installations - which contained some registers regarding an .exe C program I ran with cmd which had cygwin1.dll copied there and also, the install path of Cygwin.
Program options - which was empty
setup - which had a registry called rootdir with the install path of Cygwin as its value.

Anything else related to cygwin was what I added (the mounts v2 key) or the PATH variable.

Therefore, I think that C::B should add the registry key automatically if it doesn't exist, since, at least by default the registry that has to be added has a known name and value (cygdrive prefix and /cygdrive).

You can add a setting that is enabled by default to create that registry.

Or, you can add the compiler presets for cygwin by default. Just ask the user for the install dir.
« Last Edit: December 10, 2013, 11:06:23 am by venom4u31 »