Fix another round of suggestions.

Signed-off-by: Ricky Zhang <rickyzhang@gmail.com>
This commit is contained in:
Ricky Zhang 2017-09-04 14:21:16 -04:00
parent 597ff0666c
commit 93e800ffc7
No known key found for this signature in database
GPG Key ID: 681AFAEF6CDEDB4C
3 changed files with 50 additions and 50 deletions

View File

@ -203,7 +203,7 @@ static __inline__ void m68k_setpc (uaecptr newpc)
#endif #endif
#if ENABLE_MON #if ENABLE_MON
if(IS_BREAK_POINT(newpc)) { if (IS_BREAK_POINT(newpc)) {
printf("Stopped at break point address: %08lx. Last PC: %08lx\n", newpc, previous_pc); printf("Stopped at break point address: %08lx. Last PC: %08lx\n", newpc, previous_pc);
m68k_dumpstate(NULL); m68k_dumpstate(NULL);
char *arg[4] = {"mon", "-m", "-r", NULL}; char *arg[4] = {"mon", "-m", "-r", NULL};
@ -220,7 +220,7 @@ static __inline__ void m68k_incpc (uae_s32 delta)
regs.pc_p += (delta); regs.pc_p += (delta);
#if ENABLE_MON #if ENABLE_MON
uaecptr next_pc = m68k_getpc(); uaecptr next_pc = m68k_getpc();
if(IS_BREAK_POINT(next_pc)) { if (IS_BREAK_POINT(next_pc)) {
printf("Stopped at break point address: %08lx. Last PC: %08lx\n", next_pc, previous_pc); printf("Stopped at break point address: %08lx. Last PC: %08lx\n", next_pc, previous_pc);
m68k_dumpstate(NULL); m68k_dumpstate(NULL);
char *arg[4] = {"mon", "-m", "-r", NULL}; char *arg[4] = {"mon", "-m", "-r", NULL};

View File

@ -33,8 +33,8 @@
#endif #endif
static const char* STR_ACTIVE_BREAK_POINTS = "Active Break Points:\n"; static const char STR_ACTIVE_BREAK_POINTS[] = "Active Break Points:\n";
static const char* STR_DISABLED_BREAK_POINTS = "Disabled 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
@ -347,7 +347,7 @@ bool validate_index(uintptr *index_ptr, const BREAK_POINT_SET& break_point_set)
} }
if (*index_ptr > break_point_set.size()) { if (*index_ptr > break_point_set.size()) {
mon_error("Illegal Index Number!"); mon_error("Illegal index number!");
return false; return false;
} }
@ -418,8 +418,7 @@ void break_point_enable(void)
return; return;
if (0 == index) { if (0 == index) {
for (BREAK_POINT_SET::iterator it = disabled_break_points.begin(); it != disabled_break_points.end(); it++) active_break_points.insert(disabled_break_points.begin(), disabled_break_points.end());
active_break_points.insert(*it);
disabled_break_points.clear(); disabled_break_points.clear();
printf("Enabled all break points!\n"); printf("Enabled all break points!\n");
return; return;
@ -469,8 +468,6 @@ void break_point_info(void)
*/ */
void break_point_save(void) void break_point_save(void)
{ {
FILE *file;
if (mon_token == T_END) { if (mon_token == T_END) {
mon_error("Missing file name"); mon_error("Missing file name");
return; return;
@ -485,21 +482,23 @@ void break_point_save(void)
return; return;
} }
if (!(file = fopen(mon_string, "w"))) FILE *file;
if (!(file = fopen(mon_string, "w"))) {
mon_error("Unable to create file"); mon_error("Unable to create file");
else { return;
BREAK_POINT_SET::iterator it; }
fprintf(file, STR_ACTIVE_BREAK_POINTS); BREAK_POINT_SET::iterator it;
for (it = active_break_points.begin(); it != active_break_points.end(); it++)
fprintf(file, STR_ACTIVE_BREAK_POINTS);
for (it = active_break_points.begin(); it != active_break_points.end(); it++)
fprintf(file, "%x\n", *it);
fprintf(file, STR_DISABLED_BREAK_POINTS);
for (it = disabled_break_points.begin(); it != disabled_break_points.end(); it++)
fprintf(file, "%x\n", *it); fprintf(file, "%x\n", *it);
fprintf(file, STR_DISABLED_BREAK_POINTS); fclose(file);
for (it = disabled_break_points.begin(); it != disabled_break_points.end(); it++)
fprintf(file, "%x\n", *it);
fclose(file);
}
} }
@ -508,8 +507,6 @@ void break_point_save(void)
*/ */
void break_point_load(void) void break_point_load(void)
{ {
FILE *file;
if (mon_token == T_END) { if (mon_token == T_END) {
mon_error("Missing file name"); mon_error("Missing file name");
return; return;
@ -524,35 +521,38 @@ void break_point_load(void)
return; return;
} }
if (!(file = fopen(mon_string, "r"))) FILE *file;
if (!(file = fopen(mon_string, "r"))) {
mon_error("Unable to create file"); mon_error("Unable to create file");
else { 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!");
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);
} }
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);
} }

View File

@ -1,5 +1,5 @@
# What # What
suspend.bin is a MacBinary file which should be upacked and run in M68k Macintosh only. It runs emul_op `0x7138` and trigger BasiliskII into cxmon so that you can add break points there. suspend.bin is a MacBinary file which should be unpacked and run in M68k Macintosh only. It runs emul_op `0x7138` and trigger BasiliskII into cxmon so that you can add break points there.
# How # How
1. You must build Basilisk II `--with-mon=YES` options. 1. You must build Basilisk II `--with-mon=YES` options.