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?
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.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.