简体   繁体   中英

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?

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

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM