Merge pull request #213 from birarda/stacktraces

output stack trace on audio mixer crash
This commit is contained in:
ZappoMan 2013-05-06 15:31:44 -07:00
commit 026016e869
3 changed files with 51 additions and 5 deletions

View file

@ -16,10 +16,13 @@
#include <errno.h>
#include <fstream>
#include <limits>
#include <AgentList.h>
#include <AgentTypes.h>
#include <SharedUtil.h>
#include <StdDev.h>
#include <Stacktrace.h>
#include "AudioRingBuffer.h"
#include "PacketHeaders.h"
@ -71,8 +74,7 @@ void plateauAdditionOfSamples(int16_t &mixSample, int16_t sampleToAdd) {
mixSample = normalizedSample;
}
void *sendBuffer(void *args)
{
void *sendBuffer(void *args) {
int sentBytes;
int nextFrame = 0;
timeval startTime;
@ -255,11 +257,12 @@ void attachNewBufferToAgent(Agent *newAgent) {
}
}
int main(int argc, const char * argv[])
{
AgentList* agentList = AgentList::createInstance(AGENT_TYPE_AUDIO_MIXER, MIXER_LISTEN_PORT);
int main(int argc, const char* argv[]) {
signal(SIGSEGV, printStacktrace);
setvbuf(stdout, NULL, _IOLBF, 0);
AgentList* agentList = AgentList::createInstance(AGENT_TYPE_AUDIO_MIXER, MIXER_LISTEN_PORT);
ssize_t receivedBytes = 0;
agentList->linkedDataCreateCallback = attachNewBufferToAgent;

View file

@ -0,0 +1,27 @@
//
// Stacktrace.cpp
// hifi
//
// Created by Stephen Birarda on 5/6/13.
//
//
#include <signal.h>
#include <stdio.h>
#include <execinfo.h>
#include "Stacktrace.h"
const int NUMBER_OF_STACK_ENTRIES = 20;
void printStacktrace(int signal) {
void* array[NUMBER_OF_STACK_ENTRIES];
// get void*'s for all entries on the stack
size_t size = backtrace(array, NUMBER_OF_STACK_ENTRIES);
// print out all the frames to stderr
fprintf(stderr, "Error: signal %d:\n", signal);
backtrace_symbols_fd(array, size, 2);
exit(1);
}

View file

@ -0,0 +1,16 @@
//
// Stacktrace.h
// hifi
//
// Created by Stephen Birarda on 5/6/13.
//
//
#ifndef __hifi__Stacktrace__
#define __hifi__Stacktrace__
#include <iostream>
void printStacktrace(int signal);
#endif /* defined(__hifi__Stacktrace__) */