Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.server -> Perl program to decode memory dump to timestamps in 10046 trace files.
While working a problem recently I needed to
look at some bind values to a TIMESTAMP(3) variable, and
found that Oracle doesn't print these directly. Instead
what you get is a few lines identifying the variable as
a TIMESTAMP (dty=180), and a dump of three memory
locations, e.g.
bind 2: dty=180 mxl=11(11) mal=00 scl=00 pre=00 oacflg=01 oacfl2=0 size=0 offset=48
bfp=0bbeea10 bln=11 avl=11 flg=01
value=
Dump of memory from 0x0BBEEA10 to 0x0BBEEA1B
BBEEA10 1F0CA977 00010111 0040420F [w........B@.]
bind 3: dty=180 mxl=11(11) mal=00 scl=00 pre=00 oacflg=01 oacfl2=0
size=0 offset=60
bfp=0bbeea1c bln=11 avl=11 flg=01
value=
Dump of memory from 0x0BBEEA1C to 0x0BBEEA27
BBEEA10 13096A78 [xj..] BBEEA20 070D0112 00C0D454 [....T...]
I wrote a short perl program to decode this into the timstamp value. I've not done much perl programming so the program is probably not as ugly, squirrelly or recondite as it should be, so feel free to criticise or (especially) improve it. You simply give the program three doubleword hex arguments, and it will decode this as a timestamp, according to Note 376618.1. The program does some simple checking to see if you have passed three 8-character strings to it, but does not check that the arguments are hex (though you will get a warning when the hex() function is invoked if this is not the case).
Usage is:
db-plog1na-b-r2.iad5$ perl mem2ts.pl 0c076a78 3414340a 00c08bde
Timestamp is: 19 Sep 2006 17:00:12.123000000
Hope you find it useful. It's probably not something that you'd need often, but if you do need it, as I did, it can save a ton of time.
James Petts
#!/opt/third-party/bin/perl
if (@ARGV==0) {die "Usage: mem2ts.pl <hex doubleword> <hex
doubleword> <hex doubleword>\n"}
@months=("Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec");
&check_args;
my($dy,$mo,$yr,$cy)=map{hex$_}$ARGV[0]=~/(..)(..)(..)(..)/; my($fs0,$ss,$mi,$hr)=map{hex$_}$ARGV[1]=~/(..)(..)(..)(..)/; my($blah,$fs3,$fs2,$fs1)=map{hex$_}$ARGV[2]=~/(..)(..)(..)(..)/;$tsfrac=hex(substr($ARGV[1],0,2).substr($ARGV[2],6,2).substr($ARGV[2],4,2).substr($ARGV[2],2,2)); printf "\nTimestamp is: %02d %s %4d
if (@ARGV != 3)
{die "Number of arguments must be 3";}
foreach $i (0.._at_ARGV-1){
if (length($ARGV[$i])!=8) {die "Incorrect length for argument
",$i+1,": got ",length($ARGV[$i]),", should be 8";}
}
}
exit;
Received on Thu Sep 28 2006 - 23:21:37 CDT
![]() |
![]() |