diff options
author | Patrick Williams <iawillia@us.ibm.com> | 2011-11-07 16:23:00 -0600 |
---|---|---|
committer | A. Patrick Williams III <iawillia@us.ibm.com> | 2011-11-16 12:56:42 -0600 |
commit | 032c54f4f03414618499a6717890a408e80acb77 (patch) | |
tree | c3fb15cdd4cb5119937b8b11cedb52aa05e49cc7 /src | |
parent | 1e3a888edab060be5b016aff86a5d547b5be6643 (diff) | |
download | talos-hostboot-032c54f4f03414618499a6717890a408e80acb77.tar.gz talos-hostboot-032c54f4f03414618499a6717890a408e80acb77.zip |
Simics implementation of debug framework.
Change-Id: Ie9f6963070ced0a39c2e62f685c79d6da01fdcdb
Reviewed-on: http://gfw160.austin.ibm.com:8080/gerrit/488
Tested-by: Jenkins Server
Reviewed-by: Andrew J. Geissler <andrewg@us.ibm.com>
Reviewed-by: Monte K. Copeland <copelanm@us.ibm.com>
Reviewed-by: A. Patrick Williams III <iawillia@us.ibm.com>
Diffstat (limited to 'src')
-rwxr-xr-x | src/build/citest/autocitest | 16 | ||||
-rwxr-xr-x | src/build/debug/Hostboot/Printk.pm | 2 | ||||
-rwxr-xr-x | src/build/debug/Hostboot/Ps.pm | 16 | ||||
-rwxr-xr-x | src/build/debug/Hostboot/Trace.pm | 4 | ||||
-rwxr-xr-x | src/build/debug/Hostboot/_DebugFramework.pm (renamed from src/build/debug/Hostboot/DebugFramework.pm) | 60 | ||||
-rwxr-xr-x | src/build/debug/hb-dump-debug | 2 | ||||
-rwxr-xr-x | src/build/debug/simics-debug-framework.pl | 146 | ||||
-rwxr-xr-x | src/build/debug/simics-debug-framework.py | 224 | ||||
-rwxr-xr-x | src/build/simics/hb-simdebug.py | 241 | ||||
-rwxr-xr-x | src/build/simics/post_model_hook.simics | 2 | ||||
-rwxr-xr-x | src/build/tools/cpfiles.pl | 21 |
11 files changed, 445 insertions, 289 deletions
diff --git a/src/build/citest/autocitest b/src/build/citest/autocitest index c63383c00..5e8829057 100755 --- a/src/build/citest/autocitest +++ b/src/build/citest/autocitest @@ -85,7 +85,7 @@ function runtraceHB() # exit 1 #fi - autosim $NOWIN --simcmd "hb-trace" + autosim $NOWIN --simcmd "hb-trace" --timeout 120 if [ $? -ne 0 ] ; then echo "ERROR 4 : Unable to run $?" stopsim @@ -150,12 +150,6 @@ HBICORE_TEST_SYMS="${HBICORE_TEST%%.*}.syms" HBICORE_TEST_EXTENDED="${HBICORE_TEST%%.*}_extended.bin" -## Find the hbotStringfile for traceHB. -HBICORE_TEST_STRINGFILE="${SBXHOME}/img/hbotStringFile" - -## Set the path to the hb-simdebug.py script -SIMDEBUG_PYTHON_FILE="${SBXHOME}/src/build/simics/hb-simdebug.py" - CPFILES="${SBXHOME}/src/build/tools/cpfiles.pl" @@ -170,8 +164,6 @@ echo "TEST_SANDBOX = $TEST_SANDBOX" echo "HBICORE_TEST = $HBICORE_TEST" echo "HBICORE_TEST_EXTENDED = $HBICORE_TEST_EXTENDED" echo "HBICORE_TEST_SYMS = $HBICORE_TEST_SYMS" -echo "HBICORE_TEST_STRINGFILE = $HBICORE_TEST_STRINGFILE" -echo "SIMDEBUG_PYTHON_FILE = $SIMDEBUG_PYTHON_FILE" echo "SANDBOXRC = $SANDBOXRC" echo "SBXHOME = $SBXHOME" echo "current directory is " `pwd` @@ -325,12 +317,6 @@ mods_started_addr=`grep "CxxTest::g_ModulesStarted" \ mods_completed_addr=`grep "CxxTest::g_ModulesCompleted" \ ${SBXHOME}/${HBICORE_TEST_SYMS} | awk '{split($0,a,","); print a[2]}'` -## borrowed from CamVan's python script -trace_buffer_addr=`grep "g_desc_array" \ - ${SBXHOME}/${HBICORE_TEST_SYMS} | awk '{split($0,a,","); print a[2]}'` -trace_buffer_size=`grep "g_desc_array" \ - ${SBXHOME}/${HBICORE_TEST_SYMS} | awk '{split($0,a,","); print a[4]}'` - ## note, don't use $VERBOSE here or you get all sorts of extra junk in the output file. echo "Wait for unit test completion." declare -i timeout=0 diff --git a/src/build/debug/Hostboot/Printk.pm b/src/build/debug/Hostboot/Printk.pm index 6e76b484c..deaf6c72d 100755 --- a/src/build/debug/Hostboot/Printk.pm +++ b/src/build/debug/Hostboot/Printk.pm @@ -32,7 +32,7 @@ sub main { ::userDisplay "------------Kernel Printk Parser------------\n"; my ($symAddr, $symSize) = ::findSymbolAddress("kernel_printk_buffer"); - if (not defined $symAddr) { ::userDisplay "Cannot find symbol.\n"; die; } + if (not defined $symAddr) { ::userDisplay "Cannot find symbol.\n"; die; } ::userDisplay ::readData($symAddr,$symSize); ::userDisplay "--------------------------------------------\n"; } diff --git a/src/build/debug/Hostboot/Ps.pm b/src/build/debug/Hostboot/Ps.pm index 7077079d1..0048ccc87 100755 --- a/src/build/debug/Hostboot/Ps.pm +++ b/src/build/debug/Hostboot/Ps.pm @@ -28,7 +28,7 @@ package Hostboot::Ps; use Exporter; our @EXPORT_OK = ('main'); -use constant PS_TASKMGR_SYMBOLNAME => +use constant PS_TASKMGR_SYMBOLNAME => "Singleton<TaskManager>::instance()::instance"; use constant PS_TASKMGR_TRACKER_LIST_OFFSET => 8 * 4; use constant PS_TRACKER_LIST_HEAD_OFFSET => 0; @@ -39,7 +39,7 @@ use constant PS_TRACKER_PREV_OFFSET => 0; use constant PS_TRACKER_NEXT_OFFSET => 8 + PS_TRACKER_PREV_OFFSET; use constant PS_TRACKER_PARENT_OFFSET => 8 + PS_TRACKER_NEXT_OFFSET; use constant PS_TRACKER_CHILDREN_LIST_OFFSET => 8 + PS_TRACKER_PARENT_OFFSET; -use constant PS_TRACKER_TID_OFFSET => +use constant PS_TRACKER_TID_OFFSET => PS_TRACKER_CHILDREN_LIST_OFFSET + PS_TRACKER_LIST_SIZE; use constant PS_TRACKER_TASK_OFFSET => 8 + PS_TRACKER_TID_OFFSET; use constant PS_TRACKER_STATUS_OFFSET => 8 + PS_TRACKER_TASK_OFFSET; @@ -55,9 +55,9 @@ sub main # Find symbol containing kernel list of task objects. # (Tasks who's parent is the kernel) my ($symAddr, $symSize) = ::findSymbolAddress(PS_TASKMGR_SYMBOLNAME); - if (not defined $symAddr) - { - ::userDisplay "Couldn't find ".PS_TASKMGR_SYMBOLNAME; + if (not defined $symAddr) + { + ::userDisplay "Couldn't find ".PS_TASKMGR_SYMBOLNAME; die; } @@ -96,7 +96,7 @@ sub displayList sub displayTracker { my ($trackAddr, $level) = @_; - + # Read TID. my $tid = ::read16(PS_TRACKER_TID_OFFSET + $trackAddr); @@ -121,7 +121,7 @@ sub displayTracker if (($state ne "R") and ($state ne "r") and ($state ne "E") and ($state ne "Z")) { - $stateExtra = sprintf "(0x%x)", + $stateExtra = sprintf "(0x%x)", ::read64(PS_TASK_STATEEXTRA_OFFSET + $taskAddr); } elsif ($state eq "Z") @@ -163,7 +163,7 @@ sub makeTabs $result = $result." |"; $level = $level - 1; } - + return $result; } diff --git a/src/build/debug/Hostboot/Trace.pm b/src/build/debug/Hostboot/Trace.pm index f57676f40..42722c09f 100755 --- a/src/build/debug/Hostboot/Trace.pm +++ b/src/build/debug/Hostboot/Trace.pm @@ -66,11 +66,11 @@ sub main if ((not defined $traceBuffers) or ($traceBuffers =~ m/$compName/)) { - $foundBuffer = 1; + $foundBuffer = 1; print $fh (::readData($buffAddr, TRAC_DEFAULT_BUFFER_SIZE)); } } - + if ($foundBuffer) { open TRACE, ($args->{"fsp-trace"}." -s ". diff --git a/src/build/debug/Hostboot/DebugFramework.pm b/src/build/debug/Hostboot/_DebugFramework.pm index 5bdedd4df..a55794ebc 100755 --- a/src/build/debug/Hostboot/DebugFramework.pm +++ b/src/build/debug/Hostboot/_DebugFramework.pm @@ -1,8 +1,30 @@ #!/usr/bin/perl +# IBM_PROLOG_BEGIN_TAG +# This is an automatically generated prolog. +# +# $Source: src/build/debug/Hostboot/_DebugFramework.pm $ +# +# IBM CONFIDENTIAL +# +# COPYRIGHT International Business Machines Corp. 2011 +# +# 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 -# DebugFramework.pm +# _DebugFramework.pm # -# This module is a set of utility functions for the debug framework, which +# This module is a set of utility functions for the debug framework, which # should be common across all debug framework environments. # # The module provides the functions listed below in @EXPORT. @@ -17,7 +39,7 @@ use strict; -package Hostboot::DebugFramework; +package Hostboot::_DebugFramework; use Exporter 'import'; our @EXPORT = ( 'callToolModule', 'callToolModuleHelp', @@ -47,7 +69,7 @@ BEGIN return 1; # @sub callToolModule -# +# # Executes the 'main' function of the requested tool module. # # @param string - Tool to call. @@ -59,14 +81,15 @@ sub callToolModule my $tool = shift; my $package = "Hostboot::$tool"; - eval("use lib '.'; use $package; return 1;") or - die "Couldn't load tool \"$tool\""; + eval("use lib '.'; use $package; return 1;") or + die "Couldn't load tool \"$tool\":\n\t$@"; eval("$package->main(\\%toolOpts);"); + die $@ if $@; } # @sub callToolModuleHelp # -# Executes the 'help' function of the requested tool module to display +# Executes the 'help' function of the requested tool module to display # tool usage. # # @param string - Tool to call. @@ -76,9 +99,10 @@ sub callToolModuleHelp my $tool = shift; my $package = "Hostboot::$tool"; - eval("use lib '.'; use $package; return 1;") or - die "Couldn't load tool \"$tool\""; + eval("use lib '.'; use $package; return 1;") or + die "Couldn't load tool \"$tool\":\n\t$@"; eval("$package->help(\\%toolOpts);"); + die $@ if $@; } # @sub parseToolOpts @@ -131,7 +155,7 @@ sub determineImagePath $imgPath = $ENV{"HOSTBOOTROOT"} . "/img/"; } } - + return $imgPath; } @@ -144,24 +168,24 @@ sub parseSymbolFile if ($parsedSymbolFile) { return; } my $symsFile = ::getImgPath(); - if (::getIsTest()) - { + if (::getIsTest()) + { $symsFile = $symsFile."hbicore_test.syms"; } else { $symsFile = $symsFile."hbicore.syms"; } - - open(FILE, "< $symsFile") or die; + + open(FILE, "< $symsFile") or die "Cannot open symbol file $symsFile"; while (my $line = <FILE>) { $line =~ m/(.*?),(.*?),(.*?),(.*?),(.*)/; - my $name = $5; + my $name = $5; my $addr = hex $2; my $tocAddr = hex $3; my $size = hex $4; - + $symbolAddress{$name} = $addr; $symbolSize{$name} = $size; $addressSymbol{$addr} = $name; @@ -222,7 +246,7 @@ sub parseModuleFile $modFile = $modFile."hbicore.bin.modinfo"; } - open(FILE, "< $modFile") or die; + open(FILE, "< $modFile") or die "Cannot open module-info file $modFile"; while (my $line = <FILE>) { $line =~ m/(.*?),(.*)/; @@ -337,7 +361,7 @@ sub read8 my $addr = shift; my $result = ::readData($addr, 1); - + return unpack("C", $result); } diff --git a/src/build/debug/hb-dump-debug b/src/build/debug/hb-dump-debug index b6648b397..600187f61 100755 --- a/src/build/debug/hb-dump-debug +++ b/src/build/debug/hb-dump-debug @@ -28,7 +28,7 @@ use Getopt::Long; use Pod::Usage; use IO::Seekable; -use Hostboot::DebugFramework; +use Hostboot::_DebugFramework; my $tool = ""; my $dumpfile = ""; diff --git a/src/build/debug/simics-debug-framework.pl b/src/build/debug/simics-debug-framework.pl new file mode 100755 index 000000000..a255439a9 --- /dev/null +++ b/src/build/debug/simics-debug-framework.pl @@ -0,0 +1,146 @@ +#!/usr/bin/perl +# IBM_PROLOG_BEGIN_TAG +# This is an automatically generated prolog. +# +# $Source: src/build/debug/simics-debug-framework.pl $ +# +# IBM CONFIDENTIAL +# +# COPYRIGHT International Business Machines Corp. 2011 +# +# 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 + +# @file simics-debug-framework.pl +# @brief Implementation of the common debug framework for running in simics. +# +# Simics uses Python for all debug. This file is a Perl bridge between Python +# and the framework tool modules. The Python side will create a sub-process of +# this script using STDIN/STDOUT as an IPC message pipe. This side will +# execute the Perl module and send data / output across the pipe to the Python +# side. + +use strict; +use Hostboot::_DebugFramework; + +$| = 1; # Disable buffering on STDIN/STDOUT. + +# @sub sendIPCMsg +# @brief Sends a message to the Python side of the framework over STDOUT. +# +# Messages are of the format: +# [ "type", "data-in-ascii-encoded-hex" ] +# Example: +# The message... +# [ "display", "48656c6c6f20576f726c642e0a" ] +# means 'display "Hello World.\n"' +sub sendIPCMsg +{ + my ($type, $data) = @_; + + print "[ \"$type\", \"".unpack("H*",$data)."\" ]\n"; +} + +# @sub recvIPCMsg +# @brief Watis for a message from the Python side of the framework from STDIN. +# +# See sendIPCMsg for message format. +sub recvIPCMsg +{ + my $type = ""; + my $data = ""; + + if (my $string = <STDIN>) + { + if ($string =~ m/\[ \"([^\"]+)\", \"([0-9a-f]*)\" ]\n/) + { + $type = $1; + $data = pack("H*", $2); + } + } + + return ($type, $data); +} + +# @sub userDisplay +# @brief Send a 'display' type message to Python. +sub userDisplay +{ + my $string = ""; + + foreach my $value (@_) + { + $string = $string . $value; + } + + sendIPCMsg("display", $string); +} + +# @sub readData +# @brief Send a 'read-data' type message to Python. +sub readData +{ + my $addr = shift; + my $size = shift; + + sendIPCMsg("read-data", "$addr,$size"); + + my ($type, $data) = recvIPCMsg(); + + if (length($data) == $size) + { + return $data; + } + + return ""; +} + +# Image path global. +my $imgPath = ""; +sub getImgPath +{ + return $imgPath; +} + +# Simics always uses the non-test named files. +sub getIsTest +{ + return 0; +} + + +# Get tool name. +sendIPCMsg("get-tool",""); +my ($unused, $tool) = recvIPCMsg(); + +# If we were called with --usage, send tool help instead of executing. +if ((-1 != $#ARGV) && ("--usage" eq $ARGV[0])) +{ + callToolModuleHelp($tool); + exit; +} + +# Get tool options, image path. +sendIPCMsg("get-tool-options",""); +my ($unused, $toolOpts) = recvIPCMsg(); +sendIPCMsg("get-img-path"); +($unused, $imgPath) = recvIPCMsg(); + +# Update image path, parse options. +$imgPath = determineImagePath(); +parseToolOpts($toolOpts); + +# Execute module. +callToolModule($tool); + diff --git a/src/build/debug/simics-debug-framework.py b/src/build/debug/simics-debug-framework.py new file mode 100755 index 000000000..5be2f8c37 --- /dev/null +++ b/src/build/debug/simics-debug-framework.py @@ -0,0 +1,224 @@ +#!/usr/bin/python +# IBM_PROLOG_BEGIN_TAG +# This is an automatically generated prolog. +# +# $Source: src/build/debug/simics-debug-framework.py $ +# +# IBM CONFIDENTIAL +# +# COPYRIGHT International Business Machines Corp. 2011 +# +# 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 + +# @file simics-debug-framework.py +# @brief Simics/Python implementation of the common debug framework. +# +# This is the Python side of the simics implementation of the debug framework. +# It operates by opening a Perl script as a subprocess using stdin/stdout to +# the subprocess as an IPC pipe. +# +# The Python script will handle the bridging from framework primatives, such +# as 'readData', to Simics interfaces. The script will also search for all +# existing debug modules and automatically instantiate simics commands of the +# form 'hb-Tool' so they can be used. +# +# If the users are expecting another tool name, such as 'hb-printk' instead of +# 'hb-Printk', or are expecting nicer parameter passing, such as +# 'hb-trace COMP1,COMP2' instead of 'hb-Trace "components=COMP1,COMP2"', then a +# manual wrapper command should be implemented in 'hb-simdebug.py'. + + +import os +import subprocess +import re + +# @class DebugFrameworkIPCMessage +# @brief Wrapper class for constructing a properly formed IPC message for the +# Python-Perl bridge. +# +# The class provides a Pickle-like API (dumps / loads). +# +# Messages are of the format: +# [ "type", "data-in-ascii-encoded-hex" ] +# Example: +# The message... +# [ "display", "48656c6c6f20576f726c642e0a" ] +# means 'display "Hello World.\n"' +# +class DebugFrameworkIPCMessage: + msgtype = "unknown" + msg = "" + + def __init__(self, msgtype = "unknown", msg = ""): + self.msgtype = msgtype + self.msg = msg + + def dumps(self): + return ("[ \"" + self.msgtype + "\", \"" + + self.msg.encode("hex") + "\" ]\n") + + def loads(self,string): + pattern = re.compile("\[ \"([^\"]+)\", \"([0-9a-f]*)\" ]") + match = pattern.search(string) + + self.msgtype = match.group(1) + self.msg = match.group(2).decode("hex") + +# @class DebugFrameworkProcess +# @brief Provides a wrapper to the 'subprocess' interface and IPC bridge. +# +# This class also provides the handling functions for various bridge message +# types into the appropriate simics interface. +# +class DebugFrameworkProcess: + process = ""; # subprocess object. + tool = ""; # string - tool module name. + toolOptions = ""; # string - tool options + usage = None; # mode - Usage output instead of Execution. + imgPath = "./"; # Image dir path override. + result = ""; # Result string for Usage-mode. + + def __init__(self, tool = "Printk", toolOptions = "", + usage = None, imgPath = "./"): + # Determine sub-process arguments. + process_args = ["./simics-debug-framework.pl"]; + if (usage): # Pass --usage if Usage mode selected. + process_args = process_args + [ "--usage" ]; + + # Spawn sub-process + self.process = subprocess.Popen(process_args, + stdin=subprocess.PIPE, stdout=subprocess.PIPE) + # Update instance variables. + self.tool = tool; + self.toolOptions = toolOptions; + self.usage = usage; + self.imgPath = imgPath; + + # Read a message from the process pipe. + def recvMsg(self): + msg = DebugFrameworkIPCMessage() + line = self.process.stdout.readline() + if len(line) != 0: + msg.loads(line) + return (msg.msgtype, msg.msg) + else: + return ("", "") + + # Send a message into the process pipe. + def sendMsg(self,msgtype,msg): + msg = DebugFrameworkIPCMessage(msgtype, msg) + self.process.stdin.write(msg.dumps()) + + # End sub-process by closing its pipe. + def endProcess(self): + self.process.stdin.close() + + # Display string (or save to result in Usage mode). + def display(self,data): + if (self.usage): + self.result += data + else: + print data, + + # Read data from memory. + # This message has data of the format "0xADDRESS,0xSIZE". + def read_data(self,data): + pattern = re.compile("([0-9]+),([0-9]+)") + match = pattern.search(data); + + addr = int(match.group(1)) + size = int(match.group(2)) + + data = "".join(map(chr, conf.phys_mem.memory[[addr , addr+size-1]])) + self.sendMsg("data-response", data) + + # Get tool module name. + def get_tool(self,data): + self.sendMsg("data-response", self.tool) + + # Get tool options. + def get_tool_options(self,data): + self.sendMsg("data-response", self.toolOptions) + + # Get image path. + def get_img_path(self,data): + self.sendMsg("data-response", self.imgPath) + +# @fn run_hb_debug_framework +# @brief Wrapper function to execute a tool module. +# +# @param tool - Tool module to execute. +# @param toolOpts - String containing tool options. +# @param usage - Usage mode or Execute mode. +# @param imgPath - Image path override. +def run_hb_debug_framework(tool = "Printk", toolOpts = "", + usage = None, imgPath = "./"): + # Create debug sub-process. + fp = DebugFrameworkProcess(tool,toolOpts,usage,imgPath) + + # Read / handle messages until there are no more. + msg = fp.recvMsg() + while msg[0] != "": + operations = { "display" : DebugFrameworkProcess.display, + "read-data" : DebugFrameworkProcess.read_data, + "get-tool" : DebugFrameworkProcess.get_tool, + "get-tool-options" : DebugFrameworkProcess.get_tool_options, + "get-img-path" : DebugFrameworkProcess.get_img_path, + "exit" : DebugFrameworkProcess.endProcess, + } + operations[msg[0]](fp,msg[1]) + msg = fp.recvMsg() + + # If in Usage mode, return result string. + if (usage): + return fp.result + return None + +# @fn register_hb_debug_framework_tools +# @brief Create a simics command wrapper for each debug tool module. +def register_hb_debug_framework_tools(): + # Find all modules from within Hostboot subdirectory. + files = os.listdir("./Hostboot") + + # Filter out any prefixed with '_' (utility module) or a '.' (hidden file). + pattern = re.compile("[^\._]"); + files = [f for f in files if pattern.match(f)] + + # Remove the .pm extension from the tool modules. + files = [re.sub("\.pm","",f) for f in files]; + + # Create an entry for each module. + for tool in files: + # Get usage information for each module, fix text to HTML-like. + usage = run_hb_debug_framework(tool, usage = 1) + usage = re.sub("<","<", usage); + usage = re.sub(">",">", usage); + usage = re.sub("\t"," ",usage) + usage = "<pre>"+usage+"</pre>" + + # Create command hook. + new_command("hb-" + tool, + (lambda toolname: + lambda options: + run_hb_debug_framework(toolname, options))(tool), + args = [arg(str_t, "options", "?", "")], + type = ["hostboot-commands"], + short = "Runs the debug framework for tool " + tool, + doc = usage) + print "Hostboot Debug Framework: Registered tool:", "hb-" + tool + +# Run the registration automatically whenever this script is loaded. +register_hb_debug_framework_tools() + diff --git a/src/build/simics/hb-simdebug.py b/src/build/simics/hb-simdebug.py index 06b5e4ccd..2ecf7bac3 100755 --- a/src/build/simics/hb-simdebug.py +++ b/src/build/simics/hb-simdebug.py @@ -20,19 +20,6 @@ # Origin: 30 # # IBM_PROLOG_END -# *** hb-simdebug.py -# -# Script to extract and display formatted trace in simics - -# *** Usage -# -# On simics console: -# 1. Load file -# simics> run-python-file <gitrepo>/src/build/trace/traceHB.py -# 2. Display global trace buffer -# simics> @traceHB("<compName1>,<compName2>,...", <git.repo>/img/hbicore.syms", <git.repo>/img/hbotStringFile") -# 3. Display kernel printk buffer -# simics> @printkHB("<git.repo>/img/hbicore.syms") import os,sys import conf @@ -43,206 +30,6 @@ import datetime import commands ## getoutput, getstatusoutput #------------------------------------------------------------------------------ -# Function to dump the trace buffers -#------------------------------------------------------------------------------ -def traceHB(compStr, symsFile, stringFile): - - # "constants" - DESC_ARRAY_ENTRY_SIZE = 24 - DESC_ARRAY_ENTRY_ADDR_SIZE = 8 - DESC_ARRAY_ENTRY_COMP_NAME_SIZE = 16 - MAX_NUM_BUFFERS = 24 - MAX_COMP_NAME_SIZE = DESC_ARRAY_ENTRY_COMP_NAME_SIZE - 1 #minus null termination - - print - - gDescArraySym = "g_desc_array" - - #Find location of g_desc_array variable from the image's .syms file - for line in open(symsFile): - - if gDescArraySym in line: #if found - - #print line - x = line.split(",") - array_addr = int(x[1],16) #address of g_desc_array - #print "g_desc_array addr = 0x%x"%(array_addr) - array_size = int(x[3],16) #size of g_desc_array - #print "g_desc_array size = 0x%x"%(array_size) - - # content of g_desc_array - #string = "phys_mem.x 0x%x 0x%x"%(array_addr,array_size) - #print string - #result,message = quiet_run_command(string) - #print message - - #flag to indicate if we found any buffer - buffer_found = 0; - - #Parse the compStr argument for the list of component buffers requested - compList = compStr.split(",") - #print compList - for compName in compList: - - # Strip all whitespaces and limit to 15 bytes max - compName = compName.strip() - if (len(compName) > MAX_COMP_NAME_SIZE): - compName = compName[0:MAX_COMP_NAME_SIZE] - #print compName - - #pointer to first entry of g_desc_array - entry_addr = array_addr - - #find the component trace buffer - for entry in range (1, MAX_NUM_BUFFERS + 1): - - #print "entry = 0x%x"%(entry) - string = "phys_mem.x 0x%x 0x%x"%(entry_addr,DESC_ARRAY_ENTRY_COMP_NAME_SIZE) - #print string - #example output of phys_mem.x is: - #simics> phys_mem.x 0x263c8 0x10 - #p:0x000263c0 4465 7646 5700 0000 0 DevFW... - #p:0x000263d0 0000 0000 0000 0000 0 ........ - result,message = quiet_run_command(string) - #print message - lst = message.split() - #print lst - #example output of lst (lst[1] = '4465'): - #['p:0x000263c0', '4465', '7646', '5700', '0000', '0', 'DevFW...', - #'p:0x000263d0', '0000', '0000', '0000', '0000', '0', '........'] - - # no more entry to search - if lst[1]=='0000': - break - - # get component name from entry - name_str = lst[1] - count = 1 - i = 2 - while (count < (DESC_ARRAY_ENTRY_COMP_NAME_SIZE/2)): - if (lst[i] == '0000'): - break - if len(lst[i]) == 4: - name_str += lst[i] - count +=1 - i += 1 - - #1st method: - #str = name_str.strip('00') - #if (compName.encode("hex")==str): - # print "we found the buffer" - #2nd method: - name_str = binascii.unhexlify(name_str) - #print name_str - str = name_str.strip('\0') - - #We found the component buffer - if ((str == compName) or (len(compName) == 0)): - - #get address of component trace buffer - string = "phys_mem.x 0x%x 0x%x"%(entry_addr + DESC_ARRAY_ENTRY_COMP_NAME_SIZE, DESC_ARRAY_ENTRY_ADDR_SIZE) - #print string - result,message = quiet_run_command(string) - #print message - lst = message.split() - #print lst - - addr_str = "" - for i in range(1,(DESC_ARRAY_ENTRY_ADDR_SIZE/2) + 1): - addr_str += lst[i] - #print addr_str - addr_trace_buffer = int(addr_str,16) - - #save trace buffer to <sandbox>/simics/tracBIN - string = "memory_image_ln0.save tmp.out 0x%x 0x800"%(addr_trace_buffer) - #print string - result = run_command(string) - #print result - - if (buffer_found == 0): - fd1 = open('tracBIN','wb') - buffer_found = 1 - else: - fd1 = open('tracBIN','ab') - fd2 = open('tmp.out', 'rb') - fd1.write(fd2.read()) - fd1.close() - fd2.close() - - if (str == compName): - break - - # Increment address to next entry in g_desc_array - entry_addr += DESC_ARRAY_ENTRY_SIZE - - if (buffer_found == 1): - #display formatted trace & save it to <sandbox>/simics/tracMERG - string = 'fsp-trace -s %s tracBIN | tee tracMERG'%(stringFile) - #print string - os.system(string) - #remove tmp.out & tracBIN - os.system('rm tmp.out tracBIN') - - print "\n\n\nData saved to %s/tracMERG."%(os.getcwd()) - else: - print "\nNo component trace buffers found." - - print - break - - #print line - if gDescArraySym not in line: #if not found - print "\nCannot find %s in %s"%(gDescArraySym,symsFile) - - return - - -#------------------------------------------------------------------------------ -# Function to dump the kernel printk buffer -#------------------------------------------------------------------------------ -def printkHB(symsFile): - - print - - printkSym = "kernel_printk_buffer" - - #Find location of the kernel_printk_buffer variable from the image's .syms file - #i.e. grep kernel_printk_buffer <gitrepo>/img/hbicore.syms - for line in open(symsFile): - if printkSym in line: #if found - #print line - x = line.split(",") - addr = int(x[1],16) #address of kernel_printk_buffer - #print "addr = 0x%x"%(addr) - size = int(x[3],16) #size of kernel_printk_buffer - #print "size = 0x%x"%(size) - - #save kernel printk buffer to <sandbox>/simics/printk.out - string = "memory_image_ln0.save %s 0x%x 0x%x"%(printkSym,addr,size) - #print string - result = run_command(string) - #print result - - #display buffer - #for line in open(printkSym): - # print line - #file = open(printkSym) - #print file.read() - string = "cat %s"%(printkSym) - os.system(string) - - print "\n\nData saved to %s/%s."%(os.getcwd(),printkSym) - - break - - #print line - if printkSym not in line: #if not found - print "\nCannot find %s in %s"%(printkSym,symsFile) - - return - - -#------------------------------------------------------------------------------ # Function to dump L3 #------------------------------------------------------------------------------ def dumpL3(): @@ -476,29 +263,14 @@ def errlHB(symsFile, errlParser, flag, logid, stringFile): #=============================================================================== # HOSTBOOT Commands #=============================================================================== -default_comp = "" default_syms = "hbicore.syms" default_stringFile = "hbotStringFile" -#traceHB_relative_path = "../tools" # relative to $sb #------------------------------------------------ #------------------------------------------------ -def hb_trace(comp): - syms = default_syms - stringFile = default_stringFile - - if comp == None: - comp = default_comp - - print "comp=%s" % str(comp) - - print "syms=%s" % str(syms) - print "StringFile=%s" % str(stringFile) - traceHB(comp, syms, stringFile) - return None - new_command("hb-trace", - hb_trace, + (lambda comp: run_hb_debug_framework("Trace", + ("components="+comp) if comp else "")), [arg(str_t, "comp", "?", None), ], #alias = "hbt", @@ -523,15 +295,8 @@ Examples: \n #------------------------------------------------ #------------------------------------------------ -def hb_printk(): - syms = default_syms - - print "syms=%s" % str(syms) - printkHB(syms) - return None - new_command("hb-printk", - hb_printk, + lambda: run_hb_debug_framework("Printk"), #alias = "hbt", type = ["hostboot-commands"], #see_also = ["hb-trace"], diff --git a/src/build/simics/post_model_hook.simics b/src/build/simics/post_model_hook.simics index 0455e66f0..85dc001ec 100755 --- a/src/build/simics/post_model_hook.simics +++ b/src/build/simics/post_model_hook.simics @@ -29,7 +29,7 @@ ################################################################################ -#setup traces +run-python-file simics-debug-framework.py run-python-file hb-simdebug.py #Load extended image and pnor.toc into phys_mem diff --git a/src/build/tools/cpfiles.pl b/src/build/tools/cpfiles.pl index 5ee77afe3..8828ae7a7 100755 --- a/src/build/tools/cpfiles.pl +++ b/src/build/tools/cpfiles.pl @@ -58,6 +58,9 @@ sub printUsage; my @files = ("src/build/tools/hb-parsedump.pl", "src/build/simics/hb-simdebug.py", "src/build/simics/post_model_hook.simics", + "src/build/debug/Hostboot", + "src/build/debug/simics-debug-framework.pl", + "src/build/debug/simics-debug-framework.py", "img/errlparser", "img/hbotStringFile", "img/hbicore.syms", @@ -68,6 +71,8 @@ my @files = ("src/build/tools/hb-parsedump.pl", "img/hbicore_test.list", "img/hbicore_extended.bin", "img/hbicore_test_extended.bin", + "img/hbicore.bin.modinfo", + "img/hbicore_test.bin.modinfo", "img/pnor.toc", "img/simics_SALERNO_targeting.bin", "img/simics_VENICE_targeting.bin", @@ -216,6 +221,8 @@ foreach (@files) my($filename, $directories, $suffix) = fileparse($_, qr{\..*}); #print "$filename, $directories, $suffix\n"; + my $recursive = (-d $_) ? "-r" : ""; + #Copy .bin to the img dir if (($suffix eq ".bin") || ($suffix eq ".toc")) @@ -228,7 +235,8 @@ foreach (@files) } #Delete the old file first (handles copying over symlinks) - $command = sprintf("rm -f %s/%s%s", $copyDir, $filename, $suffix); + $command = sprintf("rm -f %s %s/%s%s", $recursive, + $copyDir, $filename, $suffix); if ($command ne "") { print "$command\n"; @@ -243,20 +251,23 @@ foreach (@files) #Copy test versions to hbicore.<syms|bin|list> if ($filename eq "hbicore_test") { - $command = sprintf("cp %s %s", $_, $copyDir."/hbicore".$suffix); + $command = sprintf("cp %s %s %s", $recursive, + $_, $copyDir."/hbicore".$suffix); } elsif ($filename eq "hbicore_test_extended") { - $command = sprintf("cp %s %s", $_, $copyDir."/hbicore_extended".$suffix); + $command = sprintf("cp %s %s %s", $recursive, + $_, $copyDir."/hbicore_extended".$suffix); } elsif ($filename ne "hbicore" and $filename ne "hbicore_extended") { - $command = sprintf("cp %s %s", $_, $copyDir); + $command = sprintf("cp %s %s %s", $recursive, + $_, $copyDir); } } else { - $command = sprintf("cp %s %s", $_, $copyDir); + $command = sprintf("cp %s %s %s", $recursive, $_, $copyDir); } # Copy the file |