Esempio n. 1
0
def fred_setup():
    """Perform any setup needed by FReD before entering an I/O loop."""
    global g_debugger, gs_resume_dir_path, GS_FRED_TMPDIR
    # Parse command line args and set up environment.
    l_cmd = parse_program_args()
    # Set up the FReD global debugger
    setup_debugger(l_cmd[0])
    # Set up I/O handling
    # (only spawn if we are not resuming:)
    b_resume = gs_resume_dir_path != None
    if not b_resume:
        cleanup_fred_files()
        setup_fredio(l_cmd, True)
        g_debugger.create_master_branch()
    else:
        setup_fredio(l_cmd, False)
        dmtcpmanager.resume(GS_FRED_TMPDIR, gs_resume_dir_path)
        g_debugger.setup_from_resume()
        # XXX: Right now this is a hack to get the virtualized pid of the
        # inferior. We should make this more robust. Ideally we could have
        # support from DMTCP (via dmtcp_command) to tell us the inferior
        # virtualized pid.
        fredutil.fred_assert(g_debugger.personality_name() == "gdb")
        n_inf_pid = int(g_debugger.evaluate_expression("getpid()"))
        fredmanager.set_pid(n_inf_pid)
    g_debugger.set_debugger_pid(fredio.get_child_pid())
Esempio n. 2
0
def dispatch_command(s_command, b_wait=False):
    """Given a user command, dispatches and executes it in the right way.
    If b_wait is True, wait for the debugger prompt after each command."""
    fredutil.fred_timer_start(s_command)
    # TODO: Currently we do not log fred commands. Do we need to?
    if is_fred_command(s_command):
        handle_fred_command(s_command)
    else:
        # XXX: Figure out a more elegant way to do this. We can't set the
        # inferior pid until we know the inferior is alive, so we keep trying
        # to update it with every command issued until it succeeds.
        if fredmanager.get_pid() == -1:
            n_inf_pid = fredutil.get_inferior_pid(fredio.get_child_pid())
            fredmanager.set_pid(n_inf_pid)

        fredio.send_command(s_command)
        g_debugger.log_command(s_command)
        if b_wait:
            fredio.wait_for_prompt()
    fredutil.fred_timer_stop(s_command)