-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
Add custom debug printing for your asserts #15792
Conversation
e16bc9c
to
a5aabbd
Compare
Oh, I love this. I write a jank variant of this nearly every day. Nice work! If I'll also say that the lowercase |
I was a little worried it might get pulled in by libspl if I do that, and I could coalesce both of those too, but that was why I didn't, was that I mostly wanted to get feedback on the design, and figured that could be implemented later if it worked and people liked the idea.
I don't really like it either, if I'm honest, but since all the uppercase was overloaded with pointer/unsigned/etc, lowercase seemed like the most expressive way to make it clear this wasn't just a different element type. Not that we use floating point around much, but that was why. Suggestions on alternatives welcome. |
I'm all for this. Thanks for reviving this work. For what it's worth, I'd lean slightly towards
It would be nice if these shared a common file, but it looks to me like that would currently be a problem. We've bumped in to this in a few other places so a generic way to handle it would be good. Maybe a new |
@rincebrain if you can rebase this and sort out the style warnings I'll go ahead and merge it. This is such a nice quality of life improvement I'd hate for it to get hung up on any |
Honestly, it wasn't a disagreement about the f versus F for me, I just forgot I never replied or updated this. I'll go rebase and push. |
I think it should be much easier to fix the capitalization now than remember about this case oddity forever after. |
cfade36
to
1a070b6
Compare
1a070b6
to
aa3386c
Compare
Looking at it quickly, I'm debating what to do about the |
It seems to me that |
@rincebrain if you can sort out the remaining build errors I think we'd all love to get a version of this integrated. |
...fascinatingly, my branch locally has no pending changes and even after a make distclean and configure, builds. I wonder what's going on. |
f10c4c4
to
0c564c2
Compare
Not really sure what happened, but a fresh clone from the repo into a new dir and the same configure+make breaks as in the repo, now, so that was simple to debug. |
Strange, but this looks good to me as long as the CI is happy this time around. |
0c564c2
to
87cdaae
Compare
I think this is good to go and the centos 7 failure is unrelated. I just squashed the two fix commits and pushed to see what happens. |
The FBSD tests seem to be the same failure described in #15934, the CentOS 9 tests seem to be bclone broken for every PR atm, and the others seem to be flaky tests, I think? Someone check me, by all means, but they all seem to be unrelated to this change. |
@rincebrain can I talk you one to one last rebase, then we can get this merged. |
Being able to print custom debug information on assert trip seems useful. Signed-off-by: Rich Ercolani <rincebrain@gmail.com>
Being able to print custom debug information on assert trip seems useful. Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov> Reviewed-by: Paul Dagnelie <pcd@delphix.com> Signed-off-by: Rich Ercolani <rincebrain@gmail.com> Closes openzfs#15792
Being able to print custom debug information on assert trip seems useful. Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov> Reviewed-by: Paul Dagnelie <pcd@delphix.com> Signed-off-by: Rich Ercolani <rincebrain@gmail.com> Closes openzfs#15792
Motivation and Context
(Recreated because it wouldn't let me reopen #14466.)
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 (because ASSERT normally grounds out in((void) x)
on non-DEBUG builds), 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
Checklist:
Signed-off-by
.