Author Topic: Debugger not working  (Read 396 times)

Offline jeqcho

  • Single posting newcomer
  • *
  • Posts: 3
Debugger not working
« on: January 17, 2020, 03:23:06 pm »
Hi,

I have been using CodeBlocks for more than a year but I still can't use the debugger. Since it's the new decade I might as well finally solve this for good.
I looked at the -g -s flags, checked the path for spaces and even made a new project to test out debugging, but the debugger is still not working. I tried all I could find on the web.

Here is my debugger logs:
Code: [Select]
Active debugger config: GDB/CDB debugger:Default
Building to ensure sources are up-to-date
Selecting target:
Debug
Adding source dir: C:\CodeBlocks_Projects\test-debug-2\
Adding source dir: C:\CodeBlocks_Projects\test-debug-2\
Adding file: C:\CodeBlocks_Projects\test-debug-2\bin\Debug\test-debug-2.exe
Changing directory to: C:/CodeBlocks_Projects/test-debug-2/.
Set variable: PATH=.;C:\cygwin64\bin;C:\cygwin64;C:\Program Files (x86)\Intel\iCLS Client;C:\Program Files\Intel\iCLS Client;C:\Program Files\Dell\DW WLAN Card;C:\Windows\System32;C:\Windows;C:\Windows\System32\wbem;C:\Windows\System32\WindowsPowerShell\v1.0;c:\Program Files\WIDCOMM\Bluetooth Software;c:\Program Files\WIDCOMM\Bluetooth Software\syswow64;C:\Program Files\Intel\Intel(R) Management Engine Components\DAL;C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\DAL;C:\Program Files\Intel\Intel(R) Management Engine Components\IPT;C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\IPT;C:\Windows\System32\OpenSSH;C:\go\bin;C:\Program Files\Git\cmd;C:\Program Files\nodejs;C:\Users\Chooi\AppData\Local\Microsoft\WindowsApps;C:\Users\Chooi\go\bin;C:\Users\Chooi\AppData\Roaming\npm;C:\Program Files\Sublime Text 3;C:\Users\Chooi\AppData\Local\Programs\Microsoft VS Code\bin;C:\Users\Chooi\AppData\Local\Programs\Python\Python37-32;C:\Users\Chooi\AppData\Local\Programs\Python\Python37-32\Scripts;C:\nuke

[debug]Command-line: C:\CodeBlocks\MinGW\bin\gdb32.exe -nx -fullname -quiet  -args C:/CodeBlocks_Projects/test-debug-2/bin/Debug/test-debug-2.exe
[debug]Working dir : C:\CodeBlocks_Projects\test-debug-2

Starting debugger: C:\CodeBlocks\MinGW\bin\gdb32.exe -nx -fullname -quiet  -args C:/CodeBlocks_Projects/test-debug-2/bin/Debug/test-debug-2.exe
done

[debug]> set prompt >>>>>>cb_gdb:

Setting breakpoints

[debug]"C:/CodeBlocks_Projects/test-debug-2/bin/Debug/test-debug-2.exe": not in executable format: File format not recognized
[debug](gdb) >>>>>>cb_gdb:
[debug]> show version
[debug]GNU gdb (GDB) 7.9.1
[debug]Copyright (C) 2015 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 "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) 7.9.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 C:/CodeBlocks_Projects/test-debug-2/
[debug]Source directories searched: C:/CodeBlocks_Projects/test-debug-2;$cdir;$cwd
[debug]>>>>>>cb_gdb:
[debug]> break "C:/CodeBlocks_Projects/test-debug-2/Untitled2.cpp:44"
[debug]No symbol table is loaded.  Use the "file" command.
[debug]Breakpoint 2 ("C:/CodeBlocks_Projects/test-debug-2/Untitled2.cpp:44") pending.
[debug]>>>>>>cb_gdb:
[debug]> run
[debug]No executable specified, use `target exec'.
[debug]Starting program: 
[debug]>>>>>>cb_gdb:

Starting the debuggee failed: No executable specified, use `target exec'.

[debug]> quit

Debugger finished with status 0

Help is very much appreciated. Thanks!

Offline stahta01

  • Lives here!
  • ****
  • Posts: 6753
    • My Best Post
Re: Debugger not working
« Reply #1 on: January 17, 2020, 06:01:19 pm »
Quote
-g -s flags

You made sure the -g flag was set, correct?
You made sure the -s flag was *not* set, correct?

Edit: What compiler was used to build your project? 64 bit or 32 bit?
What debugger are you trying to use to debug your project? 64 bit or 32 bit?

Edit2: What code::blocks version? Is it 32 bit or 64 bit?
Code::Blocks nightly are 64 bit; otherwise the windows builds are 32 bit.

Tim S.
« Last Edit: January 17, 2020, 06:15:51 pm by stahta01 »
C Programmer working to learn more about C++ and Git.
On Windows 7 64 bit and Windows 10 32 bit.
On Debian Stretch, compiling CB Trunk against wxWidgets 3.0.
--
When in doubt, read the CB WiKi FAQ. http://wiki.codeblocks.org

Offline stahta01

  • Lives here!
  • ****
  • Posts: 6753
    • My Best Post
Re: Debugger not working
« Reply #2 on: January 17, 2020, 07:41:26 pm »
To debug an exe created by CygWin 64 bit it is suggested to use MinGW gdb 64 bit.

The IDE needs to be 64 bit when you use an 64 bit debugger to have full functionally.

NOTE: The above is from reading the posts on this website; it is not been confirmed as true by me.

Tim S.


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

Offline jeqcho

  • Single posting newcomer
  • *
  • Posts: 3
Re: Debugger not working
« Reply #3 on: January 18, 2020, 06:27:15 am »
Thanks for replying. I rechecked that the -g flag is set and the -s flag is not set.
Compiler: Cygwin 64bit
Debugger: The default in CodeBlocks MinGW (which I see it as gdb32.exe)

CodeBlocks version is 32 bit.

Is the solution to download gdb 64?

Offline stahta01

  • Lives here!
  • ****
  • Posts: 6753
    • My Best Post
Re: Debugger not working
« Reply #4 on: January 18, 2020, 06:33:27 am »
Thanks for replying. I rechecked that the -g flag is set and the -s flag is not set.
Compiler: Cygwin 64bit
Debugger: The default in CodeBlocks MinGW (which I see it as gdb32.exe)

CodeBlocks version is 32 bit.

Is the solution to download gdb 64?

If you wish to debug an 64 bit app you must use an 64 bit debugger!

Edit: You can try the 64 bit gdb from Cygwin; but, I heard it does not work with Code::Blocks.
You might try the Cygwin mingw64 gdb and see if that works.

Edit2: You could build an 32 bit Cygwin app, instead.
You could build an mingw gcc app instead.

Tim S.
« Last Edit: January 18, 2020, 06:51:06 am by stahta01 »
C Programmer working to learn more about C++ and Git.
On Windows 7 64 bit and Windows 10 32 bit.
On Debian Stretch, compiling CB Trunk against wxWidgets 3.0.
--
When in doubt, read the CB WiKi FAQ. http://wiki.codeblocks.org

Offline jeqcho

  • Single posting newcomer
  • *
  • Posts: 3
Re: Debugger not working
« Reply #5 on: January 18, 2020, 07:40:52 am »
Thanks stahta01, I got the debugger working!

What I did is download minGW64 from
http://sourceforge.net/projects/mingw-w64/files/Toolchains%20targetting%20Win32/Personal%20Builds/mingw-builds/installer/mingw-w64-install.exe/download

which downloads the installer exe (watch out for a download page that look similar to this, but downloads a zip instead. That's where I wasted a lot of time)

So I downloaded it into the MinGW folder in the CodeBlocks folder, and then go to Settings > Debugger > GDB/CDB Debugger:Default and then set executable path as C:\CodeBlocks\MinGW\mingw64\bin\gdb.exe

Then the debugger works like a charm! However, it keeps asking me to change perspectives every time I debug. How can I solve this next, smaller problem?

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 12219
    • Travis build status
Re: Debugger not working
« Reply #6 on: January 18, 2020, 10:16:02 am »
There is a checkbox in the dialog. Select it and it will stop.
(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 oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 12219
    • Travis build status
Re: Debugger not working
« Reply #7 on: January 23, 2020, 09:03:22 am »
@jeqcho: If you're using cygwin and have problems with debugging you can watch when this issue https://sourceforge.net/p/codeblocks/tickets/909/ is resolved.
(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!]