mirror of
https://github.com/kanjitalk755/macemu.git
synced 2024-11-21 22:31:19 +00:00
Merge pull request #133 from rickyzhang82/pr-enhance-rom-break-point
Enhance ROM break point feature.
This commit is contained in:
commit
8d53921b20
@ -24,6 +24,7 @@
|
|||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <signal.h>
|
#include <signal.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
|
#include <sstream>
|
||||||
|
|
||||||
#ifdef USE_SDL
|
#ifdef USE_SDL
|
||||||
# include <SDL.h>
|
# include <SDL.h>
|
||||||
@ -371,7 +372,8 @@ static void usage(const char *prg_name)
|
|||||||
"\nUnix options:\n"
|
"\nUnix options:\n"
|
||||||
" --config FILE\n read/write configuration from/to FILE\n"
|
" --config FILE\n read/write configuration from/to FILE\n"
|
||||||
" --display STRING\n X display to use\n"
|
" --display STRING\n X display to use\n"
|
||||||
" --break ADDRESS\n set ROM breakpoint\n"
|
" --break ADDRESS\n set ROM breakpoint in hexadecimal\n"
|
||||||
|
" --loadbreak FILE\n load breakpoint from FILE\n"
|
||||||
" --rominfo\n dump ROM information\n", prg_name
|
" --rominfo\n dump ROM information\n", prg_name
|
||||||
);
|
);
|
||||||
LoadPrefs(NULL); // read the prefs file so PrefsPrintUsage() will print the correct default values
|
LoadPrefs(NULL); // read the prefs file so PrefsPrintUsage() will print the correct default values
|
||||||
@ -413,9 +415,17 @@ int main(int argc, char **argv)
|
|||||||
} else if (strcmp(argv[i], "--break") == 0) {
|
} else if (strcmp(argv[i], "--break") == 0) {
|
||||||
argv[i++] = NULL;
|
argv[i++] = NULL;
|
||||||
if (i < argc) {
|
if (i < argc) {
|
||||||
ROMBreakpoint = strtol(argv[i], NULL, 0);
|
std::stringstream ss;
|
||||||
|
ss << std::hex << argv[i];
|
||||||
|
ss >> ROMBreakpoint;
|
||||||
argv[i] = NULL;
|
argv[i] = NULL;
|
||||||
}
|
}
|
||||||
|
#ifdef ENABLE_MON
|
||||||
|
} else if (strcmp(argv[i], "--loadbreak") == 0) {
|
||||||
|
argv[i++] = NULL;
|
||||||
|
if (i < argc)
|
||||||
|
mon_load_break_point(argv[i]);
|
||||||
|
#endif
|
||||||
} else if (strcmp(argv[i], "--config") == 0) {
|
} else if (strcmp(argv[i], "--config") == 0) {
|
||||||
argv[i++] = NULL;
|
argv[i++] = NULL;
|
||||||
if (i < argc) {
|
if (i < argc) {
|
||||||
|
@ -32,6 +32,11 @@
|
|||||||
#include "video.h"
|
#include "video.h"
|
||||||
#include "extfs.h"
|
#include "extfs.h"
|
||||||
#include "prefs.h"
|
#include "prefs.h"
|
||||||
|
|
||||||
|
#if ENABLE_MON
|
||||||
|
#include "mon.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
#include "rom_patches.h"
|
#include "rom_patches.h"
|
||||||
|
|
||||||
#define DEBUG 0
|
#define DEBUG 0
|
||||||
@ -1678,8 +1683,14 @@ bool PatchROM(void)
|
|||||||
|
|
||||||
// Install breakpoint
|
// Install breakpoint
|
||||||
if (ROMBreakpoint) {
|
if (ROMBreakpoint) {
|
||||||
|
#if ENABLE_MON
|
||||||
|
mon_add_break_point(ROMBaseMac + ROMBreakpoint);
|
||||||
|
printf("ROM start address at %08lx\n", ROMBaseMac);
|
||||||
|
printf("Set ROM break point at %08lx\n", ROMBaseMac + ROMBreakpoint);
|
||||||
|
#else
|
||||||
uint16 *wp = (uint16 *)(ROMBaseHost + ROMBreakpoint);
|
uint16 *wp = (uint16 *)(ROMBaseHost + ROMBreakpoint);
|
||||||
*wp = htons(M68K_EMUL_BREAK);
|
*wp = htons(M68K_EMUL_BREAK);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
// Clear caches as we loaded and patched code
|
// Clear caches as we loaded and patched code
|
||||||
|
@ -26,6 +26,7 @@
|
|||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <map>
|
#include <map>
|
||||||
|
#include <sstream>
|
||||||
|
|
||||||
#if defined(HAVE_READLINE_H)
|
#if defined(HAVE_READLINE_H)
|
||||||
extern "C" {
|
extern "C" {
|
||||||
@ -66,7 +67,7 @@ static uint8 *mem;
|
|||||||
|
|
||||||
|
|
||||||
// Streams for input, output and error messages
|
// Streams for input, output and error messages
|
||||||
FILE *monin, *monout, *monerr;
|
FILE *monin, *monout, *monerr = NULL;
|
||||||
|
|
||||||
// Input line
|
// Input line
|
||||||
static char *input;
|
static char *input;
|
||||||
@ -153,7 +154,7 @@ void mon_add_command(const char *name, void (*func)(), const char *help_text)
|
|||||||
|
|
||||||
void mon_error(const char *s)
|
void mon_error(const char *s)
|
||||||
{
|
{
|
||||||
fprintf(monerr, "*** %s\n", s);
|
fprintf(monerr == NULL? stdout : monerr, "*** %s\n", s);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -1029,6 +1030,63 @@ void mon_change_dir()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Add break point
|
||||||
|
*/
|
||||||
|
|
||||||
|
void mon_add_break_point(uintptr addr)
|
||||||
|
{
|
||||||
|
BREAK_POINT_SET::iterator it = disabled_break_points.find(addr);
|
||||||
|
// Save break point
|
||||||
|
if (it == disabled_break_points.end()) {
|
||||||
|
active_break_points.insert(addr);
|
||||||
|
} else {
|
||||||
|
disabled_break_points.erase(it);
|
||||||
|
active_break_points.insert(addr);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Load break point from file
|
||||||
|
*/
|
||||||
|
void mon_load_break_point(const char* file_path)
|
||||||
|
{
|
||||||
|
FILE *file;
|
||||||
|
if (!(file = fopen(file_path, "r"))) {
|
||||||
|
mon_error("Unable to create file");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
char line_buff[1024];
|
||||||
|
bool is_disabled_break_points = false;
|
||||||
|
|
||||||
|
if (fgets(line_buff, sizeof(line_buff), file) == NULL ||
|
||||||
|
strcmp(line_buff, STR_ACTIVE_BREAK_POINTS) != 0) {
|
||||||
|
mon_error("Invalid break point file format!");
|
||||||
|
fclose(file);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
while (fgets(line_buff, sizeof(line_buff), file) != NULL) {
|
||||||
|
if (strcmp(line_buff, STR_DISABLED_BREAK_POINTS) == 0) {
|
||||||
|
is_disabled_break_points = true;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
uintptr address;
|
||||||
|
std::stringstream ss;
|
||||||
|
ss << std::hex << line_buff;
|
||||||
|
ss >> address;
|
||||||
|
if (is_disabled_break_points)
|
||||||
|
disabled_break_points.insert(address);
|
||||||
|
else
|
||||||
|
active_break_points.insert(address);
|
||||||
|
}
|
||||||
|
|
||||||
|
fclose(file);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Initialize mon
|
* Initialize mon
|
||||||
*/
|
*/
|
||||||
|
@ -33,6 +33,9 @@ void mon_init();
|
|||||||
void mon_exit();
|
void mon_exit();
|
||||||
void mon(int argc, char **argv);
|
void mon(int argc, char **argv);
|
||||||
|
|
||||||
|
// Break points prompt
|
||||||
|
const char STR_ACTIVE_BREAK_POINTS[] = "Active Break Points:\n";
|
||||||
|
const char STR_DISABLED_BREAK_POINTS[] = "Disabled Break Points:\n";
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Definitions for adding commands to mon
|
* Definitions for adding commands to mon
|
||||||
@ -104,5 +107,8 @@ extern void mon_write_word(uintptr adr, uint32 l);
|
|||||||
|
|
||||||
// Check if break point is set
|
// Check if break point is set
|
||||||
#define IS_BREAK_POINT(address) (active_break_points.find(address) != active_break_points.end())
|
#define IS_BREAK_POINT(address) (active_break_points.find(address) != active_break_points.end())
|
||||||
|
// Add break point
|
||||||
|
extern void mon_add_break_point(uintptr addr);
|
||||||
|
extern void mon_load_break_point(const char* file_path);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/*
|
/*
|
||||||
* mon_cmd.cpp - cxmon standard commands
|
* mon_cmd.cpp - cxmon standard commands
|
||||||
*
|
*
|
||||||
* cxmon (C) 1997-2004 Christian Bauer, Marc Hellwig
|
* cxmon (C) 1997-2004 Christian Bauer, Marc Hellwig
|
||||||
@ -22,7 +22,6 @@
|
|||||||
|
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
#include <sstream>
|
|
||||||
|
|
||||||
#include "mon.h"
|
#include "mon.h"
|
||||||
#include "mon_cmd.h"
|
#include "mon_cmd.h"
|
||||||
@ -33,9 +32,6 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
static const char STR_ACTIVE_BREAK_POINTS[] = "Active Break Points:\n";
|
|
||||||
static const char STR_DISABLED_BREAK_POINTS[] = "Disabled Break Points:\n";
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* range_args = [expression] [[COMMA] expression] END
|
* range_args = [expression] [[COMMA] expression] END
|
||||||
*
|
*
|
||||||
@ -323,14 +319,7 @@ void break_point_add(void)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
BREAK_POINT_SET::iterator it;
|
mon_add_break_point(address);
|
||||||
// Save break point
|
|
||||||
if ((it = disabled_break_points.find(address)) == disabled_break_points.end())
|
|
||||||
active_break_points.insert(address);
|
|
||||||
else {
|
|
||||||
disabled_break_points.erase(it);
|
|
||||||
active_break_points.insert(address);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -521,38 +510,8 @@ void break_point_load(void)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
FILE *file;
|
// load from file
|
||||||
if (!(file = fopen(mon_string, "r"))) {
|
mon_load_break_point(mon_string);
|
||||||
mon_error("Unable to create file");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
char line_buff[1024];
|
|
||||||
bool is_disabled_break_points = false;
|
|
||||||
|
|
||||||
if (fgets(line_buff, sizeof(line_buff), file) == NULL ||
|
|
||||||
strcmp(line_buff, STR_ACTIVE_BREAK_POINTS) != 0) {
|
|
||||||
mon_error("Invalid break point file format!");
|
|
||||||
fclose(file);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
while (fgets(line_buff, sizeof(line_buff), file) != NULL) {
|
|
||||||
if (strcmp(line_buff, STR_DISABLED_BREAK_POINTS) == 0) {
|
|
||||||
is_disabled_break_points = true;
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
uintptr address;
|
|
||||||
std::stringstream ss;
|
|
||||||
ss << std::hex << line_buff;
|
|
||||||
ss >> address;
|
|
||||||
if (is_disabled_break_points)
|
|
||||||
disabled_break_points.insert(address);
|
|
||||||
else
|
|
||||||
active_break_points.insert(address);
|
|
||||||
}
|
|
||||||
|
|
||||||
fclose(file);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user