Add ICU message format support
[chromium-blink-merge.git] / base / third_party / symbolize / demangle.h
blob9c7591527c0f1af693a030848866ddab8d76eba6
1 // Copyright (c) 2006, Google Inc.
2 // All rights reserved.
3 //
4 // Redistribution and use in source and binary forms, with or without
5 // modification, are permitted provided that the following conditions are
6 // met:
7 //
8 // * Redistributions of source code must retain the above copyright
9 // notice, this list of conditions and the following disclaimer.
10 // * Redistributions in binary form must reproduce the above
11 // copyright notice, this list of conditions and the following disclaimer
12 // in the documentation and/or other materials provided with the
13 // distribution.
14 // * Neither the name of Google Inc. nor the names of its
15 // contributors may be used to endorse or promote products derived from
16 // this software without specific prior written permission.
18 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
22 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 // Author: Satoru Takabayashi
32 // An async-signal-safe and thread-safe demangler for Itanium C++ ABI
33 // (aka G++ V3 ABI).
35 // The demangler is implemented to be used in async signal handlers to
36 // symbolize stack traces. We cannot use libstdc++'s
37 // abi::__cxa_demangle() in such signal handlers since it's not async
38 // signal safe (it uses malloc() internally).
40 // Note that this demangler doesn't support full demangling. More
41 // specifically, it doesn't print types of function parameters and
42 // types of template arguments. It just skips them. However, it's
43 // still very useful to extract basic information such as class,
44 // function, constructor, destructor, and operator names.
46 // See the implementation note in demangle.cc if you are interested.
48 // Example:
50 // | Mangled Name | The Demangler | abi::__cxa_demangle()
51 // |---------------|---------------|-----------------------
52 // | _Z1fv | f() | f()
53 // | _Z1fi | f() | f(int)
54 // | _Z3foo3bar | foo() | foo(bar)
55 // | _Z1fIiEvi | f<>() | void f<int>(int)
56 // | _ZN1N1fE | N::f | N::f
57 // | _ZN3Foo3BarEv | Foo::Bar() | Foo::Bar()
58 // | _Zrm1XS_" | operator%() | operator%(X, X)
59 // | _ZN3FooC1Ev | Foo::Foo() | Foo::Foo()
60 // | _Z1fSs | f() | f(std::basic_string<char,
61 // | | | std::char_traits<char>,
62 // | | | std::allocator<char> >)
64 // See the unit test for more examples.
66 // Note: we might want to write demanglers for ABIs other than Itanium
67 // C++ ABI in the future.
70 #ifndef BASE_DEMANGLE_H_
71 #define BASE_DEMANGLE_H_
73 #include "config.h"
75 _START_GOOGLE_NAMESPACE_
77 // Demangle "mangled". On success, return true and write the
78 // demangled symbol name to "out". Otherwise, return false.
79 // "out" is modified even if demangling is unsuccessful.
80 bool Demangle(const char *mangled, char *out, int out_size);
82 _END_GOOGLE_NAMESPACE_
84 #endif // BASE_DEMANGLE_H_