在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。
答案 0 :(得分:1)
如何宣布'bg'? id bg或Sprite * bg
使用'id bg' 你必须把bg强制转换为正确的类,
(gdb) p bg->top
There is no member named top.
(gdb) p ((struct Sprite *)bg)->top
$1 = 0
使用Sprite * bg
(gdb) p bg->top
$1 = 0
使用GNU gdb(GDB)7.3.50.20110421-cvs 在linux下,你使用的是哪个版本的gdb?
是在DLL /库中单独实现的Sprite类 在主要的应用程序?
可能它可能是一些表现形式 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=39465