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 | |
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')
-rwxr-xr-x | src/build/debug/Hostboot/AutoIpl.pm | 165 | ||||
-rwxr-xr-x | src/build/debug/Hostboot/ContTrace.pm | 128 | ||||
-rwxr-xr-x | src/build/debug/vpo-debug-framework.pl | 77 |
3 files changed, 367 insertions, 3 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."], + }, + ); +} diff --git a/src/build/debug/vpo-debug-framework.pl b/src/build/debug/vpo-debug-framework.pl index 244c834b5..713b35ebd 100755 --- a/src/build/debug/vpo-debug-framework.pl +++ b/src/build/debug/vpo-debug-framework.pl @@ -55,6 +55,7 @@ my %optionInfo = ( "directory instead of using this option."], "--out-path=<path>" => ["The path to the directory where the output will be saved."], "--debug" => ["Enable debug tracing."], + "--mute" => ["Shut up the 'Data saved ...' message"], "-k#" => ["The cage to act on."], "-n#" => ["The node to act on."], "-s#" => ["The slot to act on."], @@ -76,6 +77,7 @@ my $cfgHelp = 0; my $cfgMan = 0; my $toolHelp = 0; my $debug = 0; +my $mute = 0; my @ecmdOpt = ("-c3"); my @threadState = (); my $l2Flushed = 0; @@ -102,6 +104,7 @@ if ($self) "img-path:s" => \$imgPath, "out-path:s" => \$outPath, "debug" => \$debug, + "mute" => \$mute, "help" => \$cfgHelp, "toolhelp" => \$toolHelp, "man" => \$cfgMan, @@ -128,6 +131,7 @@ else "img-path:s" => \$imgPath, "out-path:s" => \$outPath, "debug" => \$debug, + "mute" => \$mute, "help" => \$cfgHelp, "man" => \$cfgMan, "k=i" => \&processEcmdOpts, @@ -178,7 +182,10 @@ callToolModule($tool); # Restore thread states restoreThreadStates(); -print "\n\nData saved to $outFile\n\n"; +if (!$mute) +{ + print "\n\nData saved to $outFile\n\n"; +} # Close the output file close $fh if ($outFile ne ""); @@ -396,7 +403,20 @@ sub startInstructions print "$command\n"; } - die "ERROR: cannot start instructions" if (system("$command") != 0); + if (system("$command") != 0) + { + if (0 == getShutdownRequestStatus()) + { + die "ERROR: cannot start instructions"; + } + else + { + if ($debug) + { + print "Cannot start instructions since Hostboot has shutdown"; + } + } + } #Need to flush L2 the next time we read data from L3 $l2Flushed = 0; @@ -454,6 +474,40 @@ sub restoreThreadStates } } +# @sub CheckXstopAttn +# @brief Check for a checkstop/special attn +# return 1 if checkstop/attn occurs +sub CheckXstopAttn +{ + my $result = `getscom pu 000f001a @ecmdOpt -quiet`; + my $chkstop = 0; + if ($result !~ m/0x[04]000000000000000/) + { + $chkstop = 1; + } + return $chkstop; +} + +# @sub FirCheck +# @brief Check for FIR +sub FirCheck +{ + my $result = `fircheck @ecmdOpt -quiet 2>&1 | head -30`; + $result =~ s/error/ERR*R/gi; + $result =~ s/FAIL/F*IL/g; + $result =~ s/.*00 SIMDISP.*\n//g; + $result =~ s/.*CNFG FILE GLOBAL_DEBUG.*\n//g; + print "$result\n"; +} + +# @sub getCIA +# @brief return CIA +sub getCIA +{ + my $cia = `getspy pu EX03.EC.IFU.I.T0_CIA -quiet | paste - -`; + return $cia; +} + # @sub executeInstrCycles # @brief Tell the simulator to run for so many clock cycles sub executeInstrCycles @@ -471,7 +525,11 @@ sub executeInstrCycles my $cycles = shift; $cycles = $cycles * 100; #increase cycles since VBU takes longer my $command = "simclock $cycles $flag"; - print "$command\n"; + my $noshow = shift; + if (!$noshow) + { + print "$command\n"; + } die "ERROR: cannot run clock cycles" if (system("$command") != 0); } @@ -484,6 +542,19 @@ sub readyForInstructions return 1; } +# @sub getShutdownRequestStatus +# @brief Check whether shutdown has been requested +# @returns 0 - Shutdown not requested or 1 - Shutdown requested +sub getShutdownRequestStatus +{ + my ($symAddr, $symSize) = findSymbolAddress("CpuManager::cv_shutdown_requested"); + if (not defined $symAddr) { print "Cannot find symbol.\n"; die; } + my $result = readData($symAddr, $symSize); + $result= hex (unpack('H*',$result)); + + return $result; +} + # @sub getImgPath # # Return file-system path to .../img/ subdirectory containing debug files. |