I am learning to use USDT probes. I want to have an address argument which I''ll then print with %A and know what this address is. here is a trivial C program: #include <stdio.h> #include <sys/sdt.h> int foo = 5; int main(int argc, char *argv[]) { int c; while ((c = getchar()) != EOF) { DTRACE_PROBE2(dserv, put, c, &foo); putchar(c); } } And its provider part: provider dserv { probe put(int, int*); }; An attempt to use %A gives: $ dtrace -n ''dserv18310:::{printf("%c %A", args[0], (uintptr_t)args[1]);}'' dtrace: invalid probe specifier dserv18310:::{printf("%c %A", args[0], (uintptr_t)args[1]);}: format conversion #2 only valid when target process is specified Using %X works as expected. Am I doing something wrong or it is not possible to get symbolic address of the pointer passed as USDT probe argument? - Alexander Kolbasov
On Fri, Sep 02, 2005 at 12:25:45PM -0700, Alexander Kolbasov wrote:> I am learning to use USDT probes. I want to have an address argument which > I''ll then print with %A and know what this address is. > > here is a trivial C program: > > #include <stdio.h> > #include <sys/sdt.h> > > int foo = 5; > > int main(int argc, char *argv[]) > { > int c; > > while ((c = getchar()) != EOF) { > DTRACE_PROBE2(dserv, put, c, &foo); > putchar(c); > } > } > > And its provider part: > > provider dserv { > probe put(int, int*); > }; > > An attempt to use %A gives: > > $ dtrace -n ''dserv18310:::{printf("%c %A", args[0], (uintptr_t)args[1]);}'' > dtrace: invalid probe specifier dserv18310:::{printf("%c %A", args[0], (uintptr_t)args[1]);}: format conversion #2 only valid when target process is specified > > Using %X works as expected. > > Am I doing something wrong or it is not possible to get symbolic address of > the pointer passed as USDT probe argument?As the error message states, you have to specify a process with ''-p'' (or start one with ''-c'') for %A to work. Try: % dtrace -p 18310 -n ''dserv$target:::{printf("%c %A", args[0], (uintptr_t)args[1]);}'' Cheers, - jonathan -- Jonathan Adams, Solaris Kernel Development
> > $ dtrace -n ''dserv18310:::{printf("%c %A", args[0], (uintptr_t)args[1]);}'' > > dtrace: invalid probe specifier dserv18310:::{printf("%c %A", args[0], (uintptr_t)args[1]);}: format conversion #2 only valid when target process is specified > As the error message states, you have to specify a process with ''-p'' (or start > one with ''-c'') for %A to work. Try: > > % dtrace -p 18310 -n ''dserv$target:::{printf("%c %A", args[0], (uintptr_t)args[1]);}''This works, thanks!