Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSergey Sharybin <sergey.vfx@gmail.com>2018-03-16 14:24:08 +0300
committerSergey Sharybin <sergey.vfx@gmail.com>2018-03-16 14:24:51 +0300
commitda4efaeb87b74f73bd5b640eb70132521a1db5cb (patch)
treef913ac83bfdc2dd2293d52f2b1e02c940c7ff277 /source/blender/depsgraph
parent295d8510afcbf2c7315d3bcbe53db583505d18f6 (diff)
Depsgraph: Support colored addresses in debug prints
Enabled with --debug-depsgraph-pretty, only works with ANSI terminals. Thanks Bastien for review!
Diffstat (limited to 'source/blender/depsgraph')
-rw-r--r--source/blender/depsgraph/intern/depsgraph.cc70
-rw-r--r--source/blender/depsgraph/intern/depsgraph_intern.h4
2 files changed, 65 insertions, 9 deletions
diff --git a/source/blender/depsgraph/intern/depsgraph.cc b/source/blender/depsgraph/intern/depsgraph.cc
index f8e12ef45c3..66ddaa6b0d5 100644
--- a/source/blender/depsgraph/intern/depsgraph.cc
+++ b/source/blender/depsgraph/intern/depsgraph.cc
@@ -35,6 +35,8 @@
#include "MEM_guardedalloc.h"
#include "BLI_utildefines.h"
+#include "BLI_console.h"
+#include "BLI_hash.h"
#include "BLI_ghash.h"
#include "BLI_listbase.h"
@@ -458,6 +460,31 @@ void deg_editors_scene_update(Main *bmain, Scene *scene, bool updated)
}
}
+bool deg_terminal_do_color(void)
+{
+ return (G.debug & G_DEBUG_DEPSGRAPH_PRETTY) != 0;
+}
+
+string deg_color_for_pointer(const void *pointer)
+{
+ if (!deg_terminal_do_color()) {
+ return "";
+ }
+ int r, g, b;
+ BLI_hash_pointer_to_color(pointer, &r, &g, &b);
+ char buffer[64];
+ BLI_snprintf(buffer, sizeof(buffer), TRUECOLOR_ANSI_COLOR_FORMAT, r, g, b);
+ return string(buffer);
+}
+
+string deg_color_end(void)
+{
+ if (!deg_terminal_do_color()) {
+ return "";
+ }
+ return string(TRUECOLOR_ANSI_COLOR_FINISH);
+}
+
} // namespace DEG
/* **************** */
@@ -495,6 +522,8 @@ void DEG_editors_update_pre(Main *bmain, Scene *scene, bool time)
}
}
+/* Evaluation and debug */
+
void DEG_debug_print_eval(const char *function_name,
const char *object_name,
const void *object_address)
@@ -502,7 +531,12 @@ void DEG_debug_print_eval(const char *function_name,
if ((G.debug & G_DEBUG_DEPSGRAPH_EVAL) == 0) {
return;
}
- printf("%s on %s (%p)\n", function_name, object_name, object_address);
+ printf("%s on %s %s(%p)%s\n",
+ function_name,
+ object_name,
+ DEG::deg_color_for_pointer(object_address).c_str(),
+ object_address,
+ DEG::deg_color_end().c_str());
}
void DEG_debug_print_eval_subdata(const char *function_name,
@@ -515,11 +549,17 @@ void DEG_debug_print_eval_subdata(const char *function_name,
if ((G.debug & G_DEBUG_DEPSGRAPH_EVAL) == 0) {
return;
}
- printf("%s on %s (%p) %s %s (%p)\n",
+ printf("%s on %s %s(%p)%s %s %s %s(%p)%s\n",
function_name,
- object_name, object_address,
+ object_name,
+ DEG::deg_color_for_pointer(object_address).c_str(),
+ object_address,
+ DEG::deg_color_end().c_str(),
subdata_comment,
- subdata_name, subdata_address);
+ subdata_name,
+ DEG::deg_color_for_pointer(subdata_address).c_str(),
+ subdata_address,
+ DEG::deg_color_end().c_str());
}
void DEG_debug_print_eval_subdata_index(const char *function_name,
@@ -533,11 +573,18 @@ void DEG_debug_print_eval_subdata_index(const char *function_name,
if ((G.debug & G_DEBUG_DEPSGRAPH_EVAL) == 0) {
return;
}
- printf("%s on %s (%p) %s %s[%d] (%p)\n",
+ printf("%s on %s %s(%p)^%s %s %s[%d] %s(%p)%s\n",
function_name,
- object_name, object_address,
+ object_name,
+ DEG::deg_color_for_pointer(object_address).c_str(),
+ object_address,
+ DEG::deg_color_end().c_str(),
subdata_comment,
- subdata_name, subdata_index, subdata_address);
+ subdata_name,
+ subdata_index,
+ DEG::deg_color_for_pointer(subdata_address).c_str(),
+ subdata_address,
+ DEG::deg_color_end().c_str());
}
void DEG_debug_print_eval_time(const char *function_name,
@@ -548,6 +595,11 @@ void DEG_debug_print_eval_time(const char *function_name,
if ((G.debug & G_DEBUG_DEPSGRAPH_EVAL) == 0) {
return;
}
- printf("%s on %s (%p) at time %f\n",
- function_name, object_name, object_address, time);
+ printf("%s on %s %s(%p)%s at time %f\n",
+ function_name,
+ object_name,
+ DEG::deg_color_for_pointer(object_address).c_str(),
+ object_address,
+ DEG::deg_color_end().c_str(),
+ time);
}
diff --git a/source/blender/depsgraph/intern/depsgraph_intern.h b/source/blender/depsgraph/intern/depsgraph_intern.h
index 2ac97c53db7..89432e17f87 100644
--- a/source/blender/depsgraph/intern/depsgraph_intern.h
+++ b/source/blender/depsgraph/intern/depsgraph_intern.h
@@ -116,4 +116,8 @@ void deg_editors_scene_update(struct Main *bmain, struct Scene *scene, bool upda
} \
} while (0)
+bool deg_terminal_do_color(void);
+string deg_color_for_pointer(const void *pointer);
+string deg_color_end(void);
+
} // namespace DEG