-
-
Notifications
You must be signed in to change notification settings - Fork 1
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
variadic an idea #29
Comments
I wasn't aware of these builtins, looks like perfect forwarding is possible after all. However I'm still not sure how you would use |
Just published a new version that incorporates the GCC builtins to forward the variadic arguments instead of ignoring them. This allows you to provide variadic stubs. For now the variadic arguments are not recorded in |
Nice additions! I've outlined a rough sketch of how one could gather the variable arguments. This restricts the captured types to <= 64 bits. If this is too narrow then one could use a dummy struct instead. struct narmock_vargs_capture_type {
uint64_t a,b,c,d;
}; |
Just revised the last idea a bit. Instead of using |
The idea of using a printf-like format string is interesting. Instead of parsing formatting syntax manually maybe it's worth considering just forwarding the arguments to Of course your proposal looks pretty good but I just need to experiment a bit with it. I'm also thinking about something more structured: int a;
int b;
int c;
MOCK(sum_variadic)
->mock_implementation(fake_sum_variadic1)
->capture_variadic()
->arg_int(&a)
->arg_int(&b)
->arg_int(&c);
sum_variadic(3, &value, 1, 2, 3);
ASSERT_EQ(a, 1);
ASSERT_EQ(b, 2);
ASSERT_EQ(c, 3); I also wonder if instead of setting up a static variadic capture you could have something like I'm gonna try to play with some of these concepts later. |
Hi
I've been toying around with how to get variadic functions working.
It uses the gcc builtin in functions (https://gcc.gnu.org/onlinedocs/gcc-4.1.2/gcc/Constructing-Calls.html) to forward the call.
A hacked together example for ioctl can be seen here: https://gist.github.com/Munken/df6828e275e128a8174c6e5851776a4d
This could be combined with something like:
The
__wrap_xxx
would then useva_start
,va_arg
andva_end
to capture the varargs into an array.The text was updated successfully, but these errors were encountered: