This is the mail archive of the
gdb-patches@sources.redhat.com
mailing list for the GDB project.
[RFC/RFA] gdb.cp/classes.exp: Don't try to print local variable out of scope
- From: Corinna Vinschen <vinschen at redhat dot com>
- To: gdb-patches at sources dot redhat dot com
- Date: Tue, 9 Mar 2004 13:59:59 +0100
- Subject: [RFC/RFA] gdb.cp/classes.exp: Don't try to print local variable out of scope
- Reply-to: gdb-patches at sources dot redhat dot com
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.