fix: change x paddr to vaddr
This commit is contained in:
parent
4aa536e1ef
commit
2675a647b0
3 changed files with 18 additions and 19 deletions
|
@ -10,7 +10,7 @@ endif
|
||||||
WORK_DIR = $(shell pwd)
|
WORK_DIR = $(shell pwd)
|
||||||
BUILD_DIR = $(WORK_DIR)/build
|
BUILD_DIR = $(WORK_DIR)/build
|
||||||
|
|
||||||
INC_PATH := $(WORK_DIR)/include $(INC_PATH)
|
INC_PATH := $(WORK_DIR)/include $(BUILD_DIR)/include $(INC_PATH)
|
||||||
OBJ_DIR = $(BUILD_DIR)/obj-$(NAME)$(SO)
|
OBJ_DIR = $(BUILD_DIR)/obj-$(NAME)$(SO)
|
||||||
BINARY = $(BUILD_DIR)/$(NAME)$(SO)
|
BINARY = $(BUILD_DIR)/$(NAME)$(SO)
|
||||||
|
|
||||||
|
@ -42,13 +42,13 @@ $(OBJ_DIR)/%.o: %.cc
|
||||||
|
|
||||||
$(OBJ_DIR)/%.tag.c: %.y
|
$(OBJ_DIR)/%.tag.c: %.y
|
||||||
@echo + YACC $<
|
@echo + YACC $<
|
||||||
@mkdir -p $(dir $@)
|
@mkdir -p $(dir $@) $(BUILD_DIR)/include
|
||||||
@$(YACC) $(YFLAGS) --header=$(<:.y=.h) -o $@ $<
|
@$(YACC) $(YFLAGS) --header=$(BUILD_DIR)/include/$(notdir $(<:.y=.h)) -o $@ $<
|
||||||
|
|
||||||
$(OBJ_DIR)/%.yy.c: %.l $(OBJ_DIR)/%.tag.c
|
$(OBJ_DIR)/%.yy.c: %.l $(OBJ_DIR)/%.tag.c
|
||||||
@echo + LEX $<
|
@echo + LEX $<
|
||||||
@mkdir -p $(dir $@)
|
@mkdir -p $(dir $@) $(BUILD_DIR)/include
|
||||||
@$(LEX) $(LFLAGS) --header=$(<:.l=_lex.h) -o $@ $<
|
@$(LEX) $(LFLAGS) --header=$(BUILD_DIR)/include/$(notdir $(<:.l=_lex.h)) -o $@ $<
|
||||||
|
|
||||||
$(OBJ_DIR)/%.tag.o: $(OBJ_DIR)/%.tag.c
|
$(OBJ_DIR)/%.tag.o: $(OBJ_DIR)/%.tag.c
|
||||||
@echo + CC $<
|
@echo + CC $<
|
||||||
|
@ -67,7 +67,7 @@ $(OBJ_DIR)/%.yy.o: $(OBJ_DIR)/%.yy.c
|
||||||
|
|
||||||
# Some convenient rules
|
# Some convenient rules
|
||||||
|
|
||||||
.PHONY: app clean
|
.PHONY: app install clean
|
||||||
|
|
||||||
app: $(BINARY)
|
app: $(BINARY)
|
||||||
|
|
||||||
|
@ -75,5 +75,9 @@ $(BINARY):: $(OBJS) $(ARCHIVES)
|
||||||
@echo + LD $@
|
@echo + LD $@
|
||||||
@$(LD) -o $@ $(OBJS) $(LDFLAGS) $(ARCHIVES) $(LIBS)
|
@$(LD) -o $@ $(OBJS) $(LDFLAGS) $(ARCHIVES) $(LIBS)
|
||||||
|
|
||||||
|
install: $(BINARY)
|
||||||
|
@mkdir -p $(PREFIX)/bin
|
||||||
|
@cp $(BINARY) $(PREFIX)/bin/
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
-rm -rf $(BUILD_DIR)
|
-rm -rf $(BUILD_DIR)
|
||||||
|
|
|
@ -1,3 +1,2 @@
|
||||||
SRCS-y += src/monitor/sdb/addrexp.tag.c src/monitor/sdb/addrexp.yy.c
|
SRCS-y += src/monitor/sdb/addrexp.tag.c src/monitor/sdb/addrexp.yy.c
|
||||||
INC_PATH += src/monitor/sdb
|
|
||||||
LFLAGS += -DYY_NO_UNPUT -DYY_NO_INPUT
|
LFLAGS += -DYY_NO_UNPUT -DYY_NO_INPUT
|
||||||
|
|
|
@ -19,7 +19,7 @@
|
||||||
#include <cpu/cpu.h>
|
#include <cpu/cpu.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <isa.h>
|
#include <isa.h>
|
||||||
#include <memory/paddr.h>
|
#include <memory/vaddr.h>
|
||||||
#include <readline/history.h>
|
#include <readline/history.h>
|
||||||
#include <readline/readline.h>
|
#include <readline/readline.h>
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
@ -125,17 +125,13 @@ static word_t parse_uint(const char *arg, bool *success) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static paddr_t parse_expr(const char *arg, bool *success) {
|
static vaddr_t parse_expr(const char *arg, bool *success) {
|
||||||
if (arg == NULL) {
|
if (arg == NULL) {
|
||||||
puts("Invalid expr argument.");
|
puts("Invalid expr argument.");
|
||||||
*success = false;
|
*success = false;
|
||||||
return 0;
|
return 0;
|
||||||
} else {
|
} else {
|
||||||
// bool res = false;
|
vaddr_t addr;
|
||||||
// FIXME: We cannot use `parse_uint` here, it accept `-1234` as input
|
|
||||||
// paddr_t addr = parse_uint(arg, &res);
|
|
||||||
// *success = res;
|
|
||||||
paddr_t addr;
|
|
||||||
yy_scan_string(arg);
|
yy_scan_string(arg);
|
||||||
*success = !yyparse(&addr);
|
*success = !yyparse(&addr);
|
||||||
yylex_destroy();
|
yylex_destroy();
|
||||||
|
@ -193,15 +189,15 @@ static int cmd_x(char *args) {
|
||||||
goto wrong_usage;
|
goto wrong_usage;
|
||||||
// No deliminter here, just pass all the remain argument to `parse_expr()`
|
// No deliminter here, just pass all the remain argument to `parse_expr()`
|
||||||
arg = strtok(NULL, "");
|
arg = strtok(NULL, "");
|
||||||
word_t addr = parse_expr(arg, &res);
|
word_t start_addr = parse_expr(arg, &res);
|
||||||
if (!res)
|
if (!res)
|
||||||
goto wrong_usage;
|
goto wrong_usage;
|
||||||
addr = addr & ~(WORD_BYTES - 1);
|
start_addr = start_addr & ~(WORD_BYTES - 1);
|
||||||
for (paddr_t paddr = addr; paddr < addr + n; paddr += WORD_BYTES) {
|
for (vaddr_t vaddr = start_addr; vaddr < start_addr + n; vaddr += WORD_BYTES) {
|
||||||
word_t value = paddr_read(addr, WORD_BYTES);
|
word_t value = vaddr_read(vaddr, WORD_BYTES);
|
||||||
printf("\e[1;34m" FMT_PADDR "\e[0m"
|
printf("\e[1;34m" FMT_PADDR "\e[0m"
|
||||||
" " FMT_WORD "\n",
|
" " FMT_WORD "\n",
|
||||||
paddr, value);
|
vaddr, value);
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue