在NASM中调试符号(更多) [英] Debug symbols in NASM (once more)

查看:151
本文介绍了在NASM中调试符号(更多)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这个问题在StackOverflow上已经问了好几次了,但是我尝试了所有答案,但仍然无法使NASM包含DWARF调试符号.

This question has been asked several times on StackOverflow but I tried all the answers and I still cannot get NASM to include DWARF debugging symbols.

我正在Ubuntu 18.04 64位下使用NASM 2.13.02.我不确定我是否仍然缺少什么?

I am using NASM 2.13.02 under Ubuntu 18.04 64-bit. I am not sure if I am still missing something?

如果有关系,我实际上想同时使用LLDB和GDB.

In case it matters, I would actually like to use both LLDB and GDB.

谢谢.

这是我的代码:

section .bss
section .text

global _start

_start:
    mov ebx, 0
    mov eax, 1
    int 80h

这是我建立和链接的方式:

Here is how I build and link it:

nasm -g -F dwarf -f elf64 hello.asm
ld -s -o hello hello.o

结果文件为:

$ ls -la hello
-rwxr-xr-x 1 terry terry 352 Sep  4 18:21 hello
$

尝试检查是否包含DWARF数据:

Trying to check if DWARF data is included:

$ dwarfdump hello
No DWARF information present in hello
$

在gdb下运行它:

$ gdb ./hello 
GNU gdb (Ubuntu 8.1-0ubuntu3.2) 8.1.0.20180409-git
[... snip copyright ...]
Reading symbols from ./hello...(no debugging symbols found)...done.
(gdb) 

推荐答案

我是根据@Michael Petch的建议(这是真正找到根本原因的人)自问自己.

I am self-answering my own question based on a suggestion from @Michael Petch who was the person that actually found the root cause.

问题是我将ld-s一起使用,意思是全部带走",包括调试符号,即我正在破坏自己的努力.

The issue was that I was using ld with -s which means "strip all", including debug symbols, i.e. I was undermining my own effort.

正确的命令应该是:

nasm -g -F dwarf -f elf64 hello.asm
ld -o hello hello.o

现在,使用gdb:

$ gdb ./hello 
GNU gdb (Ubuntu 8.1-0ubuntu3.2) 8.1.0.20180409-git
[.. snip copyright ..]
Reading symbols from ./hello...done.

(gdb) b _start
Breakpoint 1 at 0x400080: file hello.asm, line 7.

(gdb) run
Starting program: /home/terry/hello 

Breakpoint 1, _start () at hello.asm:7
7       xor ebx, 0
(gdb) 
$

这篇关于在NASM中调试符号(更多)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆