From edbbabb286f9b3a9280e605132dbea851d33f09c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mateusz=20Grzeli=C5=84ski?= Date: Wed, 19 Aug 2020 09:59:18 +0200 Subject: Remove special logic triggering special behaviour from debug flags Special debug logic can be triggered only from command line --- release/scripts/startup/bl_ui/space_userpref.py | 2 - source/blender/blenkernel/BKE_global.h | 13 ++---- source/blender/blenkernel/intern/blender.c | 53 ---------------------- .../blender/editors/space_userpref/userpref_ops.c | 9 +--- source/blender/makesdna/DNA_userdef_types.h | 1 - source/blender/makesrna/intern/rna_userdef.c | 17 ++++--- source/creator/creator_args.c | 45 +++++++++++++----- 7 files changed, 45 insertions(+), 95 deletions(-) diff --git a/release/scripts/startup/bl_ui/space_userpref.py b/release/scripts/startup/bl_ui/space_userpref.py index cf99387c435..992c300cfba 100644 --- a/release/scripts/startup/bl_ui/space_userpref.py +++ b/release/scripts/startup/bl_ui/space_userpref.py @@ -649,10 +649,8 @@ class USERPREF_PT_system_logging(SystemPanel, CenterAlignMixIn, Panel): def draw_header_preset(self, _context): layout = self.layout - # TODO (grzelins) this is mocap: layout.operator("preferences.log_preferences_save", icon='IMPORT', text="Save") layout.operator("preferences.log_preferences_reset_default", icon='IMPORT', text="Restore Default") - layout.operator("preferences.studiolight_install", icon='PRESET', text="") layout.separator() def draw_centered(self, context, layout): diff --git a/source/blender/blenkernel/BKE_global.h b/source/blender/blenkernel/BKE_global.h index aee57832536..9de4d249340 100644 --- a/source/blender/blenkernel/BKE_global.h +++ b/source/blender/blenkernel/BKE_global.h @@ -87,8 +87,8 @@ typedef struct Global { int f; struct { - /** Verbosity for third party loggers */ - int level; + /** Logging vars (different loggers may use). */ + int level; /* currently unused */ /** FILE handle or use stderr (we own this so close when done). */ void *file; /* currently unused */ } log; @@ -157,19 +157,12 @@ enum { G_DEBUG_XR_TIME = (1 << 22), /* XR/OpenXR timing messages */ G_DEBUG_GHOST = (1 << 23), /* Debug GHOST module. */ - G_DEBUG_LIBMV = (1 << 24), - G_DEBUG_CYCLES = (1 << 25), - G_DEBUG_FPE = (1 << 26), /* floating point exceptions */ - G_DEBUG_MEMORY = (1 << 27), }; -void G_debug_enable(int flags); -void G_verbose_set(int value); - #define G_DEBUG_ALL \ (G_DEBUG | G_DEBUG_FFMPEG | G_DEBUG_PYTHON | G_DEBUG_EVENTS | G_DEBUG_WM | G_DEBUG_JOBS | \ G_DEBUG_FREESTYLE | G_DEBUG_DEPSGRAPH | G_DEBUG_GPU_MEM | G_DEBUG_IO | G_DEBUG_GPU_SHADERS | \ - G_DEBUG_GHOST | G_DEBUG_LIBMV | G_DEBUG_CYCLES | G_DEBUG_FPE | G_DEBUG_MEMORY) + G_DEBUG_GHOST) /** #Global.fileflags */ enum { diff --git a/source/blender/blenkernel/intern/blender.c b/source/blender/blenkernel/intern/blender.c index d0c92ff1fbf..5443b3c1f31 100644 --- a/source/blender/blenkernel/intern/blender.c +++ b/source/blender/blenkernel/intern/blender.c @@ -23,7 +23,6 @@ * Application level startup/shutdown functionality. */ -#include #include #include #include @@ -62,18 +61,8 @@ #include "RE_pipeline.h" #include "RE_render_ext.h" -#include "../../../creator/creator_intern.h" -#include "../../editors/space_userpref/userpref_intern.h" #include "BLF_api.h" -#ifdef WITH_LIBMV -# include "libmv-capi.h" -#endif - -#ifdef WITH_CYCLES_LOGGING -# include "CCL_api.h" -#endif - Global G; UserDef U; @@ -161,48 +150,6 @@ void BKE_blender_globals_init(void) #endif } -void G_debug_enable(int flags) -{ - if (flags & G_DEBUG) { - MEM_set_memory_debug(); -#ifdef DEBUG - BLI_mempool_set_memory_debug(); -#endif - } - -#ifdef WITH_LIBMV - if (flags & G_DEBUG_LIBMV) { - libmv_startDebugLogging(); - } -#endif -#ifdef WITH_CYCLES_LOGGING - if (flags & G_DEBUG_CYCLES) { - CCL_start_debug_logging(); - } -#endif - if (flags & G_DEBUG_FPE) { - // TODO (grzelins) causes linking error on windows - // main_signal_setup_fpe(); - } - - if (flags & G_DEBUG_MEMORY) { - MEM_set_memory_debug(); - } - G.debug |= flags; -} - -void G_verbose_set(int level) -{ -#ifdef WITH_LIBMV - libmv_setLoggingVerbosity(level); -#elif defined(WITH_CYCLES_LOGGING) - CCL_logging_verbosity_set(level); -#else - (void)level; -#endif - G.log.level = level; -} - void BKE_blender_globals_clear(void) { BKE_main_free(G_MAIN); /* free all lib data */ diff --git a/source/blender/editors/space_userpref/userpref_ops.c b/source/blender/editors/space_userpref/userpref_ops.c index 0b2bda1abd3..e58f40ebc90 100644 --- a/source/blender/editors/space_userpref/userpref_ops.c +++ b/source/blender/editors/space_userpref/userpref_ops.c @@ -170,26 +170,19 @@ void USERPREF_restore_global_log_settings(bool use_command_line_mask) } if (!(mask & ARGS_LOG_FILE)) { CLG_use_stdout_set(U.log_use_stdout); + CLG_file_output_path_set(U.log_output_file_path); } /* if (!(mask & ARGS_LOG_DISABLE_ALWAYS_SHOW_WARNINGS)) { CLG_always_show_warnings_set(U.log_always_show_warnings); } */ - if (!(mask & ARGS_VERBOSE)) { - CLG_file_output_path_set(U.log_output_file_path); - } if (!(mask & ARGS_DEBUG)) { - /* TODO (grzelins) we need proper setter, not only enabler */ - G_debug_enable(U.debug_flags); G.debug = U.debug_flags; } if (!(mask & ARGS_DEBUG_VALUE)) { G.debug_value = U.debug_value; } - if (!(mask & ARGS_VERBOSE)) { - G_verbose_set(U.verbose); - } } void USERPREF_restore_factory_log_settings() diff --git a/source/blender/makesdna/DNA_userdef_types.h b/source/blender/makesdna/DNA_userdef_types.h index 9b6828d1be8..f36189eab71 100644 --- a/source/blender/makesdna/DNA_userdef_types.h +++ b/source/blender/makesdna/DNA_userdef_types.h @@ -599,7 +599,6 @@ typedef enum UserDef_RuntimeCommandLineArgs { ARGS_LOG_SHOW_BASENAME = (1 << 5), ARGS_LOG_SHOW_TIMESTAMP = (1 << 6), ARGS_LOG_FILE = (1 << 7), - ARGS_VERBOSE = (1 << 8), // ARGS_LOG_DISABLE_ALWAYS_SHOW_WARNINGS = (1 << 6), // needed? } UserDef_RuntimeCommandLineArgs; diff --git a/source/blender/makesrna/intern/rna_userdef.c b/source/blender/makesrna/intern/rna_userdef.c index 9daa4bbc2c3..a4cbcf655f9 100644 --- a/source/blender/makesrna/intern/rna_userdef.c +++ b/source/blender/makesrna/intern/rna_userdef.c @@ -1178,7 +1178,12 @@ static int rna_verbose_get(PointerRNA *UNUSED(ptr)) static void rna_verbose_set(PointerRNA *UNUSED(ptr), int value) { - G_verbose_set(value); + G.log.level = value; +# ifdef WITH_LIBMV + libmv_setLoggingVerbosity(value); +# elif defined(WITH_CYCLES_LOGGING) + CCL_logging_verbosity_set(value); +# endif } static void rna_verbose_range( @@ -5862,6 +5867,7 @@ static void rna_def_userdef_system(BlenderRNA *brna) "Debug Depsgraph Pretty", ""}, {G_DEBUG_DEPSGRAPH_UUID, "DEBUG_DEPSGRAPH_UUID", ICON_NONE, "Debug Depsgraph UUID", ""}, + /* skipped G_DEBUG_DEPSGRAPH */ {G_DEBUG_SIMDATA, "DEBUG_SIMDATA", ICON_NONE, "Debug Simulation Data", ""}, {G_DEBUG_GPU_MEM, "DEBUG_GPU_MEM", ICON_NONE, "Debug GPU Memory", ""}, {G_DEBUG_GPU, "DEBUG_GPU", ICON_NONE, "Debug GPU", ""}, @@ -5875,9 +5881,6 @@ static void rna_def_userdef_system(BlenderRNA *brna) {G_DEBUG_XR, "DEBUG_XR", ICON_NONE, "Debug XR", ""}, {G_DEBUG_XR_TIME, "DEBUG_XR_TIME", ICON_NONE, "Debug XR Time", ""}, {G_DEBUG_GHOST, "DEBUG_GHOST", ICON_NONE, "Debug GHOST", ""}, - {G_DEBUG_LIBMV, "DEBUG_LIBMV", ICON_NONE, "Debug LIBMV", ""}, - {G_DEBUG_CYCLES, "DEBUG_CYCLES", ICON_NONE, "Debug Cycles", ""}, - {G_DEBUG_FPE, "DEBUG_FPE", ICON_NONE, "Debug FPE", "Debug floating point exceptions"}, {0, NULL, 0, NULL, NULL}, }; @@ -5889,11 +5892,7 @@ static void rna_def_userdef_system(BlenderRNA *brna) RNA_def_property_ui_text( prop, "Debug Flags", - "Boolean, for debug info (started with --debug / --debug_* matching this attribute name"); - -// prop = RNA_def_property(srna, "debug_cycles", PROP_BOOLEAN, PROP_NONE); -// RNA_def_property_boolean_sdna(prop, NULL, "edit_studio_light", 1); -// RNA_def_property_boolean_sdna(prop, NULL, "debug_flags", G_DEBUG_CYCLES); + "Boolean, for debug info (started with --debug / --debug-* matching this attribute name"); /* TODO (grzelins) now we can remove WM_OT_debug_menu */ prop = RNA_def_property(srna, "debug_value", PROP_INT, PROP_NONE); diff --git a/source/creator/creator_args.c b/source/creator/creator_args.c index 4f3247a3532..eef728b073f 100644 --- a/source/creator/creator_args.c +++ b/source/creator/creator_args.c @@ -71,6 +71,14 @@ # include "WM_api.h" +# ifdef WITH_LIBMV +# include "libmv-capi.h" +# endif + +# ifdef WITH_CYCLES_LOGGING +# include "CCL_api.h" +# endif + # include "DEG_depsgraph.h" # include "DEG_depsgraph_build.h" # include "DEG_depsgraph_debug.h" @@ -895,9 +903,13 @@ static const char arg_handle_debug_mode_set_doc[] = "\t* Keeps Python's 'sys.stdin' rather than setting it to None"; static int arg_handle_debug_mode_set(int UNUSED(argc), const char **UNUSED(argv), void *data) { - G_debug_enable(G_DEBUG); + G.debug |= G_DEBUG; /* std output printf's */ U.runtime.use_settings_from_command_line |= ARGS_DEBUG; printf("Blender %s\n", BKE_blender_version_string()); + MEM_set_memory_debug(); +# ifndef NDEBUG + BLI_mempool_set_memory_debug(); +# endif # ifdef WITH_BUILDINFO printf("Build: %s %s %s %s\n", build_date, build_time, build_platform, build_type); @@ -975,7 +987,7 @@ static int arg_handle_debug_mode_generic_set(int UNUSED(argc), const char **UNUSED(argv), void *data) { - G_debug_enable(POINTER_AS_INT(data)); + G.debug |= POINTER_AS_INT(data); U.runtime.use_settings_from_command_line |= ARGS_DEBUG; return 0; } @@ -987,7 +999,7 @@ static int arg_handle_debug_mode_io(int UNUSED(argc), const char **UNUSED(argv), void *UNUSED(data)) { - G_debug_enable(G_DEBUG_IO); + G.debug |= G_DEBUG_IO; U.runtime.use_settings_from_command_line |= ARGS_DEBUG; return 0; } @@ -999,8 +1011,13 @@ static int arg_handle_debug_mode_all(int UNUSED(argc), const char **UNUSED(argv), void *UNUSED(data)) { - G_debug_enable(G_DEBUG_ALL); - U.runtime.use_settings_from_command_line |= ARGS_DEBUG; + G.debug |= G_DEBUG_ALL; +# ifdef WITH_LIBMV + libmv_startDebugLogging(); +# endif +# ifdef WITH_CYCLES_LOGGING + CCL_start_debug_logging(); +# endif return 0; } @@ -1012,7 +1029,8 @@ static int arg_handle_debug_mode_libmv(int UNUSED(argc), const char **UNUSED(argv), void *UNUSED(data)) { - G_debug_enable(G_DEBUG_LIBMV); + libmv_startDebugLogging(); + return 0; } # endif @@ -1025,12 +1043,11 @@ static int arg_handle_debug_mode_cycles(int UNUSED(argc), const char **UNUSED(argv), void *UNUSED(data)) { - G_debug_enable(G_DEBUG_CYCLES); + CCL_start_debug_logging(); return 0; } # endif -/* TODO (grzelins) this is useless it is done in --debug */ static const char arg_handle_debug_mode_memory_set_doc[] = "\n\t" "Enable fully guarded memory allocation and debugging."; @@ -1038,7 +1055,7 @@ static int arg_handle_debug_mode_memory_set(int UNUSED(argc), const char **UNUSED(argv), void *UNUSED(data)) { - G_debug_enable(G_DEBUG_MEMORY); + MEM_set_memory_debug(); return 0; } @@ -1074,9 +1091,7 @@ static int arg_handle_debug_fpe_set(int UNUSED(argc), const char **UNUSED(argv), void *UNUSED(data)) { - // G_debug_enable(G_DEBUG_FPE); main_signal_setup_fpe(); - U.runtime.use_settings_from_command_line |= ARGS_DEBUG; return 0; } @@ -1483,7 +1498,13 @@ static int arg_handle_verbosity_set(int argc, const char **argv, void *UNUSED(da printf("\nError: %s '%s %s'.\n", err_msg, arg_id, argv[1]); } - G_verbose_set(level); +# ifdef WITH_LIBMV + libmv_setLoggingVerbosity(level); +# elif defined(WITH_CYCLES_LOGGING) + CCL_logging_verbosity_set(level); +# else + (void)level; +# endif return 1; } -- cgit v1.2.3