X-Git-Url: http://drtracing.org/?a=blobdiff_plain;f=sim%2Frx%2Fgdb-if.c;h=8d265f1324cd668e8b68dbd61eaf0d2cbb63dfe9;hb=1a20473059c7a088b9f3c4188c09976eebbc3ab4;hp=5326bb36844da7a0896213f1c72c22371bd50046;hpb=c91e8ecef53e652f954c3ec21e149b4617aa1f3d;p=deliverable%2Fbinutils-gdb.git diff --git a/sim/rx/gdb-if.c b/sim/rx/gdb-if.c index 5326bb3684..8d265f1324 100644 --- a/sim/rx/gdb-if.c +++ b/sim/rx/gdb-if.c @@ -1,6 +1,6 @@ /* gdb-if.c -- sim interface to GDB. -Copyright (C) 2008, 2009, 2010 Free Software Foundation, Inc. +Copyright (C) 2008-2020 Free Software Foundation, Inc. Contributed by Red Hat, Inc. This file is part of the GNU simulators. @@ -18,6 +18,7 @@ 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, see . */ +#include "config.h" #include #include #include @@ -36,6 +37,7 @@ along with this program. If not, see . */ #include "load.h" #include "syscalls.h" #include "err.h" +#include "trace.h" /* Ideally, we'd wrap up all the minisim's data structures in an object and pass that around. However, neither GDB nor run needs @@ -52,14 +54,14 @@ static struct sim_state the_minisim = { "This is the sole rx minisim instance. See libsim.a's global variables." }; -static int open; +static int rx_sim_is_open; SIM_DESC sim_open (SIM_OPEN_KIND kind, struct host_callback_struct *callback, - struct bfd *abfd, char **argv) + struct bfd *abfd, char * const *argv) { - if (open) + if (rx_sim_is_open) fprintf (stderr, "rx minisim: re-opened sim\n"); /* The 'run' interface doesn't use this function, so we don't care @@ -77,7 +79,7 @@ sim_open (SIM_OPEN_KIND kind, execution_error_init_debugger (); sim_disasm_init (abfd); - open = 1; + rx_sim_is_open = 1; return &the_minisim; } @@ -96,7 +98,7 @@ sim_close (SIM_DESC sd, int quitting) /* Not much to do. At least free up our memory. */ init_mem (); - open = 0; + rx_sim_is_open = 0; } static bfd * @@ -162,14 +164,14 @@ build_swap_list (struct bfd *abfd) struct swap_list *sl; bfd_size_type size; - size = bfd_get_section_size (s); + size = bfd_section_size (s); if (size <= 0) continue; sl = malloc (sizeof (struct swap_list)); assert (sl != NULL); sl->next = swap_list; - sl->start = bfd_section_lma (abfd, s); + sl->start = bfd_section_lma (s); sl->end = sl->start + size; swap_list = sl; } @@ -190,7 +192,7 @@ addr_in_swap_list (bfd_vma addr) } SIM_RC -sim_load (SIM_DESC sd, char *prog, struct bfd *abfd, int from_tty) +sim_load (SIM_DESC sd, const char *prog, struct bfd *abfd, int from_tty) { check_desc (sd); @@ -199,20 +201,21 @@ sim_load (SIM_DESC sd, char *prog, struct bfd *abfd, int from_tty) if (!abfd) return SIM_RC_FAIL; - rx_load (abfd); + rx_load (abfd, get_callbacks ()); build_swap_list (abfd); return SIM_RC_OK; } SIM_RC -sim_create_inferior (SIM_DESC sd, struct bfd *abfd, char **argv, char **env) +sim_create_inferior (SIM_DESC sd, struct bfd *abfd, + char * const *argv, char * const *env) { check_desc (sd); if (abfd) { - rx_load (abfd); + rx_load (abfd, NULL); build_swap_list (abfd); } @@ -403,6 +406,9 @@ reg_size (enum sim_rx_regnum regno) case sim_rx_fpsw_regnum: size = sizeof (regs.r_fpsw); break; + case sim_rx_acc_regnum: + size = sizeof (regs.r_acc); + break; default: size = 0; break; @@ -503,6 +509,9 @@ sim_fetch_register (SIM_DESC sd, int regno, unsigned char *buf, int length) case sim_rx_fpsw_regnum: val = get_reg (fpsw); break; + case sim_rx_acc_regnum: + val = ((DI) get_reg (acchi) << 32) | get_reg (acclo); + break; default: fprintf (stderr, "rx minisim: unrecognized register number: %d\n", regno); @@ -526,12 +535,12 @@ sim_store_register (SIM_DESC sd, int regno, unsigned char *buf, int length) check_desc (sd); if (!check_regno (regno)) - return 0; + return -1; size = reg_size (regno); if (length != size) - return 0; + return -1; if (rx_big_endian) val = get_be (buf, length); @@ -615,10 +624,14 @@ sim_store_register (SIM_DESC sd, int regno, unsigned char *buf, int length) case sim_rx_fpsw_regnum: put_reg (fpsw, val); break; + case sim_rx_acc_regnum: + put_reg (acclo, val & 0xffffffff); + put_reg (acchi, (val >> 32) & 0xffffffff); + break; default: fprintf (stderr, "rx minisim: unrecognized register number: %d\n", regno); - return -1; + return 0; } return size; @@ -638,52 +651,35 @@ int siggnal; /* Given a signal number used by the RX bsp (that is, newlib), - return a host signal number. (Oddly, the gdb/sim interface uses - host signal numbers...) */ -int -rx_signal_to_host (int rx) + return a target signal number used by GDB. */ +static int +rx_signal_to_gdb_signal (int rx) { switch (rx) { case 4: -#ifdef SIGILL - return SIGILL; -#else - return SIGSEGV; -#endif + return GDB_SIGNAL_ILL; case 5: - return SIGTRAP; + return GDB_SIGNAL_TRAP; case 10: -#ifdef SIGBUS - return SIGBUS; -#else - return SIGSEGV; -#endif + return GDB_SIGNAL_BUS; case 11: - return SIGSEGV; + return GDB_SIGNAL_SEGV; case 24: -#ifdef SIGXCPU - return SIGXCPU; -#else - break; -#endif + return GDB_SIGNAL_XCPU; case 2: - return SIGINT; + return GDB_SIGNAL_INT; case 8: -#ifdef SIGFPE - return SIGFPE; -#else - break; -#endif + return GDB_SIGNAL_FPE; case 6: - return SIGABRT; + return GDB_SIGNAL_ABRT; } return 0; @@ -698,17 +694,17 @@ handle_step (int rc) if (execution_error_get_last_error () != SIM_ERR_NONE) { reason = sim_stopped; - siggnal = TARGET_SIGNAL_SEGV; + siggnal = GDB_SIGNAL_SEGV; } if (RX_STEPPED (rc) || RX_HIT_BREAK (rc)) { reason = sim_stopped; - siggnal = TARGET_SIGNAL_TRAP; + siggnal = GDB_SIGNAL_TRAP; } else if (RX_STOPPED (rc)) { reason = sim_stopped; - siggnal = rx_signal_to_host (RX_STOP_SIG (rc)); + siggnal = rx_signal_to_gdb_signal (RX_STOP_SIG (rc)); } else { @@ -722,6 +718,8 @@ handle_step (int rc) void sim_resume (SIM_DESC sd, int step, int sig_to_deliver) { + int rc; + check_desc (sd); if (sig_to_deliver != 0) @@ -734,7 +732,12 @@ sim_resume (SIM_DESC sd, int step, int sig_to_deliver) execution_error_clear_last_error (); if (step) - handle_step (decode_opcode ()); + { + rc = setjmp (decode_jmp_buf); + if (rc == 0) + rc = decode_opcode (); + handle_step (rc); + } else { /* We don't clear 'stop' here, because then we would miss @@ -747,16 +750,18 @@ sim_resume (SIM_DESC sd, int step, int sig_to_deliver) { stop = 0; reason = sim_stopped; - siggnal = TARGET_SIGNAL_INT; + siggnal = GDB_SIGNAL_INT; break; } - int rc = decode_opcode (); + rc = setjmp (decode_jmp_buf); + if (rc == 0) + rc = decode_opcode (); if (execution_error_get_last_error () != SIM_ERR_NONE) { reason = sim_stopped; - siggnal = TARGET_SIGNAL_SEGV; + siggnal = GDB_SIGNAL_SEGV; break; } @@ -787,11 +792,12 @@ sim_stop_reason (SIM_DESC sd, enum sim_stop *reason_p, int *sigrc_p) } void -sim_do_command (SIM_DESC sd, char *cmd) +sim_do_command (SIM_DESC sd, const char *cmd) { - check_desc (sd); + const char *args; + char *p = strdup (cmd); - char *p = cmd; + check_desc (sd); /* Skip leading whitespace. */ while (isspace (*p)) @@ -804,7 +810,6 @@ sim_do_command (SIM_DESC sd, char *cmd) /* Null-terminate the command word, and record the start of any further arguments. */ - char *args; if (*p) { *p = '\0'; @@ -840,4 +845,12 @@ sim_do_command (SIM_DESC sd, char *cmd) else printf ("The 'sim' command expects either 'trace' or 'verbose'" " as a subcommand.\n"); + + free (p); +} + +char ** +sim_complete_command (SIM_DESC sd, const char *text, const char *word) +{ + return NULL; }