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, gb_show_child_output # 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_virtual_inferior_pid(n_inf_pid) g_debugger.set_real_debugger_pid(fredio.get_child_pid())
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())
def fred_setup_as_module(l_cmd, s_dmtcp_port, b_debug, b_show_child_output): """Perform setup for FReD when being used as a module, return g_debugger. For example, fredtest.py uses FReD as a module.""" global g_debugger, gb_show_child_output cleanup_fred_files() setup_environment_variables(s_dmtcp_port, b_debug) setup_debugger(l_cmd[0]) gb_show_child_output = b_show_child_output setup_fredio(l_cmd, True) # Since modules won't use the main_io_loop, we perform the debugger setup # requiring a debugger prompt here. g_debugger.set_real_debugger_pid(fredio.get_child_pid()) fredio.wait_for_prompt() interactive_debugger_setup() return g_debugger
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)