"""Niagara command parser
import re
, string
, sys
, types
## # if nasAPI is not available (which is the case in MOM mode), we can make do
## #sys.stderr.write('WARNING: nasAPI module is not available\n')
from CmdParserNiCmd
import *
# the following breakpoint constants (BP_*) must be consistent with
# include/system/BreakpointEntry.h
hexRE
= re
.compile('^0[xX][0-9A-Fa-f]+$')
octRE
= re
.compile('^0[0-7]+$')
# split command line to locate any % variable, e.g., %pc
splitRE
= re
.compile('[^%_\w]')
### need to support the following commands:
NAME_breakpoint
= 'phys_mem'
NAME_memory_space
= 'phys_mem'
NAME_swerver_memory
= 'swvmem'
NAME_swerver_proc_mmu
= 'swmmu'
NAME_swerver_thread_mmu
= 'stmmu'
CMD_add_directory
= 'add-directory'
CMD_api_apropos
= 'api-apropos'
CMD_api_help
= 'api-help'
CMD_break_cr
= 'break-cr'
CMD_break_exception
= 'break-exception'
CMD_break_hap
= 'break-hap'
CMD_break_io
= 'break-io'
CMD_breakpoint_break
= 'break'
CMD_catch_exception
= 'catch-exception'
CMD_clear_directories
= 'clear-directories'
CMD_command_list
= 'command-list'
CMD_cycle_break
= 'cycle-break'
CMD_cycle_break_absolute
= 'cycle-break-absolute'
CMD_debug_level
= 'debug-level'
CMD_device_interrupt
= 'device-interrupt'
CMD_disable_real_time_mode
= 'disable-real-time-mode'
CMD_disassemble
= 'disassemble'
CMD_dstc_disable
= 'dstc-disable'
CMD_dstc_enable
= 'dstc-enable'
CMD_enable_external_commands
= 'enable-external-commands'
CMD_enable_real_time_mode
= 'enable-real-time-mode'
CMD_gdb_remote
= 'gdb-remote'
CMD_image_add_diff_file
= 'add-diff-file'
CMD_image_add_partial_diff_file
= 'add-partial-diff-file'
CMD_image_commit
= 'commit'
CMD_image_limit_memory
= 'limit-memory'
CMD_instruction_profile_mode
= 'instruction-profile-mode'
CMD_io_buffer
= 'io-buffer'
CMD_istc_disable
= 'istc-disable'
CMD_istc_enable
= 'istc-enable'
CMD_le_checksum
= 'le-checksum'
CMD_le_permissions
= 'le-permissions'
CMD_list_attributes
= 'list-attributes'
CMD_list_breakpoints
= 'list-breakpoints'
CMD_list_classes
= 'list-classes'
CMD_list_failed_modules
= 'list-failed-modules'
CMD_list_haps
= 'list-haps'
CMD_list_modules
= 'list-modules'
CMD_list_namespaces
= 'list-namespaces'
CMD_list_profilers
= 'list-profilers'
CMD_list_vars
= 'list-vars'
CMD_load_binary
= 'load-binary'
CMD_load_file
= 'load-file'
CMD_load_module
= 'load-module'
CMD_load_veri_file
= 'load-veri-file'
CMD_logical_to_physical
= 'logical-to-physical'
CMD_magic_break_disable
= 'magic-break-disable'
CMD_magic_break_enable
= 'magic-break-enable'
CMD_memory_profile
= 'memory-profile'
CMD_memory_space_map
= 'map'
CMD_module_list_refresh
= 'module-list-refresh'
CMD_native_path
= 'native-path'
CMD_new_command
= 'new_command'
CMD_new_context
= 'new-context'
CMD_output_radix
= 'output-radix'
CMD_pdisable
= 'pdisable'
CMD_pdisassemble
= 'pdisassemble'
CMD_port_space_map
= 'map'
CMD_pregs_all
= 'pregs-all'
CMD_pregs_hyper
= 'pregs-hyper'
CMD_print_directories
= 'print-directories'
CMD_print_double_regs
= 'print-double-regs'
CMD_print_event_queue
= 'print-event-queue'
CMD_print_float_regs
= 'print-float-regs'
CMD_print_float_regs_raw
= 'print-float-regs-raw'
CMD_print_instruction_queue
= 'print-instruction-queue'
CMD_print_profile
= 'print-profile'
CMD_print_statistics
= 'print-statistics'
CMD_print_time
= 'print-time'
CMD_prof_page_details
= 'prof-page-details'
CMD_prof_page_map
= 'prof-page-map'
CMD_prof_weight
= 'prof-weight'
CMD_read_configuration
= 'read-configuration'
CMD_read_fp_reg_i
= 'read-fp-reg-i'
CMD_read_fp_reg_x
= 'read-fp-reg-x'
CMD_read_reg
= 'read-reg'
CMD_read_sw_pcs
= 'read-sw-pcs'
CMD_read_th_ctl_reg
= 'read-th-ctl-reg'
CMD_read_th_fp_reg_i
= 'read-th-fp-reg-i'
CMD_read_th_fp_reg_x
= 'read-th-fp-reg-x'
CMD_read_thread_status
= 'read-thread-status'
CMD_read_th_reg
= 'read-th-reg'
CMD_resolve_file
= 'resolve-file'
CMD_rtl_cycle
= 'rtl_cycle'
CMD_rtl_intf_info
= 'info'
CMD_run_command_file
= 'run-command-file'
CMD_run_python_file
= 'run-python-file'
CMD_set_context
= 'set-context'
CMD_set_pattern
= 'set-pattern'
CMD_set_prefix
= 'set-prefix'
CMD_set_prof_weight
= 'set-prof-weight'
CMD_set_substr
= 'set-substr'
CMD_special_interrupt
= 'special-interrupt'
CMD_stc_status
= 'stc-status'
CMD_step_break
= 'step-break'
CMD_step_break_absolute
= 'step-break-absolute'
CMD_step_cycle
= 'step-cycle'
CMD_step_instruction
= 'step-instruction'
CMD_swerver_memory_debug
= 'debug'
CMD_swerver_memory_info
= 'info'
CMD_swerver_proc_mmu_i_tlb_entry
= 'i-tlb-entry'
CMD_swerver_proc_mmu_probe
= 'probe'
CMD_swerver_proc_mmu_regs
= 'regs'
CMD_swerver_proc_mmu_tlb
= 'tlb'
CMD_swerver_proc_mmu_trace
= 'trace'
CMD_swerver_thread_mmu_probe
= 'probe'
CMD_swerver_thread_mmu_read_spu_trap
= 'read-spu-trap'
CMD_swerver_thread_mmu_regs
= 'regs'
CMD_swerver_thread_mmu_set_spu_trap
= 'set-spu-trap'
CMD_swerver_thread_mmu_trace
= 'trace'
CMD_trace_cr
= 'trace-cr'
CMD_trace_exception
= 'trace-exception'
CMD_trace_hap
= 'trace-hap'
CMD_trace_io
= 'trace-io'
CMD_trap_info
= 'trap-info'
CMD_undisplay
= 'undisplay'
CMD_unload_module
= 'unload-module'
CMD_write_configuration
= 'write-configuration'
CMD_write_fp_reg_i
= 'write-fp-reg-i'
CMD_write_fp_reg_x
= 'write-fp-reg-x'
CMD_write_reg
= 'write-reg'
CMD_write_th_ctl_reg
= 'write-th-ctl-reg'
CMD_write_th_fp_reg_i
= 'write-th-fp-reg-i'
CMD_write_th_fp_reg_x
= 'write-th-fp-reg-x'
CMD_write_thread_status
= 'write-thread-status'
def __init__ (self
, id, sid
, addr
, cmd
, type):
tokens
= cmd
[i
+1:j
].split(';')
#print 'DBX: cmd=%s, tokens=%s' % (cmd, tokens) #DBX
self
.action
.append(tokens
[k
].strip())
return 'breakpoint=%d, sid=%d, addr=%#x, type=%s, enable=%d, hit=%d, ignore=%d, action=%s' % (self
.id, self
.sid
, self
.addr
, self
.type, self
.enable
, self
.hitCount
, self
.ignore
, self
.action
)
TODO we don't really use this any more, as of 5/10/05, and this
if self
.enable
== 1 and self
.addr
== pc
:
# a hit, is there an ignore count or do we just hit this same pc
if ((self
.ignore
== 0 and self
.justHit
== 0) or
(self
.ignore
> 0 and self
.hitCount
> self
.ignore
)):
## if self.hitCount > self.ignore:
## if (self.justHit == 1) and (self.ignore > 0):
def __init__ (self
, riesReposit
):
self
.riesReposit
= riesReposit
self
.topName
= self
.riesReposit
.topName
self
.ncpus
= self
.riesReposit
.ncpus
self
.ncores
= self
.riesReposit
.ncores
self
.nucores
= self
.riesReposit
.nucores
self
.nstrands
= self
.riesReposit
.nstrands
self
.nSpregs
= self
.riesReposit
.nSpregs
self
.nDpregs
= self
.riesReposit
.nDpregs
self
.nQpregs
= self
.riesReposit
.nQpregs
self
.nWinregs
= 16 #************CONSTANTS***********
self
.nWin
= 8 #XXX there should be a better way to initialize from backend
#sys.stderr.write('***config\n');
#sys.stderr.write(str(self.topName+' '))
#sys.stderr.write(str(self.ncpus))
#sys.stderr.write(str(self.ncores))
#sys.stderr.write(str(self.nstrands))
#sys.stderr.write('\nend config***\n')
self
.cpusize
= self
.ncores
* self
.nstrands
self
.coresize
= self
.nstrands
self
.cpusize
= self
.ncores
* self
.nucores
* self
.nstrands
self
.coresize
= self
.nucores
* self
.nstrands
self
.ucoresize
= self
.nstrands
self
.nstrandObjs
= self
.cpusize
* self
.ncpus
# thread state: 1 == enabled
# instr executed on each strand
self
.instrCount
= { 0:0 }
# breakpoint, id:vaddr (in uint64 format)
# the last strand that issued 'ssi'.
# TODO if a user call backend step() directly, it will bypass this
# lastTid tracking, it will also bypass breakpoint handling.
# ---> with breakpoint set in backend strand.step(), we can catch
# breakpoint now. 4/13/05
# thread/core/cpu mapping
self
.regmap
= RegisterMap
.RegisterMap(riesReposit
.optdir
['--ar'])
# register interactive commands
# allow registration of a command map to re-direct commands to
# a different command parser.
#######################################
#Function to check the argument types
self
.intStr
= '(^[0-9]+[lL]?$)|(^0[xX][0-9a-fA-F]+[lL]?$)'
self
.intStrRE
= re
.compile(self
.intStr
)
# import XX_Main.cc as nas, if available
if self
.riesReposit
.arch
== 'n2':
sys
.stderr
.write('ERROR: %s not a supported cpu type\n' % (self
.riesReposit
.arch
))
if self
.riesReposit
.arch
== 'n2':
import _N2_Python
as vonk
sys
.stderr
.write('ERROR: %s not a supported cpu type\n' % (self
.riesReposit
.arch
))
def checkArgs(self
,Args
):
"""Return a list of boolean values.
True if the arg is an int/long
matchOb
= self
.intStrRE
.match(arg
)
# Function to code double and quad precision
def codeFpreg(self
,regnum
, type):
"""type = 0, code double precision
return str(val
<< 1) # | (val & 0x10 >> 4))
return str(val
<< 2) # & ~0x3) << 1) | (val & 0x10 >> 4))
def truncVal(self
, val
, type):
"""truncate string if larger than
16 or 8 bytes depending on
#sys.stderr.write('DB: truncVal(): <%s>\n' % val)
if val
.startswith('0X') or val
.startswith('0x'):
# append 'L' to value to quiet complain about larger than 32bit value
#sys.stderr.write('DBX: truncVal(): int=%#x, hex=%s, len=%d\n' % (intval, hexval, length)) #DBX
if type == 0 and length
> 8:
return '0x'+hexval
[length
-8:]
elif type == 1 and length
> 16:
return '0x'+hexval
[length
-16:]
def polishCommand (self
, cmd
):
"""append 'L' to hex values and remove the command's trailing comment
#sys.stderr.write('DBX: polishCommand: cmd=<%s>\n' % (cmd)) #DBX
# TODO be aware that if '#' is part of a valid expression, this will
#print 'input cmd=%s' % cmd #DBX
# make sure the # is not embedded in '...' or "..."
# 'break' command can have {action...}, so don't remove the # in
j1
= cmd
.rfind("'", prev
, i
)
k1
= cmd
.rfind('"', prev
, i
)
l1
= cmd
.rfind('{', 0, i
)
#print 'i=%d j1=%d j2=%d k1=%d k2=%d l1=%d l2=%d' % (i, j1, j2, k1, k2, l1, l2) #DBX
if (((j1
> -1) and (j2
> -1) and (j1
< i
) and (i
< j2
)) or
((k1
> -1) and (k2
> -1) and (k1
< i
) and (i
< k2
)) or
((l1
> -1) and (l2
> -1) and (l1
< i
) and (i
< l2
))):
# this one is embedded in '...' or "...", not a comment sign
# let's look for the next one
#print 'i=%d before cmd=%s' % (i, cmd) #DBX
#print ' after cmd=%s' % cmd #DBX
# append 'L' to any hex value that has at least 32 bits, no, just
# do it to all hex is simplier. Be aware of the overhead involved.
# TODO take this out once python 2.4 fix the problem, i.e.,
# treats number like 0x80000000 as negative int32.
if re
.match(hexRE
, tokens
[i
]) and tokens
[i
][-1].upper() != 'L':
tokens
[i
] = tokens
[i
] + 'L'
#sys.stderr.write('DBX: polishCommand: cmd2=<%s>\n' % ' '.join(tokens)) #DBX
#self.dbx('enter initCmd\n')
# % - read register by name
cmdSyntax
= '^%[a-zA-Z]+[a-zA-Z_\d]*'
cmdRE
= re
.compile(cmdSyntax
)
self
.cmdRE
[cmdRE
] = self
.handleRegName
# <breakpoint>.break, <breakpoint>.tbreak, break - set breakpoint
# <breakpoint>.break address [length] [-r] [-w] [-x]
# <breakpoint>.tbreak address [length] [-r] [-w] [-x]
# break address [length] [-r] [-w] [-x]
#cmdSyntax = '^(%s\d+\.)?(t)?%s\s+0[Xx][\dA-Fa-f]+' % (NAME_breakpoint, CMD_breakpoint_break)
cmdSyntax
= '^(%s\d+\.)?(t)?%s\s+' % (NAME_breakpoint
, CMD_breakpoint_break
)
cmdRE
= re
.compile(cmdSyntax
)
self
.cmdRE
[cmdRE
] = self
.handleBreak
# <context>.on, <context>.off - switch on context object
cmdSyntax
= '^%s\d+\.(%s|%s)' % (NAME_context
, CMD_context_on
, CMD_context_off
)
cmdRE
= re
.compile(cmdSyntax
)
#self.cmdRE[cmdRE] = self.handleTodo
# <image>.add-diff-file - add a diff file to the image
# <image>.add-diff-file filename
# <image>: memory0_image, memory_cache_image, memory_ciop_image
cmdSyntax
= '^%s\d+\.%s' % (NAME_image
, CMD_image_add_diff_file
)
cmdRE
= re
.compile(cmdSyntax
)
#self.cmdRE[cmdRE] = self.handleTodo
# <image>.add-partial-diff-file - add a partial diff file to the image
# <image>.add-partial-diff-file filename start size
cmdSyntax
= '^%s\d+\.%s' % (NAME_image
, CMD_image_add_partial_diff_file
)
cmdRE
= re
.compile(cmdSyntax
)
#self.cmdRE[cmdRE] = self.handleTodo
# <image>.commit - commit modifies pages
cmdSyntax
= '^%s\d+\.%s' % (NAME_image
, CMD_image_commit
)
cmdRE
= re
.compile(cmdSyntax
)
#self.cmdRE[cmdRE] = self.handleTodo
# <image>.limit-memory - limit memory usage
# <image>.limit-memory [Mb] ["swapfile"] ["swapdir"] [-k] [-r]
cmdSyntax
= '^%s\d+\.%s' % (NAME_image
, CMD_image_limit_memory
)
cmdRE
= re
.compile(cmdSyntax
)
#self.cmdRE[cmdRE] = self.handleTodo
# <image>.save - save image to disk
# <image>.save filename [start-byte] [length]
cmdSyntax
= '^%s\d+\.%s' % (NAME_image
, CMD_image_save
)
cmdRE
= re
.compile(cmdSyntax
)
#self.cmdRE[cmdRE] = self.handleTodo
# <image>.x - examine image data
# <image>.x offset [size]
cmdSyntax
= '^%s\d+\.%s' % (NAME_image
, CMD_image_x
)
cmdRE
= re
.compile(cmdSyntax
)
#self.cmdRE[cmdRE] = self.handleTodo
# <memory-space>.map - list memory map
cmdSyntax
= '^%s\d+\.%s' % (NAME_memory_space
, CMD_memory_space_map
)
cmdRE
= re
.compile(cmdSyntax
)
#self.cmdRE[cmdRE] = self.handleTodo
# <port-space>.map - list port map
cmdSyntax
= '^%s\d+\.%s' % (NAME_port_space
, CMD_port_space_map
)
cmdRE
= re
.compile(cmdSyntax
)
#self.cmdRE[cmdRE] = self.handleTodo
# <rtl-intf>.info - Drive and expect of rtl
cmdSyntax
= '^%s\d+\.%s' % (NAME_rtl_intf
, CMD_rtl_intf_info
)
cmdRE
= re
.compile(cmdSyntax
)
#self.cmdRE[cmdRE] = self.handleTodo
# <swerver-memory>.debug - setup the memory modeling debug level
# <swerver-memory>.debug debug_level
cmdSyntax
= '^%s\d+\.%s' % (NAME_swerver_memory
, CMD_swerver_memory_debug
)
cmdRE
= re
.compile(cmdSyntax
)
#self.cmdRE[cmdRE] = self.handleTodo
# <swerver-memory>.info - print information about swerver-memory model
cmdSyntax
= '^%s\d+\.%s' % (NAME_swerver_memory
, CMD_swerver_memory_info
)
cmdRE
= re
.compile(cmdSyntax
)
#self.cmdRE[cmdRE] = self.handleTodo
# <swerver-proc-mmu>.d-probe, <swerver-proc-mmu>.i-probe - check data tlb for
# <swerver-proc-mmu>.d-probe address
# <swerver-proc-mmu>.i-probe address
cmdSyntax
= '^%s\d+\.[di]-%s' % (NAME_swerver_proc_mmu
, CMD_swerver_proc_mmu_probe
)
cmdRE
= re
.compile(cmdSyntax
)
#self.cmdRE[cmdRE] = self.handleTodo
# <swerver-proc-mmu>.d-tlb, <swerver-proc-mmu>.i-tlb, <
# swerver-proc-mmu>.i-tlb-entry - print data tlb contents
# <swerver-proc-mmu>.d-tlb
# <swerver-proc-mmu>.i-tlb
# <swerver-proc-mmu>.i-tlb-entry idx
cmdSyntax
= '^%s\d+\.[di]-%s' % (NAME_swerver_proc_mmu
, CMD_swerver_proc_mmu_tlb
)
cmdRE
= re
.compile(cmdSyntax
)
self
.cmdRE
[cmdRE
] = self
.handleTLB
cmdSyntax
= '^%s\d+\.%s' % (NAME_swerver_proc_mmu
, CMD_swerver_proc_mmu_i_tlb_entry
)
cmdRE
= re
.compile(cmdSyntax
)
self
.cmdRE
[cmdRE
] = self
.handleTLB
# <swerver-proc-mmu>.regs - print mmu registers
# <swerver-proc-mmu>.regs
cmdSyntax
= '^%s\d+\.%s' % (NAME_swerver_proc_mmu
, CMD_swerver_proc_mmu_regs
)
cmdRE
= re
.compile(cmdSyntax
)
#self.cmdRE[cmdRE] = self.handleTodo
# <swerver-proc-mmu>.trace - toggle trace functionality
# <swerver-proc-mmu>.trace
cmdSyntax
= '^%s\d+\.%s' % (NAME_swerver_proc_mmu
, CMD_swerver_proc_mmu_trace
)
cmdRE
= re
.compile(cmdSyntax
)
#self.cmdRE[cmdRE] = self.handleTodo
# <swerver-thread-mmu>.d-probe, <swerver-thread-mmu>.i-probe - check data tlb
# <swerver-thread-mmu>.d-probe address
# <swerver-thread-mmu>.i-probe address
cmdSyntax
= '^%s\d+\.[di]-%s' % (NAME_swerver_thread_mmu
, CMD_swerver_thread_mmu_probe
)
cmdRE
= re
.compile(cmdSyntax
)
#self.cmdRE[cmdRE] = self.handleTodo
# <swerver-thread-mmu>.read-spu-trap - Display SPU traps.
# <swerver-thread-mmu>.read-spu-trap
cmdSyntax
= '^%s\d+\.%s' % (NAME_swerver_thread_mmu
, CMD_swerver_thread_mmu_read_spu_trap
)
cmdRE
= re
.compile(cmdSyntax
)
#self.cmdRE[cmdRE] = self.handleTodo
# <swerver-thread-mmu>.regs - print mmu registers
# <swerver-thread-mmu>.regs
cmdSyntax
= '^%s\d+\.%s' % (NAME_swerver_thread_mmu
, CMD_swerver_thread_mmu_regs
)
cmdRE
= re
.compile(cmdSyntax
)
self
.cmdRE
[cmdRE
] = self
.handleMmu
# <swerver-thread-mmu>.set-spu-trap - Set SPU traps.
# <swerver-thread-mmu>.set-spu-trap trap-type
cmdSyntax
= '^%s\d+\.%s' % (NAME_swerver_thread_mmu
, CMD_swerver_thread_mmu_set_spu_trap
)
cmdRE
= re
.compile(cmdSyntax
)
#self.cmdRE[cmdRE] = self.handleTodo
# <swerver-thread-mmu>.trace - toggle trace functionality
# <swerver-thread-mmu>.trace
cmdSyntax
= '^%s\d+\.%s' % (NAME_swerver_thread_mmu
, CMD_swerver_thread_mmu_trace
)
cmdRE
= re
.compile(cmdSyntax
)
#self.cmdRE[cmdRE] = self.handleTodo
# action - bind action to breakpoint
cmdSyntax
= '^%s\s+\d+' % (CMD_action
)
cmdRE
= re
.compile(cmdSyntax
)
#self.cmdRE[cmdRE] = self.handleTodo
# add-directory, clear-directories, print-directories - add a directory to
# add-directory "path" [-prepend]
cmdSyntax
= '^%s' % (CMD_add_directory
)
cmdRE
= re
.compile(cmdSyntax
)
#self.cmdRE[cmdRE] = self.handleTodo
cmdSyntax
= '^%s' % (CMD_clear_directories
)
cmdRE
= re
.compile(cmdSyntax
)
#self.cmdRE[cmdRE] = self.handleTodo
cmdSyntax
= '^%s' % (CMD_print_directories
)
cmdRE
= re
.compile(cmdSyntax
)
#self.cmdRE[cmdRE] = self.handleTodo
# api-apropos - search API help
# api-apropos "search-string"
cmdSyntax
= '^%s' % (CMD_api_apropos
)
cmdRE
= re
.compile(cmdSyntax
)
#self.cmdRE[cmdRE] = self.handleTodo
# api-help - get API help
cmdSyntax
= '^%s' % (CMD_api_help
)
cmdRE
= re
.compile(cmdSyntax
)
#self.cmdRE[cmdRE] = self.handleTodo
# apropos - search for text in documentation
cmdSyntax
= '^%s' % (CMD_apropos
)
cmdRE
= re
.compile(cmdSyntax
)
#self.cmdRE[cmdRE] = self.handleTodo
# break-cr, unbreak-cr - break on control register updates
# break-cr ("register"|-all|-list)
# unbreak-cr ("register"|-all|-list)
cmdSyntax
= '^(un)?%s' % (CMD_break_cr
)
cmdRE
= re
.compile(cmdSyntax
)
#self.cmdRE[cmdRE] = self.handleTodo
# break-exception, unbreak-exception - break on control register updates
# break-exception ("name"|number|-all|-list)
# unbreak-exception ("name"|number|-all|-list)
cmdSyntax
= '^(un)?%s' % (CMD_break_exception
)
cmdRE
= re
.compile(cmdSyntax
)
#self.cmdRE[cmdRE] = self.handleTodo
# break-hap, unbreak-hap - break on haps
# break-hap ("hap"|-all|-list)
# unbreak-hap ("hap"|-all|-list)
cmdSyntax
= '^(un)?%s' % (CMD_break_hap
)
cmdRE
= re
.compile(cmdSyntax
)
#self.cmdRE[cmdRE] = self.handleTodo
# break-io, unbreak-io - break on device accesses
# break-io ("device"|-all|-list)
# unbreak-io ("device"|-all|-list)
cmdSyntax
= '^(un)?%s' % (CMD_break_io
)
cmdRE
= re
.compile(cmdSyntax
)
#self.cmdRE[cmdRE] = self.handleTodo
# catch-exception, uncatch-exception - catch exceptions
# catch-exception [("name"|number|-all)]
# uncatch-exception [("name"|vector|-all)]
cmdSyntax
= '^(un)?%s' % (CMD_catch_exception
)
cmdRE
= re
.compile(cmdSyntax
)
#self.cmdRE[cmdRE] = self.handleTodo
# command-list - generate html document describing commands
#cmdSyntax = '^%s\s+\S+' % (CMD_command_list)
cmdSyntax
= '^%s' % (CMD_command_list
)
cmdRE
= re
.compile(cmdSyntax
)
#self.cmdRE[cmdRE] = self.handleTodo
# cycle-break-absolute, <processor>.cycle-break, <
# processor>.cycle-break-absolute, cycle-break - set absolute cycle
# <processor>.cycle-break cycles
# <processor>.cycle-break-absolute cycles
# cycle-break ["cpu-name"] cycles
# cycle-break-absolute ["cpu-name"] cycles
cmdSyntax
= '^(%s\d+\.)?%s' % (NAME_processor
, CMD_cycle_break_absolute
)
cmdRE
= re
.compile(cmdSyntax
)
#self.cmdRE[cmdRE] = self.handleTodo
cmdSyntax
= '^(%s\d+\.)?%s' % (NAME_processor
, CMD_cycle_break
)
cmdRE
= re
.compile(cmdSyntax
)
#self.cmdRE[cmdRE] = self.handleTodo
# debug-level - set or get the debug level
# debug-level "object-name" [level]
cmdSyntax
= '^%s' % (CMD_debug_level
)
cmdRE
= re
.compile(cmdSyntax
)
#self.cmdRE[cmdRE] = self.handleTodo
# delete - remove a breakpoint
#cmdSyntax = '^%s\s+(-all|\d+(\s+\d+)*)' % (CMD_delete)
cmdSyntax
= '^%s\s+' % (CMD_delete
)
cmdRE
= re
.compile(cmdSyntax
)
self
.cmdRE
[cmdRE
] = self
.handleDelete
# device-interrupt - Device interrupt
# device-interrupt issue-device target-thread intvec
cmdSyntax
= '^%s' % (CMD_device_interrupt
)
cmdRE
= re
.compile(cmdSyntax
)
#self.cmdRE[cmdRE] = self.handleTodo
# devs - list all devices in system
cmdSyntax
= '^%s' % (CMD_devs
)
cmdRE
= re
.compile(cmdSyntax
)
#self.cmdRE[cmdRE] = self.handleTodo
# disassemble, <processor>.disassemble - disassemble instructions
# <processor>.disassemble [address] [count]
# disassemble ["cpu-name"] [address] [count]
cmdSyntax
='^(%s\d+\.%s\s*)|^(%s(\s*%s\d+)?\s*)' % (NAME_processor
, CMD_disassemble
,CMD_disassemble
,NAME_processor
)
cmdRE
= re
.compile(cmdSyntax
)
self
.cmdRE
[cmdRE
] = self
.handleDisassemble
# display - print expression at prompt
# display ["expression"] [-l] [-p] [-t]
cmdSyntax
= '^%s' % (CMD_display
)
cmdRE
= re
.compile(cmdSyntax
)
#self.cmdRE[cmdRE] = self.handleTodo
# echo - echo a value to screen
# echo [("string"|integer|float)]
#cmdSyntax = '^(%s|%s\s+.*)' % (CMD_echo, CMD_echo)
cmdSyntax
= '^%s' % (CMD_echo
)
cmdRE
= re
.compile(cmdSyntax
)
self
.cmdRE
[cmdRE
] = self
.handleEcho
# enable, disable - enable/disable breakpoint
#cmdSyntax = '^%s\s+(-all|\d+)' % (CMD_enable)
cmdSyntax
= '^(%s|%s\s+.*)' % (CMD_enable
, CMD_enable
)
cmdRE
= re
.compile(cmdSyntax
)
self
.cmdRE
[cmdRE
] = self
.handleEnable
cmdSyntax
= '^(%s|%s\s+.*)' % (CMD_disable
, CMD_disable
)
cmdRE
= re
.compile(cmdSyntax
)
self
.cmdRE
[cmdRE
] = self
.handleDisable
# enable-external-commands - enable external command port
# enable-external-commands [port]
cmdSyntax
= '^%s' % (CMD_enable_external_commands
)
cmdRE
= re
.compile(cmdSyntax
)
#self.cmdRE[cmdRE] = self.handleTodo
# enable-real-time-mode, disable-real-time-mode - set real time mode
# enable-real-time-mode [speed] [check_interval]
cmdSyntax
= '^%s' % (CMD_enable_real_time_mode
)
cmdRE
= re
.compile(cmdSyntax
)
#self.cmdRE[cmdRE] = self.handleTodo
cmdSyntax
= '^%s' % (CMD_disable_real_time_mode
)
cmdRE
= re
.compile(cmdSyntax
)
#self.cmdRE[cmdRE] = self.handleTodo
cmdSyntax
= '^%s' % (CMD_eosl
)
cmdRE
= re
.compile(cmdSyntax
)
#self.cmdRE[cmdRE] = self.handleTodo
# expect - fail if not equal
#cmdSyntax = '^%s\s+(\(.+\)\s+(\d+|0[Xx][\dA-Fa-f]+)|(\d+|0[Xx][\dA-Fa-f]+)\s+(\d+|0[Xx][\dA-Fa-f]+))' % (CMD_expect)
cmdSyntax
= '^%s\s+\S+' % (CMD_expect
)
cmdRE
= re
.compile(cmdSyntax
)
self
.cmdRE
[cmdRE
] = self
.handleExpect
# gdb-remote - start gdb-remote
cmdSyntax
= '^%s' % (CMD_gdb_remote
)
cmdRE
= re
.compile(cmdSyntax
)
#self.cmdRE[cmdRE] = self.handleTodo
# get, <memory-space>.get - get value of physical address
# <memory-space>.get address [size] [-l] [-b]
# get address [size] [-l] [-b]
#cmdSyntax = '^(%s\d+\.)?%s\s+0[Xx][\dA-Fa-f]+' % (NAME_memory_space, CMD_get)
cmdSyntax
= '^(%s\d+\.)?%s\s+' % (NAME_memory_space
, CMD_get
)
cmdRE
= re
.compile(cmdSyntax
)
self
.cmdRE
[cmdRE
] = self
.handleGet
# help [("help-string"|-all)]
cmdSyntax
= '^(%s\s*$|%s\s+\S+)' % (CMD_help
, CMD_help
)
cmdRE
= re
.compile(cmdSyntax
)
self
.cmdRE
[cmdRE
] = self
.handleHelp
# hex - display integer in hexadecimal notation
cmdSyntax
= '^%s\s+\d+' % (CMD_hex
)
cmdRE
= re
.compile(cmdSyntax
)
#self.cmdRE[cmdRE] = self.handleTodo
# ignore - set ignore count for a breakpoint
#cmdSyntax = '^%s\s+\d+\s+\d+' % (CMD_ignore)
cmdSyntax
= '^%s\s+' % (CMD_ignore
)
cmdRE
= re
.compile(cmdSyntax
)
self
.cmdRE
[cmdRE
] = self
.handleIgnore
# instruction-profile-mode - set or get current mode for instruction
# instruction-profile-mode ["mode"]
cmdSyntax
= '^%s' % (CMD_instruction_profile_mode
)
cmdRE
= re
.compile(cmdSyntax
)
#self.cmdRE[cmdRE] = self.handleTodo
# io ["object-name"] [count]
cmdSyntax
= '^%s' % (CMD_io
)
cmdRE
= re
.compile(cmdSyntax
)
#self.cmdRE[cmdRE] = self.handleTodo
# io-buffer - set I/O buffer size
# io-buffer ["object-name"] [size]
cmdSyntax
= '^%s' % (CMD_io_buffer
)
cmdRE
= re
.compile(cmdSyntax
)
#self.cmdRE[cmdRE] = self.handleTodo
# istc-enable, dstc-disable, dstc-enable, istc-disable, stc-status - enable
# or disable internal caches
cmdSyntax
= '^%s' % (CMD_dstc_disable
)
cmdRE
= re
.compile(cmdSyntax
)
#self.cmdRE[cmdRE] = self.handleTodo
cmdSyntax
= '^%s' % (CMD_dstc_enable
)
cmdRE
= re
.compile(cmdSyntax
)
#self.cmdRE[cmdRE] = self.handleTodo
cmdSyntax
= '^%s' % (CMD_istc_disable
)
cmdRE
= re
.compile(cmdSyntax
)
#self.cmdRE[cmdRE] = self.handleTodo
cmdSyntax
= '^%s' % (CMD_istc_enable
)
cmdRE
= re
.compile(cmdSyntax
)
#self.cmdRE[cmdRE] = self.handleTodo
cmdSyntax
= '^%s' % (CMD_stc_status
)
cmdRE
= re
.compile(cmdSyntax
)
#self.cmdRE[cmdRE] = self.handleTodo
# le-checksum - display the checksum of the module-list attribute
cmdSyntax
= '^%s' % (CMD_le_checksum
)
cmdRE
= re
.compile(cmdSyntax
)
#self.cmdRE[cmdRE] = self.handleTodo
# le-permissions - describe the current 'Limited Edition' permissions
cmdSyntax
= '^%s' % (CMD_le_permissions
)
cmdRE
= re
.compile(cmdSyntax
)
#self.cmdRE[cmdRE] = self.handleTodo
# list-attributes - list all attributes
# list-attributes "object-name" ["attribute-name"]
cmdSyntax
= '^%s' % (CMD_list_attributes
)
cmdRE
= re
.compile(cmdSyntax
)
#self.cmdRE[cmdRE] = self.handleTodo
# list-breakpoints - print information about breakpoints
# list-breakpoints [-all]
cmdSyntax
= '^%s' % (CMD_list_breakpoints
)
cmdRE
= re
.compile(cmdSyntax
)
self
.cmdRE
[cmdRE
] = self
.handleListBreak
# list-classes - list all configuration classes
cmdSyntax
= '^%s' % (CMD_list_classes
)
cmdRE
= re
.compile(cmdSyntax
)
#self.cmdRE[cmdRE] = self.handleTodo
# list-failed-modules - show list of failed modules
# list-failed-modules ["substr"] [-v]
cmdSyntax
= '^%s' % (CMD_list_failed_modules
)
cmdRE
= re
.compile(cmdSyntax
)
#self.cmdRE[cmdRE] = self.handleTodo
# list-haps - print list of haps
# list-haps ["substring"]
cmdSyntax
= '^%s' % (CMD_list_haps
)
cmdRE
= re
.compile(cmdSyntax
)
#self.cmdRE[cmdRE] = self.handleTodo
# list-modules - list loadable modules
# list-modules ["substr"] [-v]
cmdSyntax
= '^%s' % (CMD_list_modules
)
cmdRE
= re
.compile(cmdSyntax
)
#self.cmdRE[cmdRE] = self.handleTodo
# list-namespaces - list all namespaces
cmdSyntax
= '^%s' % (CMD_list_namespaces
)
cmdRE
= re
.compile(cmdSyntax
)
#self.cmdRE[cmdRE] = self.handleTodo
# list-profilers - list description of active profilers
cmdSyntax
= '^%s' % (CMD_list_profilers
)
cmdRE
= re
.compile(cmdSyntax
)
#self.cmdRE[cmdRE] = self.handleTodo
# list-vars - list environment variables
cmdSyntax
= '^%s' % (CMD_list_vars
)
cmdRE
= re
.compile(cmdSyntax
)
#self.cmdRE[cmdRE] = self.handleTodo
# load-binary, <memory-space>.load-binary - load binary (executable) file
# <memory-space>.load-binary filename [offset] [-v] [-pa]
# load-binary filename [offset] [-v] [-pa]
#cmdSyntax = '^(%s\d+\.)?%s\s+\S+' % (NAME_memory_space, CMD_load_binary)
cmdSyntax
= '^(%s\d+\.)?%s' % (NAME_memory_space
, CMD_load_binary
)
cmdRE
= re
.compile(cmdSyntax
)
#self.cmdRE[cmdRE] = self.handleTodo
# load-file, <memory-space>.load-file - load file into memory
# <memory-space>.load-file filename [offset]
# load-file filename [offset]
#cmdSyntax = '^(%s\d+\.)?%s\s+\S+' % (NAME_memory_space, CMD_load_file)
cmdSyntax
= '^(%s\d+\.)?%s' % (NAME_memory_space
, CMD_load_file
)
cmdRE
= re
.compile(cmdSyntax
)
#self.cmdRE[cmdRE] = self.handleTodo
# load-module - load module into system
cmdSyntax
= '^%s' % (CMD_load_module
)
cmdRE
= re
.compile(cmdSyntax
)
#self.cmdRE[cmdRE] = self.handleTodo
# load-veri-file - load the physical addres from verilog memory format file
# load-veri-file "verilog-mem-format-file-name"
cmdSyntax
= '^%s' % (CMD_load_veri_file
)
cmdRE
= re
.compile(cmdSyntax
)
#self.cmdRE[cmdRE] = self.handleTodo
# logical-to-physical, <processor>.logical-to-physical - translate logical
# <processor>.logical-to-physical address
# logical-to-physical ["cpu-name"] address
cmdSyntax
= '^(%s\d+\.)?%s' % (NAME_processor
, CMD_logical_to_physical
)
cmdRE
= re
.compile(cmdSyntax
)
self
.cmdRE
[cmdRE
] = self
.handleVa2Pa
# magic-break-enable, magic-break-disable - install magic instruction hap
cmdSyntax
= '^%s' % (CMD_magic_break_enable
)
cmdRE
= re
.compile(cmdSyntax
)
#self.cmdRE[cmdRE] = self.handleTodo
cmdSyntax
= '^%s' % (CMD_magic_break_disable
)
cmdRE
= re
.compile(cmdSyntax
)
#self.cmdRE[cmdRE] = self.handleTodo
# memory-profile - enable or disable memory profiling
# memory-profile ["mode"]
cmdSyntax
= '^%s' % (CMD_memory_profile
)
cmdRE
= re
.compile(cmdSyntax
)
#self.cmdRE[cmdRE] = self.handleTodo
# module-list-refresh - create a new list of loadable modules
cmdSyntax
= '^%s' % (CMD_module_list_refresh
)
cmdRE
= re
.compile(cmdSyntax
)
#self.cmdRE[cmdRE] = self.handleTodo
# native-path - convert a filename to host native form
cmdSyntax
= '^%s' % (CMD_native_path
)
cmdRE
= re
.compile(cmdSyntax
)
#self.cmdRE[cmdRE] = self.handleTodo
# new-context - create a new context
cmdSyntax
= '^%s' % (CMD_new_context
)
cmdRE
= re
.compile(cmdSyntax
)
#self.cmdRE[cmdRE] = self.handleTodo
# output-radix - change the default output radix
cmdSyntax
= '^%s' % (CMD_output_radix
)
cmdRE
= re
.compile(cmdSyntax
)
#self.cmdRE[cmdRE] = self.handleTodo
# pdisassemble - disassemble instructions in physical memory
# pdisassemble [address] [count]
cmdSyntax
= '^%s' % (CMD_pdisassemble
)
cmdRE
= re
.compile(cmdSyntax
)
#self.cmdRE[cmdRE] = self.handleTodo
# penable, <processor>.disable, <processor>.enable, pdisable - switch
# pdisable [("cpu-name"|-all)]
# penable [("cpu-name"|-all)]
cmdSyntax
= '^(%s|%s\d+\.%s)' % (CMD_penable
, NAME_processor
, CMD_enable
)
cmdRE
= re
.compile(cmdSyntax
)
self
.cmdRE
[cmdRE
] = self
.handlePenable
cmdSyntax
= '^(%s|%s\d+\.%s)' % (CMD_pdisable
, NAME_processor
, CMD_disable
)
cmdRE
= re
.compile(cmdSyntax
)
self
.cmdRE
[cmdRE
] = self
.handlePdisable
# pio - print information about an object
cmdSyntax
= '^%s' % (CMD_pio
)
cmdRE
= re
.compile(cmdSyntax
)
#self.cmdRE[cmdRE] = self.handleTodo
# pipe - run commands through a pipe
cmdSyntax
= '^%s' % (CMD_pipe
)
cmdRE
= re
.compile(cmdSyntax
)
#self.cmdRE[cmdRE] = self.handleTodo
# pli-run - Run # of instruction through PLI command interface
#cmdSyntax = '^%s\s+\d+' % (CMD_pli_run)
cmdSyntax
= '^%s' % (CMD_pli_run
)
cmdRE
= re
.compile(cmdSyntax
)
#self.cmdRE[cmdRE] = self.handlePlirun
# pregs, <processor>.pregs - print cpu registers
# <processor>.pregs [-all]
# pregs ["cpu-name"] [-all]
cmdSyntax
= '^(%s\d+\.)?%s$|^(%s\d+\.)?%s\s+' % (NAME_processor
, CMD_pregs
, NAME_processor
, CMD_pregs
)
cmdRE
= re
.compile(cmdSyntax
)
self
.cmdRE
[cmdRE
] = self
.handlePregs
# fpregs, <processor>.fpregs - print cpu fp registers
cmdSyntax
= '^(%s\d+\.)?%s$|^(%s\d+\.)?%s\s+' % (NAME_processor
, CMD_fpregs
, NAME_processor
, CMD_fpregs
)
cmdRE
= re
.compile(cmdSyntax
)
self
.cmdRE
[cmdRE
] = self
.handleFpregs
# cmpregs, <processor>.cmpregs - print cmp registers
cmdSyntax
= '^(%s\d+\.)?%s$|^(%s\d+\.)?%s\s+' % (NAME_processor
, CMD_cmpregs
, NAME_processor
, CMD_cmpregs
)
cmdRE
= re
.compile(cmdSyntax
)
self
.cmdRE
[cmdRE
] = self
.handleCmpregs
# mmuregs, <processor>.mmuregs - print mmu registers
cmdSyntax
= '^(%s\d+\.)?%s$|^(%s\d+\.)?%s\s+' % (NAME_processor
, CMD_mmuregs
, NAME_processor
, CMD_mmuregs
)
cmdRE
= re
.compile(cmdSyntax
)
self
.cmdRE
[cmdRE
] = self
.handleMmuregs
# pregs-all - print all cpu registers
cmdSyntax
= '^%s' % (CMD_pregs_all
)
cmdRE
= re
.compile(cmdSyntax
)
#self.cmdRE[cmdRE] = self.handleTodo
# pregs-hyper, <processor>.pregs-hyper - print hypervisor registers
# <processor>.pregs-hyper [-all]
# pregs-hyper ["cpu-name"] [-all]
cmdSyntax
= '^(%s\d+\.)?%s' % (NAME_processor
, CMD_pregs_hyper
)
cmdRE
= re
.compile(cmdSyntax
)
#self.cmdRE[cmdRE] = self.handleTodo
# print - display integer in various bases
# print [(-x|-o|-b|-s|-d)] value [size]
#cmdSyntax = '^%s' % (CMD_print)
#cmdRE = re.compile(cmdSyntax)
#self.cmdRE[cmdRE] = self.handleTodo
# print-double-regs - print floating point registers as doubles
cmdSyntax
= '^%s' % (CMD_print_double_regs
)
cmdRE
= re
.compile(cmdSyntax
)
#self.cmdRE[cmdRE] = self.handleTodo
# print-event-queue - print event queue for processor
# print-event-queue ["cpu-name"] [queue]
cmdSyntax
= '^%s' % (CMD_print_event_queue
)
cmdRE
= re
.compile(cmdSyntax
)
#self.cmdRE[cmdRE] = self.handleTodo
# print-float-regs - print floating point registers
cmdSyntax
= '^%s' % (CMD_print_float_regs
)
cmdRE
= re
.compile(cmdSyntax
)
#self.cmdRE[cmdRE] = self.handleTodo
# print-float-regs-raw - print raw floating point register contents
cmdSyntax
= '^%s' % (CMD_print_float_regs_raw
)
cmdRE
= re
.compile(cmdSyntax
)
#self.cmdRE[cmdRE] = self.handleTodo
# print-instruction-queue - print instruction queue
# print-instruction-queue [-v]
cmdSyntax
= '^%s' % (CMD_print_instruction_queue
)
cmdRE
= re
.compile(cmdSyntax
)
#self.cmdRE[cmdRE] = self.handleTodo
# print-profile - print execution profile
# print-profile [address] [length]
cmdSyntax
= '^%s' % (CMD_print_profile
)
cmdRE
= re
.compile(cmdSyntax
)
#self.cmdRE[cmdRE] = self.handleTodo
# print-statistics, <processor>.print-statistics - print various statistics
# <processor>.print-statistics
# print-statistics [("cpu-name"|-all)]
cmdSyntax
= '^(%s\d+\.)?%s' % (NAME_processor
, CMD_print_statistics
)
cmdRE
= re
.compile(cmdSyntax
)
#self.cmdRE[cmdRE] = self.handleTodo
# print-time, <processor>.print-time - print simulated time
# print-time ["cpu-name"]
cmdSyntax
= '^(%s\d+\.)?%s' % (NAME_processor
, CMD_print_time
)
cmdRE
= re
.compile(cmdSyntax
)
#self.cmdRE[cmdRE] = self.handleTodo
# prof-page-details - print profile details for a page
# prof-page-details [address] [strand]
cmdSyntax
= '^%s' % (CMD_prof_page_details
)
cmdRE
= re
.compile(cmdSyntax
)
#self.cmdRE[cmdRE] = self.handleTodo
# prof-page-map - print summary profile statistics for each page
cmdSyntax
= '^%s' % (CMD_prof_page_map
)
cmdRE
= re
.compile(cmdSyntax
)
#self.cmdRE[cmdRE] = self.handleTodo
# prof-weight, set-prof-weight - print weighted result of profilers
# prof-weight [block-size] [count]
# set-prof-weight profiler weight
cmdSyntax
= '^%s' % (CMD_prof_weight
)
cmdRE
= re
.compile(cmdSyntax
)
#self.cmdRE[cmdRE] = self.handleTodo
cmdSyntax
= '^%s' % (CMD_set_prof_weight
)
cmdRE
= re
.compile(cmdSyntax
)
#self.cmdRE[cmdRE] = self.handleTodo
# pselect - select a processor
cmdSyntax
= '^%s' % (CMD_pselect
)
cmdRE
= re
.compile(cmdSyntax
)
self
.cmdRE
[cmdRE
] = self
.handlePselect
# quit - quit from system
cmdSyntax
= '^%s(\s+\d+)?' % (CMD_quit
)
cmdRE
= re
.compile(cmdSyntax
)
self
.cmdRE
[cmdRE
] = self
.handleQuit
# read-configuration - restore configuration
# read-configuration file
cmdSyntax
= '^%s' % (CMD_read_configuration
)
cmdRE
= re
.compile(cmdSyntax
)
#self.cmdRE[cmdRE] = self.handleTodo
# read-fp-reg-i - print floating point single register as integer
#cmdSyntax = '^%s\s+\d+' % (CMD_read_fp_reg_i)
cmdSyntax
= '^%s\s+' % (CMD_read_fp_reg_i
)
cmdRE
= re
.compile(cmdSyntax
)
self
.cmdRE
[cmdRE
] = self
.handleReadFpi
# read-fp-reg-x - print floating point double register as integer
#cmdSyntax = '^%s\s+\d+' % (CMD_read_fp_reg_x)
cmdSyntax
= '^%s\s+' % (CMD_read_fp_reg_x
)
cmdRE
= re
.compile(cmdSyntax
)
self
.cmdRE
[cmdRE
] = self
.handleReadFpx
# read-reg, <processor>.read-reg - read a register
# <processor>.read-reg "reg-name"
# read-reg ["cpu-name"] "reg-name"
#cmdSyntax = '^(%s\d+\.%s\s+\S+|%s(\s+%s\d+)?\s+\S+' % (NAME_processor, CMD_read_reg, CMD_read_reg, NAME_cpu)
cmdSyntax
= '^(%s\d+\.)?%s\s+' % (NAME_processor
, CMD_read_reg
)
cmdRE
= re
.compile(cmdSyntax
)
self
.cmdRE
[cmdRE
] = self
.handleReadReg
# read-sw-pcs - read all pc and npc of a swerver processor
# read-sw-pcs "swerver-num"
cmdSyntax
= '^%s' % (CMD_read_sw_pcs
)
cmdRE
= re
.compile(cmdSyntax
)
#self.cmdRE[cmdRE] = self.handleTodo
# read-th-ctl-reg - Control Register value of a thread
# read-th-ctl-reg thread control-register-num
#cmdSyntax = '^%s\s+\d+\s+\d+' % (CMD_read_th_ctl_reg)
cmdSyntax
= '^%s\s+' % (CMD_read_th_ctl_reg
)
cmdRE
= re
.compile(cmdSyntax
)
self
.cmdRE
[cmdRE
] = self
.handleReadCtlReg
# write-th-ctl-reg - Control Register value of a thread
# write-th-ctl-reg thread control-register-num value
cmdSyntax
= '^%s\s+' % (CMD_write_th_ctl_reg
)
cmdRE
= re
.compile(cmdSyntax
)
self
.cmdRE
[cmdRE
] = self
.handleWriteCtlReg
# read-th-fp-reg-i - Read single Fp Register value of a thread
# read-th-fp-reg-i thread register-num
#cmdSyntax = '^%s\s+\d+\s+\d+' % (CMD_read_th_fp_reg_i)
cmdSyntax
= '^%s\s+' % (CMD_read_th_fp_reg_i
)
cmdRE
= re
.compile(cmdSyntax
)
self
.cmdRE
[cmdRE
] = self
.handleReadThFpi
# read-th-fp-reg-x - Read double Fp Register value of a thread
# read-th-fp-reg-x thread register-num
#cmdSyntax = '^%s\s+\d+\s+\d+' % (CMD_read_th_fp_reg_x)
cmdSyntax
= '^%s\s+' % (CMD_read_th_fp_reg_x
)
cmdRE
= re
.compile(cmdSyntax
)
self
.cmdRE
[cmdRE
] = self
.handleReadThFpx
# read-th-reg - Register value of a window on a thread
# read-th-reg thread window register-num
#cmdSyntax = '^%s\s+\d+\s+\d+\s+\d+' % (CMD_read_th_reg)
cmdSyntax
= '^%s\s+' % (CMD_read_th_reg
)
cmdRE
= re
.compile(cmdSyntax
)
self
.cmdRE
[cmdRE
] = self
.handleReadThReg
# read-thread-status - Read Thread Status Register
# read-thread-status "thread"
cmdSyntax
= '^%s' % (CMD_read_thread_status
)
cmdRE
= re
.compile(cmdSyntax
)
#self.cmdRE[cmdRE] = self.handleTodo
# resolve-file - resolve a filename
# resolve-file "filename"
cmdSyntax
= '^%s' % (CMD_resolve_file
)
cmdRE
= re
.compile(cmdSyntax
)
#self.cmdRE[cmdRE] = self.handleTodo
# rtl_cycle - update the interface
cmdSyntax
= '^%s' % (CMD_rtl_cycle
)
cmdRE
= re
.compile(cmdSyntax
)
#self.cmdRE[cmdRE] = self.handleTodo
cmdSyntax
= '^(%s$|%s\s+\d+)' % (CMD_run
, CMD_run
)
cmdRE
= re
.compile(cmdSyntax
)
self
.cmdRE
[cmdRE
] = self
.handleRun
# runfast - start execution
cmdSyntax
= '^(%s$|%s\s+\d+)' % (CMD_runfast
, CMD_runfast
)
cmdRE
= re
.compile(cmdSyntax
)
self
.cmdRE
[cmdRE
] = self
.handleRunfast
# whatis - map va to symbol
cmdSyntax
= '^%s' % (CMD_whatis
)
cmdRE
= re
.compile(cmdSyntax
)
self
.cmdRE
[cmdRE
] = self
.handleWhatis
# run-command-file - run commands from a file
#cmdSyntax = '^%s\s+\S+' % (CMD_run_command_file)
cmdSyntax
= '^%s\s+' % (CMD_run_command_file
)
cmdRE
= re
.compile(cmdSyntax
)
self
.cmdRE
[cmdRE
] = self
.handleRunCommandFile
# run-python-file - execute Python file
# run-python-file filename
#cmdSyntax = '^%s\s+\S+' % (CMD_run_python_file)
cmdSyntax
= '^%s\s+' % (CMD_run_python_file
)
cmdRE
= re
.compile(cmdSyntax
)
self
.cmdRE
[cmdRE
] = self
.handleRunPythonFile
# set, <memory-space>.set - set physical address to specified value
# <memory-space>.set address value [size] [-l] [-b]
# set address value [size] [-l] [-b]
#cmdSyntax = '^(%s\d+\.)%s\s+0[xX][\dA-Fa-f]+\s+0[xX][\dA-Fa-f]+' % (NAME_memory_space, CMD_set)
cmdSyntax
= '^(%s\d+\.)?%s\s+' % (NAME_memory_space
, CMD_set
)
cmdRE
= re
.compile(cmdSyntax
)
self
.cmdRE
[cmdRE
] = self
.handleSet
# set-context, <processor>.set-context - set the current context of a cpu
# <processor>.set-context "context"
cmdSyntax
= '^(%s\d+\.)?%s' % (NAME_processor
, CMD_set_context
)
cmdRE
= re
.compile(cmdSyntax
)
#self.cmdRE[cmdRE] = self.handleTodo
# set-pattern - set an instruction pattern for a breakpoint
# set-pattern id "pattern" "mask"
cmdSyntax
= '^%s' % (CMD_set_pattern
)
cmdRE
= re
.compile(cmdSyntax
)
#self.cmdRE[cmdRE] = self.handleTodo
# set-pc, <processor>.set-pc - set the current processor's program counter
# <processor>.set-pc address
cmdSyntax
= '^(%s\d+\.)?%s\s+' % (NAME_processor
, CMD_set_pc
)
cmdRE
= re
.compile(cmdSyntax
)
self
.cmdRE
[cmdRE
] = self
.handleSetPc
# set-prefix - set a syntax prefix for a breakpoint
cmdSyntax
= '^%s' % (CMD_set_prefix
)
cmdRE
= re
.compile(cmdSyntax
)
#self.cmdRE[cmdRE] = self.handleTodo
# set-substr - set a syntax substring for a breakpoint
cmdSyntax
= '^%s' % (CMD_set_substr
)
cmdRE
= re
.compile(cmdSyntax
)
#self.cmdRE[cmdRE] = self.handleTodo
# special-interrupt - Special interrupt
# special-interrupt reset-type target-thread rstvec
cmdSyntax
= '^%s' % (CMD_special_interrupt
)
cmdRE
= re
.compile(cmdSyntax
)
#self.cmdRE[cmdRE] = self.handleTodo
# sstepi - step one instr of all swerver processor
cmdSyntax
= '^%s' % (CMD_sstepi
)
cmdRE
= re
.compile(cmdSyntax
)
#self.cmdRE[cmdRE] = self.handleTodo
# step-break-absolute, <processor>.step-break, <
# processor>.step-break-absolute, step-break - set step breakpoints
# <processor>.step-break instructions
# <processor>.step-break-absolute instructions
# step-break ["cpu-name"] instructions
# step-break-absolute ["cpu-name"] instructions
cmdSyntax
= '^(%s\d+\.)?%s' % (NAME_processor
, CMD_step_break
)
cmdRE
= re
.compile(cmdSyntax
)
#self.cmdRE[cmdRE] = self.handleTodo
cmdSyntax
= '^(%s\d+\.)?%s' % (NAME_processor
, CMD_step_break_absolute
)
cmdRE
= re
.compile(cmdSyntax
)
#self.cmdRE[cmdRE] = self.handleTodo
# step-cycle - step one or more cycles
#cmdSyntax = '^%s(\s+\d+)?' % (CMD_step_cycle)
cmdSyntax
= '^%s' % (CMD_step_cycle
)
cmdRE
= re
.compile(cmdSyntax
)
#self.cmdRE[cmdRE] = self.handleTodo
# step-instruction - step one or more instructions
# step-instruction [count]
#cmdSyntax = '^%s(\s+\d+)?' % (CMD_step_instruction)
cmdSyntax
= '^%s' % (CMD_step_instruction
)
cmdRE
= re
.compile(cmdSyntax
)
#self.cmdRE[cmdRE] = self.handleTodo
# stop - interrupt simulation
cmdSyntax
= '^%s' % (CMD_stop
)
cmdRE
= re
.compile(cmdSyntax
)
#self.cmdRE[cmdRE] = self.handleTodo
# swrun - start execution
#cmdSyntax = '^%s(\s+\d+)?' % (CMD_swrun)
cmdSyntax
= '^%s' % (CMD_swrun
)
cmdRE
= re
.compile(cmdSyntax
)
#self.cmdRE[cmdRE] = self.handleTodo
# trace-cr, untrace-cr - trace control register updates
# trace-cr ("register"|-all|-list)
# untrace-cr ("register"|-all|-list)
cmdSyntax
= '^(un)?%s' % (CMD_trace_cr
)
cmdRE
= re
.compile(cmdSyntax
)
#self.cmdRE[cmdRE] = self.handleTodo
# trace-exception, untrace-exception - trace exceptions
# trace-exception ("name"|number|-all|-list)
# untrace-exception ("name"|number|-all|-list)
cmdSyntax
= '^(un)?%s' % (CMD_trace_exception
)
cmdRE
= re
.compile(cmdSyntax
)
#self.cmdRE[cmdRE] = self.handleTodo
# trace-hap, untrace-hap - trace haps
# trace-hap ("hap"|-all|-list)
# untrace-hap ("hap"|-all|-list)
cmdSyntax
= '^(un)?%s' % (CMD_trace_hap
)
cmdRE
= re
.compile(cmdSyntax
)
#self.cmdRE[cmdRE] = self.handleTodo
# trace-io, untrace-io - trace device accesses
# trace-io ("device"|-all|-list)
# untrace-io ("device"|-all|-list)
cmdSyntax
= '^(un)?%s' % (CMD_trace_io
)
cmdRE
= re
.compile(cmdSyntax
)
#self.cmdRE[cmdRE] = self.handleTodo
# trap-info - print information about current traps
cmdSyntax
= '^%s' % (CMD_trap_info
)
cmdRE
= re
.compile(cmdSyntax
)
#self.cmdRE[cmdRE] = self.handleTodo
# unbreak - remove breakpoint range
# unbreak (id|-all) address length [-r] [-w] [-x]
#cmdSyntax = '^%s\s+(\d+|-all)' % (CMD_unbreak)
cmdSyntax
= '^%s' % (CMD_unbreak
)
cmdRE
= re
.compile(cmdSyntax
)
#self.cmdRE[cmdRE] = self.handleTodo
# undisplay - remove expression installed by display
# undisplay expression-id
cmdSyntax
= '^%s' % (CMD_undisplay
)
cmdRE
= re
.compile(cmdSyntax
)
#self.cmdRE[cmdRE] = self.handleTodo
# unload-module - unload module
cmdSyntax
= '^%s' % (CMD_unload_module
)
cmdRE
= re
.compile(cmdSyntax
)
#self.cmdRE[cmdRE] = self.handleTodo
# write-configuration - save configuration
# write-configuration file
cmdSyntax
= '^%s' % (CMD_write_configuration
)
cmdRE
= re
.compile(cmdSyntax
)
#self.cmdRE[cmdRE] = self.handleTodo
# write-fp-reg-i - write floating point single register as integer
# write-fp-reg-i reg-num value
#cmdSyntax = '^%s\s+\d+\s+(\d+|0[xX][\da-fA-F]+)' % (CMD_write_fp_reg_i)
cmdSyntax
= '^%s\s+' % (CMD_write_fp_reg_i
)
cmdRE
= re
.compile(cmdSyntax
)
self
.cmdRE
[cmdRE
] = self
.handleWriteFpi
# write-fp-reg-x - write floating point double register as integer
# write-fp-reg-x reg-num value
#cmdSyntax = '^%s\s+\d+\s+(\d+|0[xX][\da-fA-F]+)' % (CMD_write_fp_reg_x)
cmdSyntax
= '^%s\s+' % (CMD_write_fp_reg_x
)
cmdRE
= re
.compile(cmdSyntax
)
self
.cmdRE
[cmdRE
] = self
.handleWriteFpx
# write-reg, <processor>.write-reg - write to register
# <processor>.write-reg "reg-name" value
# write-reg ["cpu-name"] "reg-name" value
cmdSyntax
= '^(%s\d+\.)?%s\s+' % (NAME_processor
, CMD_write_reg
)
cmdRE
= re
.compile(cmdSyntax
)
self
.cmdRE
[cmdRE
] = self
.handleWriteReg
# write-th-fp-reg-i - Write double Fp Register value of a thread
# write-th-fp-reg-i thread register-num value
cmdSyntax
= '^%s\s+' % (CMD_write_th_fp_reg_i
)
cmdRE
= re
.compile(cmdSyntax
)
self
.cmdRE
[cmdRE
] = self
.handleWriteThFpi
# write-th-fp-reg-x - Write double Fp Register value of a thread
# write-th-fp-reg-x thread register-num value
cmdSyntax
= '^%s\s+' % (CMD_write_th_fp_reg_x
)
cmdRE
= re
.compile(cmdSyntax
)
self
.cmdRE
[cmdRE
] = self
.handleWriteThFpx
# write-thread-status - Write Thread Status Register
# write-thread-status "thread" value
cmdSyntax
= '^%s' % (CMD_write_thread_status
)
cmdRE
= re
.compile(cmdSyntax
)
#self.cmdRE[cmdRE] = self.handleTodo
# x, <memory-space>.x, <processor>.x, xp - examine raw memory contents
# <memory-space>.x address [size]
# <processor>.x address [size]
# x ["cpu-name"] address [size]
cmdSyntax
= '^(%s\d+|%s\d+)\.%s\s+0[xX][\da-fA-F]+' % (NAME_memory_space
, NAME_processor
, CMD_x
)
cmdRE
= re
.compile(cmdSyntax
)
#self.cmdRE[cmdRE] = self.handleTodo
cmdSyntax
= '^%s(\s+%s\d+)?\s+0[xX][\da-fA-F]+' % (CMD_x
, NAME_processor
)
cmdRE
= re
.compile(cmdSyntax
)
#self.cmdRE[cmdRE] = self.handleTodo
cmdSyntax
= '^%s\s+0[xX][\da-fA-F]+' % (CMD_xp
)
cmdRE
= re
.compile(cmdSyntax
)
#self.cmdRE[cmdRE] = self.handleTodo
##### extra commands #####
cmdSyntax
= '^%s\s+' % (CMD_ssi
)
cmdRE
= re
.compile(cmdSyntax
)
self
.cmdRE
[cmdRE
] = self
.handleStep
cmdSyntax
= '^%s' % (CMD_ALIAS
)
cmdRE
= re
.compile(cmdSyntax
)
self
.cmdRE
[cmdRE
] = self
.handleAlias
cmdSyntax
= '^%s' % (CMD_UNALIAS
)
cmdRE
= re
.compile(cmdSyntax
)
self
.cmdRE
[cmdRE
] = self
.handleUnalias
#TODO reset, in current form, does not work as intended.
## cmdSyntax = '^%s' % (CMD_RESET)
## cmdRE = re.compile(cmdSyntax)
## self.cmdRE[cmdRE] = self.handleReset
# keep a list of all the keys, do this AFTER all the commands are
self
.cmdList
= self
.cmdRE
.keys()
#self.dbx('cmdList=%s\n' % (self.cmdList))
# DOCS[cmd]=('cmd syntax', 'CMD', 'short-desc', 'long-desc')
self
.DOCS
['set-pc'] = ("set-pc", 'CMD', "set a strand's pc", 'syntax: set-pc address')
self
.DOCS
['set'] = ("set", 'CMD', 'set value at a memory location', 'syntax: set [v:]address value [size]')
self
.DOCS
['get'] = ("get", 'CMD', 'get value from a memory location', 'syntax: get [v:]address [size]')
self
.DOCS
['write-th-fp-reg-i'] = ("write-th-fp-reg-i", 'CMD', 'write to a floating-point single register', 'syntax: write-th-fp-reg-i thread register-num value')
self
.DOCS
['write-th-fp-reg-x'] = ("write-th-fp-reg-x", 'CMD', 'write to a floating-point double register', 'syntax: write-th-fp-reg-x thread register-num value')
self
.DOCS
['read-th-fp-reg-i'] = ("read-th-fp-reg-i", 'CMD', 'read a floating-point single register', 'syntax: read-th-fp-reg-i thread reg-num')
self
.DOCS
['read-th-fp-reg-x'] = ("read-th-fp-reg-x", 'CMD', 'read a floating-point double register', 'syntax: read-th-fp-reg-x thread reg-num')
self
.DOCS
['write-fp-reg-i'] = ("write-fp-reg-i", 'CMD', 'write to a floating-point single register of current strand', 'syntax: write-fp-reg-i register-num value')
self
.DOCS
['write-fp-reg-x'] = ("write-fp-reg-x", 'CMD', 'write to a floating-point double register of current strand', 'syntax: write-fp-reg-x register-num value')
self
.DOCS
['read-fp-reg-i'] = ("read-fp-reg-i", 'CMD', 'read a floating-point single register of current strand', 'syntax: read-fp-reg-i register-num')
self
.DOCS
['read-fp-reg-x'] = ("read-fp-reg-x", 'CMD', 'read a floating-point double register of current strand', 'syntax: read-fp-reg-x register-num')
self
.DOCS
['write-reg'] = ("write-reg", 'CMD', 'write to a register', 'syntax: write-reg [cpu-name] reg-name value')
self
.DOCS
['read-reg'] = ("read-reg", 'CMD', 'read a register', 'syntax: read-reg [cpu-name] reg-name')
self
.DOCS
['read-th-reg'] = ("read-th-reg", 'CMD', 'read a register of a specified strand', 'syntax: read-th-reg thread window register-num')
self
.DOCS
['read-th-ctl-reg'] = ("read-th-ctl-reg", 'CMD', 'read a control register of a specified strand', 'syntax: read-th-ctl-reg thread control-register-num')
self
.DOCS
['write-th-ctl-reg'] = ("write-th-ctl-reg", 'CMD', 'write to a control register of a specified strand', 'syntax: write-th-ctl-reg thread control-register-num value')
self
.DOCS
['echo'] = ("echo", 'CMD', 'echo a string or value', 'syntax: echo [("string"|integer|float)]')
self
.DOCS
['expect'] = ("expect", 'CMD', 'compare two values, exit if the values do not match', 'syntax: expect i1 i2')
self
.DOCS
['%'] = ("%", 'CMD', 'read a register', 'syntax: %regname')
#self.DOCS['ssi'] = ("ssi", 'CMD', 'step instruction(s) on strand(s)', 'syntax: ssi cN, ssi sN, ssi lN')
self
.DOCS
['pregs'] = ("pregs", 'CMD', 'print out integer/floating-point/control registers', 'syntax: pregs [cpu-name] [-all]')
self
.DOCS
['fpregs'] = ("fpregs", 'CMD', 'print out floating-point registers', 'syntax: fpregs [cpu-name]')
self
.DOCS
['cmpregs'] = ("cmpregs", 'CMD', 'print out cmp registers', 'syntax: cmpregs [cpu-name]')
self
.DOCS
['mmuregs'] = ("mmuregs", 'CMD', 'print out mmu registers', 'syntax: mmuregs [cpu-name]')
self
.DOCS
['stmmuN.regs'] = ("stmmuN.regs", 'CMD', 'print out mmu registers', 'syntax: stmmuN.regs')
self
.DOCS
['swmmuN.d-tlb'] = ("swmmuN.d-tlb", 'CMD', 'print out d-tlb values', 'syntax: swmmuN.d-tlb')
self
.DOCS
['swmmuN.i-tlb'] = ("swmmuN.i-tlb", 'CMD', 'print out i-tlb values', 'syntax: swmmuN.i-tlb')
self
.DOCS
['break'] = ("break", 'CMD', 'set a breakpoint', 'syntax: break 0xpc|v:0xva|p:0xpa [sid=-1], break &symbol [sid=-1]')
self
.DOCS
['delete'] = ("delete", 'CMD', 'delete a breakpoint', 'syntax: delete (-all|id)')
self
.DOCS
['enable'] = ("enable", 'CMD', 'enable a breakpoint', 'syntax: enable (-all|id)')
self
.DOCS
['disable'] = ("disable", 'CMD', 'disable a breakpoint', 'syntax: disable (-all|id)')
self
.DOCS
['pdisable'] = ("pdisable", 'CMD', 'disable a strand', 'syntax: pdisable [(cpu-name|-all)]')
self
.DOCS
['penable'] = ("penable", 'CMD', 'enable one or more strands', 'syntax: penable [(cpu-name|-all|0x3210)]')
self
.DOCS
['pmask'] = ("pmask", 'CMD', 'control strand enabling in SAM setting', 'syntax: pmask [hex - one bit per strand, lowest bit as strand0]')
self
.DOCS
['run'] = ("run", 'CMD', 'continue to execute instructions, until hit breakpoint or exit', 'syntax: run [count] [strand-id]')
#self.DOCS['runfast'] = ("runfast", 'CMD', 'execute instructions in fast mode', 'syntax: runfast [count] [strand-id]')
self
.DOCS
['whatis'] = ("whatis", 'CMD', 'map a VA/PA to symbol+offset', 'syntax: whatis 0xva|p:0xpa')
self
.DOCS
['alias'] = ("alias", 'CMD', 'set an alias', 'syntax: alias zzz z1, e.g., alias pr print "%s=%#x" % ($1,$2)')
self
.DOCS
['unalias'] = ("unalias", 'CMD', 'unalias an alias', 'syntax: unalias zzz [zzz]* | -all')
#self.DOCS['reset'] = ("reset", 'CMD', "reset all strands' back to a system reset state", 'syntax: reset [traptype=0x1]')
#self.DOCS['ignore'] = ("ignore", 'CMD', 'ignore hitting breakpoint N times', 'syntax: ignore id num')
self
.DOCS
['list-breakpoints'] = ("list-breakpoints", 'CMD', 'list all breakpoints', 'syntax: list-breakpoints')
self
.DOCS
['pselect'] = ("pselect", 'CMD', 'select a strand to be the current strand', 'syntax: pselect [cpu-name]')
self
.DOCS
['quit'] = ("quit", 'CMD', 'terminate the execution', 'syntax: quit [status]')
self
.DOCS
['run-command-file'] = ("run-command-file", 'CMD', 'execute a command file', 'syntax: run-command-file file')
self
.DOCS
['run-python-file'] = ("run-python-file", 'CMD', 'execute a python file', 'syntax: run-python-file file')
self
.DOCS
['logical-to-physical'] = ("logical-to-physical", 'CMD', 'convert logical address to physical address', 'syntax: logical-to-physical [cpu-name] address')
self
.DOCS
['disassemble'] = ("disassemble", 'CMD', 'disassembler one or more instructions', 'syntax: [thN.]disassemble [address [count]]')
def showDoc (self
, key
=None):
"""return 1 means a match is found, 0 means no match
# strip off ' ', '(', or ')', they are not part of the key
if self
.DOCS
.has_key(key
):
(func
,type,shortd
,longd
) = self
.DOCS
[key
]
print '%s: %s: \t%s' % (type, func
, shortd
)
if longd
and longd
!= 'TODO':
for (key2
,(func
,type,shortd
,longd
)) in self
.DOCS
.items():
if not byType
.has_key(type):
byType
[type][key2
] = (func
,type,shortd
,longd
)
klist3
= byType
[key2
].keys()
(func
,type,shortd
,longd
) = byType
[key2
][key3
]
#print '%s: %s: \t%s' % (type, func, shortd)
print '%s: %s' % (type, func
)
def registerCommand (self
, key
, cmdlist
):
#@new_command("write-th-fp-reg-x", write_th_fp_reg_x_cmd,
# args = [arg(int_t, "thread"), arg(int_t, "register-num"), arg(integer_t, "value")],
# type = "niagara commands",
# short = "Write double Fp Register value of a thread",
# Write double precision fp-reg. """)
#self.dbx('key=%s, cmdlist=%s\n' % (key, cmdlist))
if type(cmdlist
) is types
.ListType
:
oneline
+= ' ' + cmd
.strip()
#self.dbx('oneline=%s\n' % (oneline))
lindex
= oneline
.find(',')
rindex
= oneline
.find(',', lindex
+1)
if lindex
> -1 and rindex
> -1:
func
= oneline
[lindex
+1:rindex
].strip()
#self.wrongSyntax(oneline)
# TODO we don't keep track the following values yet
lindex
= oneline
.find('[', rindex
+1)
rindex
= oneline
.find(']', lindex
+1)
if lindex
> -1 and rindex
> -1:
args
= oneline
[lindex
+1:rindex
].strip()
# squeeze out blank space(s)
argcount
= args
.count('arg(')
lindex
= oneline
.find('"', rindex
+1)
rindex
= oneline
.find('"', lindex
+1)
if lindex
> -1 and rindex
> -1:
ctype
= oneline
[lindex
+1:rindex
].strip()
lindex
= oneline
.find('"', rindex
+1)
rindex
= oneline
.find('"', lindex
+1)
if lindex
> -1 and rindex
> -1:
short
= oneline
[lindex
+1:rindex
].strip()
lindex
= oneline
.find('"', rindex
+1)
rindex
= oneline
.rfind('"', lindex
+1)
if lindex
> -1 and rindex
> -1:
doc
= oneline
[lindex
+1:rindex
].strip('"').strip()
#self.dbx('key=%s\n' % (key))
#self.dbx('func=%s\n' % (func))
#self.dbx('args=%s\n' % (args))
#self.dbx('argcount=%s\n' % (argcount))
#self.dbx('ctype=%s\n' % (ctype))
#self.dbx('short=%s\n' % (short))
#self.dbx('doc=%s\n' % (doc))
cmdSyntax
= '^%s\s+' % (key
)
cmdSyntax
= '^%s$' % (key
)
cmdRE
= re
.compile(cmdSyntax
)
self
.cmdExt
[cmdRE
] = (func
, argcount
)
self
.registerDoc(key
, key
, 'CMD-EXT', short
, doc
)
def registerDoc (self
, key
, fname
, type, shortdoc
, longdoc
):
self
.DOCS
[key
] = (fname
, type, shortdoc
, longdoc
)
def setNstrandObjs (self
, count
):
if self
.nstrandObjs
!= count
:
sys
.stderr
.write('WARNING: CmdParserNi: setNstrandObjs: self.nstrandObjs=%d, count=%d\n' % (self
.nstrandObjs
, count
))
while i
< self
.nstrandObjs
:
# 5/25/05: penable/pdisable will update CMP registers, and step()
# is controlled by core_running_status, so frontend thdEnable[]
def registerCmdMap (self
, cmdMap
):
def parseCmd (self
, line
, **parms
):
#self.dbx('DBX: enter parseCmd(%s)\n' % (line)) #DBX
return self
._parseCmd
(line
, **parms
)
sys
.stderr
.write('Wrong command syntax: <%s>, ex=%s\n' % (line
, ex
))
def _parseCmd (self
, line
, **parms
):
#self.dbx('DBX: enter _parseCmd(%s)\n' % (line)) #DBX
# preserve leading white space
while (i
< n
) and (line
[i
] in string
.whitespace
):
if self
.riesReposit
.running
== 1:
# check to see if the 'run' non-blocking command has hit a bpoint
#bid = self.riesReposit.riesling.getBreakpointTablePtr().queryLast()
## bid = self.riesReposit.riesling.bp_table.hit_bp()
## #sid = self.riesReposit.riesling.getBreakpointTablePtr().queryLastSid()
## sid = self.riesReposit.riesling.bp_table.hit_strand()
## #TODO what to do if bpCmd is not none?
## bpCmd = self.showBreakpoint(sid, bid)
#print 'DBX: alias: cmd=%s' % cmd #DBX
if self
.alias
.has_key(tokens
[0]):
#cmd = self.alias[tokens[0]] + ' ' + ' '.join(tokens[1:])
cmd
= self
.alias
[tokens
[0]]
#print 'DBX: alias: cmd0=%s' % cmd #DBX
# there are embedded parameters
for i
in range(1, len(tokens
)):
cmd
= cmd
.replace(('$%d' % i
), tokens
[i
])
#print 'DBX: alias: cmd%d=%s' % (i ,cmd) #DBX
while cmd
.find('$') > -1:
# if there are extra (optional) $parameter, get rid of them
cmd
= cmd
.replace(('$%d' % i
), '')
cmd
= cmd
+ ' ' + ' '.join(tokens
[1:])
#print 'DBX: alias: final cmd=%s' % cmd #DBX
if tokens
[0] == CMD_ALIAS
:
# replace % variable, e.g., %pc, with RS_read_register_name(), so they
# can be used in any expression, e.g., "print '%#x' % %pc", hex(%pc),
cmd
= self
.replaceToken(cmd
)
# TODO we would like to collect cmd ouput in variable 'cmdOut' so that
# the output can be processed, but current structure does not
# if the program is in running mode, accept only 'stop' or 'quit'
if (not sam
.is_stopped()) and ((cmd
!= 'stop') and (cmd
!= 'quit') and (not cmd
.startswith('mips'))):
sys
.stderr
.write("not in stop state, enter 'stop' first before issue the command\n")
returnCmd
= self
.cmdMap
.issueCmd(cmd
, cmdOut
, self
.riesReposit
)
# return of 'None' means the command has a match in cmdMap and
# had been executed, so go no further.
# for 'run N' and 'stepi N', we need to check if there is
#TODO if it is a 'run' command, cannot check it here, and it
# is hard to check whether a 'run' hit a breakpoint at
# all, so we won't be able to do showBreakpoint() for
# non-blocking 'run' command.
if ((tokens
[0] == 'run') or (tokens
[0] == 'stepi')):
#bid = self.riesReposit.riesling.getBreakpointTablePtr().query()
## bid = self.riesReposit.riesling.bp_table.last_hit_bp()
## #sid = self.riesReposit.riesling.getBreakpointTablePtr().querySid()
## sid = self.riesReposit.riesling.bp_table.last_hit_strand()
## bpCmd = self.showBreakpoint(sid, bid)
# if no match, use the returned command (likely the original
# cmd) for further processing
#sys.stderr.write('DBX: line=<%s>, cmd=<%s>, cmdkey=<%s>\n' % (line, cmd, cmdkey)) #DBX
if cmdkey
== CMD_pli_run
and (parms
['socketInit'] == 1):
# pli-run command is valid only if pli-socket layer is init'ed
self
.riesReposit
.socketAPI
.plirun(int(tokens
[1]))
self
.riesReposit
.socketAPI
.plirun()
sys
.stderr
.write('WARNING: socketAPI exception, ex=%s\n' % (ex
))
#sys.stderr.write('DBX: @def=<%s>\n' % (cmd)) #DBX
# simics uses @def foo() ---> @foo() syntax, bring
# it back to normal def foo() ---> foo()
mindex
= cmd
.find('(', lindex
)
fname
= cmd
[lindex
+1:mindex
].strip()
func
= cmd
[lindex
+1:rindex
].strip()
self
.registerDoc(fname
, func
, '@DEF', '@def '+func
, None)
elif cmdkey
.startswith('@new_command') or cmdkey
.startswith('new_command'):
lindex
= cmd
.find('"', 0, eindex
)
rindex
= cmd
.find('"', lindex
+1, eindex
)
if lindex
== -1 or rindex
== -1:
key
= cmd
[lindex
+1:rindex
]
self
.registerCommand(key
, cmd
)
# match command extension first
for key
in self
.cmdExt
.keys():
cmd
= self
.polishCommand(cmd
)
(func
,argcount
) = self
.cmdExt
[key
]
return self
.dispatcher(cmd
, func
, argcount
)
# if no match in extension, try matching registered commands
# sys.stdout.write(cmd + '\n')
cmd
= self
.polishCommand(cmd
)
newCmd
= self
.cmdRE
[key
](cmd
)
# get here only if we cannot find any match
def mapRS (self
, tid
, level
):
if level
== RegisterMap
.LEVEL_STRAND
:
return self
.mapThdid(tid
)
elif level
== RegisterMap
.LEVEL_UCORE
:
return self
.mapuCoreid(tid
)
elif level
== RegisterMap
.LEVEL_CORE
:
return self
.mapCoreid(tid
)
elif level
== RegisterMap
.LEVEL_CPU
:
return self
.mapCpuid(tid
)
def mapThdid (self
, tid
):
if tid
>= self
.nstrandObjs
:
if not self
.strandMap
.has_key(tid
):
self
.strandMap
[tid
] = 'strands[%d]' % tid
## cpuid = tid / self.cpusize
## leftover = tid % self.cpusize
## coreid = leftover / self.nstrands
## strandid = leftover % self.nstrands
## self.strandMap[tid] = '%s.%s%d.%s%d.%s%d' % (self.topName, NAME_CPU, cpuid, NAME_CORE, coreid, NAME_STRAND, strandid)
return self
.strandMap
[tid
]
def mapuCoreid (self
, tid
):
if tid
>= self
.nstrandObjs
:
if not self
.ucoreMap
.has_key(tid
):
ucoreid
= tid
/ self
.ucoresize
self
.ucoreMap
[tid
] = 'ucores[%d]' % ucoreid
## cpuid = tid / self.cpusize
## leftover = tid % self.cpusize
## coreid = leftover / self.nstrands
## self.coreMap[tid] = '%s.%s%d.%s%d' % (self.topName, NAME_CPU, cpuid, NAME_CORE, coreid)
return self
.ucoreMap
[tid
]
def mapCoreid (self
, tid
):
if tid
>= self
.nstrandObjs
:
if not self
.coreMap
.has_key(tid
):
coreid
= tid
/ self
.coresize
self
.coreMap
[tid
] = 'cores[%d]' % coreid
## cpuid = tid / self.cpusize
## leftover = tid % self.cpusize
## coreid = leftover / self.nstrands
## self.coreMap[tid] = '%s.%s%d.%s%d' % (self.topName, NAME_CPU, cpuid, NAME_CORE, coreid)
def mapCpuid (self
, tid
):
if tid
>= self
.nstrandObjs
:
if not self
.cpuMap
.has_key(tid
):
cpuid
= tid
/ self
.cpusize
self
.cpuMap
[tid
] = 'cpus[%d]' % cpuid
## self.cpuMap[tid] = '%s.%s%d' % (self.topName, NAME_CPU, cpuid)
sys
.stderr
.write('DBX: CmdParserNi.py: %s' % (msg
))
sys
.stderr
.write('TODO: CmdParserNi.py: %s' % (msg
))
return eval(cmd
, self
.riesReposit
.globals)
def dispatcher (self
, cmd
, func
, argcount
):
return self
._eval
('%s()' % (func
))
if len(tokens
) != (argcount
+1):
raise RuntimeError, 'input parameters do not match command syntax, cmd=<%s>' % (cmd
)
#self.dbx('%s(%s)\n' % (func, ','.join(tokens[1:])))
return self
._eval
('%s(%s)' % (func
, ','.join(tokens
[1:])))
def handleSetPc (self
, cmd
):
<processor>.set-pc address
#self.dbx('handleSetPC(%s)\n' % (cmd))
if tokens
[0].startswith(CMD_set_pc
):
# <processor>.set-pc 0x00010000
tid
= tokens
[0][len(NAME_processor
):i
]
retval
= self
.checkArgs([tokens
[1]])
sys
.stderr
.write('ERROR: invalid argument\n')
## newCmd = '%s.s%s.pc=%s' % (self.topName,tid, tokens[1])
## #eval(newCmd, self.riesReposit.globals)
if tokens
[1].startswith('0x'):
addr
= long(tokens
[1], 16)
self
.riesReposit
.riesling
.s
[tid
].pc
= addr
def handleSet (self
, cmd
):
TODO <memory-space>.set address value size [-l] [-b]
set address value size [-l] [-b]
TODO -l/-b: little-endian/big-endian byte order
e.g., set 0x00010004 0xafa0188b # fitos %f11, %f23
#print 'DBX: handleSet(): <%s>' % (cmd) #DBX
if addrStr
.startswith(SYM_VA
):
# logical address: v:0x...
# RS_logical_to_physical always check itlb, then dtlb
(addr
,type) = RS_logical_to_physical(tid
, eval(addrStr
[len(SYM_VA
):]), 2)
elif addrStr
.startswith(SYM_PA
):
addr
= eval(addrStr
[len(SYM_PA
):])
if self
.checkArgs([addrStr
]) != [True]:
sys
.stderr
.write('ERROR: wrong addr argument\n')
if self
.checkArgs([tokens
[2]]) != [True]:
sys
.stderr
.write('ERROR: wrong value argument\n')
if len(tokens
) >= 4 and self
.checkArgs([tokens
[3]]) != [True]:
sys
.stderr
.write('ERROR: wrong value or size argument\n')
value
= eval(self
.truncVal(tokens
[2],1))
# if size is not provided, or is not valid, use 4 bytes
#print 'DBX: handleSet(): tid=%d, addr=%#x, value=%#x, size=%d' % (tid, addr, value, size) #DBX
if not size
in [1,2,4,8]:
sys
.stderr
.write('ERROR: set: wrong size %d, must be 1,2,4,8-byte\n' % (size
))
sys
.stderr
.write('ERROR: set: misaligned address\n')
RS_write_phys_memory(tid
, addr
, value
, size
)
def handleGet (self
, cmd
):
TODO <memory-space>.get address [size] [-l] [-b]
get address size [-l] [-b]
TODO -l/-b: little-endian/big-endian byte order
if addrStr
.startswith(SYM_VA
):
# logical address: v:0x...
# RS_logical_to_physical() always check itlb, then dtlb.
(addr
,type) = RS_logical_to_physical(tid
, eval(addrStr
[len(SYM_VA
):]), 2)
elif addrStr
.startswith(SYM_PA
):
addr
= eval(addrStr
[len(SYM_PA
):])
if self
.checkArgs([addrStr
]) != [True]:
sys
.stderr
.write('ERROR: wrong addr argument\n')
if len(tokens
) >=3 and self
.checkArgs([tokens
[2]]) != [True]:
sys
.stderr
.write('ERROR: wrong size argument\n')
# if tokens[2] is not provided or not valid, use 4 bytes
if (not size
in [1,2,4]) and ((size
% 8) != 0):
sys
.stderr
.write('ERROR: get: wrong size %d, must be 1,2,4,8N-byte\n' % (size
))
if (size
<= 8) and ((addr
% size
) != 0):
sys
.stderr
.write('ERROR: get: addr %#x is not aligned to %d\n' % (addr
, size
))
if (size
> 8) and ((addr
% 8) != 0):
sys
.stderr
.write('ERROR: get: addr %#x is not aligned to %d\n' % (addr
, 8))
#newCmd = 'hex(%s)' % (RS_read_phys_memory(0, addr+8*i, 8))
sys
.stdout
.write('%#018x ' % (RS_read_phys_memory(tid
, addr
+8*i
, 8)))
# make sure we finish off the last value with an EOL
#newCmd = 'hex(%s)' % (RS_read_phys_memory(0, addr, size))
print '%#010x' % (RS_read_phys_memory(tid
, addr
, size
))
def handleWriteThFpi (self
, cmd
):
write-th-fp-reg-i thread register-num value
e.g., write-th-fp-reg-i 0 10 0x00000000fbff1391
if self
.checkArgs([tokens
[1],tokens
[2],tokens
[3]]) != [True,True,True]:
sys
.stderr
.write('ERROR: wrong input paramters\n')
if tid
< self
.nstrandObjs
and self
.myInt(regid
) < self
.nSpregs
:
value
= self
.truncVal(value
,0)
newCmd
= '%s.s%d.f%s=%s' % (self
.topName
,tid
, regid
, value
)
# eval(newCmd, self.riesReposit.globals)
sys
.stderr
.write('ERROR: out of bounds tid or regid\n')
def handleWriteThFpx (self
, cmd
):
write-th-fp-reg-x thread register-num value
e.g., write-th-fp-reg-x 0 10 0x00000000fbff1391
if self
.checkArgs([tokens
[1],tokens
[2],tokens
[3]]) != [True,True,True]:
sys
.stderr
.write('ERROR: wrong input paramters\n')
if tid
< self
.nstrandObjs
and self
.myInt(regid
) < self
.nDpregs
:
value
= self
.truncVal(value
,1)
newCmd
= '%s.s%d.d%s=%s' % (self
.topName
,tid
, regid
, value
)
# eval(newCmd, self.riesReposit.globals)
# sys.stderr.write(newCmd + '\n')
sys
.stderr
.write('ERROR: out of bounds tid or regid\n')
def handleReadThFpi (self
, cmd
):
read-th-fp-reg-i thread reg-num
if self
.checkArgs([tokens
[1],tokens
[2]]) != [True,True]:
system
.stderr
.write('ERROR: wrong input parameters\n')
if (int(tokens
[1]) < self
.nstrandObjs
) and (int(tokens
[2]) < self
.nSpregs
):
# as the result will be passed through python interpreter, it must
newCmd
= '%s.s%s.f%s' % (self
.topName
,tokens
[1], tokens
[2])
#return str(eval(newCmd, self.riesReposit.globals))
sys
.stderr
.write("ERROR: thread id or register number out of bounds\n")
def handleReadThFpx (self
, cmd
):
read-th-fp-reg-x thread reg-num
if self
.checkArgs([tokens
[1],tokens
[2]]) != [True,True]:
system
.stderr
.write('ERROR: wrong input parameters\n')
if (int(tokens
[1]) < self
.nstrandObjs
) and (int(tokens
[2]) < self
.nDpregs
):
# as the result will be passed through python interpreter, it must
newCmd
= '%s.s%s.d%s' % (self
.topName
,tokens
[1], tokens
[2])
#return str(eval(newCmd, self.riesReposit.globals))
sys
.stderr
.write("ERROR: thread id or register number out of bounds\n")
def handleWriteFpi (self
, cmd
):
write-fp-reg-i register-num value
if self
.checkArgs([regid
,value
]) != [True, True]:
sys
.stderr
.write('ERROR: wrong command arguments\n')
if int(regid
) < self
.nSpregs
:
value
= self
.truncVal(value
,0)
newCmd
= '%s.s%d.f%s=%s' % (self
.topName
,self
.lastTid
, regid
, value
)
# eval(newCmd, self.riesReposit.globals)
sys
.stderr
.write('ERROR: register index %s out of bound %s\n' % (regid
,self
.nSpregs
- 1))
def handleWriteFpx (self
, cmd
):
write-fp-reg-x thread register-num value
if self
.checkArgs([regid
,value
]) != [True, True]:
sys
.stderr
.write('ERROR: wrong command arguments\n')
if int(regid
) < self
.nDpregs
:
value
= self
.truncVal(value
,1)
newCmd
= '%s.s%d.d%s=%s' % (self
.topName
,self
.lastTid
, regid
, value
)
#eval(newCmd, self.riesReposit.globals)
sys
.stderr
.write('ERROR: register index %s out of bound %s\n' % (regid
,self
.nDpregs
- 1))
def handleReadFpi (self
, cmd
):
#self.dbx('handleReadFpx(%s)\n' % (cmd))
if self
.checkArgs([tokens
[1]]) != [True]:
sys
.stderr
.write('ERROR: wrong input argument\n')
if int(tokens
[1]) < self
.nSpregs
:
# as the result will be passed through python interpreter, it must
newCmd
= '%s.s%d.f%s' % (self
.topName
,self
.lastTid
, tokens
[1])
#return str(eval(newCmd, self.riesReposit.globals))
sys
.stderr
.write('ERROR: register index %s out of bound %s\n' % (tokens
[1],self
.nSpregs
- 1))
def handleReadFpx (self
, cmd
):
#self.dbx('handleReadFpx(%s)\n' % (cmd))
if self
.checkArgs([tokens
[1]]) != [True]:
sys
.stdout
.write('ERROR: wrong input argument\n')
if int(tokens
[1]) < self
.nDpregs
:
# as the result will be passed through python interpreter, it must
newCmd
= 'strands[%d].d%s' % (self
.lastTid
, tokens
[1])
#return str(eval(newCmd, self.riesReposit.globals))
sys
.stdout
.write('ERROR: register index %s out of bound %s\n' % (tokens
[1],self
.nDpregs
- 1))
def regMapSrch(self
, reg_name
):
name
= self
.regmap
.feName2beName(reg_name
)
sys
.stderr
.write('ERROR: unimplemented register access or unknown register\n')
def handleWriteReg (self
, cmd
):
<processor>.write-reg "reg-name" value
write-reg ["cpu-name"] "reg-name" value
e.g., write-reg fsr 0x40000be0
if tokens
[0].startswith(CMD_write_reg
):
# write-reg ['cpu-name'] fsr 0x40000be0
if tokens
[1].startswith(NAME_processor
):
tid
= int(tokens
[1][len(NAME_processor
):])
# <processor>.write-reg fsr 0x40000be0
index
= tokens
[0].find('.')
tid
= int(tokens
[0][len(NAME_processor
):index
])
value
= self
.truncVal(value
,1)
name
= self
.regMapSrch(name
)
newCmd
= '%s.s%d.%s=%s' % (self
.topName
,tid
,name
,value
)
def handleReadReg (self
, cmd
):
<processor>.read-reg "reg-name"
read-reg ["cpu-name"] "reg-name"
if tokens
[0].startswith(CMD_read_reg
):
# read-reg ['cpu-name'] fsr
if tokens
[1].startswith(NAME_processor
):
tid
= int(tokens
[1][len(NAME_processor
):])
# <processor>.read-reg fsr
tid
= int(tokens
[0][len(NAME_processor
):i
])
name
= self
.regMapSrch(name
)
newCmd
= '%s.s%d.%s' % (self
.topName
,tid
,name
)
def handleReadThReg (self
, cmd
):
read-th-reg thread window register-num
sys
.stderr
.write('ERROR: wrong number of arguments\n')
if self
.checkArgs([tokens
[1],tokens
[2],tokens
[3]]) != [True,True,True]:
sys
.stderr
.write('ERROR: wrong input argument\n')
if tid
>= self
.nstrandObjs
or int(reg
) >= self
.nWinregs
+ 8 or int(reg
) < 8 or int(win
) >= self
.nWin
:
sys
.stderr
.write('ERROR: thread id or register # or win # out of bounds\n')
newCmd
= '%s.s%d.w[%s][%s]' % (self
.topName
,tid
, win
, reg
)
def handleReadCtlReg (self
, cmd
):
read-th-ctl-reg thread control-register-num
reg
= self
.regmap
.id2key(rid
)
sys
.stdout
.write('no register mapped at id %d or UNIMP\n' % (rid
,))
newCmd
= '%s.s%d.%s' % (self
.topName
,tid
,reg
)
def handleWriteCtlReg (self
, cmd
):
write-th-ctl-reg thread control-register-num value
reg
= self
.regmap
.id2key(rid
)
value
= self
.truncVal(value
,1)
sys
.stdout
.write('no register mapped at id %d or UNIMP\n' % (rid
,))
newCmd
= '%s.s%d.%s=%s' % (self
.topName
,tid
,reg
,value
)
#sys.stderr.write('DBX: handleWriteCtlReg: newCmd=%s\n' % (newCmd)) #DBX
def handleEcho (self
, cmd
):
echo [("string"|integer|float)]
e.g., echo ?Checking fsr ..?
#self.dbx('handleEcho(%s)\n' % (cmd))
cmd
= cmd
[len(CMD_echo
):].strip()
if ((cmd
.startswith("'") and cmd
.endswith("'")) or
(cmd
.startswith('"') and cmd
.endswith('"'))):
cmd
= cmd
.replace("'", "\\'")
newCmd
= 'print \'%s\'' % (cmd
)
def handleExpect (self
, cmd
):
e.g., expect (read-fp-reg-x 22) 0xb06dd828cc801d8d
#self.dbx('handleExpect(%s)\n' % (cmd))
expr1
= cmd
[lindex
+1:rindex
].strip()
tokens
= cmd
[rindex
+1:].split()
expr2
= tokens
[0].strip()
## # make sure 0x87654321 does not turn into negative value
## if re.match(hexRE, expr1) or re.match(octRE, expr1):
## if re.match(hexRE, expr2) or re.match(octRE, expr2):
value1
= self
._eval
(self
.parseCmd(expr1
))
if type(value1
) is types
.StringType
:
value1
= self
._eval
(value1
)
value2
= self
._eval
(expr2
)
sys
.stdout
.write('ERROR: EXPECT mismatch: (%s = %s) != (%s = %s)\n' % (expr1
, value1
, expr2
, value2
))
def handleRegName (self
, cmd
):
name
= self
.regmap
.feName2beName(name
)
sys
.stderr
.out("register %s unimplemented\n")
newCmd
= '%s.s[%d].%s' % (self
.riesReposit
.topName
,tid
,name
)
#sys.stderr.write('DBX: lastTid=%d newCmd=%s\n' % (self.lastTid, newCmd)) #DBX
def handleStep (self
, cmd
):
""" ssi cN, ssi sN, ssi lNN
if tokens
[1].startswith('s'):
self
.stepOverPreviousHit()
# every strand executes one instr in round-robin fashion, until
# every strand has executed N instrs.
count
= int(tokens
[1][1:])
while done
== 0 and i
< count
:
while done
== 0 and j
< self
.nstrandObjs
:
if self
.thdEnable
[j
] == 1:
bid
= self
.riesReposit
.strands
[j
].step()
#self.handlePselect('pselect th%d' % j)
bpCmd
= self
.showBreakpoint(j
, bid
)
elif tokens
[1].startswith('c'):
self
.stepOverPreviousHit()
# strand 0 in each core executes one instr in round-robin
# fashion, until every strand 0 has executed N instrs.
count
= int(tokens
[1][1:])
while done
== 0 and i
< count
:
while done
== 0 and j
< self
.nstrandObjs
:
if self
.thdEnable
[j
] == 1:
bid
= self
.riesReposit
.strands
[j
].step()
#self.handlePselect('pselect th%d' % j)
bpCmd
= self
.showBreakpoint(j
, bid
)
elif tokens
[1].startswith('l'):
if tid
< self
.nstrandObjs
:
if self
.thdEnable
[j
] == 1:
bid
= self
.riesReposit
.strands
[j
].step()
#self.handlePselect('pselect th%d' % j)
bpCmd
= self
.showBreakpoint(j
, bid
)
# def showLastInstr (self, tid, thd, pc): no longer used
def handlePregs (self
, cmd
):
pregs ["cpu-name"] [-all]
if cmd
.startswith(CMD_pregs
):
if tokens
[1].startswith(NAME_processor
):
tid
= int(tokens
[1][len(NAME_processor
):])
## sys.stderr.write('ERROR: wrong command argument, enter tid as thN\n')
tid
= int(cmd
[len(NAME_processor
):i
])
if cmd
.find(' -all') > -1:
RS_print_archregs(tid
, all
)
def handleFpregs (self
, cmd
):
if cmd
.startswith(CMD_fpregs
):
if tokens
[1].startswith(NAME_processor
):
tid
= int(tokens
[1][len(NAME_processor
):])
sys
.stderr
.write('ERROR: wrong command argument, enter tid as thN\n')
tid
= int(cmd
[len(NAME_processor
):i
])
sys
.stderr
.write('Strand %d\n' % (tid
,))
def handleMmu (self
, cmd
):
<swerver-thread-mmu>.regs
tid
= int(cmd
[len(NAME_swerver_thread_mmu
):i
])
print RS_print_mmuregs(tid
)
def handleMmuregs (self
, cmd
):
if cmd
.startswith(CMD_mmuregs
):
if tokens
[1].startswith(NAME_processor
):
tid
= int(tokens
[1][len(NAME_processor
):])
sys
.stderr
.write('ERROR: wrong command syntax\n')
tid
= int(cmd
[len(NAME_processor
):i
])
if tid
>= self
.nstrandObjs
:
sys
.stderr
.write('ERRORL tid out of bound\n')
print RS_print_mmuregs(tid
)
def handleCmpregs (self
, cmd
):
if cmd
.startswith(CMD_cmpregs
):
if tokens
[1].startswith(NAME_processor
):
tid
= int(tokens
[1][len(NAME_processor
):])
sys
.stderr
.write('ERROR: wrong command syntax\n')
tid
= int(cmd
[len(NAME_processor
):i
])
if tid
>= self
.nstrandObjs
:
sys
.stderr
.write('ERRORL tid out of bound\n')
print RS_print_cmpregs(tid
)
def handleTLB (self
, cmd
):
<swerver-proc-mmu>.i-tlb-entry idx
swmmuN.i-tlb, swmmuN.d-tlb, N is strand-id
if cmd
.find(CMD_swerver_proc_mmu_i_tlb_entry
) > -1:
index
= cmd
.find('.i-tlb')
tid
= int(cmd
[len(NAME_swerver_proc_mmu
):index
])
newCmd
= 'print RS_dump_tlb(%d, 1, 1)' % (tid
)
index
= cmd
.find('.d-tlb')
tid
= int(cmd
[len(NAME_swerver_proc_mmu
):index
])
newCmd
= 'print RS_dump_tlb(%d, 0, 1)' % (tid
)
# not an expected syntax, return to interpreter
def handleBreak (self
, cmd
):
<breakpoint>.break address [length] [-r] [-w] [-x]
<breakpoint>.tbreak address [length] [-r] [-w] [-x]
break address [length] [-r] [-w] [-x]
currently we support: (4/13/05)
break [0x]pc [sid] [{cmd;cmd;cmd}]
break v:[0x]vaddr [sid] [{cmd;cmd;cmd}]
break p:[0x]paddr [sid] [{cmd;cmd;cmd}]
break &symbol [sid] [{cmd;cmd;cmd}]
# TODO we don't handle <breakpoint>.break, <breakpoint>.tbreak
# TODO we don't handle [length] [-r] [-w] [-x]
if not cmd
.startswith(CMD_breakpoint_break
):
# 'break' by itself is a python keyword, cannot use it alone for
# displaying the list of breakpoints, use enable|disable for that
if len(tokens
) >= 3 and not tokens
[2].startswith('{'):
# breakpoint ona specific strand
# breakpoint on all strands
if tokens
[1].startswith('&'):
# symbol is used, it is considered a vaddr for PC breakpoint
if self
.riesReposit
.symTable
:
va
= self
.riesReposit
.symTable
.symbol2va(tokens
[1][1:])
self
.setBpoint(va
, sid
, cmd
, 'PC')
sys
.stderr
.write('WARNING: break: symbol %s not found\n' % (tokens
[1][1:]))
sys
.stderr
.write('WARNING: break: symbol table is not available\n')
self
.wrongSyntax('1 %s, ex=%s' % (cmd
, ex
))
# if not symbol, then the value must be in hex format,
if tokens
[1].startswith('v:'):
addr
= long(tokens
[1][2:], 16)
self
.setBpoint(addr
, sid
, cmd
, 'VA')
elif tokens
[1].startswith('p:'):
addr
= long(tokens
[1][2:], 16)
self
.setBpoint(addr
, sid
, cmd
, 'PA')
addr
= long(tokens
[1], 16)
self
.setBpoint(addr
, sid
, cmd
, 'PC')
self
.wrongSyntax('2 %s, ex=%s' % (cmd
, ex
))
self
.wrongSyntax('3 %s' % (cmd
))
def setBpoint (self
, addr
, sid
, cmd
, type):
## if self.riesReposit.running == 1:
## sys.stderr.write('Simulator is running, issue "stop" before adding breakpoint\n')
sys
.stderr
.write('ERROR: unaligned address\n')
# right now we only support interval=1
for ss
in self
.riesReposit
.riesling
.s
:
bid
= ss
.brk
.on_inst_va(addr
)
sys
.stderr
.write('%s breakpoint id=%d at %s=%#x\n' % (ss
.ref
, bid
, type, addr
))
ss
= self
.riesReposit
.riesling
.s
[sid
]
bid
= ss
.brk
.on_inst_va(addr
)
sys
.stderr
.write('%s breakpoint id=%d at %s=%#x\n' % (ss
.ref
, bid
, type, addr
))
sys
.stderr
.write('Breakpoin on wrong strand-id %d\n' % (sid
))
sys
.stderr
.write('Breakpoint on type %s not supported\n' % type)
## if self.riesReposit.symTable:
## bid = self.riesReposit.riesling.bp_table.add(sid, long(addr), 1, self.riesReposit.symTable.va2symbol(addr), BP_PC)
## bid = self.riesReposit.riesling.bp_table.add(sid, long(addr), 1, self.riesReposit.symTable.va2symbol(addr), BP_VA)
## bid = self.riesReposit.riesling.bp_table.add(sid, long(addr), 1, self.riesReposit.symTable.pa2symbol(addr), BP_PA)
## bid = self.riesReposit.riesling.bp_table.add(sid, long(addr), int(1), '', BP_PC)
## bid = self.riesReposit.riesling.bp_table.add(sid, long(addr), 1, '', BP_VA)
## bid = self.riesReposit.riesling.bp_table.add(sid, long(addr), 1, '', BP_PA)
## self.bpoint[bid] = BreakPoint(bid, sid, addr, cmd, type)
## sys.stderr.write('Break id: %d at %#x\n' % (bid, addr))
## self.nextBpoint = bid + 1
def handleDelete (self
, cmd
):
if self
.riesReposit
.running
== 1:
sys
.stderr
.write('Simulator is running, issue "stop" before deleting breakpoint\n')
cmd
= cmd
.replace(',',' ')
for ss
in self
.riesReposit
.riesling
.s
:
## self.riesReposit.riesling.bp_table.remove(-1)
## if tokens[i].lower().startswith('0x'):
## bid = long(tokens[i],16)
for ss
in self
.riesReposit
.riesling
.s
:
sys
.stderr
.write('Breakpoint id %d not found\n' % (bid
))
## if self.bpoint.has_key(bid):
## self.riesReposit.riesling.bp_table.remove(bid)
## sys.stderr.write('break id %d not found\n' % (bid))
def handleEnable (self
, cmd
):
return self
._handleEnable
(cmd
, 1)
def handleDisable (self
, cmd
):
return self
._handleEnable
(cmd
, 0)
def _handleEnable (self
, cmd
, enable
):
## if self.riesReposit.running == 1:
## sys.stderr.write('Simulator is running, issue "stop" before enabling/disabling breakpoint\n')
cmd
= cmd
.replace(',',' ')
# display all breakpoints, regardless it is enabled or not
self
.handleListBreak(cmd
)
#sys.stdout.write('%s\n' % (self.riesReposit.riesling.bp_table.list()))
## print 'DBX: DBX DBX DBX' #DBX
## klist = self.bpoint.keys()
## if self.bpoint[bid].enable == enable:
## sys.stdout.write('%s\n' % (self.bpoint[bid]))
elif tokens
[1] == '-all':
for ss
in self
.riesReposit
.riesling
.s
:
for key
in ss
.brk
.keys():
#self.riesReposit.riesling.bp_table.enable(-1)
for ss
in self
.riesReposit
.riesling
.s
:
for key
in ss
.brk
.keys():
#self.riesReposit.riesling.bp_table.disable(-1)
## # even though we no longer rely on the frontend bpoint[] for
## # everthing, it is good to keep it updated
## for bid in self.bpoint.keys():
## self.bpoint[bid].enable = enable
## self.bpoint[bid].hitCount = 0
## self.bpoint[bid].justHit = 0
## if tokens[i].lower().startswith('0x'):
## bid = long(tokens[i],16)
for ss
in self
.riesReposit
.riesling
.s
:
sys
.stderr
.write('Breakpoint id %d not found\n' % (bid
,))
## if self.bpoint.has_key(bid):
## self.riesReposit.riesling.bp_table.enable(bid)
## self.riesReposit.riesling.bp_table.disable(bid)
## # ditto, keep it updated
## self.bpoint[bid].enable = enable
## self.bpoint[bid].hitCount = 0
## self.bpoint[bid].justHit = 0
## sys.stderr.write('break id %d not found\n' % (bid,))
def handlePenable (self
, cmd
):
return self
._handlePenable
(cmd
, 1)
def handlePdisable (self
, cmd
):
return self
._handlePenable
(cmd
, 0)
def _handlePenable (self
, cmd
, enable
):
pdisable [("cpu-name"|-all)]
penable [("cpu-name"|-all|0x3210)]
#sys.stderr.write('DBX: handlePenable(): cmd=%s enable=%d\n' % (cmd, enable)) #DBX
if self
.riesReposit
.optdir
['--ar'] == 'n1':
sys
.stderr
.write('no enable/disable support for n1\n')
if cmd
.startswith(NAME_processor
):
tid
= long(cmd
[len(NAME_processor
):i
])
#TODO this part never get called, somehow re cannot match
# thN.penable, thN.pdisable. 5/25/05
if tid
< self
.nstrandObjs
:
newRunning
= long(1L<<(tid
%self
.cpusize
)) | self
.riesReposit
.strands
[tid
].rdasi(0x41, 0x50L
)
newRunning
= ~
long(1L<<(tid
%self
.cpusize
)) & self
.riesReposit
.strands
[tid
].rdasi(0x41, 0x50L
)
self
.riesReposit
.strands
[tid
].wrasi(0x41, 0x50L
, newRunning
)
sys
.stderr
.write('ERROR: strand-id %d out of range\n' % (tid
))
tokens
= cmd
.lower().split()
for ii
in range(self
.riesReposit
.ncpus
):
running
= self
.riesReposit
.strands
[ii
*self
.cpusize
].rdasi(0x41, 0x50L
)
if ((running
>> i
) & 0x1L
):
sys
.stdout
.write('strand%d enabled\n' % (i
+(ii
*self
.cpusize
)))
elif tokens
[1] == '-all':
for ii
in range(self
.riesReposit
.ncpus
):
# enable all, asiWrite will mask the value with core_avail
self
.riesReposit
.strands
[ii
*self
.cpusize
].wrasi(0x41, 0x50L
, 0xffffffffffffffffL
)
# disable all, asiWrite will make sure one strand remains
self
.riesReposit
.strands
[ii
*self
.cpusize
].wrasi(0x41, 0x50L
, 0x0L
)
elif tokens
[1].startswith('-mask='):
# make sure we don't replace 0x with 00
# -mask=0:1234, -mask=0:0x1234
jj
= tokens
[1].find('-mask=')
cpuid
= int(tokens
[1][jj
+len('-mask='):ii
])
sys
.stderr
.write('ERROR: cpuid %d out of range\n' % (cpuid
))
headStrand
= cpuid
* self
.cpusize
if tokens
[1][ii
+1:].startswith('0x'):
mask
= long(tokens
[1][ii
+3:].replace('x','0'),16)
mask
= long(tokens
[1][ii
+1:].replace('x','0'),16)
# -mask=1234, -mask=0x1234, default to cpu0
if tokens
[1].startswith('-mask=0x'):
mask
= long(tokens
[1][len('-mask=0x'):].replace('x','0'),16)
mask
= long(tokens
[1][len('-mask='):].replace('x','0'),16)
mask
= 0xffffffffffffffffL ^ mask
self
.riesReposit
.strands
[headStrand
].wrasi(0x41, 0x50L
, mask
)
elif tokens
[1].startswith(NAME_processor
):
tid
= int(tokens
[1][len(NAME_processor
):])
if tid
< self
.nstrandObjs
:
newRunning
= long(1L<<(tid
%self
.cpusize
)) | self
.riesReposit
.strands
[tid
].rdasi(0x41, 0x50L
)
newRunning
= ~
long(1L<<(tid
%self
.cpusize
)) & self
.riesReposit
.strands
[tid
].rdasi(0x41, 0x50L
)
self
.riesReposit
.strands
[tid
].wrasi(0x41, 0x50L
, newRunning
)
sys
.stderr
.write('ERROR: strand-id %d out of range\n' % (tid
))
cpuid
= int(tokens
[1][:ii
])
sys
.stderr
.write('ERROR: cpuid %d out of range\n' % (cpuid
))
headStrand
= cpuid
* self
.cpusize
if tokens
[1][ii
+1:].lower().startswith('0x'):
mask
= long(tokens
[1][ii
+3:],16)
mask
= long(tokens
[1][ii
+1:],16)
if tokens
[1].lower().startswith('0x'):
mask
= long(tokens
[1][2:],16)
mask
= long(tokens
[1],16)
mask
= 0xffffffffffffffffL ^ mask
self
.riesReposit
.strands
[headStrand
].wrasi(0x41, 0x50L
, mask
)
def handleRun (self
, cmd
):
# no #instr is specified, use max
# run on a particular strand only, otherwise round-rabin all
self
.stepOverPreviousHit()
while (done
== 0) and (count
< ninstr
):
while (tid
< self
.nstrandObjs
) and (doneOne
== 0):
if self
.thdEnable
[tid
] == 1:
bid
= self
.riesReposit
.strands
[tid
].step()
#self.handlePselect('pselect th%d' % tid)
bpCmd
= self
.showBreakpoint(tid
, bid
)
self
.instrCount
[tid
] += 1
# only run on a particular strand, cut short of inner
def handleRunfast (self
, cmd
):
runfast [count] [strand-id]
the difference between run and runfast is that with runfast, each
strand will execute the specified number of instructions before pass
the control to the next strand, unless a breakpoint is hit. 'run' will
have each strand run one instruciton at a time, in a round-rabin order,
until every strand has executed the specified number of instructions,
or until a breakpoint is hit.
===> this function is no longer advertised
# no #instr is specified, use 1, as control will not return
# until the specified number instructions have been executed,
# use sys.maxint here will send the execution into an endless loop
# ---> we have breakpoint in strand now, so treat it the same as
# run, which uses sys.maxint
# run on a particular strand only, otherwise round-rabin all
# strands (tid == -1), but each strand runs the specified number
# of instructions before passes the control to the next strand,
# which is different to run, where each strand run one instruciton
self
.stepOverPreviousHit()
while (done
== 0 and i
< self
.nstrandObjs
):
if (self
.thdEnable
[i
] == 1):
bid
= self
.riesReposit
.strands
[i
].step(ninstr
)
# hit a breakpoint, but we don't know how many
# instructions have been executed before the breakpoint
#self.handlePselect('pselect th%d' % i)
bpCmd
= self
.showBreakpoint(i
, bid
)
self
.instrCount
[i
] += ninstr
if (self
.thdEnable
[tid
] == 1):
bid
= self
.riesReposit
.strands
[tid
].step(ninstr
)
# hit a breakpoint, but we don't know how many
# instructions have been executed before the breakpoint
#self.handlePselect('pselect th%d' % tid)
bpCmd
= self
.showBreakpoint(tid
, bid
)
self
.instrCount
[tid
] += ninstr
def handleWhatis (self
, cmd
):
if tokens
[1].startswith('p:'):
if self
.riesReposit
.symTable
:
#print 'addr=%s va=' % (addr, va)
print '%s' % self
.riesReposit
.symTable
.va2symbol(addr
)
print '%s' % self
.riesReposit
.symTable
.pa2symbol(addr
)
print 'No symbol table is available'
# def hitBreakpoint (self, tid, thd): no longer used
def showBreakpoint (self
, tid
, bid
):
#sys.stderr.write('DBX: showBreakpoint: strand-is=%d bpoint-id=%d\n' % (tid, bid)) #DBX
# a breakpoint is hit, switch command prompt to that strand, and set
# maybe riesling backend does not complete the update of sid yet,
#tid = self.riesReposit.riesling.getBreakpointTablePtr().queryLastSid()
tid
= self
.riesReposit
.riesling
.bp_table
.hit_strand()
self
.handlePselect('pselect th%d' % tid
)
self
.riesReposit
.running
= 0
#thd = self.mapThdid(tid)
#newCmd = '%s.getArchStatePtr().getPc()' % (thd)
#pc = eval(newCmd, self.riesReposit.globals)
#symbol = self.riesReposit.symTable.va2symbol(pc)
# let instrCount includes the instruction supposed to be executed,
# but didn't because of the breakpoint
#sys.stdout.write('breakpoint %d: T%d, ic=%d, pc=<%s>\n' % (bid, tid, self.instrCount[tid]+1, symbol))
# ---> ic won't be accurate when runfast is used, so might as well not
# ---> move the display to riesling backend, so that a basic breakpoint
# info is displayed there.
#sys.stdout.write('Hit breakpoint %d: T%d, pc=<%s>\n' % (bid, tid, symbol))
# take action(s) associated with the breakpoint
if self
.bpoint
[bid
].action
!= None and len(self
.bpoint
[bid
].action
) > 0:
# if 'run' or 'step' is part of a breakpoint's action, we can
# get into a recursive call-chain, when hitting the breakpoint
# triggers the 'run' (or 'step'), which in turns hits the same
# breakpoint, and on and on, ...
BP_ACTION
= '.breakpoint_action'
fd
= open(BP_ACTION
, 'w')
for action
in self
.bpoint
[bid
].action
:
fd
.write('%s\n' % action
)
newCmd
= 'execfile("%s")' % BP_ACTION
# we check for breakpoint hit before the instruction is fetched,
# so we don't have the instruction word yet.
#newCmd = '%s.lastInstr()' % (thd)
#lastInstr = eval(newCmd, self.riesReposit.globals)
#newCmd = '%s.lastInstrToString()' % (thd)
#lastInstrCode = eval(newCmd, self.riesReposit.globals)
##sys.stdout.write('breakpoint: T%d, ic=%d, pc=<v:%#016x>[%s] [%08x] %s\n' % (tid, self.instrCount[tid], pc, symbol, lastInstr, lastInstrCode))
#sys.stdout.write('breakpoint: T%d, ic=%d, pc=<%s> [%08x] %s\n' % (tid, self.instrCount[tid], symbol, lastInstr, lastInstrCode))
def stepOverPreviousHit (self
):
every time before we step, we reset breakpoint hit status so
that we won't hit the same point twice in a row. If T1 hits a
breakpoint, then in the next step/run command T0 is executed first
T0 will reset the breakpoint hit status, so when T1 is to execute
again, it can hit the same breakpoint, which is not desirable, so we
want step over that first. If user chooses to step/run a particular
strand after a breakpoint hit, then we don't execute the function
first, even if that means T1 in the above example will hit the same
breakpoint twice in a row. One problem with this function is that
the strand which hit a breakpoint in the previous step/run will execute
one extra instruction than user specified.
sid
= self
.riesReposit
.riesling
.bp_table
.last_hit_strand()
if ((sid
>= 0) and (self
.thdEnable
[sid
] == 1)):
self
.riesReposit
.strands
[sid
].step()
self
.instrCount
[sid
] += 1
def handleAlias (self
, cmd
):
klist
= self
.alias
.keys()
sys
.stdout
.write('alias %s == %s\n' % (key
, self
.alias
[key
]))
self
.alias
[tokens
[1]] = ' '.join(tokens
[2:])
def handleUnalias (self
, cmd
):
cmd
= cmd
.replace(',', ' ')
if len(tokens
) == 2 and tokens
[1] == '-all':
if self
.alias
.has_key(tokens
[i
]):
del self
.alias
[tokens
[i
]]
def handleHelp (self
, cmd
):
print '\nTo use python help utility, enter help()'
if tokens
[1] == 'regid' or tokens
[1] == 'regname':
# show regid to regname mapping
for regname
in self
.regmap
.regMap
.keys():
__localMap
[self
.regmap
.regMap
[regname
][1]] = regname
for regname
in self
.regmap
.regMapArch
.keys():
__localMap
[self
.regmap
.regMapArch
[regname
][1]] = regname
print __localMap
[key
] + '\t\t\t\t' + str(key
)
## def handleReset (self, cmd):
## """handle system reset
## syntax: reset [traptype=0x1]
## traptype=0x1: power_on_reset
## traptype = eval(tokens[2])
## while i < self.nstrandObjs:
## self.instrCount[i] = 0
## def handleReset (self, cmd):
## """return every strand's pc to power-on-reset
## # .RED.Power_on_Reset fffffffff0000020 X fff0000020
## pc = self.riesReposit.symTable.symbol2va('.RED.Power_on_Reset')
## sys.stderr.write('symbol .RED.Power_on_Reset not found\n')
## pc = 0xfffffffff0000020
## pc = 0xfffffffff0000020
## while i < self.nstrandObjs:
## if self.thdEnable[i] == 1:
## self.instrCount[i] = 0
## thd = self.mapThdid(i)
## newCmd = '%s.getArchStatePtr().setPc(value=%u)' % (thd, pc)
## eval(newCmd, self.riesReposit.globals)
## newCmd = '%s.getArchStatePtr().setNpc(value=%u)' % (thd, pc+4)
## eval(newCmd, self.riesReposit.globals)
def handleIgnore (self
, cmd
):
sys.stderr.write('%s\n' % (newCmd,))
sys
.stderr
.write('"ignore" command is not supported\n')
retval
= self
.checkArgs([tokens
[1],tokens
[2]])
if not retval
== [True,True]:
sys
.stderr
.write('ERROR: wrong i/p paramters\n')
if self
.bpoint
.has_key(id):
self
.bpoint
[id].ignore
= num
self
.bpoint
[id].hitCount
= 0
self
.bpoint
[id].justHit
= 0
sys
.stderr
.write('ERROR: Break id not found\n')
def handleListBreak (self
, cmd
):
for ss
in self
.riesReposit
.riesling
.s
:
print '%s: %s' % (ss
.ref
, ss
.brk
)
#sys.stdout.write('%s\n' % (self.riesReposit.riesling.bp_table.list()))
## klist = self.bpoint.keys()
## sys.stdout.write('%s\n' % (self.bpoint[id]))
def handlePselect (self
, cmd
):
sys
.stdout
.write('pselect: th%d\n' % (self
.lastTid
))
if tokens
[1].startswith(NAME_processor
):
tid
= int(tokens
[1][len(NAME_processor
):])
if tid
< self
.nstrandObjs
:
sys
.ps1
= "%s-th%d>>> " % (self
.riesReposit
.prompt
, self
.lastTid
)
sys
.stderr
.write('ERROR: tid value out of range\n')
sys
.stderr
.write('ERROR: wrong input parameter, enter tid as thN\n')
def handleQuit (self
, cmd
):
# if pli-socket does not present, we shouldn't make socketAPI calls
self
.riesReposit
.socketAPI
.fini()
#sys.exit(self.riesReposit.riesling.bp_table.is_bad_trap())
def handleRunCommandFile (self
, cmd
):
return self
.handleRunPythonFile(cmd
)
def handleRunPythonFile (self
, cmd
):
newCmd
= 'execfile("%s")' % (tokens
[1])
def handleVa2Pa (self
, cmd
):
<processor>.logical-to-physical address
logical-to-physical ["cpu-name"] address
if cmd
.startswith(NAME_processor
):
tid
= int(cmd
[len(NAME_processor
):i
])
if tokens
[1].startswith(NAME_processor
):
tid
= int(tokens
[1][len(NAME_processor
):])
# remove leading 'v:' if any
if va
.startswith(SYM_VA
):
if tid
>= self
.nstrandObjs
:
sys
.stderr
.write('ERROR: strand id out of bounds\n')
(addr
,type) = RS_logical_to_physical(tid
, eval(va
), 2)
def decode_addr (self
, addr
):
p:[0x]addr, r:[0x]addr, v:[0x]addr, [0x]addr
if addr
.startswith(SYM_PA
):
addr_type
= AddrType
.PA_TYPE
addr
= eval(addr
[len(SYM_PA
):])
elif addr
.startswith(SYM_RA
):
addr_type
= AddrType
.RA_TYPE
addr
= eval(addr
[len(SYM_RA
):])
elif addr
.startswith(SYM_VA
):
addr_type
= AddrType
.VA_TYPE
addr
= eval(addr
[len(SYM_VA
):])
addr_type
= AddrType
.VA_TYPE
def handle_va2pa (self
, cmd
):
syntax: va2pa [(p|r|v):][0x]addr [-p pid] [-c context] [strand-di]
(addr_type
,addr
) = self
.decode_addr(tokens
[1])
(addr
,type) = RS_logical_to_physical(tid
, addr
, addr_type
, pid
, ctxt
)
def handleDisassemble (self
, cmd
):
<processor>.disassemble [address [count]]
disassemble [address [count]]
addr_type
= AddrType
.VA_TYPE
# 0 - pa, 1 - ra, 2 - va, default is VA
if cmd
.startswith(NAME_processor
):
tid
= int(cmd
[len(NAME_processor
):i
])
if tid
>= self
.nstrandObjs
:
sys
.stderr
.write('ERROR: strand id out of bounds\n')
if addr
.startswith(SYM_PA
):
addr
= addr
[len(SYM_PA
):]
## if not addr.startswith('0x') and not addr.startswith('0X'):
addr_type
= AddrType
.PA_TYPE
elif addr
.startswith(SYM_RA
):
addr
= addr
[len(SYM_RA
):]
## if not addr.startswith('0x') and not addr.startswith('0X'):
addr_type
= AddrType
.RA_TYPE
elif addr
.startswith(SYM_VA
):
addr
= addr
[len(SYM_VA
):]
## if not addr.startswith('0x') and not addr.startswith('0X'):
# default is VA, if no addr is given, PC is used
# use selected strand's pc
addr
= str(self
.riesReposit
.riesling
.s
[tid
].pc
)
if self
.checkArgs([addr
,count
]) != [True, True]:
sys
.stderr
.write('ERROR: invalid address or count arguments\n')
sys
.stderr
.write('ERROR: %s is not a proper address, use prefix "0x" for hex value\n' % (addr
))
if addr_type
== AddrType
.PA_TYPE
:
return self
.handle_dism('dism p:%#x -c %s %d' % (addrv
, count
, tid
))
elif addr_type
== AddrType
.RA_TYPE
:
return self
.handle_dism('dism r:%#x -c %s %d' % (addrv
, count
, tid
))
return self
.handle_dism('dism v:%#x -c %s %d' % (addrv
, count
, tid
))
def handle_dism (self
, cmd
):
dism pc [-c count] [strand-id]
dism [(p|r|v):]addr [-c count] [strand-id]
# if no addr is specified, use the selected strand's PC
#addr = self.riesReposit.riesling.s[self.selectTid].pc
addr
= self
.riesReposit
.riesling
.s
[self
.lastTid
].pc
addr_type
= AddrType
.VA_TYPE
# special syntax, allow accessing PC of a different strand
addr_type
= AddrType
.VA_TYPE
(addr_type
,addr
) = self
.decode_addr(tokens
[1])
count
= eval(tokens
[i
+1])
addr
= self
.riesReposit
.riesling
.s
[tid
].pc
(size
,iwStr
,type) = RS_disassemble(tid
, addr
, addr_type
, self
.vonk
)
if type == AddrType
.PA_TYPE
:
sys
.stdout
.write('PA %#x %s\n' % (addr
, iwStr
))
elif type == AddrType
.RA_TYPE
:
sys
.stdout
.write('RA %#x %s\n' % (addr
, iwStr
))
sys
.stdout
.write('VA %#x %s\n' % (addr
, iwStr
))
def str2long (self
, str):
if str.startswith('0x') or str.startswith('0X'):
elif str.startswith('0'):
def handleTodo (self
, cmd
):
def wrongSyntax (self
, cmd
):
sys
.stderr
.write('Wrong command syntax: <%s>\n' % (cmd
))
"""Display the exception that just occurred.
#We remove the first stack item because it is our own code.
The output is written by self.write(), below.
type, value
, tb
= sys
.exc_info()
tblist
= traceback
.extract_tb(tb
)
list = traceback
.format_list(tblist
)
list.insert(0, "Traceback (most recent call last):\n")
list[len(list):] = traceback
.format_exception_only(type, value
)
#sys.stderr.write('%s' % (list))
def replaceToken (self
, cmd
):
"""replace %reg with RS_read_register_name() so that the %reg can be
treated as a variable and used in any valid python expression.
tokens
= splitRE
.split(cmd
)
if token
.startswith('%'):
name
= self
.regmap
.feName2beName(token
[1:])
newToken
= "%s.s%d.%s" % (self
.topName
,self
.lastTid
,name
)
#sys.stderr.write('DBX: newToken=%s\n' % (newToken)) #DBX
cmd
= cmd
.replace(token
, newToken
)
#sys.stderr.write('unimplemented register %s\n' % (token[1:],))
if __name__
== "__main__":
niParser
= CmdParserNi(Repository
.Repository())