summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorevan@chromium.org <evan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-09-29 23:41:59 +0000
committerevan@chromium.org <evan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-09-29 23:41:59 +0000
commit6adad206bfe6b833350eb0ec674f062070b1f6ae (patch)
tree6a371413b6f0f6c3751e033eee878856808f0af3
parent5d39f5f4f6cd9f5b90b59d1c3ee2587e3cdeda3b (diff)
downloadchromium_src-6adad206bfe6b833350eb0ec674f062070b1f6ae.zip
chromium_src-6adad206bfe6b833350eb0ec674f062070b1f6ae.tar.gz
chromium_src-6adad206bfe6b833350eb0ec674f062070b1f6ae.tar.bz2
symbolize: don't stringify errno if we're using google::Symbolize.
This prevents us from printing out confusing error messages like: Unable to get symbols for backtrace (Success). BUG=57305 TEST=ran locally, saw no error Review URL: http://codereview.chromium.org/3544004 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@61010 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--base/debug_util_posix.cc19
1 files changed, 13 insertions, 6 deletions
diff --git a/base/debug_util_posix.cc b/base/debug_util_posix.cc
index dfafc13..7d7aca4 100644
--- a/base/debug_util_posix.cc
+++ b/base/debug_util_posix.cc
@@ -99,9 +99,11 @@ void DemangleSymbols(std::string* text) {
// Gets the backtrace as a vector of strings. If possible, resolve symbol
// names and attach these. Otherwise just use raw addresses. Returns true
-// if any symbol name is resolved.
+// if any symbol name is resolved. Returns false on error and *may* fill
+// in |error_message| if an error message is available.
bool GetBacktraceStrings(void **trace, int size,
- std::vector<std::string>* trace_strings) {
+ std::vector<std::string>* trace_strings,
+ std::string* error_message) {
bool symbolized = false;
#if defined(USE_SYMBOLIZE)
@@ -130,6 +132,8 @@ bool GetBacktraceStrings(void **trace, int size,
}
symbolized = true;
} else {
+ if (error_message)
+ *error_message = safe_strerror(errno);
for (int i = 0; i < size; ++i) {
trace_strings->push_back(base::StringPrintf("%p", trace[i]));
}
@@ -282,7 +286,7 @@ void StackTrace::PrintBacktrace() {
#endif
fflush(stderr);
std::vector<std::string> trace_strings;
- GetBacktraceStrings(trace_, count_, &trace_strings);
+ GetBacktraceStrings(trace_, count_, &trace_strings, NULL);
for (size_t i = 0; i < trace_strings.size(); ++i) {
std::cerr << "\t" << trace_strings[i] << "\n";
}
@@ -294,11 +298,14 @@ void StackTrace::OutputToStream(std::ostream* os) {
return;
#endif
std::vector<std::string> trace_strings;
- if (GetBacktraceStrings(trace_, count_, &trace_strings)) {
+ std::string error_message;
+ if (GetBacktraceStrings(trace_, count_, &trace_strings, &error_message)) {
(*os) << "Backtrace:\n";
} else {
- (*os) << "Unable get symbols for backtrace (" << safe_strerror(errno)
- << "). Dumping raw addresses in trace:\n";
+ if (!error_message.empty())
+ error_message = " (" + error_message + ")";
+ (*os) << "Unable to get symbols for backtrace" << error_message << ". "
+ << "Dumping raw addresses in trace:\n";
}
for (size_t i = 0; i < trace_strings.size(); ++i) {