> 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 17:38:54 up 3:14, 2 users, load average: 0.92, 0.78, 1.37
This commit is contained in:
parent
80ccc78e9b
commit
7a45094712
5 changed files with 36 additions and 12 deletions
|
@ -21,7 +21,15 @@
|
|||
#include <utils.h>
|
||||
|
||||
#define Log(format, ...) \
|
||||
_Log(ANSI_FMT("[%s:%d %s] " format, ANSI_FG_BLUE) "\n", \
|
||||
_Log(ANSI_FMT("%s:%d %s [INFO]" format, ANSI_FG_BLUE) "\n", \
|
||||
__FILE__, __LINE__, __func__, ## __VA_ARGS__)
|
||||
|
||||
#define Warning(format, ...) \
|
||||
_Log(ANSI_FMT("%s:%d %s [WARNING]" format, ANSI_FG_YELLOW) "\n", \
|
||||
__FILE__, __LINE__, __func__, ## __VA_ARGS__)
|
||||
|
||||
#define Error(format, ...) \
|
||||
_Log(ANSI_FMT("%s:%d %s [ERROR] " format, ANSI_FG_RED) "\n", \
|
||||
__FILE__, __LINE__, __func__, ## __VA_ARGS__)
|
||||
|
||||
#define Assert(cond, format, ...) \
|
||||
|
|
|
@ -42,10 +42,7 @@ expression
|
|||
$$ = $1 / $3;
|
||||
}
|
||||
| '-' number { $$ = -$2; }
|
||||
| '*' expression {
|
||||
// printf("deref: %u, value: %#x\n", $2, vaddr_read($2, WORD_BYTES));
|
||||
$$ = vaddr_read($2, WORD_BYTES);
|
||||
}
|
||||
| '*' expression { $$ = vaddr_read($2, WORD_BYTES); }
|
||||
| '(' expression ')' { $$ = $2; }
|
||||
|
||||
number
|
||||
|
|
|
@ -125,17 +125,17 @@ static word_t parse_uint(const char *arg, bool *success) {
|
|||
}
|
||||
}
|
||||
|
||||
static vaddr_t parse_expr(const char *arg, bool *success) {
|
||||
word_t parse_expr(const char *arg, bool *success) {
|
||||
if (arg == NULL) {
|
||||
puts("Invalid expr argument.");
|
||||
*success = false;
|
||||
return 0;
|
||||
} else {
|
||||
vaddr_t addr;
|
||||
word_t res;
|
||||
yy_scan_string(arg);
|
||||
*success = !yyparse(&addr);
|
||||
*success = !yyparse(&res);
|
||||
yylex_destroy();
|
||||
return addr;
|
||||
return res;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -18,4 +18,6 @@
|
|||
|
||||
#include <common.h>
|
||||
|
||||
word_t parse_expr(const char *arg, bool *success);
|
||||
|
||||
#endif
|
||||
|
|
|
@ -15,6 +15,7 @@
|
|||
|
||||
#include "common.h"
|
||||
#include "sdb.h"
|
||||
#include <stdio.h>
|
||||
|
||||
#define NR_WP 32
|
||||
|
||||
|
@ -42,7 +43,7 @@ void init_wp_pool() {
|
|||
|
||||
WP *wp_new() {
|
||||
if (free_ == NULL) {
|
||||
Log("wp_pool: Watchpoint pool not initialized or is full.");
|
||||
Error("wp_pool: Watchpoint pool not initialized or is full.");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
@ -63,7 +64,7 @@ void wp_delete(WP *wp) {
|
|||
int wp_add(char * expr) {
|
||||
WP *wp = wp_new();
|
||||
if (wp == NULL) {
|
||||
Log("watchpoint: Failed to add watchpoint, pool is full.");
|
||||
Error("watchpoint: Failed to add watchpoint, pool is full.");
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
@ -83,7 +84,7 @@ int wp_remove_by_number(int number) {
|
|||
// 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) {
|
||||
Log("Watchpoint not found, you can check current watchpoints with `info w`");
|
||||
Error("Watchpoint not found, you can check current watchpoints with `info w`");
|
||||
return 1;
|
||||
}
|
||||
WP *target = target_prev->next;
|
||||
|
@ -97,4 +98,20 @@ int wp_remove_by_number(int number) {
|
|||
return 0;
|
||||
}
|
||||
|
||||
// int wp_eval(WP* wp) {
|
||||
// bool success = false;
|
||||
// word_t result;
|
||||
|
||||
// result = parse_expr(wp->expr, &success);
|
||||
// if (!success) {
|
||||
|
||||
// }
|
||||
// }
|
||||
|
||||
/*
|
||||
Check if watchpoint value changed after execution
|
||||
*/
|
||||
// int wp_eval_all() {
|
||||
// }
|
||||
|
||||
/* TODO: Implement the functionality of watchpoint */
|
||||
|
|
Loading…
Reference in a new issue