X-Git-Url: http://git.efficios.com/?a=blobdiff_plain;f=gdb%2Fremote-rdi.c;h=50d1fbf7c12afcd34716089fa5f29017c3fa6c9f;hb=902f2ccb3d3c265dfd20a64f35839df9a6c7655a;hp=d97cb65c2c916e5ef6246ebae4ce611e1b0f29b1;hpb=fa58ee119617c4302d6bf94ff751c3ee8e1062cd;p=deliverable%2Fbinutils-gdb.git diff --git a/gdb/remote-rdi.c b/gdb/remote-rdi.c index d97cb65c2c..50d1fbf7c1 100644 --- a/gdb/remote-rdi.c +++ b/gdb/remote-rdi.c @@ -1,5 +1,7 @@ /* GDB interface to ARM RDI library. - Copyright 1997, 1998, 2001 Free Software Foundation, Inc. + + Copyright 1997, 1998, 1999, 2000, 2001, 2002, 2004 Free Software + Foundation, Inc. This file is part of GDB. @@ -33,6 +35,8 @@ #include "gdbcore.h" #include "breakpoint.h" #include "completer.h" +#include "regcache.h" +#include "arm-tdep.h" #ifdef USG #include @@ -59,34 +63,21 @@ static void arm_rdi_prepare_to_store (void); static void arm_rdi_fetch_registers (int regno); -static void arm_rdi_resume (int pid, int step, enum target_signal siggnal); - -static int arm_rdi_start_remote (char *dummy); +static void arm_rdi_resume (ptid_t pid, int step, + enum target_signal siggnal); static void arm_rdi_open (char *name, int from_tty); -static void arm_rdi_create_inferior (char *exec_file, char *args, char **env); - static void arm_rdi_close (int quitting); static void arm_rdi_store_registers (int regno); -static void arm_rdi_mourn (void); - -static void arm_rdi_send (char *buf); - -static int arm_rdi_wait (int pid, struct target_waitstatus *status); +static ptid_t arm_rdi_wait (ptid_t ptid, struct target_waitstatus *status); static void arm_rdi_kill (void); static void arm_rdi_detach (char *args, int from_tty); -static void arm_rdi_interrupt (int signo); - -static void arm_rdi_interrupt_twice (int signo); - -static void interrupt_query (void); - static int arm_rdi_insert_breakpoint (CORE_ADDR, char *); static int arm_rdi_remove_breakpoint (CORE_ADDR, char *); @@ -129,39 +120,30 @@ static struct local_bp_list_entry } *local_bp_list; - -/* Stub for catch_errors. */ - -static int -arm_rdi_start_remote (char *dummy) -{ - return 1; -} - /* Helper callbacks for the "host interface" structure. RDI functions call these to forward output from the target system and so forth. */ -void +static void voiddummy (void *dummy) { fprintf_unfiltered (gdb_stdout, "void dummy\n"); } static void -myprint (PTR arg, const char *format, va_list ap) +myprint (void *arg, const char *format, va_list ap) { vfprintf_unfiltered (gdb_stdout, format, ap); } static void -mywritec (PTR arg, int c) +mywritec (void *arg, int c) { if (isascii (c)) fputc_unfiltered (c, gdb_stdout); } static int -mywrite (PTR arg, char const *buffer, int len) +mywrite (void *arg, char const *buffer, int len) { int i; char *e; @@ -180,7 +162,7 @@ mywrite (PTR arg, char const *buffer, int len) } static void -mypause (PTR arg) +mypause (void *arg) { } @@ -188,13 +170,13 @@ mypause (PTR arg) being interrupted more carefully */ static int -myreadc (PTR arg) +myreadc (void *arg) { return fgetc (stdin); } static char * -mygets (PTR arg, char *buffer, int len) +mygets (void *arg, char *buffer, int len) { return fgets (buffer, len, stdin); } @@ -241,7 +223,7 @@ device is attached to the remote system (e.g. /dev/ttya)."); if (rslt != adp_ok) error ("Could not open device \"%s\"", name); - gdb_config.bytesex = 2 | (TARGET_BYTE_ORDER == BIG_ENDIAN ? 1 : 0); + gdb_config.bytesex = 2 | (TARGET_BYTE_ORDER == BFD_ENDIAN_BIG ? 1 : 0); gdb_config.fpe = 1; gdb_config.rditype = 2; gdb_config.heartbeat_on = 1; @@ -260,7 +242,7 @@ device is attached to the remote system (e.g. /dev/ttya)."); 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) + else if (rslt != RDIError_NoError) { printf_filtered ("RDI_open: %s\n", rdi_error_message (rslt)); Adp_CloseDevice (); @@ -268,33 +250,33 @@ device is attached to the remote system (e.g. /dev/ttya)."); } rslt = angel_RDI_info (RDIInfo_Target, &arg1, &arg2); - if (rslt) + if (rslt != RDIError_NoError) { printf_filtered ("RDI_info: %s\n", rdi_error_message (rslt)); } rslt = angel_RDI_info (RDIInfo_Points, &arg1, &arg2); - if (rslt) + if (rslt != RDIError_NoError) { printf_filtered ("RDI_info: %s\n", rdi_error_message (rslt)); } rslt = angel_RDI_info (RDIInfo_Step, &arg1, &arg2); - if (rslt) + if (rslt != RDIError_NoError) { printf_filtered ("RDI_info: %s\n", rdi_error_message (rslt)); } rslt = angel_RDI_info (RDIInfo_CoPro, &arg1, &arg2); - if (rslt) + if (rslt != RDIError_NoError) { printf_filtered ("RDI_info: %s\n", rdi_error_message (rslt)); } rslt = angel_RDI_info (RDIInfo_SemiHosting, &arg1, &arg2); - if (rslt) + if (rslt != RDIError_NoError) { printf_filtered ("RDI_info: %s\n", rdi_error_message (rslt)); } rslt = angel_RDI_info (RDIInfo_GetLoadSize, &arg1, &arg2); - if (rslt) + if (rslt != RDIError_NoError) { printf_filtered ("RDI_info: %s\n", rdi_error_message (rslt)); } @@ -305,7 +287,7 @@ device is attached to the remote system (e.g. /dev/ttya)."); target_fetch_registers (-1); rslt = angel_RDI_open (1, &gdb_config, NULL, NULL); - if (rslt) + if (rslt != RDIError_NoError) { printf_filtered ("RDI_open: %s\n", rdi_error_message (rslt)); } @@ -313,14 +295,14 @@ device is attached to the remote system (e.g. /dev/ttya)."); arg1 = rom_at_zero ? 0x0 : 0x13b; rslt = angel_RDI_info (RDIVector_Catch, &arg1, &arg2); - if (rslt) + 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) + if (rslt != RDIError_NoError) { printf_filtered ("RDI_info: %s\n", rdi_error_message (rslt)); } @@ -338,10 +320,10 @@ device is attached to the remote system (e.g. /dev/ttya)."); printf_filtered ("Connected to ARM RDI target.\n"); closed_already = 0; - inferior_pid = 42; + inferior_ptid = pid_to_ptid (42); } -/* Start an inferior process and set inferior_pid to its pid. +/* Start an inferior process and set inferior_ptid to its pid. EXEC_FILE is the file to run. ARGS is a string containing the arguments to the program. ENV is the environment vector to pass. Errors reported with error(). @@ -350,7 +332,7 @@ device is attached to the remote system (e.g. /dev/ttya)."); user types "run" after having attached. */ static void -arm_rdi_create_inferior (char *exec_file, char *args, char **env) +arm_rdi_create_inferior (char *exec_file, char *args, char **env, int from_tty) { int len, rslt; unsigned long arg1, arg2; @@ -373,7 +355,7 @@ arm_rdi_create_inferior (char *exec_file, char *args, char **env) strcat (arg_buf, " "); strcat (arg_buf, args); - inferior_pid = 42; + inferior_ptid = pid_to_ptid (42); insert_breakpoints (); /* Needed to get correct instruction in cache */ if (env != NULL) @@ -392,7 +374,7 @@ arm_rdi_create_inferior (char *exec_file, char *args, char **env) top_of_memory); rslt = angel_RDI_info (RDIInfo_SetTopMem, &top_of_memory, &arg2); - if (rslt) + if (rslt != RDIError_NoError) { printf_filtered ("RDI_info: %s\n", rdi_error_message (rslt)); } @@ -403,7 +385,7 @@ arm_rdi_create_inferior (char *exec_file, char *args, char **env) arg1 = (unsigned long) arg_buf; rslt = angel_RDI_info (RDISet_Cmdline, /* &arg1 */ (unsigned long *) arg_buf, &arg2); - if (rslt) + if (rslt != RDIError_NoError) { printf_filtered ("RDI_info: %s\n", rdi_error_message (rslt)); } @@ -432,12 +414,12 @@ arm_rdi_close (int quitting) if (!closed_already) { rslt = angel_RDI_close (); - if (rslt) + if (rslt != RDIError_NoError) { printf_filtered ("RDI_close: %s\n", rdi_error_message (rslt)); } closed_already = 1; - inferior_pid = 0; + inferior_ptid = null_ptid; Adp_CloseDevice (); generic_mourn_inferior (); } @@ -446,7 +428,7 @@ arm_rdi_close (int quitting) /* Tell the remote machine to resume. */ static void -arm_rdi_resume (int pid, int step, enum target_signal siggnal) +arm_rdi_resume (ptid_t ptid, int step, enum target_signal siggnal) { int rslt; PointHandle point; @@ -454,65 +436,36 @@ arm_rdi_resume (int pid, int step, enum target_signal siggnal) 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)); - } + if (rslt != RDIError_NoError) + printf_filtered ("RDI_step: %s\n", rdi_error_message (rslt)); } else { char handle[4]; - CORE_ADDR pc; + CORE_ADDR pc = 0; if (step) { - pc = read_register (PC_REGNUM); + pc = read_register (ARM_PC_REGNUM); 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 (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_remove_breakpoint (pc, handle); } } -/* Send ^C to target to halt it. Target will respond, and send us a - packet. */ - -static void -arm_rdi_interrupt (int signo) -{ -} - -static void (*ofunc) (); - -/* The user typed ^C twice. */ -static void -arm_rdi_interrupt_twice (int signo) -{ -} - -/* Ask the user what to do when an interrupt is received. */ - -static void -interrupt_query (void) -{ -} - /* Wait until the remote machine stops, then return, storing status in STATUS just as `wait' would. Returns "pid" (though it's not clear what, if anything, that means in the case of this target). */ -static int -arm_rdi_wait (int pid, struct target_waitstatus *status) +static ptid_t +arm_rdi_wait (ptid_t ptid, struct target_waitstatus *status) { status->kind = (execute_status == RDIError_NoError ? TARGET_WAITKIND_EXITED : TARGET_WAITKIND_STOPPED); @@ -520,12 +473,11 @@ arm_rdi_wait (int pid, struct target_waitstatus *status) /* convert stopped code from target into right signal */ status->value.sig = rdi_error_signal (execute_status); - return inferior_pid; + return inferior_ptid; } /* Read the remote registers into the block REGS. */ -/* ARGSUSED */ static void arm_rdi_fetch_registers (int regno) { @@ -536,7 +488,7 @@ arm_rdi_fetch_registers (int regno) if (regno == -1) { rslt = angel_RDI_CPUread (255, 0x27fff, rawregs); - if (rslt) + if (rslt != RDIError_NoError) { printf_filtered ("RDI_CPUread: %s\n", rdi_error_message (rslt)); } @@ -544,34 +496,34 @@ arm_rdi_fetch_registers (int regno) for (regno = 0; regno < 15; regno++) { store_unsigned_integer (cookedreg, 4, rawregs[regno]); - supply_register (regno, (char *) cookedreg); + regcache_raw_supply (current_regcache, regno, (char *) cookedreg); } store_unsigned_integer (cookedreg, 4, rawregs[15]); - supply_register (PS_REGNUM, (char *) cookedreg); - arm_rdi_fetch_registers (PC_REGNUM); + regcache_raw_supply (current_regcache, ARM_PS_REGNUM, (char *) cookedreg); + arm_rdi_fetch_registers (ARM_PC_REGNUM); } else { - if (regno == PC_REGNUM) + if (regno == ARM_PC_REGNUM) rdi_regmask = RDIReg_PC; - else if (regno == PS_REGNUM) + else if (regno == ARM_PS_REGNUM) rdi_regmask = RDIReg_CPSR; else if (regno < 0 || regno > 15) { rawreg = 0; - supply_register (regno, (char *) &rawreg); + regcache_raw_supply (current_regcache, regno, (char *) &rawreg); return; } else rdi_regmask = 1 << regno; rslt = angel_RDI_CPUread (255, rdi_regmask, &rawreg); - if (rslt) + if (rslt != RDIError_NoError) { printf_filtered ("RDI_CPUread: %s\n", rdi_error_message (rslt)); } store_unsigned_integer (cookedreg, 4, rawreg); - supply_register (regno, (char *) cookedreg); + regcache_raw_supply (current_regcache, regno, (char *) cookedreg); } } @@ -599,13 +551,13 @@ arm_rdi_store_registers (int regno) } else { - read_register_gen (regno, (char *) rawreg); + deprecated_read_register_gen (regno, (char *) rawreg); /* RDI manipulates data in host byte order, so convert now. */ store_unsigned_integer (rawerreg, 4, rawreg[0]); - if (regno == PC_REGNUM) + if (regno == ARM_PC_REGNUM) rdi_regmask = RDIReg_PC; - else if (regno == PS_REGNUM) + else if (regno == ARM_PS_REGNUM) rdi_regmask = RDIReg_CPSR; else if (regno < 0 || regno > 15) return; @@ -613,7 +565,7 @@ arm_rdi_store_registers (int regno) rdi_regmask = 1 << regno; rslt = angel_RDI_CPUwrite (255, rdi_regmask, rawerreg); - if (rslt) + if (rslt != RDIError_NoError) { printf_filtered ("RDI_CPUwrite: %s\n", rdi_error_message (rslt)); } @@ -625,18 +577,17 @@ arm_rdi_store_registers (int regno) if SHOULD_WRITE is nonzero. Returns length of data written or read; 0 for error. TARGET is unused. */ -/* ARGSUSED */ static int -arm_rdi_xfer_memory (CORE_ADDR memaddr, char *myaddr, int len, int should_write, - struct mem_attrib *attrib ATTRIBUTE_UNUSED, - struct target_ops *target ATTRIBUTE_UNUSED) +arm_rdi_xfer_memory (CORE_ADDR memaddr, char *myaddr, int len, + int should_write, struct mem_attrib *attrib, + struct target_ops *target) { int rslt, i; if (should_write) { rslt = angel_RDI_write (myaddr, memaddr, &len); - if (rslt) + if (rslt != RDIError_NoError) { printf_filtered ("RDI_write: %s\n", rdi_error_message (rslt)); } @@ -644,7 +595,7 @@ arm_rdi_xfer_memory (CORE_ADDR memaddr, char *myaddr, int len, int should_write, else { rslt = angel_RDI_read (memaddr, myaddr, &len); - if (rslt) + if (rslt != RDIError_NoError) { printf_filtered ("RDI_read: %s\n", rdi_error_message (rslt)); len = 0; @@ -663,7 +614,7 @@ arm_rdi_files_info (struct target_ops *ignore) unsigned long arg1, arg2; rslt = angel_RDI_info (RDIInfo_Target, &arg1, &arg2); - if (rslt) + if (rslt != RDIError_NoError) { printf_filtered ("RDI_info: %s\n", rdi_error_message (rslt)); } @@ -675,14 +626,14 @@ arm_rdi_files_info (struct target_ops *ignore) printf_filtered ("Target is real hardware.\n"); rslt = angel_RDI_info (RDIInfo_Step, &arg1, &arg2); - if (rslt) + 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) + if (rslt != RDIError_NoError) { printf_filtered ("RDI_info: %s\n", rdi_error_message (rslt)); } @@ -696,7 +647,7 @@ arm_rdi_kill (void) int rslt; rslt = angel_RDI_open (1, &gdb_config, NULL, NULL); - if (rslt) + if (rslt != RDIError_NoError) { printf_filtered ("RDI_open: %s\n", rdi_error_message (rslt)); } @@ -731,7 +682,7 @@ arm_rdi_insert_breakpoint (CORE_ADDR addr, char *contents_cache) 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) + if (rslt != RDIError_NoError) { printf_filtered ("RDI_setbreak: %s\n", rdi_error_message (rslt)); } @@ -749,36 +700,27 @@ arm_rdi_remove_breakpoint (CORE_ADDR addr, char *contents_cache) { int rslt; PointHandle point; - struct local_bp_list_entry *entry, *preventry; + struct local_bp_list_entry **entryp, *dead; - for (entry = local_bp_list; entry != NULL; entry = entry->next) - { - if (entry->addr == addr) - { - break; - } - preventry = entry; - } - if (entry) + for (entryp = &local_bp_list; *entryp != NULL; entryp = &(*entryp)->next) + if ((*entryp)->addr == addr) + break; + + if (*entryp) { - rslt = angel_RDI_clearbreak (entry->point); - if (rslt) - { - printf_filtered ("RDI_clearbreak: %s\n", rdi_error_message (rslt)); - } + 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. */ - if (entry == local_bp_list) - { - local_bp_list = entry->next; - } - else - { - preventry->next = entry->next; - } - xfree (entry); + *entryp = dead->next; + xfree (dead); } + return 0; } + static char * rdi_error_message (int err) @@ -1019,6 +961,8 @@ rdilogenable_command (char *args, int from_tty) " try y or n\n", args); } +extern initialize_file_ftype _initialize_remote_rdi; /* -Wmissing-prototypes */ + void _initialize_remote_rdi (void) { @@ -1033,48 +977,48 @@ _initialize_remote_rdi (void) c = add_cmd ("rdilogfile", class_maintenance, rdilogfile_command, - "Set filename for ADP packet log.\n\ -This file is used to log Angel Debugger Protocol packets.\n\ -With a single argument, sets the logfile name to that value.\n\ -Without an argument, shows the current logfile name.\n\ -See also: rdilogenable\n", - &maintenancelist); - c->completer = filename_completer; + "Set filename for ADP packet log.\n" + "This file is used to log Angel Debugger Protocol packets.\n" + "With a single argument, sets the logfile name to that value.\n" + "Without an argument, shows the current logfile name.\n" + "See also: rdilogenable\n", + &maintenancelist); + set_cmd_completer (c, filename_completer); add_cmd ("rdilogenable", class_maintenance, rdilogenable_command, - "Set enable logging of ADP packets.\n\ -This will log ADP packets exchanged between gdb and the\n\ -rdi target device.\n\ -An argument of 1,t,true,y,yes will enable.\n\ -An argument of 0,f,false,n,no will disabled.\n\ -Withough an argument, it will display current state.\n", + "Set enable logging of ADP packets.\n" + "This will log ADP packets exchanged between gdb and the\n" + "rdi target device.\n" + "An argument of 1, t, true, y or yes will enable.\n" + "An argument of 0, f, false, n or no will disabled.\n" + "Withough an argument, it will display current state.\n", &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\ + add_setshow_boolean_cmd ("rdiromatzero", no_class, &rom_at_zero, "\ +Set target has ROM at addr 0.", "\ +Show if target has ROM at addr 0.", "\ 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\ +This is evaluated at the time the 'target rdi' command is executed.", "\ +Target has ROM at addr 0 is %s.", + NULL, NULL, + &setlist, &showlist); + + add_setshow_boolean_cmd ("rdiheartbeat", no_class, &rdi_heartbeat, "\ +Set enable for ADP heartbeat packets.", "\ +Show enable for ADP heartbeat packets.", "\ 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); +as the Angel Monitor.", "\ +Enable for ADP heartbeat packets is %s.", + NULL, NULL, + &setlist, &showlist); } /* A little dummy to make linking with the library succeed. */ -int -Fail (void) +void +Fail (const char *ignored, ...) { - return 0; + }