Line 36... |
Line 36... |
#include <fcntl.h>
|
#include <fcntl.h>
|
#include <arpa/inet.h>
|
#include <arpa/inet.h>
|
#include <poll.h>
|
#include <poll.h>
|
#include <netinet/tcp.h>
|
#include <netinet/tcp.h>
|
#include <string.h>
|
#include <string.h>
|
|
#include <netinet/in.h>
|
|
|
/* Package includes */
|
/* Package includes */
|
#include "except.h"
|
#include "except.h"
|
#include "spr-defs.h"
|
#include "spr-defs.h"
|
#include "dbg_api.h"
|
#include "dbg_api.h"
|
Line 497... |
Line 498... |
if (rsp.client_waiting)
|
if (rsp.client_waiting)
|
{
|
{
|
// Read the PPC
|
// Read the PPC
|
dbg_cpu0_read(SPR_PPC, &ppcval);
|
dbg_cpu0_read(SPR_PPC, &ppcval);
|
|
|
if ((TARGET_SIGNAL_TRAP == rsp.sigval) &&
|
// This is structured the way it is to avoid the read of DMR2 unless it's necessary.
|
(NULL != mp_hash_lookup (BP_MEMORY, ppcval))) // We also get TRAP from a single-step, don't change npc unless it's really a BP
|
if (TARGET_SIGNAL_TRAP == rsp.sigval)
|
{
|
{
|
|
if(NULL != mp_hash_lookup (BP_MEMORY, ppcval)) // Is this a breakpoint we set? (we also get a TRAP on single-step)
|
|
{
|
|
//fprintf(stderr, "Resetting NPC to PPC\n");
|
|
set_npc(ppcval);
|
|
}
|
|
else
|
|
{
|
|
uint32_t dmr2val;
|
|
dbg_cpu0_read(SPR_DMR2, &dmr2val); // We need this to check for a hardware breakpoint
|
|
if((dmr2val & SPR_DMR2_WBS) != 0) // Is this a hardware breakpoint?
|
|
{
|
|
//fprintf(stderr, "Resetting NPC to PPC\n");
|
set_npc (ppcval);
|
set_npc (ppcval);
|
}
|
}
|
|
}
|
|
}
|
|
|
rsp_report_exception();
|
rsp_report_exception();
|
rsp.client_waiting = 0; /* No longer waiting */
|
rsp.client_waiting = 0; /* No longer waiting */
|
}
|
}
|
}
|
}
|
Line 1730... |
Line 1745... |
static void
|
static void
|
rsp_continue_generic (unsigned long int except)
|
rsp_continue_generic (unsigned long int except)
|
{
|
{
|
uint32_t tmp;
|
uint32_t tmp;
|
|
|
/* Clear Debug Reason Register and watchpoint break generation in Debug Mode
|
/* Clear Debug Reason Register */
|
Register 2 */
|
|
dbg_cpu0_write(SPR_DRR, 0);
|
dbg_cpu0_write(SPR_DRR, 0);
|
|
|
|
/* Clear any watchpoints indicated in DMR2. Any write to DMR2 will clear this (undocumented feature). */
|
dbg_cpu0_read(SPR_DMR2, &tmp);
|
dbg_cpu0_read(SPR_DMR2, &tmp);
|
tmp &= ~SPR_DMR2_WGB;
|
if(tmp & SPR_DMR2_WBS) { // don't waste the time writing if no hw breakpoints set
|
dbg_cpu0_write(SPR_DMR2, tmp);
|
dbg_cpu0_write(SPR_DMR2, tmp);
|
|
}
|
|
|
/* Clear the single step trigger in Debug Mode Register 1 and set traps to be
|
/* Clear the single step trigger in Debug Mode Register 1 and set traps to be
|
handled by the debug unit in the Debug Stop Register */
|
handled by the debug unit in the Debug Stop Register */
|
dbg_cpu0_read(SPR_DMR1, &tmp);
|
dbg_cpu0_read(SPR_DMR1, &tmp);
|
tmp &= ~(SPR_DMR1_ST|SPR_DMR1_BT); // clear single-step and trap-on-branch
|
tmp &= ~(SPR_DMR1_ST|SPR_DMR1_BT); // clear single-step and trap-on-branch
|
Line 2445... |
Line 2462... |
static void
|
static void
|
rsp_step_generic (unsigned long int except)
|
rsp_step_generic (unsigned long int except)
|
{
|
{
|
uint32_t tmp;
|
uint32_t tmp;
|
|
|
/* Clear Debug Reason Register and watchpoint break generation in Debug Mode
|
/* Clear Debug Reason Register */
|
Register 2 */
|
|
tmp = 0;
|
tmp = 0;
|
dbg_cpu0_write(SPR_DRR, tmp); // *** TODO Check return value of all hardware accesses
|
dbg_cpu0_write(SPR_DRR, tmp); // *** TODO Check return value of all hardware accesses
|
|
|
|
/* Clear any watchpoint indicators in DMR2. Any write to DMR2 will do this (undocumented feature) */
|
dbg_cpu0_read(SPR_DMR2, &tmp);
|
dbg_cpu0_read(SPR_DMR2, &tmp);
|
if(tmp & SPR_DMR2_WGB) {
|
if(tmp & SPR_DMR2_WBS) { // If no HW breakpoints, don't waste time writing
|
tmp &= ~SPR_DMR2_WGB;
|
|
dbg_cpu0_write(SPR_DMR2, tmp);
|
dbg_cpu0_write(SPR_DMR2, tmp);
|
}
|
}
|
|
|
/* Set the single step trigger in Debug Mode Register 1 and set traps to be
|
/* Set the single step trigger in Debug Mode Register 1 and set traps to be
|
handled by the debug unit in the Debug Stop Register */
|
handled by the debug unit in the Debug Stop Register */
|