aboutsummaryrefslogtreecommitdiff
path: root/gdb/utils.h
diff options
context:
space:
mode:
authorAndrew Burgess <aburgess@redhat.com>2024-06-19 11:13:46 +0100
committerAndrew Burgess <aburgess@redhat.com>2024-09-07 20:28:58 +0100
commit1217ae6726a867aac7faf8e52271a21788064996 (patch)
tree01fb070ea97a429515e400421c6ea7db586541a6 /gdb/utils.h
parent67b8e30af907d8c19f50343268d7c6db85347ee2 (diff)
downloadgdb-1217ae6726a867aac7faf8e52271a21788064996.zip
gdb-1217ae6726a867aac7faf8e52271a21788064996.tar.gz
gdb-1217ae6726a867aac7faf8e52271a21788064996.tar.bz2
gdb: new extract_single_filename_arg helper function
This commit is in preparation for the next few commits, this commit adds a new function extract_single_filename_arg. This new function will be used to convert GDB commands that expect a single filename argument to have these commands take a possibly quoted or escaped string. There's no use of the new function in this commit, for that see the following commits.
Diffstat (limited to 'gdb/utils.h')
-rw-r--r--gdb/utils.h14
1 files changed, 14 insertions, 0 deletions
diff --git a/gdb/utils.h b/gdb/utils.h
index 90c8012..d69c81c 100644
--- a/gdb/utils.h
+++ b/gdb/utils.h
@@ -371,6 +371,20 @@ assign_return_if_changed (T &lval, const T &val)
return true;
}
+/* ARG is an argument string as passed to a GDB command which is expected
+ to contain a single, possibly quoted, filename argument. Extract the
+ filename and return it as a string. If the filename is quoted then the
+ quotes will have been removed. If the filename is not quoted then any
+ escaping within the filename will have been removed.
+
+ If there is any content in ARG after the filename then an error will be
+ thrown complaining about the extra content.
+
+ If there is no filename in ARG, or if ARG is nullptr, then an empty
+ string will be returned. */
+
+extern std::string extract_single_filename_arg (const char *arg);
+
/* A class that can be used to intercept warnings. A class is used
here, rather than a gdb::function_view because it proved difficult
to use a function view in conjunction with ATTRIBUTE_PRINTF in a