From b003dc73229294eb2f6ee3ec0e85a70e2a245912 Mon Sep 17 00:00:00 2001 From: Theodore Dubois Date: Wed, 13 Dec 2017 12:37:48 -0800 Subject: [PATCH] Fix debugger macro on arm --- debug.h | 15 +++++++++++++++ emu/memory.c | 6 ++++++ emu/memory.h | 2 ++ fs/real.c | 5 ----- misc.h | 6 ------ 5 files changed, 23 insertions(+), 11 deletions(-) diff --git a/debug.h b/debug.h index 0d3ba5794d..3a156d16e8 100644 --- a/debug.h +++ b/debug.h @@ -24,6 +24,9 @@ #ifndef DEBUG_strace #define DEBUG_strace DEBUG_all #endif +#ifndef DEBUG_memory +#define DEBUG_memory DEBUG_all +#endif #if DEBUG_default #define TRACE_default TRACE__ @@ -45,6 +48,11 @@ #else #define TRACE_strace TRACE__NOP #endif +#if DEBUG_memory +#define TRACE_memory TRACE__ +#else +#define TRACE_memory TRACE__NOP +#endif #ifdef LOG_OVERRIDE extern int log_override; @@ -68,3 +76,10 @@ extern int log_override; #define STRACE(msg, ...) TRACE_(strace, msg, ##__VA_ARGS__) #define STRACELN(msg, ...) TRACELN_(strace, msg, ##__VA_ARGS__) + +#if defined(__i386__) || defined(__x86_64__) +#define debugger __asm__("int3") +#else +#include +#define debugger raise(SIGTRAP) +#endif diff --git a/emu/memory.c b/emu/memory.c index 158da88cef..3672659700 100644 --- a/emu/memory.c +++ b/emu/memory.c @@ -5,6 +5,7 @@ #include #include +#define DEFAULT_CHANNEL memory #include "debug.h" #include "kernel/errno.h" #include "emu/memory.h" @@ -209,3 +210,8 @@ void *tlb_handle_miss(struct mem *mem, addr_t addr, int type) { mem->dirty_page = TLB_PAGE(addr); return (void *) (tlb->data_minus_addr + addr); } + +size_t real_page_size; +__attribute__((constructor)) static void get_real_page_size() { + real_page_size = sysconf(_SC_PAGESIZE); +} diff --git a/emu/memory.h b/emu/memory.h index ce7f4e72ef..480c5a95d2 100644 --- a/emu/memory.h +++ b/emu/memory.h @@ -126,4 +126,6 @@ forceinline bool __mem_write(struct mem *mem, addr_t addr, const void *value, un } #define mem_write(mem, addr, value) __mem_write(mem, addr, (value), sizeof(*(value))) +extern size_t real_page_size; + #endif diff --git a/fs/real.c b/fs/real.c index 34da7acc5c..cc5ac53dc1 100644 --- a/fs/real.c +++ b/fs/real.c @@ -149,11 +149,6 @@ off_t realfs_lseek(struct fd *fd, off_t offset, int whence) { return res; } -static size_t real_page_size; -__attribute__((constructor)) static void get_real_page_size() { - real_page_size = sysconf(_SC_PAGESIZE); -} - int realfs_mmap(struct fd *fd, struct mem *mem, page_t start, pages_t pages, off_t offset, int prot, int flags) { if (pages == 0) return 0; diff --git a/misc.h b/misc.h index 7fe58a0b28..fddd142788 100644 --- a/misc.h +++ b/misc.h @@ -32,12 +32,6 @@ #define must_check __attribute__((warn_unused_result)) #define typecheck(type, x) ({type _x = x; x;}) -#if defined(__i386__) || defined(__x86_64__) -#define debugger __asm__("int3") -#elif defined(__arm__) -#define debugger __asm__("trap") -#endif - // types typedef int64_t sqword_t; typedef uint64_t qword_t;