1 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
2 * Mupen64plus - debugger.c *
3 * Mupen64Plus homepage: http://code.google.com/p/mupen64plus/ *
4 * Copyright (C) 2008 DarkJeztr *
5 * Copyright (C) 2002 davFr *
7 * This program is free software; you can redistribute it and/or modify *
8 * it under the terms of the GNU General Public License as published by *
9 * the Free Software Foundation; either version 2 of the License, or *
10 * (at your option) any later version. *
12 * This program is distributed in the hope that it will be useful, *
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
15 * GNU General Public License for more details. *
17 * You should have received a copy of the GNU General Public License *
18 * along with this program; if not, write to the *
19 * Free Software Foundation, Inc., *
20 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
21 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
25 #include "api/debugger.h"
27 #include "dbg_types.h"
29 #include "dbg_breakpoints.h"
30 #include "dbg_memory.h"
32 // State of the Emulation Thread:
33 // 0 -> pause, 2 -> run.
35 int g_DebuggerActive = 0; // whether the debugger is enabled or not
38 static SDL_cond *debugger_done_cond;
39 static SDL_mutex *mutex;
43 //]=-=-=-=-=-=-=-=-=-=-=[ Initialisation du Debugger ]=-=-=-=-=-=-=-=-=-=-=-=[
50 DebuggerCallback(DEBUG_UI_INIT, 0); /* call front-end to initialize user interface */
52 init_host_disassembler();
54 mutex = SDL_CreateMutex();
55 debugger_done_cond = SDL_CreateCond();
58 void destroy_debugger()
60 SDL_DestroyMutex(mutex);
62 SDL_DestroyCond(debugger_done_cond);
63 debugger_done_cond = NULL;
67 //]=-=-=-=-=-=-=-=-=-=-=-=-=[ Mise-a-Jour Debugger ]=-=-=-=-=-=-=-=-=-=-=-=-=[
69 void update_debugger(uint32 pc)
70 // Update debugger state and display.
71 // Should be called after each R4300 instruction
72 // Checks for breakpoint hits on PC
76 if(run!=0) {//check if we hit a breakpoint
77 bpt = check_breakpoints(pc);
81 if(BPT_CHECK_FLAG(g_Breakpoints[bpt], BPT_FLAG_LOG))
82 log_breakpoint(pc, BPT_FLAG_EXEC, 0);
87 DebuggerCallback(DEBUG_UI_UPDATE, pc); /* call front-end to notify user interface to update */
90 // Emulation thread is blocked until a button is clicked.
92 SDL_CondWait(debugger_done_cond, mutex);
101 SDL_CondSignal(debugger_done_cond);