In order to print the arguments to a syscall probe, I''m having to hard code the processing in advance. Although what I really want is a to_string() function that "does the right thing", I was wondering if I could hack something up using the ?: operator. If I had a way to find out the type of an arg[] entry, I could process it differently, depending on whether it was a string or a number. Sadly, I don''t see anything of this sort. Help? -r -- http://www.cfcl.com/rdm Rich Morin http://www.cfcl.com/rdm/resume rdm at cfcl.com http://www.cfcl.com/rdm/weblog +1 650-873-7841 Technical editing and writing, programming, and web development
Mike Shapiro
2007-Dec-22 22:15 UTC
[dtrace-discuss] determining the type of arg[] entries?
On Sat, Dec 22, 2007 at 02:09:47PM -0800, Rich Morin wrote:> In order to print the arguments to a syscall probe, I''m having > to hard code the processing in advance. Although what I really > want is a to_string() function that "does the right thing", I > was wondering if I could hack something up using the ?: operator. > > If I had a way to find out the type of an arg[] entry, I could > process it differently, depending on whether it was a string or > a number. Sadly, I don''t see anything of this sort. Help? > > -rargs[] provides the proper types automatically when the provider describes the types, but we haven''t done that for syscall yet. There are a couple of problems to be solved there: (a) a canonical description of the syscall types (b) support for sub-sys calls as part of syscall We could also provide the magic to_string(), but I would consider that dependent to the above -- it would have to be able to reliably know the args[] types in order to work. Sorry we don''t have a better answer yet. At the moment, your best bet is simply trace(), which does include a simple heuristic for formatting the data appropriately: # dtrace -s /dev/stdin BEGIN { trace(3); trace("hello"); trace(`kmem_flags); } ^D dtrace: script ''/dev/stdin'' matched 1 probe CPU ID FUNCTION:NAME 1 1 :BEGIN 3 hello 15 but of course unlike printf you can''t control the output. -Mike -- Mike Shapiro, Solaris Kernel Development. blogs.sun.com/mws/