vertextao
vertextao

Reputation: 63

Android ARM C++ exception debugging

I've got a backtrace stack of my program (running on Android ARM), like this:

#00 pc 0001d796 /system/lib/libc.so (abort+57) [armeabi-v7a]
#01 pc 0004f663 libxx.so (__gnu_cxx::__verbose_terminate_handler()+226) [armeabi-v7a]
#02 pc 00024709 libxx.so (__cxxabiv1::__terminate(void (*)())+4) [armeabi-v7a]
#03 pc 0002477d libxx.so (std::terminate()+8) [armeabi-v7a]
#04 pc 0058f3d3 libxxx_sdk.so [armeabi-v7a]
#05 pc 00065ac7 /system/lib/libc.so (__pthread_start(void*)+22) [armeabi-v7a]
#06 pc 0001e9ad /system/lib/libc.so (__start_thread+32) [armeabi-v7a]

This was probably cased by an exception, but I can't figure out the right place in libxxx_sdk.so threw this exception.

So, is there any thing I can do to make the backtrace more valuable for me to figure out the right issue?

Note:

Update 1

I used objdump -Cd to dump the libxxx_sdk.so, and located the address near by 0058f3d3, but still can't know who called the __pointer_catch below:

0055c290 <__cxxabiv1::__pointer_type_info::__pointer_catch(__cxxabiv1::__pbase_type_info const*, void**, unsigned int) const>:
~~~
...
~~~
  58f3c0:       e7d7            b.n     58f372 <__cxxabiv1::__pointer_type_info::__pointer_catch(__cxxabiv1::__pbase_type_info const*, void**, unsigned int) const+0x330e2>
  58f3c2:       2901            cmp     r1, #1
  58f3c4:       d103            bne.n   58f3ce <__cxxabiv1::__pointer_type_info::__pointer_catch(__cxxabiv1::__pbase_type_info const*, void**, unsigned int) const+0x3313e>
  58f3c6:       f7ed e486       blx     17ccd4 <__cxa_begin_catch@plt>
  58f3ca:       f7ed e73c       blx     17d244 <__cxa_rethrow@plt>
  58f3ce:       f7ed e482       blx     17ccd4 <__cxa_begin_catch@plt>
  58f3d2:       f7ee e136       blx     17d640 <std::terminate()@plt>
  58f3d6:       f7ed e484       blx     17cce0 <__cxa_end_catch@plt>
  58f3da:       b114            cbz     r4, 58f3e2 <__cxxabiv1::__pointer_type_info::__pointer_catch(__cxxabiv1::__pbase_type_info const*, void**, unsigned int) const+0x33152>
  58f3dc:       4620            mov     r0, r4
...
~~~

Thanks!

Upvotes: 0

Views: 74

Answers (1)

Employed Russian
Employed Russian

Reputation: 213789

I can't figure out the right place in libxxx_sdk.so

The stack trace suggests that libxxx_sdk.so is fully stripped. Don't do that if you want to be able to debug it.

In order to determine location in libxxx_sdk.so that corresponds to address 0x058f3d3, you need to know what address that library was loaded at. Since you don't currently have that info, you may wish to add logging to the library, so that every time it is loaded you log the address of some function in it (let's call it fn). Next time it crashes, you'll be able to subtract the logged value of &fn from the crash address, and add &fn from nm libxxx_sdk.so output, to get the address of crashing function.

Alternatively, you can examine every instruction at address ending with 0x3d3 in libxxx_sdk.so to find one that calls __throw. If there is only one such instruction, it's probably the one that threw the exception.

Upvotes: 1

Related Questions