Ejemplo n.º 1
0
def ReportTestResult() :
  result = 0
  i = 0
  for target in DA.IterateTargets():
    if threads_loaded[target]:
      if DA.SelectTarget (target):
        txenable = DA.ReadRegister("TXENABLE")
        status   = DA.ReadRegister("TXSTATUS")
        pc       = DA.ReadRegister("PC")
        hreason  = (status >> 18) & 3
        is_mtx   = (txenable & (1<<11)) != 0

        if is_mtx:
          if (pc & 0xFFF80000) == 0x80900000:
            # Map MTX address
            pc = (pc & 0xFFE00000) | ((pc & 0x1FFFFF) >> 1)
          else :
            print "PC %x out of expected range for MTX" % pc

        # WORK NEEDED: This does not support MiniM exit paths

        if hreason == 0:
          # Expect SWITCH 0xC30006 trap to exit
          is_exit_switch = False
          if  is_mtx  :
            inst = DA.ReadWord(pc-2)
            is_exit_switch = ( inst == 0x9FF3 )
          else :
            inst = DA.ReadLong(pc)
            if inst != 0xAFC30006:
              inst = DA.ReadLong(pc-4)
            is_exit_switch = ( inst == 0xAFC30006 )

          if is_exit_switch:
            # D0Re0 is on the stack, fetch it
            stack_pointer = DA.ReadRegister("A0StP")
            exit_value = DA.ReadLong(stack_pointer - 4)
            if exit_value != 0:
              result = exit_value
              print "Thread %d FAILED: D0Re0: %d (%x)" %(i, exit_value, exit_value)
          elif threads_stopped[target]:
            print "Thread %d STOPPED AT: %x [PC=%x]" % (i, inst, pc)
          else :
            result = 1
            print "Thread %d FAILED: Unexpected SWITCH: %x [PC=%x]" % (i, inst, pc)
        else:# Halted for some other reason
          reason = "<UNKNOWN>"
          if hreason == 1:
            reason = "Unknown instruction"
          elif hreason == 2:
            reason = "Privilege violation"
          elif hreason == 3:
            reason = "Memory fault"
          print "Thread %d FAILED: %s [PC=%x]" % (i, reason, pc)
          result = 1
      # Keep track of thread number
      i += 1
    return result
Ejemplo n.º 2
0
def NumThreads() :
  """
  Find the number of threads
  """
  num_threads = 0
  for target in DA.IterateTargets(True):
    if DA.SelectTarget (target):
      num_threads += 1
    
  return num_threads
Ejemplo n.º 3
0
def AnyLoadedThreadRunning() :
  thread_running = False
  for target in DA.IterateTargets():
    if threads_loaded[target]:
      if DA.SelectTarget (target):
        is_running = DA.IsRunning()
        thread_running |= is_running
        if not is_running and threads_started[target] :
            print "Thread stopped on: %s" % DA.GetTargetInfo(target)
            threads_started[target] = 0
            threads_stopped[target] = 0
  return thread_running
Ejemplo n.º 4
0
def RunAllLoadedThreads():
  """
  Run all the threads that have been loaded
  """
  for target in DA.IterateTargets():
    if threads_loaded[target]:
      if DA.SelectTarget(target):
        print "Running %s" % DA.GetTargetInfo(target)
        DA.Run()
        threads_started[target] = True
      else:
        print "Failed to SelectTarget()"
Ejemplo n.º 5
0
def OutputChannelData(s):
  """
  Read channel data
  """
  if (DA.ChannelDataReady(logf_channel)):
    while(DA.ChannelDataReady(logf_channel)):
      ch = DA.ChannelRead(logf_channel)
      if (s != "" and (ch == 0 or ch == 10)):
        Write(s)
        s = ""
      elif (ch != 13):
        s += chr(ch)
  return s
Ejemplo n.º 6
0
def LoadProgramFiles(path) :
  """
  Load the script
  """
  load_success = True
  try:
    DA.LoadProgramFileEx(path, ShowProgress=suppress_dialog)
  except Exception, e:
    load_success = False
Ejemplo n.º 7
0
def StopAllLoadedThreadsRunning() :
  """
  Stop all threads
  """
  thread_running = False
  for target in DA.IterateTargets():
    if threads_loaded[target]:
      if DA.SelectTarget (target):
        if is_running and threads_started[target]:
          print "Stopped thread on: %s" % DA.GetTargetInfo(target)
          DA.Stop()
          threads_started[target] = False
          threads_stopped[target] = True
          thread_running = True
      else:
        print "Failed to SelectTarget()"

  return thread_running
Ejemplo n.º 8
0
def ArgsForAllLoadedThreads(args) :
  """
  Inject arguments in to all loaded threads with _metag_argv
  """
  if len(args) == 0:
    return
  for target in DA.IterateTargets():
    if threads_loaded[target]:
      if DA.SelectTarget (target):
        print "Args for thread %s" % DA.GetTargetInfo(target)
        addr = DA.EvaluateSymbol ("_metag_argv")
        i = 0
        for arg in args:
          arga = DA.ReadLong( addr + (i*4) )
          print "Argument %d <%s> to %x" % (i, arg, arga)
          DA.WriteString( arga, arg )
          i += 1
        else:
          print("Failed to SelectTarget()")
Ejemplo n.º 9
0
#  Copyright (C) 2012-2020 MIPS Tech LLC
#  Written by Matthew Fortune <*****@*****.**> and
#  Daniel Sanders <*****@*****.**>
#  This file is part of Overtest.
#
#  Overtest is free software; you can redistribute it and/or modify
#  it under the terms of the GNU General Public License as published by
#  the Free Software Foundation; either version 3, or (at your option)
#  any later version.
#
#  Overtest is distributed in the hope that it will be useful,
#  but WITHOUT ANY WARRANTY; without even the implied warranty of
#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#  GNU General Public License for more details.
#
#  You should have received a copy of the GNU General Public License
#  along with overtest; see the file COPYING.  If not, write to the Free
#  Software Foundation, 51 Franklin Street - Fifth Floor, Boston, MA
#  02110-1301, USA.
import os
import VersionCheck

from CSUtils import DA
print os.environ
DA.UseTarget("DA-net 45")
Ejemplo n.º 10
0
  dir, file = os.path.split(path)
  olddir = os.getcwd()
  os.chdir(dir)
  try:
    try:
      modulename = os.path.splitext(file)[0]
      m = __import__(modulename)
      elf_files = m.elf_files
    except Exception, e:
      load_success = False
  finally :
    os.chdir(olddir)

  n = 0
  for target in DA.IterateTargets():
    if elf_files["e%d" % n] != 0:
      threads_loaded[target] = True
    else:
      threads_loaded[target] = False
    n += 1
  return load_success

def GetMilliTime() :
  """
  Current time in milliseconds
  """
  return int(time.time()*1000)

def RunAllLoadedThreads():
  """