This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: 1 Month Followup on Libiberty patch
At 13:59 20/02/01 +0000, Jason Merrill wrote:
>Where are the sources for the Borland demangler?
Attached - I was planning to put them in GDB. The following segment of code
is in a separate file that is intended to go into GDB (tdsread.c). The
demangler deals with two versions of the Borland mangling scheme that are
similar, but just incompatible enough to require a flag to be passed to the
demangler. This means that without reading the TDS information to find the
version of the debugging format, attempting to demangle a Borland symbol
can produce unpredictable results, most notably for templates, which means
that tools such as c++filt won't be able to reliably use the demangler
anyway (unless flags are added to tell it which version of Borland
demangling to use.
The Borland demangler also has additional features that the other
demanglers don't, due to some odd choices to mangle things in the TDS
debugging format in ways you wouldn't expect - in some cases we need to
extract just the demangled operator name, or method name from a symbol
mangled by its fully qualified name - most notably, in the data structures
describing a class, the constructor is listed using the fully qualified
name of the constructor including the mangled arguments of one of the
constructors, and we need to get just the
...
static int last_tds_version_seen = 10;
...
/ Demangler to hook into libiberty */
static char *
borland_libiberty_demangler (const char *mangled, int options)
{
if (*mangled != '@')
{
return 0;
}
else
{
borland_demangling_info deminfo;
borland_init_demangling_info (&deminfo);
deminfo.noansi = !(options & DMGL_ANSI);
deminfo.noargs = !(options & DMGL_PARAMS);
return borland_demangle_symbol (0, mangled, 0,
last_tds_version_seen, &deminfo);
}
}
static struct runtime_demangler borland_demangler_info =
{
borland_demangling,
0,
borland_libiberty_demangler,
0,
0
};
void
_initialize_tdsread ()
{
add_symtab_fns (&tds_sym_fns);
cplus_demangle_add_demangler (&borland_demangler_info);
}
borldem.c
/* Demangling for Borland C++ Symbols.
Contributed by Troy Rollo - http://www.troy.rollo.com/
Copyright 2000 Free Software Foundation, Inc.
This file is part of GDB.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA. */
typedef struct
{
int methodonly : 1;
int noargs : 1;
int noansi : 1;
int isoperator : 1;
char const *args_start;
char const *method_start;
}
borland_demangling_info;
extern void borland_init_demangling_info (borland_demangling_info *info);
extern char *borland_demangle_symbol (struct obstack *obstack
, char const *name
, int *lenp
, int version
, borland_demangling_info *info);
______________________________________________________________________________
troy@rollo.com Troy Rollo, Sydney, Australia
Fight spam in Australia - Join CAUBE.AU - http://www.caube.org.au/