This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2 of the License, or
+ the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 51 Franklin Street, Fifth Floor,
- Boston, MA 02110-1301, USA. */
+ along with this program. If not, see <http://www.gnu.org/licenses/>. */
/* See the GDB User Guide for details of the GDB remote protocol. */
/* Use the architecture to build a regnum<->pnum table, which will be
1:1 unless a feature set specifies otherwise. */
rsa->regs = GDBARCH_OBSTACK_CALLOC (gdbarch,
- gdbarch_num_regs (current_gdbarch),
+ gdbarch_num_regs (gdbarch),
struct packet_reg);
- for (regnum = 0; regnum < gdbarch_num_regs (current_gdbarch); regnum++)
+ for (regnum = 0; regnum < gdbarch_num_regs (gdbarch); regnum++)
{
struct packet_reg *r = &rsa->regs[regnum];
- if (register_size (current_gdbarch, regnum) == 0)
+ if (register_size (gdbarch, regnum) == 0)
/* Do not try to fetch zero-sized (placeholder) registers. */
r->pnum = -1;
else
with a remote protocol number, in order of ascending protocol
number. */
- remote_regs = alloca (gdbarch_num_regs (current_gdbarch)
- * sizeof (struct packet_reg *));
+ remote_regs = alloca (gdbarch_num_regs (gdbarch)
+ * sizeof (struct packet_reg *));
for (num_remote_regs = 0, regnum = 0;
- regnum < gdbarch_num_regs (current_gdbarch);
+ regnum < gdbarch_num_regs (gdbarch);
regnum++)
if (rsa->regs[regnum].pnum != -1)
remote_regs[num_remote_regs++] = &rsa->regs[regnum];
{
remote_regs[regnum]->in_g_packet = 1;
remote_regs[regnum]->offset = offset;
- offset += register_size (current_gdbarch, remote_regs[regnum]->regnum);
+ offset += register_size (gdbarch, remote_regs[regnum]->regnum);
}
/* Record the maximum possible size of the g packet - it may turn out
do_segments = (data != NULL);
do_sections = num_segments == 0;
- /* Text= and Data= specify offsets for the text and data sections,
- but symfile_map_offsets_to_segments expects base addresses
- instead of offsets. If we have two segments, we can still
- try to relocate the whole segments instead of just ".text"
- and ".data". */
- if (num_segments == 0)
+ if (num_segments > 0)
{
- do_sections = 1;
- if (data == NULL || data->num_segments != 2)
- do_segments = 0;
- else
- {
- segments[0] = data->segment_bases[0] + text_addr;
- segments[1] = data->segment_bases[1] + data_addr;
- }
- }
- else
- {
- do_sections = 0;
segments[0] = text_addr;
segments[1] = data_addr;
}
+ /* If we have two segments, we can still try to relocate everything
+ by assuming that the .text and .data offsets apply to the whole
+ text and data segments. Convert the offsets given in the packet
+ to base addresses for symfile_map_offsets_to_segments. */
+ else if (data && data->num_segments == 2)
+ {
+ segments[0] = data->segment_bases[0] + text_addr;
+ segments[1] = data->segment_bases[1] + data_addr;
+ num_segments = 2;
+ }
+ /* There's no way to relocate by segment. */
+ else
+ do_segments = 0;
if (do_segments)
{
do_sections = 0;
}
- free_symfile_segment_data (data);
+ if (data)
+ free_symfile_segment_data (data);
if (do_sections)
{
return 0;
case PACKET_ERROR:
error (_("Could not fetch register \"%s\""),
- gdbarch_register_name (current_gdbarch, reg->regnum));
+ gdbarch_register_name (get_regcache_arch (regcache), reg->regnum));
}
/* If this register is unfetchable, tell the regcache. */
static void
process_g_packet (struct regcache *regcache)
{
+ struct gdbarch *gdbarch = get_regcache_arch (regcache);
struct remote_state *rs = get_remote_state ();
struct remote_arch_state *rsa = get_remote_arch_state ();
int i, buf_len;
{
rsa->sizeof_g_packet = buf_len / 2;
- for (i = 0; i < gdbarch_num_regs (current_gdbarch); i++)
+ for (i = 0; i < gdbarch_num_regs (gdbarch); i++)
{
if (rsa->regs[i].pnum == -1)
continue;
{
int i;
- for (i = 0; i < gdbarch_num_regs (current_gdbarch); i++)
+ for (i = 0; i < gdbarch_num_regs (gdbarch); i++)
{
struct packet_reg *r = &rsa->regs[i];
if (r->in_g_packet)
fetch_registers_using_g (regcache);
- for (i = 0; i < gdbarch_num_regs (current_gdbarch); i++)
+ for (i = 0; i < gdbarch_num_regs (get_regcache_arch (regcache)); i++)
if (!rsa->regs[i].in_g_packet)
if (!fetch_register_using_p (regcache, &rsa->regs[i]))
{
case PACKET_DISABLE:
case PACKET_SUPPORT_UNKNOWN:
/* Make sure all the necessary registers are cached. */
- for (i = 0; i < gdbarch_num_regs (current_gdbarch); i++)
+ for (i = 0; i < gdbarch_num_regs (get_regcache_arch (regcache)); i++)
if (rsa->regs[i].in_g_packet)
regcache_raw_read (regcache, rsa->regs[i].regnum, buf);
break;
static int
store_register_using_P (const struct regcache *regcache, struct packet_reg *reg)
{
+ struct gdbarch *gdbarch = get_regcache_arch (regcache);
struct remote_state *rs = get_remote_state ();
struct remote_arch_state *rsa = get_remote_arch_state ();
/* Try storing a single register. */
xsnprintf (buf, get_remote_packet_size (), "P%s=", phex_nz (reg->pnum, 0));
p = buf + strlen (buf);
regcache_raw_collect (regcache, reg->regnum, regp);
- bin2hex (regp, p, register_size (current_gdbarch, reg->regnum));
+ bin2hex (regp, p, register_size (gdbarch, reg->regnum));
remote_send (&rs->buf, &rs->buf_size);
switch (packet_ok (rs->buf, &remote_protocol_packets[PACKET_P]))
return 1;
case PACKET_ERROR:
error (_("Could not write register \"%s\""),
- gdbarch_register_name (current_gdbarch, reg->regnum));
+ gdbarch_register_name (gdbarch, reg->regnum));
case PACKET_UNKNOWN:
return 0;
default:
int i;
regs = alloca (rsa->sizeof_g_packet);
memset (regs, 0, rsa->sizeof_g_packet);
- for (i = 0; i < gdbarch_num_regs (current_gdbarch); i++)
+ for (i = 0; i < gdbarch_num_regs (get_regcache_arch (regcache)); i++)
{
struct packet_reg *r = &rsa->regs[i];
if (r->in_g_packet)
store_registers_using_G (regcache);
- for (i = 0; i < gdbarch_num_regs (current_gdbarch); i++)
+ for (i = 0; i < gdbarch_num_regs (get_regcache_arch (regcache)); i++)
if (!rsa->regs[i].in_g_packet)
if (!store_register_using_P (regcache, &rsa->regs[i]))
/* See above for why we do not issue an error here. */
{
QUIT;
target_mourn_inferior ();
- error (_("Watchdog has expired. Target detached."));
+ error (_("Watchdog timeout has expired. Target detached."));
}
if (remote_debug)
fputs_filtered ("Timed out.\n", gdb_stdlog);
return remote_stopped_by_watchpoint_p;
}
-extern int stepped_after_stopped_by_watchpoint;
-
static int
remote_stopped_data_address (struct target_ops *target, CORE_ADDR *addr_p)
{
int rc = 0;
- if (remote_stopped_by_watchpoint ()
- || stepped_after_stopped_by_watchpoint)
+ if (remote_stopped_by_watchpoint ())
{
*addr_p = remote_watch_data_address;
rc = 1;