diff options
author | Alexander Monakov <amonakov@ispras.ru> | 2013-05-13 15:35:44 +0100 |
---|---|---|
committer | José Fonseca <jfonseca@vmware.com> | 2013-05-13 15:35:44 +0100 |
commit | 825bb152a877152c8fd77fd5edc75b5c027023f0 (patch) | |
tree | e6de87ee783cfb71942ab1a0343281dd7c74b2b3 | |
parent | 9d1b1c55ac7204dbbedee97ce52c2cd1def2fd5b (diff) |
common: Cleanup backtrace.
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.
-rw-r--r-- | common/trace_backtrace.cpp | 13 |
1 files changed, 4 insertions, 9 deletions
diff --git a/common/trace_backtrace.cpp b/common/trace_backtrace.cpp index d0bdd5ad..730cfef0 100644 --- a/common/trace_backtrace.cpp +++ b/common/trace_backtrace.cpp @@ -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); |