Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
* Re: [RFC/RFA] gdb.cp/classes.exp: Don't try to print local variable out of scope
@ 2004-03-19  0:09 Michael Elizabeth Chastain
  2004-03-09 15:27 ` Michael Elizabeth Chastain
  0 siblings, 1 reply; 38+ messages in thread
From: Michael Elizabeth Chastain @ 2004-03-19  0:09 UTC (permalink / raw)
  To: drow, mec.gnu; +Cc: carlton, gdb-patches, vinschen

mec> Is it okay for gcc to emit debug info that "i" is out of scope here?
drow> I think so.  It's unfortunate.

Okay, that makes three people in favor of accepting this limited
scoping from gcc 3.4, good enough for me.

drow> Duplicate the file, then, since we've decided this is a bad practice?

You're right, this is better.

I was secretly hoping not to touch misc.cc at all, because as soon as I
go to touch it, I have to add a proper copyright notice, and then
re-test with all the *.exp anyways.

I'd better get to work.

Michael C


^ permalink raw reply	[flat|nested] 38+ messages in thread
* Re: [RFC/RFA] gdb.cp/classes.exp: Don't try to print local variable out of scope
@ 2004-03-19  0:09 Michael Elizabeth Chastain
  2004-03-09 15:11 ` Michael Elizabeth Chastain
                   ` (2 more replies)
  0 siblings, 3 replies; 38+ messages in thread
From: Michael Elizabeth Chastain @ 2004-03-19  0:09 UTC (permalink / raw)
  To: carlton, drow, vinschen; +Cc: gdb-patches

Hi Corinna,

cv> Basically, the testsuite tries to print the value of a local variable
cv> on a closing brace.  This fails due to the debug info given in this
cv> case:

I have been seeing this also on native i686-pc-linux-gnu.

cv> When the testsuite steps to the closing brace of the function, $pc is
cv> set to the first instruction of the epilogue.  This is exactly the
cv> first instruction which doesn't belong to the lexical block anymore.
cv> Logically, the local variable doesn't exist anymore at this point.

Right.

I want to raise the question: is this really a bug in the gdb test suite,
or is it a bug in gcc?

That is: is a local variable required to exist at the closing brace of a
function?

I think your answer is "no, it's not required to exist, therefore the
gdb test suite should change".  My answer is "reluctantly, no,
it's not required to exist"; I don't think the famous gcc -O0
debug info clause covers this case.  I'm curious what drow and
carlton and other people have to say.

  void foo ()
  {
    int i;
    i = 1;
    bar (i);
  }

  (gdb) break bar
  (gdb) run
  (gdb) finish
  (gdb) print i

Is it okay for gcc to emit debug info that "i" is out of scope here?

cv> I'd suggest to change the testsuite case to add another line to the
cv> function enums1(), so that it's sure to be still in the scope of the
cv> local variable obj_with_enum.

misc.cc is used by three *.exp files so I do not want to touch it
at all, so I am dis-approving your patch.  I will write a patch to
remove the "gdb_test next" in test_enums instead.

Michael C


^ permalink raw reply	[flat|nested] 38+ messages in thread
* [RFC/RFA] gdb.cp/classes.exp: Don't try to print local variable out of scope
@ 2004-03-19  0:09 Corinna Vinschen
  2004-03-09 13:00 ` Corinna Vinschen
  2004-03-19  0:09 ` Daniel Jacobowitz
  0 siblings, 2 replies; 38+ messages in thread
From: Corinna Vinschen @ 2004-03-19  0:09 UTC (permalink / raw)
  To: gdb-patches

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.


^ permalink raw reply	[flat|nested] 38+ messages in thread
* Re: [RFC/RFA] gdb.cp/classes.exp: Don't try to print local variable out of scope
@ 2004-03-19  0:09 Michael Elizabeth Chastain
  2004-03-10 23:58 ` Michael Elizabeth Chastain
  0 siblings, 1 reply; 38+ messages in thread
From: Michael Elizabeth Chastain @ 2004-03-19  0:09 UTC (permalink / raw)
  To: cagney, drow; +Cc: gdb-patches, mec.gnu, vinschen

ac> I'm wondering what the 3.4 wierdness MichaelC's refering to is.

I'm wondering too.

Here is the big scope bug in 3.4:

  http://gcc.gnu.org/bugzilla/show_bug.cgi?id=13956

There are two more bugs with tree-ssa:

  http://gcc.gnu.org/bugzilla/show_bug.cgi?id=14048
  http://gcc.gnu.org/bugzilla/show_bug.cgi?id=14049

I think I was referring to weirdness with 14048 and 14049,
but is in the tree-ssa branch, not gcc 3.4.

Michael C


^ permalink raw reply	[flat|nested] 38+ messages in thread
* Re: [RFC/RFA] gdb.cp/classes.exp: Don't try to print local variable out of scope
@ 2004-03-19  0:09 Michael Elizabeth Chastain
  2004-03-10  2:06 ` Michael Elizabeth Chastain
  0 siblings, 1 reply; 38+ messages in thread
From: Michael Elizabeth Chastain @ 2004-03-19  0:09 UTC (permalink / raw)
  To: cagney, drow; +Cc: gdb-patches, mec.gnu, vinschen

Too busy to look right now, but my recollection is that gcc 3.4.X
(and later) actually behave a little differently for inner blocks
versus the outermost block of a function.  That is, my recollection
is that the scoping problem happens only with the outermost block.

Michael C


^ permalink raw reply	[flat|nested] 38+ messages in thread
* Re: [RFC/RFA] gdb.cp/classes.exp: Don't try to print local variable out of scope
@ 2004-03-19  0:09 Michael Elizabeth Chastain
  2004-03-09 16:15 ` Michael Elizabeth Chastain
  2004-03-19  0:09 ` Andrew Cagney
  0 siblings, 2 replies; 38+ messages in thread
From: Michael Elizabeth Chastain @ 2004-03-19  0:09 UTC (permalink / raw)
  To: gdb-patches, vinschen

  1 void foo ()
  2 {
  3   int i = 1;
  4   {
  5     int i = 2;
  6     bar(i);
  7   }
  8   bar (i);
  9 }

cv> Is line 7 still in the scope of the inner definition of variable `i'?
cv> Which `i' should be printed at that point?

My intuition says that the inner "i" is in scope at line 7.
That means my intutition is faulty.  :(

> I tested the whole gdb.cp testsuite on linux-x-sh with and without the
> patch and the only difference in the testsuite output where the tests
> directly affected by this change:

I still want to add a copyright notice to misc.cc, and then clone the
file, and then make the change only in classes.cc.  I think it's a bit
better for every test script to have a dedicated unique test program.

Michael C


^ permalink raw reply	[flat|nested] 38+ messages in thread

end of thread, other threads:[~2004-03-15 18:47 UTC | newest]

Thread overview: 38+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-03-19  0:09 [RFC/RFA] gdb.cp/classes.exp: Don't try to print local variable out of scope Michael Elizabeth Chastain
2004-03-09 15:27 ` Michael Elizabeth Chastain
  -- strict thread matches above, loose matches on Subject: below --
2004-03-19  0:09 Michael Elizabeth Chastain
2004-03-09 15:11 ` Michael Elizabeth Chastain
2004-03-09 15:40 ` Corinna Vinschen
2004-03-19  0:09   ` Corinna Vinschen
2004-03-19  0:09 ` Daniel Jacobowitz
2004-03-09 15:20   ` Daniel Jacobowitz
2004-03-19  0:09 Corinna Vinschen
2004-03-09 13:00 ` Corinna Vinschen
2004-03-19  0:09 ` Daniel Jacobowitz
2004-03-09 14:17   ` Daniel Jacobowitz
2004-03-19  0:09 Michael Elizabeth Chastain
2004-03-10 23:58 ` Michael Elizabeth Chastain
2004-03-19  0:09 Michael Elizabeth Chastain
2004-03-10  2:06 ` Michael Elizabeth Chastain
2004-03-19  0:09 Michael Elizabeth Chastain
2004-03-09 16:15 ` Michael Elizabeth Chastain
2004-03-19  0:09 ` Andrew Cagney
2004-03-09 20:38   ` Andrew Cagney
2004-03-09 21:27   ` Daniel Jacobowitz
2004-03-09 22:32     ` Andrew Cagney
2004-03-19  0:09       ` Andrew Cagney
2004-03-19  0:09       ` Daniel Jacobowitz
2004-03-10  0:56         ` Daniel Jacobowitz
2004-03-19  0:09         ` Andrew Cagney
2004-03-10  1:51           ` Andrew Cagney
2004-03-10  3:05           ` Daniel Jacobowitz
2004-03-19  0:09             ` Daniel Jacobowitz
2004-03-19  0:09             ` Daniel Jacobowitz
2004-03-10  3:23               ` Daniel Jacobowitz
2004-03-10 22:21               ` Andrew Cagney
2004-03-10 22:29                 ` Daniel Jacobowitz
2004-03-15 18:47                   ` Andrew Cagney
2004-03-19  0:09                     ` Andrew Cagney
2004-03-19  0:09                   ` Daniel Jacobowitz
2004-03-19  0:09                 ` Andrew Cagney
2004-03-19  0:09     ` Daniel Jacobowitz

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox