From 7ea9e4442b880afa35bf4006c2b0c7f18632202b Mon Sep 17 00:00:00 2001 From: Folkert van Heusden Date: Sun, 6 Apr 2025 19:40:07 +0200 Subject: [PATCH] keep track of memory writes --- CMakeLists.txt | 1 + PDP11/pdp11_cpu.c | 24 ++++++++++++++++++++++++ PDP11/test.c | 19 ++++++++++++++++--- 3 files changed, 41 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 120da396..1e0b1894 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -94,6 +94,7 @@ if (NOT CMAKE_CONFIGURATION_TYPES) message(STATUS "CMAKE_BUILD_TYPE is ${CMAKE_BUILD_TYPE}") endif (NOT CMAKE_BUILD_TYPE) endif () +set(CMAKE_BUILD_TYPE "RelWithDebInfo") # SIMH_SYSTEM_ID: Roughly analogous to the autoconf system triple. Used (almost exclusively) # as part of the dependencies' top-level directory name. diff --git a/PDP11/pdp11_cpu.c b/PDP11/pdp11_cpu.c index 54669379..b30e82df 100644 --- a/PDP11/pdp11_cpu.c +++ b/PDP11/pdp11_cpu.c @@ -279,6 +279,17 @@ typedef struct { /* Global state */ +struct __mem_writes { + int32_t addr; + uint16_t data; +} *mem_writes; +int n_mem_writes = 0; + +void init_mem_writes() +{ + mem_writes = (struct __mem_writes *)malloc(sizeof(struct __mem_writes) * 256); +} + uint16 *M = NULL; /* memory */ int32 REGFILE[6][2] = { {0} }; /* R0-R5, two sets */ int32 STACKFILE[4] = { 0 }; /* SP, four modes */ @@ -2780,6 +2791,7 @@ if ((va & 1) && CPUT (HAS_ODD)) { /* odd address? */ ABORT (TRAP_ODD); } pa = relocW (va); /* relocate */ + if (BPT_SUMM_WR && (sim_brk_test (va & 0177777, BPT_WRVIR) || sim_brk_test (pa, BPT_WRPHY))) /* write breakpoint? */ @@ -2818,9 +2830,21 @@ if (BPT_SUMM_WR && PWriteW (data, pa); } +void reset_mem_writes() +{ + n_mem_writes = 0; +} + void PWriteW (int32 data, int32 pa) { if (ADDR_IS_MEM (pa)) { /* memory address? */ + + if (data > 0xffff) + printf("FAIL %x\n", data); + mem_writes[n_mem_writes].addr = pa; + mem_writes[n_mem_writes].data = data; + n_mem_writes++; + WrMemW (pa, data); return; } diff --git a/PDP11/test.c b/PDP11/test.c index f36c84f5..c0d483a5 100644 --- a/PDP11/test.c +++ b/PDP11/test.c @@ -21,6 +21,15 @@ extern DEVICE cpu_dev; extern int32 STACKFILE[4]; extern int32 sim_interval; +struct __mem_writes { + int32_t addr; + uint16_t data; +}; +extern struct __mem_writes *mem_writes; +extern int n_mem_writes; +extern void reset_mem_writes(); +extern void init_mem_writes(); + struct mem_t { uint32_t addr; uint16_t value; @@ -123,12 +132,12 @@ json_t *generate_test(uint16_t instruction, int *const id, struct mem_t *mem, si json_t *memory_o = json_array(); - for(size_t i=0; i