aboutsummaryrefslogtreecommitdiff
path: root/gdb
diff options
context:
space:
mode:
authorJan Vrany <jan.vrany@labware.com>2020-10-09 06:47:30 +0100
committerJan Vrany <jan.vrany@labware.com>2020-10-09 06:49:33 +0100
commitf5c4b229c67d9ef2e79ba86432a409a8f506b3f6 (patch)
treefe70465e3822b6015053b3ef2c34660ed44585f9 /gdb
parentb270168504d91292ec7089056ce32c68ad6c28a7 (diff)
downloadgdb-f5c4b229c67d9ef2e79ba86432a409a8f506b3f6.zip
gdb-f5c4b229c67d9ef2e79ba86432a409a8f506b3f6.tar.gz
gdb-f5c4b229c67d9ef2e79ba86432a409a8f506b3f6.tar.bz2
Notify observers that directories have changed when using "directory" CLI command
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.
Diffstat (limited to 'gdb')
-rw-r--r--gdb/ChangeLog5
-rw-r--r--gdb/source.c11
-rw-r--r--gdb/testsuite/ChangeLog5
-rw-r--r--gdb/testsuite/gdb.mi/mi-cmd-param-changed.exp11
4 files changed, 30 insertions, 2 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index cba2c27..4927c89 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -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
diff --git a/gdb/source.c b/gdb/source.c
index 0c2b5a4..a73a31f 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 075fe2f..3d88199 100644
--- a/gdb/testsuite/ChangeLog
+++ b/gdb/testsuite/ChangeLog
@@ -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.
diff --git a/gdb/testsuite/gdb.mi/mi-cmd-param-changed.exp b/gdb/testsuite/gdb.mi/mi-cmd-param-changed.exp
index 031d396..2d653c0 100644
--- a/gdb/testsuite/gdb.mi/mi-cmd-param-changed.exp
+++ b/gdb/testsuite/gdb.mi/mi-cmd-param-changed.exp
@@ -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
}
}