This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
[patch][python PR python/16497 (bt n produces an off-by-one error)
- From: Phil Muldoon <pmuldoon at redhat dot com>
- To: gdb-patches at sourceware dot org
- Date: Fri, 21 Feb 2014 13:43:19 +0000
- Subject: [patch][python PR python/16497 (bt n produces an off-by-one error)
- Authentication-results: sourceware.org; auth=none
This patch fixes a case where a positive count to the "bt" command was
passed to the frame filters as a count, instead of a range. The inner
API of the frame filter print code takes a range, but "bt n" provides
a count (e.g, bt 5, five frames). This test fixes the off-by-one
error, and also tightens the regex on the existing "bt n" tests to
make sure they fail if the expected number of frames is incorrect.
2014-02-21 Phil Muldoon <pmuldoon@redhat.com>
PR python/16497
* gdb.python/py-framefilter.exp: Make bt 1 tests more restrictive
on end of line testing.
2014-02-21 Phil Muldoon <pmuldoon@redhat.com>
* stack.c (backtrace_command_1): Fix off-by-one error in frame
filters specified with a count.
diff --git a/gdb/stack.c b/gdb/stack.c
index 54553bc..96fc1a9 100644
--- a/gdb/stack.c
+++ b/gdb/stack.c
@@ -1752,7 +1752,7 @@ backtrace_command_1 (char *count_exp, int show_locals, int no_filters,
else
{
py_start = 0;
- py_end = count;
+ py_end = count - 1;
}
}
else
diff --git a/gdb/testsuite/gdb.python/py-framefilter.exp b/gdb/testsuite/gdb.python/py-framefilter.exp
index 948ae94..6ff7cd2 100644
--- a/gdb/testsuite/gdb.python/py-framefilter.exp
+++ b/gdb/testsuite/gdb.python/py-framefilter.exp
@@ -138,13 +138,14 @@ gdb_test "bt full" \
# Test set print frame-arguments
# none
+set snum [gdb_get_line_number "Backtrace end breakpoint"]
gdb_test_no_output "set print frame-arguments none" \
"turn off frame arguments"
gdb_test "bt no-filter 1" \
"#0.*end_func \\(foo=\.\.\., bar=\.\.\., fb=\.\.\., bf=\.\.\.\\) at .*py-framefilter.c.*" \
"bt no-filter 1 no args"
gdb_test "bt 1" \
- "#0.*end_func \\(foo=\.\.\., bar=\.\.\., fb=\.\.\., bf=\.\.\.\\) at .*py-framefilter.c.*" \
+ "#0.*end_func \\(foo=\.\.\., bar=\.\.\., fb=\.\.\., bf=\.\.\.\\) at .*py-framefilter.c\:$snum" \
"bt 1 no args"
# scalars
@@ -154,7 +155,7 @@ gdb_test "bt no-filter 1" \
"#0.*end_func \\(foo=21, bar=$hex \"Param\", fb=$hex, bf=\.\.\.\\) at .*py-framefilter.c.*" \
"bt no-filter 1 scalars"
gdb_test "bt 1" \
- "#0.*end_func \\(foo=21, bar=$hex \"Param\", fb=$hex, bf=\.\.\.\\) at .*py-framefilter.c.*" \
+ "#0.*end_func \\(foo=21, bar=$hex \"Param\", fb=$hex, bf=\.\.\.\\) at .*py-framefilter.c\:$snum" \
"bt 1 scalars"
# all
@@ -164,7 +165,7 @@ gdb_test "bt no-filter 1" \
"#0.*end_func \\(foo=21, bar=$hex \"Param\", fb=$hex, bf=\{nothing = $hex \"Foo Bar\", f = 42, s = 19\}\\) at .*py-framefilter.c.*" \
"bt no-filter 1 all args"
gdb_test "bt 1" \
- "#0.*end_func \\(foo=21, bar=$hex \"Param\", fb=$hex, bf=\{nothing = $hex \"Foo Bar\", f = 42, s = 19\}\\) at .*py-framefilter.c.*" \
+ "#0.*end_func \\(foo=21, bar=$hex \"Param\", fb=$hex, bf=\{nothing = $hex \"Foo Bar\", f = 42, s = 19\}\\) at .*py-framefilter.c\:$snum" \
"bt 1 all args"
# set print address off
@@ -174,7 +175,7 @@ gdb_test "bt no-filter 1" \
"#0 end_func \\(foo=21, bar=\"Param\", fb=, bf=\{nothing = \"Foo Bar\", f = 42, s = 19\}\\) at .*py-framefilter.c.*" \
"bt no-filter 1 no address"
gdb_test "bt 1" \
- "#0 end_func \\(foo=21, bar=\"Param\", fb=, bf=\{nothing = \"Foo Bar\", f = 42, s = 19\}\\) at .*py-framefilter.c.*" \
+ "#0 end_func \\(foo=21, bar=\"Param\", fb=, bf=\{nothing = \"Foo Bar\", f = 42, s = 19\}\\) at .*py-framefilter.c\:$snum" \
"bt 1 no addresss"
gdb_test_no_output "set python print-stack message" \