aboutsummaryrefslogtreecommitdiff
path: root/gdb/remote.c
diff options
context:
space:
mode:
authorStan Shebs <shebs@codesourcery.com>2010-06-12 00:05:22 +0000
committerStan Shebs <shebs@codesourcery.com>2010-06-12 00:05:22 +0000
commitd914c394a99165d5406c625a3675761e728b33b7 (patch)
tree9076dfce3479288e1a9c2cd8c075015657ebe9c9 /gdb/remote.c
parent139f2ac873b8899228e9f99dc3b50d3416336bc7 (diff)
downloadfsf-binutils-gdb-d914c394a99165d5406c625a3675761e728b33b7.zip
fsf-binutils-gdb-d914c394a99165d5406c625a3675761e728b33b7.tar.gz
fsf-binutils-gdb-d914c394a99165d5406c625a3675761e728b33b7.tar.bz2
2010-06-11 Stan Shebs <stan@codesourcery.com>
Add per-operation permission flags. * target.h (struct target_ops): New method to_set_permissions. (target_set_permissions): New macro. (target_insert_breakpoint): Change macro to function. (target_remove_breakpoint): Ditto. (target_stop): Ditto. (may_write_registers): Declare. (may_write_memory): Declare. (may_insert_breakpoints): Declare. (may_insert_tracepoints): Declare. (may_insert_fast_tracepoints): Declare. (may_stop): Declare. * target.c (may_write_registers, may_write_registers_1): New globals. (may_write_memory, may_write_memory_1): New globals. (may_insert_breakpoints, may_insert_breakpoints_1): New globals. (may_insert_tracepoints, may_insert_tracepoints_1): New globals. (may_insert_fast_tracepoints, may_insert_fast_tracepoints_1): New globals. (may_stop, may_stop_1): New global. (target_xfer_partial): Test for write permission. (target_store_registers): Ditto. (target_insert_breakpoint): New function. (target_remove_breakpoint): New function. (target_stop): New function. (_initialize_targets): Add new set/show variables. (set_write_memory_permission): New function. (update_target_permissions): New function. (set_target_permissions): New function. (update_current_target): Default to_set_permissions. (_initialize_targets): Use new globals and setter function. * tracepoint.c (start_tracing): Test for permission. * inferior.h (update_observer_mode): Declare. * infrun.c (non_stop_1): Define earlier. (observer_mode, observer_mode_1): New globals. (set_observer_mode, show_observer_mode): New functions. (update_observer_mode): New function. (_initialize_infrun): Define "set observer" command. * remote.c (PACKET_QAllow): New optional packet. (remote_protocol_features): Add QAllow. (remote_set_permissions): New function. (remote_start_remote): Call it. (init_remote_ops): Add it to target vector. (_initialize_remote): Add config command for QAllow. * gdb.texinfo (Observer Mode): New section. (General Query Packets): Document QAllow. * gdb.base/permissions.exp: New file.
Diffstat (limited to 'gdb/remote.c')
-rw-r--r--gdb/remote.c43
1 files changed, 43 insertions, 0 deletions
diff --git a/gdb/remote.c b/gdb/remote.c
index 276e581..35d517d 100644
--- a/gdb/remote.c
+++ b/gdb/remote.c
@@ -212,6 +212,8 @@ static void show_remote_protocol_packet_cmd (struct ui_file *file,
static char *write_ptid (char *buf, const char *endbuf, ptid_t ptid);
static ptid_t read_ptid (char *buf, char **obuf);
+static void remote_set_permissions (void);
+
struct remote_state;
static int remote_get_trace_status (struct trace_status *ts);
@@ -1213,6 +1215,7 @@ enum {
PACKET_bc,
PACKET_bs,
PACKET_TracepointSource,
+ PACKET_QAllow,
PACKET_MAX
};
@@ -3047,6 +3050,10 @@ remote_start_remote (struct ui_out *uiout, void *opaque)
which later probes to skip. */
remote_query_supported ();
+ /* If the stub wants to get a QAllow, compose one and send it. */
+ if (remote_protocol_packets[PACKET_QAllow].support != PACKET_DISABLE)
+ remote_set_permissions ();
+
/* Next, we possibly activate noack mode.
If the QStartNoAckMode packet configuration is set to AUTO,
@@ -3393,6 +3400,36 @@ Some events may be lost, rendering further debugging impossible."));
return serial_open (name);
}
+/* Inform the target of our permission settings. The permission flags
+ work without this, but if the target knows the settings, it can do
+ a couple things. First, it can add its own check, to catch cases
+ that somehow manage to get by the permissions checks in target
+ methods. Second, if the target is wired to disallow particular
+ settings (for instance, a system in the field that is not set up to
+ be able to stop at a breakpoint), it can object to any unavailable
+ permissions. */
+
+void
+remote_set_permissions (void)
+{
+ struct remote_state *rs = get_remote_state ();
+
+ sprintf (rs->buf, "QAllow:"
+ "WriteReg:%x;WriteMem:%x;"
+ "InsertBreak:%x;InsertTrace:%x;"
+ "InsertFastTrace:%x;Stop:%x",
+ may_write_registers, may_write_memory,
+ may_insert_breakpoints, may_insert_tracepoints,
+ may_insert_fast_tracepoints, may_stop);
+ putpkt (rs->buf);
+ getpkt (&rs->buf, &rs->buf_size, 0);
+
+ /* If the target didn't like the packet, warn the user. Do not try
+ to undo the user's settings, that would just be maddening. */
+ if (strcmp (rs->buf, "OK") != 0)
+ warning ("Remote refused setting permissions with: %s", rs->buf);
+}
+
/* This type describes each known response to the qSupported
packet. */
struct protocol_feature
@@ -3564,6 +3601,8 @@ static struct protocol_feature remote_protocol_features[] = {
PACKET_bs },
{ "TracepointSource", PACKET_DISABLE, remote_supported_packet,
PACKET_TracepointSource },
+ { "QAllow", PACKET_DISABLE, remote_supported_packet,
+ PACKET_QAllow },
};
static char *remote_support_xml;
@@ -10061,6 +10100,7 @@ Specify the serial device it is connected to\n\
remote_ops.to_core_of_thread = remote_core_of_thread;
remote_ops.to_verify_memory = remote_verify_memory;
remote_ops.to_get_tib_address = remote_get_tib_address;
+ remote_ops.to_set_permissions = remote_set_permissions;
}
/* Set up the extended remote vector by making a copy of the standard
@@ -10536,6 +10576,9 @@ Show the maximum size of the address (in bits) in a memory packet."), NULL,
add_packet_config_cmd (&remote_protocol_packets[PACKET_TracepointSource],
"TracepointSource", "TracepointSource", 0);
+ add_packet_config_cmd (&remote_protocol_packets[PACKET_QAllow],
+ "QAllow", "allow", 0);
+
/* Keep the old ``set remote Z-packet ...'' working. Each individual
Z sub-packet has its own set and show commands, but users may
have sets to this variable in their .gdbinit files (or in their