diff options
| author | Van Lee <vanlee@us.ibm.com> | 2012-02-27 11:55:51 -0600 |
|---|---|---|
| committer | A. Patrick Williams III <iawillia@us.ibm.com> | 2012-03-06 10:57:32 -0600 |
| commit | c556e10089a39c5fbb67073c4355c0a9d0981920 (patch) | |
| tree | 237e6f808cd6738e066ae0f570cc1e6e00ed3485 /src/build/debug/Hostboot | |
| parent | f538d4cbe355a98be2675468da6f3a24078893e8 (diff) | |
| download | talos-hostboot-c556e10089a39c5fbb67073c4355c0a9d0981920.tar.gz talos-hostboot-c556e10089a39c5fbb67073c4355c0a9d0981920.zip | |
Tool scripts to support VBU/VPO continuous trace - RTC37669
Change-Id: Ibc692313f145038d4d614e12a2fe63b23e46de0b
Reviewed-on: http://gfw160.austin.ibm.com:8080/gerrit/697
Tested-by: Jenkins Server
Reviewed-by: CAMVAN T. NGUYEN <ctnguyen@us.ibm.com>
Reviewed-by: A. Patrick Williams III <iawillia@us.ibm.com>
Diffstat (limited to 'src/build/debug/Hostboot')
| -rwxr-xr-x | src/build/debug/Hostboot/AutoIpl.pm | 165 | ||||
| -rwxr-xr-x | src/build/debug/Hostboot/ContTrace.pm | 128 |
2 files changed, 293 insertions, 0 deletions
diff --git a/src/build/debug/Hostboot/AutoIpl.pm b/src/build/debug/Hostboot/AutoIpl.pm new file mode 100755 index 000000000..6c1227e81 --- /dev/null +++ b/src/build/debug/Hostboot/AutoIpl.pm @@ -0,0 +1,165 @@ +#!/usr/bin/perl + +use strict; + +package Hostboot::AutoIpl; +use Exporter; +our @EXPORT_OK = ('main'); + +use constant PRINTK_SAMPLING => 50; +use constant NUM_CLOCK_CYCLES => 25000; +use constant MAX_NUM_CONT_TRACE_CTL_STRUCT => 2; +use constant CONT_TRACE_CTL_STRUCT_SIZE => 16; +use constant CONT_TRACE_DISABLE_FLAG_OFFSET => MAX_NUM_CONT_TRACE_CTL_STRUCT * CONT_TRACE_CTL_STRUCT_SIZE; + +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"); + #userDisplay("args num-clk-cycles ".$args->{"num-clk-cycles"}."\n"); + + # Ensure environment is in the proper state for running instructions. + if (!::readyForInstructions()) + { + ::userDisplay "Cannot execute while unable to run instructions.\n"; + return; + } + + # retrieve the Information of the Continous Trace Trigger Info structure + my ($symAddr, $symSize) = + ::findSymbolAddress("TRACE::g_cont_trace_trigger_info"); + if (not defined $symAddr) + { + ::userDisplay "Cannot find symbol.\n"; die; + } + + my $disable = 0; + if (defined $args->{"enable-cont-trace"}) + { + #my $disable = ::read64($symAddr + CONT_TRACE_DISABLE_FLAG_OFFSET); + #::userDisplay("Cont Trace Disable Flag read = $disable\n"); + ::write64($symAddr + CONT_TRACE_DISABLE_FLAG_OFFSET, 0); + #$disable = ::read64($symAddr + CONT_TRACE_DISABLE_FLAG_OFFSET); + #::userDisplay("Cont Trace Disable Flag after reset = $disable\n"); + # truncate tracMERG to 0 + system( "cp /dev/null tracMERG" ); + return; + } + else + { + my $disable = ::read64($symAddr + CONT_TRACE_DISABLE_FLAG_OFFSET); + #::userDisplay("Cont Trace Disable Flag after reset = $disable\n"); + } + + # set the number of clock cycles + my $cycles = NUM_CLOCK_CYCLES; + if (defined $args->{"num-clk-cycles"}) + { + $cycles = $args->{"num-clk-cycles"}; + } + + # Check if shutdown has been requested + my $result = ::getShutdownRequestStatus(); + #::userDisplay("shutdown requested: $result\n"); + + if ($result) + { + ::userDisplay("Shutdown has been reported.\n"); + return; + } + + # truncate printk.content to 0 + system( "cp /dev/null printk.content" ); + + my $loop = 0; + my $excp = 0; + + while (0 == $result) + { + if ( -e 'STOP' ) + { + return; + } + + if (::CheckXstopAttn() == 1) + { + ::userDisplay("checkstop/attn occur.\n"); + ::FirCheck(); + return; + } + + $loop++; + + # Display printk buffer's unshown messages + if (($loop % PRINTK_SAMPLING) == 0) + { + system("hb-printk --mute > /dev/null"); + system("diff hb-Printk.output printk.content | sed -e 's/< //g' -e '1d'"); + system("mv hb-Printk.output printk.content"); + } + + # run clock cycles + ::executeInstrCycles($cycles,1); + + # Display CIA + my $pc = ::getCIA(); + ::userDisplay("Loop $loop: $pc"); + + # Check for exception + if ($pc =~ m/.*0x0000000000000E4[04]/) + { + $excp++; + if ($excp == 5) + { + ::userDisplay("Trapped in the exception loop.\n"); + return; + } + } + else + { + $excp = 0; + } + + if ($disable == 0) + { + # collect continuous traces + system("hb-ContTrace --mute > /dev/null"); + system("cat hb-ContTrace.output >> tracMERG"); + } + + # check if shutdown has been requested + $result = ::getShutdownRequestStatus(); + #::userDisplay("shutdown requested: $result\n"); + } + + if ($disable == 0) + { + # First, collect continuous traces from any triggered buffer + system("hb-ContTrace --mute > /dev/null"); + system("cat hb-ContTrace.output >> tracMERG"); + # Now, collect the partial continuous traces from untriggered buffer + system("hb-ContTrace --mute --last > /dev/null"); + system("cat hb-ContTrace.output >> tracMERG"); + } + + #::userDisplay("\n\n Hostboot has shutdown\n\n"); + +} + +sub helpInfo +{ + my %info = ( + name => "AutoIpl", + intro => ["IPL Hostboot and collect continuous trace."], + 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."], + "num-clk-cycles=<number>" => ["Number of clock cycles to before collecting traces."], + "enable-cont-trace" => ["Turn on continuous trace"], + }, + ); +} diff --git a/src/build/debug/Hostboot/ContTrace.pm b/src/build/debug/Hostboot/ContTrace.pm new file mode 100755 index 000000000..a9ba5eadb --- /dev/null +++ b/src/build/debug/Hostboot/ContTrace.pm @@ -0,0 +1,128 @@ +#!/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 + +use strict; + +package Hostboot::ContTrace; +use Exporter; +our @EXPORT_OK = ('main'); + +use constant MAX_NUM_CONT_TRACE_BUFFERS => 2; +use constant DDWORD_SIZE => 8; +use constant TRIG_BIT => 0x8000000000000000; + +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"); + #::userDisplay("args last ".$args->{"last"}."\n"); + + if (not defined $args->{"fsp-trace"}) + { + $args->{"fsp-trace"} = "fsp-trace"; + } + + my $fsptrace_options = ""; + if (defined $args->{"with-file-names"}) + { + $fsptrace_options = $fsptrace_options."-f "; + } + + my $last = 0; + if (defined $args->{"last"}) + { + $last = 1; + } + + my ($symAddr, $symSize) = + ::findSymbolAddress("TRACE::g_cont_trace_trigger_info"); + if (not defined $symAddr) { ::userDisplay "Cannot find symbol.\n"; die; } + + my ($fh,$fname) = tempfile(); + binmode($fh); + + # read the g_cont_trace_trigger_info structure + my $result = ::readData($symAddr, $symSize); + + my $addrOff = 0; + my $lenOff = $addrOff + DDWORD_SIZE; + my $foundBuffer = 0; + + for (my $i = 0; $i < MAX_NUM_CONT_TRACE_BUFFERS; $i++) + { + # get the pointer to the continuous trace buffer + my $buffAddr = substr $result, $addrOff, DDWORD_SIZE; + $buffAddr= hex (unpack('H*',$buffAddr)); + my $buffLen = substr $result, $lenOff, DDWORD_SIZE; + $buffLen= hex (unpack('H*',$buffLen)); + #::userDisplay("Trigger [".$i."] = $buffAddr\n"); + #::userDisplay("Length [".$i."] = $buffLen\n"); + + # If trigger bit is set, or last call and buffer has trace data + if ((0 != ($buffAddr & TRIG_BIT)) || (($last == 1) && ($buffLen > 1))) + { + $foundBuffer = 1; + $buffAddr &= ~TRIG_BIT; + print $fh (::readData($buffAddr, $buffLen)); + + # reset trigger bit + ::write64($symAddr + $addrOff, $buffAddr); + + # reset count to 1 + ::write64($symAddr + $lenOff, 1); + } + + # increment to next element in g_cont_trace_trigger_info.triggers[] + $addrOff += (2 * DDWORD_SIZE); + $lenOff = $addrOff + DDWORD_SIZE; + } + + if ($foundBuffer) + { + open TRACE, ($args->{"fsp-trace"}." -s ". + ::getImgPath()."hbotStringFile $fsptrace_options $fname |"); + while (my $line = <TRACE>) + { + ::userDisplay $line; + } + } + +} + +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."], + "last" => ["Shutdown call to offload remaining traces."], + }, + ); +} |

