GDB抱怨没有可用的资源 [英] GDB complains No Source Available

查看:84
本文介绍了GDB抱怨没有可用的资源的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在Ubuntu 12.10 64位上运行.

I'm running on Ubuntu 12.10 64bit.

我正在尝试在GDB中调试一个简单的汇编程序.但是,GDB的gui模式(-tui)似乎找不到我的汇编文件的源代码.我已经在当前目录中重建了该项目,并在Google搜索中无济于事,请在这里为我提供帮助.

I am trying to debug a simple assembly program in GDB. However GDB's gui mode (-tui) seems unable to find the source code of my assembly file. I've rebuilt the project in the currently directory and searched google to no avail, please help me out here.

我的命令:

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

gcc -g hello.o -o hello

gdb -tui hello

调试信息似乎已加载,我可以在main()处设置一个断点,但屏幕的上半部分仍显示' [No Source Available] ".

Debug information seems to be loaded, I can set a breakpoint at main() but the top half the screen still says '[ No Source Available ]'.

如果您有兴趣,这里是hello.asm:

Here is hello.asm if you're interested:

;  hello.asm  a first program for nasm for Linux, Intel, gcc
;
; assemble: nasm -f elf -l hello.lst  hello.asm
; link:     gcc -o hello  hello.o
; run:          hello 
; output is:    Hello World 

    SECTION .data       ; data section
msg:    db "Hello World",10 ; the string to print, 10=cr
len:    equ $-msg       ; "$" means "here"
                ; len is a value, not an address

    SECTION .text       ; code section
        global main     ; make label available to linker 
main:               ; standard  gcc  entry point

    mov edx,len     ; arg3, length of string to print
    mov ecx,msg     ; arg2, pointer to string
    mov ebx,1       ; arg1, where to write, screen
    mov eax,4       ; write command to int 80 hex
    int 0x80        ; interrupt 80 hex, call kernel

    mov ebx,0       ; exit code, 0=normal
    mov eax,1       ; exit command to kernel
    int 0x80        ; interrupt 80 hex, call kernel

推荐答案

在这种情况下,问题是汇编器没有为调试器生成行号信息.因此,尽管存在源代码(如果您在gdb中执行列表",它会显示源文件的列表-至少在我按照您的步骤操作时,它会显示源文件的列表),但是调试器需要文件中的行号信息才能知道哪行对应什么地址.它不能用给定的信息做到这一点.

The problem in this case is that the assembler isn't producing line-number information for the debugger. So although the source is there (if you do "list" in gdb, it shows a listing of the source file - at least when I follow your steps, it does), but the debugger needs line-number information from the file to know what line corresponds to what address. It can't do that with the information given.

据我所知,没有办法让NASM发出例如使用gccas使用的.loc指令.但是as不能在不生成大量错误的情况下获取源文件(即使使用-msyntax = intel -mmnemonic = intel,您也应该认为可行).

As far as I can find, there isn't a way to get NASM to issue the .loc directive that is used by as when using gcc for example. But as isn't able to take your source file without generating a gazillion errors [even with -msyntax=intel -mmnemonic=intel -- you would think that should work].

因此,除非有人更聪明地提出一种生成.loc条目的方法,以提供调试器的行号信息,否则我不确定是否能以一种让您满意的方式回答您的问题.

So unless someone more clever can come up with a way to generate the .loc entries which gives the debugger line number information, I'm not entirely sure how we can answer your question in a way that you'll be happy with.

这篇关于GDB抱怨没有可用的资源的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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