2 * This file is part of ltrace.
3 * Copyright (C) 1998,1999,2003,2004,2008,2009 Juan Cespedes
4 * Copyright (C) 2006 Ian Wienand
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License as
8 * published by the Free Software Foundation; either version 2 of the
9 * License, or (at your option) any later version.
11 * This program is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
32 /*****************************************************************************/
34 static Dict *d = NULL;
37 my_demangle(const char *function_name) {
38 const char *tmp, *fn_copy;
39 #ifdef USE_CXA_DEMANGLE
40 extern char *__cxa_demangle(const char *, char *, size_t *, int *);
43 debug(DEBUG_FUNCTION, "my_demangle(name=%s)", function_name);
46 d = dict_init(dict_key2hash_string, dict_key_cmp_string);
48 tmp = dict_find_entry(d, (void *)function_name);
50 fn_copy = strdup(function_name);
52 tmp = cplus_demangle(function_name, DMGL_ANSI | DMGL_PARAMS);
53 #elif defined USE_CXA_DEMANGLE
55 tmp = __cxa_demangle(function_name, NULL, NULL, &status);
60 dict_enter(d, (void *)fn_copy, (void *)tmp);