mdb_demangle.c revision 7c478bd95313f5f23a4c958a745db2134aa03244
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License, Version 1.0 only
* (the "License"). You may not use this file except in compliance
* with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2001-2002 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
#include <mdb/mdb_modapi.h>
#include <mdb/mdb_demangle.h>
#include <demangle.h>
#include <strings.h>
#include <unistd.h>
#include <dlfcn.h>
#include <link.h>
#ifdef _LP64
static const char LIB_DEMANGLE[] = "/usr/lib/64/libdemangle.so.1";
#else
static const char LIB_DEMANGLE[] = "/usr/lib/libdemangle.so.1";
#endif
mdb_dem_load(const char *path)
{
return (NULL);
return (NULL);
}
(void) set_errno(EMDB_NODEM);
return (NULL);
}
return (dmp);
}
void
{
}
static const char *
{
static const char s_pref[] = "static ";
static const char c_suff[] = " const";
static const char v_suff[] = " volatile";
/*
* We process dm_dem, which skips the prefix in dm_buf (if any)
*/
/*
* If static, const, and volatile qualifiers should not be displayed,
* rip all of them out of dmp->dm_dem.
*/
}
for (;;) {
*end = '\0';
continue;
}
*end = '\0';
continue;
}
break;
}
}
/*
* If function arguments should not be displayed, remove everything
* between the outermost set of parentheses in dmp->dm_dem.
*/
}
/*
* If function scope specifiers should not be displayed, remove text
* from the leftmost space to the rightmost colon prior to any paren.
*/
*lp = '\0';
*lp = '(';
if (c != NULL) {
if (s == NULL || s > c)
else
}
}
/*
* Compute bytes remaining
*/
/*
* If we want to append the mangled name as well and there is enough
* space for "[]\0" and at least one character, append "["+name+"]".
*/
*p++ = '[';
p += strlen(p);
(void) strcpy(p, "]");
}
/*
* We return the whole string
*/
}
/*
* Take a name: (the foo`bar` is optional)
* foo`bar`__mangled_
* and put:
* foo`bar`demangled
* into dmp->dm_buf. Point dmp->dm_dem to the beginning of the
* demangled section of the result.
*/
static int
{
if (prefix) {
prefix++; /* the ` is part of the prefix */
return (DEMANGLE_ESPACE);
/*
* Fix up the arguments to dmp->dm_convert()
*/
}
/*
* Save the position of the demangled string for mdb_dem_filter()
*/
}
const char *
{
int err;
mdb_warn("failed to allocate memory for demangling");
return (name); /* just return original name */
}
}
return (name); /* return original name if not mangled */
}
/*ARGSUSED*/
int
{
const char *path = LIB_DEMANGLE;
return (DCMD_USAGE);
if (argc > 0) {
}
mdb_printf("C++ symbol demangling enabled\n");
mdb_printf("C++ symbol demangling enabled\n");
} else {
}
} else {
mdb_printf("C++ symbol demangling disabled\n");
}
return (DCMD_OK);
}
/*ARGSUSED*/
int
{
static const char *const dm_desc[] = {
"scope resolution specifiers displayed",
"function arguments displayed",
"mangled name displayed"
};
int i;
if (argc > 0)
return (DCMD_USAGE);
mdb_warn("C++ demangling facility is currently disabled\n");
return (DCMD_ERR);
}
if (flags & DCMD_ADDRSPEC)
}
return (DCMD_OK);
}
/*ARGSUSED*/
int
{
return (DCMD_USAGE);
return (DCMD_ERR);
}
}
return (DCMD_OK);
}