|
||||
File indexing completed on 2025-01-18 09:27:16
0001 // Copyright 2018 The Abseil Authors. 0002 // 0003 // Licensed under the Apache License, Version 2.0 (the "License"); 0004 // you may not use this file except in compliance with the License. 0005 // You may obtain a copy of the License at 0006 // 0007 // https://www.apache.org/licenses/LICENSE-2.0 0008 // 0009 // Unless required by applicable law or agreed to in writing, software 0010 // distributed under the License is distributed on an "AS IS" BASIS, 0011 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 0012 // See the License for the specific language governing permissions and 0013 // limitations under the License. 0014 0015 #ifndef ABSL_DEBUGGING_INTERNAL_DEMANGLE_H_ 0016 #define ABSL_DEBUGGING_INTERNAL_DEMANGLE_H_ 0017 0018 #include <string> 0019 #include "absl/base/config.h" 0020 0021 namespace absl { 0022 ABSL_NAMESPACE_BEGIN 0023 namespace debugging_internal { 0024 0025 // Demangle `mangled`. On success, return true and write the 0026 // demangled symbol name to `out`. Otherwise, return false. 0027 // `out` is modified even if demangling is unsuccessful. 0028 // 0029 // This function provides an alternative to libstdc++'s abi::__cxa_demangle, 0030 // which is not async signal safe (it uses malloc internally). It's intended to 0031 // be used in async signal handlers to symbolize stack traces. 0032 // 0033 // Note that this demangler doesn't support full demangling. More 0034 // specifically, it doesn't print types of function parameters and 0035 // types of template arguments. It just skips them. However, it's 0036 // still very useful to extract basic information such as class, 0037 // function, constructor, destructor, and operator names. 0038 // 0039 // See the implementation note in demangle.cc if you are interested. 0040 // 0041 // Example: 0042 // 0043 // | Mangled Name | Demangle | DemangleString 0044 // |---------------|-------------|----------------------- 0045 // | _Z1fv | f() | f() 0046 // | _Z1fi | f() | f(int) 0047 // | _Z3foo3bar | foo() | foo(bar) 0048 // | _Z1fIiEvi | f<>() | void f<int>(int) 0049 // | _ZN1N1fE | N::f | N::f 0050 // | _ZN3Foo3BarEv | Foo::Bar() | Foo::Bar() 0051 // | _Zrm1XS_" | operator%() | operator%(X, X) 0052 // | _ZN3FooC1Ev | Foo::Foo() | Foo::Foo() 0053 // | _Z1fSs | f() | f(std::basic_string<char, 0054 // | | | std::char_traits<char>, 0055 // | | | std::allocator<char> >) 0056 // 0057 // See the unit test for more examples. 0058 // 0059 // Demangle also recognizes Rust mangled names by delegating the parsing of 0060 // anything that starts with _R to DemangleRustSymbolEncoding (demangle_rust.h). 0061 // 0062 // Note: we might want to write demanglers for ABIs other than Itanium 0063 // C++ ABI in the future. 0064 bool Demangle(const char* mangled, char* out, size_t out_size); 0065 0066 // A wrapper around `abi::__cxa_demangle()`. On success, returns the demangled 0067 // name. On failure, returns the input mangled name. 0068 // 0069 // This function is not async-signal-safe. 0070 std::string DemangleString(const char* mangled); 0071 0072 } // namespace debugging_internal 0073 ABSL_NAMESPACE_END 0074 } // namespace absl 0075 0076 #endif // ABSL_DEBUGGING_INTERNAL_DEMANGLE_H_
[ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |