aboutsummaryrefslogtreecommitdiff
path: root/gdb/remote.c
diff options
context:
space:
mode:
authorSimon Marchi <simon.marchi@polymtl.ca>2021-10-31 12:02:03 -0400
committerSimon Marchi <simon.marchi@polymtl.ca>2021-11-04 15:48:57 -0400
commitfcef6471ed3c07d6eac2d9e0010552994f0891aa (patch)
tree22738befcaa3ea4f3f4533b733fe5a2ae17ca5bf /gdb/remote.c
parent7ead06a8b65ef038abd65344ff6aea76054ea1d5 (diff)
downloadgdb-fcef6471ed3c07d6eac2d9e0010552994f0891aa.zip
gdb-fcef6471ed3c07d6eac2d9e0010552994f0891aa.tar.gz
gdb-fcef6471ed3c07d6eac2d9e0010552994f0891aa.tar.bz2
gdb: pass/return setting setter/getter scalar values by value
The getter and setter in struct setting always receive and return values by const reference. This is not necessary for scalar values (like bool and int), but more importantly it makes it a bit annoying to write a getter, you have to use a scratch static variable or something similar that you can refer to: const bool & my_getter () { static bool value; value = function_returning_bool (); return value; } Change the getter and setter function signatures to receive and return value by value instead of by reference, when the underlying data type is scalar. This means that string-based settings will still use references, but all others will be by value. The getter above would then be re-written as: bool my_getter () { return function_returning_bool (); } This is useful for a patch later in this series that defines a boolean setting with a getter and a setter. Change-Id: Ieca3a2419fcdb75a6f75948b2c920b548a0af0fd
Diffstat (limited to 'gdb/remote.c')
-rw-r--r--gdb/remote.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/gdb/remote.c b/gdb/remote.c
index 0fb4275..abf63de 100644
--- a/gdb/remote.c
+++ b/gdb/remote.c
@@ -1873,6 +1873,9 @@ struct packet_config
have an associated command always have this set to auto. */
enum auto_boolean detect;
+ /* The "show remote foo-packet" command created for this packet. */
+ cmd_list_element *show_cmd;
+
/* Does the target support this packet? */
enum packet_support support;
};
@@ -1936,6 +1939,7 @@ add_packet_config_cmd (struct packet_config *config, const char *name,
NULL,
show_remote_protocol_packet_cmd,
&remote_set_cmdlist, &remote_show_cmdlist);
+ config->show_cmd = cmds.show;
/* The command code copies the documentation strings. */
xfree (set_doc);
@@ -2245,7 +2249,7 @@ show_remote_protocol_packet_cmd (struct ui_file *file, int from_tty,
packet < &remote_protocol_packets[PACKET_MAX];
packet++)
{
- if (&packet->detect == &c->var->get<enum auto_boolean> ())
+ if (c == packet->show_cmd)
{
show_packet_config_cmd (packet);
return;