Hi! I am trying to dtrace dtrace itself and understand what happens when a D function call is make. So, here is a simple script I am trying to trace: #!/usr/sbin/dtrace dtrace:::BEGIN { printf("%d\n",strlen("123456")); } I have managed to trace the function calls, but I want to know more about the arguments. Here is my dtrace dtracing script: #!/usr/sbin/dtrace -qs #pragma D option flowindent pid$1:libdtrace.so.1:dt_idcook_func:entry { self->trace = 1; } pid$1:libdtrace.so.1::entry, pid$1:libdtrace.so.1::return /self->trace/ { printf("%s\n", curlwpsinfo->pr_syscall ? "K" : "U"); } pid$1:libdtrace.so.1:dt_idcook_func:entry /self->trace/ { printf("%s\n", args[1]->di_name); } pid$1:libdtrace.so.1:dt_idcook_func:return /self->trace/ { self->trace = 0; } dt_idcook_func''s second argument is a dt_ident_t struct, which has a di_name member. When running the "strlen script" above dt_idcook_func is called 41 times, I want to find out why. When I try to run the dtrace tracing script: dtrace: failed to compile script ./tracer.d: line 19: index 1 is out of range for pid103366:libdtrace.so.1:dt_idcook_func:entry args[ ] And by the way args[0] is out of range too. What am I doing wrong? Do I have to include some dtrace source header files? Peter
Peter, This error message is overloaded. In addition to meaning that you''ve strayed outside the bounds of an existing args array, it also means you''ve strayed outside the bounds of a non-existent args array. In other words, in this case, there is no index that is in bounds. fbt probes, SDT based probes, and USDT based probes all define the args array upon clause entry, but the pid provider does not. You''ll need to use the arg0, arg1, ... 64-bit integers and cast them. Chip Peter Boros wrote:> Hi! > > I am trying to dtrace dtrace itself and understand what happens when a D > function call is make. So, here is a simple script I am trying to trace: > #!/usr/sbin/dtrace > dtrace:::BEGIN > { > printf("%d\n",strlen("123456")); > } > > I have managed to trace the function calls, but I want to know more > about the arguments. Here is my dtrace dtracing script: > #!/usr/sbin/dtrace -qs > #pragma D option flowindent > > pid$1:libdtrace.so.1:dt_idcook_func:entry > { > self->trace = 1; > } > > pid$1:libdtrace.so.1::entry, > pid$1:libdtrace.so.1::return > /self->trace/ > { > printf("%s\n", curlwpsinfo->pr_syscall ? "K" : "U"); > } > > pid$1:libdtrace.so.1:dt_idcook_func:entry > /self->trace/ > { > printf("%s\n", args[1]->di_name); > } > > pid$1:libdtrace.so.1:dt_idcook_func:return > /self->trace/ > { > self->trace = 0; > } > > dt_idcook_func''s second argument is a dt_ident_t struct, which has a > di_name member. When running the "strlen script" above dt_idcook_func is > called 41 times, I want to find out why. When I try to run the dtrace > tracing script: > dtrace: failed to compile script ./tracer.d: line 19: index 1 is out of > range for pid103366:libdtrace.so.1:dt_idcook_func:entry args[ ] > > And by the way args[0] is out of range too. What am I doing wrong? > Do I have to include some dtrace source header files? > > Peter > > _______________________________________________ > dtrace-discuss mailing list > dtrace-discuss at opensolaris.org >
Hi! How can I cast this correctly? I tried (dt_ident_t *) arg1, but I got an error message that arg1 is not a pointer. Peter On Tue, 2006-12-05 at 12:47 -0600, Chip Bennett wrote:> Peter, > > This error message is overloaded. In addition to meaning that you''ve > strayed outside the bounds of an existing args array, it also means > you''ve strayed outside the bounds of a non-existent args array. In > other words, in this case, there is no index that is in bounds. > > fbt probes, SDT based probes, and USDT based probes all define the args > array upon clause entry, but the pid provider does not. You''ll need to > use the arg0, arg1, ... 64-bit integers and cast them. > > Chip > > Peter Boros wrote: > > Hi! > > > > I am trying to dtrace dtrace itself and understand what happens when a D > > function call is make. So, here is a simple script I am trying to trace: > > #!/usr/sbin/dtrace > > dtrace:::BEGIN > > { > > printf("%d\n",strlen("123456")); > > } > > > > I have managed to trace the function calls, but I want to know more > > about the arguments. Here is my dtrace dtracing script: > > #!/usr/sbin/dtrace -qs > > #pragma D option flowindent > > > > pid$1:libdtrace.so.1:dt_idcook_func:entry > > { > > self->trace = 1; > > } > > > > pid$1:libdtrace.so.1::entry, > > pid$1:libdtrace.so.1::return > > /self->trace/ > > { > > printf("%s\n", curlwpsinfo->pr_syscall ? "K" : "U"); > > } > > > > pid$1:libdtrace.so.1:dt_idcook_func:entry > > /self->trace/ > > { > > printf("%s\n", args[1]->di_name); > > } > > > > pid$1:libdtrace.so.1:dt_idcook_func:return > > /self->trace/ > > { > > self->trace = 0; > > } > > > > dt_idcook_func''s second argument is a dt_ident_t struct, which has a > > di_name member. When running the "strlen script" above dt_idcook_func is > > called 41 times, I want to find out why. When I try to run the dtrace > > tracing script: > > dtrace: failed to compile script ./tracer.d: line 19: index 1 is out of > > range for pid103366:libdtrace.so.1:dt_idcook_func:entry args[ ] > > > > And by the way args[0] is out of range too. What am I doing wrong? > > Do I have to include some dtrace source header files? > > > > Peter > > > > _______________________________________________ > > dtrace-discuss mailing list > > dtrace-discuss at opensolaris.org > > >
> Hi! > > I am trying to dtrace dtrace itself and understand what happens when a D > function call is make. So, here is a simple script I am trying to trace: > #!/usr/sbin/dtrace > dtrace:::BEGIN > { > printf("%d\n",strlen("123456")); > } > > I have managed to trace the function calls, but I want to know more > about the arguments. Here is my dtrace dtracing script: > #!/usr/sbin/dtrace -qs > #pragma D option flowindent > > pid$1:libdtrace.so.1:dt_idcook_func:entry > { > self->trace = 1; > } > > pid$1:libdtrace.so.1::entry, > pid$1:libdtrace.so.1::return > /self->trace/ > { > printf("%s\n", curlwpsinfo->pr_syscall ? "K" : "U"); > } > > pid$1:libdtrace.so.1:dt_idcook_func:entry > /self->trace/ > { > printf("%s\n", args[1]->di_name); > } > > pid$1:libdtrace.so.1:dt_idcook_func:return > /self->trace/ > { > self->trace = 0; > } > > dt_idcook_func''s second argument is a dt_ident_t struct, which has a > di_name member. When running the "strlen script" above dt_idcook_func is > called 41 times, I want to find out why. When I try to run the dtrace > tracing script: > dtrace: failed to compile script ./tracer.d: line 19: index 1 is out of > range for pid103366:libdtrace.so.1:dt_idcook_func:entry args[ ] > > And by the way args[0] is out of range too. What am I doing wrong? > Do I have to include some dtrace source header files? > > PeterDTrace does not yet automatically include userland type information when using the pid provider. So you need to #include the necessary headers and use -C with your script. You will also need to use copyin() to access the relevant userland data structures. Alternately, if you''re trying to understand the compiler source code in libdtrace, feel free to just e-mail your question to the alias and we''ll answer it. -Mike -- Mike Shapiro, Solaris Kernel Development. blogs.sun.com/mws/
Hi Peter, While libdtrace (and all ON libraries) are built with CTF (type) data, DTrace can''t currently use it. You may be able to work around this by including the header files from the libdtrace source code. Adam On Wed, Dec 06, 2006 at 06:51:51PM +0100, Peter Boros wrote:> Hi! > > How can I cast this correctly? I tried (dt_ident_t *) arg1, but I got an > error message that arg1 is not a pointer. > > Peter > > On Tue, 2006-12-05 at 12:47 -0600, Chip Bennett wrote: > > Peter, > > > > This error message is overloaded. In addition to meaning that you''ve > > strayed outside the bounds of an existing args array, it also means > > you''ve strayed outside the bounds of a non-existent args array. In > > other words, in this case, there is no index that is in bounds. > > > > fbt probes, SDT based probes, and USDT based probes all define the args > > array upon clause entry, but the pid provider does not. You''ll need to > > use the arg0, arg1, ... 64-bit integers and cast them. > > > > Chip > > > > Peter Boros wrote: > > > Hi! > > > > > > I am trying to dtrace dtrace itself and understand what happens when a D > > > function call is make. So, here is a simple script I am trying to trace: > > > #!/usr/sbin/dtrace > > > dtrace:::BEGIN > > > { > > > printf("%d\n",strlen("123456")); > > > } > > > > > > I have managed to trace the function calls, but I want to know more > > > about the arguments. Here is my dtrace dtracing script: > > > #!/usr/sbin/dtrace -qs > > > #pragma D option flowindent > > > > > > pid$1:libdtrace.so.1:dt_idcook_func:entry > > > { > > > self->trace = 1; > > > } > > > > > > pid$1:libdtrace.so.1::entry, > > > pid$1:libdtrace.so.1::return > > > /self->trace/ > > > { > > > printf("%s\n", curlwpsinfo->pr_syscall ? "K" : "U"); > > > } > > > > > > pid$1:libdtrace.so.1:dt_idcook_func:entry > > > /self->trace/ > > > { > > > printf("%s\n", args[1]->di_name); > > > } > > > > > > pid$1:libdtrace.so.1:dt_idcook_func:return > > > /self->trace/ > > > { > > > self->trace = 0; > > > } > > > > > > dt_idcook_func''s second argument is a dt_ident_t struct, which has a > > > di_name member. When running the "strlen script" above dt_idcook_func is > > > called 41 times, I want to find out why. When I try to run the dtrace > > > tracing script: > > > dtrace: failed to compile script ./tracer.d: line 19: index 1 is out of > > > range for pid103366:libdtrace.so.1:dt_idcook_func:entry args[ ] > > > > > > And by the way args[0] is out of range too. What am I doing wrong? > > > Do I have to include some dtrace source header files? > > > > > > Peter > > > > > > _______________________________________________ > > > dtrace-discuss mailing list > > > dtrace-discuss at opensolaris.org > > > > > > > _______________________________________________ > dtrace-discuss mailing list > dtrace-discuss at opensolaris.org-- Adam Leventhal, Solaris Kernel Development http://blogs.sun.com/ahl