Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 <execinfo.h> | 8 #include <execinfo.h> |
| 9 #include <fcntl.h> | 9 #include <fcntl.h> |
| 10 #include <signal.h> | 10 #include <signal.h> |
| (...skipping 25 matching lines...) Expand all Loading... | |
| 36 #include "base/third_party/symbolize/symbolize.h" | 36 #include "base/third_party/symbolize/symbolize.h" |
| 37 #endif | 37 #endif |
| 38 | 38 |
| 39 namespace base { | 39 namespace base { |
| 40 namespace debug { | 40 namespace debug { |
| 41 | 41 |
| 42 namespace { | 42 namespace { |
| 43 | 43 |
| 44 volatile sig_atomic_t in_signal_handler = 0; | 44 volatile sig_atomic_t in_signal_handler = 0; |
| 45 | 45 |
| 46 #if !defined(USE_SYMBOLIZE) && defined(_GLIBCXX__) | |
|
Nico
2013/10/03 19:57:12
Err, this should be __GLIBCXX__ (note two leading
| |
| 46 // The prefix used for mangled symbols, per the Itanium C++ ABI: | 47 // The prefix used for mangled symbols, per the Itanium C++ ABI: |
| 47 // http://www.codesourcery.com/cxx-abi/abi.html#mangling | 48 // http://www.codesourcery.com/cxx-abi/abi.html#mangling |
| 48 const char kMangledSymbolPrefix[] = "_Z"; | 49 const char kMangledSymbolPrefix[] = "_Z"; |
| 49 | 50 |
| 50 // Characters that can be used for symbols, generated by Ruby: | 51 // Characters that can be used for symbols, generated by Ruby: |
| 51 // (('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 |
| 52 const char kSymbolCharacters[] = | 53 const char kSymbolCharacters[] = |
| 53 "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_"; | 54 "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_"; |
| 55 #endif // !defined(USE_SYMBOLIZE) && defined(_GLIBCXX__) | |
| 54 | 56 |
| 55 #if !defined(USE_SYMBOLIZE) | 57 #if !defined(USE_SYMBOLIZE) |
| 56 // Demangles C++ symbols in the given text. Example: | 58 // Demangles C++ symbols in the given text. Example: |
| 57 // | 59 // |
| 58 // "out/Debug/base_unittests(_ZN10StackTraceC1Ev+0x20) [0x817778c]" | 60 // "out/Debug/base_unittests(_ZN10StackTraceC1Ev+0x20) [0x817778c]" |
| 59 // => | 61 // => |
| 60 // "out/Debug/base_unittests(StackTrace::StackTrace()+0x20) [0x817778c]" | 62 // "out/Debug/base_unittests(StackTrace::StackTrace()+0x20) [0x817778c]" |
| 61 void DemangleSymbols(std::string* text) { | 63 void DemangleSymbols(std::string* text) { |
| 62 // Note: code in this function is NOT async-signal safe (std::string uses | 64 // Note: code in this function is NOT async-signal safe (std::string uses |
| 63 // malloc internally). | 65 // malloc internally). |
| (...skipping 483 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 547 *ptr = *start; | 549 *ptr = *start; |
| 548 *start++ = ch; | 550 *start++ = ch; |
| 549 } | 551 } |
| 550 return buf; | 552 return buf; |
| 551 } | 553 } |
| 552 | 554 |
| 553 } // namespace internal | 555 } // namespace internal |
| 554 | 556 |
| 555 } // namespace debug | 557 } // namespace debug |
| 556 } // namespace base | 558 } // namespace base |
| OLD | NEW |