📄 infcmd.c
字号:
{ error ("Unreasonable jump request"); } sal = sals.sals[0]; free ((PTR)sals.sals); if (sal.symtab == 0 && sal.pc == 0) error ("No source file has been specified."); resolve_sal_pc (&sal); /* May error out */ /* See if we are trying to jump to another function. */ fn = get_frame_function (get_current_frame ()); sfn = find_pc_function (sal.pc); if (fn != NULL && sfn != fn) { fname = strdup_demangled (SYMBOL_NAME (fn)); back_to = make_cleanup (free, fname); if (!query ("Line %d is not in `%s'. Jump anyway? ", sal.line, fname)) { error ("Not confirmed."); /* NOTREACHED */ } do_cleanups (back_to); } addr = ADDR_BITS_SET (sal.pc); if (from_tty) printf_filtered ("Continuing at %s.\n", local_hex_string(addr)); clear_proceed_status (); proceed (addr, 0, 0);}/* Continue program giving it specified signal. */static voidsignal_command (signum_exp, from_tty) char *signum_exp; int from_tty;{ register int signum; dont_repeat (); /* Too dangerous. */ ERROR_NO_INFERIOR; if (!signum_exp) error_no_arg ("signal number"); signum = parse_and_eval_address (signum_exp); if (from_tty) printf_filtered ("Continuing with signal %d.\n", signum); clear_proceed_status (); proceed (stop_pc, signum, 0);}/* Execute a "stack dummy", a piece of code stored in the stack by the debugger to be executed in the inferior. To call: first, do PUSH_DUMMY_FRAME. Then push the contents of the dummy. It should end with a breakpoint insn. Then call here, passing address at which to start the dummy. The contents of all registers are saved before the dummy frame is popped and copied into the buffer BUFFER. The dummy's frame is automatically popped whenever that break is hit. If that is the first time the program stops, run_stack_dummy returns to its caller with that frame already gone. Otherwise, the caller never gets returned to. *//* DEBUG HOOK: 4 => return instead of letting the stack dummy run. */static int stack_dummy_testing = 0;voidrun_stack_dummy (addr, buffer) CORE_ADDR addr; char buffer[REGISTER_BYTES];{ /* Now proceed, having reached the desired place. */ clear_proceed_status ();#ifdef notdef if (stack_dummy_testing & 4) { POP_FRAME; return; }#endif proceed (addr, 0, 0); if (!stop_stack_dummy) /* This used to say "Cannot continue previously requested operation". */ error ("\The program being debugged stopped while in a function called from GDB.\n\The expression which contained the function call has been discarded."); /* On return, the stack dummy has been popped already. */ read_register_bytes(0, buffer, REGISTER_BYTES);}/* Proceed until we reach a different source line with pc greater than our current one or exit the function. We skip calls in both cases. Note that eventually this command should probably be changed so that only source lines are printed out when we hit the breakpoint we set. I'm going to postpone this until after a hopeful rewrite of wait_for_inferior and the proceed status code. -- randy *//* ARGSUSED */static voiduntil_next_command (from_tty) int from_tty;{ FRAME frame; CORE_ADDR pc; struct symbol *func; struct symtab_and_line sal; clear_proceed_status (); frame = get_current_frame (); /* Step until either exited from this function or greater than the current line (if in symbolic section) or pc (if not). */ pc = read_pc (); func = find_pc_function (pc); if (!func) { struct minimal_symbol *msymbol = lookup_minimal_symbol_by_pc (pc); if (msymbol == NULL) error ("Execution is not within a known function."); step_range_start = msymbol -> address; step_range_end = pc; } else { sal = find_pc_line (pc, 0); step_range_start = BLOCK_START (SYMBOL_BLOCK_VALUE (func)); step_range_end = sal.end; } step_over_calls = 1; step_frame_address = FRAME_FP (frame); step_multi = 0; /* Only one call to proceed */ proceed ((CORE_ADDR) -1, -1, 1);}static void until_command (arg, from_tty) char *arg; int from_tty;{ if (!target_has_execution) error ("The program is not running."); if (arg) until_break_command (arg, from_tty); else until_next_command (from_tty);}/* "finish": Set a temporary breakpoint at the place the selected frame will return to, then continue. */static voidfinish_command (arg, from_tty) char *arg; int from_tty;{ struct symtab_and_line sal; register FRAME frame; struct frame_info *fi; register struct symbol *function; struct breakpoint *breakpoint; struct cleanup *old_chain; if (arg) error ("The \"finish\" command does not take any arguments."); if (!target_has_execution) error ("The program is not running."); if (selected_frame == NULL) error ("No selected frame."); frame = get_prev_frame (selected_frame); if (frame == 0) error ("\"finish\" not meaningful in the outermost frame."); clear_proceed_status (); fi = get_frame_info (frame); sal = find_pc_line (fi->pc, 0); sal.pc = fi->pc; breakpoint = set_momentary_breakpoint (sal, frame, bp_finish); old_chain = make_cleanup(delete_breakpoint, breakpoint); /* Find the function we will return from. */ fi = get_frame_info (selected_frame); function = find_pc_function (fi->pc); /* Print info on the selected frame, including level number but not source. */ if (from_tty) { printf_filtered ("Run till exit from "); print_stack_frame (selected_frame, selected_frame_level, 0); } proceed ((CORE_ADDR) -1, -1, 0); /* Did we stop at our breakpoint? */ if (bpstat_find_breakpoint(stop_bpstat, breakpoint) != NULL && function != 0) { struct type *value_type; register value val; CORE_ADDR funcaddr; char stop_registers[REGISTER_BYTES]; read_register_bytes(0, stop_registers, REGISTER_BYTES); value_type = TYPE_TARGET_TYPE (SYMBOL_TYPE (function)); if (!value_type) fatal ("internal: finish_command: function has no target type"); if (TYPE_CODE (value_type) == TYPE_CODE_VOID) return; funcaddr = BLOCK_START (SYMBOL_BLOCK_VALUE (function)); val = value_being_returned (value_type, stop_registers, using_struct_return (value_of_variable (function), funcaddr, value_type, BLOCK_GCC_COMPILED (SYMBOL_BLOCK_VALUE (function)))); printf_filtered ("Value returned is $%d = ", record_latest_value (val)); value_print (val, stdout, 0, Val_no_prettyprint); printf_filtered ("\n"); } do_cleanups(old_chain);}/* ARGSUSED */static voidprogram_info (args, from_tty) char *args; int from_tty;{ bpstat bs = stop_bpstat; int num = bpstat_num (&bs); if (!target_has_execution) { printf_filtered ("The program being debugged is not being run.\n"); return; } target_files_info (); printf_filtered ("Program stopped at %s.\n", local_hex_string(stop_pc)); if (stop_step) printf_filtered ("It stopped after being stepped.\n"); else if (num != 0) { /* There may be several breakpoints in the same place, so this isn't as strange as it seems. */ while (num != 0) { if (num < 0) printf_filtered ("It stopped at a breakpoint that has since been deleted.\n"); else printf_filtered ("It stopped at breakpoint %d.\n", num); num = bpstat_num (&bs); } } else if (stop_signal) {#ifdef PRINT_RANDOM_SIGNAL PRINT_RANDOM_SIGNAL (stop_signal);#else printf_filtered ("It stopped with signal %d (%s).\n", stop_signal, safe_strsignal (stop_signal));#endif } if (!from_tty) printf_filtered ("Type \"info stack\" or \"info registers\" for more information.\n");}static voidenvironment_info (var, from_tty) char *var; int from_tty;{ if (var) { register char *val = get_in_environ (inferior_environ, var); if (val) printf_filtered ("%s = %s\n", var, val); else printf_filtered ("Environment variable \"%s\" not defined.\n", var); } else { register char **vector = environ_vector (inferior_environ); while (*vector) printf_filtered ("%s\n", *vector++); }}static voidset_environment_command (arg, from_tty) char *arg; int from_tty;{ register char *p, *val, *var; int nullset = 0; if (arg == 0) error_no_arg ("environment variable and value"); /* Find seperation between variable name and value */ p = (char *) strchr (arg, '='); val = (char *) strchr (arg, ' '); if (p != 0 && val != 0) { /* We have both a space and an equals. If the space is before the equals and the only thing between the two is more space, use the equals */ if (p > val) while (*val == ' ') val++; /* Take the smaller of the two. If there was space before the "=", they will be the same right now. */ p = arg + min (p - arg, val - arg); } else if (val != 0 && p == 0) p = val; if (p == arg) error_no_arg ("environment variable to set"); if (p == 0 || p[1] == 0) { nullset = 1; if (p == 0) p = arg + strlen (arg); /* So that savestring below will work */ } else { /* Not setting variable value to null */ val = p + 1; while (*val == ' ' || *val == '\t') val++; } while (p != arg && (p[-1] == ' ' || p[-1] == '\t')) p--; var = savestring (arg, p - arg); if (nullset) { printf_filtered ("Setting environment variable \"%s\" to null value.\n", var); set_in_environ (inferior_environ, var, ""); } else set_in_environ (inferior_environ, var, val); free (var);}static voidunset_environment_command (var, from_tty) char *var; int from_tty;{ if (var == 0) { /* If there is no argument, delete all environment variables. Ask for confirmation if reading from the terminal. */ if (!from_tty || query ("Delete all environment variables? ")) { free_environ (inferior_environ); inferior_environ = make_environ (); } } else unset_in_environ (inferior_environ, var);}/* Handle the execution path (PATH variable) */const static char path_var_name[] = "PATH";/* ARGSUSED */static voidpath_info (args, from_tty) char *args; int from_tty;{ puts_filtered ("Executable and object file path: "); puts_filtered (get_in_environ (inferior_environ, path_var_name)); puts_filtered ("\n");}/* Add zero or more directories to the front of the execution path. */static voidpath_command (dirname, from_tty) char *dirname; int from_tty;{ char *exec_path;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -