/*
* 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 (c) 1988 AT&T
* All Rights Reserved
*
*
* Copyright (c) 1998 by Sun Microsystems, Inc.
* All rights reserved.
*/
#pragma ident "%Z%%M% %I% %E% SMI" /* SVr4.0 1.2 */
#include <ctype.h>
#include <stdlib.h>
#include <string.h>
#include "elf_dem.h"
#include "String.h"
#include "msg.h"
/* This structure is used to keep
* track of pointers to argument
* descriptions in the mangled string.
* This is needed for N and T encodings
* to work.
*/
typedef struct {
int pos;
} Place;
/* Strings and flags needed by the argument demangles. The declarator
* is built up in ptr. Type modifiers are held in the flag fields.
* The type itself is passed in separately.
*/
typedef struct {
} Arg_Remem;
/* initialize Arg_Remem */
static void
mkar(r)
Arg_Remem *r;
{
}
/* free data for Arg_Remem */
static void
delar(r)
Arg_Remem *r;
{
free_String(r->ptr);
}
/* This routine formats a single argument
* on the buffer sptr.
* c is the type or class name, n is its length.
*/
static void
{
if(r->Cons)
if(r->Vol)
if(r->Uns)
else if(r->Sign)
delar(r);
}
/* This routine formats a single argument
* on the buffer sptr.
* c is the null terminated type or class name.
*/
static void
{
}
/* Demangle a single function argument.
* Returns the number of characters processed from c.
*/
int
char *c;
{
register int i;
for(i=0;c[i];i++) {
/* Loop until you find a type.
Then call setarg and return.
*/
switch(c[i]) {
case 'T':
{
return -1;
}
return 2;
}
case 'N':
{
return -1;
}
while(cycles--) {
}
return 3;
}
/* Qualifiers to type names */
case 'S':
break;
case 'U':
break;
case 'C':
break;
case 'V':
break;
/* Pointers, references, and Member Pointers */
case 'P':
case 'R':
case 'M':
}
}
if(c[i] == 'P')
else if(c[i] == 'R')
else {
int cnt = 0;
char *s;
/* Skip over the 'M' */
i++;
i = s - c;
i += cnt;
/* The loop increments i */
i--;
}
break;
/* Demangle for basic built-in types */
case 'i':
return i + 1;
case 'c':
return i + 1;
case 's':
return i + 1;
case 'l':
return i + 1;
case 'f':
return i + 1;
case 'd':
return i + 1;
case 'r':
return i + 1;
/* Class encodings */
case '1': case '2': case '3':
case '4': case '5': case '6':
case '7': case '8': case '9':
{
int cnt = 0;
char *s;
i = s - c;
return -1;
}
return i+cnt;
}
/* Ellipsis and void */
case 'e':
return i + 1;
case 'v':
return i + 1;
/* Arrays */
case 'A':
}
{
int cnt = 0;
i++;
cnt++;
i += cnt;
if(c[i] != '_') {
return -1;
}
}
break;
/* Functions
* This will always be called as a pointer
* to a function.
*/
case 'F':
{
i++;
if(c[i] != '_') {
return -1;
}
}
break;
/* Needed when this is called to demangle
* an argument of a pointer to a function.
*/
case '_':
return 0;
default:
return -1;
}
}
/* Did the argument list terminate properly? */
{
int rc = 0;
rc = -1;
return rc;
}
}
/* This function is called to demangle
* an argument list.
* Returns the number of characters processed from c.
*/
int
char *c;
{
int i,n = 0;
while(*c && (i = demangle_doarg(sptr,c)) > 0) {
c += i;
n += i;
}
if(i < 0)
return -1;
return n;
}