public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
* [PATCH v2 0/1] Notify observers that directories have changed when using "directory" CLI command
@ 2020-10-06 11:08 Jan Vrany
  2020-10-06 11:08 ` [PATCH v2 1/1] " Jan Vrany
  0 siblings, 1 reply; 3+ messages in thread
From: Jan Vrany @ 2020-10-06 11:08 UTC (permalink / raw)
  To: gdb-patches; +Cc: Jan Vrany

## Changes from v1: 

Addressed Andrew's comments:

* handle the case of "directory" with no arguments,
* added test for this case to. 

This patch also changes existing behavior in that now it does
not show directories when user answers no to when asked
"Reinitialize source path to empty?" (as Andrew also suggested). 

Jan Vrany (1):
  Notify observers that directories have changed when using "directory"
    CLI command

 gdb/ChangeLog                                 |  5 +++++
 gdb/source.c                                  | 11 +++++++++--
 gdb/testsuite/ChangeLog                       |  5 +++++
 gdb/testsuite/gdb.mi/mi-cmd-param-changed.exp | 13 +++++++++++++
 4 files changed, 32 insertions(+), 2 deletions(-)

-- 
2.28.0


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

* [PATCH v2 1/1] Notify observers that directories have changed when using "directory" CLI command
  2020-10-06 11:08 [PATCH v2 0/1] Notify observers that directories have changed when using "directory" CLI command Jan Vrany
@ 2020-10-06 11:08 ` Jan Vrany
  2020-10-08 13:05   ` Andrew Burgess
  0 siblings, 1 reply; 3+ messages in thread
From: Jan Vrany @ 2020-10-06 11:08 UTC (permalink / raw)
  To: gdb-patches; +Cc: Jan Vrany

gdb/ChangeLog

	* source.c (directory_command): Notify observers that "directories"
	parameter has changed.

gdb/testsuite/ChangeLog

	* gdb.mi/mi-cmd-param-changed.exp: Check that notification is
	is emmited for both 'set directories' and 'directory' commands.
---
 gdb/ChangeLog                                 |  5 +++++
 gdb/source.c                                  | 11 +++++++++--
 gdb/testsuite/ChangeLog                       |  5 +++++
 gdb/testsuite/gdb.mi/mi-cmd-param-changed.exp | 13 +++++++++++++
 4 files changed, 32 insertions(+), 2 deletions(-)

diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 9c802c57ef..1d8ff2f83d 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,3 +1,8 @@
+2020-10-06  Jan Vrany  <jan.vrany@labware.com>
+
+	* source.c (directory_command): Notify observers that "directories"
+	parameter has changed.
+
 2020-09-29  Tom Tromey  <tom@tromey.com>
 
 	* dwarf2/read.c (lookup_dwo_id, get_type_unit_group)
diff --git a/gdb/source.c b/gdb/source.c
index 0c2b5a4f83..a73a31f644 100644
--- a/gdb/source.c
+++ b/gdb/source.c
@@ -446,6 +446,7 @@ init_source_path (void)
 static void
 directory_command (const char *dirname, int from_tty)
 {
+  bool value_changed = false;
   dont_repeat ();
   /* FIXME, this goes to "delete dir"...  */
   if (dirname == 0)
@@ -454,15 +455,21 @@ directory_command (const char *dirname, int from_tty)
 	{
 	  xfree (source_path);
 	  init_source_path ();
+	  value_changed = true;
 	}
     }
   else
     {
       mod_path (dirname, &source_path);
       forget_cached_source_info ();
+      value_changed = true;
+    }
+  if (value_changed)
+    {
+      gdb::observers::command_param_changed.notify ("directories", source_path);
+      if (from_tty)
+	show_directories_1 ((char *) 0, from_tty);
     }
-  if (from_tty)
-    show_directories_1 ((char *) 0, from_tty);
 }
 
 /* Add a path given with the -d command line switch.
diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog
index 2046c9b8e6..68e9c3204f 100644
--- a/gdb/testsuite/ChangeLog
+++ b/gdb/testsuite/ChangeLog
@@ -1,3 +1,8 @@
+2020-10-06  Jan Vrany  <jan.vrany@labware.com>
+
+	* gdb.mi/mi-cmd-param-changed.exp: Check that notification is
+	is emmited for both 'set directories' and 'directory' commands.
+
 2020-09-30  Gary Benson <gbenson@redhat.com>
 
 	* gdb.dwarf2/dw2-double-set-die-type.S (.Ldie_3e0):
diff --git a/gdb/testsuite/gdb.mi/mi-cmd-param-changed.exp b/gdb/testsuite/gdb.mi/mi-cmd-param-changed.exp
index 031d396dba..bd619d254d 100644
--- a/gdb/testsuite/gdb.mi/mi-cmd-param-changed.exp
+++ b/gdb/testsuite/gdb.mi/mi-cmd-param-changed.exp
@@ -102,6 +102,19 @@ proc test_command_param_changed { } {
 	    ".*=cmd-param-changed,param=\"check type\",value=\"on\".*\\^done" \
 	    "\"set ch type on\""
 
+	# Notification is emitted for both 'set directories' and 'directory'.
+	mi_gdb_test "set directories \$cdir:\$cwd:/tmp" \
+	    ".*=cmd-param-changed,param=\"directories\",value=\".*\".*\\^done" \
+	    "\"set directories \$cdir:\$cwd:/tmp\""
+	mi_gdb_test "directory /usr/src/gdb" \
+	    ".*=cmd-param-changed,param=\"directories\",value=\".*\".*\\^done" \
+	    "\"directory /usr/src/gdb\""
+	mi_gdb_test "directory" \
+	    ".*=cmd-param-changed,param=\"directories\",value=\".*\".*\\^done" \
+	    "\"directory\""
+
+
+
 	mi_gdb_exit
     }
 }
-- 
2.28.0


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

* Re: [PATCH v2 1/1] Notify observers that directories have changed when using "directory" CLI command
  2020-10-06 11:08 ` [PATCH v2 1/1] " Jan Vrany
@ 2020-10-08 13:05   ` Andrew Burgess
  0 siblings, 0 replies; 3+ messages in thread
From: Andrew Burgess @ 2020-10-08 13:05 UTC (permalink / raw)
  To: Jan Vrany; +Cc: gdb-patches

* Jan Vrany via Gdb-patches <gdb-patches@sourceware.org> [2020-10-06 12:08:09 +0100]:

> gdb/ChangeLog
> 
> 	* source.c (directory_command): Notify observers that "directories"
> 	parameter has changed.
> 
> gdb/testsuite/ChangeLog
> 
> 	* gdb.mi/mi-cmd-param-changed.exp: Check that notification is
> 	is emmited for both 'set directories' and 'directory'
> 	commands.

This looks great, thanks, with just one very minor nit..

> ---
>  gdb/ChangeLog                                 |  5 +++++
>  gdb/source.c                                  | 11 +++++++++--
>  gdb/testsuite/ChangeLog                       |  5 +++++
>  gdb/testsuite/gdb.mi/mi-cmd-param-changed.exp | 13 +++++++++++++
>  4 files changed, 32 insertions(+), 2 deletions(-)
> 
> diff --git a/gdb/ChangeLog b/gdb/ChangeLog
> index 9c802c57ef..1d8ff2f83d 100644
> --- a/gdb/ChangeLog
> +++ b/gdb/ChangeLog
> @@ -1,3 +1,8 @@
> +2020-10-06  Jan Vrany  <jan.vrany@labware.com>
> +
> +	* source.c (directory_command): Notify observers that "directories"
> +	parameter has changed.
> +
>  2020-09-29  Tom Tromey  <tom@tromey.com>
>  
>  	* dwarf2/read.c (lookup_dwo_id, get_type_unit_group)
> diff --git a/gdb/source.c b/gdb/source.c
> index 0c2b5a4f83..a73a31f644 100644
> --- a/gdb/source.c
> +++ b/gdb/source.c
> @@ -446,6 +446,7 @@ init_source_path (void)
>  static void
>  directory_command (const char *dirname, int from_tty)
>  {
> +  bool value_changed = false;
>    dont_repeat ();
>    /* FIXME, this goes to "delete dir"...  */
>    if (dirname == 0)
> @@ -454,15 +455,21 @@ directory_command (const char *dirname, int from_tty)
>  	{
>  	  xfree (source_path);
>  	  init_source_path ();
> +	  value_changed = true;
>  	}
>      }
>    else
>      {
>        mod_path (dirname, &source_path);
>        forget_cached_source_info ();
> +      value_changed = true;
> +    }
> +  if (value_changed)
> +    {
> +      gdb::observers::command_param_changed.notify ("directories", source_path);
> +      if (from_tty)
> +	show_directories_1 ((char *) 0, from_tty);
>      }
> -  if (from_tty)
> -    show_directories_1 ((char *) 0, from_tty);
>  }
>  
>  /* Add a path given with the -d command line switch.
> diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog
> index 2046c9b8e6..68e9c3204f 100644
> --- a/gdb/testsuite/ChangeLog
> +++ b/gdb/testsuite/ChangeLog
> @@ -1,3 +1,8 @@
> +2020-10-06  Jan Vrany  <jan.vrany@labware.com>
> +
> +	* gdb.mi/mi-cmd-param-changed.exp: Check that notification is
> +	is emmited for both 'set directories' and 'directory' commands.
> +
>  2020-09-30  Gary Benson <gbenson@redhat.com>
>  
>  	* gdb.dwarf2/dw2-double-set-die-type.S (.Ldie_3e0):
> diff --git a/gdb/testsuite/gdb.mi/mi-cmd-param-changed.exp b/gdb/testsuite/gdb.mi/mi-cmd-param-changed.exp
> index 031d396dba..bd619d254d 100644
> --- a/gdb/testsuite/gdb.mi/mi-cmd-param-changed.exp
> +++ b/gdb/testsuite/gdb.mi/mi-cmd-param-changed.exp
> @@ -102,6 +102,19 @@ proc test_command_param_changed { } {
>  	    ".*=cmd-param-changed,param=\"check type\",value=\"on\".*\\^done" \
>  	    "\"set ch type on\""
>  
> +	# Notification is emitted for both 'set directories' and 'directory'.
> +	mi_gdb_test "set directories \$cdir:\$cwd:/tmp" \
> +	    ".*=cmd-param-changed,param=\"directories\",value=\".*\".*\\^done" \
> +	    "\"set directories \$cdir:\$cwd:/tmp\""
> +	mi_gdb_test "directory /usr/src/gdb" \
> +	    ".*=cmd-param-changed,param=\"directories\",value=\".*\".*\\^done" \
> +	    "\"directory /usr/src/gdb\""
> +	mi_gdb_test "directory" \
> +	    ".*=cmd-param-changed,param=\"directories\",value=\".*\".*\\^done" \
> +	    "\"directory\""
> +
> +
> +

I think only one blank line is needed here.

With that fixed you can commit this.

Thanks,
Andrew



>  	mi_gdb_exit
>      }
>  }
> -- 
> 2.28.0
> 

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

end of thread, other threads:[~2020-10-08 13:05 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-10-06 11:08 [PATCH v2 0/1] Notify observers that directories have changed when using "directory" CLI command Jan Vrany
2020-10-06 11:08 ` [PATCH v2 1/1] " Jan Vrany
2020-10-08 13:05   ` 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).