I'm trying to debug my program using C::B and added to the compiler settings:
#define
-DNDEBEUG
I get the log:
[debug]> run
[debug]No executable specified, use `target exec'.
[debug]Starting program:
[debug]>>>>>>cb_gdb:
Starting the debugger failed: No executable specified, use `target exec'.
[debug]> quit
Debugger finished with status 0
anyone can help please?
Breakpoints may not work if the folder you've placed your application has spaces or other special characters. replacing space with Underscore _ may solve the issue.
Click here for addition details to debug application in Code::blocks
Related
I'm using gcc 4.9.2 & gdb 7.2 in Solaris 10 on sparc. The following was tested after compiling/linking with -g, -ggdb, and -ggdb3.
When I attach to a process:
~ gdb
/snip/
(gdb) attach pid_goes_here
... it is not loading symbolic information. I started with netbeans which starts gdb without specifying the executable name until after the attach occurs, but I've eliminated netbeans as the cause.
I can force it to load the symbol table under netbeans if I do one of the following:
Attach to the process, then in the debugger console do one of the following:
(gdb) detach
(gdb) file /path/to/file
(gdb) attach the_pid_goes_here
or
(gdb) file /path/to/file
(gdb) sharedlibrary .
I want to know if there's a more automatic way I can force this behavior. So far googling has turned up zilch.
I want to know if there's a more automatic way I can force this behavior.
It looks like a bug.
Are you sure that the main executable symbols are loaded? This bug says that attach pid without giving the binary doesn't work on Solaris at all.
In any case, it's supposed to work automatically, so your best bet to make it work better is probably to file a bug, and wait for it to be fixed (or send a patch to fix it yourself :-)
I am trying to debug C++ project in Codeblocks, but it's not stopping at breakpoints. I read the other answers and have tried the following things so far:
(Build Options > Compiler Settings) Produce debugging symbols is checked, strip all symbols is unchecked.
No spaces/non-ascii values in my file path.
Running the debug version.
Debugger in (Settings > Compiler > Toolchain Executables) set to GDB/CDB Debugger:Default
Executable path in (Settings > Debugger > GDB/CDB Debugger:Default) is C:\MinGW\bin\gdb.exe.
Its still not stopping at breakpoints and the debugger log is mentioning that no debugging symbols found
What am I missing here ?
While trying to fix this,I came across a lot of similar questions where CodeBlocks is ignoring breakpoints during debugging, so here's the fixes I have came across so far.
1.Clean and rebuild.
2.Ensure that (Build Options > Compiler Settings) Produce debugging symbols is checked, strip all symbols is unchecked. Please ensure this is done in global settings AND project settings.This fixed it for me.
3.Check so that there are no spaces/non-ASCII values in the project file path.
4.Check if you are running the debug version, not release.The executable from Release build will be \bin\Release , and the executable from a Debug build will be in \bin\Debug .
5. Check that Debugger in (Settings > Compiler > Toolchain Executables) is set to GDB/CDB Debugger:Default.
6.Check that executable path in (Settings > Debugger > GDB/CDB Debugger:Default) is valid gdb path like (C:\MinGW\bin\gdb.exe).
7.Update Codeblocks(last resort).
Please add in comments anything else that worked for you.
I had this problem too, however, it was because a long time ago I'd set
Settings > Debugger > GDB / CDB Debugger > Default > Debugger initialization commands
to
"set follow-fork-mode child"
so GDB was actually debugging another program entirely.
The only thing which worked for me:
Path with spaces
Breakpoints could not work if the path/folder you've placed your project contains spaces or other special characters. To be safe use English letters, digits and '_'.
Source: Debugging with Code::Blocks
Also you can check menu: Build->Select target->Debug
For me the thing which worked was, to delete the file main.o, which is contained in obj/Debug.
Hope it helps someone.
I'm using codeblock to test two projects. In one project everything is right, I can both run and debug the code. However in another project I can only run the code but could not debug. I set up breakpoint and begin debug, but it doesn't stop at the breakpoint. Could anyone tell me what might be wrong here?
I searched and find this thread Codeblocks "Error resetting breakpoint..." can't debug
and I've make sure there is no space in my project file names.
The following is from the Debugger
Starting debugger: C:\Program Files (x86)\CodeBlocks\MINGW\bin\gdb.exe -nx -fullname -quiet -args D:/SOFTWA~1/C__~1/LEARNC~1/SELECT~1/bin/Debug/SELECT~1.EXE
done
Registered new type: wxString
Registered new type: STL String
Registered new type: STL Vector
Setting breakpoints
(no debugging symbols found)
Debugger name and version: GNU gdb 6.8
Child process PID: 12992
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
Program exited normally.
Debugger finished with status 0
no debugging symbols found,it tells you that you should add -g option when you compile the project.
Is there anyway to debug a link error or any kind of error that may occur before the execution of the main() function using GDB?
Is there anyway to debug a link error
Presumably you are asking about runtime link error (e.g. `error: libfoo.so: no such file or directory'), and not about (static) link step of your build process.
The trick is to set a breakpoint on exit or (exit_group on Linux) system call with e.g. catch syscall exit. You will then be stopped inside ld.so at the point where it gives up running your binary.
or any kind of error that may occur before the execution of the main() function using GDB?
Any other kind of error, e.g. SIGSEGV can be debugged "normally" -- for signal you don't need to do anything at all -- GDB will just stop. For other errors, just set a breakpoint as usual.
On way to debug initialization code (even if you don't have symbols) goes like this:
gdb somebinary
GNU gdb (Ubuntu/Linaro 7.4-2012.04-0ubuntu2.1) 7.4-2012.04
etc.
info file
Symbols from "somebinary".
Local exec file:
`/somebinary', file type elf64-x86-64.
Entry point: 0x4045a4, etc.
break *0x4045a4
run
...Breakpoint 1, 0x00000000004045a4 in ?? ()
From here on you can proceed as usual.
After debugging for some hours, I am unable to debug my project I'm making anymore for the following reasons.
(It compiles smoothly without errors nor warnings from the compiler.)
Problem #1:
Error creating process d:\My
Documents\Downloads\CandyCrush\CandyCrush\bin\debug\CandyCrush.exe,
(error 5).
Solutions:
I followed the suggestions
here and here,
so I think it fixed one thing. ('spaces' in environment path)
Reboot the computer to ensure that the path is made available to all processes properly as suggested here. (Although its somewhat not really related to my problem)
Change the directory of my IDE along with the compiler.
Change the directory of the project I'm working on.
Delete and reinstall MinGW.
Delete and reinstall Code::Blocks.
And it changes the problem.
(take note that I always try to debug and run after each solutions)
Problem #2:
Starting debugger: D:\cb\CodeBlocks\MingGW\bin\gdb.exe -nx -fullname -quiet -args D:/CandyCrush/CandyCrush/bin/Debug/CandyCrush.exe failed
Solution:
Configure manually the path of debugger from the IDE (it says it can't find the file but it is there(?)) so it does fixed it.
Aaaand the first problem return again, so I think I really mess up things here.
What could be the fix?
PS. I'm using GNU gdb (GDB) 7.5
Edit
Full (Debug) log
Debugger name and version: GNU gdb (GDB) 7.5
[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 D:\cb\CodeBlocks\share\codeblocks/scripts/stl-views-1.0.3.gdb
[debug]>>>>>>cb_gdb: [debug]> directory D:/CandyCrush/CandyCrush/
[debug]Source directories searched:
D:/CandyCrush/CandyCrush;$cdir;$cwd [debug]>>>>>>cb_gdb: [debug]> run
[debug]Error creating process
D:\CandyCrush\CandyCrush\bin\Debug\CandyCrush.exe, (error 5).
[debug]Starting program:
D:\CandyCrush\CandyCrush\bin\Debug\CandyCrush.exe
[debug]>>>>>>cb_gdb:
Error creating process
D:\CandyCrush\CandyCrush\bin\Debug\CandyCrush.exe, (error 5).
[debug]> quit
Debugger finished with status 0
This isn't good at all. After resting the IDE(compiler, debugger, editor) for some hours, it magically works again. I didn't close any application or reboot the computer.
Also It's because of Game Guard or Anti Virus