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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
|
#!/usr/bin/perl
# IBM_PROLOG_BEGIN_TAG
# This is an automatically generated prolog.
#
# $Source: src/build/debug/Hostboot/ContTrace.pm $
#
# IBM CONFIDENTIAL
#
# COPYRIGHT International Business Machines Corp. 2012
#
# p1
#
# Object Code Only (OCO) source materials
# Licensed Internal Code Source Materials
# IBM HostBoot Licensed Internal Code
#
# The source code for this program is not published or other-
# wise divested of its trade secrets, irrespective of what has
# been deposited with the U.S. Copyright Office.
#
# Origin: 30
#
# IBM_PROLOG_END_TAG
use strict;
package Hostboot::ContTrace;
use Exporter;
our @EXPORT_OK = ('main');
use constant CONT_TRACE_ENABLE_FLAG_OFFSET => 0;
use constant CONT_TRACE_BUFFER_SIZE => CONT_TRACE_ENABLE_FLAG_OFFSET + 2;
use constant CONT_TRACE_BUFFER_ADDR => CONT_TRACE_BUFFER_SIZE + 6;
use File::Temp ('tempfile');
sub main
{
my ($packName,$args) = @_;
#::userDisplay("args fsp-trace ".$args->{"fsp-trace"}."\n");
#::userDisplay("args with-file-names ".$args->{"with-file-names"}."\n");
if (not defined $args->{"fsp-trace"})
{
$args->{"fsp-trace"} = "fsp-trace";
}
my $dbgMsg = 0;
if (defined $args->{"debug"})
{
$dbgMsg = 1;
}
my $fsptrace_options = "";
if (defined $args->{"with-file-names"})
{
$fsptrace_options = $fsptrace_options."-f ";
}
my $symAddr = 0;
my $symSize = 0;
($symAddr, $symSize) = ::findSymbolAddress("TRACE::g_debugSettings");
if (not defined $symAddr)
{
::userDisplay "Cannot find symbol: TRACE::g_debugSettings.\n"; die;
}
if (defined $args->{"enable-cont-trace"})
{
my $new_enable = $args->{"enable-cont-trace"};
$new_enable = $new_enable ? 2 : 1;
my $enable = ::read8($symAddr + CONT_TRACE_ENABLE_FLAG_OFFSET);
if ($dbgMsg)
{
::userDisplay("current Cont Trace Enable Flag = $enable\n");
}
if (($enable < 2) && ($new_enable == 2))
{
# truncate tracMERG to 0
system( "cp /dev/null tracMERG" );
}
::write8($symAddr + CONT_TRACE_ENABLE_FLAG_OFFSET, $new_enable);
if ($dbgMsg)
{
$new_enable = ::read8($symAddr+CONT_TRACE_ENABLE_FLAG_OFFSET);
::userDisplay("new Cont Trace Enable Flag = $new_enable\n");
}
return;
}
my $trigger = ::readScom(0x00050038,8);
if ($dbgMsg)
{
::userDisplay("$trigger...\n");
my $cycles = `simgetcurrentcycle`;
$cycles =~ s/\n//g;
$cycles =~ s/.*is ([0-9]*).*/$1/g;
::userDisplay("$cycles\n");
$cycles = `date`;
::userDisplay("$cycles");
}
if (0 == $trigger)
{
if ($dbgMsg)
{
::userDisplay("No new trace to gather.\n");
}
return;
}
my $fh;
my $fname;
($fh,$fname) = tempfile();
binmode($fh);
my $buffAddr = ::read64($symAddr + CONT_TRACE_BUFFER_ADDR);
my $buffSize = ::read16($symAddr + CONT_TRACE_BUFFER_SIZE);
print $fh (::readData($buffAddr, $buffSize));
if ($dbgMsg)
{
my $cycles = `simgetcurrentcycle`;
$cycles =~ s/\n//g;
$cycles =~ s/.*is ([0-9]*).*/$1/g;
::userDisplay("$cycles\n");
}
::writeScom(0x00050038, 8, 0x0);
open TRACE, ($args->{"fsp-trace"}." -s ".::getImgPath().
"hbotStringFile $fsptrace_options $fname |") || die;
while (my $line = <TRACE>)
{
::userDisplay $line;
}
unlink $fname;
if ($dbgMsg)
{
my $cycles = `date`;
::userDisplay("$cycles");
}
}
sub helpInfo
{
my %info = (
name => "ContTrace",
intro => ["Displays the continuous trace buffers."],
options => {
"fsp-trace=<path>" => ["Path to non-default fsp-trace utility."],
"with-file-names" => ["Trace statements will include file name of place the",
"trace was defined."],
"enable-cont-trace=<1|0>" => ["Turn on|off continuous trace"],
"debug" => ["Turn on debug messages"],
}
);
}
|