aboutsummaryrefslogtreecommitdiffstats
path: root/include/os/freebsd/spl/sys/debug.h
Commit message (Collapse)AuthorAgeFilesLines
* Add custom debug printing for your assertsRich Ercolani2024-04-101-12/+137
| | | | | | | | | Being able to print custom debug information on assert trip seems useful. Reviewed-by: Brian Behlendorf <[email protected]> Reviewed-by: Paul Dagnelie <[email protected]> Signed-off-by: Rich Ercolani <[email protected]> Closes #15792
* Add VERIFY0P() and ASSERT0P() macros.Dag-Erling Smørgrav2023-09-191-0/+13
| | | | | | | | | | | These macros are similar to VERIFY0() and ASSERT0() but are intended for pointers, and therefore use uintptr_t instead of int64_t. Reviewed-by: Brian Behlendorf <[email protected]> Reviewed-by: Kay Pedersen <[email protected]> Reviewed-by: Alexander Motin <[email protected]> Signed-off-by: Dag-Erling Smørgrav <[email protected]> Closes #15225
* Clean up existing VERIFY*() macros.Dag-Erling Smørgrav2023-09-191-14/+13
| | | | | | | | | | | | | | | Chiefly: - Remove unnecessary parentheses around variable names. - Remove spaces between the type and variable in casts. - Make the panic message for VERIFY0() reflect how the macro is used. - Use %p to format pointers, except in Linux kernel code. Reviewed-by: Brian Behlendorf <[email protected]> Reviewed-by: Kay Pedersen <[email protected]> Reviewed-by: Alexander Motin <[email protected]> Signed-off-by: Dag-Erling Smørgrav <[email protected]> Closes #15225
* debug: fix output from VERIFY0 assertionRob N ★2022-10-281-1/+1
| | | | | | | | | | The previous version reported all the right info, but the VERIFY3 name made a little more confusing when looking for the matching location in the source code. Reviewed-by: Brian Behlendorf <[email protected]> Reviewed-by: Richard Yao <[email protected]> Signed-off-by: Rob N ★ <[email protected]> Closes #14099
* Silence objtool warnings from 55d7afa4Richard Yao2022-10-261-0/+3
| | | | | | | | | | | | The use of __noreturn__ in 55d7afa4adbb4ca569e9c4477a7d121f4dc0bfbd on spl_panic() caused objtool warnings on Linux when the kernel is built with CONFIG_STACK_VALIDATION=y. This patch works around that by restricting the application of __noreturn__ to builds for static analyzers. Reviewed-by: Brian Behlendorf <[email protected]> Reviewed-by: Ryan Moeller <[email protected]> Signed-off-by: Richard Yao <[email protected]> Closes #14068
* Reduce false positives from Static AnalyzersRichard Yao2022-09-301-11/+19
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Both Clang's Static Analyzer and Synopsys' Coverity would ignore assertions. Following Clang's advice, we annotate our assertions: https://clang-analyzer.llvm.org/annotations.html#custom_assertions This makes both Clang's Static Analyzer and Coverity properly identify assertions. This change reduced Clang's reported defects from 246 to 180. It also reduced the false positives reported by Coverityi by 10, while enabling Coverity to find 9 more defects that previously were false negatives. A couple examples of this would be CID-1524417 and CID-1524423. After submitting a build to coverity with the modified assertions, CID-1524417 disappeared while the report for CID-1524423 no longer claimed that the assertion tripped. Coincidentally, it turns out that it is possible to more accurately annotate our headers than the Coverity modelling file permits in the case of format strings. Since we can do that and this patch annotates headers whenever `__coverity_panic__()` would have been used in the model file, we drop all models that use `__coverity_panic__()` from the model file. Upon seeing the success in eliminating false positives involving assertions, it occurred to me that we could also modify our headers to eliminate coverity's false positives involving byte swaps. We now have coverity specific byteswap macros, that do nothing, to disable Coverity's false positives when we do byte swaps. This allowed us to also drop the byteswap definitions from the model file. Lastly, a model file update has been done beyond the mentioned deletions: * The definitions of `umem_alloc_aligned()`, `umem_alloc()` andi `umem_zalloc()` were originally implemented in a way that was intended to inform coverity that when KM_SLEEP has been passed these functions, they do not return NULL. A small error in how this was done was found, so we correct it. * Definitions for umem_cache_alloc() and umem_cache_free() have been added. In practice, no false positives were avoided by making these changes, but in the interest of correctness from future coverity builds, we make them anyway. Reviewed-by: Brian Behlendorf <[email protected]> Reviewed-by: Ryan Moeller <[email protected]> Signed-off-by: Richard Yao <[email protected]> Closes #13902
* Replace *CTASSERT() with _Static_assert()наб2022-01-261-1/+0
| | | | | | Reviewed-by: Brian Behlendorf <[email protected]> Signed-off-by: Ahelenia Ziemiańska <[email protected]> Closes #12993
* Clean up CSTYLEDsнаб2022-01-261-28/+26
| | | | | | | | | | | | | | | | | | | | 69 CSTYLED BEGINs remain, appx. 30 of which can be removed if cstyle(1) had a useful policy regarding CALL(ARG1, ARG2, ARG3); above 2 lines. As it stands, it spits out *both* sysctl_os.c: 385: continuation line should be indented by 4 spaces sysctl_os.c: 385: indent by spaces instead of tabs which is very cool Another >10 could be fixed by removing "ulong" &al. handling. I don't foresee anyone actually using it intentionally (does it even exist in modern headers? why did it in the first place?). Reviewed-by: Brian Behlendorf <[email protected]> Signed-off-by: Ahelenia Ziemiańska <[email protected]> Closes #12993
* libspl: cast to uintptr_t instead of !!ingнаб2022-01-241-8/+14
| | | | | | | | | | | | | | | | | | | | | | | | | | | This led to these two warning types: debug.h:139:67: warning: the address of ‘ARC_anon’ will always evaluate as ‘true’ [-Waddress] 139 | #define ASSERT3P(x, y, z) ((void) sizeof (!!(x)), (void) sizeof (!!(z))) | ^ arc.c:1591:2: note: in expansion of macro ‘ASSERT3P’ 1591 | ASSERT3P(hdr->b_l1hdr.b_state, ==, arc_anon); | ^~~~~~~~ and arc.h:66:44: warning: ‘<<’ in boolean context, did you mean ‘<’? [-Wint-in-bool-context] 66 | #define HDR_GET_LSIZE(hdr) ((hdr)->b_lsize << SPA_MINBLOCKSHIFT) debug.h:138:46: note: in definition of macro ‘ASSERT3U’ 138 | #define ASSERT3U(x, y, z) ((void) sizeof (!!(x)), (void) sizeof (!!(z))) | ^ arc.c:1760:12: note: in expansion of macro ‘HDR_GET_LSIZE’ 1760 | ASSERT3U(HDR_GET_LSIZE(hdr), !=, 0); | ^~~~~~~~~~~~~ Reviewed-by: Brian Behlendorf <[email protected]> Signed-off-by: Ahelenia Ziemiańska <[email protected]> Closes #13009
* libspl: ASSERT*: !! for sizeofнаб2022-01-211-8/+8
| | | | | | | | | | | sizeof(bitfield.member) is invalid, and this shows up in some FreeBSD build configurations: work around this by !!ing ‒ this makes the sizeof target the ! result type (_Bool), instead Reviewed-by: Brian Behlendorf <[email protected]> Signed-off-by: Ahelenia Ziemiańska <[email protected]> Fixes: 42aaf0e ("libspl: ASSERT*: mark arguments as used") Closes #12984 Closes #12986
* libspl: ASSERT*: mark arguments as usedнаб2021-12-231-8/+8
| | | | | | Reviewed-by: Brian Behlendorf <[email protected]> Signed-off-by: Ahelenia Ziemiańska <[email protected]> Closes #12844
* Microoptimizations for VERIFY() and friendsAdam D. Moss2021-03-111-40/+40
| | | | | | | | | Add branch hints and constify the intermediate evaluations of left/right params in VERIFY3*(). Reviewed-by: Ryan Moeller <[email protected]> Reviewed-by: Brian Behlendorf <[email protected]> Signed-off-by: Adam Moss <[email protected]> Closes #11708
* Add FreeBSD support to OpenZFSMatthew Macy2020-04-141-0/+168
Add the FreeBSD platform code to the OpenZFS repository. As of this commit the source can be compiled and tested on FreeBSD 11 and 12. Subsequent commits are now required to compile on FreeBSD and Linux. Additionally, they must pass the ZFS Test Suite on FreeBSD which is being run by the CI. As of this commit 1230 tests pass on FreeBSD and there are no unexpected failures. Reviewed-by: Sean Eric Fagan <[email protected]> Reviewed-by: Jorgen Lundman <[email protected]> Reviewed-by: Richard Laager <[email protected]> Reviewed-by: Brian Behlendorf <[email protected]> Co-authored-by: Ryan Moeller <[email protected]> Signed-off-by: Matt Macy <[email protected]> Signed-off-by: Ryan Moeller <[email protected]> Closes #898 Closes #8987