From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 9070 invoked by alias); 22 Oct 2004 17:00:14 -0000 Mailing-List: contact gdb-patches-help@sources.redhat.com; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sources.redhat.com Received: (qmail 8995 invoked from network); 22 Oct 2004 17:00:11 -0000 Received: from unknown (HELO us.ibm.com) (32.97.110.142) by sourceware.org with SMTP; 22 Oct 2004 17:00:11 -0000 Received: by us.ibm.com (Postfix, from userid 1000) id 12A65119FB; Fri, 22 Oct 2004 09:57:46 -0700 (PDT) From: Paul Gilliam Reply-To: pgilliam@us.ibm.com To: gdb-patches@sources.redhat.com Subject: Re: [patch] New test for set backtrace related functionality Date: Fri, 22 Oct 2004 17:00:00 -0000 User-Agent: KMail/1.6.2 Cc: Michael Chastain References: <200410141539.22560.pgilliam@us.ibm.com> <200410210955.15904.pgilliam@us.ibm.com> <41792E5A.nailCWS110OUT@mindspring.com> In-Reply-To: <41792E5A.nailCWS110OUT@mindspring.com> MIME-Version: 1.0 Content-Disposition: inline Content-Type: Multipart/Mixed; boundary="Boundary-00=_KwTeB21pifxIRBW" Message-Id: <200410220957.46790.pgilliam@us.ibm.com> X-SW-Source: 2004-10/txt/msg00369.txt.bz2 --Boundary-00=_KwTeB21pifxIRBW Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Content-Disposition: inline Content-length: 402 On Friday 22 October 2004 08:59, Michael Chastain wrote: > Paul Gilliam wrote: > > one week ping. > ... > Some of the lines in setbacktrace.exp are incorrectly formatted > (weird line wrapping after the '+' markers have been inserted). > you send me a clean copy of the files, by sending them as attachments > perhaps? > ... > Michael OK, here they are. Thanks, -=# Paul #=- --Boundary-00=_KwTeB21pifxIRBW Content-Type: text/x-csrc; charset="iso-8859-1"; name="setbacktrace.c" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="setbacktrace.c" Content-length: 1182 /* This testcase is part of GDB, the GNU debugger. Copyright 2004 Free Software Foundation, Inc. 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. */ int factorial (int n) { if (n > 0) { /* marker: factorial */ return factorial (n - 1) * n; /* marker: factorial recursion */ } else { return 1; } } int main (int argc, char *argv[]) { int depth = 3; if (argc > 1) { depth = atoi(argv[1]); } return factorial (depth); /* marker: call from main */ } --Boundary-00=_KwTeB21pifxIRBW Content-Type: text/plain; charset="iso-8859-1"; name="setbacktrace.exp" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="setbacktrace.exp" Content-length: 5504 # This file is part of the gdb testsuite. # Copyright 2004 Free Software Foundation, Inc. # 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: # * 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. if $tracelevel { strace $tracelevel } set prms_id 0 set bug_id 0 set testfile setbacktrace set srcfile ${testfile}.c set escapedsrcfile [string_to_regexp "${srcdir}/${subdir}/${srcfile}"] set binfile ${objdir}/${subdir}/${testfile} if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } { untested "Couldn't compile ${testfile}.c" return -1 } set fact_subr_line_nbr [gdb_get_line_number "marker: factorial"] set fact_recur_line_nbr [gdb_get_line_number "marker: factorial recursion"] set main_subr_line_nbr [gdb_get_line_number "marker: call from main"] # Set how deep should we go and build the expected_frames pattern list. set leadin ".*\[\r\n\]" set subr_depth 20 set expected_frames [list "$leadin#0 factorial \\(n=0\\) at $escapedsrcfile:$fact_subr_line_nbr"] for {set ndx 1} {$ndx <= $subr_depth} {incr ndx} { lappend expected_frames [format "$leadin#%-2d $hex in factorial \\(n=$ndx\\) at $escapedsrcfile:$fact_recur_line_nbr" $ndx] } lappend expected_frames [format "$leadin#%-2d $hex in main \\(argc=2, argv=$hex\\) at $escapedsrcfile:$main_subr_line_nbr" [expr $subr_depth + 1]] #for {set ndx 0} {$ndx < [expr $subr_depth + 2]} {incr ndx} { # puts "$ndx: [lindex $expected_frames $ndx]" #} # get things started gdb_exit gdb_start gdb_reinitialize_dir $srcdir/$subdir gdb_load ${binfile} gdb_test "set args $subr_depth" # Advance to main if { ![runto_main] } then { 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 foobar [list \ ".*\[\n\r\]+List of set backtrace subcommands:" \ ".*\[\n\r\]+set backtrace limit -- Set an upper bound on the number of backtrace levels" \ ".*\[\n\r\]+set backtrace past-main -- Set whether backtraces should continue past \"main\"" \ ".*\[\n\r\]+Type \"help set backtrace\" followed by set backtrace subcommand name for full documentation." \ ".*\[\n\r\]+Command name abbreviations are allowed if unambiguous."] gdb_expect_list $test ".*$gdb_prompt $" $foobar # Create a simple stack. gdb_test "break factorial if n == 0" gdb_continue_to_breakpoint "factorial" # Check a backtrace to main (ignore any extra). set test "full backtrace" send_gdb "backtrace\n" gdb_expect_list $test ".*$gdb_prompt $" $expected_frames # 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 # Check a backtrace short of main. set test "partial backtrace" set partial_depth [expr int($subr_depth / 2)] set partial_frames [lrange $expected_frames 0 [expr $partial_depth - 1]] lappend partial_frames "\[\n\r\]\\(More stack frames follow\\.\\.\\.\\)" #for {set ndx 0} {$ndx < [expr $partial_depth + 2]} {incr ndx} { # puts "$ndx: [lindex $partial_frames $ndx]" #} send_gdb "backtrace $partial_depth\n" gdb_expect_list $test "\[\n\r\]+$gdb_prompt $" $partial_frames ## Check a backtrace short of main due to limit. set test "partial backtrace (using 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 # Check a backtrace past main, specify a backtrace limit so it does not fall off the end of the stack. 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 [lrange $expected_frames 0 [expr $subr_depth + 2]] lappend extra_frames [format "$leadin#%-2d $hex in \[^ \]+ \\(\[^\\)]*\\) .*" [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 ".*\[\r\n]+$gdb_prompt $" $extra_frames --Boundary-00=_KwTeB21pifxIRBW--