Line 31... |
Line 31... |
#include "gdbcore.h"
|
#include "gdbcore.h"
|
#include "target.h"
|
#include "target.h"
|
#include "remote-utils.h"
|
#include "remote-utils.h"
|
#include "gdb_string.h"
|
#include "gdb_string.h"
|
#include "tm.h"
|
#include "tm.h"
|
|
#include "event-loop.h"
|
|
#include "event-top.h"
|
|
#include "inf-loop.h"
|
|
|
#include <signal.h>
|
#include <signal.h>
|
#include <sys/types.h>
|
#include <sys/types.h>
|
#include <sys/stat.h>
|
#include <sys/stat.h>
|
#include <sys/ioctl.h>
|
#include <sys/ioctl.h>
|
#include <fcntl.h>
|
#include <fcntl.h>
|
|
|
#define debug if (remote_debug) printf_unfiltered
|
#define debug if (remote_debug) printf_unfiltered
|
|
|
|
/* Prototypes for local functions */
|
|
static void or1k_interrupt PARAMS ((int signo));
|
|
static void or1k_interrupt_twice PARAMS ((int signo));
|
|
static void interrupt_query PARAMS ((void));
|
|
|
/* The following prototype is necessary or the compiler will not
|
/* The following prototype is necessary or the compiler will not
|
correctly promote the data argument to ULONGEST */
|
correctly promote the data argument to ULONGEST */
|
static void or1k_write_reg (unsigned int, ULONGEST);
|
static void or1k_write_reg (unsigned int, ULONGEST);
|
static int insn_modifies_gprs (unsigned int insn);
|
static int insn_modifies_gprs (unsigned int insn);
|
|
|
Line 179... |
Line 187... |
int matchpoint_user_count[MAX_MATCHPOINTS] = {0};
|
int matchpoint_user_count[MAX_MATCHPOINTS] = {0};
|
|
|
/* Old SIGINT handler. */
|
/* Old SIGINT handler. */
|
static void (*ofunc) PARAMS ((int));
|
static void (*ofunc) PARAMS ((int));
|
|
|
|
/* Tokens for use by the asynchronous signal handlers for SIGINT */
|
|
PTR sigint_or1k_twice_token;
|
|
PTR sigint_or1k_token;
|
|
|
|
|
/* Handle low-level error that we can't recover from. Note that just
|
/* Handle low-level error that we can't recover from. Note that just
|
error()ing out from target_wait or some such low-level place will cause
|
error()ing out from target_wait or some such low-level place will cause
|
all hell to break loose--the rest of GDB will tend to get left in an
|
all hell to break loose--the rest of GDB will tend to get left in an
|
inconsistent state. */
|
inconsistent state. */
|
Line 558... |
Line 570... |
return;
|
return;
|
or1k_status = TARGET_UNDEFINED;
|
or1k_status = TARGET_UNDEFINED;
|
or1k_reset();
|
or1k_reset();
|
or1k_status = TARGET_STOPPED;
|
or1k_status = TARGET_STOPPED;
|
|
|
inferior_pid = 0;
|
/* obsolete inferior_pid = 0; */
|
}
|
}
|
|
|
/* Open a connection to the remote board. */
|
/* Open a connection to the remote board. */
|
|
|
static void
|
static void
|
Line 608... |
Line 620... |
/* HW STEP. Set DMR1_ST. */
|
/* HW STEP. Set DMR1_ST. */
|
dmr1 |= DMR1_ST;
|
dmr1 |= DMR1_ST;
|
or1k_write_spr_reg (DMR1_SPRNUM, dmr1);
|
or1k_write_spr_reg (DMR1_SPRNUM, dmr1);
|
dmr1 &= ~DMR1_ST;
|
dmr1 &= ~DMR1_ST;
|
or1k_unstall ();
|
or1k_unstall ();
|
|
or1k_status = TARGET_STOPPED;
|
}
|
}
|
|
|
/* Close a connection to the remote board. */
|
/* Close a connection to the remote board. */
|
|
|
static void
|
static void
|
or1k_close (quitting)
|
or1k_close (quitting)
|
int quitting;
|
int quitting;
|
{
|
{
|
if (or1k_is_open)
|
if (or1k_is_open)
|
{
|
{
|
or1k_kill ();
|
|
if (current_or1k_target != NULL && current_or1k_target->to_done != NULL)
|
if (current_or1k_target != NULL && current_or1k_target->to_done != NULL)
|
current_or1k_target->to_done ();
|
current_or1k_target->to_done ();
|
current_or1k_target = NULL;
|
current_or1k_target = NULL;
|
}
|
}
|
generic_mourn_inferior ();
|
generic_mourn_inferior ();
|
Line 697... |
Line 709... |
}
|
}
|
|
|
target_terminal_inferior ();
|
target_terminal_inferior ();
|
}
|
}
|
|
|
static void or1k_interrupt_twice (int signo);
|
/* Send ^C to target to halt it. Target will respond, and send us a
|
|
packet. */
|
|
static void (*ofunc) PARAMS ((int));
|
|
|
/* The command line interface's stop routine. This function is installed
|
/* The command line interface's stop routine. This function is installed
|
as a signal handler for SIGINT. The first time a user requests a
|
as a signal handler for SIGINT. The first time a user requests a
|
stop, we call remote_stop to send a break or ^C. If there is no
|
stop, we call remote_stop to send a break or ^C. If there is no
|
response from the target (it didn't stop when the user requested it),
|
response from the target (it didn't stop when the user requested it),
|
we ask the user if he'd like to detach from the target. */
|
we ask the user if he'd like to detach from the target. */
|
static void
|
static void
|
or1k_interrupt (signo)
|
or1k_interrupt (signo)
|
int signo;
|
int signo;
|
{
|
{
|
debug ("interrupt");
|
|
/* If this doesn't work, try more severe steps. */
|
/* If this doesn't work, try more severe steps. */
|
signal (signo, or1k_interrupt_twice);
|
signal (signo, or1k_interrupt_twice);
|
|
|
debug ("remote_interrupt called\n");
|
if (remote_debug)
|
|
fprintf_unfiltered (gdb_stdlog, "or1k_interrupt called\n");
|
|
|
interrupt_count++;
|
interrupt_count++;
|
}
|
}
|
|
|
/* The user typed ^C twice. */
|
/* The user typed ^C twice. */
|
|
|
static void
|
static void
|
or1k_interrupt_twice (signo)
|
or1k_interrupt_twice (signo)
|
int signo;
|
int signo;
|
{
|
{
|
debug ("interrupt2");
|
quit_flag = 1;
|
|
if (interrupt_count++ >= 2) {
|
|
or1k_stop ();
|
signal (signo, ofunc);
|
signal (signo, ofunc);
|
interrupt_query ();
|
interrupt_query ();
|
signal (signo, or1k_interrupt);
|
signal (signo, or1k_interrupt_twice);
|
|
interrupt_count = 1;
|
|
}
|
}
|
}
|
|
|
/* Resume execution of the target process. STEP says whether to single-step
|
/* Resume execution of the target process. STEP says whether to single-step
|
or to run free; SIGGNAL is the signal value (e.g. SIGINT) to be given
|
or to run free; SIGGNAL is the signal value (e.g. SIGINT) to be given
|
to the target, or zero for no signal. */
|
to the target, or zero for no signal. */
|
Line 746... |
Line 763... |
unsigned int npc;
|
unsigned int npc;
|
unsigned int val;
|
unsigned int val;
|
unsigned int ppc_insn;
|
unsigned int ppc_insn;
|
unsigned int pc_insn;
|
unsigned int pc_insn;
|
|
|
|
/* We must accumulate interrupt counts, when stepping. This may cause some
|
|
unwanted questions, if step is interrupted several consequtive times,
|
|
but this should not be the issue with normal usage */
|
|
if (step == 0)
|
|
interrupt_count = 0;
|
|
|
pc = read_pc();
|
pc = read_pc();
|
npc = or1k_read_spr_reg (PC_SPRNUM);
|
npc = or1k_read_spr_reg (PC_SPRNUM);
|
ppc = or1k_read_spr_reg (PPC_SPRNUM);
|
ppc = or1k_read_spr_reg (PPC_SPRNUM);
|
debug ("pc = %08x BP = %x npc = %08x ppc = %08x\n", pc, breakpoint_here_p (pc), npc, ppc);
|
debug ("pc = %08x BP = %x npc = %08x ppc = %08x\n", pc, breakpoint_here_p (pc), npc, ppc);
|
debug ("resume %i, %i, %i\n",step, siggnal, or1k_status);
|
debug ("resume %i, %i, %i\n",step, siggnal, or1k_status);
|
Line 958... |
Line 981... |
{
|
{
|
unsigned long val;
|
unsigned long val;
|
unsigned long pc;
|
unsigned long pc;
|
unsigned long ppc;
|
unsigned long ppc;
|
char buf[MAX_REGISTER_RAW_SIZE];
|
char buf[MAX_REGISTER_RAW_SIZE];
|
interrupt_count = 0;
|
|
|
|
debug ("wait %i %i\n", pid, or1k_status);
|
debug ("wait %i %i\n", pid, or1k_status);
|
/* If we have not sent a single step or continue command, then the
|
/* If we have not sent a single step or continue command, then the
|
board is waiting for us to do something. Return a status
|
board is waiting for us to do something. Return a status
|
indicating that it is stopped. */
|
indicating that it is stopped. */
|
Line 977... |
Line 999... |
|
|
if (err)
|
if (err)
|
or1k_error ("Remote failure: %s", or1k_err_name (err));
|
or1k_error ("Remote failure: %s", or1k_err_name (err));
|
|
|
/* Set new signal handler */
|
/* Set new signal handler */
|
|
if (interrupt_count)
|
|
ofunc = signal (SIGINT, or1k_interrupt_twice);
|
|
else
|
ofunc = signal (SIGINT, or1k_interrupt);
|
ofunc = signal (SIGINT, or1k_interrupt);
|
|
|
/* Wait for risc to stop. */
|
/* Wait for risc to stop. */
|
do {
|
do {
|
or1k_set_chain (SC_REGISTER);
|
or1k_set_chain (SC_REGISTER);
|
Line 993... |
Line 1018... |
|
|
usleep (10);
|
usleep (10);
|
debug ("%i", val);
|
debug ("%i", val);
|
} while ((val & 1) == 0);
|
} while ((val & 1) == 0);
|
|
|
|
//sleep(1);
|
drr = or1k_read_spr_reg (DRR_SPRNUM);
|
drr = or1k_read_spr_reg (DRR_SPRNUM);
|
|
|
/* Restore old INT signal handler */
|
/* Restore old INT signal handler */
|
signal (SIGINT, ofunc);
|
signal (SIGINT, ofunc);
|
|
|