[m-dev.] diff: fixes for demangling

Tyson Richard DOWD trd at cs.mu.oz.au
Thu Jul 24 15:33:19 AEST 1997


Fergus Henderson wrote:
> Hi,
> 
> Anyone want to review this change?

Sure.

> Index: util/mdemangle.c
> ===================================================================
> RCS file: /home/staff/zs/imp/mercury/util/mdemangle.c,v
> retrieving revision 1.18
> diff -u -r1.18 mdemangle.c
> --- mdemangle.c	1997/06/05 05:50:09	1.18
> +++ mdemangle.c	1997/07/23 19:40:08
> @@ -13,6 +13,12 @@
>  ** A mercury symbol demangler.
>  ** This is used to convert error messages from the linker back
>  ** into a form that users can understand.
> +**
> +** This is implemented in C to minimize startup time and memory usage.
> +**
> +** BEWARE:
> +** This code is duplicated in profiler/demangle.m and profiler/mdemangle.m.
> +** Any changes here will need to be duplicated there and vice versa.
>  */

(Fergus and I just discussed this, so to fill others in...).

We now have a double maintenance problem... we also have a problem in
that maintaining C code is quite difficult, time consuming, and
error prone. Since we are using the demangling code in the profiler, it
would be good to write it in Mercury (it would still be fiddly, but much
easier).

We could do this, and avoid any startup time and memory usage problems
by using a shell script wrapper of some sort, that only invokes the
*real* demangler if there is a "mercury__" in the input. If there is a
link error, it doesn't really matter much what the startup time and
memory usage is like.

We could then implement the real demangler in, say, Mercury. Of course
there would be small bootstrapping problems if a distribution doesn't
link, but if the demangler doesn't link properly, there's a either real
problem with the distribution (and so, in comparison, it doesn't matter
too much that the symbols are mangled), or a system problem (in which
case the symbols probably won't be Mercury symbols.

Something to do after this release, however.

> +	% Now start processing from the start of the string again.
> +	% Check whether the start of the string matches the name of
> +	% one of the special compiler-generated predicates; if so,
> +	% set the `category' to the appropriate value and then
> +	% skip past the prefix.
> +	%
> +	( remove_prefix("__Unify__") ->
> +		{ Category = unify }
> +	; remove_prefix("__Compare__") ->
> +		{ Category = compare },
> +		{ ModeNum = 0 } % sanity check
> +	; remove_prefix("__Index__") ->
> +		{ Category = index },
> +		{ ModeNum = 0 } % sanity check
> +	;	
> +		{ Category = ordinary }
> +	),

I don't know whether "sanity check" is the right comment. If it's a
sanity check, they should use require. Instead, it rejects them as a
pred symbol, and doesn't demangle them.

> ===================================================================
> RCS file: demangle_test.m
> diff -N demangle_test.m
> --- /dev/null	Thu Jul 24 06:02:47 1997
> +++ demangle_test.m	Thu Jul 24 05:55:40 1997

Your diffs agains /dev/null don't show the directory that a particular
file lives in. Considered using ~trd/bin/scripts/makediff?

Also, the filename doesn't match this comment

> +%
> +% File: mdemangle.m
> +% Author: fjh
> +%

or this module declaration.

> +
> +:- module mdemangle.
> +:- interface.
> +

-- 
       Tyson Dowd           # 4.4: People keep saying the behavior is undefined,
                            # but I just tried it on an ANSI-conforming compiler
     trd at cs.mu.oz.au        # and got the results I expected.
http://www.cs.mu.oz.au/~trd # A: They were wrong. Flame them mercilessly. C-IAQ



More information about the developers mailing list