> compile NEMU

ysyx_22040000 李心杨
Linux calcite 6.1.75 #1-NixOS SMP PREEMPT_DYNAMIC Thu Jan 25 23:27:52 UTC 2024 x86_64 GNU/Linux
 19:05:19  up 1 day  4:41,  2 users,  load average: 1.09, 0.92, 0.82
This commit is contained in:
tracer-ysyx 2024-02-08 19:05:19 +08:00 committed by xinyangli
parent 2cb8584055
commit 5f3581ad47
2 changed files with 15 additions and 9 deletions

View file

@ -185,12 +185,6 @@ static int cmd_info_w(char *args) {
static int cmd_w(char *args) {
char *expr = strtok(NULL, " ");
bool success = false;
parse_expr(expr, &success);
if (!success) {
Error("Failed to parse given expression `%s`", expr);
return 0;
}
wp_add(expr);
return 0;
}

View file

@ -56,7 +56,7 @@ static WP *wp_new() {
}
static void wp_delete(WP *wp) {
assert(wp);
Assert(wp, "Failed to delete watchpoint from pool.");
wp->next = free_;
free_ = wp;
}
@ -65,7 +65,7 @@ int wp_add(char * expr) {
WP *wp = wp_new();
if (wp == NULL) {
Error("watchpoint: Failed to add watchpoint, pool is full.");
return 1;
goto failed_create;
}
wp->NO = wp_count++;
@ -76,15 +76,27 @@ int wp_add(char * expr) {
tail->next = wp;
tail = wp;
}
bool success = false;
wp->val = parse_expr(expr, &success);
if (!success) {
Error("Failed to parse given expression `%s`", expr);
goto failed_create;
}
int len = strlen(expr);
wp->expr = malloc((len + 1) * sizeof(char));
if (wp->expr == NULL) {
Error("Failed to allocate memory for expression");
return 1;
goto failed_create;
}
strncpy(wp->expr, expr, len + 1);
wp->expr[len] = '\0';
return 0;
failed_create:
wp_delete(wp);
return 1;
}
int wp_remove_by_number(int number) {