user191776
user191776

Reputation:

GDB unable to read from file

I'm debugging a set of C source files using GDB. I've compile all the files with the -g flag. I'm even able to set the breakpoint at a valid location.

$ cd /home/user/project/test
$ gdb ../src/exec

Reading symbols from /home/user/project/src/exec...done.
(gdb) b driver.c:196
Breakpoint 1 at 0x80698ac: file driver.c, line 196.
(gdb) r input.txt
Starting program: /home/user/project/src/exec input.txt
Breakpoint 1, handle_new_request (curriodriver=0x810b228, curr=0x8143ec0)
    at driver.c:196
196 driver.c: No such file or directory.
    in driver.c

Why is GDB unable to read the line from driver.c?

Upvotes: 0

Views: 1255

Answers (1)

David Schwartz
David Schwartz

Reputation: 182847

It's because gdb doesn't know where to look for the file. You can set a breakpoint because the breakpoint information is part of the debug info attacked to the executable. But to actually display the source code, it needs to find the actual source code. Likely running gdb with a different working directory will solve the problem.

Upvotes: 1

Related Questions