I'm assuming that you've tried to use "ndk-gdb" and this was
unsuccessful (it seems to be broken for many people, including me)
What you can do is to disassemble the .so file and see where in the
file it was.
To do this execute the following:
$NDK_ROOT/build/prebuilt/HOST/arm-eabi-4.2.1/bin/arm-eabi-objdump -dR /
PATH/TO/.SO/FILE > tmp
Where "HOST" is the folder in the prebuilt folder, this differs on
each system.
If you look at your debug info you'll se a bunch of there lines:
07-30 09:52:15.289: INFO/DEBUG(28): #00 pc 0000aea4
/system/lib/libc.so
07-30 09:52:15.289: INFO/DEBUG(28): #01 pc 00026810
/data/data/oms.cj.yap/lib/libsdl.so
These are called the stack trace, 'pc' stands for program counter
which is the register that keeps track of what line of assembly that
is currently being executed.
Look for the last entry which was in your file (I'm assuming that
"libapplication" is your file so the last entry with that file would
be 07-30 09:52:15.298: INFO/DEBUG(28): #05 pc 00008b50 /data/data/
oms.cj.yap/lib/libapplication.so)
Now you know that the last function the program ran (last function in
your application at least) contains the address #00008b50.
Now search for 08b50 in the tmp-file (the first three zeros are
omitted), on that line a call should be made to an external
subroutine, now scroll up until you see a function name. Now you know
which function in your program that crashed.
As an example here's a snippet of libc.so:
000188ac <__assert>:
188ac: b530 push {r4, r5, lr}
188ae: 4c07 ldr r4, [pc, #28] (188cc <__assert+0x20>)
188b0: 1c03 adds r3, r0, #0
188b2: 4807 ldr r0, [pc, #28] (188d0 <__assert+0x24>)
188b4: 447c add r4, pc
188b6: 4d07 ldr r5, [pc, #28] (188d4 <__assert+0x28>)
188b8: 5820 ldr r0, [r4, r0]
188ba: b083 sub sp, #12
188bc: 1964 adds r4, r4, r5
188be: 9100 str r1, [sp, #0]
188c0: 30a8 adds r0, #168
188c2: 1c21 adds r1, r4, #0
188c4: f7fc f916 bl 14af4 <fprintf>
188c8: f7f9 fa4c bl 11d64 <abort>
188cc: 7a70 ldrb r0, [r6, #9]
188ce: 0002 lsls r2, r0, #0
188d0: 00a0 lsls r0, r4, #2
188d2: 0000 lsls r0, r0, #0
188d4: 6d0e ldr r6, [r1, #80]
188d6: ffff b5f0 vsli.64 <illegal reg q13.5>, q8, #63
The stack trace was:
#0 pc: #00011d94
#1 pc: #000188c8
In this example the PC we're looking for was #1 (let's pretend that
the first one was in a different file) and the pc at this line is
#000188c8 which means the last call that was made was to "abort" from
the function "__assert", I know this because on the line starting with
"188c8" this is:
188c8: f7f9 fa4c bl 11d64 <abort>
This tells me that abort was called and if a scroll up I see "000188ac
<__assert>:" which tells me that the function in libc.so that I'm
looking for is called __assert.
This usually is enough to figure out what has happened
I hope this helps a bit :)
// Nicklas