From 70ddaed818ccd18e75a1be10b8d6408f4db21c8b Mon Sep 17 00:00:00 2001 From: tracer-ics2023 Date: Sat, 21 Sep 2024 14:14:36 +0800 Subject: [PATCH] =?UTF-8?q?>=20=20compile=20NEMU=20221220000=20=E5=BC=A0?= =?UTF-8?q?=E4=B8=89=20Linux=20zzy=205.15.146.1-microsoft-standard-WSL2=20?= =?UTF-8?q?#1=20SMP=20Thu=20Jan=2011=2004:09:03=20UTC=202024=20x86=5F64=20?= =?UTF-8?q?x86=5F64=20x86=5F64=20GNU/Linux=20=2014:14:35=20up=204=20days,?= =?UTF-8?q?=20=209:20,=20=201=20user,=20=20load=20average:=200.59,=200.47,?= =?UTF-8?q?=200.46?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- nemu/src/cpu/Kconfig | 11 +++++++++++ nemu/src/device/io/map.c | 8 ++++++++ 2 files changed, 19 insertions(+) diff --git a/nemu/src/cpu/Kconfig b/nemu/src/cpu/Kconfig index 57e94ab..cac6ceb 100644 --- a/nemu/src/cpu/Kconfig +++ b/nemu/src/cpu/Kconfig @@ -90,6 +90,17 @@ menuconfig DTRACE if DTRACE +config DTRACE_COND + string "Only trace device when the condition is true (you can use 'offset' variable)" + default "offset >= 0" + +config DTRACE_WRITE + bool "Enable device trace on write" + default y + +config DTRACE_READ + bool "Enable device trace on read" + default y endif # DTRACE diff --git a/nemu/src/device/io/map.c b/nemu/src/device/io/map.c index c3ab777..8a53450 100644 --- a/nemu/src/device/io/map.c +++ b/nemu/src/device/io/map.c @@ -58,6 +58,10 @@ word_t map_read(paddr_t addr, int len, IOMap *map) { paddr_t offset = addr - map->low; invoke_callback(map->callback, offset, len, false); // prepare data to read word_t ret = host_read(map->space + offset, len); +#ifdef CONFIG_DTRACE_READ + if (CONFIG_DTRACE_COND) log_write("device_read " FMT_WORD " from offset " FMT_PADDR " (%s)\n", + ret, offset, map->name); +#endif //word_t ret = *(word_t*)(map->space + offset); //printf("map_read: %p, %d\n", map->space + offset, ret); return ret; @@ -68,5 +72,9 @@ void map_write(paddr_t addr, int len, word_t data, IOMap *map) { check_bound(map, addr); paddr_t offset = addr - map->low; host_write(map->space + offset, len, data); +#ifdef CONFIG_DTRACE_WRITE + if (CONFIG_DTRACE_COND) log_write("device_write " FMT_WORD " from offset " FMT_PADDR " (%s)\n", + data, offset, map->name); +#endif invoke_callback(map->callback, offset, len, true); }