GDB doesn't find debugging symbols in Rust executable - gdb

This is my Cargo.toml with debugging settings:
[package]
name = "rpolysolve"
version = "0.1.0"
authors = ["stiv"]
[dependencies]
[profile.dev]
debug = true
opt-level = 0
As I can see from console output, cargo has not removed debug symbols:
Finished dev [unoptimized + debuginfo] target(s) in 5.66 secs
I have downloaded gdb-7.9.1-tdm64-2 to my C:\gdb-7.9.1-tdm64-2 folder on windows7. Now I try to launch it with this command from project folder:
C:\gdb-7.9.1-tdm64-2\gdb64\bin\gdb.exe ./target/debug/rpolysolve.exe
GNU gdb (GDB) 7.9.1
... GNU blablabla cut here ...
Type "apropos word" to search for commands related to "word"...
Reading symbols from ./target/debug/rpolysolve.exe...(no debugging symbols found)...done.
As you see it says no debugging symbols found and there is now way how I can set a breakpoint. How can I fix this?

Ok, the solution is to switch toolchain, i.e. to make binaries be compatible with GNU:
rustup install stable-gnu
rustup default stable-gnu
I don't know if there is gdb.exe for msvc toolchain.

Related

LLDB - Qt missing debug info

I've installed Qt 5.10.0 through the macOS installer.
I'm currently running OSX El Capitan 10.11.6.
Whenever I try to load any of the Qt libraries/ frameworks, I get the following warning:
warning: (x86_64) /Users/randomuser/Qt/5.10.0/clang_64/lib/QtWidgets.framework/QtWidgets empty dSYM file detected, dSYM was created with an executable with no debug info.
I can reproduce the warning simply by running lldb QtWidgets.framework
I've tried setting DYLD_IMAGE_SUFFIX=_debug, but that doesn't seem to work.
Also, running otool -L QtWidgets.framework/Versions/5/QtWidgets_debug reports the library being linked to the release versions of QtCore and QtGui.
Any insight would be greatly appreciated, thanks!
Edit:
To elaborate on my attempt to use DYLD_IMAGE_SUFFIX, I tried the following, but it still resulted in the warning above.
export DYLD_IMAGE_SUFFIX=_debug
lldb
>env DYLD_IMAGE_SUFFIX=_debug
>target create QtWidgets.framework
>warning: (x86_64) /Users/randomuser/Qt5.10.0/5.10.0/clang_64/lib/QtWidgets.framework/QtWidgets empty dSYM file detected, dSYM was created with an executable with no debug info.
>Current executable set to 'QtWidgets.framework' (x86_64).
I had a similar problem with Qt5.10.0
qmake CONFIG+=debug
make
lldb ./debug/qt_test.app/Contents/MacOS/qt_test
(lldb) env DYLD_IMAGE_SUFFIX=_debug
(lldb) image list
...
[ 16] 9A8C46A9-CADB-3DC2-9D5A-E04826477DCB 0x0000000000000000 /Users/macmini/Qt5.10.0/5.10.0/clang_64/lib/QtWidgets.framework/Versions/5/QtWidgets
/Users/macmini/Qt5.10.0/5.10.0/clang_64/lib/QtWidgets.framework.dSYM/Contents/Resources/DWARF/QtWidgets
...
dSYM seems to be loaded, but not for the _debug version of Qt libs. But when I run the application in lldb:
(lldb) b main
(lldb) r
... lldb breaks on main()...
(lldb) image list
...
[ 9] 1292D5A0-4ADF-37C3-A724-DDB9B199EE8A 0x0000000100296000 /Users/macmini/Qt5.10.0/5.10.0/clang_64/lib/QtWidgets.framework/Versions/5/QtWidgets_debug
/Users/macmini/Qt5.10.0/5.10.0/clang_64/lib/QtWidgets.framework.dSYM/Contents/Resources/DWARF/QtWidgets_debug
...
Now it uses the _debug Qt libs with correct symbols.
Happy debugging!

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.

Codelite issue--No executable specified,use 'target exec

I have just installed codelite in my windows 8.1.It shows error
Debugger exited with the following error string:
"No executable
specified,use 'target exec'"
I searched and found this (another stackoverflow question) I did the same as mentioned there but nothing really worked for me.I made a new project and selected Simple executable (g++) and GNU debugger as default debugger.Can anybody help me with this.Also it shows "Program exited with return code: 4199040".
It seems that you don't provide executable to run/debug:
Go to
Project settings... -> Common settings -> General
and fill correct information for
Executable to Run / Debug
Jarod42 provided a 'close enough' answer. On Linux the steps seem to be:
Workspace -> Open Active Project Settings... -> General
and fill correct information for
Executable to Run / Debug
In the command prompt:
gdb (program type: example python or c or c++ etc)
If am running python program then the command will be gdb python
then (gdb) run program_name.py

Code::Blocks debbuger failure

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

gdb: (no debugging symbols found)

I have a file called test. Even after compiling it with -g, when I run it in gdb, it says no debugging symbols found. I have also tried using -ggdb but it too was off no use. Please help.
Output for : gdb test
This GDB was configured as "x86_64-linux-gnu".
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>...
Reading symbols from /usr/bin/test...(no debugging symbols found)...done.
The issue is that you are attempting to debug the wrong program.
Your program is called test and yet you are debugging /usr/bin/test (a system program that will almost certainly be shipped without symbols; even if it did contain symbols, they wouldn't relate to your source code).
gdb will search $PATH to find the executable. From here:
exec-file [ filename ] Specify that the program to be run (but not the
symbol table) is found in filename. gdb searches the environment
variable PATH if necessary to locate your program. Omitting filename
means to discard information on the executable file.
Try using the command:
$ gdb ./test
Remove a.out and then try again. It worked for me as I was also getting the same error.
rm a.out
gcc -g your_code.c
Check that the executable is not stripped, you can see that with file /usr/bin/test