userland x86_64: ASSERT_EQ show actual and expected values

This commit is contained in:
Ciro Santilli 六四事件 法轮功
2019-05-08 00:00:08 +00:00
parent 6d1a38e6b8
commit fce78fcd46
2 changed files with 22 additions and 2 deletions

View File

@@ -11588,10 +11588,16 @@ And then watch the assertion fail:
with error message:
....
error 1 at line 8
assert_eq_64 failed
val1 0x3
val2 0x4
error: asm_main returned 1 at line 8
....
and notice how we give the actual assembly line number where the failing assert was!
and notice how the error message gives both:
* the actual assembly source line number where the failing assert was
* the actual and expected values
Other setup sanity checks that you might want to look into include:

View File

@@ -3,6 +3,7 @@
#ifndef COMMON_ARCH_H
#define COMMON_ARCH_H
#if 0
#define ASSERT_EQ(reg, const) \
push %rax; \
push %rbx; \
@@ -13,6 +14,19 @@
pop %rax; \
ASSERT(je); \
;
#endif
#define ASSERT_EQ(reg, const) \
mov reg, %rdi; \
mov const, %rsi; \
ASSERT_EQ_DO(64); \
;
#define ASSERT_EQ_DO(bits) \
call assert_eq_ ## bits; \
cmp $0, %rax; \
ASSERT(je); \
;
# TODO
##define ASSERT_MEMCMP(s1, s2, n) \