From fce78fcd46f6b84fc83f60f7c67b749784469d0b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ciro=20Santilli=20=E5=85=AD=E5=9B=9B=E4=BA=8B=E4=BB=B6=20?= =?UTF-8?q?=E6=B3=95=E8=BD=AE=E5=8A=9F?= Date: Wed, 8 May 2019 00:00:08 +0000 Subject: [PATCH] userland x86_64: ASSERT_EQ show actual and expected values --- README.adoc | 10 ++++++++-- userland/arch/x86_64/common_arch.h | 14 ++++++++++++++ 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/README.adoc b/README.adoc index 0c7a5be..e489a67 100644 --- a/README.adoc +++ b/README.adoc @@ -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: diff --git a/userland/arch/x86_64/common_arch.h b/userland/arch/x86_64/common_arch.h index d94e3d4..26e37e4 100644 --- a/userland/arch/x86_64/common_arch.h +++ b/userland/arch/x86_64/common_arch.h @@ -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) \