Example #1
0
def parse_program_args():
    """Initialize command line options, and parse them.
    Return the user's inferior to execute as a list."""
    global GS_FRED_USAGE, g_source_script, gs_resume_dir_path
    global gb_show_child_output
    parser = OptionParser(usage=GS_FRED_USAGE, version=GS_FRED_VERSION)
    parser.disable_interspersed_args()
    # Note that '-h' and '--help' are supported automatically.
    default_port = os.getenv("DMTCP_PORT") or 7779
    parser.add_option(
        "-p",
        "--port",
        dest="dmtcp_port",
        default=default_port,
        help="Use PORT for DMTCP port number. (default %default)",
        metavar="PORT")
    parser.add_option("-x",
                      "--source",
                      dest="source_script",
                      help="Execute batch file FILE",
                      metavar="FILE")
    parser.add_option("--enable-debug",
                      dest="debug",
                      default=False,
                      action="store_true",
                      help="Enable FReD debugging messages.")
    parser.add_option("--show-child-output",
                      dest="show_child_output",
                      default=False,
                      action="store_true",
                      help="Show all output from child processes.")
    parser.add_option("--fred-demo",
                      dest="fred_demo",
                      default=False,
                      action="store_true",
                      help="Enable FReD demo mode.")
    parser.add_option("--resume",
                      dest="resume_dir",
                      help="Resume session from directory DIR containing "
                      "FReD support files: checkpoint images, "
                      "synchronization logs, etc.",
                      metavar="DIR")
    (options, l_args) = parser.parse_args()
    # 'l_args' is the 'gdb ARGS ./a.out' list
    if len(l_args) == 0 and options.resume_dir == None:
        parser.print_help()
        fredutil.fred_quit(1)
    if options.source_script != None:
        # Source script executed from main_io_loop().
        g_source_script = options.source_script
    fredio.GB_FRED_DEMO = options.fred_demo
    gb_show_child_output = options.show_child_output
    if options.resume_dir != None:
        # Resume session from given directory.
        gs_resume_dir_path = options.resume_dir
    setup_environment_variables(str(options.dmtcp_port), options.debug)
    return l_args
Example #2
0
def main():
    """Program execution starts here."""
    global gs_resume_dir_path
    setup_critical_files()
    # Don't do anything if we can't find DMTCP.
    verify_critical_files_present()
    fred_setup()
    # Main input/output loop
    # skip the prompt waiting if we are resuming:
    b_skip_prompt = gs_resume_dir_path != None
    main_io_loop(b_skip_prompt)
    # If we get here, quit.
    fredutil.fred_quit(0)
Example #3
0
def main():
    """Program execution starts here."""
    global gs_resume_dir_path
    setup_critical_files()
    # Don't do anything if we can't find DMTCP.
    verify_critical_files_present()
    fred_setup()
    # Main input/output loop
    # skip the prompt waiting if we are resuming:
    b_skip_prompt = gs_resume_dir_path != None
    main_io_loop(b_skip_prompt)
    # If we get here, quit.
    fredutil.fred_quit(0)
Example #4
0
def handle_fred_command(s_command):
    """Performs handling of 'special' (non-debugger) commands."""
    global g_debugger, GS_FRED_COMMAND_PREFIX
    s_command = s_command.replace(GS_FRED_COMMAND_PREFIX, "")
    (s_command_name, sep, s_command_args) = s_command.partition(' ')
    n_count = fredutil.to_int(s_command_args, 1)
    if is_quit_command(s_command_name):
        fredutil.fred_quit(0)
    elif s_command_name == "undo":
        undo.undo(g_debugger, n_count)
    elif s_command_name in ["reverse-next", "rn"]:
        reverse_next.reverse_next(g_debugger, n_count)
    elif s_command_name in ["reverse-step", "rs"]:
        reverse_step.reverse_step(g_debugger, n_count)
    elif s_command_name in ["reverse-finish", "rf"]:
        reverse_finish.reverse_finish(g_debugger, n_count)
    elif s_command_name in ["reverse-continue", "rc"]:
        reverse_continue.reverse_continue(g_debugger)
    elif s_command_name in ["checkpoint", "ckpt"]:
        g_debugger.do_checkpoint()
    elif s_command_name == "restart":
        # n_count defaults to 1 if no argument given (not appropriate here)
        n_index = fredutil.to_int(s_command_args, 0)
        g_debugger.do_restart(n_index, b_clear_history=True)
    elif s_command_name in ["reverse-watch", "rw"]:
        if g_debugger.personality_name() == "gdb":
            # Multithreaded reverse-watch only supported for gdb.
            reverse_watch.reverse_watch_for_mt(g_debugger, s_command_args)
        else:
            reverse_watch.reverse_watch(g_debugger, s_command_args)
    elif s_command_name == "source":
        source_from_file(s_command_args)
    elif s_command_name == "list":
        g_debugger.print_branches()
    elif s_command_name == "branch":
        g_debugger.do_branch(s_command_args)
    elif s_command_name == "switch":
        g_debugger.switch_to_branch(s_command_args)
    elif s_command_name == "help":
        fred_command_help()
    elif s_command_name == "history":
        print g_debugger.history()
    elif s_command_name == "debug":
        pdb.set_trace()
    else:
        fredutil.fred_error("Unknown FReD command '%s'" % s_command_name)
Example #5
0
def parse_program_args():
    """Initialize command line options, and parse them.
    Return the user's inferior to execute as a list."""
    global GS_FRED_USAGE, g_source_script, gs_resume_dir_path
    parser = OptionParser(usage=GS_FRED_USAGE, version=GS_FRED_VERSION)
    parser.disable_interspersed_args()
    # Note that '-h' and '--help' are supported automatically.
    default_port = os.getenv("DMTCP_PORT") or 7779
    parser.add_option(
        "-p",
        "--port",
        dest="dmtcp_port",
        default=default_port,
        help="Use PORT for DMTCP port number. (default %default)",
        metavar="PORT",
    )
    parser.add_option("-x", "--source", dest="source_script", help="Execute batch file FILE", metavar="FILE")
    parser.add_option(
        "--enable-debug", dest="debug", default=False, action="store_true", help="Enable FReD debugging messages."
    )
    parser.add_option(
        "--fred-demo", dest="fred_demo", default=False, action="store_true", help="Enable FReD demo mode."
    )
    parser.add_option(
        "--resume",
        dest="resume_dir",
        help="Resume session from directory DIR containing "
        "FReD support files: checkpoint images, "
        "synchronization logs, etc.",
        metavar="DIR",
    )
    (options, l_args) = parser.parse_args()
    # 'l_args' is the 'gdb ARGS ./a.out' list
    if len(l_args) == 0 and options.resume_dir == None:
        parser.print_help()
        fredutil.fred_quit(1)
    if options.source_script != None:
        # Source script executed from main_io_loop().
        g_source_script = options.source_script
    if options.fred_demo:
        fredio.GB_FRED_DEMO = True
    if options.resume_dir != None:
        # Resume session from given directory.
        gs_resume_dir_path = options.resume_dir
    setup_environment_variables(str(options.dmtcp_port), options.debug)
    return l_args
Example #6
0
def handle_fred_command(s_command):
    """Performs handling of 'special' (non-debugger) commands."""
    global g_debugger, GS_FRED_COMMAND_PREFIX
    s_command = s_command.replace(GS_FRED_COMMAND_PREFIX, "")
    (s_command_name, sep, s_command_args) = s_command.partition(" ")
    n_count = fredutil.to_int(s_command_args, 1)
    if is_quit_command(s_command_name):
        fredutil.fred_quit(0)
    elif s_command_name == "undo":
        undo.undo(g_debugger, n_count)
    elif s_command_name in ["reverse-next", "rn"]:
        # iF THIS DOESN'T WORK FOR YOU, CHANGE IT BACK TO reverse_next().
        reverse_next.NEW_reverse_next(g_debugger, n_count)
    elif s_command_name in ["reverse-step", "rs"]:
        # iF THIS DOESN'T WORK FOR YOU, CHANGE IT BACK TO reverse_step().
        reverse_step.NEW_reverse_step(g_debugger, n_count)
    elif s_command_name in ["reverse-finish", "rf"]:
        # iF THIS DOESN'T WORK FOR YOU, CHANGE IT BACK TO reverse_step().
        reverse_finish.NEW_reverse_finish(g_debugger, n_count)
    elif s_command_name in ["reverse-continue", "rc"]:
        reverse_continue.reverse_continue(g_debugger)
    elif s_command_name in ["checkpoint", "ckpt"]:
        g_debugger.do_checkpoint()
    elif s_command_name == "restart":
        # n_count defaults to 1 if no argument given (not appropriate here)
        n_index = fredutil.to_int(s_command_args, 0)
        g_debugger.do_restart(n_index, b_clear_history=True)
    elif s_command_name in ["reverse-watch", "rw"]:
        reverse_watch.reverse_watch_with_log_support(g_debugger, s_command_args)
        # reverse_watch.reverse_watch(g_debugger, s_command_args)
    elif s_command_name == "source":
        source_from_file(s_command_args)
    elif s_command_name == "list":
        g_debugger.print_branches()
    elif s_command_name == "branch":
        g_debugger.do_branch(s_command_args)
    elif s_command_name == "switch":
        g_debugger.switch_to_branch(s_command_args)
    elif s_command_name == "help":
        fred_command_help()
    elif s_command_name == "history":
        print g_debugger.history()
    elif s_command_name == "debug":
        pdb.set_trace()
    else:
        fredutil.fred_error("Unknown FReD command '%s'" % s_command_name)