]> git.cworth.org Git - apitrace/blobdiff - common/trace_writer_local.cpp
d3dretrace: Dump D3D10 depth stencil surfaces as float.
[apitrace] / common / trace_writer_local.cpp
index 4d946f5c0a53a50aa5b9ba91d323ffa4d76101a6..529f83b2fbd88b8f5406860d6dece3aef0d8b758 100644 (file)
@@ -36,6 +36,7 @@
 #include "trace_file.hpp"
 #include "trace_writer_local.hpp"
 #include "trace_format.hpp"
+#include "os_backtrace.hpp"
 
 
 namespace trace {
@@ -63,6 +64,8 @@ static void exceptionCallback(void)
 LocalWriter::LocalWriter() :
     acquired(0)
 {
+    os::log("apitrace: loaded\n");
+
     // Install the signal handlers as early as possible, to prevent
     // interfering with the application's signal handling.
     os::setExceptionCallback(exceptionCallback);
@@ -150,7 +153,7 @@ void LocalWriter::checkProcessId(void) {
     }
 }
 
-unsigned LocalWriter::beginEnter(const FunctionSig *sig) {
+unsigned LocalWriter::beginEnter(const FunctionSig *sig, bool fake) {
     mutex.lock();
     ++acquired;
 
@@ -169,7 +172,16 @@ unsigned LocalWriter::beginEnter(const FunctionSig *sig) {
 
     assert(this_thread_num);
     unsigned thread_id = this_thread_num - 1;
-    return Writer::beginEnter(sig, thread_id);
+    unsigned call_no = Writer::beginEnter(sig, thread_id);
+    if (!fake && os::backtrace_is_needed(sig->name)) {
+        std::vector<RawStackFrame> backtrace = os::get_backtrace();
+        beginBacktrace(backtrace.size());
+        for (unsigned i = 0; i < backtrace.size(); ++i) {
+            writeStackFrame(&backtrace[i]);
+        }
+        endBacktrace();
+    }
+    return call_no;
 }
 
 void LocalWriter::endEnter(void) {