* dwarfread.c (decode_modified_type): Change type of first arg.

Change 'modifier' to char from unsigned char.  Cast single use
that needs to be unsigned char.
* symtab.h (SYMBOL_BASEREG_VALID):  Explain disabling.
* utils.c (strdup_demangled):  Add function.
* defs.h (strdup_demangled):  Add prototype.
* stack.c (return_command):  Demangle C++ function names for query.
* infcmd.c (jump_command):  Demangle C++ function names for query.
* cplus-dem.c (consume_count):  New function and prototype.
* cplus-dem.c (demangle_class, gnu_special, demangle_func_type,
do_type):  Replace conversion code with consume_count().
* cplus-dem.c (gnu_special):  Fix demangled of static members.
* source.c (list_command):  Print demangled function names
when appropriate.  Fix supplied by Peter Schauer.
This commit is contained in:
Fred Fish 1992-06-15 14:26:57 +00:00
parent 2778e91584
commit 1c92ca6f3b
3 changed files with 125 additions and 57 deletions

View File

@ -1,3 +1,26 @@
Mon Jun 15 07:21:00 1992 Fred Fish (fnf@cygnus.com)
* dwarfread.c (decode_modified_type): Change type of first arg.
Change 'modifier' to char from unsigned char. Cast single use
that needs to be unsigned char.
* symtab.h (SYMBOL_BASEREG_VALID): Explain disabling.
* utils.c (strdup_demangled): Add function.
* defs.h (strdup_demangled): Add prototype.
* stack.c (return_command): Demangle C++ function names for query.
* infcmd.c (jump_command): Demangle C++ function names for query.
* cplus-dem.c (consume_count): New function and prototype.
* cplus-dem.c (demangle_class, gnu_special, demangle_func_type,
do_type): Replace conversion code with consume_count().
* cplus-dem.c (gnu_special): Fix demangled of static members.
* source.c (list_command): Print demangled function names
when appropriate. Fix supplied by Peter Schauer.
Mon Jun 15 01:45:48 1992 John Gilmore (gnu at cygnus.com)
* buildsym.c (define_symbol): Nameless types are now on several
platforms; generalize them and un-ifdef them to make Solaris 2
work.
Sun Jun 14 10:55:51 1992 John Gilmore (gnu at cygnus.com) Sun Jun 14 10:55:51 1992 John Gilmore (gnu at cygnus.com)
* infcmd.c: Fix typo (reported by Rob Savoye). * infcmd.c: Fix typo (reported by Rob Savoye).

View File

@ -232,6 +232,9 @@ string_prependn PARAMS ((string *, const char *, int));
static int static int
get_count PARAMS ((const char **, int *)); get_count PARAMS ((const char **, int *));
static int
consume_count PARAMS ((const char **));
static int static int
demangle_args PARAMS ((string *, const char **, struct work_stuff *)); demangle_args PARAMS ((string *, const char **, struct work_stuff *));
@ -253,6 +256,23 @@ static void
string_prepends PARAMS ((string *, string *)); string_prepends PARAMS ((string *, string *));
#endif #endif
/* Translate count to integer, consuming tokens in the process.
Conversion terminates on the first non-digit character. */
static int
consume_count (type)
const char **type;
{
int count = 0;
do
{
count *= 10;
count += **type - '0';
(*type)++;
} while (isdigit (**type));
return (count);
}
/* Takes operator name as e.g. "++" and returns mangled /* Takes operator name as e.g. "++" and returns mangled
operator name (e.g. "postincrement_expr"), or NULL if not found. operator name (e.g. "postincrement_expr"), or NULL if not found.
@ -806,14 +826,7 @@ demangle_class (declp, mangled, work)
int n; int n;
int success = 0; int success = 0;
n = 0; n = consume_count (mangled);
do
{
n *= 10;
n += **mangled - '0';
(*mangled)++;
}
while (isdigit (**mangled));
if (strlen (*mangled) >= n) if (strlen (*mangled) >= n)
{ {
if (work -> constructor || work -> destructor) if (work -> constructor || work -> destructor)
@ -925,6 +938,29 @@ demangle_prefix (declp, mangled, work)
return (success); return (success);
} }
/*
LOCAL FUNCTION
gnu_special -- special handling of gnu mangled strings
SYNOPSIS
static int
gnu_special (string *declp, const char **mangled,
struct work_stuff *work)
DESCRIPTION
Process some special GNU style mangling forms that don't fit
the normal pattern. For example:
_$_3foo (destructor for class foo)
_vt$foo (virtual table)
_3foo$varname (static data member)
*/
static int static int
gnu_special (declp, mangled, work) gnu_special (declp, mangled, work)
string *declp; string *declp;
@ -943,17 +979,6 @@ gnu_special (declp, mangled, work)
(*mangled) += 3; (*mangled) += 3;
work -> destructor = 1; work -> destructor = 1;
} }
else if (**mangled != '_' && (p = strchr (*mangled, CPLUS_MARKER)) != NULL)
{
#if 0
/* static data member */
n = strlen (*mangled) + 2;
tem = (char *) xmalloc (n);
memcpy (tem, *mangled, p - *mangled);
strcpy (tem + (p - *mangled), "::");
strcpy (tem + (p - *mangled) + 2, p + 1);
#endif
}
else if ((*mangled)[0] == '_' else if ((*mangled)[0] == '_'
&& (*mangled)[1] == 'v' && (*mangled)[1] == 'v'
&& (*mangled)[2] == 't' && (*mangled)[2] == 't'
@ -969,6 +994,20 @@ gnu_special (declp, mangled, work)
string_append (declp, " virtual table"); string_append (declp, " virtual table");
(*mangled) += n; (*mangled) += n;
} }
else if ((*mangled)[0] == '_'
&& isdigit ((*mangled)[1])
&& (p = strchr (*mangled, CPLUS_MARKER)) != NULL)
{
/* static data member, "_3foo$varname" for example */
(*mangled)++;
p++;
n = consume_count (mangled);
string_appendn (declp, *mangled, n);
string_append (declp, "::");
n = strlen (p);
string_appendn (declp, p, n);
(*mangled) = p + n;
}
else else
{ {
success = 0; success = 0;
@ -1021,6 +1060,22 @@ demangle_qualified (declp, mangled, work)
return (success); return (success);
} }
/*
LOCAL FUNCTION
get_count -- convert an ascii count to integer, consuming tokens
SYNOPSIS
static int
get_count (const char **type, int *count)
DESCRIPTION
Return 0 if no conversion is performed, 1 if a string is converted.
*/
static int static int
get_count (type, count) get_count (type, count)
const char **type; const char **type;
@ -1033,24 +1088,26 @@ get_count (type, count)
{ {
return (0); return (0);
} }
*count = **type - '0'; else
(*type)++;
/* see flush_repeats in cplus-method.c */
if (isdigit (**type))
{ {
p = *type; *count = **type - '0';
n = *count; (*type)++;
do if (isdigit (**type))
{ {
n *= 10; p = *type;
n += *p - '0'; n = *count;
p++; do
} {
while (isdigit (*p)); n *= 10;
if (*p == '_') n += *p - '0';
{ p++;
*type = p + 1; }
*count = n; while (isdigit (*p));
if (*p == '_')
{
*type = p + 1;
*count = n;
}
} }
} }
return (1); return (1);
@ -1162,14 +1219,7 @@ do_type (type, result, work)
success = 0; success = 0;
break; break;
} }
n = 0; n = consume_count (type);
do
{
n *= 10;
n += **type - '0';
(*type)++;
}
while (isdigit (**type));
if (strlen (*type) < n) if (strlen (*type) < n)
{ {
success = 0; success = 0;
@ -1394,14 +1444,7 @@ demangle_fund_type (type, result, work)
case '7': case '7':
case '8': case '8':
case '9': case '9':
n = 0; n = consume_count (type);
do
{
n *= 10;
n += **type - '0';
(*type)++;
}
while (isdigit (**type));
if (strlen (*type) < n) if (strlen (*type) < n)
{ {
success = 0; success = 0;

View File

@ -380,7 +380,7 @@ static struct type *
decode_mod_u_d_type PARAMS ((char *)); decode_mod_u_d_type PARAMS ((char *));
static struct type * static struct type *
decode_modified_type PARAMS ((unsigned char *, unsigned int, int)); decode_modified_type PARAMS ((char *, unsigned int, int));
static struct type * static struct type *
decode_fund_type PARAMS ((unsigned int)); decode_fund_type PARAMS ((unsigned int));
@ -2711,7 +2711,7 @@ LOCAL FUNCTION
SYNOPSIS SYNOPSIS
static struct type *decode_modified_type (unsigned char *modifiers, static struct type *decode_modified_type (char *modifiers,
unsigned short modcount, int mtype) unsigned short modcount, int mtype)
DESCRIPTION DESCRIPTION
@ -2745,14 +2745,14 @@ BUGS
static struct type * static struct type *
decode_modified_type (modifiers, modcount, mtype) decode_modified_type (modifiers, modcount, mtype)
unsigned char *modifiers; char *modifiers;
unsigned int modcount; unsigned int modcount;
int mtype; int mtype;
{ {
struct type *typep = NULL; struct type *typep = NULL;
unsigned short fundtype; unsigned short fundtype;
DIE_REF die_ref; DIE_REF die_ref;
unsigned char modifier; char modifier;
int nbytes; int nbytes;
if (modcount == 0) if (modcount == 0)
@ -2799,9 +2799,11 @@ decode_modified_type (modifiers, modcount, mtype)
SQUAWK (("type modifier 'volatile' ignored")); /* FIXME */ SQUAWK (("type modifier 'volatile' ignored")); /* FIXME */
break; break;
default: default:
if (!(MOD_lo_user <= modifier && modifier <= MOD_hi_user)) if (!(MOD_lo_user <= (unsigned char) modifier
&& (unsigned char) modifier <= MOD_hi_user))
{ {
SQUAWK (("unknown type modifier %u", modifier)); SQUAWK (("unknown type modifier %u",
(unsigned char) modifier));
} }
break; break;
} }