> 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 18:43:12 up 1 day 4:19, 2 users, load average: 1.84, 1.38, 0.75
This commit is contained in:
parent
ace6b4a72b
commit
515e7be314
3 changed files with 68 additions and 52 deletions
|
@ -32,6 +32,7 @@ static int is_batch_mode = false;
|
|||
static int cmd_help(char *args);
|
||||
static int cmd_c(char *args);
|
||||
static int cmd_q(char *args);
|
||||
static int cmd_w(char *args);
|
||||
static int cmd_x(char *args);
|
||||
static int cmd_si(char *args);
|
||||
static int cmd_info(char *args);
|
||||
|
@ -55,6 +56,7 @@ static struct CommandTable {
|
|||
{"c", "Continue the execution of the program", cmd_c, NULL, 0},
|
||||
{"q", "Exit NEMU", cmd_q, NULL, 0},
|
||||
{"x", "Examine content of physical memory address", cmd_x, NULL, 0},
|
||||
{"w", "Break when expression is changed", cmd_w, NULL, 0},
|
||||
{"si", "Execute next [n] program line", cmd_si, NULL, 0},
|
||||
{"info", "Print information of registers or watchpoints", cmd_info,
|
||||
cmd_info_table, ARRLEN(cmd_info_table)},
|
||||
|
@ -181,6 +183,18 @@ static int cmd_info_w(char *args) {
|
|||
return 0;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
static int cmd_x(char *args) {
|
||||
char *arg = strtok(NULL, " ");
|
||||
bool res = false;
|
||||
|
|
|
@ -19,5 +19,7 @@
|
|||
#include <common.h>
|
||||
|
||||
word_t parse_expr(const char *arg, bool *success);
|
||||
int wp_add(char * expr);
|
||||
int wp_remove_by_number(int number);
|
||||
|
||||
#endif
|
||||
|
|
|
@ -27,8 +27,8 @@ typedef struct watchpoint {
|
|||
} WP;
|
||||
|
||||
static WP wp_pool[NR_WP] = {};
|
||||
static WP *head = NULL, *free_ = NULL;
|
||||
// static int wp_count = 0;
|
||||
static WP *head = NULL, *tail = NULL, *free_ = NULL;
|
||||
static int wp_count = 0;
|
||||
|
||||
void init_wp_pool() {
|
||||
int i;
|
||||
|
@ -41,62 +41,62 @@ void init_wp_pool() {
|
|||
free_ = wp_pool;
|
||||
}
|
||||
|
||||
// static WP *wp_new() {
|
||||
// if (free_ == NULL) {
|
||||
// Error("wp_pool: Watchpoint pool not initialized or is full.");
|
||||
// return NULL;
|
||||
// }
|
||||
static WP *wp_new() {
|
||||
if (free_ == NULL) {
|
||||
Error("wp_pool: Watchpoint pool not initialized or is full.");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
// WP *ret = free_;
|
||||
// free_ = free_->next;
|
||||
WP *ret = free_;
|
||||
free_ = free_->next;
|
||||
|
||||
// ret->NO = 0;
|
||||
// ret->next = NULL;
|
||||
// return ret;
|
||||
// }
|
||||
ret->NO = 0;
|
||||
ret->next = NULL;
|
||||
return ret;
|
||||
}
|
||||
|
||||
// static void wp_delete(WP *wp) {
|
||||
// assert(wp);
|
||||
// wp->next = free_;
|
||||
// free_ = wp;
|
||||
// }
|
||||
static void wp_delete(WP *wp) {
|
||||
assert(wp);
|
||||
wp->next = free_;
|
||||
free_ = wp;
|
||||
}
|
||||
|
||||
// static int wp_add(char * expr) {
|
||||
// WP *wp = wp_new();
|
||||
// if (wp == NULL) {
|
||||
// Error("watchpoint: Failed to add watchpoint, pool is full.");
|
||||
// return 1;
|
||||
// }
|
||||
int wp_add(char * expr) {
|
||||
WP *wp = wp_new();
|
||||
if (wp == NULL) {
|
||||
Error("watchpoint: Failed to add watchpoint, pool is full.");
|
||||
return 1;
|
||||
}
|
||||
|
||||
// wp->NO = wp_count++;
|
||||
// if (tail == NULL) {
|
||||
// head = wp;
|
||||
// tail = wp;
|
||||
// } else {
|
||||
// tail->next = wp;
|
||||
// tail = wp;
|
||||
// }
|
||||
// return 0;
|
||||
// }
|
||||
wp->NO = wp_count++;
|
||||
if (tail == NULL) {
|
||||
head = wp;
|
||||
tail = wp;
|
||||
} else {
|
||||
tail->next = wp;
|
||||
tail = wp;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
// static int wp_remove_by_number(int number) {
|
||||
// WP *target_prev;
|
||||
// // Find previous node of target number
|
||||
// for (target_prev = head; target_prev != NULL && target_prev->next->NO != number; target_prev = target_prev->next) ;
|
||||
// if (target_prev == NULL) {
|
||||
// Error("Watchpoint not found, you can check current watchpoints with `info w`");
|
||||
// return 1;
|
||||
// }
|
||||
// WP *target = target_prev->next;
|
||||
// target_prev->next = target->next;
|
||||
// if (target == head) {
|
||||
// head = target->next;
|
||||
// } else if (target == tail) {
|
||||
// tail = target_prev;
|
||||
// }
|
||||
// wp_delete(target);
|
||||
// return 0;
|
||||
// }
|
||||
int wp_remove_by_number(int number) {
|
||||
WP *target_prev;
|
||||
// Find previous node of target number
|
||||
for (target_prev = head; target_prev != NULL && target_prev->next->NO != number; target_prev = target_prev->next) ;
|
||||
if (target_prev == NULL) {
|
||||
Error("Watchpoint not found, you can check current watchpoints with `info w`");
|
||||
return 1;
|
||||
}
|
||||
WP *target = target_prev->next;
|
||||
target_prev->next = target->next;
|
||||
if (target == head) {
|
||||
head = target->next;
|
||||
} else if (target == tail) {
|
||||
tail = target_prev;
|
||||
}
|
||||
wp_delete(target);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static bool wp_check_change(WP* wp) {
|
||||
bool success = false;
|
||||
|
|
Loading…
Reference in a new issue