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:
authorCampbell Barton <ideasman42@gmail.com>2018-05-18 12:02:39 +0300
committerCampbell Barton <ideasman42@gmail.com>2018-05-18 12:02:39 +0300
commit2451a1951e22fd7761f7e39ededda0bd5cc2d875 (patch)
tree615306055960e0c35c549ee3a88ce041d1e33509 /intern/clog
parent987d1df57159afd57f33d7e58681be2fcdebda16 (diff)
parent278e3f7d5fea2a8b3775e76257dfd96a5e5c2f11 (diff)
Merge branch 'master' into blender2.8
Diffstat (limited to 'intern/clog')
-rw-r--r--intern/clog/CLG_log.h1
-rw-r--r--intern/clog/clog.c37
2 files changed, 33 insertions, 5 deletions
diff --git a/intern/clog/CLG_log.h b/intern/clog/CLG_log.h
index ff8f983b10c..61fc93be9e7 100644
--- a/intern/clog/CLG_log.h
+++ b/intern/clog/CLG_log.h
@@ -146,6 +146,7 @@ void CLG_exit(void);
void CLG_output_set(void *file_handle);
void CLG_output_use_basename_set(int value);
void CLG_fatal_fn_set(void (*fatal_fn)(void *file_handle));
+void CLG_backtrace_fn_set(void (*fatal_fn)(void *file_handle));
void CLG_type_filter_include(const char *type_filter, int type_filter_len);
void CLG_type_filter_exclude(const char *type_filter, int type_filter_len);
diff --git a/intern/clog/clog.c b/intern/clog/clog.c
index e96cbbe7f14..d26f0545117 100644
--- a/intern/clog/clog.c
+++ b/intern/clog/clog.c
@@ -81,6 +81,7 @@ typedef struct CLogContext {
struct {
void (*fatal_fn)(void *file_handle);
+ void (*backtrace_fn)(void *file_handle);
} callbacks;
} CLogContext;
@@ -328,15 +329,23 @@ static CLG_LogType *clg_ctx_type_register(CLogContext *ctx, const char *identifi
return ty;
}
-static void clg_ctx_fatal_action(CLogContext *ctx, FILE *file_handle)
+static void clg_ctx_fatal_action(CLogContext *ctx)
{
if (ctx->callbacks.fatal_fn != NULL) {
- ctx->callbacks.fatal_fn(file_handle);
+ ctx->callbacks.fatal_fn(ctx->output_file);
}
- fflush(file_handle);
+ fflush(ctx->output_file);
abort();
}
+static void clg_ctx_backtrace(CLogContext *ctx)
+{
+ /* Note: we avoid writing fo 'FILE', for backtrace we make an exception,
+ * if necessary we could have a version of the callback that writes to file descriptor all at once. */
+ ctx->callbacks.backtrace_fn(ctx->output_file);
+ fflush(ctx->output_file);
+}
+
/** \} */
/* -------------------------------------------------------------------- */
@@ -409,8 +418,12 @@ void CLG_log_str(
clg_str_free(&cstr);
+ if (lg->ctx->callbacks.backtrace_fn) {
+ clg_ctx_backtrace(lg->ctx);
+ }
+
if (severity == CLG_SEVERITY_FATAL) {
- clg_ctx_fatal_action(lg->ctx, lg->ctx->output_file);
+ clg_ctx_fatal_action(lg->ctx);
}
}
@@ -441,8 +454,12 @@ void CLG_logf(
clg_str_free(&cstr);
+ if (lg->ctx->callbacks.backtrace_fn) {
+ clg_ctx_backtrace(lg->ctx);
+ }
+
if (severity == CLG_SEVERITY_FATAL) {
- clg_ctx_fatal_action(lg->ctx, lg->ctx->output_file);
+ clg_ctx_fatal_action(lg->ctx);
}
}
@@ -472,6 +489,11 @@ static void CLG_ctx_fatal_fn_set(CLogContext *ctx, void (*fatal_fn)(void *file_h
ctx->callbacks.fatal_fn = fatal_fn;
}
+static void CLG_ctx_backtrace_fn_set(CLogContext *ctx, void (*backtrace_fn)(void *file_handle))
+{
+ ctx->callbacks.backtrace_fn = backtrace_fn;
+}
+
static void clg_ctx_type_filter_append(CLG_IDFilter **flt_list, const char *type_match, int type_match_len)
{
if (type_match_len == 0) {
@@ -569,6 +591,11 @@ void CLG_fatal_fn_set(void (*fatal_fn)(void *file_handle))
CLG_ctx_fatal_fn_set(g_ctx, fatal_fn);
}
+void CLG_backtrace_fn_set(void (*fatal_fn)(void *file_handle))
+{
+ CLG_ctx_backtrace_fn_set(g_ctx, fatal_fn);
+}
+
void CLG_type_filter_exclude(const char *type_match, int type_match_len)
{
CLG_ctx_type_filter_exclude(g_ctx, type_match, type_match_len);