Code::Blocks debbuger failure - c++

Before explaining my problem:
My OS is Ubuntu 12.04 LTS 32bits with 4GB RAM.
My IDE is Code::Blocks 12.11(I've had the same problem with 10.05)
I'm using the GNU GCC Compiler with the -g flag and the -std=c++0x flag.
When trying to debug this program:
using namespace std;
#include<iostream>
int main(){
int n=10;
for(int i=1;i<=n;i++){
int ax=i;
while(ax) ax--;
cout<<i;
}
return 0;
}
I can't get anything to happen,if I try the "Run to cursor" command or if I try to use breakpoints. They just get skipped and my program finishes running.
This is what I get in the debugger log:
Building to ensure sources are up-to-date
Selecting target:
Release
Adding source dir: /home/classius/CodeBlocks/Dr/
Adding source dir: /home/classius/CodeBlocks/Dr/
Adding file: /home/classius/CodeBlocks/Dr/bin/Release/Dr
Changing directory to: /home/classius/CodeBlocks/Dr/.
Set variable: LD_LIBRARY_PATH=.:
Starting debugger: /usr/bin/gdb -nx -fullname -quiet -args /home/classius/CodeBlocks/Dr/bin/Release/Dr
done
Registered new type: wxString
Registered new type: STL String
Registered new type: STL Vector
Setting breakpoints
Reading symbols from /home/classius/CodeBlocks/Dr/bin/Release/Dr...(no debugging symbols found)...done.
Debugger name and version: GNU gdb (Ubuntu/Linaro 7.4-2012.04-0ubuntu2.1) 7.4-2012.04
No symbol table is loaded. Use the "file" command.
Temporary breakpoint 2 ("/home/classius/CodeBlocks/Dr/main.cpp:10) pending.
[Inferior 1 (process 13381) exited normally]
Debugger finished with status 0
If anyone wants to suggest a solution that implies using the terminal, please do it in the most noob-orieted terms you can find!
PS: How to add breaklines on stack-overflow when asking a question?(Solved-Thanks!)

Reading symbols from /home/classius/CodeBlocks/Dr/bin/Release/Dr...(no
debugging symbols found)...done.
This means you didn't have the -g option during compilation.
UPDATE:
file /home/classius/CodeBlocks/Dr/bin/Release/Dr
/home/classius/CodeBlocks/Dr/bin/Release/Dr: ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.24, BuildID[sha1]=0x7da8c5cff4af5082d82eecc3ede59a5920b253a0, stripped
So it's 'stripped', which means -g option was not really used. You may recheck your compiler config or try to build the Debug version?

in settings menu choose debugger then gdb-cdb tab and then reset default

Related

how to make gdb debug a linked program

For example, if we do
mkdir a
mkdir a/b
mkdir a/b/c
mkdir a/b/c/d
ln /bin/ls -s a/b/c/d/myls
ln a -s as
gdb as/b/c/d/myls
...
(gdb) r
Starting program: <mypath>/a/b/c/d/myls
^D
lldb as/b/c/d/myls
(lldb) r
Process 56636 launched: '<mypath>/as/b/c/d/myls' (x86_64)
We can see that gdb debugs on the canonical program, while lldb debugs on the linked program. How can we make gdb debug the linked program w/o getting its absolute path?
We can see that gdb debugs on the canonical program, while lldb debugs on the linked program.
No, we don't see this. We see that GDB performs a realpath to resolve the program, and lldb doesn't, but they both debug the exact same program.
Maybe you can use hard links instead?
This way, gdb will always refer to what you are looking for.
You can also play with with different version of gdb. It seems that version 7.11 provides what you want.
Take a look here:
~/tmp/link] stat hello
File: ‘hello’ -> ‘../hello’
This is what you get for version 7.12
Type "apropos word" to search for commands related to "word"...
Reading symbols from ./link/hello...(no debugging symbols found)...done.
while for older gdb, you get
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>...
Reading symbols from full_path/tmp/hello...(no debugging symbols found)...done.
So, play around with more recent release.

gdb list error "No such file or directory"

I'm currently running a file manager program that abruptly crashed with a segmentation fault and dumped a core file. So I used gdb to debug the core file as:
gdb /path/to/executable /path/to/core
The program which I was running is written in C++. When I ran GDB and tried to print the source lines using "list", I got the following error:
(gdb) bt
#0 0x0000000000554286 in
MyFSEventManager::AddEvent(wxFileSystemWatcherEvent&) ()
#1 0x00000000005ab2e8 in
MyGenericDirCtrl::OnFileWatcherEvent(wxFileSystemWatcherEvent&) ()
(gdb) f 0
#0 0x0000000000554286 in
MyFSEventManager::AddEvent(wxFileSystemWatcherEvent&) ()
(gdb) l
1 /build/glib2.0-prJhLS/glib2.0-2.48.2/./glib/gmain.c: No such file or directory.
Why does gdb say this "/build/glib2.0-prJhLS/glib2.0-2.48.2/./glib/gmain.c: No such file or directory." I do not hit this issue with some other programs that I've debugged using gdb.
The operating system used is Ubuntu 16.04 running on Oracle virtual box. I think may be the gdb symbols were not loaded. I'm not sure why since I compiled the program using the "-g" option. I really need to know the source lines where the code crashes via gdb.
Any suggestions?
EDIT: changes after suggestions from Employed Russian
I was compiling my main using "-g" option and linking it to "existing" object files which were obviously not compiled using "-g" so when the core dumped, I could not see the source for these files. So I went ahead and recompiled those files with "-g" option and reproduced the core dump. It's able to show me the source lines now.
Why does gdb say this "/build/glib2.0-prJhLS/glib2.0-2.48.2/./glib/gmain.c: No such file or directory."
Because you really don't have that file on your system.
I think may be the gdb symbols were not loaded
GDB did load debug symbols for glib, but not for your main executable.
I'm not sure why since I compiled the program using the "-g" option.
Since we don't have your compile and link lines, we can't tell exactly what's wrong, but some of the common issues are:
You have a "stray" -s or -Wl,-s on your link line (this strips debug info from the resulting binary).
You have -g when compiling your main.c, but not when compiling the source in which MyFSEventManager::AddEvent() is defined
P.S.
(gdb) bt
This doesn't seem to be the complete output from bt command. Always try to paste complete outputs as it makes helping easier :)

debug doesn't stop at breakpoint in codeblock

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.

How do you get nacl-gdb to show debug symbols when debugging?

I'm attempting to get the nacl-gdb working with one of the example applications provided with the nacl_sdk. In particular, I'm trying to get it working with the sample hello_tutorial application in the getting_started/part1 folder (the stub code from this tutorial: https://developers.google.com/native-client/dev/devguide/tutorial/tutorial-part1).
I've tried following the instructions here: https://developers.google.com/native-client/dev/devguide/devcycle/debugging#debugging-with-nacl-gdb
But whenever I connect to the target, gdb prints out the following:
(gdb) target remote localhost:4014
Remote debugging using localhost:4014
warning: Can not parse XML target description; XML support was disabled at compile time
0x00000000 in ?? ()
I can then continue and the application runs, but it it's very helpful without the debugging symbols. Anybody know why this might not be working properly?
I performed the following steps:
Modified the Makefile to build hello_tutorial.pexe without finalizing it, and added the -g flag when compiling, and re-ran make.
Ran pnacl-translate to create the .nexe files from the un-finalized .pexe.
../../toolchain/linux_pnacl/bin/pnacl-translate --allow-llvm-bitcode-input hello_tutorial.pexe -arch x86-64 -o hello_tutorial_x86_64.nexe
Modified the hello_tutorial.nmf to point to the nexe files instead of the pexe file.
Modified index.html to point to "application/x-nacl", instead of "application/x-pnacl"
Started Chrome with the following command:
/opt/google/chrome/chrome --enable-nacl --enable-nacl-debug --no-sandbox --disable-hang-monitor localhost:5103
Start up the debugger from the part1 folder with the following command:
../../toolchain/linux_x86_newlib/bin/x86_64-nacl-gdb
Ran the following commands from within gdb. (Note that it shows "no debugging symbols found" when reading from the nacl_irt_x86_64.nexe - is that a problem?)
(gdb) nacl-irt hello_tutorial_x86_64.nexe
Reading symbols from /home/bender/dev/nacl_sdk/pepper_33/getting_started/part1/hello_tutorial_x86_64.nexe...done.
(gdb) nacl-irt /opt/google/chrome/nacl_irt_x86_64.nexe
Reading symbols from /opt/google/chrome/nacl_irt_x86_64.nexe...(no debugging symbols found)...done.
(gdb) target remote localhost:4014
Remote debugging using localhost:4014
warning: Can not parse XML target description; XML support was disabled at compile time
0x00000000 in ?? ()
I'm running on Linux:
Linux bender-VirtualBox 3.11.0-18-generic #32-Ubuntu SMP Tue Feb 18 21:11:14 UTC 2014 x86_64 x86_64 x86_64 GNU/Linux
Looks like this is working okay if I use pepper_canary instead of pepper_33. Found some info at this link: https://code.google.com/p/nativeclient/issues/detail?id=3739

I can't debug in Code::Blocks

I know this is a very common problem, but I tried a lot of stuff, I no one give me a solution. I have a program in C++ with C::B, and I cannot debug. I have the tick in the "-g" option at the "Build Options" in my project. And I have the "gdb.exe" as debugger. But the result is this:
Building to ensure sources are up-to-date
Build succeeded
Selecting target:
Release
Adding source dir: I:\Juego para practicar\
Adding source dir: I:\Juego para practicar\
Adding file: bin\Release\Juego para practicar.exe
Starting debugger:
done
Registered new type: wxString
Registered new type: STL String
Registered new type: STL Vector
Setting breakpoints
**(no debugging symbols found)...(gdb)**
Debugger name and version: GNU gdb 5.2.1
No symbol table is loaded. Use the "file" command.
Program exited with code 030000000472.
Debugger finished with status 0
What can I do? I proved everything, but it remains with no debugging.
"..
Selecting target:
Release
.."
You are in release build, try to rebuild in debug
Paste your buildlog showing us that you are getting the correct compiler flags.
For example, you should have -g for producing symbols.. You shouldn't have -s (strip) which removes all symbols not needed for relocations, etc.