Bug in XCode debugger?

2019-05-11 04:04发布

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?

3条回答
来,给爷笑一个
2楼-- · 2019-05-11 04:13

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...?

查看更多
何必那么认真
3楼-- · 2019-05-11 04:21

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?

查看更多
forever°为你锁心
4楼-- · 2019-05-11 04:28

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;
}
查看更多
登录 后发表回答