]> git.cworth.org Git - apitrace/blobdiff - common/trace_local_writer.cpp
Bring some of the virtual-memory-regions
[apitrace] / common / trace_local_writer.cpp
index ea6c111eb8756ff6b0fa2386bebf5560d71d766a..e560e498cb7a80dd92378db097fa6b7f8a7d6748 100644 (file)
 namespace Trace {
 
 
+static const char *memcpy_args[3] = {"dest", "src", "n"};
+const FunctionSig memcpy_sig = {0, "memcpy", 3, memcpy_args};
+
+static const char *malloc_args[1] = {"size"};
+const FunctionSig malloc_sig = {1, "malloc", 1, malloc_args};
+
+static const char *free_args[1] = {"ptr"};
+const FunctionSig free_sig = {2, "free", 1, free_args};
+
+static const char *realloc_args[2] = {"ptr", "size"};
+const FunctionSig realloc_sig = {3, "realloc", 2, realloc_args};
+
+
 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 +112,6 @@ LocalWriter::open(void) {
 
     Writer::open(szFileName);
 
-    OS::SetExceptionCallback(exceptionCallback);
-
 #if 0
     // For debugging the exception handler
     *((int *)0) = 0;
@@ -142,6 +156,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();