Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Missing debugging information with gdb and nasm

I have a simple assembly program with the following makefile:

all : calc

calc : calc.o
    gcc -m32 -g -o calc calc.o

calc.o : calc.s
    nasm -f elf -g -F stabs calc.s

I try to debug it using gdb but it always says:

Single stepping until exit from function asc2int, which has no line number information.

I tried many solutions to the problem, including -F dwarf but none of them works. Can you please help me resolve this issue?

like image 651
Ori Popowski Avatar asked Oct 23 '25 18:10

Ori Popowski


1 Answers

I don't see any problems with your makefile.

Quick google search gives following nasm. The documentation example shows you need to disassemble to look through the code, but its kind of weird, as already assembly code is being debugged why would the debugger ask to disassemble it further. However the disassembled code is inline with assembly source file.

Form what you have mentioned it seems you are able to debug. use nexti in case if you are using next instruction to step through. You can you disassemble command to every time see where the execution control lies. Or if you want it automated you can save following as a script. asm_next becomes the new instruction for you step in through the code.

set language asm
set disassembly-flavor intel
define asm_next
nexti
disassemble
end

Run it using the command

gdb -x <script> calc

P.S. for larger programs you might need to ad -O0 flag to get correlation between debugger disassembled code and your assembly code in .s file.

like image 103
Kamath Avatar answered Oct 26 '25 07:10

Kamath



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!