Notify observers that directories have changed when using "directory" CLI command
authorJan Vrany <jan.vrany@labware.com>
Fri, 9 Oct 2020 05:47:30 +0000 (06:47 +0100)
committerJan Vrany <jan.vrany@labware.com>
Fri, 9 Oct 2020 05:49:33 +0000 (06:49 +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.

gdb/ChangeLog
gdb/source.c
gdb/testsuite/ChangeLog
gdb/testsuite/gdb.mi/mi-cmd-param-changed.exp

index cba2c27c0e176475aa0e8ff54d033df48bee3dfd..4927c895fa017245d76d62cb5eba1b0052674f21 100644 (file)
@@ -1,3 +1,8 @@
+2020-10-09  Jan Vrany  <jan.vrany@labware.com>
+
+       * source.c (directory_command): Notify observers that "directories"
+       parameter has changed.
+
 2020-10-08  Tom Tromey  <tom@tromey.com>
 
        * cli/cli-cmds.c (print_disassembly): Style function name and
index 0c2b5a4f83de7f57ec587c66cfaa3c5f701f6562..a73a31f644cc0d70082ca5a6dd75d96e31a72b3b 100644 (file)
@@ -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.
index 075fe2ff5a3a5f2cc696b59d369b33869ea7d551..3d88199c63c5e123856c21cb0f37f995527f7fbd 100644 (file)
@@ -1,3 +1,8 @@
+2020-10-09  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-10-08  Tom Tromey  <tom@tromey.com>
 
        * gdb.base/style.exp: Check that "main"'s name is styled.
index 031d396dbab9a6632cc546de42d39b0bf8afaa10..2d653c0e801af630b0e67e02ec5e26fbf88ecd40 100644 (file)
@@ -102,6 +102,17 @@ 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
     }
 }