This is the mail archive of the gdb@sources.redhat.com mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: C++ nested classes, namespaces, structs, and compound statements



Daniel Jacobowitz <drow@mvista.com> writes:
> How about -containing- `struct fields', instead of replacing?  i.e. let
> the name search happen in the `struct environment', as before, but the
> data items would be fields (could be indicated in a flag in the
> environment, with a pointer to the type or symbol for the enclosing
> structure).  I don't think turning members into symbols is a good idea.

I admit the idea of using `struct symbol' for fields as well as
variables is pretty weird.  Here's the rationale:

First, keep in mind that `struct symbol' is sort of a `messy union':
it's used for a lot of distinct purposes, and it contains all the
members any of those purposes might need.  The `struct symbol'
representing a declaration like `struct A' doesn't need its
ginfo.value field.  The `struct symbol' representing a local variable
doesn't need its `bfd_section' field.  (I'm not saying this is a great
way to do things; but it is the way it's done now.)

Now, when we're debugging a C++ program, if we have a class A, think
about what sorts of objects A::x could represent:

- It could be a member.
- It could be a static member, which is really a global variable
  with a qualified name.
- It could be a typedef.
- It could be a nested class.

When the user says `ptype A::x', we should be able to just look up A,
then look up x in A's environment, and see what it is.

It needs to have an `enum address_class' to distinguish members from
typedefs.

If it's a static member, it'll need to have a bfd_section.

`struct field' is slowly acquiring the equivalent of `enum
address_class', but badly: here's the comment for the `bitsize'
member:

    /* Size of this field, in bits, or zero if not packed.
       For an unpacked field, the field's type's length
       says how many bytes the field occupies.
       A value of -1 or -2 indicates a static field;  -1 means the location
       is specified by the label loc.physname;  -2 means that loc.physaddr
       specifies the actual address. */

    int bitsize;

How would you suggest we represent nested typedefs and classes?


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]