Added print_ptr() util function for debugging

This commit is contained in:
Maxime Chevalier-Boisvert 2020-10-14 14:03:31 -04:00 committed by Alan Wu
parent e5751768ba
commit 6f81bd2c76
3 changed files with 20 additions and 7 deletions

View file

@ -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);