Question

Okay, my NDK app crashes with info like that:

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)

How I want to locate this crash in my C++ code.

What does +249 or +20 mean in backtrace above? I guess it's some offset from start of the routine to the call of subroutine. But in what units is it measured?

How can ip 00000003 help me? I guess it's an instruction pointer... and what?

My C++ code looks like

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
}

Can anybody help me to find corellation between those magic numbers from the crash report and this C++ code?

Was it helpful?

Solution

You should have a look at ndk-stack, located at the root of your Android NDK directory. It converts such a crash report into some more human-readable crash stack.

Just pipe the logcat into it and specify the location of your library:

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

(assuming both adb and ndk-stack are in your path, otherwise use the full path)

Hope this helps!

OTHER TIPS

NDK toolchains include a tool called addr2line. You can interpret

#00 pc 000dec36 /mnt/asec/com.myapp/lib/myapp.so     (HWLayer::SoundManagerImpl::MyChannel::start(SLEngineItf_ const* const*, SLObjectItf_ const* const*, HWLayer::SndChannelData const&)+249)

like this (for arm gcc toolchain):

~/android-ndk-r9d/toolchains/arm-linux-androideabi-4.8/prebuilt/linux-x86_64/bin/arm-linux-androideabi-addr2line -Cf -e obj/local/armeabi/myapp.so dec36

Note that I provide the --executable from the obj directory, there I have the .so file with extra infprmation, which is stripped when installed into libs/armeabi.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top