9

My app is crashing and it seems like it's caught in the exception breakpoint (which makes sense), but I am unable to get to the reason of the crash.

Here's what I've tried:

  • po $eax
  • po $rax
  • po $r0
  • po *(id *)($esp + 4)

For all the attempts above I'm getting the following error:

error: use of undeclared identifier '$<register name>' error: 1 errors parsing expression

I also found this LLDB Command Guide, but didn't find anything useful (a bit confusing it you don't know what you're looking for).

How can I print the reason for the crash?

I'm running iOS 8, lldb and Xcode 6.

EDIT

Now I see why these registers are not found. Here's what I get when I run register read:

General Purpose Registers:
x0 = 0x0000000000000001
x1 = 0x0000000000000000
x2 = 0x0000000000000000
x3 = 0x0000000195531a74  libsystem_malloc.dylib`nano_free_definite_size
x4 = 0x0000000000000000
x5 = 0x0000000000000000
x6 = 0x676e697274534643
x7 = 0x0000000000000f80
x8 = 0x00000001569d5a10
x9 = 0x0000000000000000
x10 = 0x000001a574056051
x11 = 0x0000000000000001
x12 = 0x000000000000003d
x13 = 0x0000000000000000
x14 = 0x0000000000000001
x15 = 0x0000000000000052
x16 = 0x0000000194d6e510  libobjc.A.dylib`object_setClass
x17 = 0x0000000000000000
x18 = 0x0000000000000000
x19 = 0x00000001702823f0
x20 = 0x0000000174038eaa
x21 = 0x000000019130a778  "release"
x22 = 0x0000000000000000
x23 = 0x0000000174246d20
x24 = 0x0000000174038ea0
x25 = 0x00000001895d22fa  "forwardingTargetForSelector:"
x26 = 0x00000001745186a0
x27 = 0x0000000000000000
x28 = 0x00000000a40008ff
fp = 0x0000000105757720
lr = 0x000000018462a440  CoreFoundation`___forwarding___ + 968
sp = 0x00000001057576c0
pc = 0x000000018462a440  CoreFoundation`___forwarding___ + 968
cpsr = 0x20000000

As you can see these are the registers used do not contain any of the ones I had previously tried. However, I'm still unable to find the exception.

xcode view

Bartłomiej Semańczyk
  • 59,234
  • 49
  • 233
  • 358
Julian B.
  • 3,605
  • 2
  • 29
  • 38
  • possible duplicate of [Xcode/GDB: How to get information about an exception that was just thrown?](http://stackoverflow.com/questions/3327828/xcode-gdb-how-to-get-information-about-an-exception-that-was-just-thrown) – Ben Flynn Jun 12 '15 at 18:38

2 Answers2

6

You should just type:

po $arg1

For more information look at: How to replace NSUncaughtExceptionHandler with definition in Breakpoint navigator?

Community
  • 1
  • 1
Bartłomiej Semańczyk
  • 59,234
  • 49
  • 233
  • 358
  • In the question there is no option for `$arg1`. So, check exactly what you defined within your exception breakpoint. I mean what action you defined? Can you attach a screen, please? – Bartłomiej Semańczyk Jul 22 '15 at 08:34
  • Ok, it doesn't work here: http://stackoverflow.com/questions/31403719/using-of-symbolic-breakpoints-for-child-classes-in-xcode/31527538?noredirect=1#comment51049128_31527538 and here: http://natashatherobot.com/xcode-debugging-trick/ In general - it can't even find `$arg1` so it won't work always you try to access it – Vyachaslav Gerchicov Jul 22 '15 at 09:43
  • xCode 7 beta x (last versions) also requires OSX 10.11 which is beta too. Must I install an unstable version of OS to enable one feature which should work for current version too? – Vyachaslav Gerchicov Jul 22 '15 at 09:59
  • 1
    This very much does work, just make sure you have selected the correct stack frame (the frame where the exception is being thrown). – Rickster Jan 28 '16 at 19:40
0

Emphasizing Rickster's comment from the previous answer:

Make sure you select the correct frame.

po $arg1 worked for me after selecting the top most "machine code" frame in the debug navigator.

GK100
  • 3,664
  • 1
  • 26
  • 19