Bug in XCode debugger?

家住魔仙堡 提交于 2019-12-22 10:57:32

问题


I am working on an iPhone app which is using an external library for which I have the source. During debugging some of the objects are listed as 0x0 in the debugger but the app runs fine. Also, some of the objects addresses point to the wrong thing. These symbols are in the external library. The addresses are fine if I am tracing through a file actually in the external library.

Does anyone have suggestions how to stop this behavior?


回答1:


UPDATE: target settings > Build tab > GCC 4.2 Code Generation > "Compile for Thumb"

I turned off this target setting and the gdb problem went away.

--

Hi John.

I understand what you're referring to. I'm also seeing a problem where gdb and NSLog() are giving me different results for pointers in certain parts of my code.

In a boiled-down example, gdb fails to report the proper value for "pointer" when I set a breakpoint on any line in this function:

id testPointer( id pointer )
{
    NSLog( @"pointer value: %p", pointer );

    @try
    {
        NSLog( @"foo" );
    }
    @catch ( NSException *e )
    { }
    @finally
    { }

    return pointer;
}



回答2:


As zPesk notes, 0x0 is nil, which is a common value for objects that have not been initialized (particularly instance variables). I'm not certain what you mean by "point to the wrong thing." If you haven't initialized a local (stack) variable, it may point to any random address until it is initialized. What behavior are you having trouble with?




回答3:


Were you ever able to resolve this issue? I, too, am noticing strange behavior in gdb when mixing Thumb and ARM modes. For example, it appears that the addresses of variables reported by gdb are off by exactly 64 bytes from the addresses reported using printf("%p\n") statements. Perhaps gdb needs to be explicitly told whether the current operating mode is ARM or Thumb...?



来源:https://stackoverflow.com/questions/1285708/bug-in-xcode-debugger

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!