Path: utzoo!mnetor!uunet!husc6!yale!cmcl2!nrl-cmf!mailrus!umix!umich!mibte!gamma!sabre!faline!thumper!ulysses!allegra!alice!bs From: bs@alice.UUCP Newsgroups: comp.lang.c++ Subject: Re: debuggers Message-ID: <7711@alice.UUCP> Date: 22 Feb 88 21:16:44 GMT References: <275@goofy.megatest.UUCP> Organization: AT&T Bell Laboratories, Murray Hill NJ Lines: 37 Summary: an example Megatest Corporation, San Jose, Ca) writes ... > A while back, I asked what bad things would happen if I hacked cfront so > that it does not prefix automatic variables with au0_, etc. > Nobody said anything. You may have thought I was jesting. > I was serious. Stop me if I'm going to break something. Really. > Also cfront changes the field names in structs, prefixing > the name of the struct. What if I change it so that it doesn't do that? Cfront ``mangles'' names of local variables to avoid clashes between different uses of the same name in a local scope. Consider: int i; inline f(int x) { int i = x; x++; return i; } g() { int i = f(::i); } Here the code produced must refer to both f's i, the global i, and g's i in a single expression. Take away the prefixes generated for local names and you generate bad code. I think the proper approach is to have the debuggers understand the encoding strategy so that they can allow the user to use simple names where appropriate and use C++ language level disambiguation, such as ::i, where needed. To make this approach feasible the encoding strategy must be simple, stable, and documented. This is being taken care of. This in itself will not enable you to write a systems independent debugger but it will enable you to give a C debugger a much nicer C++ interface.