From: Paul Gilliam <pgilliam@us.ibm.com>
To: gdb-patches@sources.redhat.com
Cc: Daniel Jacobowitz <drow@false.org>
Subject: [PATCH] add new .exp file and a 'c' testfile to test backtrace limits etc.
Date: Fri, 15 Apr 2005 23:03:00 -0000 [thread overview]
Message-ID: <200504151602.39257.pgilliam@us.ibm.com> (raw)
In-Reply-To: <20050414193642.GB19792@nevyn.them.org>
[-- Attachment #1: Type: text/plain, Size: 918 bytes --]
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.
-=# Paul #=-
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.
[-- Attachment #2: setbacktrace.c --]
[-- Type: text/x-csrc, Size: 1199 bytes --]
/* 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. */
#include <stdlib.h>
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: main call */
}
[-- Attachment #3: setbacktrace.exp --]
[-- Type: text/plain, Size: 5550 bytes --]
# 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: main call"]
# Set how deep should we go and build the expected_frames pattern list.
set leadin "\[^\r\n\]*\[\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 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
# 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, ignore extra"
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, via argument"
set partial_depth [expr int($subr_depth / 2)]
set partial_frames [lrange $expected_frames 0 [expr $partial_depth - 1]]
lappend partial_frames "$leadin\\(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 "$leadin$gdb_prompt $" $partial_frames
## Check a backtrace short of main due to limit.
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
# Check a backtrace past main, specify a backtrace limit so it does not fall off the end of the stack.
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
next prev parent reply other threads:[~2005-04-15 23:03 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-04-07 17:27 [PATCH] Fixes testsuit/gdb.base/annota1.exp Paul Gilliam
2005-04-14 19:36 ` Daniel Jacobowitz
2005-04-15 23:03 ` Paul Gilliam [this message]
2005-04-30 18:49 ` [PATCH] add new .exp file and a 'c' testfile to test backtrace limits etc Daniel Jacobowitz
2005-05-28 23:42 ` Daniel Jacobowitz
2005-04-15 23:38 ` [PATCH] Fixes testsuit/gdb.base/annota1.exp Paul Gilliam
2005-04-27 15:49 ` Daniel Jacobowitz
2005-04-27 20:02 ` Paul Gilliam
2005-04-15 23:38 ` [PATCH] Fixes testsuit/gdb.base/annota1.exp to deal with 'Breakpoint address adjusted' Paul Gilliam
2005-04-27 15:43 ` Daniel Jacobowitz
2005-04-27 21:47 ` [COMMIT] " Paul Gilliam
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=200504151602.39257.pgilliam@us.ibm.com \
--to=pgilliam@us.ibm.com \
--cc=drow@false.org \
--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