struct annotate_two *a2_create_context(const char *debugger, int argc, char **argv, const char *config_dir, struct logger *logger_in) { struct annotate_two *a2 = initialize_annotate_two(); char a2_debug_file[FSUTIL_PATH_MAX]; if (!tgdb_setup_config_file(a2, config_dir)) { logger_write_pos(logger_in, __FILE__, __LINE__, "tgdb_init_config_file error"); return NULL; } /* Initialize the debug file that a2_tgdb writes to */ fs_util_get_path(config_dir, "a2_tgdb_debug.txt", a2_debug_file); io_debug_init(a2_debug_file); a2->debugger_pid = invoke_debugger(debugger, argc, argv, &a2->debugger_stdin, &a2->debugger_out, 0, a2->a2_gdb_init_file); /* Couldn't invoke process */ if (a2->debugger_pid == -1) return NULL; return a2; }
struct tgdb *tgdb_initialize(const char *debugger, int argc, char **argv, int *debugger_fd, tgdb_callbacks callbacks) { /* Initialize the libtgdb context */ struct tgdb *tgdb = initialize_tgdb_context(callbacks); static struct annotations_parser_callbacks annotations_callbacks = { tgdb, tgdb_breakpoints_changed, tgdb_source_location_changed, tgdb_prompt_changed, tgdb_console_output, tgdb_command_error, tgdb_console_at_prompt }; tgdb->debugger_pid = invoke_debugger(debugger, argc, argv, &tgdb->debugger_stdin, &tgdb->debugger_stdout, 0); /* Couldn't invoke process */ if (tgdb->debugger_pid == -1) return NULL; tgdb->c = commands_initialize(tgdb); tgdb->parser = annotations_parser_initialize(annotations_callbacks); tgdb_open_new_tty(tgdb, &tgdb->inferior_stdin, &tgdb->inferior_stdout); /* Need to get source information before breakpoint information otherwise * the TGDB_UPDATE_BREAKPOINTS event will be ignored in process_commands() * because there are no source files to add the breakpoints to. */ tgdb_request_current_location(tgdb); /* gdb may already have some breakpoints when it starts. This could happen * if the user puts breakpoints in there .gdbinit. * This makes sure that TGDB asks for the breakpoints on start up. */ tgdb_issue_request(tgdb, TGDB_REQUEST_BREAKPOINTS, true); /** * Query if disassemble supports the /s flag */ tgdb_issue_request(tgdb, TGDB_REQUEST_DATA_DISASSEMBLE_MODE_QUERY, true); *debugger_fd = tgdb->debugger_stdout; return tgdb; }
struct annotate_two *a2_create_context(const char *debugger, int argc, char **argv, const char *config_dir, struct logger *logger_in) { struct annotate_two *a2 = (struct annotate_two *) cgdb_calloc(1, sizeof(struct annotate_two)); a2->debugger_stdin = -1; a2->debugger_out = -1; if (!tgdb_setup_config_file(a2, config_dir)) { logger_write_pos(logger_in, __FILE__, __LINE__, "tgdb_init_config_file error"); return NULL; } a2->debugger_pid = invoke_debugger(debugger, argc, argv, &a2->debugger_stdin, &a2->debugger_out, 0, a2->a2_gdb_init_file); /* Couldn't invoke process */ if (a2->debugger_pid == -1) return NULL; return a2; }
int main(int argc, char *argv[]) { struct thread *thread; enum pause_reason reason; struct variable *var; #if ! NO_ARGV_0 char *argv0 = "mindy"; #endif exec_file_name = argv[0]; init_color(false); init(); thread = thread_make(symbol("main")); *thread->sp++ = make_raw_function("startup", obj_Nil, true, obj_False, false, obj_Nil, obj_ObjectClass, startup); while (*++argv != NULL) { if (strcmp(*argv, "-f") == 0) { if (*++argv == NULL) missing_arg("-f"); load(*argv); #if ! NO_SHARP_BANG } else if (strcmp(*argv, "-x") == 0) { if (*++argv == NULL) missing_arg("-f"); #if ! NO_ARGV_0 if (strcmp(*argv, "-") != 0) argv0 = *argv; #endif load(*argv); argv += 1; break; #endif #if ! NO_ARGV_0 } else if (strcmp(*argv, "-0") == 0) { if (*++argv == NULL) missing_arg("-0"); argv0 = *argv; #endif } else { break; } } #if ! NO_ARGV_0 *thread->sp++ = make_byte_string(argv0); /* pass command name */ #endif while (*argv != NULL) *thread->sp++ = make_byte_string(*argv++); finalize_modules(); while (1) { thread_restart(thread); reason = do_stuff(); if (reason != pause_NothingToRun) invoke_debugger(reason); var = find_variable(module_BuiltinStuff, symbol("exit"), false, false); if (var == NULL) lose("main undefined?"); thread = thread_make(symbol("exit")); *thread->sp++ = var->value; } return 0; }