From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 21724 invoked by alias); 9 Mar 2004 13:00:13 -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 21650 invoked from network); 9 Mar 2004 13:00:10 -0000 Received: from unknown (HELO mx1.redhat.com) (66.187.233.31) by sources.redhat.com with SMTP; 9 Mar 2004 13:00:10 -0000 Received: from int-mx2.corp.redhat.com (nat-pool-rdu-dmz.redhat.com [172.16.52.200] (may be forged)) by mx1.redhat.com (8.12.10/8.12.10) with ESMTP id i29D08ST015571 for ; Tue, 9 Mar 2004 08:00:09 -0500 Received: from potter.sfbay.redhat.com (potter.sfbay.redhat.com [172.16.27.15]) by int-mx2.corp.redhat.com (8.11.6/8.11.6) with ESMTP id i29D08M24994 for ; Tue, 9 Mar 2004 08:00:08 -0500 Received: from cygbert.vinschen.de (vpn50-24.rdu.redhat.com [172.16.50.24]) by potter.sfbay.redhat.com (8.11.6/8.11.6) with ESMTP id i29D06R30686 for ; Tue, 9 Mar 2004 05:00:07 -0800 Received: by cygbert.vinschen.de (Postfix, from userid 500) id 197EF580E2; Tue, 9 Mar 2004 13:59:59 +0100 (CET) Date: Tue, 09 Mar 2004 13:00:00 -0000 From: Corinna Vinschen To: gdb-patches@sources.redhat.com Subject: [RFC/RFA] gdb.cp/classes.exp: Don't try to print local variable out of scope Message-ID: <20040309125959.GD25204@cygbert.vinschen.de> Reply-To: gdb-patches@sources.redhat.com Mail-Followup-To: gdb-patches@sources.redhat.com Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.4.2i X-RedHat-Spam-Score: -1.524 X-SW-Source: 2004-03.o/txt/msg00190.txt Message-ID: <20040309130000.O3Uxj_DkkUt2gop3l8hjS-pi0VqESWufhXx4rXwZCDo@z> Hi, with gcc 3.4.0, the gdb.cp/classes.exp test has four FAILs on sh-elf: FAIL: gdb.cp/classes.exp: print obj_with_enum (2) FAIL: gdb.cp/classes.exp: print obj_with_enum.priv_enum FAIL: gdb.cp/classes.exp: ptype obj_with_enum.priv_enum FAIL: gdb.cp/classes.exp: ptype obj_with_enum Basically, the testsuite tries to print the value of a local variable on a closing brace. This fails due to the debug info given in this case: <1><1398>: Abbrev Number: 37 (DW_TAG_subprogram) DW_AT_sibling : <13e1> DW_AT_external : 1 DW_AT_name : enums1 DW_AT_decl_file : 1 DW_AT_decl_line : 430 DW_AT_MIPS_linkage_name: _Z6enums1v DW_AT_low_pc : 0x1480 5248 DW_AT_high_pc : 0x14ac 5292 DW_AT_frame_base : 1 byte block: 5e (DW_OP_reg14; ) <2><13bd>: Abbrev Number: 28 (DW_TAG_lexical_block) DW_AT_low_pc : 0x1488 5256 DW_AT_high_pc : 0x149a 5274 <3><13c6>: Abbrev Number: 38 (DW_TAG_variable) DW_AT_name : obj_with_enum DW_AT_decl_file : 1 DW_AT_decl_line : 431 DW_AT_type : <12a2> DW_AT_location : 2 byte block: 91 0 (DW_OP_fbreg: 0; ) As you can see, the function has a lexical block attached. The local variable is a child of that lexical block. The lexical block consists of the whole body of the function, except for the prologue and the epilogue code. When the testsuite steps to the closing brace of the function, $pc is set to the first instruction of the epilogue. This is exactly the first instruction which doesn't belong to the lexical block anymore. Logically, the local variable doesn't exist anymore at this point. So GDB prints `No symbol "obj_with_enum" in current context.' Since the above debug information is correct, also GDBs behaviour is correct. The testsuite wrongly assumes, that the scope of the local class member includes the closing brace. I'd suggest to change the testsuite case to add another line to the function enums1(), so that it's sure to be still in the scope of the local variable obj_with_enum. Corinna * gdb.cp/misc.cc (enums1): Add a line to extend scope of local variable obj_with_enum. Index: gdb.cp/misc.cc =================================================================== RCS file: /cvs/src/src/gdb/testsuite/gdb.cp/misc.cc,v retrieving revision 1.1 diff -u -p -r1.1 misc.cc --- gdb.cp/misc.cc 23 Aug 2003 03:55:59 -0000 1.1 +++ gdb.cp/misc.cc 8 Mar 2004 19:59:17 -0000 @@ -433,6 +433,7 @@ void enums1 () obj_with_enum.x = 0; enums2 (); obj_with_enum.priv_enum = ClassWithEnum::green; + obj_with_enum.priv_enum = ClassWithEnum::yellow; } class ClassParam { -- Corinna Vinschen Cygwin Developer Red Hat, Inc.