From 93e800ffc71d68f7ef8bfe8ee3e35651efd70c80 Mon Sep 17 00:00:00 2001 From: Ricky Zhang Date: Mon, 4 Sep 2017 14:21:16 -0400 Subject: [PATCH] Fix another round of suggestions. Signed-off-by: Ricky Zhang --- BasiliskII/src/uae_cpu/newcpu.h | 4 +- cxmon/src/mon_cmd.cpp | 94 ++++++++++++++++----------------- cxmon/utils/README.md | 2 +- 3 files changed, 50 insertions(+), 50 deletions(-) diff --git a/BasiliskII/src/uae_cpu/newcpu.h b/BasiliskII/src/uae_cpu/newcpu.h index 6ba6dd96..305b242e 100644 --- a/BasiliskII/src/uae_cpu/newcpu.h +++ b/BasiliskII/src/uae_cpu/newcpu.h @@ -203,7 +203,7 @@ static __inline__ void m68k_setpc (uaecptr newpc) #endif #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); m68k_dumpstate(NULL); char *arg[4] = {"mon", "-m", "-r", NULL}; @@ -220,7 +220,7 @@ static __inline__ void m68k_incpc (uae_s32 delta) regs.pc_p += (delta); #if ENABLE_MON 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); m68k_dumpstate(NULL); char *arg[4] = {"mon", "-m", "-r", NULL}; diff --git a/cxmon/src/mon_cmd.cpp b/cxmon/src/mon_cmd.cpp index fdc5e3c7..59391bb3 100644 --- a/cxmon/src/mon_cmd.cpp +++ b/cxmon/src/mon_cmd.cpp @@ -33,8 +33,8 @@ #endif -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_ACTIVE_BREAK_POINTS[] = "Active Break Points:\n"; +static const char STR_DISABLED_BREAK_POINTS[] = "Disabled Break Points:\n"; /* * 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()) { - mon_error("Illegal Index Number!"); + mon_error("Illegal index number!"); return false; } @@ -418,8 +418,7 @@ void break_point_enable(void) return; if (0 == index) { - for (BREAK_POINT_SET::iterator it = disabled_break_points.begin(); it != disabled_break_points.end(); it++) - active_break_points.insert(*it); + active_break_points.insert(disabled_break_points.begin(), disabled_break_points.end()); disabled_break_points.clear(); printf("Enabled all break points!\n"); return; @@ -469,8 +468,6 @@ void break_point_info(void) */ void break_point_save(void) { - FILE *file; - if (mon_token == T_END) { mon_error("Missing file name"); return; @@ -485,21 +482,23 @@ void break_point_save(void) return; } - if (!(file = fopen(mon_string, "w"))) + FILE *file; + if (!(file = fopen(mon_string, "w"))) { mon_error("Unable to create file"); - else { - BREAK_POINT_SET::iterator it; + return; + } - fprintf(file, STR_ACTIVE_BREAK_POINTS); - for (it = active_break_points.begin(); it != active_break_points.end(); it++) + BREAK_POINT_SET::iterator 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, STR_DISABLED_BREAK_POINTS); - for (it = disabled_break_points.begin(); it != disabled_break_points.end(); it++) - fprintf(file, "%x\n", *it); - - fclose(file); - } + fclose(file); } @@ -508,8 +507,6 @@ void break_point_save(void) */ void break_point_load(void) { - FILE *file; - if (mon_token == T_END) { mon_error("Missing file name"); return; @@ -524,35 +521,38 @@ void break_point_load(void) return; } - if (!(file = fopen(mon_string, "r"))) + FILE *file; + if (!(file = fopen(mon_string, "r"))) { mon_error("Unable to create file"); - else { - 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); + 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); } diff --git a/cxmon/utils/README.md b/cxmon/utils/README.md index bad64218..9345d805 100644 --- a/cxmon/utils/README.md +++ b/cxmon/utils/README.md @@ -1,5 +1,5 @@ # 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 1. You must build Basilisk II `--with-mon=YES` options.