Android基础:cpp打印backtrace

作者: 我在等你回复可你没回 | 来源:发表于2018-03-28 18:09 被阅读81次

在cpp打印backtrace对于了解繁杂的系统很有用。例如Android什么时候获取到ServiceManager的。我们可以打下backtrace看看。

在frameworks/native/libs/binder/ProcessState.cpp

sp<IBinder> ProcessState::getContextObject(const sp<IBinder>& /*caller*/)
{
    CallStack stack("Fuck");  //添加这句
    return getStrongProxyForHandle(0);
}

结果如下,可以看到trace啦!

01-17 13:05:08.626  1993  1993 D Fuck    : #00 pc 0000000000075fd4  /system/lib64/libbinder.so (android::ProcessState::getContextObject(android::sp<android::IBinder> const&)+112)
01-17 13:05:08.626  1993  1993 D Fuck    : #01 pc 0000000000058464  /system/lib64/libbinder.so (android::defaultServiceManager()+136)
01-17 13:05:08.626  1993  1993 D Fuck    : #02 pc 000000000003ad9c  /system/lib64/libaudioclient.so (android::AudioSystem::get_audio_flinger()+104)
01-17 13:05:08.626  1993  1993 D Fuck    : #03 pc 000000000003c3fc  /system/lib64/libaudioclient.so (android::AudioSystem::getParameters(int, android::String8 const&)+96)
01-17 13:05:08.626  1993  1993 D Fuck    : #04 pc 000000000014be68  /system/lib64/libandroid_runtime.so
01-17 13:05:08.626  1993  1993 D Fuck    : #05 pc 0000000000519ffc  /system/framework/arm64/boot-framework.oat (offset 0x656000)

参考:https://www.baidu.com/link?url=8Y4zcA_5EdyLUVB6jafQuH4vk3s68wrPchfLO2LoJBcX8LFLIJFvs1maMvysmFagFt2vYv0GOljgh1f0pzz5ra&wd=&eqid=971b8f3a0006778b000000065abb5cb5

相关文章

网友评论

    本文标题:Android基础:cpp打印backtrace

    本文链接:https://www.haomeiwen.com/subject/piducftx.html