25 |
* SUCH DAMAGE. |
* SUCH DAMAGE. |
26 |
* |
* |
27 |
* |
* |
28 |
* $Id: debugger_cmds.c,v 1.10 2006/12/30 13:30:56 debug Exp $ |
* $Id: debugger_cmds.c,v 1.12 2007/06/15 17:02:39 debug Exp $ |
29 |
* |
* |
30 |
* Debugger commands. Included from debugger.c. |
* Debugger commands. Included from debugger.c. |
31 |
*/ |
*/ |
62 |
} |
} |
63 |
|
|
64 |
if (strcmp(cmd_line, "show") == 0) { |
if (strcmp(cmd_line, "show") == 0) { |
65 |
if (m->n_breakpoints == 0) |
if (m->breakpoints.n == 0) |
66 |
printf("No breakpoints set.\n"); |
printf("No breakpoints set.\n"); |
67 |
for (i=0; i<m->n_breakpoints; i++) |
for (i=0; i<m->breakpoints.n; i++) |
68 |
show_breakpoint(m, i); |
show_breakpoint(m, i); |
69 |
return; |
return; |
70 |
} |
} |
72 |
if (strncmp(cmd_line, "delete ", 7) == 0) { |
if (strncmp(cmd_line, "delete ", 7) == 0) { |
73 |
int x = atoi(cmd_line + 7); |
int x = atoi(cmd_line + 7); |
74 |
|
|
75 |
if (m->n_breakpoints == 0) { |
if (m->breakpoints.n == 0) { |
76 |
printf("No breakpoints set.\n"); |
printf("No breakpoints set.\n"); |
77 |
return; |
return; |
78 |
} |
} |
79 |
if (x < 0 || x >= m->n_breakpoints) { |
if (x < 0 || x > m->breakpoints.n) { |
80 |
printf("Invalid breakpoint nr %i. Use 'breakpoint " |
printf("Invalid breakpoint nr %i. Use 'breakpoint " |
81 |
"show' to see the current breakpoints.\n", x); |
"show' to see the current breakpoints.\n", x); |
82 |
return; |
return; |
83 |
} |
} |
84 |
|
|
85 |
free(m->breakpoint_string[x]); |
free(m->breakpoints.string[x]); |
86 |
|
|
87 |
for (i=x; i<m->n_breakpoints-1; i++) { |
for (i=x; i<m->breakpoints.n-1; i++) { |
88 |
m->breakpoint_addr[i] = m->breakpoint_addr[i+1]; |
m->breakpoints.addr[i] = m->breakpoints.addr[i+1]; |
89 |
m->breakpoint_string[i] = m->breakpoint_string[i+1]; |
m->breakpoints.string[i] = m->breakpoints.string[i+1]; |
|
m->breakpoint_flags[i] = m->breakpoint_flags[i+1]; |
|
90 |
} |
} |
91 |
m->n_breakpoints --; |
m->breakpoints.n --; |
92 |
|
|
93 |
/* Clear translations: */ |
/* Clear translations: */ |
94 |
for (i=0; i<m->ncpus; i++) |
for (i=0; i<m->ncpus; i++) |
101 |
uint64_t tmp; |
uint64_t tmp; |
102 |
size_t breakpoint_buf_len; |
size_t breakpoint_buf_len; |
103 |
|
|
104 |
if (m->n_breakpoints >= MAX_BREAKPOINTS) { |
i = m->breakpoints.n; |
|
printf("Too many breakpoints. (You need to recompile" |
|
|
" gxemul to increase this. Max = %i.)\n", |
|
|
MAX_BREAKPOINTS); |
|
|
return; |
|
|
} |
|
|
|
|
|
i = m->n_breakpoints; |
|
105 |
|
|
106 |
res = debugger_parse_expression(m, cmd_line + 4, 0, &tmp); |
res = debugger_parse_expression(m, cmd_line + 4, 0, &tmp); |
107 |
if (!res) { |
if (!res) { |
109 |
return; |
return; |
110 |
} |
} |
111 |
|
|
112 |
|
CHECK_ALLOCATION(m->breakpoints.string = realloc( |
113 |
|
m->breakpoints.string, sizeof(char *) * |
114 |
|
(m->breakpoints.n + 1))); |
115 |
|
CHECK_ALLOCATION(m->breakpoints.addr = realloc( |
116 |
|
m->breakpoints.addr, sizeof(uint64_t) * |
117 |
|
(m->breakpoints.n + 1))); |
118 |
|
|
119 |
breakpoint_buf_len = strlen(cmd_line+4) + 1; |
breakpoint_buf_len = strlen(cmd_line+4) + 1; |
120 |
m->breakpoint_string[i] = malloc(breakpoint_buf_len); |
|
121 |
if (m->breakpoint_string[i] == NULL) { |
CHECK_ALLOCATION(m->breakpoints.string[i] = |
122 |
printf("out of memory in debugger_cmd_breakpoint()\n"); |
malloc(breakpoint_buf_len)); |
123 |
exit(1); |
strlcpy(m->breakpoints.string[i], cmd_line+4, |
|
} |
|
|
strlcpy(m->breakpoint_string[i], cmd_line+4, |
|
124 |
breakpoint_buf_len); |
breakpoint_buf_len); |
125 |
m->breakpoint_addr[i] = tmp; |
m->breakpoints.addr[i] = tmp; |
|
m->breakpoint_flags[i] = 0; |
|
126 |
|
|
127 |
m->n_breakpoints ++; |
m->breakpoints.n ++; |
128 |
show_breakpoint(m, i); |
show_breakpoint(m, i); |
129 |
|
|
130 |
/* Clear translations: */ |
/* Clear translations: */ |
254 |
|
|
255 |
if (cmd_line[0] != '\0') { |
if (cmd_line[0] != '\0') { |
256 |
uint64_t tmp; |
uint64_t tmp; |
257 |
char *tmps = strdup(cmd_line); |
char *tmps; |
258 |
|
|
259 |
|
CHECK_ALLOCATION(tmps = strdup(cmd_line)); |
260 |
|
|
261 |
/* addr: */ |
/* addr: */ |
262 |
p = strchr(tmps, ' '); |
p = strchr(tmps, ' '); |
1100 |
|
|
1101 |
if (cmd_line[0] != '\0') { |
if (cmd_line[0] != '\0') { |
1102 |
uint64_t tmp; |
uint64_t tmp; |
1103 |
char *tmps = strdup(cmd_line); |
char *tmps; |
1104 |
|
|
1105 |
|
CHECK_ALLOCATION(tmps = strdup(cmd_line)); |
1106 |
|
|
1107 |
/* addr: */ |
/* addr: */ |
1108 |
p = strchr(tmps, ' '); |
p = strchr(tmps, ' '); |