gpt4 book ai didi

c - gdb 错误 : not in executable format: file not recognized

转载 作者:塔克拉玛干 更新时间:2023-11-02 23:50:33 26 4
gpt4 key购买 nike

我正在尝试调试我的项目,它包含 5 个文件。我使用 Makefiles 系统构建了项目。我的 Makefile 如下所示:

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

不知道是什么问题。有什么想法吗?

最佳答案

你要做的是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.

关于c - gdb 错误 : not in executable format: file not recognized,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33066019/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com