Пример #1
0
    str = working_dir + "/" + str

#    print " And I'm guessing this means I should look in '%s'" % str

    if (os.path.isfile(str)):
        # Load all subsequent symbol tables with this source as well
        kern_path = str
# I'm pretty sure this is unnecessary; it's not like the kernel symbol table is
# going to change in flight, and even if it does, it's not like we need to keep
# both of them around. Let's reuse deflsym and avoid the assertion failure we
# get from calling new-symtable at runtime.
#        usersym = "usersym%d" % cs410_dispatch.kernel_up
        usersym = "deflsym"
     
        cli.quiet_run_command("%s.source-path \"%s/;%s;%s\"" %
            (usersym, working_dir, user_src_path, test_src_path))
        cli.quiet_run_command("%s.load-symbols %s" % (usersym, str))
        cli.quiet_run_command("cell0_context.symtable %s" % usersym)
    else:
        print "No such kernel image: '%s'; symbolic debugging won't work." % str
#        print " !!> Cannot find that file; ignoring simulation request."
#        print " !!> This probably means that symbolic debugging will not work."
#        print " !!> Note that we are running loader callbacks anyway!"
#        print " !!> Please contact a TA."
        error = 1

    for x in boot_callbacks:
      x(cpu, cs410_dispatch.kernel_up, error)

cs410_dispatch.add_simcall(booted)
  if tid in tidtaskname :
    u.log('410', 'TID %d symbols are in %s' % (tid, tidtaskname[tid]))
  else :
    u.log('410', 'TID %d has unknown symbol table' % (tid))

  tf = tidcontext[tid]
  if isinstance(tf, dict) :
    # Off core, stored decoded frame at registration time
    u.log('410', 'TID %d is off-core right now' % tid)
    u.print_trap_frame(tf)
  else :
    # On core, read from cpu right now
    u.log('410', 'TID %d is on-core right now: %s' % (tid, tf.name))
    u.print_trap_frame(u.trap_frame_from_cpu(tf))

def cmd_tids() :
  u.log('410', 'TIDs registered right now: %r' % tidcontext.keys());

cs410_dispatch.add_simcall(tidinfo_set)
cs410_dispatch.add_simcall(tidinfo_del)
new_command("tidinfo", cmd_tidinfo, args=[arg(int_t, "tid")],
      short="Ask kernel for thread information by TID",
      doc="This reports thread information as derived from simulation state")
new_command("tids", cmd_tids,
      short="Report the list of tids registered for tidinfo debugging.",
      doc="This reports the list of tids being tracked.")

# u.logging['410-tidinfo'] = True
# u.printing['410-tidinfo'] = True
u.log('410-tidinfo', 'tidinfo loaded')
Пример #3
0

# Prints a string from system memory to the simics console
def lputs(dummy, cpu, param):
    if cpu.cs[0] & 3:
        mc = 'udbg'
    else:
        mc = 'kdbg'
    cs410_utils.log(mc, cs410_utils.copyout_str(cpu, cpu.ecx))


# Loads memory size in kilobytes into %esi
def memsize(dummy, cpu, param):
    cpu.eax = conf.system_cmp0.memory_megs * 1024


# Writes 1 into eax to determine whether we are in Simics.
def in_simics(dummy, cpu, param):
    cpu.eax = 0x15410DE0


def halt(dummy, cpu, param):
    cs410_utils.log('410-core', 'Halted.')
    cs410_dispatch.run_halt_callbacks()
    SIM_quit(0)


# Common code to register the below functions.
for fn in [in_simics, lputs, breakpoint, memsize, halt]:
    cs410_dispatch.add_simcall(fn)
    tf = tidcontext[tid]
    if isinstance(tf, dict):
        # Off core, stored decoded frame at registration time
        u.log('410', 'TID %d is off-core right now' % tid)
        u.print_trap_frame(tf)
    else:
        # On core, read from cpu right now
        u.log('410', 'TID %d is on-core right now: %s' % (tid, tf.name))
        u.print_trap_frame(u.trap_frame_from_cpu(tf))


def cmd_tids():
    u.log('410', 'TIDs registered right now: %r' % tidcontext.keys())


cs410_dispatch.add_simcall(tidinfo_set)
cs410_dispatch.add_simcall(tidinfo_del)
new_command(
    "tidinfo",
    cmd_tidinfo,
    args=[arg(int_t, "tid")],
    short="Ask kernel for thread information by TID",
    doc="This reports thread information as derived from simulation state")
new_command("tids",
            cmd_tids,
            short="Report the list of tids registered for tidinfo debugging.",
            doc="This reports the list of tids being tracked.")

# u.logging['410-tidinfo'] = True
# u.printing['410-tidinfo'] = True
u.log('410-tidinfo', 'tidinfo loaded')
Пример #5
0
    if (os.path.isfile(str)):
        # Load all subsequent symbol tables with this source as well
        kern_path = str
        usersym = "deflsym"

        sp = ""
        for p in [working_dir + "/", user_src_path, test_src_path]:
            if os.path.exists(p):
                sp += p + ";"

        def to_do_alone(cpu, times, error):
            cli.run_command("%s.source-path \"%s\"" % (usersym, sp[:-1]))
            cli.run_command("%s.load-symbols %s" % (usersym, str))
            cli.run_command("system.cell_context.symtable %s" % usersym)

        if len(sp) > 0:
            boot_callbacks.insert(0, to_do_alone)
    else:
        print "No such kernel image: '%s'; symbolic debugging won't work." % str
        error = 1

    def run_callbacks():
        for x in boot_callbacks:
            x(cpu, cs410_dispatch.kernel_up, error)

    cs410_utils.alone(run_callbacks)


cs410_dispatch.add_simcall(booted)
        #st = SIM_get_object(s) # This would be the right thing to do but it
        #SIM_delete_object(st)  # doesn't appear to be supported by simics yet

# Registers a fork()ed process for debugging
def reg_child(dummy, cpu, param):
    child_cr3 = cpu.ecx
    parent_cr3 = cpu.edx
    user_process_registry[child_cr3] = user_process_registry[parent_cr3]
    cs410_utils.alone(switch_current_symtable, cpu)

# Sets the current symtable to be the one associated with the cr3
def switch_symtable(cr3):
    if user_process_registry.has_key(cr3):
        cli.quiet_run_command("cell0_context.symtable %s" %
            user_process_registry[cr3])
    else:
        cli.quiet_run_command("cell0_context.symtable deflsym")

# Switch to the symtable associated with the current execution state
def switch_current_symtable(cpu):
    switch_symtable(cpu.iface.int_register.read(cpu, ncr3))

def switch_creg(dummy, cpu, regnum, val):
    if regnum == ncr3:
        switch_symtable(val)

for fn in [reg_process, unreg_process, reg_child]:
    cs410_dispatch.add_simcall(fn)

SIM_hap_add_callback("Core_Control_Register_Write", switch_creg, 0)
Пример #7
0
                                               irqswitch, 0)


def acked(ignored):
    return 32 + 6


def issue_command(num, arg, interactive):
    global cmdq
    cmdq.append({'op': num, 'arg': arg, 'interactive': interactive})
    if (not conf.cpu0.iface.x86.has_pending_interrupt()
            and not conf.cpu0.iface.x86.has_waiting_interrupt()):
        conf.cpu0.iface.interrupt_ack.raise_interrupt(acked, None)


# Obsoleted by 410mods-dynamic-tidinfo.py, which is a vastly superior
# mechanism.  NWF 20100120
#
# def cmd_tidinfo(tid):
#    global issue_command
#    issue_command(1, tid, True)
#    SIM_continue(0)
#
#new_command("tidinfo", cmd_tidinfo, args=[arg(int_t, "tid", "?", 1)],
#      short="Ask kernel for thread information by TID",
#      doc="This restarts the simulation long enough to ask for the "
#          + "kernel to translate a TID and dump out what the kernel "
#          + "knew last it saw that thread." )

cs410_dispatch.add_simcall(osdev_next)
Пример #8
0
def enablebps(bp):
    cli.quiet_run_command("enable %d" % bp)


def disablebps(bp):
    cli.quiet_run_command("disable %d" % bp)


# This needs to run "alone" so that it can make all the API calls it
# needs to.
def swat_help(dummy, cpu, param):
    global atomic_breakpoints

    if not atomic_breakpoints:
        setup_xchg()

    f = enablebps
    if cpu.ecx == 0:
        f = disablebps

    for brk in atomic_breakpoints:
        f(brk)


def swat(dummy, cpu, param):
    cs410_utils.alone(swat_help, dummy, cpu, param)


cs410_dispatch.add_simcall(swat)
    for brk in atomic_breakpoints:
        cs410_dispatch.breakpoint_handlers[brk] = xchg_handle_breakpoints

    # print "Atomic assist present %s" % atomic_breakpoints

def enablebps(bp):
    cli.quiet_run_command("enable %d" % bp)

def disablebps(bp):
    cli.quiet_run_command("disable %d" % bp)

# This needs to run "alone" so that it can make all the API calls it
# needs to.
def swat_help(dummy, cpu, param):
    global atomic_breakpoints

    if not atomic_breakpoints:
        setup_xchg()

    f = enablebps
    if cpu.ecx == 0:
        f = disablebps

    for brk in atomic_breakpoints:
        f(brk)

def swat(dummy, cpu, param):
    cs410_utils.alone(swat_help, dummy, cpu, param)

cs410_dispatch.add_simcall(swat)
Пример #10
0
        cmd = cmdq[0]
        u.copyin(cpu, cpu.ecx, "II", cmd['op'], cmd['arg'])
        if cmd['interactive']:
            SIM_hap_add_callback("Core_Interrupt_Status", irqswitch, 0)

def acked(ignored):
    return 32 + 6

def issue_command(num, arg, interactive):
    global cmdq
    cmdq.append({ 'op': num,
                  'arg': arg,
                  'interactive': interactive })
    conf.cpu0.iface.interrupt_ack.raise_interrupt(conf.cpu0, acked, None)

# Obsoleted by 410mods-dynamic-tidinfo.py, which is a vastly superior
# mechanism.  NWF 20100120
#
# def cmd_tidinfo(tid):
#    global issue_command
#    issue_command(1, tid, True)
#    SIM_continue(0)
#
#new_command("tidinfo", cmd_tidinfo, args=[arg(int_t, "tid", "?", 1)],
#      short="Ask kernel for thread information by TID",
#      doc="This restarts the simulation long enough to ask for the "
#          + "kernel to translate a TID and dump out what the kernel "
#          + "knew last it saw that thread." )

cs410_dispatch.add_simcall(osdev_next)