Skip to contentSkip to conversation

lib: drop debug_build()

PATCH Superseded Jan Beulich 2 participants 4 messages Dec 21, 2020 – Dec 23, 2020

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 lib: drop debug_build()

Its expansion shouldn't be tied to NDEBUG - down the road we may want to allow enabling assertions independently of CONFIG_DEBUG. Replace the few uses by IS_ENABLED(CONFIG_DEBUG).

---
I wonder whether we shouldn't further abstract this into, say, a xen_build_info() helper, seeing that all use sites want "debug=[yn]". This could then also include gcov_string right away.

xen/arch/arm/traps.c +1 -1
@@ -182,7 +182,7 @@ static void print_xen_info(void)
 #else
            "arm64",
 #endif
-           debug_build() ? 'y' : 'n', print_tainted(taint_str));
+           IS_ENABLED(CONFIG_DEBUG) ? 'y' : 'n', print_tainted(taint_str));
 }
 
 #ifdef CONFIG_ARM_32
xen/arch/x86/x86_64/traps.c +1 -1
@@ -31,7 +31,7 @@ static void print_xen_info(void)
 
     printk("----[ Xen-%d.%d%s  x86_64  debug=%c " gcov_string "  %s ]----\n",
            xen_major_version(), xen_minor_version(), xen_extra_version(),
-           debug_build() ? 'y' : 'n', print_tainted(taint_str));
+           IS_ENABLED(CONFIG_DEBUG) ? 'y' : 'n', print_tainted(taint_str));
 }
 
 enum context { CTXT_hypervisor, CTXT_pv_guest, CTXT_hvm_guest };
xen/drivers/char/console.c +2 -2
@@ -1004,8 +1004,8 @@ void __init console_init_preirq(void)
     spin_unlock(&console_lock);
     printk("Xen version %d.%d%s (%s@%s) (%s) debug=%c " gcov_string " %s\n",
            xen_major_version(), xen_minor_version(), xen_extra_version(),
-           xen_compile_by(), xen_compile_domain(),
-           xen_compiler(), debug_build() ? 'y' : 'n', xen_compile_date());
+           xen_compile_by(), xen_compile_domain(), xen_compiler(),
+           IS_ENABLED(CONFIG_DEBUG) ? 'y' : 'n', xen_compile_date());
     printk("Latest ChangeSet: %s\n", xen_changeset());
 
     /* Locate and print the buildid, if applicable. */
xen/include/xen/lib.h +0 -2
@@ -52,11 +52,9 @@
 #define ASSERT(p) \
     do { if ( unlikely(!(p)) ) assert_failed(#p); } while (0)
 #define ASSERT_UNREACHABLE() assert_failed("unreachable")
-#define debug_build() 1
 #else
 #define ASSERT(p) do { if ( 0 && (p) ) {} } while (0)
 #define ASSERT_UNREACHABLE() do { } while (0)
-#define debug_build() 0
 #endif
 
 #define ABS(_x) ({                              \
#1 lore raw
Quoted 2 lines · Jan Beulich

Its expansion shouldn't be tied to NDEBUG - down the road we may want to allow enabling assertions independently of CONFIG_DEBUG.

I'm not sure I agree that we'll ever want to do this, but...

Quoted 1 line

Replace the few uses by IS_ENABLED(CONFIG_DEBUG).

... we should be aligning on CONFIG_DEBUG.

Quoted 6 lines

---
I wonder whether we shouldn't further abstract this into, say, a xen_build_info() helper, seeing that all use sites want "debug=[yn]". This could then also include gcov_string right away.

I think that would be a nicer way of doing it.  It should probably also have some trace of CONFIG_UBSAN in the resulting string.

~Andrew

#2 lore raw
Quoted 5 lines · Andrew Cooper
Quoted 2 lines · Jan Beulich

Its expansion shouldn't be tied to NDEBUG - down the road we may want to allow enabling assertions independently of CONFIG_DEBUG.

I'm not sure I agree that we'll ever want to do this, but...

Didn't you once say XenServer keeps (or kept) assertions enabled even in release builds? In any event, having such an option may e.g. help diagnose issues from mis-optimization (no matter whether because of mis-compilation or because of subtly broken sources).

Quoted 5 lines
Quoted 1 line

Replace the few uses by IS_ENABLED(CONFIG_DEBUG).

... we should be aligning on CONFIG_DEBUG.

Quoted 1 line
Quoted 8 lines
Quoted 5 lines

---
I wonder whether we shouldn't further abstract this into, say, a xen_build_info() helper, seeing that all use sites want "debug=[yn]". This could then also include gcov_string right away.

I think that would be a nicer way of doing it.  It should probably also have some trace of CONFIG_UBSAN in the resulting string.

Okay, will do.

Jan

#3 lore raw
Quoted 7 lines · Jan Beulich
Quoted 4 lines · Andrew Cooper
Quoted 2 lines · Jan Beulich

Its expansion shouldn't be tied to NDEBUG - down the road we may want to allow enabling assertions independently of CONFIG_DEBUG.

I'm not sure I agree that we'll ever want to do this, but...

Didn't you once say XenServer keeps (or kept) assertions enabled even in release builds?

The hypervisor RPM has two xen.gz's, a release and debug build from the same source.

So yes - a debug hypervisor is available in a normal XenServer release, but its not assertions in a release build of Xen.

~Andrew