This is the mail archive of the
gdb-patches@sources.redhat.com
mailing list for the GDB project.
PATCH cleanup remote-rdi.c
- From: Richard Earnshaw <rearnsha at arm dot com>
- To: gdb-patches at sources dot redhat dot com
- Cc: Richard dot Earnshaw at arm dot com
- Date: Thu, 07 Mar 2002 15:35:39 +0000
- Subject: PATCH cleanup remote-rdi.c
- Organization: ARM Ltd.
- Reply-to: Richard dot Earnshaw at arm dot com
A small patch to fix a few infelicities in remote-rdi.c...
1) Eliminate ARI whinges (PTR -> void *; var_boolean ->
add_set_boolean_cmd).
2) Eliminate compiler warnings.
3) Eliminate the assumption that RDIError_NoError has the value 0.
2002-03-07 Richard Earnshaw <rearnsha@arm.com>
* remote-rdi.c (myprint): Replace 'PTR' with 'void *'.
(mywrite, mywritec, mypause, myreadc, mygets): Likewise.
(_initialize_remote_rdi): Use add_set_boolean_cmd to register
commands that set boolean values.
(arm_rdi_remove_breakpoint): Rewrite to avoid uninitialized warning.
(arm_rdi_resume): Always initialize PC.
(arm_rdi_open): Don't use rslt as a boolean.
(arm_rdi_create_inferior, arm_rdi_close, arm_rdi_resume)
(arm_rdi_fetch_registers, arm_rdi_store_registers)
(arm_rdi_xfer_memory, arm_rdi_files_info, arm_rdi_kill)
(arm_rdi_insert_breakpoint, arm_rdi_remove_breakpoint): Likewise.
Index: remote-rdi.c
===================================================================
RCS file: /cvs/src/src/gdb/remote-rdi.c,v
retrieving revision 1.21
diff -p -r1.21 remote-rdi.c
*** remote-rdi.c 2002/03/06 06:28:33 1.21
--- remote-rdi.c 2002/03/07 15:19:23
*************** voiddummy (void *dummy)
*** 153,172 ****
}
static void
! myprint (PTR arg, const char *format, va_list ap)
{
vfprintf_unfiltered (gdb_stdout, format, ap);
}
static void
! mywritec (PTR arg, int c)
{
if (isascii (c))
fputc_unfiltered (c, gdb_stdout);
}
static int
! mywrite (PTR arg, char const *buffer, int len)
{
int i;
char *e;
--- 153,172 ----
}
static void
! myprint (void *arg, const char *format, va_list ap)
{
vfprintf_unfiltered (gdb_stdout, format, ap);
}
static void
! mywritec (void *arg, int c)
{
if (isascii (c))
fputc_unfiltered (c, gdb_stdout);
}
static int
! mywrite (void *arg, char const *buffer, int len)
{
int i;
char *e;
*************** mywrite (PTR arg, char const *buffer, in
*** 185,191 ****
}
static void
! mypause (PTR arg)
{
}
--- 185,191 ----
}
static void
! mypause (void *arg)
{
}
*************** mypause (PTR arg)
*** 193,205 ****
being interrupted more carefully */
static int
! myreadc (PTR arg)
{
return fgetc (stdin);
}
static char *
! mygets (PTR arg, char *buffer, int len)
{
return fgets (buffer, len, stdin);
}
--- 193,205 ----
being interrupted more carefully */
static int
! myreadc (void *arg)
{
return fgetc (stdin);
}
static char *
! mygets (void *arg, char *buffer, int len)
{
return fgets (buffer, len, stdin);
}
*************** device is attached to the remote system
*** 265,271 ****
rslt = angel_RDI_open (10, &gdb_config, &gdb_hostif, NULL);
if (rslt == RDIError_BigEndian || rslt == RDIError_LittleEndian)
; /* do nothing, this is the expected return */
! else if (rslt)
{
printf_filtered ("RDI_open: %s\n", rdi_error_message (rslt));
Adp_CloseDevice ();
--- 265,271 ----
rslt = angel_RDI_open (10, &gdb_config, &gdb_hostif, NULL);
if (rslt == RDIError_BigEndian || rslt == RDIError_LittleEndian)
; /* do nothing, this is the expected return */
! else if (rslt != RDIError_NoError)
{
printf_filtered ("RDI_open: %s\n", rdi_error_message (rslt));
Adp_CloseDevice ();
*************** device is attached to the remote system
*** 273,305 ****
}
rslt = angel_RDI_info (RDIInfo_Target, &arg1, &arg2);
! if (rslt)
{
printf_filtered ("RDI_info: %s\n", rdi_error_message (rslt));
}
rslt = angel_RDI_info (RDIInfo_Points, &arg1, &arg2);
! if (rslt)
{
printf_filtered ("RDI_info: %s\n", rdi_error_message (rslt));
}
rslt = angel_RDI_info (RDIInfo_Step, &arg1, &arg2);
! if (rslt)
{
printf_filtered ("RDI_info: %s\n", rdi_error_message (rslt));
}
rslt = angel_RDI_info (RDIInfo_CoPro, &arg1, &arg2);
! if (rslt)
{
printf_filtered ("RDI_info: %s\n", rdi_error_message (rslt));
}
rslt = angel_RDI_info (RDIInfo_SemiHosting, &arg1, &arg2);
! if (rslt)
{
printf_filtered ("RDI_info: %s\n", rdi_error_message (rslt));
}
rslt = angel_RDI_info (RDIInfo_GetLoadSize, &arg1, &arg2);
! if (rslt)
{
printf_filtered ("RDI_info: %s\n", rdi_error_message (rslt));
}
--- 273,305 ----
}
rslt = angel_RDI_info (RDIInfo_Target, &arg1, &arg2);
! if (rslt != RDIError_NoError)
{
printf_filtered ("RDI_info: %s\n", rdi_error_message (rslt));
}
rslt = angel_RDI_info (RDIInfo_Points, &arg1, &arg2);
! if (rslt != RDIError_NoError)
{
printf_filtered ("RDI_info: %s\n", rdi_error_message (rslt));
}
rslt = angel_RDI_info (RDIInfo_Step, &arg1, &arg2);
! if (rslt != RDIError_NoError)
{
printf_filtered ("RDI_info: %s\n", rdi_error_message (rslt));
}
rslt = angel_RDI_info (RDIInfo_CoPro, &arg1, &arg2);
! if (rslt != RDIError_NoError)
{
printf_filtered ("RDI_info: %s\n", rdi_error_message (rslt));
}
rslt = angel_RDI_info (RDIInfo_SemiHosting, &arg1, &arg2);
! if (rslt != RDIError_NoError)
{
printf_filtered ("RDI_info: %s\n", rdi_error_message (rslt));
}
rslt = angel_RDI_info (RDIInfo_GetLoadSize, &arg1, &arg2);
! if (rslt != RDIError_NoError)
{
printf_filtered ("RDI_info: %s\n", rdi_error_message (rslt));
}
*************** device is attached to the remote system
*** 310,316 ****
target_fetch_registers (-1);
rslt = angel_RDI_open (1, &gdb_config, NULL, NULL);
! if (rslt)
{
printf_filtered ("RDI_open: %s\n", rdi_error_message (rslt));
}
--- 310,316 ----
target_fetch_registers (-1);
rslt = angel_RDI_open (1, &gdb_config, NULL, NULL);
! if (rslt != RDIError_NoError)
{
printf_filtered ("RDI_open: %s\n", rdi_error_message (rslt));
}
*************** device is attached to the remote system
*** 318,331 ****
arg1 = rom_at_zero ? 0x0 : 0x13b;
rslt = angel_RDI_info (RDIVector_Catch, &arg1, &arg2);
! if (rslt)
{
printf_filtered ("RDI_info: %s\n", rdi_error_message (rslt));
}
arg1 = (unsigned long) "";
rslt = angel_RDI_info (RDISet_Cmdline, &arg1, &arg2);
! if (rslt)
{
printf_filtered ("RDI_info: %s\n", rdi_error_message (rslt));
}
--- 318,331 ----
arg1 = rom_at_zero ? 0x0 : 0x13b;
rslt = angel_RDI_info (RDIVector_Catch, &arg1, &arg2);
! if (rslt != RDIError_NoError)
{
printf_filtered ("RDI_info: %s\n", rdi_error_message (rslt));
}
arg1 = (unsigned long) "";
rslt = angel_RDI_info (RDISet_Cmdline, &arg1, &arg2);
! if (rslt != RDIError_NoError)
{
printf_filtered ("RDI_info: %s\n", rdi_error_message (rslt));
}
*************** arm_rdi_create_inferior (char *exec_file
*** 397,403 ****
top_of_memory);
rslt = angel_RDI_info (RDIInfo_SetTopMem, &top_of_memory, &arg2);
! if (rslt)
{
printf_filtered ("RDI_info: %s\n", rdi_error_message (rslt));
}
--- 397,403 ----
top_of_memory);
rslt = angel_RDI_info (RDIInfo_SetTopMem, &top_of_memory, &arg2);
! if (rslt != RDIError_NoError)
{
printf_filtered ("RDI_info: %s\n", rdi_error_message (rslt));
}
*************** arm_rdi_create_inferior (char *exec_file
*** 408,414 ****
arg1 = (unsigned long) arg_buf;
rslt = angel_RDI_info (RDISet_Cmdline, /* &arg1 */ (unsigned long *) arg_buf, &arg2);
! if (rslt)
{
printf_filtered ("RDI_info: %s\n", rdi_error_message (rslt));
}
--- 408,414 ----
arg1 = (unsigned long) arg_buf;
rslt = angel_RDI_info (RDISet_Cmdline, /* &arg1 */ (unsigned long *) arg_buf, &arg2);
! if (rslt != RDIError_NoError)
{
printf_filtered ("RDI_info: %s\n", rdi_error_message (rslt));
}
*************** arm_rdi_close (int quitting)
*** 437,443 ****
if (!closed_already)
{
rslt = angel_RDI_close ();
! if (rslt)
{
printf_filtered ("RDI_close: %s\n", rdi_error_message (rslt));
}
--- 437,443 ----
if (!closed_already)
{
rslt = angel_RDI_close ();
! if (rslt != RDIError_NoError)
{
printf_filtered ("RDI_close: %s\n", rdi_error_message (rslt));
}
*************** arm_rdi_resume (ptid_t ptid, int step, e
*** 459,473 ****
if (0 /* turn on when hardware supports single-stepping */ )
{
rslt = angel_RDI_step (1, &point);
! if (rslt)
! {
! printf_filtered ("RDI_step: %s\n", rdi_error_message (rslt));
! }
}
else
{
char handle[4];
! CORE_ADDR pc;
if (step)
{
--- 459,471 ----
if (0 /* turn on when hardware supports single-stepping */ )
{
rslt = angel_RDI_step (1, &point);
! if (rslt != RDIError_NoError)
! printf_filtered ("RDI_step: %s\n", rdi_error_message (rslt));
}
else
{
char handle[4];
! CORE_ADDR pc = 0;
if (step)
{
*************** arm_rdi_resume (ptid_t ptid, int step, e
*** 475,491 ****
pc = arm_get_next_pc (pc);
arm_rdi_insert_breakpoint (pc, handle);
}
execute_status = rslt = angel_RDI_execute (&point);
! if (rslt == RDIError_BreakpointReached)
! ;
! else if (rslt)
! {
! printf_filtered ("RDI_execute: %s\n", rdi_error_message (rslt));
! }
if (step)
! {
! arm_rdi_remove_breakpoint (pc, handle);
! }
}
}
--- 473,485 ----
pc = arm_get_next_pc (pc);
arm_rdi_insert_breakpoint (pc, handle);
}
+
execute_status = rslt = angel_RDI_execute (&point);
! if (rslt != RDIError_NoError && rslt != RDIError_BreakpointReached)
! printf_filtered ("RDI_execute: %s\n", rdi_error_message (rslt));
!
if (step)
! arm_rdi_remove_breakpoint (pc, handle);
}
}
*************** arm_rdi_fetch_registers (int regno)
*** 541,547 ****
if (regno == -1)
{
rslt = angel_RDI_CPUread (255, 0x27fff, rawregs);
! if (rslt)
{
printf_filtered ("RDI_CPUread: %s\n", rdi_error_message (rslt));
}
--- 535,541 ----
if (regno == -1)
{
rslt = angel_RDI_CPUread (255, 0x27fff, rawregs);
! if (rslt != RDIError_NoError)
{
printf_filtered ("RDI_CPUread: %s\n", rdi_error_message (rslt));
}
*************** arm_rdi_fetch_registers (int regno)
*** 571,577 ****
rdi_regmask = 1 << regno;
rslt = angel_RDI_CPUread (255, rdi_regmask, &rawreg);
! if (rslt)
{
printf_filtered ("RDI_CPUread: %s\n", rdi_error_message (rslt));
}
--- 565,571 ----
rdi_regmask = 1 << regno;
rslt = angel_RDI_CPUread (255, rdi_regmask, &rawreg);
! if (rslt != RDIError_NoError)
{
printf_filtered ("RDI_CPUread: %s\n", rdi_error_message (rslt));
}
*************** arm_rdi_store_registers (int regno)
*** 618,624 ****
rdi_regmask = 1 << regno;
rslt = angel_RDI_CPUwrite (255, rdi_regmask, rawerreg);
! if (rslt)
{
printf_filtered ("RDI_CPUwrite: %s\n", rdi_error_message (rslt));
}
--- 612,618 ----
rdi_regmask = 1 << regno;
rslt = angel_RDI_CPUwrite (255, rdi_regmask, rawerreg);
! if (rslt != RDIError_NoError)
{
printf_filtered ("RDI_CPUwrite: %s\n", rdi_error_message (rslt));
}
*************** arm_rdi_xfer_memory (CORE_ADDR memaddr,
*** 641,647 ****
if (should_write)
{
rslt = angel_RDI_write (myaddr, memaddr, &len);
! if (rslt)
{
printf_filtered ("RDI_write: %s\n", rdi_error_message (rslt));
}
--- 635,641 ----
if (should_write)
{
rslt = angel_RDI_write (myaddr, memaddr, &len);
! if (rslt != RDIError_NoError)
{
printf_filtered ("RDI_write: %s\n", rdi_error_message (rslt));
}
*************** arm_rdi_xfer_memory (CORE_ADDR memaddr,
*** 649,655 ****
else
{
rslt = angel_RDI_read (memaddr, myaddr, &len);
! if (rslt)
{
printf_filtered ("RDI_read: %s\n", rdi_error_message (rslt));
len = 0;
--- 643,649 ----
else
{
rslt = angel_RDI_read (memaddr, myaddr, &len);
! if (rslt != RDIError_NoError)
{
printf_filtered ("RDI_read: %s\n", rdi_error_message (rslt));
len = 0;
*************** arm_rdi_files_info (struct target_ops *i
*** 668,674 ****
unsigned long arg1, arg2;
rslt = angel_RDI_info (RDIInfo_Target, &arg1, &arg2);
! if (rslt)
{
printf_filtered ("RDI_info: %s\n", rdi_error_message (rslt));
}
--- 662,668 ----
unsigned long arg1, arg2;
rslt = angel_RDI_info (RDIInfo_Target, &arg1, &arg2);
! if (rslt != RDIError_NoError)
{
printf_filtered ("RDI_info: %s\n", rdi_error_message (rslt));
}
*************** arm_rdi_files_info (struct target_ops *i
*** 680,693 ****
printf_filtered ("Target is real hardware.\n");
rslt = angel_RDI_info (RDIInfo_Step, &arg1, &arg2);
! if (rslt)
{
printf_filtered ("RDI_info: %s\n", rdi_error_message (rslt));
}
printf_filtered ("Target can%s single-step.\n", (arg1 & 0x4 ? "" : "not"));
rslt = angel_RDI_info (RDIInfo_Icebreaker, &arg1, &arg2);
! if (rslt)
{
printf_filtered ("RDI_info: %s\n", rdi_error_message (rslt));
}
--- 674,687 ----
printf_filtered ("Target is real hardware.\n");
rslt = angel_RDI_info (RDIInfo_Step, &arg1, &arg2);
! if (rslt != RDIError_NoError)
{
printf_filtered ("RDI_info: %s\n", rdi_error_message (rslt));
}
printf_filtered ("Target can%s single-step.\n", (arg1 & 0x4 ? "" : "not"));
rslt = angel_RDI_info (RDIInfo_Icebreaker, &arg1, &arg2);
! if (rslt != RDIError_NoError)
{
printf_filtered ("RDI_info: %s\n", rdi_error_message (rslt));
}
*************** arm_rdi_kill (void)
*** 701,707 ****
int rslt;
rslt = angel_RDI_open (1, &gdb_config, NULL, NULL);
! if (rslt)
{
printf_filtered ("RDI_open: %s\n", rdi_error_message (rslt));
}
--- 695,701 ----
int rslt;
rslt = angel_RDI_open (1, &gdb_config, NULL, NULL);
! if (rslt != RDIError_NoError)
{
printf_filtered ("RDI_open: %s\n", rdi_error_message (rslt));
}
*************** arm_rdi_insert_breakpoint (CORE_ADDR add
*** 736,742 ****
if (arm_pc_is_thumb (addr) || arm_pc_is_thumb_dummy (addr))
type |= RDIPoint_16Bit;
rslt = angel_RDI_setbreak (addr, type, 0, &point);
! if (rslt)
{
printf_filtered ("RDI_setbreak: %s\n", rdi_error_message (rslt));
}
--- 730,736 ----
if (arm_pc_is_thumb (addr) || arm_pc_is_thumb_dummy (addr))
type |= RDIPoint_16Bit;
rslt = angel_RDI_setbreak (addr, type, 0, &point);
! if (rslt != RDIError_NoError)
{
printf_filtered ("RDI_setbreak: %s\n", rdi_error_message (rslt));
}
*************** arm_rdi_remove_breakpoint (CORE_ADDR add
*** 754,789 ****
{
int rslt;
PointHandle point;
! struct local_bp_list_entry *entry, *preventry;
! for (entry = local_bp_list; entry != NULL; entry = entry->next)
! {
! if (entry->addr == addr)
! {
! break;
! }
! preventry = entry;
! }
! if (entry)
! {
! rslt = angel_RDI_clearbreak (entry->point);
! if (rslt)
! {
! printf_filtered ("RDI_clearbreak: %s\n", rdi_error_message (rslt));
! }
/* Delete the breakpoint entry locally. */
! if (entry == local_bp_list)
! {
! local_bp_list = entry->next;
! }
! else
! {
! preventry->next = entry->next;
! }
! xfree (entry);
}
return 0;
}
static char *
rdi_error_message (int err)
--- 748,774 ----
{
int rslt;
PointHandle point;
! struct local_bp_list_entry **entryp, *dead;
! for (entryp = &local_bp_list; *entryp != NULL; entryp = &(*entryp)->next)
! if ((*entryp)->addr == addr)
! break;
!
! if (*entryp)
! {
! dead = *entryp;
! rslt = angel_RDI_clearbreak (dead->point);
! if (rslt != RDIError_NoError)
! printf_filtered ("RDI_clearbreak: %s\n", rdi_error_message (rslt));
!
/* Delete the breakpoint entry locally. */
! *entryp = dead->next;
! xfree (dead);
}
+
return 0;
}
+
static char *
rdi_error_message (int err)
*************** Withough an argument, it will display cu
*** 1057,1078 ****
&maintenancelist);
add_show_from_set
! (add_set_cmd ("rdiromatzero", no_class,
! var_boolean, (char *) &rom_at_zero,
! "Set target has ROM at addr 0.\n\
A true value disables vector catching, false enables vector catching.\n\
This is evaluated at the time the 'target rdi' command is executed\n",
! &setlist),
&showlist);
add_show_from_set
! (add_set_cmd ("rdiheartbeat", no_class,
! var_boolean, (char *) &rdi_heartbeat,
! "Set enable for ADP heartbeat packets.\n\
I don't know why you would want this. If you enable them,\n\
it will confuse ARM and EPI JTAG interface boxes as well\n\
as the Angel Monitor.\n",
! &setlist),
&showlist);
}
--- 1042,1061 ----
&maintenancelist);
add_show_from_set
! (add_set_boolean_cmd ("rdiromatzero", no_class, &rom_at_zero,
! "Set target has ROM at addr 0.\n\
A true value disables vector catching, false enables vector catching.\n\
This is evaluated at the time the 'target rdi' command is executed\n",
! &setlist),
&showlist);
add_show_from_set
! (add_set_boolean_cmd ("rdiheartbeat", no_class, &rdi_heartbeat,
! "Set enable for ADP heartbeat packets.\n\
I don't know why you would want this. If you enable them,\n\
it will confuse ARM and EPI JTAG interface boxes as well\n\
as the Angel Monitor.\n",
! &setlist),
&showlist);
}