From 860a1754fd7e4c8ff3c68683554b8420fcf5bb94 Mon Sep 17 00:00:00 2001 From: Jim Kingdon Date: Fri, 27 Aug 1993 03:22:33 +0000 Subject: [PATCH] * infcmd.c, inferior.h (run_stack_dummy): If we stop somewhere besides the dummy, return 1 rather than calling error(). Let caller print the error message. Remove name argument. * valops.c (call_function_by_hand): Deal with changes to calling sequence of run_stack_dummy. Discard restore_inferior_status cleanup if run_stack_dummy returns 1. --- gdb/ChangeLog | 12 +++++++++ gdb/infcmd.c | 73 +++++++++++---------------------------------------- gdb/valops.c | 38 +++++++++++++++++++++++++-- 3 files changed, 63 insertions(+), 60 deletions(-) diff --git a/gdb/ChangeLog b/gdb/ChangeLog index f957a0c58e7..8b54909879d 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,5 +1,17 @@ Thu Aug 26 14:32:51 1993 Jim Kingdon (kingdon@lioth.cygnus.com) + * infcmd.c, inferior.h (run_stack_dummy): If we stop somewhere + besides the dummy, return 1 rather than calling error(). + Let caller print the error message. Remove name argument. + * valops.c (call_function_by_hand): Deal with changes to calling + sequence of run_stack_dummy. Discard restore_inferior_status cleanup + if run_stack_dummy returns 1. + + * Version 4.10.2. + + * config/mips/tm-mips.h (EXTRACT_STRUCT_VALUE_ADDRESS): + Get struct return address from v0, not a0. + * infrun.c (restore_inferior_status): Use catch_errors when restoring selected frame. diff --git a/gdb/infcmd.c b/gdb/infcmd.c index 77015a1fea6..d11b40dc6c2 100644 --- a/gdb/infcmd.c +++ b/gdb/infcmd.c @@ -363,37 +363,15 @@ step_1 (skip_subroutines, single_inst, count_string) find_pc_line_pc_range (stop_pc, &step_range_start, &step_range_end); if (step_range_end == 0) { - struct minimal_symbol *msymbol; + char *name; + if (find_pc_partial_function (stop_pc, &name, &step_range_start, + &step_range_end) == 0) + error ("Cannot find bounds of current function"); - /* FIXME: This should be using containing_function_bounds or a - cleaned-up version thereof, to deal with things like the - end of the text segment. */ - - msymbol = lookup_minimal_symbol_by_pc (stop_pc); target_terminal_ours (); - printf_filtered ("Current function has no line number information.\n"); - fflush (stdout); - - if (msymbol == NULL || SYMBOL_NAME (msymbol + 1) == NULL) - { - /* If sigtramp is in the u area, check for it. */ -#if defined SIGTRAMP_START - if (IN_SIGTRAMP (stop_pc, (char *)NULL)) - { - step_range_start = SIGTRAMP_START; - step_range_end = SIGTRAMP_END; - } - else -#endif - error ("Cannot find bounds of current function."); - } - else - { - step_range_start = SYMBOL_VALUE_ADDRESS (msymbol); - step_range_end = SYMBOL_VALUE_ADDRESS (msymbol + 1); - } - - printf_filtered ("Single stepping until function exit.\n"); + printf_filtered ("\ +Single stepping until exit from function %s, \n\ +which has no line number information.\n", name); fflush (stdout); } } @@ -530,20 +508,16 @@ signal_command (signum_exp, from_tty) 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. - - NAME is a string to print to identify the function which we are calling. - It is not guaranteed to be the name of a function, it could be something - like "at 0x4370" if a name can't be found for the function. */ + returns to its caller with that frame already gone and returns 0. + Otherwise, run_stack-dummy returns 1 (the frame will eventually be popped + when we do hit that breakpoint). */ /* DEBUG HOOK: 4 => return instead of letting the stack dummy run. */ static int stack_dummy_testing = 0; -void -run_stack_dummy (name, addr, buffer) - char *name; +int +run_stack_dummy (addr, buffer) CORE_ADDR addr; char buffer[REGISTER_BYTES]; { @@ -558,21 +532,12 @@ run_stack_dummy (name, addr, buffer) proceed (addr, 0, 0); if (!stop_stack_dummy) - /* This used to say - "The expression which contained the function call has been discarded." - It is a hard concept to explain in a few words. Ideally, GDB would - be able to resume evaluation of the expression when the function - finally is done executing. Perhaps someday this will be implemented - (it would not be easy). */ - error ("\ -The program being debugged stopped while in a function called from GDB.\n\ -When the function (%s) is done executing, GDB will silently\n\ -stop (instead of continuing to evaluate the expression containing\n\ -the function call).", name); + return 1; /* On return, the stack dummy has been popped already. */ memcpy (buffer, stop_registers, sizeof stop_registers); + return 0; } /* Proceed until we reach a different source line with pc greater than @@ -713,7 +678,7 @@ finish_command (arg, from_tty) funcaddr = BLOCK_START (SYMBOL_BLOCK_VALUE (function)); val = value_being_returned (value_type, stop_registers, - using_struct_return (value_of_variable (function), + using_struct_return (value_of_variable (function, NULL), funcaddr, value_type, BLOCK_GCC_COMPILED (SYMBOL_BLOCK_VALUE (function)))); @@ -931,19 +896,11 @@ path_command (dirname, from_tty) CORE_ADDR read_pc () { -#ifdef GDB_TARGET_IS_HPPA - int flags = read_register(FLAGS_REGNUM); - - if (flags & 2) - return read_register(31) & ~0x3; /* User PC is here when in sys call */ - return read_register (PC_REGNUM) & ~0x3; -#else #ifdef TARGET_READ_PC return TARGET_READ_PC (); #else return ADDR_BITS_REMOVE ((CORE_ADDR) read_register (PC_REGNUM)); #endif -#endif } void diff --git a/gdb/valops.c b/gdb/valops.c index 1b409ff82af..fa75ea6f4bd 100644 --- a/gdb/valops.c +++ b/gdb/valops.c @@ -1030,7 +1030,6 @@ call_function_by_hand (function, nargs, args) wouldn't happen. (See store_inferior_registers in sparc-nat.c.) */ write_sp (sp); - /* Figure out the value returned by the function. */ { char retbuf[REGISTER_BYTES]; char *name; @@ -1063,10 +1062,37 @@ call_function_by_hand (function, nargs, args) /* Execute the stack dummy routine, calling FUNCTION. When it is done, discard the empty frame after storing the contents of all regs into retbuf. */ - run_stack_dummy (name, real_pc + CALL_DUMMY_START_OFFSET, retbuf); + if (run_stack_dummy (real_pc + CALL_DUMMY_START_OFFSET, retbuf)) + { + /* We stopped somewhere besides the call dummy. */ + + /* If we did the cleanups, we would print a spurious error message + (Unable to restore previously selected frame), would write the + registers from the inf_status (which is wrong), and would do other + wrong things (like set stop_bpstat to the wrong thing). */ + discard_cleanups (old_chain); + /* Prevent memory leak. */ + bpstat_clear (inf_status.stop_bpstat); + + /* The following error message used to say "The expression + which contained the function call has been discarded." It + is a hard concept to explain in a few words. Ideally, GDB + would be able to resume evaluation of the expression when + the function finally is done executing. Perhaps someday + this will be implemented (it would not be easy). */ + + /* FIXME: Insert a bunch of wrap_here; name can be very long if it's + a C++ name with arguments and stuff. */ + error ("\ +The program being debugged stopped while in a function called from GDB.\n\ +When the function (%s) is done executing, GDB will silently\n\ +stop (instead of continuing to evaluate the expression containing\n\ +the function call).", name); + } do_cleanups (old_chain); + /* Figure out the value returned by the function. */ return value_being_returned (value_type, retbuf, struct_return); } } @@ -1494,6 +1520,14 @@ value_struct_elt (argp, args, name, static_memfuncp, err) } if (!v) + /* FIXME: This error message is very confusing, since it can also + mean that argument matching failed. But I don't want to say + "or argument matching failed" for C programs. Checking the + current language isn't right, because whether we attempt + argument matching does not depend on the language. The right + fix is to restructure the above code to be able to distinguish + between argument matching failure and the field not being found + at all. */ error ("Structure has no component named %s.", name); return v; } -- 2.30.2