Merge branch 'dbg-runstate-enum' of https://github.com/wnayes/mupen64plus-core into wnayes-dbg-runstate-enum

This commit is contained in:
Richard Goedeken 2015-02-14 08:34:55 -08:00
commit 4abfbaf472
8 changed files with 36 additions and 28 deletions

View file

@ -38,10 +38,10 @@ Most libmupen64plus functions return an <tt>m64p_error</tt> return code, which i
<br />
{| border="1"
|Prototype
|'''<tt>m64p_error DebugSetRunState(int runstate)</tt>'''
|'''<tt>m64p_error DebugSetRunState(m64p_dbg_runstate runstate)</tt>'''
|-
|Input Parameters
|'''<tt>runstate</tt>''' 0 == pause, 1 == single instruction step, 2 == run
|'''<tt>runstate</tt>''' An <tt>m64p_dbg_runstate</tt> enumerated type specifying the debugging state of the emulator. <tt>M64P_DBG_RUNSTATE_RUNNING</tt> continues execution until a breakpoint is hit or a different state is chosen. <tt>M64P_DBG_RUNSTATE_STEPPING</tt> enters a single step running mode that sends callbacks as each step is performed. <tt>M64P_DBG_RUNSTATE_PAUSED</tt> pauses execution to allow manual stepping.
|-
|Requirements
|The Mupen64Plus library must be built with debugger support and must be initialized before calling this function.

View file

@ -191,6 +191,12 @@
M64P_DBG_CPU_NEXT_INTERRUPT
} m64p_dbg_state;
typedef enum {
M64P_DBG_RUNSTATE_PAUSED = 0,
M64P_DBG_RUNSTATE_STEPPING,
M64P_DBG_RUNSTATE_RUNNING
} m64p_dbg_runstate;
typedef enum {
M64P_DBG_MEM_TYPE = 1,
M64P_DBG_MEM_FLAGS,

View file

@ -112,10 +112,10 @@ EXPORT m64p_error CALL DebugSetCallbacks(void (*dbg_frontend_init)(void), void (
#endif
}
EXPORT m64p_error CALL DebugSetRunState(int runstate)
EXPORT m64p_error CALL DebugSetRunState(m64p_dbg_runstate runstate)
{
#ifdef DBG
run = runstate; /* in debugger/debugger.c */
g_dbg_runstate = runstate; /* in debugger/debugger.c */
return M64ERR_SUCCESS;
#else
return M64ERR_UNSUPPORTED;
@ -128,7 +128,7 @@ EXPORT int CALL DebugGetState(m64p_dbg_state statenum)
switch (statenum)
{
case M64P_DBG_RUN_STATE:
return run;
return g_dbg_runstate;
case M64P_DBG_PREVIOUS_PC:
return previousPC;
case M64P_DBG_NUM_BREAKPOINTS:

View file

@ -58,9 +58,9 @@ EXPORT m64p_error CALL DebugSetCoreCompare(void (*)(unsigned int), void (*)(int,
*
* This function sets the run state of the R4300 CPU emulator.
*/
typedef m64p_error (*ptr_DebugSetRunState)(int);
typedef m64p_error (*ptr_DebugSetRunState)(m64p_dbg_runstate);
#if defined(M64P_CORE_PROTOTYPES)
EXPORT m64p_error CALL DebugSetRunState(int);
EXPORT m64p_error CALL DebugSetRunState(m64p_dbg_runstate);
#endif
/* DebugGetState()

View file

@ -215,6 +215,12 @@ typedef enum {
M64P_DBG_CPU_NEXT_INTERRUPT
} m64p_dbg_state;
typedef enum {
M64P_DBG_RUNSTATE_PAUSED = 0,
M64P_DBG_RUNSTATE_STEPPING,
M64P_DBG_RUNSTATE_RUNNING
} m64p_dbg_runstate;
typedef enum {
M64P_DBG_MEM_TYPE = 1,
M64P_DBG_MEM_FLAGS,

View file

@ -185,17 +185,15 @@ int check_breakpoints_on_mem_access( uint32 pc, uint32 address, uint32 size, uin
//It automatically stops and updates the debugger on hit, so the memory access
//functions only need to call it and can discard the result.
int bpt;
if(run == 2)
{
bpt=lookup_breakpoint( address, size, flags );
if(bpt != -1)
{
if (g_dbg_runstate == M64P_DBG_RUNSTATE_RUNNING) {
bpt = lookup_breakpoint(address, size, flags);
if (bpt != -1) {
if (BPT_CHECK_FLAG(g_Breakpoints[bpt], M64P_BKP_FLAG_LOG))
log_breakpoint(pc, flags, address);
run = 0;
g_dbg_runstate = M64P_DBG_RUNSTATE_PAUSED;
update_debugger(pc);
return bpt;
}
}

View file

@ -29,11 +29,9 @@
#include "dbg_breakpoints.h"
#include "dbg_memory.h"
// State of the Emulation Thread:
// 0 -> pause, 2 -> run.
int g_DebuggerActive = 0; // whether the debugger is enabled or not
int run;
m64p_dbg_runstate g_dbg_runstate;
// Holds the number of pending steps the debugger needs to perform.
static SDL_sem *sem_pending_steps;
@ -45,7 +43,7 @@ uint32 previousPC;
void init_debugger()
{
g_DebuggerActive = 1;
run = 0;
g_dbg_runstate = M64P_DBG_RUNSTATE_PAUSED;
DebuggerCallback(DEBUG_UI_INIT, 0); /* call front-end to initialize user interface */
@ -70,20 +68,20 @@ void update_debugger(uint32 pc)
{
int bpt;
if(run!=0) {//check if we hit a breakpoint
if (g_dbg_runstate != M64P_DBG_RUNSTATE_PAUSED) {
bpt = check_breakpoints(pc);
if( bpt!=-1 ) {
run = 0;
if (bpt != -1) {
g_dbg_runstate = M64P_DBG_RUNSTATE_PAUSED;
if (BPT_CHECK_FLAG(g_Breakpoints[bpt], M64P_BKP_FLAG_LOG))
log_breakpoint(pc, M64P_BKP_FLAG_EXEC, 0);
}
}
if(run!=2) {
if (g_dbg_runstate != M64P_DBG_RUNSTATE_RUNNING) {
DebuggerCallback(DEBUG_UI_UPDATE, pc); /* call front-end to notify user interface to update */
}
if(run==0) {
if (g_dbg_runstate == M64P_DBG_RUNSTATE_PAUSED) {
// The emulation thread is blocked until a step call via the API.
SDL_SemWait(sem_pending_steps);
}

View file

@ -23,11 +23,11 @@
#ifndef __DEBUGGER_H__
#define __DEBUGGER_H__
#include "api/m64p_types.h"
extern int g_DebuggerActive; /* True if the debugger is running */
/* State of the Emulation Thread:
0 -> pause, 1 -> step, 2 -> run. */
extern int run;
extern m64p_dbg_runstate g_dbg_runstate;
extern uint32 previousPC;