/* Remote target communications for serial-line targets in custom GDB protocol
Copyright (C) 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997,
- 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008
+ 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009
Free Software Foundation, Inc.
This file is part of GDB.
static int readchar (int timeout);
-static ptid_t remote_wait (ptid_t ptid,
- struct target_waitstatus *status);
-
static void remote_kill (void);
static int tohex (int nib);
PACKET_qXfer_memory_map,
PACKET_qXfer_spu_read,
PACKET_qXfer_spu_write,
+ PACKET_qXfer_osdata,
PACKET_qGetTLSAddr,
PACKET_qSupported,
PACKET_QPassSignals,
PACKET_vRun,
PACKET_QStartNoAckMode,
PACKET_vKill,
+ PACKET_qXfer_siginfo_read,
+ PACKET_qXfer_siginfo_write,
PACKET_MAX
};
pp = unpack_varlen_hex (p, &tid);
/* Since the stub is not sending a process id, then default to
- what's in inferior_ptid. */
- pid = ptid_get_pid (inferior_ptid);
+ what's in inferior_ptid, unless it's null at this point. If so,
+ then since there's no way to know the pid of the reported
+ threads, use the magic number. */
+ if (ptid_equal (inferior_ptid, null_ptid))
+ pid = ptid_get_pid (magic_null_ptid);
+ else
+ pid = ptid_get_pid (inferior_ptid);
if (obuf)
*obuf = pp;
controlling. We default to adding them in the running state.
The '?' query below will then tell us about which threads are
stopped. */
-
- /* If we're not using the multi-process extensions, there's no
- way to know the pid of the reported threads; use the magic
- number. */
- if (!remote_multi_process_p (rs))
- inferior_ptid = magic_null_ptid;
-
remote_threads_info ();
}
else if (rs->non_stop_aware)
PACKET_qXfer_spu_read },
{ "qXfer:spu:write", PACKET_DISABLE, remote_supported_packet,
PACKET_qXfer_spu_write },
+ { "qXfer:osdata:read", PACKET_DISABLE, remote_supported_packet,
+ PACKET_qXfer_osdata },
{ "QPassSignals", PACKET_DISABLE, remote_supported_packet,
PACKET_QPassSignals },
{ "QStartNoAckMode", PACKET_DISABLE, remote_supported_packet,
PACKET_QStartNoAckMode },
{ "multiprocess", PACKET_DISABLE, remote_multi_process_feature, -1 },
{ "QNonStop", PACKET_DISABLE, remote_non_stop_feature, -1 },
+ { "qXfer:siginfo:read", PACKET_DISABLE, remote_supported_packet,
+ PACKET_qXfer_siginfo_read },
+ { "qXfer:siginfo:write", PACKET_DISABLE, remote_supported_packet,
+ PACKET_qXfer_siginfo_write },
};
static void
}
discard_pending_stop_replies (pid);
- detach_inferior (pid);
target_mourn_inferior ();
}
struct packet_reg *reg = packet_reg_from_pnum (rsa, pnum);
cached_reg_t cached_reg;
- cached_reg.num = reg->regnum;
-
p = p1;
if (*p != ':')
Packet: '%s'\n"),
phex_nz (pnum, 0), p, buf);
+ cached_reg.num = reg->regnum;
+
fieldsize = hex2bin (p, cached_reg.data,
register_size (target_gdbarch,
reg->regnum));
if (ptid_equal (ptid, null_ptid))
ptid = inferior_ptid;
- if (status->kind == TARGET_WAITKIND_EXITED
- || status->kind == TARGET_WAITKIND_SIGNALLED)
+ if (status->kind != TARGET_WAITKIND_EXITED
+ && status->kind != TARGET_WAITKIND_SIGNALLED)
{
- int pid = ptid_get_pid (ptid);
- delete_inferior (pid);
- }
- else
- notice_new_inferiors (ptid);
+ notice_new_inferiors (ptid);
- /* Expedited registers. */
- if (stop_reply->regcache)
- {
- cached_reg_t *reg;
- int ix;
+ /* Expedited registers. */
+ if (stop_reply->regcache)
+ {
+ cached_reg_t *reg;
+ int ix;
+
+ for (ix = 0;
+ VEC_iterate(cached_reg_t, stop_reply->regcache, ix, reg);
+ ix++)
+ regcache_raw_supply (get_thread_regcache (ptid),
+ reg->num, reg->data);
+ VEC_free (cached_reg_t, stop_reply->regcache);
+ }
- for (ix = 0;
- VEC_iterate(cached_reg_t, stop_reply->regcache, ix, reg);
- ix++)
- regcache_raw_supply (get_thread_regcache (ptid),
- reg->num, reg->data);
- VEC_free (cached_reg_t, stop_reply->regcache);
+ remote_stopped_by_watchpoint_p = stop_reply->stopped_by_watchpoint_p;
+ remote_watch_data_address = stop_reply->watch_data_address;
}
- remote_stopped_by_watchpoint_p = stop_reply->stopped_by_watchpoint_p;
- remote_watch_data_address = stop_reply->watch_data_address;
-
stop_reply_xfree (stop_reply);
return ptid;
}
STATUS just as `wait' would. */
static ptid_t
-remote_wait (ptid_t ptid, struct target_waitstatus *status)
+remote_wait (struct target_ops *ops,
+ ptid_t ptid, struct target_waitstatus *status)
{
ptid_t event_ptid;
if (res != 0)
error (_("Can't kill process"));
- delete_inferior (pid);
target_mourn_inferior ();
}
/* We're no longer interested in these events. */
discard_pending_stop_replies (ptid_get_pid (inferior_ptid));
+ /* If the current general thread belonged to the process we just
+ detached from or has exited, the remote side current general
+ thread becomes undefined. Considering a case like this:
+
+ - We just got here due to a detach.
+ - The process that we're detaching from happens to immediately
+ report a global breakpoint being hit in non-stop mode, in the
+ same thread we had selected before.
+ - GDB attaches to this process again.
+ - This event happens to be the next event we handle.
+
+ GDB would consider that the current general thread didn't need to
+ be set on the stub side (with Hg), since for all it knew,
+ GENERAL_THREAD hadn't changed.
+
+ Notice that although in all-stop mode, the remote server always
+ sets the current thread to the thread reporting the stop event,
+ that doesn't happen in non-stop mode; in non-stop, the stub *must
+ not* change the current thread when reporting a breakpoint hit,
+ due to the decoupling of event reporting and event handling.
+
+ To keep things simple, we always invalidate our notion of the
+ current thread. */
+ record_currthread (minus_one_ptid);
+
/* Unlike "target remote", we do not want to unpush the target; then
the next time the user says "run", we won't be connected. */
+ /* Call common code to mark the inferior as not running. */
+ generic_mourn_inferior ();
+
if (have_inferiors ())
{
extern void nullify_last_target_wait_ptid ();
}
else
{
- struct remote_state *rs = get_remote_state ();
-
- /* Call common code to mark the inferior as not running. */
- generic_mourn_inferior ();
if (!remote_multi_process_p (rs))
{
/* Check whether the target is running now - some remote stubs
[PACKET_qXfer_spu_write]);
}
+ /* Handle extra signal info using qxfer packets. */
+ if (object == TARGET_OBJECT_SIGNAL_INFO)
+ {
+ if (readbuf)
+ return remote_read_qxfer (ops, "siginfo", annex, readbuf, offset, len,
+ &remote_protocol_packets
+ [PACKET_qXfer_siginfo_read]);
+ else
+ return remote_write_qxfer (ops, "siginfo", annex, writebuf, offset, len,
+ &remote_protocol_packets
+ [PACKET_qXfer_siginfo_write]);
+ }
+
/* Only handle flash writes. */
if (writebuf != NULL)
{
return remote_read_qxfer (ops, "memory-map", annex, readbuf, offset, len,
&remote_protocol_packets[PACKET_qXfer_memory_map]);
+ case TARGET_OBJECT_OSDATA:
+ /* Should only get here if we're connected. */
+ gdb_assert (remote_desc);
+ return remote_read_qxfer
+ (ops, "osdata", annex, readbuf, offset, len,
+ &remote_protocol_packets[PACKET_qXfer_osdata]);
+
default:
return -1;
}
buffer. */
static char *
-remote_pid_to_str (ptid_t ptid)
+remote_pid_to_str (struct target_ops *ops, ptid_t ptid)
{
static char buf[64];
struct remote_state *rs = get_remote_state ();
stored at OFFSET within the thread local storage for thread PTID. */
static CORE_ADDR
-remote_get_thread_local_address (ptid_t ptid, CORE_ADDR lm, CORE_ADDR offset)
+remote_get_thread_local_address (struct target_ops *ops,
+ ptid_t ptid, CORE_ADDR lm, CORE_ADDR offset)
{
if (remote_protocol_packets[PACKET_qGetTLSAddr].support != PACKET_DISABLE)
{
add_packet_config_cmd (&remote_protocol_packets[PACKET_qXfer_spu_write],
"qXfer:spu:write", "write-spu-object", 0);
+ add_packet_config_cmd (&remote_protocol_packets[PACKET_qXfer_osdata],
+ "qXfer:osdata:read", "osdata", 0);
+
+ add_packet_config_cmd (&remote_protocol_packets[PACKET_qXfer_siginfo_read],
+ "qXfer:siginfo:read", "read-siginfo-object", 0);
+
+ add_packet_config_cmd (&remote_protocol_packets[PACKET_qXfer_siginfo_write],
+ "qXfer:siginfo:write", "write-siginfo-object", 0);
+
add_packet_config_cmd (&remote_protocol_packets[PACKET_qGetTLSAddr],
"qGetTLSAddr", "get-thread-local-storage-address",
0);