[fb7fe6]: pp / demangle_symbol.cpp Maximize Restore History

Download this file

demangle_symbol.cpp    45 lines (35 with data), 1.0 kB

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
/**
* \file demangle_symbol.cpp
* Copyright 2002 OProfile authors
* Read the file COPYING
*
* \author John Levon <moz@compsoc.man.ac.uk>
*/
#include "demangle_symbol.h"
// from libiberty
/*@{\name demangle option parameter */
#ifndef DMGL_PARAMS
# define DMGL_PARAMS (1 << 0) /**< Include function args */
#endif
#ifndef DMGL_ANSI
# define DMGL_ANSI (1 << 1) /**< Include const, volatile, etc */
#endif
/*@}*/
extern "C" char * cplus_demangle(const char * mangled, int options);
// FIXME: all options should be in a public singleton
// FIXME: this options should die IMO (then move this into libutil++)
extern bool demangle;
using std::string;
string const demangle_symbol(string const & name)
{
if (!demangle)
return name;
// Do not try to strip leading underscore, this leads to many
// C++ demangling failures.
char * unmangled = cplus_demangle(name.c_str(), DMGL_PARAMS | DMGL_ANSI);
if (!unmangled)
return name;
string const result(unmangled);
free(unmangled);
return result;
}