From 9acebf9ca871b3f9a5dfba0ac4f3a9c562c12ff0 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Jos=C3=A9=20Fonseca?= Date: Thu, 22 Sep 2011 17:49:24 +0100 Subject: [PATCH] Install the signal handlers as early as possible, To prevent interfering with the application's signal handling. --- common/trace_local_writer.cpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/common/trace_local_writer.cpp b/common/trace_local_writer.cpp index ea6c111..e625f2e 100644 --- a/common/trace_local_writer.cpp +++ b/common/trace_local_writer.cpp @@ -41,14 +41,17 @@ namespace Trace { static void exceptionCallback(void) { - OS::DebugMessage("apitrace: flushing trace due to an exception\n"); localWriter.flush(); } LocalWriter::LocalWriter() : acquired(0) -{} +{ + // Install the signal handlers as early as possible, to prevent + // interfering with the application's signal handling. + OS::SetExceptionCallback(exceptionCallback); +} LocalWriter::~LocalWriter() { @@ -96,8 +99,6 @@ LocalWriter::open(void) { Writer::open(szFileName); - OS::SetExceptionCallback(exceptionCallback); - #if 0 // For debugging the exception handler *((int *)0) = 0; @@ -142,6 +143,7 @@ void LocalWriter::flush(void) { if (!acquired) { OS::AcquireMutex(); if (m_file->isOpened()) { + OS::DebugMessage("apitrace: flushing trace due to an exception\n"); m_file->flush(); } OS::ReleaseMutex(); -- 2.43.0