[英]How to include debug symbols in NASM code for debugging using GDB on Windows?
How to include debug symbols in NASM code for debugging using GDB on Windows?
如何在NASM代码中包括调试符号以在Windows上使用GDB进行调试?
Having coded some NASM assembly, I want to debug it using GDB. 编码了一些NASM程序集之后,我想使用GDB对其进行调试。
I assemble and link using the following commands: 我使用以下命令进行汇编和链接:
nasm -f win32 insertion_sort.asm
ld insertion_sort.obj
However, starting GDB ( gdb a
) yields: 但是,启动GDB(
gdb a
)会产生:
Reading symbols from C:\Users\nze\Desktop\asm\sorting\insertion_sort\a.exe...(no debugging symbols found)...done.
In the code below I cannot reference _array
like: 在下面的代码中,我无法引用
_array
:
(gdb) x/4xw _array
No symbol table is loaded. Use the "file" command.
(gdb) x/4xw array
0x1: Cannot access memory at address 0x1
Also, setting breakpoint at _exit
: 另外,在
_exit
处设置断点:
(gdb) break exit
Breakpoint 1 at 0x401464
(gdb) run
Starting program: C:\Users\nze\Desktop\asm\sorting\insertion_sort/insertion_sort.exe
[New Thread 5488.0x1c7c]
[New Thread 5488.0xc54]
[Inferior 1 (process 5488) exited with code 01]
causes GDB to just run the program to completion when run... 导致GDB在运行时仅运行程序即可完成...
What is wrong? 怎么了?
The assembly code is: 汇编代码为:
BITS 32
section .data
_array: dd 4, 2, 8, 6, 1
_len: equ ($ - _array) / 4
section .text
global _start
_start:
push ebp
mov ebp, esp
xor ecx, ecx
_outer:
inc ecx
cmp ecx, _len
jge _exit
mov ebx, ecx
dec ebx
lea esi, [_array + ecx * 4]
lea edi, [_array + ebx * 4]
_inner:
cmp ebx, 0
jl _outer
mov eax, [edi]
cmp eax, [esi]
jle _outer
xchg eax, dword [esi] ; swap [esi] and [edi]
mov dword [edi], eax
sub esi, 4
sub edi, 4
dec ebx
jmp _inner
_exit:
mov esp, ebp
pop ebp
ret
您是否尝试过包括可用于Windows(Codeview 8)的调试信息?
$ nasm -gcv8 -f win32 -o insertion_sort.o insertion_sort.asm $ gcc -m32 -o insertion_sort.exe insertion_sort.o
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.