-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathparse_individual.pl
More file actions
executable file
·58 lines (48 loc) · 1.32 KB
/
parse_individual.pl
File metadata and controls
executable file
·58 lines (48 loc) · 1.32 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#!/usr/bin/perl -w
#
# Part of FPSpy
#
# Copyright (c) 2018 Peter Dinda - see LICENSE
#
$#ARGV==0 or die "usage: parse_individual.pl file\n";
%decode = ( 1 => "FPE_INTDIV",
2 => "FPE_INTOVF",
3 => "FPE_FLTDIV",
4 => "FPE_FLTOVF",
5 => "FPE_FLTUND",
6 => "FPE_FLTRES",
7 => "FPE_FLTINV",
8 => "FPE_FLTSUB",
0xffffffff => "***ABORT!!");
$file = shift;
if ($ENV{FPSPY_ARCH}) {
$myarch=$ENV{FPSPY_ARCH};
} else {
$myarch=`uname -m`; chomp($myarch);
if ($myarch eq "x86_64") { $myarch = "x64";}
if ($myarch eq "aarch64") { $myarch = "arm64";}
if ($myarch eq "riscv64") { $myarch = "riscv64";}
}
open(RAW,'<:raw', $file) or die "Failed to open $file\n";
while (1) {
$n = read(RAW,$rec, 32);
last if ($n!=32);
($time, $rip, $rsp, $code, $mxcsr) = unpack("QQQLL",$rec);
$n = read(RAW,$instr, 15);
last if ($n!=15);
$n = read(RAW,$junk, 1); undef($junk);
last if ($n!=1);
$dec = $decode{$code};
if (!defined($dec)) {
$dec = "UNDEF"
}
if ($myarch eq "x64") {
# captures denorm distinction, but only in
# the fcsr/mxcsr
if (($code != 0xffffffff) && ($mxcsr & 0x2)) {
$dec.="-FPE_DENORM";
}
}
print sprintf("%-16ld\t%s\t%016x\t%016x\t%08x\t%08x\t",$time, $dec, $rip,$rsp,$code,$mxcsr);
print unpack("H*",$instr), "\n";
}