当前位置: 技术问答>linux和unix
gdb调试程序乱跳问题
来源: 互联网 发布时间:2017-05-26
本文导语: 我单步调试redis-cli,断点设的718行,然后run却停在别的地方,感觉gdb显示的代码和程序正在执行的代码行数对不上,然后后面就是一会执行后面一会执行前面,完全搞不懂。。。 有人知道这是咋回事吗?Thanks in advan...
我单步调试redis-cli,断点设的718行,然后run却停在别的地方,感觉gdb显示的代码和程序正在执行的代码行数对不上,然后后面就是一会执行后面一会执行前面,完全搞不懂。。。
有人知道这是咋回事吗?Thanks in advance!
(gdb) break linenoise.c:718
Breakpoint 1 at 0x414347: file linenoise.c, line 718.
(gdb) run
Starting program: /root/redis-2.8.13/src/redis-cli
[Thread debugging using libthread_db enabled]
Breakpoint 1, linenoiseRaw (prompt=0x655780 "127.0.0.1:6379> ") at linenoise.c:933
933 if (enableRawMode(STDIN_FILENO) == -1) return -1;
(gdb) info break
Num Type Disp Enb Address What
1 breakpoint keep y 0x0000000000414347 in linenoise at linenoise.c:718
breakpoint already hit 1 time
(gdb) s
linenoiseEdit (prompt=0x655780 "127.0.0.1:6379> ") at linenoise.c:718
718 l.ofd = stdout_fd;
(gdb)
716 * specific editing functionalities. */
(gdb)
717 l.ifd = stdin_fd;
(gdb)
719 l.buf = buf;
(gdb)
720 l.buflen = buflen;
(gdb)
721 l.prompt = prompt;
(gdb)
718 l.ofd = stdout_fd;
(gdb)
721 l.prompt = prompt;
(gdb)
724 l.len = 0;
有人知道这是咋回事吗?Thanks in advance!
(gdb) break linenoise.c:718
Breakpoint 1 at 0x414347: file linenoise.c, line 718.
(gdb) run
Starting program: /root/redis-2.8.13/src/redis-cli
[Thread debugging using libthread_db enabled]
Breakpoint 1, linenoiseRaw (prompt=0x655780 "127.0.0.1:6379> ") at linenoise.c:933
933 if (enableRawMode(STDIN_FILENO) == -1) return -1;
(gdb) info break
Num Type Disp Enb Address What
1 breakpoint keep y 0x0000000000414347 in linenoise at linenoise.c:718
breakpoint already hit 1 time
(gdb) s
linenoiseEdit (prompt=0x655780 "127.0.0.1:6379> ") at linenoise.c:718
718 l.ofd = stdout_fd;
(gdb)
716 * specific editing functionalities. */
(gdb)
717 l.ifd = stdin_fd;
(gdb)
719 l.buf = buf;
(gdb)
720 l.buflen = buflen;
(gdb)
721 l.prompt = prompt;
(gdb)
718 l.ofd = stdout_fd;
(gdb)
721 l.prompt = prompt;
(gdb)
724 l.len = 0;
|
also, are sure this is the right source tree for the binary?
You will have to disable all optimization options during compilation. Jumping around could also happen if -O is enabled.
You will have to disable all optimization options during compilation. Jumping around could also happen if -O is enabled.