]> git.cworth.org Git - apitrace/commitdiff
common: Cleanup backtrace.
authorAlexander Monakov <amonakov@ispras.ru>
Mon, 13 May 2013 14:35:44 +0000 (15:35 +0100)
committerJosé Fonseca <jfonseca@vmware.com>
Mon, 13 May 2013 14:35:44 +0000 (15:35 +0100)
There was a bool field that was caching results of 'is_backtrace_needed'
lookups.   Now that field is gone, and 'is_backtrace_needed' is called
repeatedly.  I guess it's not that bad (it boils down to a lookup in an
std::set), but that function was also printing notices for functions
with enabled stack trace recording, and now those messages are printed
repeatedly as well.  The following patch removes the notices completely
and slightly cleans up the surrounding code.

common/trace_backtrace.cpp

index d0bdd5ad27f38bab1f5a710bf61e73dffca2904e..730cfef0bed765be2747b57aa3810a183b9f1664 100644 (file)
@@ -70,8 +70,7 @@ struct pstring {
 class StringPrefixes {
 private:
     std::set<pstring> pset;
-    char* buf;
-private:
+
     void addPrefix(char* startbuf, int n) {
         std::set<pstring>::iterator elem = pset.find(pstring(startbuf, n));
         bool replace = elem != pset.end() && n < elem->n;
@@ -86,11 +85,7 @@ public:
     StringPrefixes(const char* source);
 
     bool contain(const char* s) {
-        if (pset.find(pstring(s, strlen(s) + 1)) != pset.end()) {
-            os::log("Backtrace for %s is enabled", s);
-            return true;
-        }
-        return false;
+        return pset.find(pstring(s, strlen(s) + 1)) != pset.end();
     }
 };
 
@@ -110,7 +105,7 @@ bool backtrace_is_needed(const char* fname) {
 namespace trace {
 
 StringPrefixes::StringPrefixes(const char* source) {
-    buf = (char*)malloc(sizeof(char) * PREFIX_BUF_SIZE);
+    char* buf = (char*)malloc(sizeof(char) * PREFIX_BUF_SIZE);
     char* startbuf = buf;
     int n = 0;
     FILE* f = fopen(source, "r");
@@ -303,7 +298,7 @@ namespace trace {
 
 
 StringPrefixes::StringPrefixes(const char* source) {
-    buf = (char*)malloc(sizeof(char) * PREFIX_BUF_SIZE);
+    char* buf = (char*)malloc(sizeof(char) * PREFIX_BUF_SIZE);
     char* startbuf = buf;
     int n = 0;
     char* s = getenv(source);