From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 21751 invoked by alias); 18 Sep 2002 15:40:31 -0000 Mailing-List: contact gdb-patches-help@sources.redhat.com; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sources.redhat.com Received: (qmail 21731 invoked from network); 18 Sep 2002 15:40:29 -0000 Received: from unknown (HELO crack.them.org) (65.125.64.184) by sources.redhat.com with SMTP; 18 Sep 2002 15:40:29 -0000 Received: from nevyn.them.org ([66.93.61.169] ident=mail) by crack.them.org with asmtp (Exim 3.12 #1 (Debian)) id 17rhsF-0005sb-00; Wed, 18 Sep 2002 11:40:24 -0500 Received: from drow by nevyn.them.org with local (Exim 3.35 #1 (Debian)) id 17rgwF-0006dG-00; Wed, 18 Sep 2002 11:40:27 -0400 Date: Wed, 18 Sep 2002 08:40:00 -0000 From: Daniel Jacobowitz To: gdb-patches@sources.redhat.com, carlton@math.stanford.edu Subject: PATCH: gdb/709, C++ static members Message-ID: <20020918154026.GA24749@nevyn.them.org> Mail-Followup-To: gdb-patches@sources.redhat.com, carlton@math.stanford.edu Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.5.1i X-SW-Source: 2002-09/txt/msg00397.txt.bz2 David, your earlier patch: * values.c (value_static_field): Treat an unresolved location the same as a nonexistent symbol. Fix PR gdb/635. pointed me in the right direction for this fix. As you may have pointed out at the time, read_var_value does basically the same thing your fix does in that case. It turns out that there's some other cases - this particular one was LOC_CONST_BYTES - where read_var_value does the right thing and value_static_field doesn't. So I just had value_static_field call read_var_value, which fixes your testcase and also a new one I'll post later for gdb/709. Committed, since static members are a C++ thing. -- Daniel Jacobowitz MontaVista Software Debian GNU/Linux Developer 2002-09-18 Daniel Jacobowitz Fix PR gdb/709 * values.c (value_static_field): Call read_var_value. Index: values.c =================================================================== RCS file: /cvs/src/src/gdb/values.c,v retrieving revision 1.40 diff -u -p -r1.40 values.c --- values.c 24 Aug 2002 00:21:35 -0000 1.40 +++ values.c 18 Sep 2002 15:23:14 -0000 @@ -800,25 +800,19 @@ unpack_pointer (struct type *type, char struct value * value_static_field (struct type *type, int fieldno) { - CORE_ADDR addr; - asection *sect; + struct value *retval; + if (TYPE_FIELD_STATIC_HAS_ADDR (type, fieldno)) { - addr = TYPE_FIELD_STATIC_PHYSADDR (type, fieldno); - sect = NULL; + retval = value_at (TYPE_FIELD_TYPE (type, fieldno), + TYPE_FIELD_STATIC_PHYSADDR (type, fieldno), + NULL); } else { char *phys_name = TYPE_FIELD_STATIC_PHYSNAME (type, fieldno); struct symbol *sym = lookup_symbol (phys_name, 0, VAR_NAMESPACE, 0, NULL); - /* In some cases (involving uninitalized, unreferenced static - const integral members), g++ -gdwarf-2 can emit debugging - information giving rise to symbols whose SYMBOL_CLASS is - LOC_UNRESOLVED. In that case, do a minimal symbol lookup. - If it returns a useful value, then the symbol was defined - elsewhere, so we use that information. Otherwise, return - NULL. */ - if (sym == NULL || SYMBOL_CLASS (sym) == LOC_UNRESOLVED) + if (sym == NULL) { /* With some compilers, e.g. HP aCC, static data members are reported as non-debuggable symbols */ @@ -827,27 +821,25 @@ value_static_field (struct type *type, i return NULL; else { - addr = SYMBOL_VALUE_ADDRESS (msym); - sect = SYMBOL_BFD_SECTION (msym); + retval = value_at (TYPE_FIELD_TYPE (type, fieldno), + SYMBOL_VALUE_ADDRESS (msym), + SYMBOL_BFD_SECTION (msym)); } } else { - /* Anything static that isn't a constant, has an address */ - if (SYMBOL_CLASS (sym) != LOC_CONST) - { - addr = SYMBOL_VALUE_ADDRESS (sym); - sect = SYMBOL_BFD_SECTION (sym); - } - /* However, static const's do not, the value is already known. */ - else - { - return value_from_longest (TYPE_FIELD_TYPE (type, fieldno), SYMBOL_VALUE (sym)); - } + /* SYM should never have a SYMBOL_CLASS which will require + read_var_value to use the FRAME parameter. */ + if (symbol_read_needs_frame (sym)) + warning ("static field's value depends on the current " + "frame - bad debug info?"); + retval = read_var_value (sym, NULL); } - SET_FIELD_PHYSADDR (TYPE_FIELD (type, fieldno), addr); + if (retval && VALUE_LVAL (retval) == lval_memory) + SET_FIELD_PHYSADDR (TYPE_FIELD (type, fieldno), + VALUE_ADDRESS (retval)); } - return value_at (TYPE_FIELD_TYPE (type, fieldno), addr, sect); + return retval; } /* Change the enclosing type of a value object VAL to NEW_ENCL_TYPE.