Author Topic: GDB problem in code::blocks 20.03 on WIN 10-64b  (Read 7722 times)

Offline igartner

  • Single posting newcomer
  • *
  • Posts: 6
GDB problem in code::blocks 20.03 on WIN 10-64b
« on: June 06, 2020, 09:46:31 am »
I have a simple program, compiled with -g for debugging, put a break point and try to debug.
The program stops at the indicated location for one sec and then disappears Gdb returning 1: here is the debug log
==
Active debugger config: GDB/CDB debugger:Default
Building to ensure sources are up-to-date
Selecting target:
Debug
Adding source dir: D:\MyDocs\Work\C-simplex\
Adding source dir: D:\MyDocs\Work\C-simplex\
Adding file: D:\MyDocs\Work\C-simplex\bin\Debug\C-simplex.exe
Changing directory to: D:/MyDocs/Work/C-simplex/.
Set variable: PATH=.;D:\Program Files (x86)\CodeBlocks-V2003\MinGW\bin;D:\Program Files (x86)\CodeBlocks-V2003\MinGW;C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\iCLS;C:\Program Files\Intel\Intel(R) Management Engine Components\iCLS;C:\Windows\System32;C:\Windows;C:\Windows\System32\wbem;C:\Windows\System32\WindowsPowerShell\v1.0;C:\Windows\System32\OpenSSH;C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\DAL;C:\Program Files\Intel\Intel(R) Management Engine Components\DAL;C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common;C:\Program Files (x86)\Calibre2;D:\Program Files (x86)\Lua\5.1;D:\Program Files (x86)\Lua\5.1\clibs;C:\Program Files\Intel\WiFi\bin;C:\Program Files\Common Files\Intel\WirelessCommon;D:\Program Files\Git\cmd;C:\Users\IOAN\AppData\Local\Microsoft\WindowsApps

[debug]Command-line: D:\Program Files (x86)\CodeBlocks-V2003\MINGW\bin\gdb.exe -nx -fullname -quiet D:\MyDocs\Work\C-simplex\bin\Debug\C-simplex.exe -args D:/MyDocs/Work/C-simplex/bin/Debug/C-simplex.exe
[debug]Working dir : D:\MyDocs\Work\C-simplex

Starting debugger: D:\Program Files (x86)\CodeBlocks-V2003\MINGW\bin\gdb.exe -nx -fullname -quiet D:\MyDocs\Work\C-simplex\bin\Debug\C-simplex.exe -args D:/MyDocs/Work/C-simplex/bin/Debug/C-simplex.exe
done

[debug]Reading symbols from D:/MyDocs/Work/C-simplex/bin/Debug/C-simplex.exe...done.
[debug](gdb)
[debug]> set prompt >>>>>>cb_gdb:

Setting breakpoints

[debug]>>>>>>cb_gdb:
[debug]> show version
[debug]GNU gdb (GDB) 8.1
[debug]Copyright (C) 2018 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-w64-mingw32".
[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) 8.1

[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 200
[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]> directory D:/MyDocs/Work/C-simplex/
[debug]Source directories searched: D:/MyDocs/Work/C-simplex;$cdir;$cwd
[debug]>>>>>>cb_gdb:
[debug]> set args axxx byyy czzz dwww
[debug]>>>>>>cb_gdb:
[debug]> break "D:/MyDocs/Work/C-simplex/main.c:8"
[debug]Breakpoint 2 at 0x401577: file D:\MyDocs\Work\C-simplex\main.c, line 8.
[debug]>>>>>>cb_gdb:
[debug]> run
[debug]Starting program: D:\MyDocs\Work\C-simplex\bin\Debug\C-simplex.exe axxx byyy czzz dwww

Child process PID: 2316

[debug][New Thread 2316.0x37c8]
[debug]Breakpoint 2, main (argc=5, argv=0x8914f0) at D:\MyDocs\Work\C-simplex\main.c:8
[debug]D:\MyDocs\Work\C-simplex\main.c:8:121:beg:0x401577
[debug]>>>>>>cb_gdb:

At D:\MyDocs\Work\C-simplex\main.c:8

[debug]> info registers
[debug]rax            0x0   0
[debug]rbx            0x28   40
[debug]rcx            0xffffffff   4294967295
[debug]rdx            0x7ff97955fa30   140709459262000
[debug]rsi            0x5   5
[debug]rdi            0x891630   8984112
[debug]rbp            0x61fe20   0x61fe20
[debug]rsp            0x61fdf0   0x61fdf0
[debug]r8             0x7ff979565940   140709459286336
[debug]r9             0x61e260   6414944
[debug]r10            0x0   0
[debug]r11            0x246   582
[debug]r12            0x30   48
[debug]r13            0x28   40
[debug]r14            0x0   0
[debug]r15            0x0   0
[debug]rip            0x401577   0x401577 <main+39>
[debug]eflags         0x202   [ IF ]
[debug]cs             0x33   51
[debug]ss             0x2b   43
[debug]ds             0x2b   43
[debug]es             0x2b   43
[debug]fs             0x53   83
[debug]gs             0x2b   43

Debugger finished with status 1

=============


Please help, thanks igartner
« Last Edit: June 06, 2020, 09:49:42 am by igartner »

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13413
    • Travis build status
Re: GDB problem in code::blocks 20.03 on WIN 10-64b
« Reply #1 on: June 06, 2020, 06:52:27 pm »
The gdb we're shipping as part of the installer and the mingw-w64 version we've selected turned out to be problematic. You have to find a version which works better. :(
(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 igartner

  • Single posting newcomer
  • *
  • Posts: 6
Re: GDB problem in code::blocks 20.03 on WIN 10-64b
« Reply #2 on: June 06, 2020, 09:51:23 pm »
Excuse m, but if I understand you well, your advice is to install an older version, correct?

Offline stahta01

  • Lives here!
  • ****
  • Posts: 7588
    • My Best Post
Re: GDB problem in code::blocks 20.03 on WIN 10-64b
« Reply #3 on: June 06, 2020, 10:13:07 pm »
Excuse m, but if I understand you well, your advice is to install an older version, correct?

I think his advise is to install a different Compiler/Debugger; but, that is just a guess on my part.

Tim S.

C Programmer working to learn more about C++ and Git.
On Windows 7 64 bit and Windows 10 64 bit.
--
When in doubt, read the CB WiKi FAQ. http://wiki.codeblocks.org

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13413
    • Travis build status
Re: GDB problem in code::blocks 20.03 on WIN 10-64b
« Reply #4 on: June 06, 2020, 11:32:53 pm »
Different version of the debugger which is compatible with your compiler (32 compiler should have 32 bit debugger, and vice versa for 64 bits). I'm not a windows user, so I cannot give advice about which versions work and which doesn't.
(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 igartner

  • Single posting newcomer
  • *
  • Posts: 6
Re: GDB problem in code::blocks 20.03 on WIN 10-64b
« Reply #5 on: June 07, 2020, 07:00:06 am »
Hi, thanks for the support and care: I appreciate!!
I tried the same things with CB 1712: break point works, the program flow stops, but other serious pb come up very soon (e.g. stepping through the code, displaying values of data as pg advances). Simple debug operations seem very problematic: program hangs or goes away without any msg.
Debugger (gdb) seems to me unusable even in this older version, so I am back to "debug by printf".
Any other suggestion? Thanks for your cooperation....

 

Offline gd_on

  • Lives here!
  • ****
  • Posts: 797
Re: GDB problem in code::blocks 20.03 on WIN 10-64b
« Reply #6 on: June 07, 2020, 10:47:35 am »
Have a look to the user manual : http://www.codeblocks.org/user-manual
There is a chapter containing different addresses for different compiler's versions. May be you'll find something which works for you...
Myself, I use frequently gdb which works as expected, but I'm in 64 bits now. But, sometimes ago, it worked well in 32 bits too.
I know also that some gdb versions don't like spaces in path. This is not the case for your code, but gdb itself is in your "program files" ! May be try to move your MinGW in a folder without spaces in the path. That's worth a try !

gd-on
« Last Edit: June 07, 2020, 04:19:39 pm by gd_on »
Windows 11 64 bits (23H2), svn C::B (last version or almost!), wxWidgets 3.2.4 (tests with 3.3), Msys2 Compilers 13.2.0, 64 bits (seh, posix : gcc, g++ and gfortran in C:\msys64\mingw64) or 32 bits (dwarf2, posix  in C:\msys64\mingw32).

Offline igartner

  • Single posting newcomer
  • *
  • Posts: 6
Re: GDB problem in code::blocks 20.03 on WIN 10-64b
« Reply #7 on: June 08, 2020, 02:31:12 pm »
Thanks for your concern and suggestions. Indeed spaces in file names is not liked by Unix/Linux originated pg like GDB. I  tried to install CB such that GDB will have a "clean of space" path. Here is what I got:
==
[debug]Command-line: D:\PFX86\CodeBlocks\MINGW\bin\gdb.exe -nx -fullname -quiet D:\MyDocs\Work\C-simplex\bin\Debug\C-simplex.exe -args D:/MyDocs/Work/C-simplex/bin/Debug/C-simplex.exe
[debug]Working dir : D:\MyDocs\Work\C-simplex

Starting debugger: D:\PFX86\CodeBlocks\MINGW\bin\gdb.exe -nx -fullname -quiet D:\MyDocs\Work\C-simplex\bin\Debug\C-simplex.exe -args D:/MyDocs/Work/C-simplex/bin/Debug/C-simplex.exe
failed
==
The compilation log was:

-------------- Build: Debug in C-simplex (compiler: GNU GCC Compiler)---------------

mingw32-gcc.exe -Wall -g -g  -c D:\MyDocs\Work\C-simplex\main.c -o obj\Debug\main.o
mingw32-g++.exe  -o bin\Debug\C-simplex.exe obj\Debug\main.o   
Output file is bin\Debug\C-simplex.exe with size 28.65 KB
Process terminated with status 0 (0 minute(s), 0 second(s))
0 error(s), 0 warning(s) (0 minute(s), 0 second(s))
==
Apart of the double flag -g things seem absolutely ok; I love debugging close to the assembly code, but few people seem to care since even for this CB 17.12 of 2019 GDB quality is unacceptably poor (break points do not work, stepping through code neither etc...).
Since CB have been working and delivered with such low GDB quality, I guess people are back to "printf debugging" and ignore GDB: too bad, back to the future !

Offline igartner

  • Single posting newcomer
  • *
  • Posts: 6
Re: GDB problem in code::blocks 20.03 on WIN 10-64b
« Reply #8 on: June 08, 2020, 04:19:46 pm »
In fact the pb looks as beeing 32-64 bit architecture related.
Naive me: I imagined that after 50y of SW development & given several HW CPU architectures, this feature would become either somewhat "transparent" or visibly documented at least in an error msg coming from GDB in the last instance. But no way...
In ver 19.12 (advertised as 64b) after investigation I noticed that GDB delivered was only the 32 bit one (gdb32.exe) and thus if one sets the compiler switch accordingly one might envisage debug +/- properly.
In new 20.03 version, advertised also as 64b, GDB type is unclear (gdb.exe without any specifics) is 32 or 64 bits, because the name does not indicate it at all: so good luck or "back to printf debugging".

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13413
    • Travis build status
Re: GDB problem in code::blocks 20.03 on WIN 10-64b
« Reply #9 on: June 08, 2020, 08:05:37 pm »
Right clicking on the executable should tell you what it is. If you start it in the task manager you'll see it also.
(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!]