尝试在 gdb 中打印 Objective-C 字段时出现分段错误
在 GDB 中,如果我尝试执行以下操作,则会出现分段错误:
print bg->top
代码看起来有点像这样:
@interface Sprite : Object
{
@public
int top;
/* Other fields */
}
@end
bg = [Sprite load: "test.png"];
/* GDB is at a breakpoint after the above line */
我得到的消息是:
(gdb) print bg->top
Program received signal SIGSEGV, Segmentation fault.
0x6a7e3048 in libobjc-2!__objc_class_links_resolved () from C:\MinGW\bin\libobjc-2.dll
The program being debugged was signaled while in a function called from GDB.
GDB remains in the frame where the signal was received.
To change this behavior use "set unwindonsignal on".
Evaluation of the expression containing the function
(objc_lookup_class) will be abandoned.
When the function is done executing, GDB will silently stop.
这是为什么?
我正在使用 GNU Objective-C 运行时,但没有使用 GNUStep。
In GDB I get a segmentation fault if I attempt to do the following:
print bg->top
The code looks a bit like this:
@interface Sprite : Object
{
@public
int top;
/* Other fields */
}
@end
bg = [Sprite load: "test.png"];
/* GDB is at a breakpoint after the above line */
The message I get is:
(gdb) print bg->top
Program received signal SIGSEGV, Segmentation fault.
0x6a7e3048 in libobjc-2!__objc_class_links_resolved () from C:\MinGW\bin\libobjc-2.dll
The program being debugged was signaled while in a function called from GDB.
GDB remains in the frame where the signal was received.
To change this behavior use "set unwindonsignal on".
Evaluation of the expression containing the function
(objc_lookup_class) will be abandoned.
When the function is done executing, GDB will silently stop.
Why is this?
I'm using the GNU Objective-C runtime and I'm not using GNUStep.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
'bg' 是如何声明的?
id bg 或 Sprite *bg
使用 'id bg'
将 bg 转换为正确的类
您必须使用 Sprite *bg
使用 GNU gdb (GDB) 7.3.50.20110421-cvs
在linux下,你使用的是哪个版本的gdb?
是在 DLL/库中单独实现的 Sprite 类或者
在主应用程序中?
它可能是某种表现
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=39465
how is 'bg' declared?
id bg or Sprite *bg
using 'id bg'
you must cast bg to the correct class,
using Sprite *bg
using GNU gdb (GDB) 7.3.50.20110421-cvs
under linux, which version of gdb are you using?
is the Sprite class implemented separately in a DLL/library or
in the main application?
its possible it could be some manifestation of
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=39465