Reputation: 25
I use openSUSE as my OS,and gdb 7.5. I want to debug my programs with gdb, with breakpoints. But when I make a breakpoint, and then run my program, gdb informs me as follows :
Error in re-setting breakpoint 1: malformed linespec error: unexpected string, ".cpp"
Its same in all of my programs. Also, when run to the breakpoint ,the program doesnt' stop at all. Can any one tell me what's wrong?
I download the latest gdb and install it ,the former message is gone ,but when run gdb it tells me that :
warning: Could not load shared library symbols for linux-gate.so.1. Do you need "set solib-search-path" or "set sysroot"?
how to slove this problem?
Upvotes: 1
Views: 1857
Reputation: 17179
There is a known bug in gdb 7.5 where the debugger fails to parse the linespec when the source file name starts with a decimal digit. See this message for details.
Try renaming the file and update gdb from your distribution repository. If the bug persists, file a bug with your distribution maintainers.
See a sample session from a bug report submitted to gdb
bugzilla.
(gdb) b 3
Breakpoint 1 at 0x4004c3: file 2.c, line 3.
(gdb) r
Starting program: /home/teawater/tmp/a.out
Error in re-setting breakpoint 1: malformed linespec error: unexpected string, ".c"
Error in re-setting breakpoint 1: malformed linespec error: unexpected string, ".c"
Error in re-setting breakpoint 1: malformed linespec error: unexpected string, ".c"
Error in re-setting breakpoint 1: malformed linespec error: unexpected string, ".c"
Upvotes: 2
Reputation: 36649
I use "b + linenumber"
This defines a breakpoint relative to the current line, see als Specifying a Location. With the code from your comment below, the following would work:
$ gdb ./main
(gdb) b +5
Breakpoint 1 at 0x40139c: file main.cpp, line 6.
(gdb) run
[New Thread 1528.0x1930]
Breakpoint 1, main () at main.cpp:5
5 while(scanf("%d%d",&a,&b)!=EOF)
Unless there is a good reason to specify relative line numbers, I suggest that you use absolute line numbers or function names:
(gdb) b main
Breakpoint 1 at 0x401395: file main.cpp, line 3.
(gdb) b main.cpp:6
Breakpoint 1 at 0x40139c: file main.cpp, line 6.
Upvotes: 1