This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [RFA] Add testcase for locals identified with FUNCTION::VAR syntax.


> Date: Tue, 27 Dec 2011 16:58:14 -0800
> From: Doug Evans <dje@google.com>
> Cc: gdb-patches@sourceware.org
> Content-Type: text/plain; charset=ISO-8859-1
> 
> On Tue, Dec 27, 2011 at 11:59 AM, Paul Hilfinger <Hilfinger@adacore.com> wrote:
> >
> > This test (from Joel Brobecker) stops inside a recursive function
> > after a few levels of recursion, goes up some frames, and then
> > accesses a local variable with 'print foo::val' rather than the usual
> > 'print val' to see if the former pays attention to the selected frame.
> >
...
> > +
> > +# Some convenient regular expressions...
> > +set num "\[0-9\]+"
> 
> Delete, use $decimal.

OK.

> > +set addr "0x\[0-9a-zA-Z\]+"
> 
> This could be replaced with $hex, or do "set addr $hex".  Either is
> fine with me.

OK.

> 
> > +
> > +gdb_test "break $srcfile:[gdb_get_line_number BREAK $srcfile] if n == 3" \
> > + Â Â Â Â "Breakpoint $num at $addr: file .*recpar\\.c, line $num\\."
> > +
> > +gdb_test "continue" \
> > + Â Â Â Â "Breakpoint .* foo \\(n=3\\) at .*$srcfile:$num.*"
> > +
> > +gdb_test "backtrace" \
> > + Â Â Â Â "#0 +foo \\(n=3\\).*\r\n#1.* foo \\(n=4\\).*\r\n#2.* foo \\(n=5\\).*#3.* main \\(\\).*"
> > +
> > +gdb_test "frame 2" \
> > + Â Â Â Â "#2 .* foo \\(n=5\\) .*"
> > +
> > +# In the currently selected frame, n=5, and thus foo::val should be 5
> > +# as well.
> > +gdb_test "print foo::val" \
> > + Â Â Â Â " = 5"
> > --

> I notice scope.exp has similar tests.
> Would it make sense to move this there?
> 

I defer to whatever consensus develops.  All the tests in scope.c that use "::" 
stick to static variables, whereas the new test uses :: in an admittedly
undocumented fashion and concerns dynamic, rather than static, scoping. However,
I don't know what criteria there are for grouping tests.  

Thanks for your comments.

-- 
Paul N. Hilfinger
(Hilfinger@adacore.com)


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]