At 19:17 -0500 3/9/08, Chip Bennett wrote: > Rich Morin wrote: >> >> Of course, there are some complications. For example, >> DTrace isn't equipped with string-handling facilities, >> so it can be hard to generate output that can be parsed >> reliably. >> > > Unless I'm misunderstanding what you mean here (a real > possibility), DTrace has plenty of string handling > capability in the form of real string variables (as > opposed to C's character arrays), "str*" functions, > and a fully functional printf action. ...
Well, I'd be delighted to learn some new DTrace tricks; please let me know if I'm missing anything... When I looked into generating YAML (http://www.yaml.org) from probes, I was stymied by the problem of "escaping" the inevitable oddball characters that might show up in string values. IIRC, C strings can contain anything but zeroes, but control characters, quotes, and such aren't going to pass smoothly through a typical YAML parser. Languages such as Perl and Ruby have all sorts of string manipulation tools that will let me do percent-encoding, etc. However, I don't see any equivalent functionality in DTrace. Also, there is an argument to be made that I shouldn't do (expensive) string operations in probes. -r P.S. My workaround was to use counted strings, as: # 0 # 123456789 12345 cwd=15'Idiot's delight' Because DTrace will tell me the length of an arbitrary string, I can easily print something like this: printf("cwd=%d'%s'\n", len, cwd) The parsing code has to handle embedded newlines in an incoming text string, but the count tells it what it needs to know (and the closing quote allows a bit of sanity checking). -- http://www.cfcl.com/rdm Rich Morin http://www.cfcl.com/rdm/resume [EMAIL PROTECTED] http://www.cfcl.com/rdm/weblog +1 650-873-7841 Technical editing and writing, programming, and web development _______________________________________________ dtrace-discuss mailing list [email protected]
