convert 'truss' timestamp
Maybe I reinvented the wheel. Here's quick&dirty perl to convert 'truss -df' output. Unfortunately, this doesn't work if only "-d" is given. Here's how this works:
I hope this isn't necessary with truss on OpenSolaris. Linux's strace can do this. So, I think this has been on enhancement list. Here's perl.
$ truss -df cat Base time stamp: 1238745134.0279 [ Fri Apr 3 16:52:14 JST 2009 ] 16881: 0.0000 execve("/usr/bin/cat", 0xFFBFFDC4, 0xFFBFFDCC) argc = 1 16881: 0.0051 resolvepath("/usr/lib/ld.so.1", "/lib/ld.so.1", 1023) = 12 16881: 0.0055 resolvepath("/usr/bin/cat", "/usr/bin/cat", 1023) = 12 16881: 0.0058 stat("/usr/bin/cat", 0xFFBFFBA0) = 0 [...] $ truss -d -f cat 2>&1 | ~kinoue/trusstimestamp.pl Base time stamp: 1238745453.9931 [ Fri Apr 3 16:57:33 JST 2009 ] 16895: 16:57:33.9931 execve("/usr/bin/cat", 0xFFBFFDC4, 0xFFBFFDCC) argc = 1 16895: 16:57:33.9996 resolvepath("/usr/lib/ld.so.1", "/lib/ld.so.1", 1023) = 12 16895: 16:57:34.0018 resolvepath("/usr/bin/cat", "/usr/bin/cat", 1023) = 12 16895: 16:57:34.0024 stat("/usr/bin/cat", 0xFFBFFBA0) = 0 [...]
I hope this isn't necessary with truss on OpenSolaris. Linux's strace can do this. So, I think this has been on enhancement list. Here's perl.
#!/usr/bin/env perl
line: while (<>) {
if ($. == 1) {
@Fld = split(' ', $_, -1);
$base = $Fld[3];
print $_;
next line;
}
if (m/^([0-9\/]*:[\t ]*)([0-9.]*)([\t ].*)$/o) {
unless ($2) {
print $_;
next line;
}
my $seconds = $base + $2;
($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime($seconds);
$subsec = substr($seconds, index($seconds, '.'));
printf ("%s%02d:%02d:%02d%s %s\n",$1,$hour,$min,$sec,$subsec,$3);
next line;
}
}