gpt4 book ai didi

android - 了解 Android Native 代码崩溃报告

转载 作者:太空宇宙 更新时间:2023-11-04 15:41:04 25 4
gpt4 key购买 nike

好吧,我的 NDK 应用崩溃了,信息如下:

signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 00000000
r0 00000000 r1 0009a830 r2 698a2efc r3 2a63f4da
r4 66db37ac r5 698a2efc r6 6b843b14 r7 66d89ed4
r8 6b6e0ff5 r9 6b746000 sl 697e0680 fp 401912ec
ip 00000003 sp 6b843a90 lr 66d9d7dd pc 6b69ac36 cpsr 000d0030
d0 4c555345525f4c53 d1 4e4f434552505f54
d2 5f534e4f49544944 d3 444554414c4f4956
d4 0000000000000000 d5 000000003f800000
d6 000084c03f800000 d7 3f8000003f800000
d8 0000000000000000 d9 0000000000000000
d10 0000000000000000 d11 0000000000000000
d12 0000000000000000 d13 0000000000000000
d14 0000000000000000 d15 0000000000000000
d16 00000a3dcc4f35c1 d17 ffff000000010000
d18 3ff8099d80000000 d19 0000000000000000
d20 3ff0000000000000 d21 0000000000000000
d22 c040000000000000 d23 0000000000000000
d24 3ff8099d80000000 d25 0000000000000000
d26 3ff0000000000000 d27 0000000000000000
d28 3ff8099d80000000 d29 c040000000000000
d30 0000000000000000 d31 0000000000000000
scr 20000010

backtrace:
#00 pc 000dec36 /mnt/asec/com.myapp/lib/myapp.so (HWLayer::SoundManagerImpl::MyChannel::start(SLEngineItf_ const* const*, SLObjectItf_ const* const*, HWLayer::SndChannelData const&)+249)
#01 pc 000decb1 /mnt/asec/com.myapp/lib/myapp.so (HWLayer::SoundManagerImpl::startChannel(HWLayer::SndChannelData const&)+20)
#02 pc 000cb2f3 /mnt/asec/com.myapp/lib/myapp.so (ChannelController::start(GPSoundObjectImpl*, bool)+242)

我想如何在我的 C++ 代码中定位此崩溃。

+249+20 在上面的回溯中是什么意思?我想这是从例程开始到子例程调用的一些偏移量。但它是用什么单位来衡量的?

ip 00000003 如何帮助我?我想这是一个指令指针……什么?

我的 C++ 代码看起来像

void SoundManagerImpl::startChannel( const SndChannelData& data )
{
int const nChannel = data.nChannel;
dbgAssert(nChannel >= 0 && nChannel < m_maxNumChannels);
m_channels[nChannel].start(m_engineEngine, m_outputMix, data);
}

void SoundManagerImpl::MyChannel::start(SLEngineItf engine, SLObjectItf outputMix, SndChannelData const &data)
{
stop();

dbgAssertEq(16, data.bps);
m_numPlayedPages = 0;
m_pBuffer1 = data.pBuffer1;
m_pBuffer2 = data.pBuffer2;

SLresult status;
SLDataLocator_BufferQueue bufferQueue;
SLDataFormat_PCM pcm;
SLDataSource audioSource;
audioSource.pFormat = &pcm;
audioSource.pLocator = &bufferQueue;

/* Setup the data source structure for the buffer queue */
bufferQueue.locatorType = SL_DATALOCATOR_BUFFERQUEUE;
bufferQueue.numBuffers = data.nTotalPages;
/* Setup the format of the content in the buffer queue */
pcm.formatType = SL_DATAFORMAT_PCM;
pcm.numChannels = (m_pBuffer2 != 0) ? 2 : 1;
pcm.samplesPerSec = /*SL_SAMPLINGRATE_44_1*/data.sampleRate * 1000;
pcm.bitsPerSample = /*SL_PCMSAMPLEFORMAT_FIXED_16*/data.bps;
pcm.containerSize = pcm.bitsPerSample;
pcm.channelMask = 1 == pcm.numChannels ? SL_SPEAKER_FRONT_CENTER : (SL_SPEAKER_FRONT_LEFT | SL_SPEAKER_FRONT_RIGHT);
pcm.endianness = SL_BYTEORDER_LITTLEENDIAN;

SLDataSink audioSink;
SLDataLocator_OutputMix locator_outputmix;
locator_outputmix.locatorType = SL_DATALOCATOR_OUTPUTMIX;
locator_outputmix.outputMix = outputMix;
audioSink.pLocator = &locator_outputmix;
audioSink.pFormat = 0;

static SLboolean const s_required[] = {SL_BOOLEAN_TRUE, SL_BOOLEAN_TRUE};
static SLInterfaceID const s_iidArray[] = {SL_IID_BUFFERQUEUE, SL_IID_VOLUME};
dbgCompileAssert(GP_PLAIN_ARRAY_LEN(s_required) == GP_PLAIN_ARRAY_LEN(s_iidArray));

status = (*engine)->CreateAudioPlayer(engine, &m_player, &audioSource, &audioSink,
GP_PLAIN_ARRAY_LEN(s_required), s_iidArray, s_required);
dbgAssertEq(SL_RESULT_SUCCESS, status);

// ... and so on
}

谁能帮我找到崩溃报告中的魔数(Magic Number)和这段 C++ 代码之间的相关性?

最佳答案

您应该查看位于 Android NDK 目录根目录下的 ndk-stack。它将此类崩溃报告转换为一些更易于人类阅读的崩溃堆栈。

只需将 logcat 通过管道传输到其中并指定您的库的位置:

adb logcat | ndk-stack -sym /path/to/myapp.so

(假设 adbndk-stack 都在你的路径中,否则使用完整路径)

希望这对您有所帮助!

关于android - 了解 Android Native 代码崩溃报告,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22911679/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com