当使用GDB,你怎么看这C(未组装)指令,该指令已GDB停止时? [英] When using GDB, how do you see which C (not Assembly) instruction that GDB has stopped upon?

查看:136
本文介绍了当使用GDB,你怎么看这C(未组装)指令,该指令已GDB停止时?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

见,问题是,我应该使用一个可执行的驱动程序(VDRIVER)来测试包含方法的驱动程序将使用收集的C源文件,我写(myfile.c文件)。我用gcc编译在一起(它们所依赖的也是任何文件),然后跑了GDB VDRIVER

See, the problem is that I'm supposed to use an executable driver program (vdriver) to test the C source file I wrote (myfile.c) containing a collection of methods the driver program will use. I used gcc to compile them together (and also any files they depend on) and then ran "gdb vdriver"

显然,我在某处得到myfile.c文件段错误。在dissasemble-produced组装code甚至可以在装配和点显示整个方法,它只是说明要segfaulted

Apparently, I am getting a segfault somewhere in myfile.c. The "dissasemble"-produced assembly code can even display the whole method in assembly and point to which instruction just segfaulted.

不过,由于大会code的复杂性(和长度),我认为这将是更有效的查看该行所在的段错误发生在以下。

However, due to the complexity (and length) of the assembly code, I think it would be much more effective to view this line where the segfault occurred in C.

然而,运行命令列表* $ EIP的结果:

However, running the command "list *$eip" results in:

    No source file for address 0x804a3d3

有谁知道如何使这项工作?

Does anyone know how to make this work?

推荐答案

编译与调试信息。


gcc -ggdb -c source.c -o source.o ...

更新:它看起来像您无法调用GCC为好。我建议写一个Makefile文件,并采取了快速查找通过GCC手册什么 -c -o 的意思。

Update: It looks like you're having trouble invoking GCC as well. I suggest writing a Makefile, and taking a quick look through the GCC manual for what -c and -o mean.

CC = gcc
CFLAGS = -ggdb -Wall # or whatever flags you want, read the manual

# List all files, with *.c changed to *.o (Make will figure the rest out)
my_app : file1.o file2.o file3.o file4.o
        $(CC) -o my_app $^
# The above line should start with a tab, not spaces

clean :
        rm -f my_app *.o

# List dependencies like this (technically optional)
# But if you don't do it, "make" might not re-make things that need it
file1.o : file1.c header.h header2.h
file2.o : file2.c header.h

这篇关于当使用GDB,你怎么看这C(未组装)指令,该指令已GDB停止时?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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