Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/assembly/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Debugging 如何在NASM代码中包含调试符号,以便在Windows上使用GDB进行调试?_Debugging_Assembly_Gdb_Nasm_Mingw32 - Fatal编程技术网

Debugging 如何在NASM代码中包含调试符号,以便在Windows上使用GDB进行调试?

Debugging 如何在NASM代码中包含调试符号,以便在Windows上使用GDB进行调试?,debugging,assembly,gdb,nasm,mingw32,Debugging,Assembly,Gdb,Nasm,Mingw32,如何在NASM代码中包含调试符号,以便在Windows上使用GDB进行调试 编写了一些NASM程序集之后,我想使用GDB对其进行调试 我使用以下命令组装和链接: nasm -f win32 insertion_sort.asm ld insertion_sort.obj 但是,启动GDB(GDB a)会产生: 在下面的代码中,我无法引用\u数组,例如: (gdb) x/4xw _array No symbol table is loaded. Use the "file" comma

如何在NASM代码中包含调试符号,以便在Windows上使用GDB进行调试

编写了一些NASM程序集之后,我想使用GDB对其进行调试

我使用以下命令组装和链接:

nasm -f win32 insertion_sort.asm    
ld insertion_sort.obj
但是,启动GDB(
GDB a
)会产生:

在下面的代码中,我无法引用
\u数组
,例如:

(gdb) x/4xw _array
No symbol table is loaded.  Use the "file" command.
(gdb) x/4xw array
0x1:    Cannot access memory at address 0x1
另外,在退出时设置断点:

(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]
使GDB在运行时仅运行程序以完成

怎么了?

汇编代码为:

    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插入\u排序.o插入\u排序.asm
$gcc-m32-o插入\u sort.exe插入\u sort.o

My
nasm
说明:“win32”输出格式的有效调试格式为(“*”表示默认值):*空调试格式。除非你说了些别的,否则除了使符号全局化和使用反汇编,你就无能为力了。你会写示例命令吗?杰斯特,为什么我要使符号全局化?这里发生了什么?为什么这个问题有来自不同用户的相同代码?您实际上不需要调试符号,普通符号可以用于程序集调试。
x/4xw数组
的问题在于,无论出于何种原因,您都需要键入
x/4xw&array
。实际上,在NASM中,win32对象当前仅支持cv8格式。要检查支持的调试格式列表,可以运行“nasm-f win32-y”。
    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