]> git.cworth.org Git - apitrace/commitdiff
Remove FunctionSig::backtrace member.
authorJosé Fonseca <jose.r.fonseca@gmail.com>
Sat, 4 May 2013 10:10:33 +0000 (11:10 +0100)
committerJosé Fonseca <jose.r.fonseca@gmail.com>
Sat, 4 May 2013 10:10:33 +0000 (11:10 +0100)
Backtraces are really disjoint from signature.

This puts back const keyword in most FunctionSig usages.

common/trace_model.hpp
common/trace_parser.cpp
common/trace_writer.cpp
common/trace_writer.hpp
common/trace_writer_local.cpp
common/trace_writer_local.hpp
wrappers/gltrace.py
wrappers/trace.py

index 7c4cdc78f221528e1b0fa7df7dd7b326b790c24c..fbfa1fbbc989102710a5e4a99cc3eb48a259b9a0 100644 (file)
@@ -49,7 +49,6 @@ struct FunctionSig {
     const char *name;
     unsigned num_args;
     const char **arg_names;
-    bool backtrace;
 };
 
 
@@ -488,14 +487,14 @@ class Call
 public:
     unsigned thread_id;
     unsigned no;
-    FunctionSig *sig;
+    const FunctionSig *sig;
     std::vector<Arg> args;
     Value *ret;
 
     CallFlags flags;
     Backtrace* backtrace;
 
-    Call(FunctionSig *_sig, const CallFlags &_flags, unsigned _thread_id) :
+    Call(const FunctionSig *_sig, const CallFlags &_flags, unsigned _thread_id) :
         thread_id(_thread_id), 
         sig(_sig), 
         args(_sig->num_args), 
index 8ba9bdcdacd6b6003bda0380d5747d9796d8da80..6ccc68dbd1627f416d87ccf4311028ff071f9de0 100644 (file)
@@ -463,7 +463,7 @@ Call *Parser::parse_leave(Mode mode) {
          * between two frames.  We won't return this call, but we still need to skip 
          * over its data.
          */
-        FunctionSig sig = {0, NULL, 0, NULL};
+        const FunctionSig sig = {0, NULL, 0, NULL};
         call = new Call(&sig, 0, 0);
         parse_call_details(call, SCAN);
         delete call;
index 2dc7a00ea8c7502de88304abdbbed2239f425001..be0137619c853cb185abba5d6f84e438c4965e62 100644 (file)
@@ -200,12 +200,11 @@ void Writer::beginStackFrameOffset(void ) {
     _writeByte(trace::CALL_BACKTRACE_OFFSET);
 }
 
-unsigned Writer::beginEnter(FunctionSig *sig, unsigned thread_id) {
+unsigned Writer::beginEnter(const FunctionSig *sig, unsigned thread_id) {
     _writeByte(trace::EVENT_ENTER);
     _writeUInt(thread_id);
     _writeUInt(sig->id);
     if (!lookup(functions, sig->id)) {
-        sig->backtrace = backtrace_is_needed(sig->name);
         _writeString(sig->name);
         _writeUInt(sig->num_args);
         for (unsigned i = 0; i < sig->num_args; ++i) {
index 6440ab9cec41c19375ffb44bcc52b8e56377c065..f8d0afb12bf0261408135897692d60afcc57eabd 100644 (file)
@@ -74,7 +74,7 @@ namespace trace {
         void beginStackFrameOffset(void);
         inline void endStackFrameOffset(void) {}
 
-        unsigned beginEnter(FunctionSig *sig, unsigned thread_id);
+        unsigned beginEnter(const FunctionSig *sig, unsigned thread_id);
         void endEnter(void);
 
         void beginLeave(unsigned call);
index b894bf9d095e775f86fee36f1bd648b55f04808d..866170139c2a45356b3abcef67e482cf3c426b32 100644 (file)
@@ -43,16 +43,16 @@ namespace trace {
 
 
 static const char *memcpy_args[3] = {"dest", "src", "n"};
-FunctionSig memcpy_sig = {0, "memcpy", 3, memcpy_args, false};
+const FunctionSig memcpy_sig = {0, "memcpy", 3, memcpy_args};
 
 static const char *malloc_args[1] = {"size"};
-FunctionSig malloc_sig = {1, "malloc", 1, malloc_args, false};
+const FunctionSig malloc_sig = {1, "malloc", 1, malloc_args};
 
 static const char *free_args[1] = {"ptr"};
-FunctionSig free_sig = {2, "free", 1, free_args, false};
+const FunctionSig free_sig = {2, "free", 1, free_args};
 
 static const char *realloc_args[2] = {"ptr", "size"};
-FunctionSig realloc_sig = {3, "realloc", 2, realloc_args, false};
+const FunctionSig realloc_sig = {3, "realloc", 2, realloc_args};
 
 
 static void exceptionCallback(void)
@@ -134,7 +134,7 @@ static uintptr_t next_thread_num = 1;
 static OS_THREAD_SPECIFIC_PTR(void)
 thread_num;
 
-unsigned LocalWriter::beginEnter(FunctionSig *sig) {
+unsigned LocalWriter::beginEnter(const FunctionSig *sig, bool fake) {
     mutex.lock();
     ++acquired;
 
@@ -153,7 +153,7 @@ unsigned LocalWriter::beginEnter(FunctionSig *sig) {
     assert(this_thread_num);
     unsigned thread_id = this_thread_num - 1;
     unsigned call_no = Writer::beginEnter(sig, thread_id);
-    if (sig->backtrace) {
+    if (!fake) {
         std::vector<RawStackFrame> backtrace = get_backtrace();
         beginBacktrace();
         writeBacktrace(backtrace);
index 1da22501d41dbe52291bacd5b1679d3073734885..1859354055c672f39b25ec96ea1ccd49a1f1d84d 100644 (file)
 
 namespace trace {
 
-    extern FunctionSig memcpy_sig;
-    extern FunctionSig malloc_sig;
-    extern FunctionSig free_sig;
-    extern FunctionSig realloc_sig;
+    extern const FunctionSig memcpy_sig;
+    extern const FunctionSig malloc_sig;
+    extern const FunctionSig free_sig;
+    extern const FunctionSig realloc_sig;
 
     /**
      * A specialized Writer class, mean to trace the current process.
@@ -83,7 +83,7 @@ namespace trace {
         /**
          * It will acquire the mutex.
          */
-        unsigned beginEnter(FunctionSig *sig);
+        unsigned beginEnter(const FunctionSig *sig, bool fake = false);
 
         /**
          * It will release the mutex.
index fcb48bba5d71c2ceedffd0a8ce6bd7a0d28450e1..c40fbb36de62aaac143a13ab1acf9b4e894f659f 100644 (file)
@@ -520,7 +520,7 @@ class GlTracer(Tracer):
 
                     # Emit a fake function
                     print '        {'
-                    print '            static trace::FunctionSig &_sig = %s ? _glEnableClientState_sig : _glDisableClientState_sig;' % flag_name
+                    print '            static const trace::FunctionSig &_sig = %s ? _glEnableClientState_sig : _glDisableClientState_sig;' % flag_name
                     print '            unsigned _call = trace::localWriter.beginEnter(&_sig);'
                     print '            trace::localWriter.beginArg(0);'
                     self.serializeValue(glapi.GLenum, enable_name)
index 9ff541049fcfc93abaf46c081f625aeeb1a230a4..252db492213e952eed68163af3b3094f8ce09856 100644 (file)
@@ -452,7 +452,7 @@ class Tracer:
                 print 'static const char * _%s_args[%u] = {%s};' % (function.name, len(function.args), ', '.join(['"%s"' % arg.name for arg in function.args]))
             else:
                 print 'static const char ** _%s_args = NULL;' % (function.name,)
-            print 'static trace::FunctionSig _%s_sig = {%u, "%s", %u, _%s_args};' % (function.name, self.getFunctionSigId(), function.name, len(function.args), function.name)
+            print 'static const trace::FunctionSig _%s_sig = {%u, "%s", %u, _%s_args};' % (function.name, self.getFunctionSigId(), function.name, len(function.args), function.name)
             print
 
     def getFunctionSigId(self):
@@ -685,7 +685,7 @@ class Tracer:
         assert not method.internal
 
         print '    static const char * _args[%u] = {%s};' % (len(method.args) + 1, ', '.join(['"this"'] + ['"%s"' % arg.name for arg in method.args]))
-        print '    static trace::FunctionSig _sig = {%u, "%s", %u, _args};' % (self.getFunctionSigId(), interface.name + '::' + method.name, len(method.args) + 1)
+        print '    static const trace::FunctionSig _sig = {%u, "%s", %u, _args};' % (self.getFunctionSigId(), interface.name + '::' + method.name, len(method.args) + 1)
 
         print '    %s *_this = static_cast<%s *>(m_pInstance);' % (base, base)
 
@@ -782,7 +782,7 @@ class Tracer:
         print '    %s_this->%s(%s);' % (result, method.name, ', '.join([str(arg.name) for arg in method.args]))
     
     def emit_memcpy(self, dest, src, length):
-        print '        unsigned _call = trace::localWriter.beginEnter(&trace::memcpy_sig);'
+        print '        unsigned _call = trace::localWriter.beginEnter(&trace::memcpy_sig, true);'
         print '        trace::localWriter.beginArg(0);'
         print '        trace::localWriter.writePointer((uintptr_t)%s);' % dest
         print '        trace::localWriter.endArg();'