diff options
author | Xin Li <delphij@google.com> | 2023-08-14 15:38:30 -0700 |
---|---|---|
committer | Xin Li <delphij@google.com> | 2023-08-14 15:38:30 -0700 |
commit | bddf63953e111d742b591c1c0c7c34bcda8a51c7 (patch) | |
tree | 3a93128bff4b737b24b0c9581922c0b20410f0f4 /pw_assert_basic/public/pw_assert_basic/assert_basic.h | |
parent | ee890da55c82b95deca3518d5f3777e3d8ca9f0e (diff) | |
parent | fbb9890f8922aa55fde183655a0017e69127ea4b (diff) | |
download | pigweed-bddf63953e111d742b591c1c0c7c34bcda8a51c7.tar.gz |
Merge Android U (ab/10368041)tmp_amf_298295554
Bug: 291102124
Merged-In: I10c41adb8fe3e126cfa4ff2f49b15863fff379de
Change-Id: I66f7a6cccaafc173d3924dae62a736c6c53520c7
Diffstat (limited to 'pw_assert_basic/public/pw_assert_basic/assert_basic.h')
-rw-r--r-- | pw_assert_basic/public/pw_assert_basic/assert_basic.h | 32 |
1 files changed, 21 insertions, 11 deletions
diff --git a/pw_assert_basic/public/pw_assert_basic/assert_basic.h b/pw_assert_basic/public/pw_assert_basic/assert_basic.h index 88405f88a..6d8bd6cf8 100644 --- a/pw_assert_basic/public/pw_assert_basic/assert_basic.h +++ b/pw_assert_basic/public/pw_assert_basic/assert_basic.h @@ -18,12 +18,22 @@ #include "pw_preprocessor/compiler.h" #include "pw_preprocessor/util.h" +// Use __PRETTY_FUNCTION__, a GNU extension, in place of the __func__ macro when +// supported. __PRETTY_FUNCTION__ expands to the full C++ function name. +#ifdef __GNUC__ +#define _PW_ASSERT_BASIC_FUNCTION_NAME __PRETTY_FUNCTION__ +#else +#define _PW_ASSERT_BASIC_FUNCTION_NAME __func__ +#endif // __GNUC__ + // Die with a message with many attributes included. This is the crash macro // frontend that funnels everything into the C handler provided by the user, // pw_assert_basic_HandleFailure(). #define PW_HANDLE_CRASH(...) \ pw_assert_basic_HandleFailure( \ - __FILE__, __LINE__, __func__ PW_COMMA_ARGS(__VA_ARGS__)) + __FILE__, \ + __LINE__, \ + _PW_ASSERT_BASIC_FUNCTION_NAME PW_COMMA_ARGS(__VA_ARGS__)) // Die with a message with many attributes included. This is the crash macro // frontend that funnels everything into the C handler provided by the user, @@ -31,7 +41,7 @@ #define PW_HANDLE_ASSERT_FAILURE(condition_string, message, ...) \ pw_assert_basic_HandleFailure(__FILE__, \ __LINE__, \ - __func__, \ + _PW_ASSERT_BASIC_FUNCTION_NAME, \ "Check failed: " condition_string \ ". " message PW_COMMA_ARGS(__VA_ARGS__)) @@ -51,13 +61,13 @@ type_fmt, \ message, ...) \ pw_assert_basic_HandleFailure( \ - __FILE__, \ - __LINE__, \ - __func__, \ - "Check failed: " \ - arg_a_str " (=" type_fmt ") " \ - comparison_op_str " " \ - arg_b_str " (=" type_fmt ")" \ - ". " message, \ - arg_a_val, arg_b_val PW_COMMA_ARGS(__VA_ARGS__)) + __FILE__, \ + __LINE__, \ + _PW_ASSERT_BASIC_FUNCTION_NAME, \ + "Check failed: " \ + arg_a_str " (=" type_fmt ") " \ + comparison_op_str " " \ + arg_b_str " (=" type_fmt ")" \ + ". " message, \ + arg_a_val, arg_b_val PW_COMMA_ARGS(__VA_ARGS__)) // clang-format on |