Reputation: 467
I am trying to debug my project, which consists of 5 files. I built the project using a Makefiles-system. My Makefile looks as the following:
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
My executable file is named db. So I run on my terminal the following command:
gdb db
Then I type the following command on gdb:
list main.c
I get the following error: main.c not defined I try to type the following command:
list main.c
I get the following error: main.c: not in executable format:file not recognized
To ensure that my gdb is 64-bit-program, I typed the following command:
(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
And this is some informations about my executable:
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
I do not know, what is the problem. Any idea?
Upvotes: 2
Views: 5313
Reputation: 3163
What you want to do is list main.c:1
list
is not made to list a file the way you use it. From gdb help:
(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.
Upvotes: 2
Reputation: 213375
I do not know, what is the problem.
You likely want list main
instead.
Explanation: there are four forms of list
command, none take filename as an argument.
Upvotes: 1