aboutsummaryrefslogtreecommitdiff
path: root/gdb
diff options
context:
space:
mode:
authorAndrew Cagney <cagney@redhat.com>2004-09-24 19:51:18 +0000
committerAndrew Cagney <cagney@redhat.com>2004-09-24 19:51:18 +0000
commitb96ec7ac6d8385eee134828a87da0eaadfd69fbd (patch)
tree3262816cc633fbf53336f8dce919160bc7b2081c /gdb
parent62ece330ee155f5b561d80fa4492deec82788b23 (diff)
downloadgdb-b96ec7ac6d8385eee134828a87da0eaadfd69fbd.zip
gdb-b96ec7ac6d8385eee134828a87da0eaadfd69fbd.tar.gz
gdb-b96ec7ac6d8385eee134828a87da0eaadfd69fbd.tar.bz2
2004-09-24 Robert Picco <Robert.Picco@hp.com>
Committed by Andrew Cagney. * remote.c (set_remote_protocol_p_packet_cmd, remote_protocol_p) (show_remote_protocol_p_packet_cmd): New. Implement 'p' packet. configuration. (fetch_register_using_p): Implement 'p' packet. Based on code by Fernando Nasser. (remote_fetch_registers): Call fetch_register_using_p. (init_all_packet_configs, show_remote_cmd) (_initialize_remote): Add p-packet.
Diffstat (limited to 'gdb')
-rw-r--r--gdb/ChangeLog12
-rw-r--r--gdb/remote.c81
2 files changed, 93 insertions, 0 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 74a0283..d27a0cd 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,3 +1,15 @@
+2004-09-24 Robert Picco <Robert.Picco@hp.com>
+
+ Committed by Andrew Cagney.
+ * remote.c (set_remote_protocol_p_packet_cmd, remote_protocol_p)
+ (show_remote_protocol_p_packet_cmd): New. Implement 'p' packet.
+ configuration.
+ (fetch_register_using_p): Implement 'p' packet. Based on code by
+ Fernando Nasser.
+ (remote_fetch_registers): Call fetch_register_using_p.
+ (init_all_packet_configs, show_remote_cmd)
+ (_initialize_remote): Add p-packet.
+
2004-09-24 Mark Kettenis <kettenis@gnu.org>
* inf-ptrace.c (inf_ptrace_kill_inferior): Call ptrace directly
diff --git a/gdb/remote.c b/gdb/remote.c
index 497f972..5ea5d12 100644
--- a/gdb/remote.c
+++ b/gdb/remote.c
@@ -961,6 +961,23 @@ show_remote_protocol_qPart_auxv_packet_cmd (char *args, int from_tty,
show_packet_config_cmd (&remote_protocol_qPart_auxv);
}
+static struct packet_config remote_protocol_p;
+
+static void
+set_remote_protocol_p_packet_cmd (char *args, int from_tty,
+ struct cmd_list_element *c)
+{
+ update_packet_config (&remote_protocol_p);
+}
+
+static void
+show_remote_protocol_p_packet_cmd (char *args, int from_tty,
+ struct cmd_list_element *c)
+{
+ show_packet_config_cmd (&remote_protocol_p);
+}
+
+
/* Tokens for use by the asynchronous signal handlers for SIGINT */
static void *sigint_remote_twice_token;
@@ -2041,6 +2058,7 @@ init_all_packet_configs (void)
{
int i;
update_packet_config (&remote_protocol_P);
+ update_packet_config (&remote_protocol_p);
update_packet_config (&remote_protocol_qSymbol);
update_packet_config (&remote_protocol_vcont);
for (i = 0; i < NR_Z_PACKET_TYPES; i++)
@@ -3150,6 +3168,36 @@ static int register_bytes_found;
/* Read the remote registers into the block REGS. */
/* Currently we just read all the registers, so we don't use regnum. */
+static int
+fetch_register_using_p (int regnum)
+{
+ struct remote_state *rs = get_remote_state ();
+ char *buf = alloca (rs->remote_packet_size), *p;
+ char regp[MAX_REGISTER_SIZE];
+ int i;
+
+ buf[0] = 'p';
+ bin2hex((char *) &regnum, &buf[1], sizeof(regnum));
+ buf[9] = 0;
+ remote_send (buf, rs->remote_packet_size);
+ if (buf[0] != 0 && buf[0] != 'E') {
+ p = buf;
+ i = 0;
+ while (p[0] != 0) {
+ if (p[1] == 0) {
+ error("fetch_register_using_p: early buf termination");
+ return 0;
+ }
+ regp[i++] = fromhex (p[0]) * 16 + fromhex (p[1]);
+ p += 2;
+ }
+ regcache_raw_supply (current_regcache, regnum, regp);
+ return 1;
+ }
+
+ return 0;
+}
+
static void
remote_fetch_registers (int regnum)
{
@@ -3170,6 +3218,31 @@ remote_fetch_registers (int regnum)
"Attempt to fetch a non G-packet register when this "
"remote.c does not support the p-packet.");
}
+ switch (remote_protocol_p.support)
+ {
+ case PACKET_DISABLE:
+ break;
+ case PACKET_ENABLE:
+ if (fetch_register_using_p (regnum))
+ return;
+ else
+ error ("Protocol error: p packet not recognized by stub");
+ case PACKET_SUPPORT_UNKNOWN:
+ if (fetch_register_using_p (regnum))
+ {
+ /* The stub recognized the 'p' packet. Remember this. */
+ remote_protocol_p.support = PACKET_ENABLE;
+ return;
+ }
+ else
+ {
+ /* The stub does not support the 'P' packet. Use 'G'
+ instead, and don't try using 'P' in the future (it
+ will just waste our time). */
+ remote_protocol_p.support = PACKET_DISABLE;
+ break;
+ }
+ }
sprintf (buf, "g");
remote_send (buf, (rs->remote_packet_size));
@@ -5332,6 +5405,7 @@ show_remote_cmd (char *args, int from_tty)
remote_show_cmdlist for a list of sub commands to show. */
show_remote_protocol_Z_packet_cmd (args, from_tty, NULL);
show_remote_protocol_P_packet_cmd (args, from_tty, NULL);
+ show_remote_protocol_p_packet_cmd (args, from_tty, NULL);
show_remote_protocol_qSymbol_packet_cmd (args, from_tty, NULL);
show_remote_protocol_vcont_packet_cmd (args, from_tty, NULL);
show_remote_protocol_binary_download_cmd (args, from_tty, NULL);
@@ -5528,6 +5602,13 @@ in a memory packet.\n",
&remote_set_cmdlist, &remote_show_cmdlist,
1);
+ add_packet_config_cmd (&remote_protocol_p,
+ "p", "fetch-register",
+ set_remote_protocol_p_packet_cmd,
+ show_remote_protocol_p_packet_cmd,
+ &remote_set_cmdlist, &remote_show_cmdlist,
+ 1);
+
add_packet_config_cmd (&remote_protocol_Z[Z_PACKET_SOFTWARE_BP],
"Z0", "software-breakpoint",
set_remote_protocol_Z_software_bp_packet_cmd,