Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Jim Blandy <jimb@redhat.com>
To: gdb-patches@sources.redhat.com
Subject: Re: [Jim Blandy <jimb@redhat.com>] RFA: Check that `Local' is not in scope when it shouldn't be
Date: Tue, 04 Feb 2003 22:02:00 -0000	[thread overview]
Message-ID: <vt2el6nww43.fsf@zenia.red-bean.com> (raw)
In-Reply-To: <vt2bs3gpmfb.fsf@zenia.red-bean.com>


Okay, here's a revision of my patch to gdb.c++/local.{c,exp} that
correctly recognizes the two bugs where they occur:
- GDB prints 'class Local' incorrectly
- GDB misunderstands the scope in which 'class Local' is visible
I believe it flags them as known failures in the appropriate way.

David Carlton originally asked:
> I'm confused: don't you want to do the first 'ptype Local' _before_
> going up from foobar?  In which case your added test might as well
> happen after you go up from foobar but before running to marker2.

The test doesn't go up from foobar; it goes up from marker1, which is
called from foobar, so the "up" makes foobar the current scope.

Michael Chastain corrected the way I'd written the second kfail
patch.  I believe I've done it right this time --- so that if the
output changes from the current known incorrect output to anything
other than the correct output, the known failure will become a
straight failure.

I couldn't figure out, though, why folks were advising me to use
setup_kfail with a pattern that always matches, instead of simply
calling kfail directly.  So I just used kfail.

Whip me, beat me, make me write bad checks.

gdb/testsuite/ChangeLog:
2003-02-04  Jim Blandy  <jimb@redhat.com>

	* gdb.c++/local.exp: Don't expect Local to be in scope in main;
	it's local to foobar.  Check for it there, and check that it's not
	present in main.
	* gdb.c++/local.cc (marker2): New function.
	(foobar): Call marker1.
	(main): Call marker2 instead of marker1.

Index: gdb/testsuite/gdb.c++/local.cc
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/gdb.c++/local.cc,v
retrieving revision 1.2
diff -c -r1.2 local.cc
*** gdb/testsuite/gdb.c++/local.cc	10 Apr 2002 03:52:21 -0000	1.2
--- gdb/testsuite/gdb.c++/local.cc	4 Feb 2003 21:07:07 -0000
***************
*** 4,9 ****
--- 4,12 ----
  { 
  }
  
+ void marker2 (void)
+ {
+ }
    
  int foobar (int x)
  {
***************
*** 20,25 ****
--- 23,30 ----
    static Local l1;
    char  c;
  
+   marker1 ();
+ 
    l.loc1 = 23;
  
    c = l.loc_foo('x');
***************
*** 56,61 ****
  
     il.ilc = 'b';
     il.ip = &c;
!    marker1();
   }
  }
--- 61,66 ----
  
     il.ilc = 'b';
     il.ip = &c;
!    marker2();
   }
  }
Index: gdb/testsuite/gdb.c++/local.exp
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/gdb.c++/local.exp,v
retrieving revision 1.10
diff -c -r1.10 local.exp
*** gdb/testsuite/gdb.c++/local.exp	14 Jan 2003 04:34:46 -0000	1.10
--- gdb/testsuite/gdb.c++/local.exp	4 Feb 2003 21:07:07 -0000
***************
*** 67,73 ****
      continue
  }
  
! gdb_test "up" ".*main.*" "up from marker1"
  
  # Local classes in g++ get names like "main.1::InnerLocal", just like local
  # static variables.  Some targets use "___" instead of ".".
--- 67,73 ----
      continue
  }
  
! gdb_test "up" ".*foobar.*" "up from marker1"
  
  # Local classes in g++ get names like "main.1::InnerLocal", just like local
  # static variables.  Some targets use "___" instead of ".".
***************
*** 102,115 ****
  gdb_expect {
    -re "type = class Local \{\[\r\n\t \]*public:\[\r\n\t \]*int loc1;\[\r\n\t \]*char loc_foo\\((const *|)char\\);\[\r\n\t \]*\}.*$gdb_prompt $" { pass "ptype Local" }
    -re "type = class Local \{\[\r\n\t \]*public:\[\r\n\t \]*int loc1;\[\r\n\t \]*char loc_foo\\((const *|)char\\);\[\r\n\t \]*char loc_foo\\((const *|)char\\);\[\r\n\t \]*\}.*$gdb_prompt $" {
!     # setup_kfail "gdb/483"
!     fail "ptype Local (gdb/483)"
    }
    -re "type = class Local \{\[\r\n\t \]*public:\[\r\n\t \]*int loc1;\[\r\n\t \]*Local & operator *=\\((foobar__Fi${sep}::|)Local const *&\\);\[\r\n\t \]*Local\\((foobar__Fi${sep}::|)Local const *&\\);\[\r\n\t \]*Local\\((void|)\\);\[\r\n\t \]*char loc_foo\\(char\\);\[\r\n\t \]*\}.*$gdb_prompt $" { pass "ptype Local" }
    -re "type = class Local \{\r\n\[\t \]*public:\r\n\[\t \]*int loc1;\r\n\r\n\[\t \]*char loc_foo\\(char\\);\r\n\[\t \]*\\(Local at.*local\\.cc:\[0-9\]*\\)\r\n\}.*$gdb_prompt $" { xpass "ptype Local (old aCC)" }
    -re ".*$gdb_prompt $"   {  fail "ptype Local" }
    timeout             { fail "(timeout) ptype Local" }
  }
  
  # DTS CLLbs14316 and CLLbs17058
  # coulter - I added a clause for HP's aCC compiler.  We print out the type
--- 102,144 ----
  gdb_expect {
    -re "type = class Local \{\[\r\n\t \]*public:\[\r\n\t \]*int loc1;\[\r\n\t \]*char loc_foo\\((const *|)char\\);\[\r\n\t \]*\}.*$gdb_prompt $" { pass "ptype Local" }
    -re "type = class Local \{\[\r\n\t \]*public:\[\r\n\t \]*int loc1;\[\r\n\t \]*char loc_foo\\((const *|)char\\);\[\r\n\t \]*char loc_foo\\((const *|)char\\);\[\r\n\t \]*\}.*$gdb_prompt $" {
!     kfail "gdb/483" "ptype Local"
    }
    -re "type = class Local \{\[\r\n\t \]*public:\[\r\n\t \]*int loc1;\[\r\n\t \]*Local & operator *=\\((foobar__Fi${sep}::|)Local const *&\\);\[\r\n\t \]*Local\\((foobar__Fi${sep}::|)Local const *&\\);\[\r\n\t \]*Local\\((void|)\\);\[\r\n\t \]*char loc_foo\\(char\\);\[\r\n\t \]*\}.*$gdb_prompt $" { pass "ptype Local" }
    -re "type = class Local \{\r\n\[\t \]*public:\r\n\[\t \]*int loc1;\r\n\r\n\[\t \]*char loc_foo\\(char\\);\r\n\[\t \]*\\(Local at.*local\\.cc:\[0-9\]*\\)\r\n\}.*$gdb_prompt $" { xpass "ptype Local (old aCC)" }
    -re ".*$gdb_prompt $"   {  fail "ptype Local" }
    timeout             { fail "(timeout) ptype Local" }
  }
+ 
+ gdb_test "break marker2"
+ gdb_test "continue" "Continuing\\..*Breakpoint \[0-9\]+, marker2.*" \
+     "continuing to marker2"
+ 
+ gdb_test "up" ".*main.*" "up from marker2"
+ 
+ # Make sure that `Local' isn't in scope here; it's local to foobar.
+ # setup_kfail "gdb/825"
+ send_gdb "ptype Local\n"
+ set eol "\[\t \]*\[\r\n\]+\[\t \]*"
+ gdb_expect {
+     -re "No symbol \"Local\" in current context.*${gdb_prompt} $" {
+         pass "Local out of scope"
+     }
+     -re "ptype Local${eol}type = class Local {${eol}  public:${eol}    int loc1;${eol}${eol}    Local & operator=\\(Local const&\\);${eol}    Local\\(Local const&\\);${eol}    Local\\(\\);${eol}    char loc_foo\\(char\\);${eol}}${eol}${gdb_prompt} " {
+         # GCC emits STABS debugging information in a way that doesn't
+         # properly preserve the scoping of local classes.  I think
+         # we'd need to start using Sun's extensions to stabs to get
+         # this right.
+         kfail gdb/825 "Local out of scope"
+     }
+     -re ".*${gdb_prompt} $" {
+         fail "Local out of scope"
+     }
+     timeout {
+         fail "Local out of scope (timeout)"
+     }
+ }
+         
  
  # DTS CLLbs14316 and CLLbs17058
  # coulter - I added a clause for HP's aCC compiler.  We print out the type


  parent reply	other threads:[~2003-02-04 22:02 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-12-20 10:56 Jim Blandy
2002-12-20 11:19 ` Daniel Jacobowitz
2002-12-20 12:05   ` David Carlton
2002-12-20 12:01 ` David Carlton
2002-12-20 12:18   ` David Carlton
2003-02-04 22:02 ` Jim Blandy [this message]
2003-02-04 22:16   ` David Carlton
2003-02-05  5:49     ` Jim Blandy
2002-12-20 21:12 Michael Elizabeth Chastain
2002-12-23 22:51 Michael Elizabeth Chastain
2003-02-05  6:23 Michael Elizabeth Chastain

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=vt2el6nww43.fsf@zenia.red-bean.com \
    --to=jimb@redhat.com \
    --cc=gdb-patches@sources.redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox