--- trunk/src/debugger/debugger_cmds.c 2007/10/08 16:20:48 31 +++ trunk/src/debugger/debugger_cmds.c 2007/10/08 16:20:58 32 @@ -25,7 +25,7 @@ * SUCH DAMAGE. * * - * $Id: debugger_cmds.c,v 1.5 2006/06/24 19:52:28 debug Exp $ + * $Id: debugger_cmds.c,v 1.8 2006/10/14 02:30:12 debug Exp $ * * Debugger commands. Included from debugger.c. */ @@ -111,7 +111,7 @@ i = m->n_breakpoints; - res = debugger_parse_name(m, cmd_line + 4, 0, &tmp); + res = debugger_parse_expression(m, cmd_line + 4, 0, &tmp); if (!res) { printf("Couldn't parse '%s'\n", cmd_line + 4); return; @@ -208,15 +208,15 @@ for (i=0; in_mmapped_devices; i++) { printf("%2i: %25s @ 0x%011"PRIx64", len = 0x%"PRIx64, - i, mem->dev_name[i], - (uint64_t) mem->dev_baseaddr[i], - (uint64_t) mem->dev_length[i]); + i, mem->devices[i].name, + (uint64_t) mem->devices[i].baseaddr, + (uint64_t) mem->devices[i].length); - if (mem->dev_flags[i]) { + if (mem->devices[i].flags) { printf(" ("); - if (mem->dev_flags[i] & DM_DYNTRANS_OK) + if (mem->devices[i].flags & DM_DYNTRANS_OK) printf("DYNTRANS R"); - if (mem->dev_flags[i] & DM_DYNTRANS_WRITE_OK) + if (mem->devices[i].flags &DM_DYNTRANS_WRITE_OK) printf("+W"); printf(")"); } @@ -264,10 +264,10 @@ p = strchr(tmps, ' '); if (p != NULL) *p = '\0'; - r = debugger_parse_name(m, tmps, 0, &tmp); + r = debugger_parse_expression(m, tmps, 0, &tmp); free(tmps); - if (r == NAME_PARSE_NOMATCH || r == NAME_PARSE_MULTIPLE) { + if (r == PARSE_NOMATCH || r == PARSE_MULTIPLE) { printf("Unparsable address: %s\n", cmd_line); return; } else { @@ -277,19 +277,21 @@ p = strchr(cmd_line, ' '); } + if (m->cpus == NULL) { + printf("No cpus (?)\n"); + return; + } + c = m->cpus[m->bootstrap_cpu]; + if (c == NULL) { + printf("m->cpus[m->bootstrap_cpu] = NULL\n"); + return; + } + mem = m->cpus[m->bootstrap_cpu]->mem; + addr_start = last_dump_addr; - if (addr_start == MAGIC_UNTOUCHED) { - uint64_t tmp; - int match_register = 0; - cpu_register_match(m, "pc", 0, &tmp, &match_register); - if (match_register) { - addr_start = tmp; - } else { - printf("No starting address.\n"); - return; - } - } + if (addr_start == MAGIC_UNTOUCHED) + addr_start = c->pc; addr_end = addr_start + 16 * 16; @@ -297,24 +299,13 @@ if (p != NULL) { while (*p == ' ' && *p) p++; - r = debugger_parse_name(m, p, 0, &addr_end); - if (r == NAME_PARSE_NOMATCH || r == NAME_PARSE_MULTIPLE) { + r = debugger_parse_expression(m, p, 0, &addr_end); + if (r == PARSE_NOMATCH || r == PARSE_MULTIPLE) { printf("Unparsable address: %s\n", cmd_line); return; } } - if (m->cpus == NULL) { - printf("No cpus (?)\n"); - return; - } - c = m->cpus[m->bootstrap_cpu]; - if (c == NULL) { - printf("m->cpus[m->bootstrap_cpu] = NULL\n"); - return; - } - mem = m->cpus[m->bootstrap_cpu]->mem; - addr = addr_start & ~0xf; ctrl_c = 0; @@ -399,57 +390,86 @@ /* * debugger_cmd_focus(): * - * Changes focus to specific machine (in a specific emulation). + * Changes focus to specific cpu, in a specific machine (in a specific + * emulation). */ static void debugger_cmd_focus(struct machine *m, char *cmd_line) { - int x = -1, y = -1; - char *p; + int x = -1, y = -1, z = -1; + char *p, *p2; if (!cmd_line[0]) { - printf("syntax: focus x[,y]\n"); - printf("where x and y are integers as reported by the" - " 'emuls' command\n"); + printf("syntax: focus x[,y,[,z]]\n"); + printf("where x (cpu id), y (machine number), and z (emul " + "number) are integers as\nreported by the 'emuls'" + " command.\n"); goto print_current_focus_and_return; } x = atoi(cmd_line); p = strchr(cmd_line, ','); if (p == cmd_line) { - printf("No machine number specified?\n"); - printf("syntax: focus x[,y]\n"); + printf("No cpu number specified?\n"); return; } - if (p != NULL) - y = atoi(p + 1); + if (p != NULL) { + y = atoi(p+1); + p2 = strchr(p+1, ','); + if (p2 == p+1) { + printf("No machine number specified?\n"); + return; + } + + if (p2 != NULL) + z = atoi(p2 + 1); + } - if (y != -1) { + if (z != -1) { /* Change emul: */ - if (y < 0 || y >= debugger_n_emuls) { - printf("Invalid emul number: %i\n", y); + if (z < 0 || z >= debugger_n_emuls) { + printf("Invalid emul number: %i\n", z); return; } - debugger_emul = debugger_emuls[y]; + debugger_cur_emul = z; + debugger_emul = debugger_emuls[z]; /* This is just in case the machine change below fails... */ debugger_machine = debugger_emul->machines[0]; } - /* Change machine: */ - if (x < 0 || x >= debugger_emul->n_machines) { - printf("Invalid machine number: %i\n", x); + if (y != -1) { + /* Change machine: */ + if (y < 0 || y >= debugger_emul->n_machines) { + printf("Invalid machine number: %i\n", y); + return; + } + + debugger_cur_machine = y; + debugger_machine = debugger_emul->machines[y]; + } + + /* Change cpu: */ + if (x < 0 || x >= debugger_machine->ncpus) { + printf("Invalid cpu number: %i\n", x); return; } - debugger_machine = debugger_emul->machines[x]; + debugger_cur_cpu = x; print_current_focus_and_return: - printf("current emul: \"%s\"\n", debugger_emul->name == NULL? - "(no name)" : debugger_emul->name); - printf("current machine: \"%s\"\n", debugger_machine->name == NULL? - "(no name)" : debugger_machine->name); + if (debugger_n_emuls > 1) + printf("current emul (%i): \"%s\"\n", + debugger_cur_emul, debugger_emul->name == NULL? + "(no name)" : debugger_emul->name); + + if (debugger_emul->n_machines > 1) + printf("current machine (%i): \"%s\"\n", + debugger_cur_machine, debugger_machine->name == NULL? + "(no name)" : debugger_machine->name); + + printf("current cpu (%i)\n", debugger_cur_cpu); } @@ -637,24 +657,24 @@ return; } - res = debugger_parse_name(m, cmd_line, 0, &tmp); + res = debugger_parse_expression(m, cmd_line, 0, &tmp); switch (res) { - case NAME_PARSE_NOMATCH: + case PARSE_NOMATCH: printf("No match.\n"); break; - case NAME_PARSE_MULTIPLE: + case PARSE_MULTIPLE: printf("Multiple matches. Try prefixing with %%, $, or @.\n"); break; - case NAME_PARSE_REGISTER: + case PARSE_SETTINGS: printf("%s = 0x%"PRIx64"\n", cmd_line, (uint64_t)tmp); break; - case NAME_PARSE_SYMBOL: + case PARSE_SYMBOL: if (m->cpus[0]->is_32bit) printf("%s = 0x%08"PRIx32"\n", cmd_line, (uint32_t)tmp); else printf("%s = 0x%016"PRIx64"\n", cmd_line,(uint64_t)tmp); break; - case NAME_PARSE_NUMBER: + case PARSE_NUMBER: printf("0x%"PRIx64"\n", (uint64_t) tmp); break; } @@ -722,36 +742,36 @@ } /* here: q is the address, p is the data. */ - res = debugger_parse_name(m, q, 0, &addr); + res = debugger_parse_expression(m, q, 0, &addr); switch (res) { - case NAME_PARSE_NOMATCH: + case PARSE_NOMATCH: printf("Couldn't parse the address.\n"); return; - case NAME_PARSE_MULTIPLE: + case PARSE_MULTIPLE: printf("Multiple matches for the address." " Try prefixing with %%, $, or @.\n"); return; - case NAME_PARSE_REGISTER: - case NAME_PARSE_SYMBOL: - case NAME_PARSE_NUMBER: + case PARSE_SETTINGS: + case PARSE_SYMBOL: + case PARSE_NUMBER: break; default: printf("INTERNAL ERROR in debugger.c.\n"); return; } - res = debugger_parse_name(m, p, 0, &data); + res = debugger_parse_expression(m, p, 0, &data); switch (res) { - case NAME_PARSE_NOMATCH: + case PARSE_NOMATCH: printf("Couldn't parse the data.\n"); return; - case NAME_PARSE_MULTIPLE: + case PARSE_MULTIPLE: printf("Multiple matches for the data value." " Try prefixing with %%, $, or @.\n"); return; - case NAME_PARSE_REGISTER: - case NAME_PARSE_SYMBOL: - case NAME_PARSE_NUMBER: + case PARSE_SETTINGS: + case PARSE_SYMBOL: + case PARSE_NUMBER: break; default: printf("INTERNAL ERROR in debugger.c.\n"); @@ -925,7 +945,7 @@ */ static void debugger_cmd_reg(struct machine *m, char *cmd_line) { - int i, cpuid = -1, coprocnr = -1; + int cpuid = debugger_cur_cpu, coprocnr = -1; int gprs, coprocs; char *p; @@ -951,9 +971,7 @@ gprs = (coprocnr == -1)? 1 : 0; coprocs = (coprocnr == -1)? 0x0 : (1 << coprocnr); - for (i=0; incpus; i++) - if (cpuid == -1 || i == cpuid) - cpu_register_dump(m, m->cpus[i], gprs, coprocs); + cpu_register_dump(m, m->cpus[cpuid], gprs, coprocs); } @@ -1090,10 +1108,10 @@ p = strchr(tmps, ' '); if (p != NULL) *p = '\0'; - r = debugger_parse_name(m, tmps, 0, &tmp); + r = debugger_parse_expression(m, tmps, 0, &tmp); free(tmps); - if (r == NAME_PARSE_NOMATCH || r == NAME_PARSE_MULTIPLE) { + if (r == PARSE_NOMATCH || r == PARSE_MULTIPLE) { printf("Unparsable address: %s\n", cmd_line); return; } else { @@ -1103,19 +1121,21 @@ p = strchr(cmd_line, ' '); } + if (m->cpus == NULL) { + printf("No cpus (?)\n"); + return; + } + c = m->cpus[m->bootstrap_cpu]; + if (c == NULL) { + printf("m->cpus[m->bootstrap_cpu] = NULL\n"); + return; + } + mem = m->cpus[m->bootstrap_cpu]->mem; + addr_start = last_unasm_addr; - if (addr_start == MAGIC_UNTOUCHED) { - uint64_t tmp; - int match_register = 0; - cpu_register_match(m, "pc", 0, &tmp, &match_register); - if (match_register) { - addr_start = tmp; - } else { - printf("No starting address.\n"); - return; - } - } + if (addr_start == MAGIC_UNTOUCHED) + addr_start = c->pc; addr_end = addr_start + 1000; @@ -1123,25 +1143,14 @@ if (p != NULL) { while (*p == ' ' && *p) p++; - r = debugger_parse_name(m, p, 0, &addr_end); - if (r == NAME_PARSE_NOMATCH || r == NAME_PARSE_MULTIPLE) { + r = debugger_parse_expression(m, p, 0, &addr_end); + if (r == PARSE_NOMATCH || r == PARSE_MULTIPLE) { printf("Unparsable address: %s\n", cmd_line); return; } } else lines_left = 20; - if (m->cpus == NULL) { - printf("No cpus (?)\n"); - return; - } - c = m->cpus[m->bootstrap_cpu]; - if (c == NULL) { - printf("m->cpus[m->bootstrap_cpu] = NULL\n"); - return; - } - mem = m->cpus[m->bootstrap_cpu]->mem; - addr = addr_start; ctrl_c = 0; @@ -1237,8 +1246,8 @@ { "emuls", "", 0, debugger_cmd_emuls, "print a summary of all current emuls" }, - { "focus", "x[,y]", 0, debugger_cmd_focus, - "changes focus to machine x (in emul y)" }, + { "focus", "x[,y[,z]]", 0, debugger_cmd_focus, + "changes focus to cpu x, machine x, emul z" }, { "help", "", 0, debugger_cmd_help, "print this help message" }, @@ -1395,11 +1404,13 @@ curlines = 0; } - printf("\nIn generic assignments, x must be a register, and expr can be" - " a register, a\nnumeric value, or a symbol name (+ an optional " - "numeric offset). In case there\nare multiple matches (i.e. a " - "symbol that has the same name as a register), you\nmay add a " - "prefix character as a hint: '%%' for registers, '@' for symbols," - " and\n'$' for numeric values. Use 0x for hexadecimal values.\n"); + printf("\nIn generic assignments, x must be a register or other " + "writable settings\nvariable, and expr can contain registers/" + "settings, numeric values, or symbol\nnames, in combination with" + " parenthesis and + - * / %% ^ | operators.\nIn case there are" + " multiple matches (i.e. a symbol that has the same name as a\n" + "register), you may add a prefix character as a hint: '#' for" + " registers, '@'\nfor symbols, and '$' for numeric values. Use" + " 0x for hexadecimal values.\n"); }