aboutsummaryrefslogtreecommitdiff
path: root/gdb/gdbserver
diff options
context:
space:
mode:
authorYao Qi <yao@codesourcery.com>2012-03-03 03:32:46 +0000
committerYao Qi <yao@codesourcery.com>2012-03-03 03:32:46 +0000
commitd1feda864e0b17c5757197ba1b421e25dac6afd1 (patch)
tree6756fdf97eb2d1aeabf2bbf05fa495960c04f061 /gdb/gdbserver
parent2fa291aca43cb851ba4e108cb64c7844a257df4f (diff)
downloadgdb-d1feda864e0b17c5757197ba1b421e25dac6afd1.zip
gdb-d1feda864e0b17c5757197ba1b421e25dac6afd1.tar.gz
gdb-d1feda864e0b17c5757197ba1b421e25dac6afd1.tar.bz2
gdb:
* target.h (struct target_ops) <to_use_agent>: New field. (struct target_ops) <to_can_use_agent>: New field. (target_use_agent, target_can_use_agent): New macro. * target.c (update_current_target): Update. * remote.c: New enum `PACKET_QAgent'. (remote_protocol_features): Add a new element. (remote_use_agent, remote_can_use_agent): New. (init_remote_ops): Initialize field `can_use_agent' with remote_can_use_agent. Intiailize field `use_agent' with remote_use_agent. * common/agent.c (use_agent): New global. * common/agent.h: Declare it. * tracepoint.c (info_static_tracepoint_markers_command): Add comment. * Makefile.in (SFILES): Add common/agent.c and agent.c. (COMMON_OBS): Add common/agent.o and agent.o (common-agent.o): New rule. * agent.c: New. gdb/doc: * gdb.texinfo (In-Process Agent): New node. Document new commands. (General Query Packets): Add packet `QAgent'. gdb/gdbserver: * linux-low.c (linux_supports_agent): New. (linux_target_ops): Initialize field `supports_agent' with linux_supports_agent. * target.h (struct target_ops) <supports_agent>: New. (target_supports_agent): New macro. * server.c (handle_general_set): Handle packet 'QAgent'. (handle_query): Send `QAgent+'. * Makefile.in (server.o): Depends on agent.h.
Diffstat (limited to 'gdb/gdbserver')
-rw-r--r--gdb/gdbserver/ChangeLog11
-rw-r--r--gdb/gdbserver/Makefile.in2
-rw-r--r--gdb/gdbserver/linux-low.c7
-rw-r--r--gdb/gdbserver/server.c28
-rw-r--r--gdb/gdbserver/target.h7
5 files changed, 54 insertions, 1 deletions
diff --git a/gdb/gdbserver/ChangeLog b/gdb/gdbserver/ChangeLog
index 6cb8789..b115b23 100644
--- a/gdb/gdbserver/ChangeLog
+++ b/gdb/gdbserver/ChangeLog
@@ -1,5 +1,16 @@
2012-03-03 Yao Qi <yao@codesourcery.com>
+ * linux-low.c (linux_supports_agent): New.
+ (linux_target_ops): Initialize field `supports_agent' with
+ linux_supports_agent.
+ * target.h (struct target_ops) <supports_agent>: New.
+ (target_supports_agent): New macro.
+ * server.c (handle_general_set): Handle packet 'QAgent'.
+ (handle_query): Send `QAgent+'.
+ * Makefile.in (server.o): Depends on agent.h.
+
+2012-03-03 Yao Qi <yao@codesourcery.com>
+
* Makefile.in (OBS): Add agent.o.
Add new rule for agent.o.
Track dependence of tracepoint.c on agent.h.
diff --git a/gdb/gdbserver/Makefile.in b/gdb/gdbserver/Makefile.in
index 439fd20..0dc5e40 100644
--- a/gdb/gdbserver/Makefile.in
+++ b/gdb/gdbserver/Makefile.in
@@ -400,7 +400,7 @@ mem-break.o: mem-break.c $(server_h) $(ax_h)
proc-service.o: proc-service.c $(server_h) $(gdb_proc_service_h)
regcache.o: regcache.c $(server_h) $(regdef_h)
remote-utils.o: remote-utils.c terminal.h $(server_h)
-server.o: server.c $(server_h)
+server.o: server.c $(server_h) $(agent_h)
target.o: target.c $(server_h)
thread-db.o: thread-db.c $(server_h) $(linux_low_h) $(gdb_proc_service_h) \
$(gdb_thread_db_h)
diff --git a/gdb/gdbserver/linux-low.c b/gdb/gdbserver/linux-low.c
index 7638ca3..b4f3d5a 100644
--- a/gdb/gdbserver/linux-low.c
+++ b/gdb/gdbserver/linux-low.c
@@ -4854,6 +4854,12 @@ linux_supports_disable_randomization (void)
#endif
}
+static int
+linux_supports_agent (void)
+{
+ return 1;
+}
+
/* Enumerate spufs IDs for process PID. */
static int
spu_enumerate_spu_ids (long pid, unsigned char *buf, CORE_ADDR offset, int len)
@@ -5576,6 +5582,7 @@ static struct target_ops linux_target_ops = {
linux_supports_disable_randomization,
linux_get_min_fast_tracepoint_insn_len,
linux_qxfer_libraries_svr4,
+ linux_supports_agent,
};
static void
diff --git a/gdb/gdbserver/server.c b/gdb/gdbserver/server.c
index e3d1f7c..0de3f52 100644
--- a/gdb/gdbserver/server.c
+++ b/gdb/gdbserver/server.c
@@ -18,6 +18,7 @@
along with this program. If not, see <http://www.gnu.org/licenses/>. */
#include "server.h"
+#include "agent.h"
#if HAVE_UNISTD_H
#include <unistd.h>
@@ -529,6 +530,30 @@ handle_general_set (char *own_buf)
&& handle_tracepoint_general_set (own_buf))
return;
+ if (strncmp ("QAgent:", own_buf, strlen ("QAgent:")) == 0)
+ {
+ char *mode = own_buf + strlen ("QAgent:");
+ int req = 0;
+
+ if (strcmp (mode, "0") == 0)
+ req = 0;
+ else if (strcmp (mode, "1") == 0)
+ req = 1;
+ else
+ {
+ /* We don't know what this value is, so complain to GDB. */
+ sprintf (own_buf, "E.Unknown QAgent value");
+ return;
+ }
+
+ /* Update the flag. */
+ use_agent = req;
+ if (remote_debug)
+ fprintf (stderr, "[%s agent]\n", req ? "Enable" : "Disable");
+ write_ok (own_buf);
+ return;
+ }
+
/* Otherwise we didn't know what packet it was. Say we didn't
understand it. */
own_buf[0] = 0;
@@ -1624,6 +1649,9 @@ handle_query (char *own_buf, int packet_len, int *new_packet_len_p)
/* Support target-side breakpoint conditions. */
strcat (own_buf, ";ConditionalBreakpoints+");
+ if (target_supports_agent ())
+ strcat (own_buf, ";QAgent+");
+
return;
}
diff --git a/gdb/gdbserver/target.h b/gdb/gdbserver/target.h
index 03dff0f..256cfd9 100644
--- a/gdb/gdbserver/target.h
+++ b/gdb/gdbserver/target.h
@@ -394,6 +394,9 @@ struct target_ops
int (*qxfer_libraries_svr4) (const char *annex, unsigned char *readbuf,
unsigned const char *writebuf,
CORE_ADDR offset, int len);
+
+ /* Return true if target supports debugging agent. */
+ int (*supports_agent) (void);
};
extern struct target_ops *the_target;
@@ -514,6 +517,10 @@ void set_target_ops (struct target_ops *);
(the_target->supports_disable_randomization ? \
(*the_target->supports_disable_randomization) () : 0)
+#define target_supports_agent() \
+ (the_target->supports_agent ? \
+ (*the_target->supports_agent) () : 0)
+
/* Start non-stop mode, returns 0 on success, -1 on failure. */
int start_non_stop (int nonstop);