Skip to content

Instantly share code, notes, and snippets.

@Gautier
Created July 13, 2010 10:34
Show Gist options
  • Save Gautier/473710 to your computer and use it in GitHub Desktop.
Save Gautier/473710 to your computer and use it in GitHub Desktop.
Index: sources/rtmpserver/src/rtmpserver.cpp
===================================================================
--- sources/rtmpserver/src/rtmpserver.cpp (revision 1315)
+++ sources/rtmpserver/src/rtmpserver.cpp (working copy)
@@ -27,6 +27,8 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
+#include <stdlib.h>
+#include <execinfo.h>
#include "netio/netio.h"
#include "configuration/configfile.h"
#include "protocols/protocolmanager.h"
@@ -63,11 +65,13 @@
RunningStatus gRs = {0};
+void print_trace(int nSig);
int main(int argc, char **argv) {
//1. Pick up the startup parameters and hold them inside the running status
gRs.argc = argc;
gRs.argv = argv;
+signal(SIGSEGV, print_trace);
do {
//2. Reset the run flag
gRs.run = false;
@@ -238,3 +242,22 @@
gRs.run = true;
IOHandlerManager::SignalShutdown();
}
+
+void print_trace(int nSig) {
+ printf("print_trace: got signal %d\n", nSig);
+
+ void *array[32]; /* Array to store backtrace symbols */
+ size_t size; /* To store the exact no of values stored */
+ char **strings; /* To store functions from the backtrace list in ARRAY */
+ size_t nCnt;
+
+ size = backtrace(array, 32);
+
+ strings = backtrace_symbols(array, size);
+
+ /* prints each string of function names of trace*/
+ for (nCnt = 0; nCnt < size; nCnt++)
+ fprintf(stderr, "%s\n", strings[nCnt]);
+
+ exit(-1);
+}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment