From fffa314bffcc6bc6fd36339459b260cc9b370695 Mon Sep 17 00:00:00 2001 From: nobelj Date: Wed, 26 Apr 2023 15:01:43 -0700 Subject: [PATCH] qcacmn: Add support to invoke debug function before assert qdf assert always, assert without debug information. Added support to dump needed information before assert. Change-Id: I19898ec11c1bade4340cf1737a760d9507012f12 CRs-Fixed: 3480596 --- qdf/inc/qdf_util.h | 8 ++++++++ qdf/linux/src/i_qdf_util.h | 12 ++++++++++++ 2 files changed, 20 insertions(+) diff --git a/qdf/inc/qdf_util.h b/qdf/inc/qdf_util.h index 791b816b07..cb38e47805 100644 --- a/qdf/inc/qdf_util.h +++ b/qdf/inc/qdf_util.h @@ -91,6 +91,14 @@ typedef __qdf_wait_queue_head_t qdf_wait_queue_head_t; */ #define qdf_assert_always(expr) __qdf_assert(expr) +/** + * qdf_assert_with_debug - invoke function to dump needed info before assert + * @expr: expression to test + * @debug_fp: function pointer to be invoked for debugging + */ +#define qdf_assert_with_debug(expr, debug_fp, ...) \ + __qdf_assert_with_debug(expr, debug_fp, ...) + /** * qdf_target_assert_always - always target assert "expr" evaluates to false. * @expr: expression to test diff --git a/qdf/linux/src/i_qdf_util.h b/qdf/linux/src/i_qdf_util.h index 213f447a9f..4edddc0818 100644 --- a/qdf/linux/src/i_qdf_util.h +++ b/qdf/linux/src/i_qdf_util.h @@ -212,6 +212,18 @@ static inline bool __qdf_is_macaddr_equal(const struct qdf_mac_addr *mac_addr1, } \ } while (0) +#define __qdf_assert_with_debug(expr, debug_fp, ...) \ + do { \ + typeof(debug_fp) _debug_fp = debug_fp; \ + if (unlikely(!(expr))) { \ + pr_err("Assertion failed! %s:%s %s:%d\n", \ + # expr, __func__, __FILE__, __LINE__); \ + if (_debug_fp) \ + _debug_fp(__VA_ARGS__); \ + QDF_BUG_ON_ASSERT(0); \ + } \ + } while (0) + #define __qdf_target_assert(expr) do { \ if (unlikely(!(expr))) { \ qdf_err("Assertion failed! %s:%s %s:%d", \