Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(921)

Unified Diff: base/debug_util_posix.cc

Issue 3544004: symbolize: don't stringify errno if we're using google::Symbolize. (Closed) Base URL: http://src.chromium.org/git/chromium.git
Patch Set: Created 10 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/debug_util_posix.cc
diff --git a/base/debug_util_posix.cc b/base/debug_util_posix.cc
index dfafc13bfae55a632dae35aa05971aea40082d81..7d7aca4c63687d1851e6baffd76b696805ba6cf8 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) {
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698