* [PATCH 1/4] list.exp: Catch "set listsize" failures (and "set listsize -1/0"'s history).
2013-03-28 6:28 [PATCH 0/4 v2] [mainline+7.6] PR gdb/15294: list with unlimited listsize broken Pedro Alves
@ 2013-03-28 1:11 ` Pedro Alves
2013-03-28 6:09 ` [PATCH 2/4] list.exp: Adjust "set listsize -1" to current test source's real line count Pedro Alves
` (3 subsequent siblings)
4 siblings, 0 replies; 8+ messages in thread
From: Pedro Alves @ 2013-03-28 1:11 UTC (permalink / raw)
To: gdb-patches
As mentioned in the intro, before the changes starting at
http://sourceware.org/ml/gdb-patches/2012-08/msg00020.html, the 'set
listsize' command only accepted "0" as special value, meaning
"unlimited". The testsuite actually tried "set listsize -1" and
expected that to mean unlimited too.
If you tried testing list.exp at the time of that patch above,
you'd get:
(gdb) PASS: gdb.base/list.exp: list line 10 with listsize 100
set listsize 0
(gdb) PASS: gdb.base/list.exp: setting listsize to 0 #6
show listsize
Number of source lines gdb will list by default is unlimited.
(gdb) PASS: gdb.base/list.exp: show listsize unlimited #6
list 1
1 #include "list0.h"
2
...
42 /* Not used for anything */
43 }
(gdb) PASS: gdb.base/list.exp: listsize of 0 suppresses output
set listsize -1
integer 4294967295 out of range
(gdb) PASS: gdb.base/list.exp: setting listsize to -1 #7
show listsize
Number of source lines gdb will list by default is unlimited.
(gdb) PASS: gdb.base/list.exp: show listsize unlimited #7
list 1
1 #include "list0.h"
Notice that "set listsize -1" actually failed with "integer 4294967295
out of range", but we issued a PASS anyway.
(and notice how the "listsize of 0 suppresses output" test passes bogusly too.)
This patch fixes that testsuite problem in the obvious way.
gdb/testsuite/
2013-03-21 Pedro Alves <palves@redhat.com>
* gdb.base/list.exp (set_listsize): Use gdb_test_no_output for
"set listsize".
---
gdb/testsuite/gdb.base/list.exp | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/gdb/testsuite/gdb.base/list.exp b/gdb/testsuite/gdb.base/list.exp
index d1bdeee..8684b0c 100644
--- a/gdb/testsuite/gdb.base/list.exp
+++ b/gdb/testsuite/gdb.base/list.exp
@@ -58,7 +58,7 @@ proc set_listsize { arg } {
global set_listsize_count;
incr set_listsize_count;
- if [gdb_test "set listsize $arg" ".*" "setting listsize to $arg #$set_listsize_count"] {
+ if [gdb_test_no_output "set listsize $arg" "setting listsize to $arg #$set_listsize_count"] {
return 0
}
if { $arg < 0 } {
^ permalink raw reply [flat|nested] 8+ messages in thread
* [PATCH 2/4] list.exp: Adjust "set listsize -1" to current test source's real line count.
2013-03-28 6:28 [PATCH 0/4 v2] [mainline+7.6] PR gdb/15294: list with unlimited listsize broken Pedro Alves
2013-03-28 1:11 ` [PATCH 1/4] list.exp: Catch "set listsize" failures (and "set listsize -1/0"'s history) Pedro Alves
@ 2013-03-28 6:09 ` Pedro Alves
2013-03-28 7:44 ` [PATCH 3/4] list.exp: Avoid hardcoding line numbers Pedro Alves
` (2 subsequent siblings)
4 siblings, 0 replies; 8+ messages in thread
From: Pedro Alves @ 2013-03-28 6:09 UTC (permalink / raw)
To: gdb-patches
The "set listsize -1" test in list.exp can't work correct anymore
nowadays, because the test's source files grew over time, and this
particular test was never updated.
This fixes it in the obvious way.
gdb/testsuite/
2013-03-21 Pedro Alves <palves@redhat.com>
* gdb.base/list.exp (test_listsize): Adjust test to make sure we
list the whole file.
---
gdb/testsuite/gdb.base/list.exp | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/gdb/testsuite/gdb.base/list.exp b/gdb/testsuite/gdb.base/list.exp
index 8684b0c..97cca91 100644
--- a/gdb/testsuite/gdb.base/list.exp
+++ b/gdb/testsuite/gdb.base/list.exp
@@ -138,7 +138,7 @@ proc test_listsize {} {
set_listsize -1
setup_xfail "*-*-*"
- gdb_test "list 1" "1\[ \t\]+#include .*\r\n39\[ \t\]+\}" "list line 1 with unlimited listsize"
+ gdb_test "list 1" "1\[ \t\]+#include .*\r\n43\[ \t\]+\}" "list line 1 with unlimited listsize"
}
#
^ permalink raw reply [flat|nested] 8+ messages in thread
* [PATCH 0/4 v2] [mainline+7.6] PR gdb/15294: list with unlimited listsize broken
@ 2013-03-28 6:28 Pedro Alves
2013-03-28 1:11 ` [PATCH 1/4] list.exp: Catch "set listsize" failures (and "set listsize -1/0"'s history) Pedro Alves
` (4 more replies)
0 siblings, 5 replies; 8+ messages in thread
From: Pedro Alves @ 2013-03-28 6:28 UTC (permalink / raw)
To: gdb-patches
"set listsize -1" is currently broken:
(gdb) set listsize -1
(gdb) show listsize
Number of source lines gdb will list by default is unlimited.
(gdb) list 1
(gdb) list 1
(gdb) list 1
(gdb) set listsize 10
(gdb) list 1
1 /* Main function for CLI gdb.
2 Copyright (C) 2002-2013 Free Software Foundation, Inc.
3
4 This file is part of GDB.
5
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 3 of the License, or
9 (at your option) any later version.
10
Looking up the history behind the behaviour changes of
"set listsize -1", I wrote the below. Patches will follow as reply to
this message.
Before the changes starting at
<http://sourceware.org/ml/gdb-patches/2012-08/msg00020.html>, the 'set
listsize' command only accepted "0" as special value, meaning
"unlimited". The testsuite actually tried "set listsize -1" and
expected that to mean unlimited too.
If you tried testing list.exp at the time of that patch above,
you'd get:
(gdb) PASS: gdb.base/list.exp: list line 10 with listsize 100
set listsize 0
(gdb) PASS: gdb.base/list.exp: setting listsize to 0 #6
show listsize
Number of source lines gdb will list by default is unlimited.
(gdb) PASS: gdb.base/list.exp: show listsize unlimited #6
list 1
1 #include "list0.h"
2
...
42 /* Not used for anything */
43 }
(gdb) PASS: gdb.base/list.exp: listsize of 0 suppresses output
set listsize -1
integer 4294967295 out of range
(gdb) PASS: gdb.base/list.exp: setting listsize to -1 #7
show listsize
Number of source lines gdb will list by default is unlimited.
(gdb) PASS: gdb.base/list.exp: show listsize unlimited #7
list 1
1 #include "list0.h"
Notice that "set listsize -1" actually failed with "integer 4294967295
out of range", but we issued a PASS anyway.
Looking through ancient history, I see e.g., in gdb 4.1 (back in 1991,
yes), "set listsize" was a var_uinteger command (therefore, supposedly
treated as unsigned):
https://github.com/palves/gdb-old-releases/blob/7e43f573878c3c1b8458ddb3240b635f284b59c2/gdb/source.c
add_show_from_set
(add_set_cmd ("listsize", class_support, var_uinteger,
(char *)&lines_to_list,
"Set number of source lines gdb will list by default.",
&setlist),
But the set command handling actually treated it as signed ...
https://github.com/palves/gdb-old-releases/blob/7e43f573878c3c1b8458ddb3240b635f284b59c2/gdb/command.c
case var_uinteger:
if (arg == NULL)
error_no_arg ("integer to set it to.");
*(int *) c->var = parse_and_eval_address (arg);
if (*(int *) c->var == 0)
*(int *) c->var = UINT_MAX;
break;
But then, by 4.9 (1993), var_integer was added, and var_uinteger was
fixed like so:
case var_uinteger:
if (arg == NULL)
error_no_arg ("integer to set it to.");
*(unsigned int *) c->var = parse_and_eval_address (arg);
if (*(unsigned int *) c->var == 0)
*(unsigned int *) c->var = UINT_MAX;
break;
However, "listsize" was still registered as an unsigned command, with
a signed control variable. This meant that from 4.9 on, "set listsize -1"
actually was equivalent to "set listsize UINT_MAX".
I didn't find any old gdb where "set listsize 0" actually ever meant
"suppress printing". The first testsuite we have access to appears on
4.10 (thus after set listsize -1 meaning unlimited", and it has:
# Try listsize of 0 which suppresses printing.
send "set listsize 0\n"
expect {
-re "set listsize 0\r\n$prompt $" {
setup_xfail "*-*-*"
send "show listsize\n"
expect {
-re "Number of source lines .* is 0.\r\n.*$prompt $" {
pass "listsize of 0 displays as 0"
}
-re "Number of source lines .* is unlimited.\r\n.*$prompt $" {
fail "listsize of 0 displays as unlimited"
}
}
}
Notice the "setup_xfail". So this was failing at the time, and the
test was written to accept the failure as indication that GDB's
behavior was not ideal.
Later on, the "set listsize" command was changed to a var_integer
(made sense, since the controlling variable is actually signed), which
made "set listsize -1" not work anymore.
http://sourceware.org/ml/gdb-patches/2006-01/msg00176.html
Dan wrote:
"This doesn't substantively change the result of typing "set listsize
-1", which shouldn't really be allowed either before or after.
Someone else can get inspired and fix that one."
The one change that caused was that the var_integer set command
handling did have range validation, so -1 has since been flagged as
invalid, but the testsuite was buggy and never caught the "integer
4294967295 out of range" regression.
So from that point on, _only_ "set listsize 0" meant unlimited.
The testsuite disagreed with GDB's behavior all along, because whoever
wrote the list.exp test clearly thought -1 should mean unlimited, and
0 no output.
It was only years later, recently (after 7.5) that after all this
confusion, we changed GDB to actually do what the original list.exp
test expected. Well, set listsize -1 got broken in the progress, and
that went unnoticed because the test is actually broken, and, has a
setup_xfail "*-*-*" anyway...
In this version of the series, I'm actually proposing to revert back
the behavior of "set listsize 0" to mean unlimited.
In v1, I suggested fixing the code and keeping the new behavior, but I
found that "set listsize 0" is currently used in the wild, and we do
have a bunch of other commands where "0" means unlimited, so I'm
thinking that changing this command alone in isolation is not a good
idea.
So I now strongly prefer reverting back the behavior in 7.6 to the
same behavior the command has had since 2006 (0==unlimited, -1=error).
(Before that, set listsize -1 would be accepted as unlimited as well.)
After 7.6 is out, in mainline, we can get back to reconsidering
changing this command's behavior, if there's a real need for being
able to suppress output. For now, let's play it safe.
All tested on x86_64 Fedora 17.
---
Pedro Alves (4):
list.exp: Catch "set listsize" failures (and "set listsize -1/0"'s history).
list.exp: Adjust "set listsize -1" to current test source's real line count.
list.exp: Avoid hardcoding line numbers.
Fix PR gdb/15294: list with unlimited listsize broken
gdb/source.c | 8 ++++---
gdb/testsuite/gdb.base/list.exp | 43 ++++++++++++++++++++++++---------------
gdb/testsuite/gdb.base/list0.c | 2 +-
3 files changed, 31 insertions(+), 22 deletions(-)
--
Pedro Alves
^ permalink raw reply [flat|nested] 8+ messages in thread
* [PATCH 3/4] list.exp: Avoid hardcoding line numbers.
2013-03-28 6:28 [PATCH 0/4 v2] [mainline+7.6] PR gdb/15294: list with unlimited listsize broken Pedro Alves
2013-03-28 1:11 ` [PATCH 1/4] list.exp: Catch "set listsize" failures (and "set listsize -1/0"'s history) Pedro Alves
2013-03-28 6:09 ` [PATCH 2/4] list.exp: Adjust "set listsize -1" to current test source's real line count Pedro Alves
@ 2013-03-28 7:44 ` Pedro Alves
2013-03-28 9:12 ` [PATCH 4/4] Fix PR gdb/15294: list with unlimited listsize broken Pedro Alves
2013-03-28 15:39 ` [PATCH 0/4 v2] [mainline+7.6] " Pedro Alves
4 siblings, 0 replies; 8+ messages in thread
From: Pedro Alves @ 2013-03-28 7:44 UTC (permalink / raw)
To: gdb-patches
The previous patch actually wasn't the first time I had to update line
numbers in this file.
This avoids hard coding line numbers, hopefully making the next time a
little easier.
Tested on x86_64 Fedora 17.
gdb/testsuite/
2013-03-21 Pedro Alves <palves@redhat.com>
* gdb.base/list.exp (last_line): New global.
(last_line_re): New global.
(test_listsize, test_list_function, test_list_forward)
(test_repeat_list_command, test_list_range)
(test_list_filename_and_function): Use them.
* gdb.base/list0.c: Comment the last line of the file with "last
line".
---
gdb/testsuite/gdb.base/list.exp | 31 +++++++++++++++++++++++--------
gdb/testsuite/gdb.base/list0.c | 2 +-
2 files changed, 24 insertions(+), 9 deletions(-)
diff --git a/gdb/testsuite/gdb.base/list.exp b/gdb/testsuite/gdb.base/list.exp
index 97cca91..915b255 100644
--- a/gdb/testsuite/gdb.base/list.exp
+++ b/gdb/testsuite/gdb.base/list.exp
@@ -46,6 +46,12 @@ if [get_compiler_info] {
return -1
}
+# The last line in the file.
+set last_line [gdb_get_line_number "last line" "list0.c"]
+
+# Regex matching the last line in the file.
+set last_line_re "${last_line}\[ \t\]+} /\\* last line \\*/"
+
#
# Local utility proc just to set and verify listsize
# Return 1 if success, 0 if fail.
@@ -79,6 +85,7 @@ proc test_listsize {} {
global gdb_prompt
global hp_cc_compiler
global hp_aCC_compiler
+ global last_line_re
# Show default size
@@ -124,9 +131,9 @@ proc test_listsize {} {
# Try a size larger than the entire file.
if [ set_listsize 100 ] then {
- gdb_test "list 1" "1\[ \t\]+#include \"list0.h\".*\r\n4\[23\]\[ \t\]+\}" "list line 1 with listsize 100"
+ gdb_test "list 1" "1\[ \t\]+#include \"list0.h\".*\r\n${last_line_re}" "list line 1 with listsize 100"
- gdb_test "list 10" "1\[ \t\]+#include \"list0.h\".*\r\n4\[23\]\[ \t\]+\}" "list line 10 with listsize 100"
+ gdb_test "list 10" "1\[ \t\]+#include \"list0.h\".*\r\n${last_line_re}" "list line 10 with listsize 100"
}
# Try listsize of 0 which suppresses printing.
@@ -138,7 +145,7 @@ proc test_listsize {} {
set_listsize -1
setup_xfail "*-*-*"
- gdb_test "list 1" "1\[ \t\]+#include .*\r\n43\[ \t\]+\}" "list line 1 with unlimited listsize"
+ gdb_test "list 1" "1\[ \t\]+#include .*\r\n${last_line_re}" "list line 1 with unlimited listsize"
}
#
@@ -224,6 +231,7 @@ proc test_list_function {} {
proc test_list_forward {} {
global gdb_prompt
+ global last_line_re
set testcnt 0
@@ -250,7 +258,7 @@ proc test_list_forward {} {
send_gdb "list\n"
gdb_expect {
- -re "35\[ \t\]+foo \\(.*\\);.*42\[ \t\]+.*\}\r\n$gdb_prompt $" { incr testcnt }
+ -re "35\[ \t\]+foo \\(.*\\);.*${last_line_re}\r\n$gdb_prompt $" { incr testcnt }
-re ".*$gdb_prompt $" { fail "list 35-42" ; gdb_suppress_tests }
timeout { fail "list 35-42 (timeout)" ; gdb_suppress_tests }
}
@@ -266,6 +274,7 @@ proc test_list_forward {} {
proc test_repeat_list_command {} {
global gdb_prompt
+ global last_line_re
set testcnt 0
@@ -292,7 +301,7 @@ proc test_repeat_list_command {} {
send_gdb "\n"
gdb_expect {
- -re "35\[ \t\]+foo \\(.*\\);.*42\[ \t\]+.*\}\r\n$gdb_prompt $" { incr testcnt }
+ -re "35\[ \t\]+foo \\(.*\\);.*${last_line_re}\r\n$gdb_prompt $" { incr testcnt }
-re ".*$gdb_prompt $" { fail "list 35-42" ; gdb_suppress_tests }
timeout { fail "list 35-42 (timeout)" ; gdb_suppress_tests }
}
@@ -344,6 +353,8 @@ proc test_list_backwards {} {
proc test_list_range {} {
global gdb_prompt
+ global last_line_re
+ global last_line
gdb_test "list list0.c:2,list0.c:5" "2\[ \t\]+\r\n3\[ \t\]+int main \[)(\]+.*5\[ \t\]+int x;" "list range; filename:line1,filename:line2"
@@ -353,9 +364,12 @@ proc test_list_range {} {
# gdb_test "list -100,-40" "Line number -60 out of range; .*list0.c has 39 lines." "list range; both bounds negative"
- gdb_test "list 30,45" "30\[ \t\]+foo \(.*\);.*43\[ \t\]+\}" "list range; upper bound past EOF"
+ set past_end [expr ${last_line} + 10]
+ set much_past_end [expr ${past_end} + 10]
+
+ gdb_test "list 30,${past_end}" "30\[ \t\]+foo \(.*\);.*${last_line_re}" "list range; upper bound past EOF"
- gdb_test "list 45,100" "Line number 45 out of range; .*list0.c has 43 lines." "list range; both bounds past EOF"
+ gdb_test "list ${past_end},${much_past_end}" "Line number ${past_end} out of range; .*list0.c has ${last_line} lines." "list range; both bounds past EOF"
gdb_test "list list0.c:2,list1.c:17" "Specified start and end are in different files." "list range, must be same files"
}
@@ -366,6 +380,7 @@ proc test_list_range {} {
proc test_list_filename_and_function {} {
global gdb_prompt
+ global last_line_re
set testcnt 0
@@ -389,7 +404,7 @@ proc test_list_filename_and_function {} {
setup_xfail "rs6000-*-aix*"
send_gdb "list list0.c:unused\n"
gdb_expect {
- -re "40\[ \t\]+unused.*43\[ \t\]+\}\r\n$gdb_prompt $" {
+ -re "40\[ \t\]+unused.*${last_line_re}\r\n$gdb_prompt $" {
incr testcnt
}
-re "37.*42\[ \t\]+\}\r\n$gdb_prompt $" {
diff --git a/gdb/testsuite/gdb.base/list0.c b/gdb/testsuite/gdb.base/list0.c
index 85fc6b5..0255cf3 100644
--- a/gdb/testsuite/gdb.base/list0.c
+++ b/gdb/testsuite/gdb.base/list0.c
@@ -40,4 +40,4 @@ static void
unused ()
{
/* Not used for anything */
-}
+} /* last line */
^ permalink raw reply [flat|nested] 8+ messages in thread
* [PATCH 4/4] Fix PR gdb/15294: list with unlimited listsize broken
2013-03-28 6:28 [PATCH 0/4 v2] [mainline+7.6] PR gdb/15294: list with unlimited listsize broken Pedro Alves
` (2 preceding siblings ...)
2013-03-28 7:44 ` [PATCH 3/4] list.exp: Avoid hardcoding line numbers Pedro Alves
@ 2013-03-28 9:12 ` Pedro Alves
2013-03-28 9:26 ` Pedro Alves
2013-03-28 15:39 ` [PATCH 0/4 v2] [mainline+7.6] " Pedro Alves
4 siblings, 1 reply; 8+ messages in thread
From: Pedro Alves @ 2013-03-28 9:12 UTC (permalink / raw)
To: gdb-patches
Currently, "set listsize -1" is supposed to mean "unlimited" source
lines, but, alas, it doesn't actually work:
(gdb) set listsize -1
(gdb) show listsize
Number of source lines gdb will list by default is unlimited.
(gdb) list 1
(gdb) list 1
(gdb) list 1
(gdb) set listsize 10
(gdb) list 1
1 /* Main function for CLI gdb.
2 Copyright (C) 2002-2013 Free Software Foundation, Inc.
3
4 This file is part of GDB.
5
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 3 of the License, or
9 (at your option) any later version.
10
Before this patch:
http://sourceware.org/ml/gdb-patches/2012-08/msg00367.html
was applied, the "set listsize" command was a var_integer command, and
"unlimited" was set with 0. Internally, var_integer maps 0 to INT_MAX
case var_integer:
{
...
if (val == 0 && c->var_type == var_integer)
val = INT_MAX;
The change in that patch to zuinteger_unlimited command, meant that -1
is left as -1 in the command's control variable (lines_to_list), and
the code in source.c isn't expecting that -- it only expects positive
numbers.
I previously suggested fixing the code and keeping the new behavior,
but I found that "set listsize 0" is currently used in the wild, and
we do have a bunch of other commands where "0" means unlimited, so I'm
thinking that changing this command alone in isolation is not a good
idea.
So I now strongly prefer reverting back the behavior in 7.6 to the same
behavior the command has had since 2006 (0==unlimited, -1=error).
Before that, set listsize -1 would be accepted as unlimited as well.
After 7.6 is out, in mainline, we can get back to reconsidering
changing this command's behavior, if there's a real need for being
able to suppress output. For now, let's play it safe.
The previous patches made it so that the list line 1 with unlimited
listsize actually passes now, so we can remove the xfail.
The list.exp test was originally written years and years ago expecting
0 mean "no output", but GDB never actually worked that way. This
adjusts the test to the old behavior, so that the test actually
passes, and the xfail is removed.
gdb/
2013-03-27 Pedro Alves <palves@redhat.com>
PR gdb/15294
* source.c (_initialize_source): Change back "set listsize" to an
integer command.
gdb/testsuite/
2013-03-27 Pedro Alves <palves@redhat.com>
* gdb.base/list.exp (set_listsize): Adjust to accept $arg == 0 to
mean unlimited instead of $arg < 0.
(test_listsize): Remove "listsize of 0 suppresses output" test.
Test that "set listsize 0" ends up with an unlimited listsize.
---
gdb/source.c | 8 ++++----
gdb/testsuite/gdb.base/list.exp | 10 ++--------
2 files changed, 6 insertions(+), 12 deletions(-)
diff --git a/gdb/source.c b/gdb/source.c
index 2d9410e..03c5253 100644
--- a/gdb/source.c
+++ b/gdb/source.c
@@ -2044,12 +2044,12 @@ The matching line number is also stored as the value of \"$_\"."));
add_com_alias ("?", "reverse-search", class_files, 0);
}
- add_setshow_zuinteger_unlimited_cmd ("listsize", class_support,
- &lines_to_list, _("\
+ add_setshow_integer_cmd ("listsize", class_support, &lines_to_list, _("\
Set number of source lines gdb will list by default."), _("\
Show number of source lines gdb will list by default."), NULL,
- NULL, show_lines_to_list,
- &setlist, &showlist);
+ NULL,
+ show_lines_to_list,
+ &setlist, &showlist);
add_cmd ("substitute-path", class_files, set_substitute_path_command,
_("\
diff --git a/gdb/testsuite/gdb.base/list.exp b/gdb/testsuite/gdb.base/list.exp
index 915b255..96ca198 100644
--- a/gdb/testsuite/gdb.base/list.exp
+++ b/gdb/testsuite/gdb.base/list.exp
@@ -67,7 +67,7 @@ proc set_listsize { arg } {
if [gdb_test_no_output "set listsize $arg" "setting listsize to $arg #$set_listsize_count"] {
return 0
}
- if { $arg < 0 } {
+ if { $arg == 0 } {
set arg "unlimited";
}
@@ -136,15 +136,9 @@ proc test_listsize {} {
gdb_test "list 10" "1\[ \t\]+#include \"list0.h\".*\r\n${last_line_re}" "list line 10 with listsize 100"
}
- # Try listsize of 0 which suppresses printing.
+ # Try listsize of 0 which is special, and means unlimited.
set_listsize 0
- gdb_test "list 1" "" "listsize of 0 suppresses output"
-
- # Try listsize of -1 which is special, and means unlimited.
-
- set_listsize -1
- setup_xfail "*-*-*"
gdb_test "list 1" "1\[ \t\]+#include .*\r\n${last_line_re}" "list line 1 with unlimited listsize"
}
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH 4/4] Fix PR gdb/15294: list with unlimited listsize broken
2013-03-28 9:12 ` [PATCH 4/4] Fix PR gdb/15294: list with unlimited listsize broken Pedro Alves
@ 2013-03-28 9:26 ` Pedro Alves
2013-03-28 16:47 ` Pedro Alves
0 siblings, 1 reply; 8+ messages in thread
From: Pedro Alves @ 2013-03-28 9:26 UTC (permalink / raw)
To: gdb-patches
Grrr, I forgot updating the manual.
--
Pedro Alves
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH 0/4 v2] [mainline+7.6] PR gdb/15294: list with unlimited listsize broken
2013-03-28 6:28 [PATCH 0/4 v2] [mainline+7.6] PR gdb/15294: list with unlimited listsize broken Pedro Alves
` (3 preceding siblings ...)
2013-03-28 9:12 ` [PATCH 4/4] Fix PR gdb/15294: list with unlimited listsize broken Pedro Alves
@ 2013-03-28 15:39 ` Pedro Alves
4 siblings, 0 replies; 8+ messages in thread
From: Pedro Alves @ 2013-03-28 15:39 UTC (permalink / raw)
To: gdb-patches
I've gone ahead and pushed this into mainline and 7.6.
--
Pedro Alves
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH 4/4] Fix PR gdb/15294: list with unlimited listsize broken
2013-03-28 9:26 ` Pedro Alves
@ 2013-03-28 16:47 ` Pedro Alves
0 siblings, 0 replies; 8+ messages in thread
From: Pedro Alves @ 2013-03-28 16:47 UTC (permalink / raw)
To: gdb-patches
On 03/27/2013 08:46 PM, Pedro Alves wrote:
> Grrr, I forgot updating the manual.
It was an obvious change anyway though.
Here's what I checked in (mainline+7.6).
----------
Subject: Fix PR gdb/15294: list with unlimited listsize broken
Currently, "set listsize -1" is supposed to mean "unlimited" source
lines, but, alas, it doesn't actually work:
(gdb) set listsize -1
(gdb) show listsize
Number of source lines gdb will list by default is unlimited.
(gdb) list 1
(gdb) list 1
(gdb) list 1
(gdb) set listsize 10
(gdb) list 1
1 /* Main function for CLI gdb.
2 Copyright (C) 2002-2013 Free Software Foundation, Inc.
3
4 This file is part of GDB.
5
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 3 of the License, or
9 (at your option) any later version.
10
Before this patch:
http://sourceware.org/ml/gdb-patches/2012-08/msg00367.html
was applied, the "set listsize" command was a var_integer command, and
"unlimited" was set with 0. Internally, var_integer maps 0 to INT_MAX
case var_integer:
{
...
if (val == 0 && c->var_type == var_integer)
val = INT_MAX;
The change in that patch to zuinteger_unlimited command, meant that -1
is left as -1 in the command's control variable (lines_to_list), and
the code in source.c isn't expecting that -- it only expects positive
numbers.
I previously suggested fixing the code and keeping the new behavior,
but I found that "set listsize 0" is currently used in the wild, and
we do have a bunch of other commands where "0" means unlimited, so I'm
thinking that changing this command alone in isolation is not a good
idea.
So I now strongly prefer reverting back the behavior in 7.6 to the
same behavior the command has had since 2006 (0==unlimited, -1=error).
Before that, set listsize -1 would be accepted as unlimited as well.
After 7.6 is out, in mainline, we can get back to reconsidering
changing this command's behavior, if there's a real need for being
able to suppress output. For now, let's play it safe.
The "list line 1 with unlimited listsize" test in list.exp was
originally written years and years ago expecting 0 to mean "no
output", but GDB never actually worked that way, even when the tests
were written, so the tests had been xfailed then. This patch now
adjusts the test to the new behavior, so that the test actually
passes, and the xfail is removed.
gdb/
2013-03-28 Pedro Alves <palves@redhat.com>
PR gdb/15294
* source.c (_initialize_source): Change back "set listsize" to an
integer command.
gdb/testsuite/
2013-03-28 Pedro Alves <palves@redhat.com>
PR gdb/15294
* gdb.base/list.exp (set_listsize): Adjust to accept $arg == 0 to
mean unlimited instead of $arg < 0.
(test_listsize): Remove "listsize of 0 suppresses output" test.
Test that "set listsize 0" ends up with an unlimited listsize.
gdb/doc/
2013-03-28 Pedro Alves <palves@redhat.com>
PR gdb/15294
* gdb.texinfo (List) <set listsize>: Adjust to document that
listsize 0 means no limit, and remove mention of -1.
---
gdb/ChangeLog | 7 +++++++
gdb/doc/ChangeLog | 7 +++++++
gdb/doc/gdb.texinfo | 3 +--
gdb/source.c | 8 ++++----
gdb/testsuite/ChangeLog | 9 +++++++++
gdb/testsuite/gdb.base/list.exp | 10 ++--------
6 files changed, 30 insertions(+), 14 deletions(-)
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 95a9e75..a5f8963 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,3 +1,10 @@
+2013-03-28 Pedro Alves <palves@redhat.com>
+
+ PR gdb/15294
+
+ * source.c (_initialize_source): Change back "set listsize" to an
+ integer command.
+
2013-03-27 Gareth McMullin <gareth@blacksphere.co.nz>
PR gdb/15275
diff --git a/gdb/doc/ChangeLog b/gdb/doc/ChangeLog
index 9a3f6b4..cab3ad9 100644
--- a/gdb/doc/ChangeLog
+++ b/gdb/doc/ChangeLog
@@ -1,3 +1,10 @@
+2013-03-28 Pedro Alves <palves@redhat.com>
+
+ PR gdb/15294
+
+ * gdb.texinfo (List) <set listsize>: Adjust to document that
+ listsize 0 means no limit, and remove mention of -1.
+
2013-03-22 Yao Qi <yao@codesourcery.com>
* gdb.texinfo (Embedded Processors): Remove menu item
diff --git a/gdb/doc/gdb.texinfo b/gdb/doc/gdb.texinfo
index 38ce259..fc2aae1 100644
--- a/gdb/doc/gdb.texinfo
+++ b/gdb/doc/gdb.texinfo
@@ -6916,8 +6916,7 @@ the @code{list} command. You can change this using @code{set listsize}:
@item set listsize @var{count}
Make the @code{list} command display @var{count} source lines (unless
the @code{list} argument explicitly specifies some other number).
-Setting @var{count} to -1 means there's no limit and 0 means suppress
-display of source lines.
+Setting @var{count} to 0 means there's no limit.
@kindex show listsize
@item show listsize
diff --git a/gdb/source.c b/gdb/source.c
index 2d9410e..03c5253 100644
--- a/gdb/source.c
+++ b/gdb/source.c
@@ -2044,12 +2044,12 @@ The matching line number is also stored as the value of \"$_\"."));
add_com_alias ("?", "reverse-search", class_files, 0);
}
- add_setshow_zuinteger_unlimited_cmd ("listsize", class_support,
- &lines_to_list, _("\
+ add_setshow_integer_cmd ("listsize", class_support, &lines_to_list, _("\
Set number of source lines gdb will list by default."), _("\
Show number of source lines gdb will list by default."), NULL,
- NULL, show_lines_to_list,
- &setlist, &showlist);
+ NULL,
+ show_lines_to_list,
+ &setlist, &showlist);
add_cmd ("substitute-path", class_files, set_substitute_path_command,
_("\
diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog
index ef1ebae..33c7bf4 100644
--- a/gdb/testsuite/ChangeLog
+++ b/gdb/testsuite/ChangeLog
@@ -1,5 +1,14 @@
2013-03-28 Pedro Alves <palves@redhat.com>
+ PR gdb/15294
+
+ * gdb.base/list.exp (set_listsize): Adjust to accept $arg == 0 to
+ mean unlimited instead of $arg < 0.
+ (test_listsize): Remove "listsize of 0 suppresses output" test.
+ Test that "set listsize 0" ends up with an unlimited listsize.
+
+2013-03-28 Pedro Alves <palves@redhat.com>
+
* gdb.base/list.exp (last_line): New global.
(last_line_re): New global.
(test_listsize, test_list_function, test_list_forward)
diff --git a/gdb/testsuite/gdb.base/list.exp b/gdb/testsuite/gdb.base/list.exp
index 915b255..96ca198 100644
--- a/gdb/testsuite/gdb.base/list.exp
+++ b/gdb/testsuite/gdb.base/list.exp
@@ -67,7 +67,7 @@ proc set_listsize { arg } {
if [gdb_test_no_output "set listsize $arg" "setting listsize to $arg #$set_listsize_count"] {
return 0
}
- if { $arg < 0 } {
+ if { $arg == 0 } {
set arg "unlimited";
}
@@ -136,15 +136,9 @@ proc test_listsize {} {
gdb_test "list 10" "1\[ \t\]+#include \"list0.h\".*\r\n${last_line_re}" "list line 10 with listsize 100"
}
- # Try listsize of 0 which suppresses printing.
+ # Try listsize of 0 which is special, and means unlimited.
set_listsize 0
- gdb_test "list 1" "" "listsize of 0 suppresses output"
-
- # Try listsize of -1 which is special, and means unlimited.
-
- set_listsize -1
- setup_xfail "*-*-*"
gdb_test "list 1" "1\[ \t\]+#include .*\r\n${last_line_re}" "list line 1 with unlimited listsize"
}
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2013-03-28 12:00 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-03-28 6:28 [PATCH 0/4 v2] [mainline+7.6] PR gdb/15294: list with unlimited listsize broken Pedro Alves
2013-03-28 1:11 ` [PATCH 1/4] list.exp: Catch "set listsize" failures (and "set listsize -1/0"'s history) Pedro Alves
2013-03-28 6:09 ` [PATCH 2/4] list.exp: Adjust "set listsize -1" to current test source's real line count Pedro Alves
2013-03-28 7:44 ` [PATCH 3/4] list.exp: Avoid hardcoding line numbers Pedro Alves
2013-03-28 9:12 ` [PATCH 4/4] Fix PR gdb/15294: list with unlimited listsize broken Pedro Alves
2013-03-28 9:26 ` Pedro Alves
2013-03-28 16:47 ` Pedro Alves
2013-03-28 15:39 ` [PATCH 0/4 v2] [mainline+7.6] " Pedro Alves
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox