aboutsummaryrefslogtreecommitdiff
path: root/gdb/tracectf.c
diff options
context:
space:
mode:
authorAndrew Burgess <aburgess@redhat.com>2024-06-19 11:14:08 +0100
committerAndrew Burgess <aburgess@redhat.com>2024-09-07 20:28:59 +0100
commit03ad29c86c232484f9090582bbe6f221bc87c323 (patch)
tree993cecb5d6fd9a08db7d7f45f29eacd741835116 /gdb/tracectf.c
parente454ae416a050496107f08cb0ae0de518d732a90 (diff)
downloadgdb-03ad29c86c232484f9090582bbe6f221bc87c323.zip
gdb-03ad29c86c232484f9090582bbe6f221bc87c323.tar.gz
gdb-03ad29c86c232484f9090582bbe6f221bc87c323.tar.bz2
gdb: 'target ...' commands now expect quoted/escaped filenames
This commit changes the 'target ...' commands that accept a filename to take a quoted or escaped filename rather than a literal filename. What this means in practice is that if you are specifying a filename that contains no white space or quote characters, then nothing should change, e.g.: target exec /path/to/some/file works both before and after this commit. However, if a user wishes to specify a file containing white space then either the entire filename needs to be quoted, or the special white space needs to be escaped. Before this patch a user could write: target exec /path/to a file/containing spaces But after this commit the user would have to choose one of: target exec "/path/to a file/containing spaces" or target exec /path/to\ a\ file/containing\ spaces Obviously this is a potentially breaking change. The benefit of making this change is consistency. Commands that take multiple arguments (one of which is a filename) or in the future, commands that take filename options, will always need to use quoted/escaped filenames, so converting all unquoted filename commands to use quoting or escaping makes the UI more consistent. Additionally (though this is probably not a common problem), GDB strips trailing white space from commands that the user enters. As such it is not possible to reference any file that ends in white space unless the quoting / escaping style is used. Though I suspect very few users run into this problem! The downside obviously is that this is a UI breaking change. Reviewed-By: Eli Zaretskii <eliz@gnu.org>
Diffstat (limited to 'gdb/tracectf.c')
-rw-r--r--gdb/tracectf.c11
1 files changed, 6 insertions, 5 deletions
diff --git a/gdb/tracectf.c b/gdb/tracectf.c
index 25a8fe7..b4997f8 100644
--- a/gdb/tracectf.c
+++ b/gdb/tracectf.c
@@ -1111,7 +1111,7 @@ ctf_read_tp (struct uploaded_tp **uploaded_tps)
second packet which contains events on trace blocks. */
static void
-ctf_target_open (const char *dirname, int from_tty)
+ctf_target_open (const char *args, int from_tty)
{
struct bt_ctf_event *event;
uint32_t event_id;
@@ -1119,10 +1119,11 @@ ctf_target_open (const char *dirname, int from_tty)
struct uploaded_tsv *uploaded_tsvs = NULL;
struct uploaded_tp *uploaded_tps = NULL;
- if (!dirname)
+ std::string dirname = extract_single_filename_arg (args);
+ if (dirname.empty ())
error (_("No CTF directory specified."));
- ctf_open_dir (dirname);
+ ctf_open_dir (dirname.c_str ());
target_preopen (from_tty);
@@ -1162,7 +1163,7 @@ ctf_target_open (const char *dirname, int from_tty)
start_pos = bt_iter_get_pos (bt_ctf_get_iter (ctf_iter));
gdb_assert (start_pos->type == BT_SEEK_RESTORE);
- trace_dirname = make_unique_xstrdup (dirname);
+ trace_dirname = make_unique_xstrdup (dirname.c_str ());
current_inferior ()->push_target (&ctf_ops);
inferior_appeared (current_inferior (), CTF_PID);
@@ -1722,6 +1723,6 @@ _initialize_ctf ()
{
#if HAVE_LIBBABELTRACE
add_target (ctf_target_info, ctf_target_open,
- deprecated_filename_completer);
+ filename_maybe_quoted_completer);
#endif
}