From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 25190 invoked by alias); 9 Apr 2002 00:19:17 -0000 Mailing-List: contact gdb-help@sources.redhat.com; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-owner@sources.redhat.com Received: (qmail 25183 invoked from network); 9 Apr 2002 00:19:16 -0000 Received: from unknown (HELO zwingli.cygnus.com) (208.245.165.35) by sources.redhat.com with SMTP; 9 Apr 2002 00:19:16 -0000 Received: by zwingli.cygnus.com (Postfix, from userid 442) id 7EAD35EA11; Mon, 8 Apr 2002 19:19:14 -0500 (EST) To: Daniel Jacobowitz Cc: gdb@sources.redhat.com, Benjamin Kosnik , Daniel Berlin Subject: Re: C++ nested classes, namespaces, structs, and compound statements References: <20020406044204.245E45EA11@zwingli.cygnus.com> <20020406013408.A4570@nevyn.them.org> From: Jim Blandy Date: Mon, 08 Apr 2002 17:19:00 -0000 In-Reply-To: <20020406013408.A4570@nevyn.them.org> Message-ID: User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.1 MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-SW-Source: 2002-04/txt/msg00106.txt.bz2 Daniel Jacobowitz 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?