Initialize gflags in signalhandler_unittest.
[platform/upstream/glog.git] / src / demangle.h
1 // Copyright 2006 Google Inc. All Rights Reserved.
2 // Author: Satoru Takabayashi
3 //
4 // An async-signal-safe and thread-safe demangler for Itanium C++ ABI
5 // (aka G++ V3 ABI).
6
7 // The demangler is implemented to be used in async signal handlers to
8 // symbolize stack traces.  We cannot use libstdc++'s
9 // abi::__cxa_demangle() in such signal handlers since it's not async
10 // signal safe (it uses malloc() internally).
11 //
12 // Note that this demangler doesn't support full demangling.  More
13 // specifically, it doesn't print types of function parameters and
14 // types of template arguments.  It just skips them.  However, it's
15 // still very useful to extract basic information such as class,
16 // function, constructor, destructor, and operator names.
17 //
18 // See the implementation note in demangle.cc if you are interested.
19 //
20 // Example:
21 //
22 // | Mangled Name  | The Demangler | abi::__cxa_demangle()
23 // |---------------|---------------|-----------------------
24 // | _Z1fv         | f()           | f()
25 // | _Z1fi         | f()           | f(int)
26 // | _Z3foo3bar    | foo()         | foo(bar)
27 // | _Z1fIiEvi     | f<>()         | void f<int>(int)
28 // | _ZN1N1fE      | N::f          | N::f
29 // | _ZN3Foo3BarEv | Foo::Bar()    | Foo::Bar()
30 // | _Zrm1XS_"     | operator%()   | operator%(X, X)
31 // | _ZN3FooC1Ev   | Foo::Foo()    | Foo::Foo()
32 // | _Z1fSs        | f()           | f(std::basic_string<char,
33 // |               |               |   std::char_traits<char>,
34 // |               |               |   std::allocator<char> >)
35 //
36 // See the unit test for more examples.
37 //
38 // Note: we might want to write demanglers for ABIs other than Itanium
39 // C++ ABI in the future.
40 //
41
42 #ifndef BASE_DEMANGLE_H_
43 #define BASE_DEMANGLE_H_
44
45 #include "config.h"
46
47 _START_GOOGLE_NAMESPACE_
48
49 // Demangle "mangled".  On success, return true and write the
50 // demangled symbol name to "out".  Otherwise, return false.
51 // "out" is modified even if demangling is unsuccessful.
52 bool Demangle(const char *mangled, char *out, int out_size);
53
54 _END_GOOGLE_NAMESPACE_
55
56 #endif  // BASE_DEMANGLE_H_