Added print_ptr() util function for debugging
This commit is contained in:
parent
e5751768ba
commit
6f81bd2c76
@ -426,13 +426,6 @@ void gen_opt_minus(codeblock_t* cb, codeblock_t* ocb, ctx_t* ctx)
|
|||||||
jo_ptr(cb, side_exit);
|
jo_ptr(cb, side_exit);
|
||||||
add(cb, RAX, imm_opnd(1));
|
add(cb, RAX, imm_opnd(1));
|
||||||
|
|
||||||
/*
|
|
||||||
print_int(cb, arg0);
|
|
||||||
print_int(cb, arg1);
|
|
||||||
print_int(cb, RAX);
|
|
||||||
print_str(cb, "");
|
|
||||||
*/
|
|
||||||
|
|
||||||
// Push the output on the stack
|
// Push the output on the stack
|
||||||
x86opnd_t dst = ctx_stack_push(ctx, 1);
|
x86opnd_t dst = ctx_stack_push(ctx, 1);
|
||||||
mov(cb, dst, RAX);
|
mov(cb, dst, RAX);
|
||||||
|
19
ujit_utils.c
19
ujit_utils.c
@ -1,5 +1,6 @@
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
#include <assert.h>
|
||||||
#include "ujit_utils.h"
|
#include "ujit_utils.h"
|
||||||
#include "ujit_asm.h"
|
#include "ujit_asm.h"
|
||||||
|
|
||||||
@ -54,6 +55,24 @@ void print_int(codeblock_t* cb, x86opnd_t opnd)
|
|||||||
pop_regs(cb);
|
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)
|
static void print_str_cfun(const char* str)
|
||||||
{
|
{
|
||||||
printf("%s\n", str);
|
printf("%s\n", str);
|
||||||
|
@ -9,6 +9,7 @@
|
|||||||
void push_regs(codeblock_t* cb);
|
void push_regs(codeblock_t* cb);
|
||||||
void pop_regs(codeblock_t* cb);
|
void pop_regs(codeblock_t* cb);
|
||||||
void print_int(codeblock_t* cb, x86opnd_t opnd);
|
void print_int(codeblock_t* cb, x86opnd_t opnd);
|
||||||
|
void print_ptr(codeblock_t* cb, x86opnd_t opnd);
|
||||||
void print_str(codeblock_t* cb, const char* str);
|
void print_str(codeblock_t* cb, const char* str);
|
||||||
|
|
||||||
#endif // #ifndef UJIT_UTILS_H
|
#endif // #ifndef UJIT_UTILS_H
|
||||||
|
Loading…
x
Reference in New Issue
Block a user