[gnu.gdb.bug] Disambiguation of warbitrary identifiers in GDB

godard@CURLY.SAMSUNG.COM (Ivan Godard) (08/25/89)

You were so responsive with my last note (on ~ files), here's another one:

We do a lot of abstract data type code.  We declare 'typedef struct _foo* bar;'
in a .h file, and then let people declare 'bar' objects and pass them around
and call functions taking them.  The resolution of 'struct _foo' is local to a
compunit which implements the adt operations;  nobody else sees the inside of a
'bar'.  OK, basic stuff.

Now when we are debugging a new adt, we find ourself inside a client who is
screwed up because something is wrong with the structure of some adt value.  In
the debugger we want to be able to inspect the innards.  However, gdb won't let
us, because it doesn't know the type or fields of a 'struct _foo' from within
the cliend module.

This is fair - the reference is ambiguous.  It is perfectly possible to resolve
'struct _foo' in several different ways in different modules of the program,
and gdb can't know which is the right one.  Down with C scope rules.  However,
the need is real, so here's a suggested solution:

Thew way to supply a type in gdb is an expression containing a cast.  That
won't work for the present situation because the type name is out of scope.
You alrerady have an existing mechanism to reference (and disambiguate) names
in one other context - the break statement.  Solution: permit a compunit name
(file name) to be attached to *any* identifier in *any* context, with the
semantics that the identifier shall be interpreted with the meaning it has in
the specified compunit, rather than the one in the open compunit.

This not only solves my problem, it permits expressions containing mixed
referenced to local names from multiple compunits, which (as far as I can see )
is presently impossible.

True, you'l have to rething the expression parser...

What say?

Ivan

rms@AI.MIT.EDU (Richard Stallman) (08/25/89)

I don't think we should spend the time it would take to implement
the feature of specifying a scope for an identifier.  It doesn't
make sense in many cases, so it will be hard to spec.

But ordinary identifiers that are static in one file are visible in
other files in GDB.  Why not struct tags also?  That should be easy.