Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

custom printing messages with your assertion trips #14466

Closed
wants to merge 2 commits into from

Conversation

rincebrain
Copy link
Contributor

@rincebrain rincebrain commented Feb 6, 2023

Motivation and Context

I kept rewriting assertions into if(assert condition) { print something; trip assertion; } and went "this probably works".

So now I want to see if the CI explodes on Debian 8 or something.

(Before merge I'd probably refactor the non-f versions into being in terms of the f versions, but this way I can test a much smaller blast radius at a time...also suggestions for better naming welcome.)

(...I also flattened freebsd's debug.h and linux's after noticing they were more or less the same file, but that's mostly orthogonal and just in here because I also want to make sure that compiles everywhere.)

Description

Gives all the ASSERT/VERIFY macros an "f" suffix variant that adds "STR, ..." arguments such that you could do, say
ASSERT3Pf(hdr->b_l1hdr.b_pabd, !=, NULL, "hdr %px buf %px", hdr, buf);
and get an error trip like
VERIFY3(hdr->b_l1hdr.b_pabd != NULL) failed (0000000000000000 != 0000000000000000) hdr 0000000000000000 buf 0000000000000000

The only big caveat is I don't think you can do something like ((void) __VA_ARGS__) so the print varargs won't always get executed, so don't put side effect things in there you need to always run...but that's not a reason not to have it, just a warning.

How Has This Been Tested?

I mean, I compiled it once, what could go wrong, right?

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Performance enhancement (non-breaking change which improves efficiency)
  • Code cleanup (non-breaking change which makes code smaller or more readable)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Library ABI change (libzfs, libzfs_core, libnvpair, libuutil and libzfsbootenv)
  • Documentation (a change to man pages or other documentation)

Checklist:

This was just a thing I wanted, wondered why nobody had written,
so I tried it.

Let's see how the CI likes it...

Signed-off-by: Rich Ercolani <rincebrain@gmail.com>
Signed-off-by: Rich Ercolani <rincebrain@gmail.com>
@behlendorf behlendorf added the Status: Work in Progress Not yet ready for general review label Feb 14, 2023
@rincebrain rincebrain changed the title EXPERIMENT: custom printing messages with your assertion trips custom printing messages with your assertion trips Mar 3, 2023
@rincebrain rincebrain marked this pull request as ready for review March 3, 2023 14:19
@rincebrain rincebrain closed this Sep 11, 2023
@rincebrain
Copy link
Contributor Author

Amazing. I...can't reopen this.

@rincebrain
Copy link
Contributor Author

Or maybe it just wanted a less stale force push? I don't really know.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Status: Work in Progress Not yet ready for general review
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants