This is the mail archive of the gdb-patches@sources.redhat.com 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: [PATCH] add new .exp file and a 'c' testfile to test backtrace limits etc.


This test is going to need a little work still.  Thanks for starting
it.

On Fri, Apr 15, 2005 at 03:02:39PM -0800, Paul Gilliam wrote:
> OK.  this is in partial responce to:
> 	http://sourceware.org/ml/gdb-patches/2005-04/msg00145.html
> 
> This patch adds a new test file, setbacktrace.exp along with a new 'c' test program,
> setbacktrace.c.
> 
> The purpose of this new test is to check backtrace releated features not tested
> elsewhere in the testsuit:
>    *  Check that we know what backtrace options are available.
>    *  Check that GDB will only backtrace the requested number of frames.
>    *  Check that GDB doesn't backtrace past main unless asked to do so.
> 
> One problem:  I don't know how to add new files in a patch.  So I have attached the files
> and include only the ChangeLog entry here in the body of this e-mail.

You diff it against /dev/null; either by hand or by adding a dummy line
to CVS/Entries.  There's also "cvsdo add" in the cvsutils package,
which automates that.

> 2005-04-15   Paul Gililam  <pgilliam@us.ibm.com>
> 
> 	* gdb.base/setbacktrace.exp (new file): Check backtrace releated
>         features not tested elsewhere.
>         * gdb.base/setbacktrace.c (new file): Test case used by above.
> 

	* gdb.base/setbacktrace.exp, gdb.base/setbacktrace.c: New
	files.

> /* This testcase is part of GDB, the GNU debugger.
> 
>    Copyright 2004 Free Software Foundation, Inc.

> # This file is part of the gdb testsuite.
> 
> # Copyright 2004 Free Software Foundation, Inc.

2005 now.

> # This program is free software; you can redistribute it and/or modify
> # it under the terms of the GNU General Public License as published by
> # the Free Software Foundation; either version 2 of the License, or
> # (at your option) any later version.
> #
> # This program is distributed in the hope that it will be useful,
> # but WITHOUT ANY WARRANTY; without even the implied warranty of
> # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
> # GNU General Public License for more details.
> #
> # You should have received a copy of the GNU General Public License
> # along with this program; if not, write to the Free Software
> # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  
> 
> # Check backtrace releated features not tested elsewhere in the testsuit:

"testsuite".


> if $tracelevel {
>     strace $tracelevel
> }
> 
> set prms_id 0
> set bug_id 0

I'm pretty sure this isn't necessary any more.

> # Set how deep should we go and build the expected_frames pattern list.
> set leadin "\[^\r\n\]*\[\r\n\]+"

This is very permissive.  Do you really need to allow so much?  This
will accept garbage at the end of lines.  Otherwise the pattern
construction is very nice.

> # Advance to main
> if { ![runto_main] } then {
>     gdb_suppress_tests;
> }

Please don't use gdb_suppress_tests.

> # Check that someone has not snuck in an extra backtrace option, if
> # they do they will need to fix this and any such fix should also be
> # accompanied by a corresponding SET test.
> set test "set backtrace"
> send_gdb "set backtrace\n"
> set backtrace_subcommands [list \
> 	 "${leadin}List of set backtrace subcommands:" \
> 	 "${leadin}set backtrace limit -- Set an upper bound on the number of backtrace levels" \
> 	 "${leadin}set backtrace past-main -- Set whether backtraces should continue past \"main\"" \
> 	 "${leadin}Type \"help set backtrace\" followed by set backtrace subcommand name for full documentation." \
> 	 "${leadin}Command name abbreviations are allowed if unambiguous."]
> gdb_expect_list $test ".*$gdb_prompt $" $backtrace_subcommands

Did you test this testcase? :-)  There's "set backtrace past-entry"
now.  Also, same comment about ${leadin}.

> # Check a backtrace to main (don't ignore any extra).
> #setup_kfail *-*-* gdb/1760
> set test "full backtrace, exact"
> send_gdb "backtrace\n"
> gdb_expect_list $test "\[\n\r\]+$gdb_prompt $" $expected_frames

I don't think this does what you want it to do.  It won't ignore any
extra, and it won't ignore garbage between frames.  You probably want
to construct a single regular expression using string concatenation
rather than list append.

That's a general comment, it applies to all the uses of
gdb_expect_list.

> set test "partial backtrace, via limit"
> set partial_frames [lrange $expected_frames 0 [expr $partial_depth - 1]]
> lappend partial_frames "^\[\n\r]+Backtrace limit of $partial_depth exceeded"
> #for {set ndx 0} {$ndx < [llength $partial_frames]} {incr ndx} {
> #  puts "$ndx:  [lindex $partial_frames $ndx]"
> #}
> gdb_test "set backtrace limit $partial_depth" ".*" "Set the backtrace limit to $partial_depth"
> setup_kfail *-*-* gdb/1760
> send_gdb "backtrace\n"
> gdb_expect_list $test "\[\r\n]+$gdb_prompt $" $partial_frames

It would be better to use gdb_test_multiple and explicitly match the
KFAIL.  And to document what the problem is.

> # Check a backtrace past main, specify a backtrace limit so it does not fall off the end of the stack.

Wrap long lines where it's easy to do, please.  It's not worth the
trouble for most TCL, but comments are easy.

> set test "backtrace past main"
> set bt_limit [expr $subr_depth + 3]
> gdb_test "set backtrace past-main" ".*" "Set the backtrace past-main"
> gdb_test "set backtrace limit 0" ".*" "Set the backtrace limit to unlimited"
> set extra_frames $expected_frames
> lappend extra_frames [format "$leadin#%-2d $hex in \[^ \]+ \\(\[^\\)]*\\) \[^\r\n]*" [expr $subr_depth + 2]]
> lappend extra_frames "\\(More stack frames follow\\.\\.\\.\\)"
> #for {set ndx 0} {$ndx < [llength $extra_frames]} {incr ndx} {
> #  puts "$ndx:  [lindex $extra_frames $ndx]"
> #}
> send_gdb "backtrace $bt_limit\n"
> gdb_expect_list $test "$leadin$gdb_prompt $" $extra_frames

I'm not sure how portable this is... especially since you're requiring
there be at least one GDB-detectable frame past main.

-- 
Daniel Jacobowitz
CodeSourcery, LLC


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