2015-10-11 107 views
1

我正在尝试调试我的项目,其中包含5个文件。我使用Makefiles系统构建了该项目。我的Makefile如下所示:gdb错误:无法执行格式:文件未被识别

CC=gcc 

CFLAGS= -g -c 

all: main.o io_ops.o rw_ops.o help_functions.o 
    $(CC) -o db main.o io_ops.o rw_ops.o help_functions.o 
io_ops.o:io_ops.c db_ops.h 
    $(CC) $(CFLAGS) io_ops.c db_ops.h 
rw_ops.o: rw_ops_c db_ops.h 
    $(CC) $(CFLAGS) rw_ops.c db_ops.h 
help_functions.o: help_functions.c 
    $(CC) $(CFLAGS) help_functions.c 
clean: 
    rm *.o db 

我的可执行文件名为db。所以,我在我的终端上运行下面的命令:

gdb db 

然后我就GDB键入以下命令:

list main.c 

我得到以下错误:没有定义的main.c 我试着键入以下命令:

list main.c 

我得到以下错误: 的main.c:不可执行文件格式:文件无法识别

为了确保我的GDB是64位的程序,我输入以下命令:

(gdb) show configuration 
This GDB was configured as follows: 
configure --host=x86_64-linux-gnu --target=x86_64-linux-gnu 
     --with-auto-load-dir=$debugdir:$datadir/auto-load 
     --with-auto-load-safe-path=$debugdir:$datadir/auto-load 
     --with-expat 
     --with-gdb-datadir=/usr/share/gdb (relocatable) 
     --with-jit-reader-dir=/usr/lib/gdb (relocatable) 
     --without-libunwind-ia64 
     --with-lzma 
     --with-python=/usr (relocatable) 
     --with-separate-debug-dir=/usr/lib/debug (relocatable) 
     --with-system-gdbinit=/etc/gdb/gdbinit 
     --with-zlib 
     --without-babeltrace 

这是我的可执行的一些信息:

db: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.24, BuildID[sha1]=25731950b7f76cf428eeca5fcc534555d677f3dc, not stripped

我不知道,是什么问题。任何想法?

+0

你的'Makefile'是非常错误的;看[这](http://stackoverflow.com/a/16751650/841108) –

+0

为什么我的Makefile错了? – amitakCs

+0

尤其是,因为您明确地编译了头文件。你应该使用'-Wall -g'作为你的编译标志。 –

回答

2

你想要做什么是list main.c:1

list没有作出列表中的文件,你使用它的方式。从GDB的帮助:

(gdb) help list

List specified function or line.

With no argument, lists ten more lines after or around previous listing.

"list -" lists the ten lines before a previous ten-line listing.

One argument specifies a line, and ten lines are listed around that line. Two arguments with comma between specify starting and ending lines to list. Lines can be specified in these ways:

LINENUM, to list around that line in current file,

FILE:LINENUM, to list around that line in that file,

FUNCTION, to list around beginning of that function,

FILE:FUNCTION, to distinguish among like-named static functions.

*ADDRESS, to list around the line containing that address.

With two args if one is empty it stands for ten lines away from the other arg.

1

I do not know, what is the problem.

你可能想list main代替。

说明:有命令的four forms命令,没有将文件名作为参数。

+0

那么,在我的gdb 7.10上,有2个:'FILE:LINENUM,列出该文件中的那行'和'FILE:FUNCTION,以区分类似命名的静态functions'。该文档似乎不是最新的。 – jbm

相关问题