public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
* [PATCH 3/7] gdb: Small code restructure for list_command.
  2015-11-25  0:34 [PATCH 0/7] Minor changes to 'list' command Andrew Burgess
  2015-11-25  0:34 ` [PATCH 1/7] gdb: Make lines_to_list variable static Andrew Burgess
  2015-11-25  0:34 ` [PATCH 4/7] gdb: Make test names unique in list.exp Andrew Burgess
@ 2015-11-25  0:34 ` Andrew Burgess
  2015-11-26 12:37   ` Pedro Alves
  2015-11-25  0:34 ` [PATCH 5/7] gdb: 'list' command, tweak handling of +/- arguments Andrew Burgess
                   ` (4 subsequent siblings)
  7 siblings, 1 reply; 18+ messages in thread
From: Andrew Burgess @ 2015-11-25  0:34 UTC (permalink / raw)
  To: gdb-patches; +Cc: Andrew Burgess

Move handling of special +/- arguments to the list_command function
inside a single if block, this helps group all related functionality
together.  There should be no user visible changes after this commit.

gdb/ChangeLog:

	* cli/cli-cmds.c (list_command): Move all handling of +/-
	arguments into a single if block.
---
 gdb/ChangeLog      |  5 +++++
 gdb/cli/cli-cmds.c | 34 +++++++++++++++++-----------------
 2 files changed, 22 insertions(+), 17 deletions(-)

diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 9c22a9a..a19ed49 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,5 +1,10 @@
 2015-11-24  Andrew Burgess  <andrew.burgess@embecosm.com>
 
+	* cli/cli-cmds.c (list_command): Move all handling of +/-
+	arguments into a single if block.
+
+2015-11-24  Andrew Burgess  <andrew.burgess@embecosm.com>
+
 	* cli/cli-cmds.c (list_command): Use NULL instead of 0 when
 	checking pointers.
 
diff --git a/gdb/cli/cli-cmds.c b/gdb/cli/cli-cmds.c
index 841fc55..c47526f 100644
--- a/gdb/cli/cli-cmds.c
+++ b/gdb/cli/cli-cmds.c
@@ -932,26 +932,26 @@ list_command (char *arg, int from_tty)
 			      first + get_lines_to_list (), 0);
 	  return;
 	}
-    }
 
-  /* "l" or "l +" lists next ten lines.  */
+      /* "l" or "l +" lists next ten lines.  */
 
-  if (arg == NULL || strcmp (arg, "+") == 0)
-    {
-      print_source_lines (cursal.symtab, cursal.line,
-			  cursal.line + get_lines_to_list (), 0);
-      return;
-    }
+      if (arg == NULL || strcmp (arg, "+") == 0)
+	{
+	  print_source_lines (cursal.symtab, cursal.line,
+			      cursal.line + get_lines_to_list (), 0);
+	  return;
+	}
 
-  /* "l -" lists previous ten lines, the ones before the ten just
-     listed.  */
-  if (strcmp (arg, "-") == 0)
-    {
-      print_source_lines (cursal.symtab,
-			  max (get_first_line_listed () 
-			       - get_lines_to_list (), 1),
-			  get_first_line_listed (), 0);
-      return;
+      /* "l -" lists previous ten lines, the ones before the ten just
+	 listed.  */
+      if (strcmp (arg, "-") == 0)
+	{
+	  print_source_lines (cursal.symtab,
+			      max (get_first_line_listed ()
+				   - get_lines_to_list (), 1),
+			      get_first_line_listed (), 0);
+	  return;
+	}
     }
 
   /* Now if there is only one argument, decode it in SAL
-- 
2.5.1

^ permalink raw reply	[flat|nested] 18+ messages in thread

* [PATCH 4/7] gdb: Make test names unique in list.exp.
  2015-11-25  0:34 [PATCH 0/7] Minor changes to 'list' command Andrew Burgess
  2015-11-25  0:34 ` [PATCH 1/7] gdb: Make lines_to_list variable static Andrew Burgess
@ 2015-11-25  0:34 ` Andrew Burgess
  2015-11-26 12:37   ` Pedro Alves
  2015-11-25  0:34 ` [PATCH 3/7] gdb: Small code restructure for list_command Andrew Burgess
                   ` (5 subsequent siblings)
  7 siblings, 1 reply; 18+ messages in thread
From: Andrew Burgess @ 2015-11-25  0:34 UTC (permalink / raw)
  To: gdb-patches; +Cc: Andrew Burgess

gdb/testsuite/ChangeLog:

	* gdb.base/list.exp (test_list): Make test names unique.
---
 gdb/testsuite/ChangeLog         | 4 ++++
 gdb/testsuite/gdb.base/list.exp | 8 ++++++--
 2 files changed, 10 insertions(+), 2 deletions(-)

diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog
index a00920f..60bd923 100644
--- a/gdb/testsuite/ChangeLog
+++ b/gdb/testsuite/ChangeLog
@@ -1,3 +1,7 @@
+2015-11-24  Andrew Burgess  <andrew.burgess@embecosm.com>
+
+	* gdb.base/list.exp (test_list): Make test names unique.
+
 2015-11-23  Simon Marchi  <simon.marchi@ericsson.com>
 
 	* gdb.trace/actions.c: Include trace-common.h.
diff --git a/gdb/testsuite/gdb.base/list.exp b/gdb/testsuite/gdb.base/list.exp
index 2aea9a3..84ae251 100644
--- a/gdb/testsuite/gdb.base/list.exp
+++ b/gdb/testsuite/gdb.base/list.exp
@@ -578,9 +578,13 @@ proc test_list {command listsize1 listsize2 linerange1 linerange2} {
 	# Test changing the listsize both before nexting, and after
 	# stopping, but before listing.  Only the second listsize
 	# change should affect which lines are listed.
-	gdb_test_no_output "set listsize $listsize1"
+	with_test_prefix "before next" {
+	    gdb_test_no_output "set listsize $listsize1"
+	}
 	gdb_test "next" "foo \\(.*"
-	gdb_test_no_output "set listsize $listsize2"
+	with_test_prefix "after next" {
+	    gdb_test_no_output "set listsize $listsize2"
+	}
 
 	set pattern1 [build_pattern $linerange1]
 	set pattern2 [build_pattern $linerange2]
-- 
2.5.1

^ permalink raw reply	[flat|nested] 18+ messages in thread

* [PATCH 2/7] gdb: Use NULL instead of 0 for pointer comparison.
  2015-11-25  0:34 [PATCH 0/7] Minor changes to 'list' command Andrew Burgess
                   ` (5 preceding siblings ...)
  2015-11-25  0:34 ` [PATCH 6/7] gdb: Add an error when 'list -' reaches the start of a file Andrew Burgess
@ 2015-11-25  0:34 ` Andrew Burgess
  2015-11-26 12:37   ` Pedro Alves
  2015-12-11 23:28 ` [PATCH 0/7] Minor changes to 'list' command Andrew Burgess
  7 siblings, 1 reply; 18+ messages in thread
From: Andrew Burgess @ 2015-11-25  0:34 UTC (permalink / raw)
  To: gdb-patches; +Cc: Andrew Burgess

Small code cleanup, use NULL instead of 0 when checking pointers.  There
should be no user visible changes after this commit.

gdb/ChangeLog:

	* cli/cli-cmds.c (list_command): Use NULL instead of 0 when
	checking pointers.
---
 gdb/ChangeLog      | 5 +++++
 gdb/cli/cli-cmds.c | 4 ++--
 2 files changed, 7 insertions(+), 2 deletions(-)

diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index d1e6cbf..9c22a9a 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,5 +1,10 @@
 2015-11-24  Andrew Burgess  <andrew.burgess@embecosm.com>
 
+	* cli/cli-cmds.c (list_command): Use NULL instead of 0 when
+	checking pointers.
+
+2015-11-24  Andrew Burgess  <andrew.burgess@embecosm.com>
+
 	* source.c (lines_to_list): Make static.
 
 2015-11-23  Simon Marchi  <simon.marchi@ericsson.com>
diff --git a/gdb/cli/cli-cmds.c b/gdb/cli/cli-cmds.c
index 1886cae..841fc55 100644
--- a/gdb/cli/cli-cmds.c
+++ b/gdb/cli/cli-cmds.c
@@ -907,7 +907,7 @@ list_command (char *arg, int from_tty)
   cleanup = make_cleanup (null_cleanup, NULL);
 
   /* Pull in the current default source line if necessary.  */
-  if (arg == 0 || arg[0] == '+' || arg[0] == '-')
+  if (arg == NULL || arg[0] == '+' || arg[0] == '-')
     {
       set_default_source_symtab_and_line ();
       cursal = get_current_source_symtab_and_line ();
@@ -936,7 +936,7 @@ list_command (char *arg, int from_tty)
 
   /* "l" or "l +" lists next ten lines.  */
 
-  if (arg == 0 || strcmp (arg, "+") == 0)
+  if (arg == NULL || strcmp (arg, "+") == 0)
     {
       print_source_lines (cursal.symtab, cursal.line,
 			  cursal.line + get_lines_to_list (), 0);
-- 
2.5.1

^ permalink raw reply	[flat|nested] 18+ messages in thread

* [PATCH 6/7] gdb: Add an error when 'list -' reaches the start of a file.
  2015-11-25  0:34 [PATCH 0/7] Minor changes to 'list' command Andrew Burgess
                   ` (4 preceding siblings ...)
  2015-11-25  0:34 ` [PATCH 7/7] gdb: Extend help text for 'list' command Andrew Burgess
@ 2015-11-25  0:34 ` Andrew Burgess
  2015-11-26 12:38   ` Pedro Alves
  2015-11-25  0:34 ` [PATCH 2/7] gdb: Use NULL instead of 0 for pointer comparison Andrew Burgess
  2015-12-11 23:28 ` [PATCH 0/7] Minor changes to 'list' command Andrew Burgess
  7 siblings, 1 reply; 18+ messages in thread
From: Andrew Burgess @ 2015-11-25  0:34 UTC (permalink / raw)
  To: gdb-patches; +Cc: Andrew Burgess

When a a user uses 'list +' to list forward through a source file they
eventually reach the end of the source file.  Subsequent uses of 'list
+' result in an error message like this, that let the user know they are
at the end of the source file:

  Line number XXX out of range; FILENAME has YYY lines.

Compare this to the current behaviour of 'list -' which lists backwards
through a source file.  When the user reaches the beginning of the
source file, subsequent uses of 'list -' result in the command silently
returning.  This can be confusing if the previous uses of 'list -' have
scrolled off the users display, the user receives no reminder that the
have already seen the start of the file.

After this commit a use of 'list -' when the user has already seen the
start of a file will receive the following error:

   Already at the start of FILENAME.

gdb/ChangeLog:

	* cli/cli-cmds.c (list_command): Add an error when trying to use
	'-' to scan read off the start of the source file.

gdb/testsuite/ChangeLog:

	* gdb.base/list.exp (test_list_forward): Add end of file error
	test.
	(test_repeat_list_command): Add end of file error test.
	(test_list_backwards): Add beginning of file error test.
---
 gdb/ChangeLog                   |  5 +++++
 gdb/cli/cli-cmds.c              |  3 +++
 gdb/testsuite/ChangeLog         |  7 +++++++
 gdb/testsuite/gdb.base/list.exp | 12 ++++++++++++
 4 files changed, 27 insertions(+)

diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 4099267..278acb5 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,5 +1,10 @@
 2015-11-24  Andrew Burgess  <andrew.burgess@embecosm.com>
 
+	* cli/cli-cmds.c (list_command): Add an error when trying to use
+	'-' to scan read off the start of the source file.
+
+2015-11-24  Andrew Burgess  <andrew.burgess@embecosm.com>
+
 	* cli/cli-cmds.c (list_command): Check that the argument string is
 	a single character, either '+' or '-'.
 
diff --git a/gdb/cli/cli-cmds.c b/gdb/cli/cli-cmds.c
index be84f81..5e7ef0a 100644
--- a/gdb/cli/cli-cmds.c
+++ b/gdb/cli/cli-cmds.c
@@ -946,6 +946,9 @@ list_command (char *arg, int from_tty)
 	 listed.  */
       if (arg[0] == '-')
 	{
+	  if (get_first_line_listed () == 1)
+	    error ("Already at the start of %s.",
+		   symtab_to_filename_for_display (cursal.symtab));
 	  print_source_lines (cursal.symtab,
 			      max (get_first_line_listed ()
 				   - get_lines_to_list (), 1),
diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog
index 009044c..717e887 100644
--- a/gdb/testsuite/ChangeLog
+++ b/gdb/testsuite/ChangeLog
@@ -1,5 +1,12 @@
 2015-11-24  Andrew Burgess  <andrew.burgess@embecosm.com>
 
+	* gdb.base/list.exp (test_list_forward): Add end of file error
+	test.
+	(test_repeat_list_command): Add end of file error test.
+	(test_list_backwards): Add beginning of file error test.
+
+2015-11-24  Andrew Burgess  <andrew.burgess@embecosm.com>
+
 	* gdb.base/list.exp (test_list_invalid_args): New function,
 	defined, and called.
 
diff --git a/gdb/testsuite/gdb.base/list.exp b/gdb/testsuite/gdb.base/list.exp
index 1b9d4e6..87878f6 100644
--- a/gdb/testsuite/gdb.base/list.exp
+++ b/gdb/testsuite/gdb.base/list.exp
@@ -244,6 +244,10 @@ proc test_list_forward {} {
     }
 
     pass "successive list commands to page forward ($testcnt tests)"
+
+    gdb_test "list" "Line number 44 out of range; \[^\r\n\]+ has 43 lines\." \
+	"End of file error after \"list\" command."
+
     gdb_stop_suppressing_tests
 }
 
@@ -287,6 +291,10 @@ proc test_repeat_list_command {} {
     }
 
     pass "repeat list commands to page forward using 'return' ($testcnt tests)"
+
+    gdb_test "list" "Line number 44 out of range; \[^\r\n\]+ has 43 lines\." \
+	"End of file error after using 'return' to repeat the list command."
+
     gdb_stop_suppressing_tests
 }
 
@@ -324,6 +332,10 @@ proc test_list_backwards {} {
     }
 
     pass "$testcnt successive \"list -\" commands to page backwards"
+
+    gdb_test "list -" "Already at the start of .*\." \
+	"Beginning of file error after \"list -\" command."
+
     gdb_stop_suppressing_tests
 }
 
-- 
2.5.1

^ permalink raw reply	[flat|nested] 18+ messages in thread

* [PATCH 5/7] gdb: 'list' command, tweak handling of +/- arguments.
  2015-11-25  0:34 [PATCH 0/7] Minor changes to 'list' command Andrew Burgess
                   ` (2 preceding siblings ...)
  2015-11-25  0:34 ` [PATCH 3/7] gdb: Small code restructure for list_command Andrew Burgess
@ 2015-11-25  0:34 ` Andrew Burgess
  2015-11-26 12:38   ` Pedro Alves
  2015-11-25  0:34 ` [PATCH 7/7] gdb: Extend help text for 'list' command Andrew Burgess
                   ` (3 subsequent siblings)
  7 siblings, 1 reply; 18+ messages in thread
From: Andrew Burgess @ 2015-11-25  0:34 UTC (permalink / raw)
  To: gdb-patches; +Cc: Andrew Burgess

There is an inconsistency with the handling of the special +/- arguments
to the list command.

For the very first time that list is used (after the inferior has
changed locations) then only the first character of the argument string
is checked, so 'list +BLAH' will operate as 'list +' and 'list -----FOO'
will operate as 'list -'.  This compares to each subsequent use of list,
where the whole argument string is checked, so 'list +BLAH' will try to
list lines of code around the function '+BLAH'.

This commit unifies the behaviour so that the whole argument string is
checked, in order to list the next 10, or previous 10 lines from a file
only 'list +' and 'list -' are now valid.

gdb/ChangeLog:

	* cli/cli-cmds.c (list_command): Check that the argument string is
	a single character, either '+' or '-'.

gdb/testsuite/ChangeLog:

	* gdb.base/list.exp (test_list_invalid_args): New function,
	defined, and called.
---
 gdb/ChangeLog                   |  5 +++++
 gdb/cli/cli-cmds.c              |  6 +++---
 gdb/testsuite/ChangeLog         |  5 +++++
 gdb/testsuite/gdb.base/list.exp | 19 +++++++++++++++++++
 4 files changed, 32 insertions(+), 3 deletions(-)

diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index a19ed49..4099267 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,5 +1,10 @@
 2015-11-24  Andrew Burgess  <andrew.burgess@embecosm.com>
 
+	* cli/cli-cmds.c (list_command): Check that the argument string is
+	a single character, either '+' or '-'.
+
+2015-11-24  Andrew Burgess  <andrew.burgess@embecosm.com>
+
 	* cli/cli-cmds.c (list_command): Move all handling of +/-
 	arguments into a single if block.
 
diff --git a/gdb/cli/cli-cmds.c b/gdb/cli/cli-cmds.c
index c47526f..be84f81 100644
--- a/gdb/cli/cli-cmds.c
+++ b/gdb/cli/cli-cmds.c
@@ -907,7 +907,7 @@ list_command (char *arg, int from_tty)
   cleanup = make_cleanup (null_cleanup, NULL);
 
   /* Pull in the current default source line if necessary.  */
-  if (arg == NULL || arg[0] == '+' || arg[0] == '-')
+  if (arg == NULL || ((arg[0] == '+' || arg[0] == '-') && arg[1] == '\0'))
     {
       set_default_source_symtab_and_line ();
       cursal = get_current_source_symtab_and_line ();
@@ -935,7 +935,7 @@ list_command (char *arg, int from_tty)
 
       /* "l" or "l +" lists next ten lines.  */
 
-      if (arg == NULL || strcmp (arg, "+") == 0)
+      if (arg == NULL || arg[0] == '+')
 	{
 	  print_source_lines (cursal.symtab, cursal.line,
 			      cursal.line + get_lines_to_list (), 0);
@@ -944,7 +944,7 @@ list_command (char *arg, int from_tty)
 
       /* "l -" lists previous ten lines, the ones before the ten just
 	 listed.  */
-      if (strcmp (arg, "-") == 0)
+      if (arg[0] == '-')
 	{
 	  print_source_lines (cursal.symtab,
 			      max (get_first_line_listed ()
diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog
index 60bd923..009044c 100644
--- a/gdb/testsuite/ChangeLog
+++ b/gdb/testsuite/ChangeLog
@@ -1,5 +1,10 @@
 2015-11-24  Andrew Burgess  <andrew.burgess@embecosm.com>
 
+	* gdb.base/list.exp (test_list_invalid_args): New function,
+	defined, and called.
+
+2015-11-24  Andrew Burgess  <andrew.burgess@embecosm.com>
+
 	* gdb.base/list.exp (test_list): Make test names unique.
 
 2015-11-23  Simon Marchi  <simon.marchi@ericsson.com>
diff --git a/gdb/testsuite/gdb.base/list.exp b/gdb/testsuite/gdb.base/list.exp
index 84ae251..1b9d4e6 100644
--- a/gdb/testsuite/gdb.base/list.exp
+++ b/gdb/testsuite/gdb.base/list.exp
@@ -505,6 +505,24 @@ proc test_only_end {} {
     gdb_test "list ,5" "list ,5\r\n4\[ \t\]\[^\r\n\]*\r\n5\[ \t\]\[^\r\n\]*"
 }
 
+proc test_list_invalid_args {} {
+    global binfile
+
+    clean_restart ${binfile}
+    gdb_test "list -INVALID" \
+	"invalid explicit location argument, \"-INVALID\"" \
+	"First use of \"list -INVALID\""
+    gdb_test "list -INVALID" \
+	"invalid explicit location argument, \"-INVALID\"" \
+	"Second use of \"list -INVALID\""
+
+    clean_restart ${binfile}
+    gdb_test "list +INVALID" "Function \"\\+INVALID\" not defined." \
+	"First use of \"list +INVALID\""
+    gdb_test "list +INVALID" "Function \"\\+INVALID\" not defined." \
+	"Second use of \"list +INVALID\""
+}
+
 # Start with a fresh gdb.
 
 gdb_exit
@@ -527,6 +545,7 @@ if [ set_listsize 10 ] then {
     test_list_filename_and_function
     test_forward_search
     test_only_end
+    test_list_invalid_args
 }
 
 # Follows tests that require execution.
-- 
2.5.1

^ permalink raw reply	[flat|nested] 18+ messages in thread

* [PATCH 7/7] gdb: Extend help text for 'list' command.
  2015-11-25  0:34 [PATCH 0/7] Minor changes to 'list' command Andrew Burgess
                   ` (3 preceding siblings ...)
  2015-11-25  0:34 ` [PATCH 5/7] gdb: 'list' command, tweak handling of +/- arguments Andrew Burgess
@ 2015-11-25  0:34 ` Andrew Burgess
  2015-11-26 12:38   ` Pedro Alves
  2015-11-25  0:34 ` [PATCH 6/7] gdb: Add an error when 'list -' reaches the start of a file Andrew Burgess
                   ` (2 subsequent siblings)
  7 siblings, 1 reply; 18+ messages in thread
From: Andrew Burgess @ 2015-11-25  0:34 UTC (permalink / raw)
  To: gdb-patches; +Cc: Andrew Burgess

Reference the 'listsize' setting in the help text for the 'list' command
to help users find this setting.

gdb/ChangeLog:

	* cli/cli-cmds.c (_initialize_cli_cmds): Extend help text for
	'list' command.
---
 gdb/ChangeLog      | 5 +++++
 gdb/cli/cli-cmds.c | 6 +++++-
 2 files changed, 10 insertions(+), 1 deletion(-)

diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 278acb5..d9e91c2 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,5 +1,10 @@
 2015-11-24  Andrew Burgess  <andrew.burgess@embecosm.com>
 
+	* cli/cli-cmds.c (_initialize_cli_cmds): Extend help text for
+	'list' command.
+
+2015-11-24  Andrew Burgess  <andrew.burgess@embecosm.com>
+
 	* cli/cli-cmds.c (list_command): Add an error when trying to use
 	'-' to scan read off the start of the source file.
 
diff --git a/gdb/cli/cli-cmds.c b/gdb/cli/cli-cmds.c
index 5e7ef0a..0b3b091 100644
--- a/gdb/cli/cli-cmds.c
+++ b/gdb/cli/cli-cmds.c
@@ -1901,7 +1901,11 @@ Lines can be specified in these ways:\n\
   FILE:FUNCTION, to distinguish among like-named static functions.\n\
   *ADDRESS, to list around the line containing that address.\n\
 With two args if one is empty it stands for ten lines away from \
-the other arg."));
+the other arg.\n\
+\n\
+By default when a single location is given list displays ten lines,\n\
+this can be changed using \"set listsize\", and the current value\n\
+shown by using \"show listsize\"."));
 
   add_com_alias ("l", "list", class_files, 1);
 
-- 
2.5.1

^ permalink raw reply	[flat|nested] 18+ messages in thread

* [PATCH 1/7] gdb: Make lines_to_list variable static.
  2015-11-25  0:34 [PATCH 0/7] Minor changes to 'list' command Andrew Burgess
@ 2015-11-25  0:34 ` Andrew Burgess
  2015-11-26 12:37   ` Pedro Alves
  2015-11-25  0:34 ` [PATCH 4/7] gdb: Make test names unique in list.exp Andrew Burgess
                   ` (6 subsequent siblings)
  7 siblings, 1 reply; 18+ messages in thread
From: Andrew Burgess @ 2015-11-25  0:34 UTC (permalink / raw)
  To: gdb-patches; +Cc: Andrew Burgess

Small clean up, make variable static.

gdb/ChangeLog:

	* source.c (lines_to_list): Make static.
---
 gdb/ChangeLog | 4 ++++
 gdb/source.c  | 2 +-
 2 files changed, 5 insertions(+), 1 deletion(-)

diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index bc1a29e..d1e6cbf 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,3 +1,7 @@
+2015-11-24  Andrew Burgess  <andrew.burgess@embecosm.com>
+
+	* source.c (lines_to_list): Make static.
+
 2015-11-23  Simon Marchi  <simon.marchi@ericsson.com>
 
 	* breakpoint.c (tracepoint_print_recreate): Fix logic error
diff --git a/gdb/source.c b/gdb/source.c
index 8358033..e5412bd 100644
--- a/gdb/source.c
+++ b/gdb/source.c
@@ -95,7 +95,7 @@ static struct program_space *current_source_pspace;
    and friends should be rewritten to count characters and see where
    things are wrapping, but that would be a fair amount of work.  */
 
-int lines_to_list = 10;
+static int lines_to_list = 10;
 static void
 show_lines_to_list (struct ui_file *file, int from_tty,
 		    struct cmd_list_element *c, const char *value)
-- 
2.5.1

^ permalink raw reply	[flat|nested] 18+ messages in thread

* [PATCH 0/7] Minor changes to 'list' command.
@ 2015-11-25  0:34 Andrew Burgess
  2015-11-25  0:34 ` [PATCH 1/7] gdb: Make lines_to_list variable static Andrew Burgess
                   ` (7 more replies)
  0 siblings, 8 replies; 18+ messages in thread
From: Andrew Burgess @ 2015-11-25  0:34 UTC (permalink / raw)
  To: gdb-patches; +Cc: Andrew Burgess

The main motivation for this patch series was patch #6, this adds an
extra error when trying to use 'list -' to list off the beginning of a
file.

Patch #5 fixes a small inconsistency that I spotted while in the area,
and patches #1 to #4 are just clean up.

Patch #7 extends the command help for 'list'.

---

Andrew Burgess (7):
  gdb: Make lines_to_list variable static.
  gdb: Use NULL instead of 0 for pointer comparison.
  gdb: Small code restructure for list_command.
  gdb: Make test names unique in list.exp.
  gdb: 'list' command, tweak handling of +/- arguments.
  gdb: Add an error when 'list -' reaches the start of a file.
  gdb: Extend help text for 'list' command.

 gdb/ChangeLog                   | 29 ++++++++++++++++++++++++++
 gdb/cli/cli-cmds.c              | 45 ++++++++++++++++++++++++-----------------
 gdb/source.c                    |  2 +-
 gdb/testsuite/ChangeLog         | 16 +++++++++++++++
 gdb/testsuite/gdb.base/list.exp | 39 +++++++++++++++++++++++++++++++++--
 5 files changed, 109 insertions(+), 22 deletions(-)

-- 
2.5.1

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [PATCH 1/7] gdb: Make lines_to_list variable static.
  2015-11-25  0:34 ` [PATCH 1/7] gdb: Make lines_to_list variable static Andrew Burgess
@ 2015-11-26 12:37   ` Pedro Alves
  0 siblings, 0 replies; 18+ messages in thread
From: Pedro Alves @ 2015-11-26 12:37 UTC (permalink / raw)
  To: Andrew Burgess, gdb-patches

On 11/25/2015 12:34 AM, Andrew Burgess wrote:
> Small clean up, make variable static.
> 
> gdb/ChangeLog:
> 
> 	* source.c (lines_to_list): Make static.

OK.

Thanks,
Pedro Alves

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [PATCH 3/7] gdb: Small code restructure for list_command.
  2015-11-25  0:34 ` [PATCH 3/7] gdb: Small code restructure for list_command Andrew Burgess
@ 2015-11-26 12:37   ` Pedro Alves
  0 siblings, 0 replies; 18+ messages in thread
From: Pedro Alves @ 2015-11-26 12:37 UTC (permalink / raw)
  To: Andrew Burgess, gdb-patches

On 11/25/2015 12:34 AM, Andrew Burgess wrote:
> Move handling of special +/- arguments to the list_command function
> inside a single if block, this helps group all related functionality
> together.  There should be no user visible changes after this commit.
> 
> gdb/ChangeLog:
> 
> 	* cli/cli-cmds.c (list_command): Move all handling of +/-
> 	arguments into a single if block.

OK.

> +      if (arg == NULL || strcmp (arg, "+") == 0)
> +	{
> +	  print_source_lines (cursal.symtab, cursal.line,
> +			      cursal.line + get_lines_to_list (), 0);
> +	  return;
> +	}
>  

...

> +      if (strcmp (arg, "-") == 0)
> +	{
> +	  print_source_lines (cursal.symtab,
> +			      max (get_first_line_listed ()
> +				   - get_lines_to_list (), 1),
> +			      get_first_line_listed (), 0);
> +	  return;
> +	}
>      }

(Seems to me you could hoist the returns out now.)

Thanks,
Pedro Alves

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [PATCH 4/7] gdb: Make test names unique in list.exp.
  2015-11-25  0:34 ` [PATCH 4/7] gdb: Make test names unique in list.exp Andrew Burgess
@ 2015-11-26 12:37   ` Pedro Alves
  0 siblings, 0 replies; 18+ messages in thread
From: Pedro Alves @ 2015-11-26 12:37 UTC (permalink / raw)
  To: Andrew Burgess, gdb-patches

On 11/25/2015 12:34 AM, Andrew Burgess wrote:
> gdb/testsuite/ChangeLog:
> 
> 	* gdb.base/list.exp (test_list): Make test names unique.

OK.

Thanks,
Pedro Alves

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [PATCH 2/7] gdb: Use NULL instead of 0 for pointer comparison.
  2015-11-25  0:34 ` [PATCH 2/7] gdb: Use NULL instead of 0 for pointer comparison Andrew Burgess
@ 2015-11-26 12:37   ` Pedro Alves
  0 siblings, 0 replies; 18+ messages in thread
From: Pedro Alves @ 2015-11-26 12:37 UTC (permalink / raw)
  To: Andrew Burgess, gdb-patches

On 11/25/2015 12:34 AM, Andrew Burgess wrote:
> Small code cleanup, use NULL instead of 0 when checking pointers.  There
> should be no user visible changes after this commit.
> 
> gdb/ChangeLog:
> 
> 	* cli/cli-cmds.c (list_command): Use NULL instead of 0 when
> 	checking pointers.

OK.  Please feel free to push fixes like these as obvious.

Thanks,
Pedro Alves

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [PATCH 6/7] gdb: Add an error when 'list -' reaches the start of a file.
  2015-11-25  0:34 ` [PATCH 6/7] gdb: Add an error when 'list -' reaches the start of a file Andrew Burgess
@ 2015-11-26 12:38   ` Pedro Alves
  0 siblings, 0 replies; 18+ messages in thread
From: Pedro Alves @ 2015-11-26 12:38 UTC (permalink / raw)
  To: Andrew Burgess, gdb-patches

On 11/25/2015 12:34 AM, Andrew Burgess wrote:

>  
> diff --git a/gdb/cli/cli-cmds.c b/gdb/cli/cli-cmds.c
> index be84f81..5e7ef0a 100644
> --- a/gdb/cli/cli-cmds.c
> +++ b/gdb/cli/cli-cmds.c
> @@ -946,6 +946,9 @@ list_command (char *arg, int from_tty)
>  	 listed.  */
>        if (arg[0] == '-')
>  	{
> +	  if (get_first_line_listed () == 1)
> +	    error ("Already at the start of %s.",

Wrap text in _().

> +		   symtab_to_filename_for_display (cursal.symtab));
>  	  print_source_lines (cursal.symtab,
>  			      max (get_first_line_listed ()
>  				   - get_lines_to_list (), 1),


>  
> diff --git a/gdb/testsuite/gdb.base/list.exp b/gdb/testsuite/gdb.base/list.exp
> index 1b9d4e6..87878f6 100644
> --- a/gdb/testsuite/gdb.base/list.exp
> +++ b/gdb/testsuite/gdb.base/list.exp
> @@ -244,6 +244,10 @@ proc test_list_forward {} {
>      }
>  
>      pass "successive list commands to page forward ($testcnt tests)"
> +
> +    gdb_test "list" "Line number 44 out of range; \[^\r\n\]+ has 43 lines\." \
> +	"End of file error after \"list\" command."

Lowercase first word and no period at end.

> +    gdb_test "list" "Line number 44 out of range; \[^\r\n\]+ has 43 lines\." \
> +	"End of file error after using 'return' to repeat the list command."

Ditto.

> +
>      gdb_stop_suppressing_tests
>  }
>  
> @@ -324,6 +332,10 @@ proc test_list_backwards {} {
>      }
>  
>      pass "$testcnt successive \"list -\" commands to page backwards"
> +
> +    gdb_test "list -" "Already at the start of .*\." \
> +	"Beginning of file error after \"list -\" command."

Ditto.

OK with those fixed.

Thanks,
Pedro Alves

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [PATCH 5/7] gdb: 'list' command, tweak handling of +/- arguments.
  2015-11-25  0:34 ` [PATCH 5/7] gdb: 'list' command, tweak handling of +/- arguments Andrew Burgess
@ 2015-11-26 12:38   ` Pedro Alves
  0 siblings, 0 replies; 18+ messages in thread
From: Pedro Alves @ 2015-11-26 12:38 UTC (permalink / raw)
  To: Andrew Burgess, gdb-patches

On 11/25/2015 12:34 AM, Andrew Burgess wrote:

> gdb/ChangeLog:
> 
> 	* cli/cli-cmds.c (list_command): Check that the argument string is
> 	a single character, either '+' or '-'.
> 
> gdb/testsuite/ChangeLog:
> 
> 	* gdb.base/list.exp (test_list_invalid_args): New function,
> 	defined, and called.

> +    clean_restart ${binfile}
> +    gdb_test "list -INVALID" \
> +	"invalid explicit location argument, \"-INVALID\"" \
> +	"First use of \"list -INVALID\""
> +    gdb_test "list -INVALID" \
> +	"invalid explicit location argument, \"-INVALID\"" \
> +	"Second use of \"list -INVALID\""

Nit: please use lowercase in test messages like mostly
everywhere else (including this file).

OK with that fixed.

Thanks,
Pedro Alves

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [PATCH 7/7] gdb: Extend help text for 'list' command.
  2015-11-25  0:34 ` [PATCH 7/7] gdb: Extend help text for 'list' command Andrew Burgess
@ 2015-11-26 12:38   ` Pedro Alves
  2015-12-10 10:08     ` Andrew Burgess
  0 siblings, 1 reply; 18+ messages in thread
From: Pedro Alves @ 2015-11-26 12:38 UTC (permalink / raw)
  To: Andrew Burgess, gdb-patches

On 11/25/2015 12:34 AM, Andrew Burgess wrote:
> Reference the 'listsize' setting in the help text for the 'list' command
> to help users find this setting.
> 
> gdb/ChangeLog:
> 
> 	* cli/cli-cmds.c (_initialize_cli_cmds): Extend help text for
> 	'list' command.

LGTM, but probably Eli should take a look.

Thanks,
Pedro Alves

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [PATCH 7/7] gdb: Extend help text for 'list' command.
  2015-11-26 12:38   ` Pedro Alves
@ 2015-12-10 10:08     ` Andrew Burgess
  2015-12-10 16:24       ` Eli Zaretskii
  0 siblings, 1 reply; 18+ messages in thread
From: Andrew Burgess @ 2015-12-10 10:08 UTC (permalink / raw)
  To: gdb-patches, Eli Zaretskii; +Cc: Pedro Alves

* Pedro Alves <palves@redhat.com> [2015-11-26 12:38:41 +0000]:

> On 11/25/2015 12:34 AM, Andrew Burgess wrote:
> > Reference the 'listsize' setting in the help text for the 'list' command
> > to help users find this setting.
> > 
> > gdb/ChangeLog:
> > 
> > 	* cli/cli-cmds.c (_initialize_cli_cmds): Extend help text for
> > 	'list' command.
> 
> LGTM, but probably Eli should take a look.

Eli, any feedback?

Thanks,
Andrew

---

Reference the 'listsize' setting in the help text for the 'list' command
to help users find this setting.

gdb/ChangeLog:

        * cli/cli-cmds.c (_initialize_cli_cmds): Extend help text for
        'list' command.
---
 gdb/ChangeLog      | 5 +++++
 gdb/cli/cli-cmds.c | 6 +++++-
 2 files changed, 10 insertions(+), 1 deletion(-)

diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 278acb5..d9e91c2 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,5 +1,10 @@
 2015-11-24  Andrew Burgess  <andrew.burgess@embecosm.com>

+	* cli/cli-cmds.c (_initialize_cli_cmds): Extend help text for
+	'list' command.
+
+2015-11-24  Andrew Burgess  <andrew.burgess@embecosm.com>
+
        * cli/cli-cmds.c (list_command): Add an error when trying to use
        '-' to scan read off the start of the source file.

diff --git a/gdb/cli/cli-cmds.c b/gdb/cli/cli-cmds.c
index 5e7ef0a..0b3b091 100644
--- a/gdb/cli/cli-cmds.c
+++ b/gdb/cli/cli-cmds.c
@@ -1901,7 +1901,11 @@ Lines can be specified in these ways:\n\
   FILE:FUNCTION, to distinguish among like-named static functions.\n\
   *ADDRESS, to list around the line containing that address.\n\
 With two args if one is empty it stands for ten lines away from \
-the other arg."));
+the other arg.\n\
+\n\
+By default when a single location is given list displays ten lines,\n\
+this can be changed using \"set listsize\", and the current value\n\
+shown by using \"show listsize\"."));

   add_com_alias ("l", "list", class_files, 1);

-- 
2.5.1

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [PATCH 7/7] gdb: Extend help text for 'list' command.
  2015-12-10 10:08     ` Andrew Burgess
@ 2015-12-10 16:24       ` Eli Zaretskii
  0 siblings, 0 replies; 18+ messages in thread
From: Eli Zaretskii @ 2015-12-10 16:24 UTC (permalink / raw)
  To: Andrew Burgess; +Cc: gdb-patches, palves

> Date: Thu, 10 Dec 2015 10:07:55 +0000
> From: Andrew Burgess <andrew.burgess@embecosm.com>
> Cc: Pedro Alves <palves@redhat.com>
> 
> * Pedro Alves <palves@redhat.com> [2015-11-26 12:38:41 +0000]:
> 
> > LGTM, but probably Eli should take a look.
> 
> Eli, any feedback?

Some, see below.

> @@ -1901,7 +1901,11 @@ Lines can be specified in these ways:\n\
>    FILE:FUNCTION, to distinguish among like-named static functions.\n\
>    *ADDRESS, to list around the line containing that address.\n\
>  With two args if one is empty it stands for ten lines away from \
> -the other arg."));
> +the other arg.\n\
> +\n\
> +By default when a single location is given list displays ten lines,\n\
> +this can be changed using \"set listsize\", and the current value\n\
> +shown by using \"show listsize\"."));

Some commas are missing here, which makes this difficult to read.
Suggest to fix as follows:

  With two args, if one is empty, it stands for ten lines away from
  the other arg.

  By default, when a single location is given, display ten lines.
  This can be changed using "set listsize", and the current value
  can be shown using "show listsize".

Thanks.

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [PATCH 0/7] Minor changes to 'list' command.
  2015-11-25  0:34 [PATCH 0/7] Minor changes to 'list' command Andrew Burgess
                   ` (6 preceding siblings ...)
  2015-11-25  0:34 ` [PATCH 2/7] gdb: Use NULL instead of 0 for pointer comparison Andrew Burgess
@ 2015-12-11 23:28 ` Andrew Burgess
  7 siblings, 0 replies; 18+ messages in thread
From: Andrew Burgess @ 2015-12-11 23:28 UTC (permalink / raw)
  To: gdb-patches; +Cc: Eli Zaretskii, Pedro Alves

* Andrew Burgess <andrew.burgess@embecosm.com> [2015-11-25 00:34:25 +0000]:

> The main motivation for this patch series was patch #6, this adds an
> extra error when trying to use 'list -' to list off the beginning of a
> file.
> 
> Patch #5 fixes a small inconsistency that I spotted while in the area,
> and patches #1 to #4 are just clean up.
> 
> Patch #7 extends the command help for 'list'.
> 
> ---
> 
> Andrew Burgess (7):
>   gdb: Make lines_to_list variable static.
>   gdb: Use NULL instead of 0 for pointer comparison.
>   gdb: Small code restructure for list_command.
>   gdb: Make test names unique in list.exp.
>   gdb: 'list' command, tweak handling of +/- arguments.
>   gdb: Add an error when 'list -' reaches the start of a file.
>   gdb: Extend help text for 'list' command.
> 
>  gdb/ChangeLog                   | 29 ++++++++++++++++++++++++++
>  gdb/cli/cli-cmds.c              | 45 ++++++++++++++++++++++++-----------------
>  gdb/source.c                    |  2 +-
>  gdb/testsuite/ChangeLog         | 16 +++++++++++++++
>  gdb/testsuite/gdb.base/list.exp | 39 +++++++++++++++++++++++++++++++++--
>  5 files changed, 109 insertions(+), 22 deletions(-)
> 

All pushed, incorporating the fixes from Eli & Pedro.

Thanks,
Andrew

^ permalink raw reply	[flat|nested] 18+ messages in thread

end of thread, other threads:[~2015-12-11 23:28 UTC | newest]

Thread overview: 18+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-11-25  0:34 [PATCH 0/7] Minor changes to 'list' command Andrew Burgess
2015-11-25  0:34 ` [PATCH 1/7] gdb: Make lines_to_list variable static Andrew Burgess
2015-11-26 12:37   ` Pedro Alves
2015-11-25  0:34 ` [PATCH 4/7] gdb: Make test names unique in list.exp Andrew Burgess
2015-11-26 12:37   ` Pedro Alves
2015-11-25  0:34 ` [PATCH 3/7] gdb: Small code restructure for list_command Andrew Burgess
2015-11-26 12:37   ` Pedro Alves
2015-11-25  0:34 ` [PATCH 5/7] gdb: 'list' command, tweak handling of +/- arguments Andrew Burgess
2015-11-26 12:38   ` Pedro Alves
2015-11-25  0:34 ` [PATCH 7/7] gdb: Extend help text for 'list' command Andrew Burgess
2015-11-26 12:38   ` Pedro Alves
2015-12-10 10:08     ` Andrew Burgess
2015-12-10 16:24       ` Eli Zaretskii
2015-11-25  0:34 ` [PATCH 6/7] gdb: Add an error when 'list -' reaches the start of a file Andrew Burgess
2015-11-26 12:38   ` Pedro Alves
2015-11-25  0:34 ` [PATCH 2/7] gdb: Use NULL instead of 0 for pointer comparison Andrew Burgess
2015-11-26 12:37   ` Pedro Alves
2015-12-11 23:28 ` [PATCH 0/7] Minor changes to 'list' command Andrew Burgess

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).