diff options
author | Maxime Chevalier-Boisvert <maxime.chevalierboisvert@shopify.com> | 2020-10-14 14:03:31 -0400 |
---|---|---|
committer | Alan Wu <XrXr@users.noreply.github.com> | 2021-10-20 18:19:25 -0400 |
commit | 6f81bd2c76c9eec7a95db92f552405cc68367e4d (patch) | |
tree | 45e90c82f82b6c38d59a3230662057eeadf91ccd /ujit_utils.c | |
parent | e5751768baeb7c1e0a48c466c98014667058d2c3 (diff) |
Added print_ptr() util function for debugging
Diffstat (limited to 'ujit_utils.c')
-rw-r--r-- | ujit_utils.c | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/ujit_utils.c b/ujit_utils.c index 0594503924..b7d121c9ef 100644 --- a/ujit_utils.c +++ b/ujit_utils.c @@ -1,5 +1,6 @@ #include <stdio.h> #include <string.h> +#include <assert.h> #include "ujit_utils.h" #include "ujit_asm.h" @@ -54,6 +55,24 @@ void print_int(codeblock_t* cb, x86opnd_t opnd) pop_regs(cb); } +static void print_ptr_cfun(int64_t val) +{ + printf("%llX\n", val); +} + +void print_ptr(codeblock_t* cb, x86opnd_t opnd) +{ + assert (opnd.num_bits == 64); + + push_regs(cb); + + mov(cb, RDI, opnd); + mov(cb, RAX, const_ptr_opnd((void*)&print_ptr_cfun)); + call(cb, RAX); + + pop_regs(cb); +} + static void print_str_cfun(const char* str) { printf("%s\n", str); |