Skip to content

Commit

Permalink
Fix debugger macro on arm
Browse files Browse the repository at this point in the history
  • Loading branch information
tbodt committed Dec 13, 2017
1 parent 7dbd316 commit b003dc7
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 11 deletions.
15 changes: 15 additions & 0 deletions debug.h
Original file line number Diff line number Diff line change
Expand Up @@ -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__
Expand All @@ -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;
Expand All @@ -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 <signal.h>
#define debugger raise(SIGTRAP)
#endif
6 changes: 6 additions & 0 deletions emu/memory.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#include <stdio.h>
#include <errno.h>

#define DEFAULT_CHANNEL memory
#include "debug.h"
#include "kernel/errno.h"
#include "emu/memory.h"
Expand Down Expand Up @@ -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);
}
2 changes: 2 additions & 0 deletions emu/memory.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
5 changes: 0 additions & 5 deletions fs/real.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
6 changes: 0 additions & 6 deletions misc.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit b003dc7

Please sign in to comment.