Author Topic: Debugger doesn't work  (Read 861 times)

Offline pocoloco

  • Multiple posting newcomer
  • *
  • Posts: 11
Debugger doesn't work
« on: May 11, 2022, 10:12:00 pm »
When I try to run the debugger I get this error:
Code
Starting the debuggee failed: No executable specified, use `target exec'

I have been struggling with this for hours now.

I have removed any spaces from my project name.
I have tried downloading a different mingw version from here: https://sourceforge.net/projects/mingw-w64/files/mingw-w64/

I have the codeblocks-20.03mingw-setup.exe version installed.
I have Windows 10 64bit.

This is the log I get:

Code
Active debugger config: GDB/CDB debugger:Default
Building to ensure sources are up-to-date
Selecting target:
Debug
Adding source dir: C:\as\asdf\
Adding source dir: C:\as\asdf\
Adding file: C:\as\asdf\bin\Debug\asdf.exe
Changing directory to: C:/as/asdf/.
Set variable: PATH=.;C:\Program Files\CodeBlocks\MinGW\bin;C:\Program Files\CodeBlocks\MinGW;C:\Program Files (x86)\Common Files\Oracle\Java\javapath;C:\Python27;C:\Python27\Scripts;C:\Program Files\Python39\Scripts;C:\Program Files\Python39;C:\Program Files (x86)\Intel\iCLS Client;C:\Program Files\Intel\iCLS Client;C:\Windows\System32;C:\Windows;C:\Windows\System32\wbem;C:\Windows\System32\WindowsPowerShell\v1.0;C:\Windows\System32\OpenSSH;C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common;C:\Program Files\Git\cmd;C:\Program Files (x86)\GitExtensions;C:\Program Files (x86)\Microsoft VS Code\bin;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)\Intel\Intel(R) Management Engine Components\IPT;C:\Program Files\Intel\Intel(R) Management Engine Components\IPT;C:\Program Files (x86)\PuTTY;C:\Program Files (x86)\nodejs;C:\Program Files (x86)\Bitvise SSH Client;C:\Users\Pouria\AppData\Local\Microsoft\WindowsApps;C:\Program Files (x86)\Nmap;D:\Program Files\_bin\UnixUtils;D:\Program Files\_bin;D:\Program Files\_bin\aliases;C:\Users\Pouria\AppData\Local\Programs\Fiddler;C:\Users\Pouria\AppData\Roaming\npm;D:\Program Files\hashcat-6.1.1;D:\Program Files\ffmpeg-4.3.1-win32-shared\bin;D:\Program Files\ImageMagick-7.0.10;D:\wamp\bin\php\php7.2.4;D:\Personal Folder\Pouria\My Documents\_0NirLauncher\SysInternals;D:\Program Files\Arduino-cli;C:\Program Files (x86)\GnuWin32\bin
Starting debugger: C:\mingw64\bin\gdb.exe -nx -fullname -quiet  -args C:/as/asdf/bin/Debug/asdf.exe
done
Setting breakpoints
Debugger name and version: GNU gdb (GDB) 8.1
Starting the debuggee failed: No executable specified, use `target exec'.
Debugger finished with status 0

« Last Edit: May 11, 2022, 10:30:19 pm by pocoloco »

Offline BlueHazzard

  • Developer
  • Lives here!
  • *****
  • Posts: 3168
Re: Debugger doesn't work
« Reply #1 on: May 11, 2022, 10:32:13 pm »
Can you share your project file?
Is C:\as\asdf\bin\Debug\asdf.exe present?
Have you changed something in the project settings?

Offline pocoloco

  • Multiple posting newcomer
  • *
  • Posts: 11
Re: Debugger doesn't work
« Reply #2 on: May 12, 2022, 06:17:29 am »
Can you share your project file?
Is C:\as\asdf\bin\Debug\asdf.exe present?
Have you changed something in the project settings?

Just to be safe I created a new project with just the sample "Hello world" code.

Here is the project file
Code
<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<CodeBlocks_project_file>
<FileVersion major="1" minor="6" />
<Project>
<Option title="sample" />
<Option pch_mode="2" />
<Option compiler="gcc" />
<Build>
<Target title="Debug">
<Option output="bin/Debug/sample" prefix_auto="1" extension_auto="1" />
<Option object_output="obj/Debug/" />
<Option type="1" />
<Option compiler="gcc" />
<Compiler>
<Add option="-g" />
</Compiler>
</Target>
<Target title="Release">
<Option output="bin/Release/sample" prefix_auto="1" extension_auto="1" />
<Option object_output="obj/Release/" />
<Option type="1" />
<Option compiler="gcc" />
<Compiler>
<Add option="-O2" />
</Compiler>
<Linker>
<Add option="-s" />
</Linker>
</Target>
</Build>
<Compiler>
<Add option="-Wall" />
<Add option="-fexceptions" />
</Compiler>
<Unit filename="main.cpp" />
<Extensions>
<lib_finder disable_auto="1" />
</Extensions>
</Project>
</CodeBlocks_project_file>

- Yes the file "C:\sample\bin\Debug\sample.exe" exists

- I have not changed anything in the project settings. It's the default new project.

The log when I click debug:
Code
Active debugger config: GDB/CDB debugger:Default
Building to ensure sources are up-to-date
Selecting target:
Debug
Adding source dir: C:\sample\
Adding source dir: C:\sample\
Adding file: C:\sample\bin\Debug\sample.exe
Changing directory to: C:/sample/.
Set variable: PATH=.;C:\Program Files\CodeBlocks\MinGW\bin;C:\Program Files\CodeBlocks\MinGW;C:\Program Files (x86)\Common Files\Oracle\Java\javapath;C:\Python27;C:\Python27\Scripts;C:\Program Files\Python39\Scripts;C:\Program Files\Python39;C:\Program Files (x86)\Intel\iCLS Client;C:\Program Files\Intel\iCLS Client;C:\Windows\System32;C:\Windows;C:\Windows\System32\wbem;C:\Windows\System32\WindowsPowerShell\v1.0;C:\Windows\System32\OpenSSH;C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common;C:\Program Files\Git\cmd;C:\Program Files (x86)\GitExtensions;C:\Program Files (x86)\Microsoft VS Code\bin;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)\Intel\Intel(R) Management Engine Components\IPT;C:\Program Files\Intel\Intel(R) Management Engine Components\IPT;C:\Program Files (x86)\PuTTY;C:\Program Files (x86)\nodejs;C:\Program Files (x86)\Bitvise SSH Client;C:\Users\Pouria\AppData\Local\Microsoft\WindowsApps;C:\Program Files (x86)\Nmap;D:\Program Files\_bin\UnixUtils;D:\Program Files\_bin;D:\Program Files\_bin\aliases;C:\Users\Pouria\AppData\Local\Programs\Fiddler;C:\Users\Pouria\AppData\Roaming\npm;D:\Program Files\hashcat-6.1.1;D:\Program Files\ffmpeg-4.3.1-win32-shared\bin;D:\Program Files\ImageMagick-7.0.10;D:\wamp\bin\php\php7.2.4;D:\Personal Folder\Pouria\My Documents\_0NirLauncher\SysInternals;D:\Program Files\Arduino-cli;C:\Program Files (x86)\GnuWin32\bin
Starting debugger: C:\Program Files\CodeBlocks\MinGW\bin\gdb.exe -nx -fullname -quiet  -args C:/sample/bin/Debug/sample.exe
done
Setting breakpoints
Debugger name and version: GNU gdb (GDB) 8.1
Starting the debuggee failed: No executable specified, use `target exec'.
Debugger finished with status 0
« Last Edit: May 12, 2022, 06:20:03 am by pocoloco »

Offline pocoloco

  • Multiple posting newcomer
  • *
  • Posts: 11
Re: Debugger doesn't work
« Reply #3 on: May 12, 2022, 06:55:45 am »
I just installed the 32-bit version and I get the same error.

Offline BlueHazzard

  • Developer
  • Lives here!
  • *****
  • Posts: 3168
Re: Debugger doesn't work
« Reply #4 on: May 12, 2022, 09:56:55 am »
Can you enable full debug logging in "Settings->Debugger->Common->full debug log" and post the debug log again here?

ps. thank you for posting the log from the beginning :)

[edit:] Also, have you seen this: https://stackoverflow.com/questions/67045842/how-do-you-debug-using-codeblocks-20-03-the-mingw-version ?
« Last Edit: May 12, 2022, 09:59:00 am by BlueHazzard »

Offline pocoloco

  • Multiple posting newcomer
  • *
  • Posts: 11
Re: Debugger doesn't work
« Reply #5 on: May 12, 2022, 10:02:13 am »
Can you enable full debug logging in "Settings->Debugger->Common->full debug log" and post the debug log again here?

ps. thank you for posting the log from the beginning :)

Code
Active debugger config: GDB/CDB debugger:Default
Building to ensure sources are up-to-date
Selecting target:
Debug
Adding source dir: C:\sample\
Adding source dir: C:\sample\
Adding file: C:\sample\bin\Debug\sample.exe
Changing directory to: C:/sample/.
Set variable: PATH=.;C:\CodeBlocks32\CodeBlocks\MinGW\bin;C:\CodeBlocks32\CodeBlocks\MinGW;C:\Program Files (x86)\Common Files\Oracle\Java\javapath;C:\Python27;C:\Python27\Scripts;C:\Program Files\Python39\Scripts;C:\Program Files\Python39;C:\Program Files (x86)\Intel\iCLS Client;C:\Program Files\Intel\iCLS Client;C:\Windows\System32;C:\Windows;C:\Windows\System32\wbem;C:\Windows\System32\WindowsPowerShell\v1.0;C:\Windows\System32\OpenSSH;C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common;C:\Program Files\Git\cmd;C:\Program Files (x86)\GitExtensions;C:\Program Files (x86)\Microsoft VS Code\bin;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)\Intel\Intel(R) Management Engine Components\IPT;C:\Program Files\Intel\Intel(R) Management Engine Components\IPT;C:\Program Files (x86)\PuTTY;C:\Program Files (x86)\nodejs;C:\Program Files (x86)\Bitvise SSH Client;C:\Users\Pouria\AppData\Local\Microsoft\WindowsApps;C:\Program Files (x86)\Nmap;D:\Program Files\_bin\UnixUtils;D:\Program Files\_bin;D:\Program Files\_bin\aliases;C:\Users\Pouria\AppData\Local\Programs\Fiddler;C:\Users\Pouria\AppData\Roaming\npm;D:\Program Files\hashcat-6.1.1;D:\Program Files\ffmpeg-4.3.1-win32-shared\bin;D:\Program Files\ImageMagick-7.0.10;D:\wamp\bin\php\php7.2.4;D:\Personal Folder\Pouria\My Documents\_0NirLauncher\SysInternals;D:\Program Files\Arduino-cli;C:\Program Files (x86)\GnuWin32\bin

[debug]Command-line: C:\Program Files\CodeBlocks\MinGW\bin\gdb.exe -nx -fullname -quiet  -args C:/sample/bin/Debug/sample.exe
[debug]Working dir : C:\sample

Starting debugger: C:\Program Files\CodeBlocks\MinGW\bin\gdb.exe -nx -fullname -quiet  -args C:/sample/bin/Debug/sample.exe
done

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

Setting breakpoints

[debug]Reading symbols from C:/sample/bin/Debug/sample.exe...done.
[debug](gdb) >>>>>>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]> target exec
[debug]No executable file now.
[debug]>>>>>>cb_gdb:
[debug]> directory C:/sample/
[debug]Source directories searched: C:/sample;$cdir;$cwd
[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

Quote
Also, have you seen this: https://stackoverflow.com/questions/67045842/how-do-you-debug-using-codeblocks-20-03-the-mingw-version ?
I have but I did not have a prior mingw installation.
But just to be sure I downloaded mingw64 and used the gdb.exe that came with it, but it also gave me the same error.
I even found a gdb.exe with version 10 somehow, but that also gave me the same error.

Offline BlueHazzard

  • Developer
  • Lives here!
  • *****
  • Posts: 3168
Re: Debugger doesn't work
« Reply #6 on: May 12, 2022, 11:17:44 am »
From all what i have read this seems really to be some miss match between 32bit and 64bit or different compiler debugger combinations.
The execution command line for the debugger is right, so we have to check every setting of paths...

Close all running codeblocks
1) we fix the paths:
1.1) Open the environment variables editor:
1.2) Open a cmd line by hitting start menu and typing "cmd"
1.3) in the black window paste "rundll32 sysdm.cpl,EditEnvironmentVariables" and hit enter
1.4) in the opening dialog Search in the top and bottom field for the "PATH" variable and edit it
1.5) remove all paths that are related with codeblocks or mingw (for example "C:\CodeBlocks32\CodeBlocks\MinGW\bin" and "C:\CodeBlocks32\CodeBlocks\MinGW" )
1.6) Save and close dialog
2) Fix Codeblocks
2.1) Open codeblocks
2.2) Settings->Compiler->Global compiler settings->Selected compiler:"GNU GCC compiler"->Toolchain executables (from the tabs)->Check compiler installation directory
2.3) Fix debugger: Settings->Debugger->Default->Executable path, make sure it is the same as in 2.2
3) Recompile your application
3.1) Build->Rebuild
4) Start the debugger
4.1) Retry with Debug->Start/continue

Offline pocoloco

  • Multiple posting newcomer
  • *
  • Posts: 11
Re: Debugger doesn't work
« Reply #7 on: May 12, 2022, 11:55:39 am »
From all what i have read this seems really to be some miss match between 32bit and 64bit or different compiler debugger combinations.
The execution command line for the debugger is right, so we have to check every setting of paths...

Close all running codeblocks
1) we fix the paths:
1.1) Open the environment variables editor:
1.2) Open a cmd line by hitting start menu and typing "cmd"
1.3) in the black window paste "rundll32 sysdm.cpl,EditEnvironmentVariables" and hit enter
1.4) in the opening dialog Search in the top and bottom field for the "PATH" variable and edit it
1.5) remove all paths that are related with codeblocks or mingw (for example "C:\CodeBlocks32\CodeBlocks\MinGW\bin" and "C:\CodeBlocks32\CodeBlocks\MinGW" )
1.6) Save and close dialog
2) Fix Codeblocks
2.1) Open codeblocks
2.2) Settings->Compiler->Global compiler settings->Selected compiler:"GNU GCC compiler"->Toolchain executables (from the tabs)->Check compiler installation directory
2.3) Fix debugger: Settings->Debugger->Default->Executable path, make sure it is the same as in 2.2
3) Recompile your application
3.1) Build->Rebuild
4) Start the debugger
4.1) Retry with Debug->Start/continue

Thank you for your answer.
I did all of that but unfortunately I am getting the same error as before.

Offline AndrewCot

  • Regular
  • ***
  • Posts: 474
Re: Debugger doesn't work
« Reply #8 on: May 12, 2022, 12:21:40 pm »
GDB 8.1 is known to have issues. Please update to a later version.

Offline pocoloco

  • Multiple posting newcomer
  • *
  • Posts: 11
Re: Debugger doesn't work
« Reply #9 on: May 12, 2022, 12:41:26 pm »
GDB 8.1 is known to have issues. Please update to a later version.

It appears to be the latest version: https://sourceforge.net/projects/mingw-w64/files/mingw-w64/
Where do I get a newer one?

(I did try with a v10.1 one I found here but that gave me the same error as well).
« Last Edit: May 12, 2022, 12:43:36 pm by pocoloco »

Offline AndrewCot

  • Regular
  • ***
  • Posts: 474
Re: Debugger doesn't work
« Reply #10 on: May 13, 2022, 12:20:16 am »
The forums have a search function that allow you to find previous posts that may help.

If you search for "GDB upgrade" then the relevant post is in the first 10 results.

Offline pocoloco

  • Multiple posting newcomer
  • *
  • Posts: 11
Re: Debugger doesn't work
« Reply #11 on: May 13, 2022, 08:10:21 am »
The forums have a search function that allow you to find previous posts that may help.

If you search for "GDB upgrade" then the relevant post is in the first 10 results.

Tried version 12 and 11 from here and I still get the same error.

If anyone knows the answer to this please reply, I have set the notification on the thread.

But I myself have completely given up. I spent hours Wednesday getting this to work unsuccessfully, and then yesterday another 4-5 hours trying to install Visual Studio on a virtual machine.
The thing is I hate Visual Studio with all my heart due to dozens of gigabytes of unnecessary bloatware it installs without asking you and the fact that it has an online installer. Tried a few and finally managed to install the 2012 version with an offline installer.

I like CodeBlocks because it is very lightweight and I can install it on my real machine. I would never install Visual Studio and all its junk on my real machine.

But evidently a simple lightweight IDE you can code simple C++ programs in on Windows is too much to ask nowadays.

Offline AndrewCot

  • Regular
  • ***
  • Posts: 474
Re: Debugger doesn't work
« Reply #12 on: May 13, 2022, 09:14:19 am »
So now you have a "working" GDB as in should.
Can you do the following:
1) Zip up your project file and the main.cpp and attach it as a zip file.
2) Can you also zip up the following file and attach the zip:     C:\Users\<your user name>\AppData\Roaming\CodeBlocks\default.conf
3) Can you also include the output from the following Codeblocks dialog as text:      a) Select the Help->About menu      b) Click on the information tab
      c) Select the text in the information tab and copy it into the response post.
BTW Nothing to do with C::B, but your path indicates you have a number of different things installed that you may want to check out for upgrades and also check the path to see what gets found before other apps in the path as you have multiple Unix utils in different directories. I have been burnt in the past with the path having old unix utilities before the newer ones....


Offline AndrewCot

  • Regular
  • ***
  • Posts: 474
Re: Debugger doesn't work
« Reply #13 on: May 13, 2022, 09:30:05 am »
Can you also include the Codeblocks build log.
I have done some testing with the codeblocks-20.03mingw-nosetup.zip and tried with spaces in the C::B directory and GDB 8.1 and my hello world works.

Offline pocoloco

  • Multiple posting newcomer
  • *
  • Posts: 11
Re: Debugger doesn't work
« Reply #14 on: May 13, 2022, 07:50:58 pm »
So now you have a "working" GDB as in should.
Can you do the following:
1) Zip up your project file and the main.cpp and attach it as a zip file.
2) Can you also zip up the following file and attach the zip:     C:\Users\<your user name>\AppData\Roaming\CodeBlocks\default.conf
3) Can you also include the output from the following Codeblocks dialog as text:      a) Select the Help->About menu      b) Click on the information tab
      c) Select the text in the information tab and copy it into the response post.
BTW Nothing to do with C::B, but your path indicates you have a number of different things installed that you may want to check out for upgrades and also check the path to see what gets found before other apps in the path as you have multiple Unix utils in different directories. I have been burnt in the past with the path having old unix utilities before the newer ones....

I've attached the files.
And here's the info:
Code
Name             : Code::Blocks
Version          : 20.03-r11983
SDK Version      : 2.0.0
Scintilla Version: 3.7.5
Author           : The Code::Blocks Team
E-mail           : info@codeblocks.org
Website          : http://www.codeblocks.org

wxWidgets Library (wxMSW port)
Version 3.1.3 (Unicode: wchar_t, debug level: 1),
compiled at Nov  1 2019 18:53:26

Runtime version of toolkit used is 10.0.

I think the problem lies with the gdb itself tho.
I'm not familiar with how it works, but when I try to invoke it directly using CMD and outside of C::B I still get the same message.
Namely, when I run this:
Code
"C:\Program Files\CodeBlocks\MinGW\bin\gdb.exe" -nx -fullname -quiet  -args C:/sample/bin/Debug/sample.exe

gdb starts and says:
Code
Reading symbols from C:/sample/bin/Debug/sample.exe...
(gdb)

And then when I enter "target exec" I get this response:
Code
(gdb) target exec
No executable file now.
(gdb)

I'm not sure but I think it fails to "import" the exe file or whatever.
« Last Edit: May 13, 2022, 07:53:21 pm by pocoloco »