Example #1
0
def run(libbench, soc):
  dbg = debug.Debugger(libbench, soc)
  dbg.set_tracing_enabled(True)

  dbg.process_input("x /i4 0")

  dbg.stepi(4)
  dbg._soc.tick()

  dbg.process_input("p")
  print("")
  dbg.process_input("x /x4 0")
def run(libbench):
    soc = soc_lib.RiscVSoc(libbench, 'memtest_trace.vcd', True)

    driver = build_test_image(soc)

    soc.setDebug(False)
    ImageLoader.load_image("test.v", soc)

    if driver == None:
        print "could not detect custom driver, using standard procedure"

        expect_failure = False
        enforce_repl = False

        for arg in sys.argv:
            if arg == '--driver-invert-result':
                expect_failure = True
            if arg == '--repl':
                enforce_repl = True

        dbg = debug.Debugger(libbench, soc)
        ticks = soc.get_ticks_to_run()
        if sys.stdout.isatty() or enforce_repl:
            print('TTY session detected! starting debugger')

            # Unbuffer output (this ensures the output is in the correct order)
            sys.stdout = os.fdopen(sys.stdout.fileno(), 'w', 0)

            tee = subprocess.Popen(["tee", "log.txt"], stdin=subprocess.PIPE)
            os.dup2(tee.stdin.fileno(), sys.stdout.fileno())
            os.dup2(tee.stdin.fileno(), sys.stderr.fileno())

            dbg.set_tracing_enabled(True)
            dbg.repl()
        else:
            soc.run(ticks, expect_failure=expect_failure)
            if os.path.isfile('uart.expected'):
                ret = os.system(' && '.join([
                    'cat io.txt | sed \'/^LIBC: /d\'>_io.txt',
                    'diff _io.txt uart.expected'
                ]))
                if ret == 0:
                    print('UART output matches the expected one')
                else:
                    raise Exception('UART output mismatch!, test failed')
    else:
        print "custom driver detected, control transfered"
        driver.run(libbench, soc)
def run(libbench, opts, runner_override = None):

  soc = soc_lib.RiscVSoc(libbench, 'memtest_trace.vcd', True)
  soc.setDebug(False)
  soc.setResetPC()

  ImageLoader.load_image("test.v", soc)

  if runner_override:
    print "custom runner procedure detected, control transfered"
    return driver.run(libbench, soc)

  print "could not detect custom runner procedure, using standard procedure"

  objdump_bin = os.environ['TOOLCHAIN_DIR'] + '/bin/riscv32-unknown-elf-objdump'
  dbg = debug.Debugger(libbench, soc, objdump_bin)

  if opts.ticks_limit == 0:
    print 'no ticks_limit specified, getting limit from the SOC object'
    opts.ticks_limit = soc.get_ticks_to_run()
    print 'new ticks_limit: {}'.format(opts.ticks_limit)

  if sys.stdout.isatty() or opts.enforce_repl:
    print('TTY session detected! starting debugger')

    # Unbuffer output (this ensures the output is in the correct order)
    sys.stdout = os.fdopen(sys.stdout.fileno(), 'w', 0)

    if sys.stdin.isatty():
      tee = TeeLog("log.txt", "w")
      dbg.set_tracing_enabled(True)
      dbg.repl()
    else:
      print("stdin is not TTY reading data directly...")
      for line in sys.stdin:
        print('>>>: `' + line.rstrip() + '`')
        dbg.process_input(line)
  else:
    soc.run(opts.ticks_limit, expect_failure = opts.expect_failure)
    print("Working directory: {}".format(os.getcwd()))
    rchecks.RunnerChecks().check_uart('io.txt')
Example #4
0
def run(libbench, soc):
  dbg = debug.Debugger(libbench, soc)
  dbg.set_tracing_enabled(True)
  dbg.stepi(5)
  # soc.run(5)
  dbg.process_input("p")