| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "base/debug/stack_trace.h" | 5 #include "base/debug/stack_trace.h" |
| 6 | 6 |
| 7 #include <errno.h> | 7 #include <errno.h> |
| 8 #include <fcntl.h> | 8 #include <fcntl.h> |
| 9 #include <stdio.h> | 9 #include <stdio.h> |
| 10 #include <stdlib.h> | 10 #include <stdlib.h> |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 49 const char kMangledSymbolPrefix[] = "_Z"; | 49 const char kMangledSymbolPrefix[] = "_Z"; |
| 50 | 50 |
| 51 // Characters that can be used for symbols, generated by Ruby: | 51 // Characters that can be used for symbols, generated by Ruby: |
| 52 // (('a'..'z').to_a+('A'..'Z').to_a+('0'..'9').to_a + ['_']).join | 52 // (('a'..'z').to_a+('A'..'Z').to_a+('0'..'9').to_a + ['_']).join |
| 53 const char kSymbolCharacters[] = | 53 const char kSymbolCharacters[] = |
| 54 "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_"; | 54 "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_"; |
| 55 | 55 |
| 56 #if !defined(USE_SYMBOLIZE) | 56 #if !defined(USE_SYMBOLIZE) |
| 57 // Demangles C++ symbols in the given text. Example: | 57 // Demangles C++ symbols in the given text. Example: |
| 58 // | 58 // |
| 59 // "sconsbuild/Debug/base_unittests(_ZN10StackTraceC1Ev+0x20) [0x817778c]" | 59 // "out/Debug/base_unittests(_ZN10StackTraceC1Ev+0x20) [0x817778c]" |
| 60 // => | 60 // => |
| 61 // "sconsbuild/Debug/base_unittests(StackTrace::StackTrace()+0x20) [0x817778c]" | 61 // "out/Debug/base_unittests(StackTrace::StackTrace()+0x20) [0x817778c]" |
| 62 void DemangleSymbols(std::string* text) { | 62 void DemangleSymbols(std::string* text) { |
| 63 #if defined(__GLIBCXX__) | 63 #if defined(__GLIBCXX__) |
| 64 | 64 |
| 65 std::string::size_type search_from = 0; | 65 std::string::size_type search_from = 0; |
| 66 while (search_from < text->size()) { | 66 while (search_from < text->size()) { |
| 67 // Look for the start of a mangled symbol, from search_from. | 67 // Look for the start of a mangled symbol, from search_from. |
| 68 std::string::size_type mangled_start = | 68 std::string::size_type mangled_start = |
| 69 text->find(kMangledSymbolPrefix, search_from); | 69 text->find(kMangledSymbolPrefix, search_from); |
| 70 if (mangled_start == std::string::npos) { | 70 if (mangled_start == std::string::npos) { |
| 71 break; // Mangled symbol not found. | 71 break; // Mangled symbol not found. |
| (...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 190 << "Dumping raw addresses in trace:\n"; | 190 << "Dumping raw addresses in trace:\n"; |
| 191 } | 191 } |
| 192 | 192 |
| 193 for (size_t i = 0; i < trace_strings.size(); ++i) { | 193 for (size_t i = 0; i < trace_strings.size(); ++i) { |
| 194 (*os) << "\t" << trace_strings[i] << "\n"; | 194 (*os) << "\t" << trace_strings[i] << "\n"; |
| 195 } | 195 } |
| 196 } | 196 } |
| 197 | 197 |
| 198 } // namespace debug | 198 } // namespace debug |
| 199 } // namespace base | 199 } // namespace base |
| OLD | NEW |