[DTrace-devel] [PATCH 10/12] Add support for copyin() subroutine
Kris Van Hees
kris.van.hees at oracle.com
Thu Jul 21 21:04:30 UTC 2022
On Thu, Jul 21, 2022 at 11:49:21AM -0700, Eugene Loh wrote:
> On 7/21/22 13:03, Kris Van Hees wrote:
>
> > On Thu, Jul 21, 2022 at 11:08:45AM -0700, Eugene Loh via DTrace-devel wrote:
> > > Reviewed-by: Eugene Loh <eugene.loh at oracle.com>
> > > On 7/13/22 12:17, Kris Van Hees via DTrace-devel wrote:
> > > > diff --git a/test/unittest/funcs/copyin/tst.copyin.d b/test/unittest/funcs/copyin/tst.copyin.d
> > > > new file mode 100644
> > > The test test/unittest/funcs/copyin/tst.copyin.d should ideally check the
> > > output. I know it's hard, but the test is kind of toothless otherwise.
> > Well, yes and no. The main point we're testing here is that we *can* read
> > the data. I would like to come up with a test where I can also verify the
> > correctness of the data but thus far I have not found a truly reproducible
> > way for doing that.
> How about something like this?
Hm, yes, good point. And I can actually do it without a trigger even I think.
Your example prompted me to check definitively where syscall arguments get
copied to kernel memory before presenting them to us as a probe argument, but
indeed they are not. So yes, we can test it this way in a reliable manner.
Thanks!
> $ cat a.c
> #include <stdio.h>
> #include <string.h>
>
> #include <sys/types.h> /* open */
> #include <sys/stat.h>
> #include <fcntl.h>
>
> #include <unistd.h> /* write */
>
> int main(int c, char **v) {
> char *s = "hello world, how are you?";
> int fd = open("/dev/null", O_WRONLY);
>
> write(fd, s, strlen(s));
> close(fd);
>
> return 0;
> }
>
> # dtrace -c ./a.out -qn 'syscall::write:entry /pid == $target/ {
> printf("'%s'", (string)copyin(arg1, 256)); }'
> hello world, how are you?
More information about the DTrace-devel
mailing list