lib: drop (replace) debug_build()
PATCH v2 1/1 lib: drop (replace) 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 a new xen_build_info() helper, subsuming gcov_string at the same time (while replacing the stale CONFIG_GCOV used there) and also adding CONFIG_UBSAN indication.
---
v2: Introduce xen_build_info() including also gcov and ubsan info.
xen/arch/arm/traps.c +2 -2
@@ -175,14 +175,14 @@ static void print_xen_info(void) {char taint_str[TAINT_STRING_MAX_LEN ]; -printk ("----[ Xen-%d.%d%s %s debug=%c " gcov_string" %s ]----\n" , +printk ("----[ Xen-%d.%d%s %s %s %s ]----\n" ,xen_major_version (),xen_minor_version (),xen_extra_version (), #ifdef CONFIG_ARM_32"arm32" , #else"arm64" , #endif -debug_build () ?'y' :'n' ,print_tainted (taint_str)); +xen_build_info (),print_tainted (taint_str)); }#ifdef CONFIG_ARM_32
xen/arch/x86/x86_64/traps.c +2 -2
@@ -29,9 +29,9 @@ static void print_xen_info(void) {char taint_str[TAINT_STRING_MAX_LEN ]; -printk ("----[ Xen-%d.%d%s x86_64 debug=%c " gcov_string" %s ]----\n" , +printk ("----[ Xen-%d.%d%s x86_64 %s %s ]----\n" ,xen_major_version (),xen_minor_version (),xen_extra_version (), -debug_build () ?'y' :'n' ,print_tainted (taint_str)); +xen_build_info (),print_tainted (taint_str)); }enum context { CTXT_hypervisor, CTXT_pv_guest, CTXT_hvm_guest };
xen/common/version.c +24 -0
@@ -70,6 +70,30 @@ const char *xen_deny(void)return "<denied>" ; } +static const char build_info[] = + "debug=" +#ifdef CONFIG_DEBUG + "y" +#else + "n" +#endif +#ifdef CONFIG_COVERAGE +# ifdef __clang__ +" llvmcov=y" +# else + " gcov=y" +# endif +#endif +#ifdef CONFIG_UBSAN + " ubsan=y" +#endif +"" ; + +const char *xen_build_info (void ) +{ +return build_info; +} +static const void *build_id_p__read_mostly ;static unsigned int build_id_len__read_mostly ;
xen/drivers/char/console.c +3 -3
@@ -1002,10 +1002,10 @@ void __init console_init_preirq(void)spin_lock (&console_lock);__putstr (xen_banner ());spin_unlock (&console_lock); -printk ("Xen version %d.%d%s (%s@%s) (%s) debug=%c " gcov_string" %s\n" , +printk ("Xen version %d.%d%s (%s@%s) (%s) %s %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 (), +xen_build_info (),xen_compile_date ());printk ("Latest ChangeSet: %s\n" ,xen_changeset ());/* Locate and print the buildid, if applicable. */
xen/include/xen/lib.h +0 -8
@@ -48,21 +48,13 @@#define BUILD_BUG_ON (cond) ((void)BUILD_BUG_ON_ZERO(cond))#endif -#ifdef CONFIG_GCOV -#define gcov_string "gcov=y" -#else -#define gcov_string "" -#endif -#ifndef NDEBUG #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) ({ \
xen/include/xen/version.h +1 -0
@@ -16,6 +16,7 @@ const char *xen_extra_version(void);const char *xen_changeset (void );const char *xen_banner (void );const char *xen_deny (void ); +const char *xen_build_info (void );int xen_build_id (const void **p,unsigned int *len);#ifdef BUILD_ID
Quoted 7 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. Replace the few uses by a newxen_build_info()helper, subsuminggcov_stringat the same time (while replacing the staleCONFIG_GCOVused there) and also addingCONFIG_UBSANindication.Signed-off-by Jan Beulich <[email protected]>
Quoted 55 lines
---
v2: Introducexen_build_info()including also gcov and ubsan info.xen/arch/arm/traps.c +2
-2@@ -175,14 +175,14 @@ static void print_xen_info(void) {char taint_str[TAINT_STRING_MAX_LEN ]; -printk ("----[ Xen-%d.%d%s %s debug=%c " gcov_string" %s ]----\n" , +printk ("----[ Xen-%d.%d%s %s %s %s ]----\n" ,xen_major_version (),xen_minor_version (),xen_extra_version (), #ifdef CONFIG_ARM_32"arm32" , #else"arm64" , #endif -debug_build () ?'y' :'n' ,print_tainted (taint_str)); +xen_build_info (),print_tainted (taint_str)); }#ifdef CONFIG_ARM_32 xen/arch/x86/x86_64/traps.c +2
-2@@ -29,9 +29,9 @@ static void print_xen_info(void) {char taint_str[TAINT_STRING_MAX_LEN ]; -printk ("----[ Xen-%d.%d%s x86_64 debug=%c " gcov_string" %s ]----\n" , +printk ("----[ Xen-%d.%d%s x86_64 %s %s ]----\n" ,xen_major_version (),xen_minor_version (),xen_extra_version (), -debug_build () ?'y' :'n' ,print_tainted (taint_str)); +xen_build_info (),print_tainted (taint_str)); }enum context { CTXT_hypervisor, CTXT_pv_guest, CTXT_hvm_guest };xen/common/version.c +13
-0@@ -70,6 +70,30 @@ const char *xen_deny(void)return "<denied>" ; } +static const char build_info[] = + "debug=" +#ifdef CONFIG_DEBUG + "y" +#else + "n" +#endif +#ifdef CONFIG_COVERAGE +# ifdef __clang__ + " llvmcov=y" +# else +" gcov=y" +# endif
xen/common/version.c const char *xen_deny(void) · line 95
Quoted 10 lines
xen/common/version.c +10
-0+#endif +#ifdef CONFIG_UBSAN + " ubsan=y" +#endif +"" ; + +const char *xen_build_info (void ) +{ +return build_info; +}
... do we really need a function here?
Wouldn't an extern const char build_info[] do?
~Andrew
Quoted 54 lines
xen/common/version.c +1
-0+static const void *build_id_p__read_mostly ;static unsigned int build_id_len__read_mostly ;xen/drivers/char/console.c +3
-3@@ -1002,10 +1002,10 @@ void __init console_init_preirq(void)spin_lock (&console_lock);__putstr (xen_banner ());spin_unlock (&console_lock); -printk ("Xen version %d.%d%s (%s@%s) (%s) debug=%c " gcov_string" %s\n" , +printk ("Xen version %d.%d%s (%s@%s) (%s) %s %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 (), +xen_build_info (),xen_compile_date ());printk ("Latest ChangeSet: %s\n" ,xen_changeset ());/* Locate and print the buildid, if applicable. */ xen/include/xen/lib.h +0
-8@@ -48,21 +48,13 @@#define BUILD_BUG_ON (cond) ((void)BUILD_BUG_ON_ZERO(cond))#endif -#ifdef CONFIG_GCOV -#define gcov_string "gcov=y" -#else -#define gcov_string "" -#endif -#ifndef NDEBUG #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) ({ \xen/include/xen/version.h +1
-0@@ -16,6 +16,7 @@ const char *xen_extra_version(void);const char *xen_changeset (void );const char *xen_banner (void );const char *xen_deny (void ); +const char *xen_build_info (void );int xen_build_id (const void **p,unsigned int *len);#ifdef BUILD_ID
Quoted 10 lines · Andrew Cooper
Quoted 7 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. Replace the few uses by a newxen_build_info()helper, subsuminggcov_stringat the same time (while replacing the staleCONFIG_GCOVused there) and also addingCONFIG_UBSANindication.Signed-off-by Jan Beulich <[email protected]>Reviewed-by Andrew Cooper <[email protected]>,
Thanks.
Quoted 32 lines
Quoted 19 lines
xen/common/version.c +13
-0@@ -70,6 +70,30 @@ const char *xen_deny(void)return "<denied>" ; } +static const char build_info[] = + "debug=" +#ifdef CONFIG_DEBUG + "y" +#else + "n" +#endif +#ifdef CONFIG_COVERAGE +# ifdef __clang__ + " llvmcov=y" +# else +" gcov=y" +# endifxen/common/version.c const char *xen_deny(void) · line 95
Quoted 10 lines
xen/common/version.c +10
-0+#endif +#ifdef CONFIG_UBSAN + " ubsan=y" +#endif +"" ; + +const char *xen_build_info (void ) +{ +return build_info; +}... do we really need a function here?
Quoted 1 line
Wouldn't an extern const char build_info[] do?
It probably would, but I wanted things to remain consistent with the siblings, many of which also return string literals (or effectively plain numbers).
Jan
Quoted 43 lines · Jan Beulich
Quoted 9 lines · Andrew Cooper
Quoted 7 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. Replace the few uses by a newxen_build_info()helper, subsuminggcov_stringat the same time (while replacing the staleCONFIG_GCOVused there) and also addingCONFIG_UBSANindication.Signed-off-by Jan Beulich <[email protected]>Reviewed-by Andrew Cooper <[email protected]>,Thanks.
Quoted 31 lines
Quoted 19 lines
xen/common/version.c +13
-0@@ -70,6 +70,30 @@ const char *xen_deny(void)return "<denied>" ; } +static const char build_info[] = + "debug=" +#ifdef CONFIG_DEBUG + "y" +#else + "n" +#endif +#ifdef CONFIG_COVERAGE +# ifdef __clang__ + " llvmcov=y" +# else +" gcov=y" +# endifxen/common/version.c const char *xen_deny(void) · line 95
Quoted 10 lines
xen/common/version.c +10
-0+#endif +#ifdef CONFIG_UBSAN + " ubsan=y" +#endif +"" ; + +const char *xen_build_info (void ) +{ +return build_info; +}... do we really need a function here?
Quoted 4 lines
Quoted 1 line
Wouldn't an extern const char build_info[] do?
It probably would, but I wanted things to remain consistent with the siblings, many of which also return string literals (or effectively plain numbers).
The only reason they are still functions is because there was an argument over breaking the livepatch testing on older versions of Xen, and I got bored arguing.
I, however, don't consider this a valid reason to block improvements.
~Andrew
Hi Jan,
Quoted 7 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. Replace the few uses by a newxen_build_info()helper, subsuminggcov_stringat the same time (while replacing the staleCONFIG_GCOVused there) and also addingCONFIG_UBSANindication.Signed-off-by Jan Beulich <[email protected]>
For the Arm code:
Cheers,
Quoted 120 lines
---
v2: Introducexen_build_info()including also gcov and ubsan info.xen/arch/arm/traps.c +2
-2@@ -175,14 +175,14 @@ static void print_xen_info(void) {char taint_str[TAINT_STRING_MAX_LEN ]; -printk ("----[ Xen-%d.%d%s %s debug=%c " gcov_string" %s ]----\n" , +printk ("----[ Xen-%d.%d%s %s %s %s ]----\n" ,xen_major_version (),xen_minor_version (),xen_extra_version (), #ifdef CONFIG_ARM_32"arm32" , #else"arm64" , #endif -debug_build () ?'y' :'n' ,print_tainted (taint_str)); +xen_build_info (),print_tainted (taint_str)); }#ifdef CONFIG_ARM_32 xen/arch/x86/x86_64/traps.c +2
-2@@ -29,9 +29,9 @@ static void print_xen_info(void) {char taint_str[TAINT_STRING_MAX_LEN ]; -printk ("----[ Xen-%d.%d%s x86_64 debug=%c " gcov_string" %s ]----\n" , +printk ("----[ Xen-%d.%d%s x86_64 %s %s ]----\n" ,xen_major_version (),xen_minor_version (),xen_extra_version (), -debug_build () ?'y' :'n' ,print_tainted (taint_str)); +xen_build_info (),print_tainted (taint_str)); }enum context { CTXT_hypervisor, CTXT_pv_guest, CTXT_hvm_guest };xen/common/version.c +24
-0@@ -70,6 +70,30 @@ const char *xen_deny(void)return "<denied>" ; } +static const char build_info[] = + "debug=" +#ifdef CONFIG_DEBUG + "y" +#else + "n" +#endif +#ifdef CONFIG_COVERAGE +# ifdef __clang__ +" llvmcov=y" +# else + " gcov=y" +# endif +#endif +#ifdef CONFIG_UBSAN + " ubsan=y" +#endif +"" ; + +const char *xen_build_info (void ) +{ +return build_info; +} +static const void *build_id_p__read_mostly ;static unsigned int build_id_len__read_mostly ;xen/drivers/char/console.c +3
-3@@ -1002,10 +1002,10 @@ void __init console_init_preirq(void)spin_lock (&console_lock);__putstr (xen_banner ());spin_unlock (&console_lock); -printk ("Xen version %d.%d%s (%s@%s) (%s) debug=%c " gcov_string" %s\n" , +printk ("Xen version %d.%d%s (%s@%s) (%s) %s %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 (), +xen_build_info (),xen_compile_date ());printk ("Latest ChangeSet: %s\n" ,xen_changeset ());/* Locate and print the buildid, if applicable. */ xen/include/xen/lib.h +0
-8@@ -48,21 +48,13 @@#define BUILD_BUG_ON (cond) ((void)BUILD_BUG_ON_ZERO(cond))#endif -#ifdef CONFIG_GCOV -#define gcov_string "gcov=y" -#else -#define gcov_string "" -#endif -#ifndef NDEBUG #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) ({ \xen/include/xen/version.h +1
-0@@ -16,6 +16,7 @@ const char *xen_extra_version(void);const char *xen_changeset (void );const char *xen_banner (void );const char *xen_deny (void ); +const char *xen_build_info (void );int xen_build_id (const void **p,unsigned int *len);#ifdef BUILD_ID
Signature · 1 line
Julien Grall