summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJose Fonseca <jfonseca@vmware.com>2016-08-27 19:26:19 +0100
committerJose Fonseca <jfonseca@vmware.com>2016-08-27 19:26:19 +0100
commit886e2aeefb352550831aa04643b817926bf7ef01 (patch)
treee98ea53b7caaa9494747d068a0238676ec1bd61b
parent215515ee810d1bd5af408744365870437a75b700 (diff)
glxtrace: Intercept and flush on _exit.
As suggested in https://github.com/apitrace/apitrace/issues/479#issuecomment-239666769
-rw-r--r--lib/os/os_posix.cpp2
-rw-r--r--wrappers/dlsym.cpp21
-rw-r--r--wrappers/glxtrace.version1
3 files changed, 23 insertions, 1 deletions
diff --git a/lib/os/os_posix.cpp b/lib/os/os_posix.cpp
index 74594c3f..7b621dbd 100644
--- a/lib/os/os_posix.cpp
+++ b/lib/os/os_posix.cpp
@@ -285,7 +285,7 @@ long long timeFrequency = 0LL;
void
abort(void)
{
- _exit(1);
+ _Exit(1);
}
diff --git a/wrappers/dlsym.cpp b/wrappers/dlsym.cpp
index d7dc0865..2eda082a 100644
--- a/wrappers/dlsym.cpp
+++ b/wrappers/dlsym.cpp
@@ -228,3 +228,24 @@ void * dlopen(const char *filename, int flag)
return handle;
}
+
+
+#ifdef __linux__
+
+#include "trace_writer_local.hpp"
+
+/*
+ * Intercept _exit so we can flush our trace even when the app (eg. Wine)
+ * aborts.
+ *
+ * TODO: Currently we dispatch to _Exit, but for completness we should
+ * intercept _Exit too.
+ */
+void
+_exit(int status)
+{
+ trace::localWriter.flush();
+ _Exit(status);
+}
+
+#endif /* __linux__ */
diff --git a/wrappers/glxtrace.version b/wrappers/glxtrace.version
index 7d7a1624..0546a05e 100644
--- a/wrappers/glxtrace.version
+++ b/wrappers/glxtrace.version
@@ -4,6 +4,7 @@
_fini;
gl[A-Z]*;
dlopen;
+ _exit;
local:
*;
};