comparison debug.c @ 2193:d00fb9c6a6a2

Fix a couple of debugger regressions introduced with changes to support blocks
author Michael Pavone <pavone@retrodev.com>
date Sun, 21 Aug 2022 16:41:22 -0700
parents d87a76afbd8a
children 0dcb9e4dee7f
comparison
equal deleted inserted replaced
2192:3247bec692a4 2193:d00fb9c6a6a2
1132 1132
1133 int debugging = 1; 1133 int debugging = 1;
1134 parsed_command cmds[2] = {0}; 1134 parsed_command cmds[2] = {0};
1135 int cur = 0; 1135 int cur = 0;
1136 uint8_t has_last = 0; 1136 uint8_t has_last = 0;
1137 if (root->last_cmd.def) {
1138 memcpy(cmds + 1, &root->last_cmd, sizeof(root->last_cmd));
1139 has_last = 1;
1140 }
1137 while(debugging) { 1141 while(debugging) {
1138 switch (read_parse_command(root, cmds + cur, 0)) 1142 switch (read_parse_command(root, cmds + cur, 0))
1139 { 1143 {
1140 case NORMAL: 1144 case NORMAL:
1141 debugging = run_command(root, cmds + cur); 1145 debugging = run_command(root, cmds + cur);
1146 cur = !cur;
1142 if (debugging && has_last) { 1147 if (debugging && has_last) {
1143 cur = !cur;
1144 free_parsed_command(cmds + cur); 1148 free_parsed_command(cmds + cur);
1145 memset(cmds + cur, 0, sizeof(cmds[cur])); 1149 memset(cmds + cur, 0, sizeof(cmds[cur]));
1146 } 1150 }
1151 has_last = 1;
1147 break; 1152 break;
1148 case EMPTY: 1153 case EMPTY:
1149 debugging = run_command(root, cmds + !cur); 1154 if (has_last) {
1150 break; 1155 debugging = run_command(root, cmds + !cur);
1151 } 1156 }
1152 } 1157 break;
1153 free_parsed_command(cmds); 1158 }
1154 free_parsed_command(cmds + 1); 1159 }
1160 if (has_last) {
1161 memcpy(&root->last_cmd, cmds + !cur, sizeof(root->last_cmd));
1162 } else {
1163 free_parsed_command(cmds + !cur);
1164 }
1165 free_parsed_command(cmds + cur);
1155 } 1166 }
1156 1167
1157 static uint8_t cmd_quit(debug_root *root, parsed_command *cmd) 1168 static uint8_t cmd_quit(debug_root *root, parsed_command *cmd)
1158 { 1169 {
1159 exit(0); 1170 exit(0);
1853 } 1864 }
1854 m68k_context *m68k = root->cpu_context; 1865 m68k_context *m68k = root->cpu_context;
1855 genesis_context *gen = m68k->system; 1866 genesis_context *gen = m68k->system;
1856 segacd_context *cd = gen->expansion; 1867 segacd_context *cd = gen->expansion;
1857 if (param && *param && !isspace(*param)) { 1868 if (param && *param && !isspace(*param)) {
1858 parsed_command cmd; 1869 parsed_command cmd = {0};
1859 debug_root *sub_root = find_m68k_root(cd->m68k); 1870 debug_root *sub_root = find_m68k_root(cd->m68k);
1860 if (!sub_root) { 1871 if (!sub_root) {
1861 fputs("Failed to get debug root for Sub CPU\n", stderr); 1872 fputs("Failed to get debug root for Sub CPU\n", stderr);
1862 return 1; 1873 return 1;
1863 } 1874 }
1882 } 1893 }
1883 m68k_context *m68k = root->cpu_context; 1894 m68k_context *m68k = root->cpu_context;
1884 segacd_context *cd = m68k->system; 1895 segacd_context *cd = m68k->system;
1885 1896
1886 if (param && *param && !isspace(*param)) { 1897 if (param && *param && !isspace(*param)) {
1887 parsed_command cmd; 1898 parsed_command cmd = {0};
1888 debug_root *main_root = find_m68k_root(cd->genesis->m68k); 1899 debug_root *main_root = find_m68k_root(cd->genesis->m68k);
1889 if (!main_root) { 1900 if (!main_root) {
1890 fputs("Failed to get debug root for Main CPU\n", stderr); 1901 fputs("Failed to get debug root for Main CPU\n", stderr);
1891 return 1; 1902 return 1;
1892 } 1903 }
1911 } 1922 }
1912 m68k_context *m68k = root->cpu_context; 1923 m68k_context *m68k = root->cpu_context;
1913 genesis_context *gen = m68k->system; 1924 genesis_context *gen = m68k->system;
1914 1925
1915 if (param && *param && !isspace(*param)) { 1926 if (param && *param && !isspace(*param)) {
1916 parsed_command cmd; 1927 parsed_command cmd = {0};
1917 debug_root *z80_root = find_z80_root(gen->z80); 1928 debug_root *z80_root = find_z80_root(gen->z80);
1918 if (!z80_root) { 1929 if (!z80_root) {
1919 fputs("Failed to get debug root for Z80\n", stderr); 1930 fputs("Failed to get debug root for Z80\n", stderr);
1920 return 1; 1931 return 1;
1921 } 1932 }
2424 ++param; 2435 ++param;
2425 } 2436 }
2426 genesis_context *gen = (genesis_context *)current_system; 2437 genesis_context *gen = (genesis_context *)current_system;
2427 2438
2428 if (param && *param && !isspace(*param)) { 2439 if (param && *param && !isspace(*param)) {
2429 parsed_command cmd; 2440 parsed_command cmd = {0};
2430 debug_root *m68k_root = find_m68k_root(gen->m68k); 2441 debug_root *m68k_root = find_m68k_root(gen->m68k);
2431 if (!m68k_root) { 2442 if (!m68k_root) {
2432 fputs("Failed to get debug root for M68K\n", stderr); 2443 fputs("Failed to get debug root for M68K\n", stderr);
2433 return 1; 2444 return 1;
2434 } 2445 }