From 779817cb91c4c9c0d82daf74a7d6b409e6a8efa7 Mon Sep 17 00:00:00 2001 From: Thibault Saunier Date: Thu, 19 Mar 2020 18:26:58 -0300 Subject: [PATCH] report: Add a way to force backtraces on reports And stop report simple debug message Part-of: --- validate/gst/validate/gst-validate-report.c | 44 ++++++++++++++++++++++----- validate/gst/validate/gst-validate-report.h | 9 ++++++ validate/gst/validate/gst-validate-reporter.c | 2 -- 3 files changed, 46 insertions(+), 9 deletions(-) diff --git a/validate/gst/validate/gst-validate-report.c b/validate/gst/validate/gst-validate-report.c index 95c55e8..c027921 100644 --- a/validate/gst/validate/gst-validate-report.c +++ b/validate/gst/validate/gst-validate-report.c @@ -464,12 +464,17 @@ gst_validate_report_load_issues (void) ("Pad buffers push frequency is lower than the minimum required by the config"), NULL); REGISTER_VALIDATE_ISSUE_FULL (WARNING, G_LOG_WARNING, - _("We got a g_log warning"), NULL, GST_VALIDATE_ISSUE_FLAGS_FULL_DETAILS); + _("We got a g_log warning"), NULL, + GST_VALIDATE_ISSUE_FLAGS_FORCE_BACKTRACE | + GST_VALIDATE_ISSUE_FLAGS_FULL_DETAILS); REGISTER_VALIDATE_ISSUE_FULL (CRITICAL, G_LOG_CRITICAL, "We got a g_log critical issue", NULL, + GST_VALIDATE_ISSUE_FLAGS_FORCE_BACKTRACE | GST_VALIDATE_ISSUE_FLAGS_FULL_DETAILS); REGISTER_VALIDATE_ISSUE_FULL (ISSUE, G_LOG_ISSUE, "We got a g_log issue", - NULL, GST_VALIDATE_ISSUE_FLAGS_FULL_DETAILS); + NULL, + GST_VALIDATE_ISSUE_FLAGS_FORCE_BACKTRACE | + GST_VALIDATE_ISSUE_FLAGS_FULL_DETAILS); REGISTER_VALIDATE_ISSUE (CRITICAL, PULL_RANGE_FROM_WRONG_THREAD, "gst_pad_pull_range called from wrong thread", @@ -763,6 +768,34 @@ _report_free (GstValidateReport * report) g_slice_free (GstValidateReport, report); } +static gboolean +gst_validate_report_should_generate_backtrace (GstValidateIssue * issue, + GstValidateReport * report, + GstValidateReportingDetails default_details, + GstValidateReportingDetails issue_type_details, + GstValidateReportingDetails reporter_details) +{ + if (issue->flags & GST_VALIDATE_ISSUE_FLAGS_FORCE_BACKTRACE) + return TRUE; + + if (issue->flags & GST_VALIDATE_ISSUE_FLAGS_NO_BACKTRACE) + return FALSE; + + if (default_details == GST_VALIDATE_SHOW_ALL) + return TRUE; + + if (issue_type_details == GST_VALIDATE_SHOW_ALL) + return TRUE; + + if (gst_validate_report_check_abort (report)) + return TRUE; + + if (report->level == GST_VALIDATE_REPORT_LEVEL_CRITICAL) + return TRUE; + + return FALSE; +} + GstValidateReport * gst_validate_report_new (GstValidateIssue * issue, GstValidateReporter * reporter, const gchar * message) @@ -802,11 +835,8 @@ gst_validate_report_new (GstValidateIssue * issue, reporter_details != GST_VALIDATE_SHOW_UNKNOWN) return report; - if ((default_details == GST_VALIDATE_SHOW_ALL || - issue_type_details == GST_VALIDATE_SHOW_ALL || - gst_validate_report_check_abort (report) || - report->level == GST_VALIDATE_REPORT_LEVEL_CRITICAL) && - (!(issue->flags & GST_VALIDATE_ISSUE_FLAGS_NO_BACKTRACE))) + if (gst_validate_report_should_generate_backtrace (issue, report, + default_details, issue_type_details, reporter_details)) report->trace = gst_debug_get_stack_trace (GST_STACK_TRACE_SHOW_FULL); return report; diff --git a/validate/gst/validate/gst-validate-report.h b/validate/gst/validate/gst-validate-report.h index f19e8f2..c16a420 100644 --- a/validate/gst/validate/gst-validate-report.h +++ b/validate/gst/validate/gst-validate-report.h @@ -157,6 +157,15 @@ typedef enum { GST_VALIDATE_ISSUE_FLAGS_NONE = 0, GST_VALIDATE_ISSUE_FLAGS_FULL_DETAILS = 1 << 0, GST_VALIDATE_ISSUE_FLAGS_NO_BACKTRACE = 1 << 1, + + /** + * GST_VALIDATE_ISSUE_FLAGS_FORCE_BACKTRACE: + * + * Always generate backtrace, even if not a critical issue + * + * Since: 1.20 + */ + GST_VALIDATE_ISSUE_FLAGS_FORCE_BACKTRACE = 1 << 2, } GstValidateIssueFlags; typedef struct { diff --git a/validate/gst/validate/gst-validate-reporter.c b/validate/gst/validate/gst-validate-reporter.c index 83ae048..ac15a45 100644 --- a/validate/gst/validate/gst-validate-reporter.c +++ b/validate/gst/validate/gst-validate-reporter.c @@ -299,8 +299,6 @@ gst_validate_reporter_g_log_func (const gchar * log_domain, GST_VALIDATE_REPORT (reporter, G_LOG_CRITICAL, "%s", message); else if (log_level & G_LOG_LEVEL_WARNING) GST_VALIDATE_REPORT (reporter, G_LOG_WARNING, "%s", message); - else - GST_VALIDATE_REPORT (reporter, G_LOG_ISSUE, "%s", message); } /** -- 2.7.4