[英]gdb not setting breakpoint on correct line
I'm working through a bug in Qt/zlib at the moment, and I'm trying to check whether a variable has become corrupt prior to the line it's crashing on, so I've used break 1245
to set the break on the previous line, however: 我正在研究Qt / zlib中的一个错误,我正在尝试检查变量是否在它崩溃的行之前已经损坏,所以我使用了
break 1245
来设置上一个中断然而,行:
(gdb) info break
Num Type Disp Enb Address What
6 breakpoint keep y 0x02cb0e1e in inflateEnd at inflate.c:1245
breakpoint already hit 6 times
(gdb) c
Continuing.
[Thread 0xb103db70 (LWP 26146) exited]
[Thread 0xb5a74b70 (LWP 26143) exited]
Breakpoint 6, inflateEnd (strm=0x86ccdc0) at inflate.c:1246
1246 if (state->window != Z_NULL) ZFREE(strm, state->window);
Which is the line that it's SEGFAULTing on rather than the breakpoint I've set. 它是SEGFAULTing的线路而不是我设置的断点。 Bug in gdb or some quirky behaviour?
gdb中的bug还是一些古怪的行为?
EDIT: Adding the list of the area I'm working on: 编辑:添加我正在处理的区域列表:
(gdb) list
1241 {
1242 struct inflate_state FAR *state;
1243 if (strm == Z_NULL || strm->state == Z_NULL || strm->zfree == (free_func)0)
1244 return Z_STREAM_ERROR;
1245 state = (struct inflate_state FAR *)strm->state;
1246 if (state->window != Z_NULL) ZFREE(strm, state->window);
1247 ZFREE(strm, strm->state);
1248 strm->state = Z_NULL;
1249 Tracev((stderr, "inflate: end\n"));
1250 return Z_OK;
(gdb)
EDIT: Took the advice from the comments and rebuilt it using the source packages from ubuntu (apt-get source) and building with CFLAGS and SFLAGS forced to -O0, however it now doesn't return any line numbers within gdb for the segfault, so I think I've gone wrong somewhere. 编辑:从评论中获取建议并使用ubuntu(apt-get source)中的源包重建它,并使用强制为-O0的CFLAGS和SFLAGS进行构建,但是现在它不会返回gdb中任何段错误的行号,所以我觉得我在某个地方出了问题。
Which is the line that it's SEGFAULTing on rather than the breakpoint I've set
它是SEGFAULTing的线路而不是我设置的断点
This is expected when debugging optimized code (which inflate.c
likely is). 在调试优化代码(
inflate.c
可能是)时,这是预期的。 The compiler moves instructions around, making code execution "jump around" when you step through it. 编译器会移动指令,使代码执行在您单步执行时“跳转”。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.