diff options
-rwxr-xr-x | src/build/debug/Hostboot/ContTrace.pm | 172 | ||||
-rw-r--r-- | src/usr/trace/daemon/daemon.C | 14 | ||||
-rw-r--r-- | src/usr/trace/debug.C | 30 | ||||
-rw-r--r-- | src/usr/trace/debug.H | 53 | ||||
-rw-r--r-- | src/usr/trace/makefile | 2 |
5 files changed, 132 insertions, 139 deletions
diff --git a/src/build/debug/Hostboot/ContTrace.pm b/src/build/debug/Hostboot/ContTrace.pm index 516c8eafd..da1b8112d 100755 --- a/src/build/debug/Hostboot/ContTrace.pm +++ b/src/build/debug/Hostboot/ContTrace.pm @@ -27,13 +27,9 @@ package Hostboot::ContTrace; use Exporter; our @EXPORT_OK = ('main'); -use constant MAX_NUM_CONT_TRACE_CTL_STRUCT => 2; -use constant CONT_TRACE_CTL_STRUCT_SIZE => 16; -use constant CONT_TRACE_ENABLE_FLAG_OFFSET => MAX_NUM_CONT_TRACE_CTL_STRUCT * CONT_TRACE_CTL_STRUCT_SIZE; -use constant MAX_NUM_CONT_TRACE_BUFFERS => 2; -use constant DDWORD_SIZE => 8; -use constant WORD_SIZE => 4; -use constant TRIG_BIT => 0x8000000000000000; +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'); @@ -42,7 +38,6 @@ 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"}) { @@ -61,27 +56,21 @@ sub main $fsptrace_options = $fsptrace_options."-f "; } - my $last = 0; - if (defined $args->{"last"}) - { - $last = 1; - } - - my $on2off = 0; 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 : 0; - ($symAddr, $symSize) = - ::findSymbolAddress("TRACE::g_cont_trace_trigger_info"); - if (not defined $symAddr) - { - ::userDisplay "Cannot find symbol.\n"; die; - } - my $enable = ::read64($symAddr + CONT_TRACE_ENABLE_FLAG_OFFSET); + $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"); @@ -90,30 +79,19 @@ sub main { # truncate tracMERG to 0 system( "cp /dev/null tracMERG" ); - ::write64($symAddr + CONT_TRACE_ENABLE_FLAG_OFFSET, $new_enable); - if ($dbgMsg) - { - $new_enable = ::read64($symAddr+CONT_TRACE_ENABLE_FLAG_OFFSET); - ::userDisplay("new Cont Trace Enable Flag = $new_enable\n"); - } - return; - } - elsif (($enable == 2) && ($new_enable == 0)) - { - $on2off = 1; - $last = 0; } - else + + ::write8($symAddr + CONT_TRACE_ENABLE_FLAG_OFFSET, $new_enable); + if ($dbgMsg) { - return; + $new_enable = ::read8($symAddr+CONT_TRACE_ENABLE_FLAG_OFFSET); + ::userDisplay("new Cont Trace Enable Flag = $new_enable\n"); } + + return; } - my $trigger = "simGETFAC B0.C0.S0.P0.E8.TPC.FSI.FSI_MAILBOX.FSXCOMP." . - "FSXLOG.LBUS_MAILBOX.Q_GMB2E0.NLC.L2 32"; - $trigger = `$trigger`; - $trigger =~ s/.*\n0xr(.*)\n.*/$1/g; - $trigger =~ s/\n//g; + my $trigger = ::readScom(0x00050038,8); if ($dbgMsg) { ::userDisplay("$trigger...\n"); @@ -124,81 +102,24 @@ sub main $cycles = `date`; ::userDisplay("$cycles"); } - if (($trigger !~ /[1-9a-fA-F]+/) && ($last == 0)) + if (0 == $trigger) { - if ($on2off) - { - ::write64($symAddr + CONT_TRACE_ENABLE_FLAG_OFFSET, 0); - if ($dbgMsg) - { - $on2off = ::read64($symAddr + CONT_TRACE_ENABLE_FLAG_OFFSET); - ::userDisplay("new Cont Trace Enable Flag = $on2off\n"); - } - } if ($dbgMsg) { - my $cycles = `date`; - ::userDisplay("$cycles"); + ::userDisplay("No new trace to gather.\n"); } return; } - ($symAddr, $symSize) = - ::findSymbolAddress("TRACE::g_cont_trace_trigger_info"); - if (not defined $symAddr) { ::userDisplay "Cannot find symbol.\n"; die; } - - my @fh; - my @fname; - ($fh[0],$fname[0]) = tempfile(); - binmode($fh[0]); - ($fh[1],$fname[1]) = tempfile(); - binmode($fh[1]); + my $fh; + my $fname; + ($fh,$fname) = tempfile(); + binmode($fh); - # read the g_cont_trace_trigger_info structure - my $result = ::readData($symAddr, $symSize); + my $buffAddr = ::read64($symAddr + CONT_TRACE_BUFFER_ADDR); + my $buffSize = ::read16($symAddr + CONT_TRACE_BUFFER_SIZE); - my $addrOff = 0; - my $lenOff = $addrOff + DDWORD_SIZE; - my $seqOff = $lenOff + WORD_SIZE; - my $foundBuffer = 0; - my @seqNum; - - 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, WORD_SIZE; - $buffLen= hex (unpack('H*',$buffLen)); - $seqNum[$i] = substr $result, $seqOff, WORD_SIZE; - $seqNum[$i]= hex (unpack('H*',$seqNum[$i])); - if ($dbgMsg) - { - ::userDisplay("Trigger [".$i."] = $buffAddr\n"); - ::userDisplay("Length [".$i."] = $buffLen\n"); - ::userDisplay("SeqNum [".$i."] = $seqNum[$i]\n"); - } - - my $fhandle = $fh[$i]; - # If trigger bit is set, or last call and buffer has trace data - if ((0 != ($buffAddr & TRIG_BIT)) || (($last == 1) && ($buffLen > 1))) - { - $foundBuffer |= (1 << $i); - $buffAddr &= ~TRIG_BIT; - print $fhandle (::readData($buffAddr, $buffLen)); - - # reset trigger bit - ::write64($symAddr + $addrOff, $buffAddr); - - # reset count to 1 - ::write32($symAddr + $lenOff, 1); - } - - # increment to next element in g_cont_trace_trigger_info.triggers[] - $addrOff += (2 * DDWORD_SIZE); - $lenOff = $addrOff + DDWORD_SIZE; - $seqOff = $lenOff + WORD_SIZE; - } + print $fh (::readData($buffAddr, $buffSize)); if ($dbgMsg) { @@ -208,38 +129,16 @@ sub main ::userDisplay("$cycles\n"); } - if ($on2off) - { - ::write64($symAddr + CONT_TRACE_ENABLE_FLAG_OFFSET, 0); - if ($dbgMsg) - { - $on2off = ::read64($symAddr + CONT_TRACE_ENABLE_FLAG_OFFSET); - ::userDisplay("new Cont Trace Enable Flag = $on2off\n"); - } - } + ::writeScom(0x00050038, 8, 0x0); - if (($foundBuffer == 3) && ($seqNum[1] < $seqNum[0])) + open TRACE, ($args->{"fsp-trace"}." -s ".::getImgPath(). + "hbotStringFile $fsptrace_options $fname |") || die; + while (my $line = <TRACE>) { - my $tmp = $fname[0]; - $fname[0] =$fname[1]; - $fname[1] = $tmp; + ::userDisplay $line; } - for (my $i = 0; $i < MAX_NUM_CONT_TRACE_BUFFERS; $i++) - { - if (($foundBuffer & (1 << $i))) - { - #my $cmd = "cp " . $fname[$i] . " tracMERG." . $seqNum[$i]; - #system ( $cmd ); - open TRACE, ($args->{"fsp-trace"}." -s ". - ::getImgPath()."hbotStringFile $fsptrace_options $fname[$i] |"); - while (my $line = <TRACE>) - { - ::userDisplay $line; - } - } - unlink($fname[$i]); - } + unlink $fname; if ($dbgMsg) { @@ -257,7 +156,6 @@ sub helpInfo "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."], "enable-cont-trace=<1|0>" => ["Turn on|off continuous trace"], "debug" => ["Turn on debug messages"], } diff --git a/src/usr/trace/daemon/daemon.C b/src/usr/trace/daemon/daemon.C index 2a98f70b5..fd426933a 100644 --- a/src/usr/trace/daemon/daemon.C +++ b/src/usr/trace/daemon/daemon.C @@ -27,6 +27,7 @@ #include "../bufferpage.H" #include "../entry.H" #include "../compdesc.H" +#include "../debug.H" #include <initservice/taskargs.H> #include <initservice/initserviceif.H> @@ -308,6 +309,9 @@ namespace TRACEDAEMON void Daemon::sendContBuffer(void* i_buffer, size_t i_size) { + // Write debug structure with buffer information. + g_debugSettings.bufferSize = i_size; + g_debugSettings.bufferPage = i_buffer; // Write scratch register indicating continuous trace is available. writeScratchReg(1ull << 32); @@ -322,7 +326,14 @@ namespace TRACEDAEMON TARGETING::SpFunctions spFunctions = sys->getAttr<TARGETING::ATTR_SP_FUNCTIONS>(); - if (!spFunctions.traceContinuous) + // Determine if continuous trace is currently enabled. + bool contEnabled = spFunctions.traceContinuous; + if (g_debugSettings.contTraceOverride != 0) + { + contEnabled = (g_debugSettings.contTraceOverride == 2); + } + + if (!contEnabled) { // Trace isn't enabled so just discard the buffer. free(i_buffer); @@ -341,6 +352,7 @@ namespace TRACEDAEMON { task_yield(); } + free(i_buffer); } } } diff --git a/src/usr/trace/debug.C b/src/usr/trace/debug.C new file mode 100644 index 000000000..cc1856918 --- /dev/null +++ b/src/usr/trace/debug.C @@ -0,0 +1,30 @@ +/* IBM_PROLOG_BEGIN_TAG */ +/* This is an automatically generated prolog. */ +/* */ +/* $Source: src/usr/trace/debug.C $ */ +/* */ +/* 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 otherwise */ +/* divested of its trade secrets, irrespective of what has been */ +/* deposited with the U.S. Copyright Office. */ +/* */ +/* Origin: 30 */ +/* */ +/* IBM_PROLOG_END_TAG */ +#include "debug.H" + +namespace TRACE +{ + + DebugSettings g_debugSettings = { 0, 0, NULL }; + +} diff --git a/src/usr/trace/debug.H b/src/usr/trace/debug.H new file mode 100644 index 000000000..c9a14f91e --- /dev/null +++ b/src/usr/trace/debug.H @@ -0,0 +1,53 @@ +/* IBM_PROLOG_BEGIN_TAG */ +/* This is an automatically generated prolog. */ +/* */ +/* $Source: src/usr/trace/debug.H $ */ +/* */ +/* 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 otherwise */ +/* divested of its trade secrets, irrespective of what has been */ +/* deposited with the U.S. Copyright Office. */ +/* */ +/* Origin: 30 */ +/* */ +/* IBM_PROLOG_END_TAG */ +#ifndef __TRACE_DEBUG_H +#define __TRACE_DEBUG_H + +#include <stdint.h> + +namespace TRACE +{ + /** @struct DebugSettings + * + * Settings and values used by the debug tools to interact with the + * trace component. + */ + struct DebugSettings + { + // Continuous Trace: + /** Override of attribute setting. + * 0 - Use attribute (default). + * 1 - Force Disable + * 2 - Force Enable + */ + uint8_t contTraceOverride; + /** Size of continuous trace buffer. */ + uint16_t bufferSize; + /** Pointer to continuous trace buffer. */ + void* bufferPage; + }; + + extern DebugSettings g_debugSettings; +} + +#endif diff --git a/src/usr/trace/makefile b/src/usr/trace/makefile index 38de606aa..c58a11a4f 100644 --- a/src/usr/trace/makefile +++ b/src/usr/trace/makefile @@ -24,7 +24,7 @@ ROOTPATH = ../../.. MODULE = trace OBJS = interface.o service.o compdesc.o buffer.o bufferpage.o daemonif.o \ - assert.o + debug.o assert.o SUBDIRS = daemon.d test.d |