gdb/infcall.c - gdb

Global variables defined

Functions defined

Macros defined

Source code

  1. /* Perform an inferior function call, for GDB, the GNU debugger.

  2.    Copyright (C) 1986-2015 Free Software Foundation, Inc.

  3.    This file is part of GDB.

  4.    This program is free software; you can redistribute it and/or modify
  5.    it under the terms of the GNU General Public License as published by
  6.    the Free Software Foundation; either version 3 of the License, or
  7.    (at your option) any later version.

  8.    This program is distributed in the hope that it will be useful,
  9.    but WITHOUT ANY WARRANTY; without even the implied warranty of
  10.    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  11.    GNU General Public License for more details.

  12.    You should have received a copy of the GNU General Public License
  13.    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */

  14. #include "defs.h"
  15. #include "breakpoint.h"
  16. #include "tracepoint.h"
  17. #include "target.h"
  18. #include "regcache.h"
  19. #include "inferior.h"
  20. #include "infrun.h"
  21. #include "block.h"
  22. #include "gdbcore.h"
  23. #include "language.h"
  24. #include "objfiles.h"
  25. #include "gdbcmd.h"
  26. #include "command.h"
  27. #include "infcall.h"
  28. #include "dummy-frame.h"
  29. #include "ada-lang.h"
  30. #include "gdbthread.h"
  31. #include "event-top.h"
  32. #include "observer.h"

  33. /* If we can't find a function's name from its address,
  34.    we print this instead.  */
  35. #define RAW_FUNCTION_ADDRESS_FORMAT "at 0x%s"
  36. #define RAW_FUNCTION_ADDRESS_SIZE (sizeof (RAW_FUNCTION_ADDRESS_FORMAT) \
  37.                                    + 2 * sizeof (CORE_ADDR))

  38. /* NOTE: cagney/2003-04-16: What's the future of this code?

  39.    GDB needs an asynchronous expression evaluator, that means an
  40.    asynchronous inferior function call implementation, and that in
  41.    turn means restructuring the code so that it is event driven.  */

  42. /* How you should pass arguments to a function depends on whether it
  43.    was defined in K&R style or prototype style.  If you define a
  44.    function using the K&R syntax that takes a `float' argument, then
  45.    callers must pass that argument as a `double'.  If you define the
  46.    function using the prototype syntax, then you must pass the
  47.    argument as a `float', with no promotion.

  48.    Unfortunately, on certain older platforms, the debug info doesn't
  49.    indicate reliably how each function was defined.  A function type's
  50.    TYPE_FLAG_PROTOTYPED flag may be clear, even if the function was
  51.    defined in prototype style.  When calling a function whose
  52.    TYPE_FLAG_PROTOTYPED flag is clear, GDB consults this flag to
  53.    decide what to do.

  54.    For modern targets, it is proper to assume that, if the prototype
  55.    flag is clear, that can be trusted: `float' arguments should be
  56.    promoted to `double'.  For some older targets, if the prototype
  57.    flag is clear, that doesn't tell us anything.  The default is to
  58.    trust the debug information; the user can override this behavior
  59.    with "set coerce-float-to-double 0".  */

  60. static int coerce_float_to_double_p = 1;
  61. static void
  62. show_coerce_float_to_double_p (struct ui_file *file, int from_tty,
  63.                                struct cmd_list_element *c, const char *value)
  64. {
  65.   fprintf_filtered (file,
  66.                     _("Coercion of floats to doubles "
  67.                       "when calling functions is %s.\n"),
  68.                     value);
  69. }

  70. /* This boolean tells what gdb should do if a signal is received while
  71.    in a function called from gdb (call dummy).  If set, gdb unwinds
  72.    the stack and restore the context to what as it was before the
  73.    call.

  74.    The default is to stop in the frame where the signal was received.  */

  75. static int unwind_on_signal_p = 0;
  76. static void
  77. show_unwind_on_signal_p (struct ui_file *file, int from_tty,
  78.                          struct cmd_list_element *c, const char *value)
  79. {
  80.   fprintf_filtered (file,
  81.                     _("Unwinding of stack if a signal is "
  82.                       "received while in a call dummy is %s.\n"),
  83.                     value);
  84. }

  85. /* This boolean tells what gdb should do if a std::terminate call is
  86.    made while in a function called from gdb (call dummy).
  87.    As the confines of a single dummy stack prohibit out-of-frame
  88.    handlers from handling a raised exception, and as out-of-frame
  89.    handlers are common in C++, this can lead to no handler being found
  90.    by the unwinder, and a std::terminate call.  This is a false positive.
  91.    If set, gdb unwinds the stack and restores the context to what it
  92.    was before the call.

  93.    The default is to unwind the frame if a std::terminate call is
  94.    made.  */

  95. static int unwind_on_terminating_exception_p = 1;

  96. static void
  97. show_unwind_on_terminating_exception_p (struct ui_file *file, int from_tty,
  98.                                         struct cmd_list_element *c,
  99.                                         const char *value)

  100. {
  101.   fprintf_filtered (file,
  102.                     _("Unwind stack if a C++ exception is "
  103.                       "unhandled while in a call dummy is %s.\n"),
  104.                     value);
  105. }

  106. /* Perform the standard coercions that are specified
  107.    for arguments to be passed to C or Ada functions.

  108.    If PARAM_TYPE is non-NULL, it is the expected parameter type.
  109.    IS_PROTOTYPED is non-zero if the function declaration is prototyped.
  110.    SP is the stack pointer were additional data can be pushed (updating
  111.    its value as needed).  */

  112. static struct value *
  113. value_arg_coerce (struct gdbarch *gdbarch, struct value *arg,
  114.                   struct type *param_type, int is_prototyped, CORE_ADDR *sp)
  115. {
  116.   const struct builtin_type *builtin = builtin_type (gdbarch);
  117.   struct type *arg_type = check_typedef (value_type (arg));
  118.   struct type *type
  119.     = param_type ? check_typedef (param_type) : arg_type;

  120.   /* Perform any Ada-specific coercion first.  */
  121.   if (current_language->la_language == language_ada)
  122.     arg = ada_convert_actual (arg, type);

  123.   /* Force the value to the target if we will need its address.  At
  124.      this point, we could allocate arguments on the stack instead of
  125.      calling malloc if we knew that their addresses would not be
  126.      saved by the called function.  */
  127.   arg = value_coerce_to_target (arg);

  128.   switch (TYPE_CODE (type))
  129.     {
  130.     case TYPE_CODE_REF:
  131.       {
  132.         struct value *new_value;

  133.         if (TYPE_CODE (arg_type) == TYPE_CODE_REF)
  134.           return value_cast_pointers (type, arg, 0);

  135.         /* Cast the value to the reference's target type, and then
  136.            convert it back to a reference.  This will issue an error
  137.            if the value was not previously in memory - in some cases
  138.            we should clearly be allowing this, but how?  */
  139.         new_value = value_cast (TYPE_TARGET_TYPE (type), arg);
  140.         new_value = value_ref (new_value);
  141.         return new_value;
  142.       }
  143.     case TYPE_CODE_INT:
  144.     case TYPE_CODE_CHAR:
  145.     case TYPE_CODE_BOOL:
  146.     case TYPE_CODE_ENUM:
  147.       /* If we don't have a prototype, coerce to integer type if necessary.  */
  148.       if (!is_prototyped)
  149.         {
  150.           if (TYPE_LENGTH (type) < TYPE_LENGTH (builtin->builtin_int))
  151.             type = builtin->builtin_int;
  152.         }
  153.       /* Currently all target ABIs require at least the width of an integer
  154.          type for an argument.  We may have to conditionalize the following
  155.          type coercion for future targets.  */
  156.       if (TYPE_LENGTH (type) < TYPE_LENGTH (builtin->builtin_int))
  157.         type = builtin->builtin_int;
  158.       break;
  159.     case TYPE_CODE_FLT:
  160.       if (!is_prototyped && coerce_float_to_double_p)
  161.         {
  162.           if (TYPE_LENGTH (type) < TYPE_LENGTH (builtin->builtin_double))
  163.             type = builtin->builtin_double;
  164.           else if (TYPE_LENGTH (type) > TYPE_LENGTH (builtin->builtin_double))
  165.             type = builtin->builtin_long_double;
  166.         }
  167.       break;
  168.     case TYPE_CODE_FUNC:
  169.       type = lookup_pointer_type (type);
  170.       break;
  171.     case TYPE_CODE_ARRAY:
  172.       /* Arrays are coerced to pointers to their first element, unless
  173.          they are vectors, in which case we want to leave them alone,
  174.          because they are passed by value.  */
  175.       if (current_language->c_style_arrays)
  176.         if (!TYPE_VECTOR (type))
  177.           type = lookup_pointer_type (TYPE_TARGET_TYPE (type));
  178.       break;
  179.     case TYPE_CODE_UNDEF:
  180.     case TYPE_CODE_PTR:
  181.     case TYPE_CODE_STRUCT:
  182.     case TYPE_CODE_UNION:
  183.     case TYPE_CODE_VOID:
  184.     case TYPE_CODE_SET:
  185.     case TYPE_CODE_RANGE:
  186.     case TYPE_CODE_STRING:
  187.     case TYPE_CODE_ERROR:
  188.     case TYPE_CODE_MEMBERPTR:
  189.     case TYPE_CODE_METHODPTR:
  190.     case TYPE_CODE_METHOD:
  191.     case TYPE_CODE_COMPLEX:
  192.     default:
  193.       break;
  194.     }

  195.   return value_cast (type, arg);
  196. }

  197. /* Return the return type of a function with its first instruction exactly at
  198.    the PC address.  Return NULL otherwise.  */

  199. static struct type *
  200. find_function_return_type (CORE_ADDR pc)
  201. {
  202.   struct symbol *sym = find_pc_function (pc);

  203.   if (sym != NULL && BLOCK_START (SYMBOL_BLOCK_VALUE (sym)) == pc
  204.       && SYMBOL_TYPE (sym) != NULL)
  205.     return TYPE_TARGET_TYPE (SYMBOL_TYPE (sym));

  206.   return NULL;
  207. }

  208. /* Determine a function's address and its return type from its value.
  209.    Calls error() if the function is not valid for calling.  */

  210. CORE_ADDR
  211. find_function_addr (struct value *function, struct type **retval_type)
  212. {
  213.   struct type *ftype = check_typedef (value_type (function));
  214.   struct gdbarch *gdbarch = get_type_arch (ftype);
  215.   struct type *value_type = NULL;
  216.   /* Initialize it just to avoid a GCC false warning.  */
  217.   CORE_ADDR funaddr = 0;

  218.   /* If it's a member function, just look at the function
  219.      part of it.  */

  220.   /* Determine address to call.  */
  221.   if (TYPE_CODE (ftype) == TYPE_CODE_FUNC
  222.       || TYPE_CODE (ftype) == TYPE_CODE_METHOD)
  223.     funaddr = value_address (function);
  224.   else if (TYPE_CODE (ftype) == TYPE_CODE_PTR)
  225.     {
  226.       funaddr = value_as_address (function);
  227.       ftype = check_typedef (TYPE_TARGET_TYPE (ftype));
  228.       if (TYPE_CODE (ftype) == TYPE_CODE_FUNC
  229.           || TYPE_CODE (ftype) == TYPE_CODE_METHOD)
  230.         funaddr = gdbarch_convert_from_func_ptr_addr (gdbarch, funaddr,
  231.                                                       &current_target);
  232.     }
  233.   if (TYPE_CODE (ftype) == TYPE_CODE_FUNC
  234.       || TYPE_CODE (ftype) == TYPE_CODE_METHOD)
  235.     {
  236.       value_type = TYPE_TARGET_TYPE (ftype);

  237.       if (TYPE_GNU_IFUNC (ftype))
  238.         {
  239.           funaddr = gnu_ifunc_resolve_addr (gdbarch, funaddr);

  240.           /* Skip querying the function symbol if no RETVAL_TYPE has been
  241.              asked for.  */
  242.           if (retval_type)
  243.             value_type = find_function_return_type (funaddr);
  244.         }
  245.     }
  246.   else if (TYPE_CODE (ftype) == TYPE_CODE_INT)
  247.     {
  248.       /* Handle the case of functions lacking debugging info.
  249.          Their values are characters since their addresses are char.  */
  250.       if (TYPE_LENGTH (ftype) == 1)
  251.         funaddr = value_as_address (value_addr (function));
  252.       else
  253.         {
  254.           /* Handle function descriptors lacking debug info.  */
  255.           int found_descriptor = 0;

  256.           funaddr = 0;        /* pacify "gcc -Werror" */
  257.           if (VALUE_LVAL (function) == lval_memory)
  258.             {
  259.               CORE_ADDR nfunaddr;

  260.               funaddr = value_as_address (value_addr (function));
  261.               nfunaddr = funaddr;
  262.               funaddr = gdbarch_convert_from_func_ptr_addr (gdbarch, funaddr,
  263.                                                             &current_target);
  264.               if (funaddr != nfunaddr)
  265.                 found_descriptor = 1;
  266.             }
  267.           if (!found_descriptor)
  268.             /* Handle integer used as address of a function.  */
  269.             funaddr = (CORE_ADDR) value_as_long (function);
  270.         }
  271.     }
  272.   else
  273.     error (_("Invalid data type for function to be called."));

  274.   if (retval_type != NULL)
  275.     *retval_type = value_type;
  276.   return funaddr + gdbarch_deprecated_function_start_offset (gdbarch);
  277. }

  278. /* For CALL_DUMMY_ON_STACK, push a breakpoint sequence that the called
  279.    function returns to.  */

  280. static CORE_ADDR
  281. push_dummy_code (struct gdbarch *gdbarch,
  282.                  CORE_ADDR sp, CORE_ADDR funaddr,
  283.                  struct value **args, int nargs,
  284.                  struct type *value_type,
  285.                  CORE_ADDR *real_pc, CORE_ADDR *bp_addr,
  286.                  struct regcache *regcache)
  287. {
  288.   gdb_assert (gdbarch_push_dummy_code_p (gdbarch));

  289.   return gdbarch_push_dummy_code (gdbarch, sp, funaddr,
  290.                                   args, nargs, value_type, real_pc, bp_addr,
  291.                                   regcache);
  292. }

  293. /* Fetch the name of the function at FUNADDR.
  294.    This is used in printing an error message for call_function_by_hand.
  295.    BUF is used to print FUNADDR in hex if the function name cannot be
  296.    determined.  It must be large enough to hold formatted result of
  297.    RAW_FUNCTION_ADDRESS_FORMAT.  */

  298. static const char *
  299. get_function_name (CORE_ADDR funaddr, char *buf, int buf_size)
  300. {
  301.   {
  302.     struct symbol *symbol = find_pc_function (funaddr);

  303.     if (symbol)
  304.       return SYMBOL_PRINT_NAME (symbol);
  305.   }

  306.   {
  307.     /* Try the minimal symbols.  */
  308.     struct bound_minimal_symbol msymbol = lookup_minimal_symbol_by_pc (funaddr);

  309.     if (msymbol.minsym)
  310.       return MSYMBOL_PRINT_NAME (msymbol.minsym);
  311.   }

  312.   {
  313.     char *tmp = xstrprintf (_(RAW_FUNCTION_ADDRESS_FORMAT),
  314.                             hex_string (funaddr));

  315.     gdb_assert (strlen (tmp) + 1 <= buf_size);
  316.     strcpy (buf, tmp);
  317.     xfree (tmp);
  318.     return buf;
  319.   }
  320. }

  321. /* Subroutine of call_function_by_hand to simplify it.
  322.    Start up the inferior and wait for it to stop.
  323.    Return the exception if there's an error, or an exception with
  324.    reason >= 0 if there's no error.

  325.    This is done inside a TRY_CATCH so the caller needn't worry about
  326.    thrown errors.  The caller should rethrow if there's an error.  */

  327. static struct gdb_exception
  328. run_inferior_call (struct thread_info *call_thread, CORE_ADDR real_pc)
  329. {
  330.   volatile struct gdb_exception e;
  331.   int saved_in_infcall = call_thread->control.in_infcall;
  332.   ptid_t call_thread_ptid = call_thread->ptid;
  333.   int saved_sync_execution = sync_execution;

  334.   /* Infcalls run synchronously, in the foreground.  */
  335.   if (target_can_async_p ())
  336.     sync_execution = 1;

  337.   call_thread->control.in_infcall = 1;

  338.   clear_proceed_status (0);

  339.   disable_watchpoints_before_interactive_call_start ();

  340.   /* We want stop_registers, please...  */
  341.   call_thread->control.proceed_to_finish = 1;

  342.   TRY_CATCH (e, RETURN_MASK_ALL)
  343.     {
  344.       int was_sync = sync_execution;

  345.       proceed (real_pc, GDB_SIGNAL_0, 0);

  346.       /* Inferior function calls are always synchronous, even if the
  347.          target supports asynchronous execution.  Do here what
  348.          `proceed' itself does in sync mode.  */
  349.       if (target_can_async_p ())
  350.         {
  351.           wait_for_inferior ();
  352.           normal_stop ();
  353.           /* If GDB was previously in sync execution mode, then ensure
  354.              that it remains so.  normal_stop calls
  355.              async_enable_stdin, so reset it again here.  In other
  356.              cases, stdin will be re-enabled by
  357.              inferior_event_handler, when an exception is thrown.  */
  358.           if (was_sync)
  359.             async_disable_stdin ();
  360.         }
  361.     }

  362.   /* At this point the current thread may have changed.  Refresh
  363.      CALL_THREAD as it could be invalid if its thread has exited.  */
  364.   call_thread = find_thread_ptid (call_thread_ptid);

  365.   enable_watchpoints_after_interactive_call_stop ();

  366.   /* Call breakpoint_auto_delete on the current contents of the bpstat
  367.      of inferior call thread.
  368.      If all error()s out of proceed ended up calling normal_stop
  369.      (and perhaps they should; it already does in the special case
  370.      of error out of resume()), then we wouldn't need this.  */
  371.   if (e.reason < 0)
  372.     {
  373.       if (call_thread != NULL)
  374.         breakpoint_auto_delete (call_thread->control.stop_bpstat);
  375.     }

  376.   if (call_thread != NULL)
  377.     call_thread->control.in_infcall = saved_in_infcall;

  378.   sync_execution = saved_sync_execution;

  379.   return e;
  380. }

  381. /* A cleanup function that calls delete_std_terminate_breakpoint.  */
  382. static void
  383. cleanup_delete_std_terminate_breakpoint (void *ignore)
  384. {
  385.   delete_std_terminate_breakpoint ();
  386. }

  387. /* See infcall.h.  */

  388. struct value *
  389. call_function_by_hand (struct value *function, int nargs, struct value **args)
  390. {
  391.   return call_function_by_hand_dummy (function, nargs, args, NULL, NULL);
  392. }

  393. /* All this stuff with a dummy frame may seem unnecessarily complicated
  394.    (why not just save registers in GDB?).  The purpose of pushing a dummy
  395.    frame which looks just like a real frame is so that if you call a
  396.    function and then hit a breakpoint (get a signal, etc), "backtrace"
  397.    will look right.  Whether the backtrace needs to actually show the
  398.    stack at the time the inferior function was called is debatable, but
  399.    it certainly needs to not display garbage.  So if you are contemplating
  400.    making dummy frames be different from normal frames, consider that.  */

  401. /* Perform a function call in the inferior.
  402.    ARGS is a vector of values of arguments (NARGS of them).
  403.    FUNCTION is a value, the function to be called.
  404.    Returns a value representing what the function returned.
  405.    May fail to return, if a breakpoint or signal is hit
  406.    during the execution of the function.

  407.    ARGS is modified to contain coerced values.  */

  408. struct value *
  409. call_function_by_hand_dummy (struct value *function,
  410.                              int nargs, struct value **args,
  411.                              call_function_by_hand_dummy_dtor_ftype *dummy_dtor,
  412.                              void *dummy_dtor_data)
  413. {
  414.   CORE_ADDR sp;
  415.   struct type *values_type, *target_values_type;
  416.   unsigned char struct_return = 0, hidden_first_param_p = 0;
  417.   CORE_ADDR struct_addr = 0;
  418.   struct infcall_control_state *inf_status;
  419.   struct cleanup *inf_status_cleanup;
  420.   struct infcall_suspend_state *caller_state;
  421.   CORE_ADDR funaddr;
  422.   CORE_ADDR real_pc;
  423.   struct type *ftype = check_typedef (value_type (function));
  424.   CORE_ADDR bp_addr;
  425.   struct frame_id dummy_id;
  426.   struct cleanup *args_cleanup;
  427.   struct frame_info *frame;
  428.   struct gdbarch *gdbarch;
  429.   struct cleanup *terminate_bp_cleanup;
  430.   ptid_t call_thread_ptid;
  431.   struct gdb_exception e;
  432.   char name_buf[RAW_FUNCTION_ADDRESS_SIZE];
  433.   int stack_temporaries = thread_stack_temporaries_enabled_p (inferior_ptid);

  434.   if (TYPE_CODE (ftype) == TYPE_CODE_PTR)
  435.     ftype = check_typedef (TYPE_TARGET_TYPE (ftype));

  436.   if (!target_has_execution)
  437.     noprocess ();

  438.   if (get_traceframe_number () >= 0)
  439.     error (_("May not call functions while looking at trace frames."));

  440.   if (execution_direction == EXEC_REVERSE)
  441.     error (_("Cannot call functions in reverse mode."));

  442.   frame = get_current_frame ();
  443.   gdbarch = get_frame_arch (frame);

  444.   if (!gdbarch_push_dummy_call_p (gdbarch))
  445.     error (_("This target does not support function calls."));

  446.   /* A cleanup for the inferior status.
  447.      This is only needed while we're preparing the inferior function call.  */
  448.   inf_status = save_infcall_control_state ();
  449.   inf_status_cleanup
  450.     = make_cleanup_restore_infcall_control_state (inf_status);

  451.   /* Save the caller's registers and other state associated with the
  452.      inferior itself so that they can be restored once the
  453.      callee returns.  To allow nested calls the registers are (further
  454.      down) pushed onto a dummy frame stack.  Include a cleanup (which
  455.      is tossed once the regcache has been pushed).  */
  456.   caller_state = save_infcall_suspend_state ();
  457.   make_cleanup_restore_infcall_suspend_state (caller_state);

  458.   /* Ensure that the initial SP is correctly aligned.  */
  459.   {
  460.     CORE_ADDR old_sp = get_frame_sp (frame);

  461.     if (gdbarch_frame_align_p (gdbarch))
  462.       {
  463.         sp = gdbarch_frame_align (gdbarch, old_sp);
  464.         /* NOTE: cagney/2003-08-13: Skip the "red zone".  For some
  465.            ABIs, a function can use memory beyond the inner most stack
  466.            address.  AMD64 called that region the "red zone".  Skip at
  467.            least the "red zone" size before allocating any space on
  468.            the stack.  */
  469.         if (gdbarch_inner_than (gdbarch, 1, 2))
  470.           sp -= gdbarch_frame_red_zone_size (gdbarch);
  471.         else
  472.           sp += gdbarch_frame_red_zone_size (gdbarch);
  473.         /* Still aligned?  */
  474.         gdb_assert (sp == gdbarch_frame_align (gdbarch, sp));
  475.         /* NOTE: cagney/2002-09-18:

  476.            On a RISC architecture, a void parameterless generic dummy
  477.            frame (i.e., no parameters, no result) typically does not
  478.            need to push anything the stack and hence can leave SP and
  479.            FP.  Similarly, a frameless (possibly leaf) function does
  480.            not push anything on the stack and, hence, that too can
  481.            leave FP and SP unchanged.  As a consequence, a sequence of
  482.            void parameterless generic dummy frame calls to frameless
  483.            functions will create a sequence of effectively identical
  484.            frames (SP, FP and TOS and PC the same).  This, not
  485.            suprisingly, results in what appears to be a stack in an
  486.            infinite loop --- when GDB tries to find a generic dummy
  487.            frame on the internal dummy frame stack, it will always
  488.            find the first one.

  489.            To avoid this problem, the code below always grows the
  490.            stack.  That way, two dummy frames can never be identical.
  491.            It does burn a few bytes of stack but that is a small price
  492.            to pay :-).  */
  493.         if (sp == old_sp)
  494.           {
  495.             if (gdbarch_inner_than (gdbarch, 1, 2))
  496.               /* Stack grows down.  */
  497.               sp = gdbarch_frame_align (gdbarch, old_sp - 1);
  498.             else
  499.               /* Stack grows up.  */
  500.               sp = gdbarch_frame_align (gdbarch, old_sp + 1);
  501.           }
  502.         /* SP may have underflown address zero here from OLD_SP.  Memory access
  503.            functions will probably fail in such case but that is a target's
  504.            problem.  */
  505.       }
  506.     else
  507.       /* FIXME: cagney/2002-09-18: Hey, you loose!

  508.          Who knows how badly aligned the SP is!

  509.          If the generic dummy frame ends up empty (because nothing is
  510.          pushed) GDB won't be able to correctly perform back traces.
  511.          If a target is having trouble with backtraces, first thing to
  512.          do is add FRAME_ALIGN() to the architecture vector.  If that
  513.          fails, try dummy_id().

  514.          If the ABI specifies a "Red Zone" (see the doco) the code
  515.          below will quietly trash it.  */
  516.       sp = old_sp;

  517.     /* Skip over the stack temporaries that might have been generated during
  518.        the evaluation of an expression.  */
  519.     if (stack_temporaries)
  520.       {
  521.         struct value *lastval;

  522.         lastval = get_last_thread_stack_temporary (inferior_ptid);
  523.         if (lastval != NULL)
  524.           {
  525.             CORE_ADDR lastval_addr = value_address (lastval);

  526.             if (gdbarch_inner_than (gdbarch, 1, 2))
  527.               {
  528.                 gdb_assert (sp >= lastval_addr);
  529.                 sp = lastval_addr;
  530.               }
  531.             else
  532.               {
  533.                 gdb_assert (sp <= lastval_addr);
  534.                 sp = lastval_addr + TYPE_LENGTH (value_type (lastval));
  535.               }

  536.             if (gdbarch_frame_align_p (gdbarch))
  537.               sp = gdbarch_frame_align (gdbarch, sp);
  538.           }
  539.       }
  540.   }

  541.   funaddr = find_function_addr (function, &values_type);
  542.   if (!values_type)
  543.     values_type = builtin_type (gdbarch)->builtin_int;

  544.   CHECK_TYPEDEF (values_type);

  545.   /* Are we returning a value using a structure return (passing a
  546.      hidden argument pointing to storage) or a normal value return?
  547.      There are two cases: language-mandated structure return and
  548.      target ABI structure return.  The variable STRUCT_RETURN only
  549.      describes the latter.  The language version is handled by passing
  550.      the return location as the first parameter to the function,
  551.      even preceding "this".  This is different from the target
  552.      ABI version, which is target-specific; for instance, on ia64
  553.      the first argument is passed in out0 but the hidden structure
  554.      return pointer would normally be passed in r8.  */

  555.   if (gdbarch_return_in_first_hidden_param_p (gdbarch, values_type))
  556.     {
  557.       hidden_first_param_p = 1;

  558.       /* Tell the target specific argument pushing routine not to
  559.          expect a value.  */
  560.       target_values_type = builtin_type (gdbarch)->builtin_void;
  561.     }
  562.   else
  563.     {
  564.       struct_return = using_struct_return (gdbarch, function, values_type);
  565.       target_values_type = values_type;
  566.     }

  567.   observer_notify_inferior_call_pre (inferior_ptid, funaddr);

  568.   /* Determine the location of the breakpoint (and possibly other
  569.      stuff) that the called function will return to.  The SPARC, for a
  570.      function returning a structure or union, needs to make space for
  571.      not just the breakpoint but also an extra word containing the
  572.      size (?) of the structure being passed.  */

  573.   switch (gdbarch_call_dummy_location (gdbarch))
  574.     {
  575.     case ON_STACK:
  576.       {
  577.         const gdb_byte *bp_bytes;
  578.         CORE_ADDR bp_addr_as_address;
  579.         int bp_size;

  580.         /* Be careful BP_ADDR is in inferior PC encoding while
  581.            BP_ADDR_AS_ADDRESS is a plain memory address.  */

  582.         sp = push_dummy_code (gdbarch, sp, funaddr, args, nargs,
  583.                               target_values_type, &real_pc, &bp_addr,
  584.                               get_current_regcache ());

  585.         /* Write a legitimate instruction at the point where the infcall
  586.            breakpoint is going to be inserted.  While this instruction
  587.            is never going to be executed, a user investigating the
  588.            memory from GDB would see this instruction instead of random
  589.            uninitialized bytes.  We chose the breakpoint instruction
  590.            as it may look as the most logical one to the user and also
  591.            valgrind 3.7.0 needs it for proper vgdb inferior calls.

  592.            If software breakpoints are unsupported for this target we
  593.            leave the user visible memory content uninitialized.  */

  594.         bp_addr_as_address = bp_addr;
  595.         bp_bytes = gdbarch_breakpoint_from_pc (gdbarch, &bp_addr_as_address,
  596.                                                &bp_size);
  597.         if (bp_bytes != NULL)
  598.           write_memory (bp_addr_as_address, bp_bytes, bp_size);
  599.       }
  600.       break;
  601.     case AT_ENTRY_POINT:
  602.       {
  603.         CORE_ADDR dummy_addr;

  604.         real_pc = funaddr;
  605.         dummy_addr = entry_point_address ();

  606.         /* A call dummy always consists of just a single breakpoint, so
  607.            its address is the same as the address of the dummy.

  608.            The actual breakpoint is inserted separatly so there is no need to
  609.            write that out.  */
  610.         bp_addr = dummy_addr;
  611.         break;
  612.       }
  613.     default:
  614.       internal_error (__FILE__, __LINE__, _("bad switch"));
  615.     }

  616.   if (nargs < TYPE_NFIELDS (ftype))
  617.     error (_("Too few arguments in function call."));

  618.   {
  619.     int i;

  620.     for (i = nargs - 1; i >= 0; i--)
  621.       {
  622.         int prototyped;
  623.         struct type *param_type;

  624.         /* FIXME drow/2002-05-31: Should just always mark methods as
  625.            prototyped.  Can we respect TYPE_VARARGS?  Probably not.  */
  626.         if (TYPE_CODE (ftype) == TYPE_CODE_METHOD)
  627.           prototyped = 1;
  628.         else if (i < TYPE_NFIELDS (ftype))
  629.           prototyped = TYPE_PROTOTYPED (ftype);
  630.         else
  631.           prototyped = 0;

  632.         if (i < TYPE_NFIELDS (ftype))
  633.           param_type = TYPE_FIELD_TYPE (ftype, i);
  634.         else
  635.           param_type = NULL;

  636.         args[i] = value_arg_coerce (gdbarch, args[i],
  637.                                     param_type, prototyped, &sp);

  638.         if (param_type != NULL && language_pass_by_reference (param_type))
  639.           args[i] = value_addr (args[i]);
  640.       }
  641.   }

  642.   /* Reserve space for the return structure to be written on the
  643.      stack, if necessary.  Make certain that the value is correctly
  644.      aligned.

  645.      While evaluating expressions, we reserve space on the stack for
  646.      return values of class type even if the language ABI and the target
  647.      ABI do not require that the return value be passed as a hidden first
  648.      argument.  This is because we want to store the return value as an
  649.      on-stack temporary while the expression is being evaluated.  This
  650.      enables us to have chained function calls in expressions.

  651.      Keeping the return values as on-stack temporaries while the expression
  652.      is being evaluated is OK because the thread is stopped until the
  653.      expression is completely evaluated.  */

  654.   if (struct_return || hidden_first_param_p
  655.       || (stack_temporaries && class_or_union_p (values_type)))
  656.     {
  657.       if (gdbarch_inner_than (gdbarch, 1, 2))
  658.         {
  659.           /* Stack grows downward.  Align STRUCT_ADDR and SP after
  660.              making space for the return value.  */
  661.           sp -= TYPE_LENGTH (values_type);
  662.           if (gdbarch_frame_align_p (gdbarch))
  663.             sp = gdbarch_frame_align (gdbarch, sp);
  664.           struct_addr = sp;
  665.         }
  666.       else
  667.         {
  668.           /* Stack grows upward.  Align the frame, allocate space, and
  669.              then again, re-align the frame???  */
  670.           if (gdbarch_frame_align_p (gdbarch))
  671.             sp = gdbarch_frame_align (gdbarch, sp);
  672.           struct_addr = sp;
  673.           sp += TYPE_LENGTH (values_type);
  674.           if (gdbarch_frame_align_p (gdbarch))
  675.             sp = gdbarch_frame_align (gdbarch, sp);
  676.         }
  677.     }

  678.   if (hidden_first_param_p)
  679.     {
  680.       struct value **new_args;

  681.       /* Add the new argument to the front of the argument list.  */
  682.       new_args = xmalloc (sizeof (struct value *) * (nargs + 1));
  683.       new_args[0] = value_from_pointer (lookup_pointer_type (values_type),
  684.                                         struct_addr);
  685.       memcpy (&new_args[1], &args[0], sizeof (struct value *) * nargs);
  686.       args = new_args;
  687.       nargs++;
  688.       args_cleanup = make_cleanup (xfree, args);
  689.     }
  690.   else
  691.     args_cleanup = make_cleanup (null_cleanup, NULL);

  692.   /* Create the dummy stack frame.  Pass in the call dummy address as,
  693.      presumably, the ABI code knows where, in the call dummy, the
  694.      return address should be pointed.  */
  695.   sp = gdbarch_push_dummy_call (gdbarch, function, get_current_regcache (),
  696.                                 bp_addr, nargs, args,
  697.                                 sp, struct_return, struct_addr);

  698.   do_cleanups (args_cleanup);

  699.   /* Set up a frame ID for the dummy frame so we can pass it to
  700.      set_momentary_breakpoint.  We need to give the breakpoint a frame
  701.      ID so that the breakpoint code can correctly re-identify the
  702.      dummy breakpoint.  */
  703.   /* Sanity.  The exact same SP value is returned by PUSH_DUMMY_CALL,
  704.      saved as the dummy-frame TOS, and used by dummy_id to form
  705.      the frame ID's stack address.  */
  706.   dummy_id = frame_id_build (sp, bp_addr);

  707.   /* Create a momentary breakpoint at the return address of the
  708.      inferior.  That way it breaks when it returns.  */

  709.   {
  710.     struct breakpoint *bpt, *longjmp_b;
  711.     struct symtab_and_line sal;

  712.     init_sal (&sal);                /* initialize to zeroes */
  713.     sal.pspace = current_program_space;
  714.     sal.pc = bp_addr;
  715.     sal.section = find_pc_overlay (sal.pc);
  716.     /* Sanity.  The exact same SP value is returned by
  717.        PUSH_DUMMY_CALL, saved as the dummy-frame TOS, and used by
  718.        dummy_id to form the frame ID's stack address.  */
  719.     bpt = set_momentary_breakpoint (gdbarch, sal, dummy_id, bp_call_dummy);

  720.     /* set_momentary_breakpoint invalidates FRAME.  */
  721.     frame = NULL;

  722.     bpt->disposition = disp_del;
  723.     gdb_assert (bpt->related_breakpoint == bpt);

  724.     longjmp_b = set_longjmp_breakpoint_for_call_dummy ();
  725.     if (longjmp_b)
  726.       {
  727.         /* Link BPT into the chain of LONGJMP_B.  */
  728.         bpt->related_breakpoint = longjmp_b;
  729.         while (longjmp_b->related_breakpoint != bpt->related_breakpoint)
  730.           longjmp_b = longjmp_b->related_breakpoint;
  731.         longjmp_b->related_breakpoint = bpt;
  732.       }
  733.   }

  734.   /* Create a breakpoint in std::terminate.
  735.      If a C++ exception is raised in the dummy-frame, and the
  736.      exception handler is (normally, and expected to be) out-of-frame,
  737.      the default C++ handler will (wrongly) be called in an inferior
  738.      function call.  This is wrong, as an exception can be  normally
  739.      and legally handled out-of-frame.  The confines of the dummy frame
  740.      prevent the unwinder from finding the correct handler (or any
  741.      handler, unless it is in-frame).  The default handler calls
  742.      std::terminate.  This will kill the inferior.  Assert that
  743.      terminate should never be called in an inferior function
  744.      call.  Place a momentary breakpoint in the std::terminate function
  745.      and if triggered in the call, rewind.  */
  746.   if (unwind_on_terminating_exception_p)
  747.     set_std_terminate_breakpoint ();

  748.   /* Everything's ready, push all the info needed to restore the
  749.      caller (and identify the dummy-frame) onto the dummy-frame
  750.      stack.  */
  751.   dummy_frame_push (caller_state, &dummy_id, inferior_ptid);
  752.   if (dummy_dtor != NULL)
  753.     register_dummy_frame_dtor (dummy_id, inferior_ptid,
  754.                                dummy_dtor, dummy_dtor_data);

  755.   /* Discard both inf_status and caller_state cleanups.
  756.      From this point on we explicitly restore the associated state
  757.      or discard it.  */
  758.   discard_cleanups (inf_status_cleanup);

  759.   /* Register a clean-up for unwind_on_terminating_exception_breakpoint.  */
  760.   terminate_bp_cleanup = make_cleanup (cleanup_delete_std_terminate_breakpoint,
  761.                                        NULL);

  762.   /* - SNIP - SNIP - SNIP - SNIP - SNIP - SNIP - SNIP - SNIP - SNIP -
  763.      If you're looking to implement asynchronous dummy-frames, then
  764.      just below is the place to chop this function in two..  */

  765.   /* TP is invalid after run_inferior_call returns, so enclose this
  766.      in a block so that it's only in scope during the time it's valid.  */
  767.   {
  768.     struct thread_info *tp = inferior_thread ();

  769.     /* Save this thread's ptid, we need it later but the thread
  770.        may have exited.  */
  771.     call_thread_ptid = tp->ptid;

  772.     /* Run the inferior until it stops.  */

  773.     e = run_inferior_call (tp, real_pc);
  774.   }

  775.   observer_notify_inferior_call_post (call_thread_ptid, funaddr);

  776.   /* Rethrow an error if we got one trying to run the inferior.  */

  777.   if (e.reason < 0)
  778.     {
  779.       const char *name = get_function_name (funaddr,
  780.                                             name_buf, sizeof (name_buf));

  781.       discard_infcall_control_state (inf_status);

  782.       /* We could discard the dummy frame here if the program exited,
  783.          but it will get garbage collected the next time the program is
  784.          run anyway.  */

  785.       switch (e.reason)
  786.         {
  787.         case RETURN_ERROR:
  788.           throw_error (e.error, _("%s\n\
  789. An error occurred while in a function called from GDB.\n\
  790. Evaluation of the expression containing the function\n\
  791. (%s) will be abandoned.\n\
  792. When the function is done executing, GDB will silently stop."),
  793.                        e.message, name);
  794.         case RETURN_QUIT:
  795.         default:
  796.           throw_exception (e);
  797.         }
  798.     }

  799.   /* If the program has exited, or we stopped at a different thread,
  800.      exit and inform the user.  */

  801.   if (! target_has_execution)
  802.     {
  803.       const char *name = get_function_name (funaddr,
  804.                                             name_buf, sizeof (name_buf));

  805.       /* If we try to restore the inferior status,
  806.          we'll crash as the inferior is no longer running.  */
  807.       discard_infcall_control_state (inf_status);

  808.       /* We could discard the dummy frame here given that the program exited,
  809.          but it will get garbage collected the next time the program is
  810.          run anyway.  */

  811.       error (_("The program being debugged exited while in a function "
  812.                "called from GDB.\n"
  813.                "Evaluation of the expression containing the function\n"
  814.                "(%s) will be abandoned."),
  815.              name);
  816.     }

  817.   if (! ptid_equal (call_thread_ptid, inferior_ptid))
  818.     {
  819.       const char *name = get_function_name (funaddr,
  820.                                             name_buf, sizeof (name_buf));

  821.       /* We've switched threads.  This can happen if another thread gets a
  822.          signal or breakpoint while our thread was running.
  823.          There's no point in restoring the inferior status,
  824.          we're in a different thread.  */
  825.       discard_infcall_control_state (inf_status);
  826.       /* Keep the dummy frame record, if the user switches back to the
  827.          thread with the hand-call, we'll need it.  */
  828.       if (stopped_by_random_signal)
  829.         error (_("\
  830. The program received a signal in another thread while\n\
  831. making a function call from GDB.\n\
  832. Evaluation of the expression containing the function\n\
  833. (%s) will be abandoned.\n\
  834. When the function is done executing, GDB will silently stop."),
  835.                name);
  836.       else
  837.         error (_("\
  838. The program stopped in another thread while making a function call from GDB.\n\
  839. Evaluation of the expression containing the function\n\
  840. (%s) will be abandoned.\n\
  841. When the function is done executing, GDB will silently stop."),
  842.                name);
  843.     }

  844.   if (stopped_by_random_signal || stop_stack_dummy != STOP_STACK_DUMMY)
  845.     {
  846.       const char *name = get_function_name (funaddr,
  847.                                             name_buf, sizeof (name_buf));

  848.       if (stopped_by_random_signal)
  849.         {
  850.           /* We stopped inside the FUNCTION because of a random
  851.              signal.  Further execution of the FUNCTION is not
  852.              allowed.  */

  853.           if (unwind_on_signal_p)
  854.             {
  855.               /* The user wants the context restored.  */

  856.               /* We must get back to the frame we were before the
  857.                  dummy call.  */
  858.               dummy_frame_pop (dummy_id, call_thread_ptid);

  859.               /* We also need to restore inferior status to that before the
  860.                  dummy call.  */
  861.               restore_infcall_control_state (inf_status);

  862.               /* FIXME: Insert a bunch of wrap_here; name can be very
  863.                  long if it's a C++ name with arguments and stuff.  */
  864.               error (_("\
  865. The program being debugged was signaled while in a function called from GDB.\n\
  866. GDB has restored the context to what it was before the call.\n\
  867. To change this behavior use \"set unwindonsignal off\".\n\
  868. Evaluation of the expression containing the function\n\
  869. (%s) will be abandoned."),
  870.                      name);
  871.             }
  872.           else
  873.             {
  874.               /* The user wants to stay in the frame where we stopped
  875.                  (default).
  876.                  Discard inferior status, we're not at the same point
  877.                  we started at.  */
  878.               discard_infcall_control_state (inf_status);

  879.               /* FIXME: Insert a bunch of wrap_here; name can be very
  880.                  long if it's a C++ name with arguments and stuff.  */
  881.               error (_("\
  882. The program being debugged was signaled while in a function called from GDB.\n\
  883. GDB remains in the frame where the signal was received.\n\
  884. To change this behavior use \"set unwindonsignal on\".\n\
  885. Evaluation of the expression containing the function\n\
  886. (%s) will be abandoned.\n\
  887. When the function is done executing, GDB will silently stop."),
  888.                      name);
  889.             }
  890.         }

  891.       if (stop_stack_dummy == STOP_STD_TERMINATE)
  892.         {
  893.           /* We must get back to the frame we were before the dummy
  894.              call.  */
  895.           dummy_frame_pop (dummy_id, call_thread_ptid);

  896.           /* We also need to restore inferior status to that before
  897.              the dummy call.  */
  898.           restore_infcall_control_state (inf_status);

  899.           error (_("\
  900. The program being debugged entered a std::terminate call, most likely\n\
  901. caused by an unhandled C++ exception.  GDB blocked this call in order\n\
  902. to prevent the program from being terminated, and has restored the\n\
  903. context to its original state before the call.\n\
  904. To change this behaviour use \"set unwind-on-terminating-exception off\".\n\
  905. Evaluation of the expression containing the function (%s)\n\
  906. will be abandoned."),
  907.                  name);
  908.         }
  909.       else if (stop_stack_dummy == STOP_NONE)
  910.         {

  911.           /* We hit a breakpoint inside the FUNCTION.
  912.              Keep the dummy frame, the user may want to examine its state.
  913.              Discard inferior status, we're not at the same point
  914.              we started at.  */
  915.           discard_infcall_control_state (inf_status);

  916.           /* The following error message used to say "The expression
  917.              which contained the function call has been discarded."
  918.              It is a hard concept to explain in a few words.  Ideally,
  919.              GDB would be able to resume evaluation of the expression
  920.              when the function finally is done executing.  Perhaps
  921.              someday this will be implemented (it would not be easy).  */
  922.           /* FIXME: Insert a bunch of wrap_here; name can be very long if it's
  923.              a C++ name with arguments and stuff.  */
  924.           error (_("\
  925. The program being debugged stopped while in a function called from GDB.\n\
  926. Evaluation of the expression containing the function\n\
  927. (%s) will be abandoned.\n\
  928. When the function is done executing, GDB will silently stop."),
  929.                  name);
  930.         }

  931.       /* The above code errors out, so ...  */
  932.       internal_error (__FILE__, __LINE__, _("... should not be here"));
  933.     }

  934.   do_cleanups (terminate_bp_cleanup);

  935.   /* If we get here the called FUNCTION ran to completion,
  936.      and the dummy frame has already been popped.  */

  937.   {
  938.     struct address_space *aspace = get_regcache_aspace (stop_registers);
  939.     struct regcache *retbuf = regcache_xmalloc (gdbarch, aspace);
  940.     struct cleanup *retbuf_cleanup = make_cleanup_regcache_xfree (retbuf);
  941.     struct value *retval = NULL;

  942.     regcache_cpy_no_passthrough (retbuf, stop_registers);

  943.     /* Inferior call is successful.  Restore the inferior status.
  944.        At this stage, leave the RETBUF alone.  */
  945.     restore_infcall_control_state (inf_status);

  946.     if (TYPE_CODE (values_type) == TYPE_CODE_VOID)
  947.       retval = allocate_value (values_type);
  948.     else if (struct_return || hidden_first_param_p)
  949.       {
  950.         if (stack_temporaries)
  951.           {
  952.             retval = value_from_contents_and_address (values_type, NULL,
  953.                                                       struct_addr);
  954.             push_thread_stack_temporary (inferior_ptid, retval);
  955.           }
  956.         else
  957.           {
  958.             retval = allocate_value (values_type);
  959.             read_value_memory (retval, 0, 1, struct_addr,
  960.                                value_contents_raw (retval),
  961.                                TYPE_LENGTH (values_type));
  962.           }
  963.       }
  964.     else
  965.       {
  966.         retval = allocate_value (values_type);
  967.         gdbarch_return_value (gdbarch, function, values_type,
  968.                               retbuf, value_contents_raw (retval), NULL);
  969.         if (stack_temporaries && class_or_union_p (values_type))
  970.           {
  971.             /* Values of class type returned in registers are copied onto
  972.                the stack and their lval_type set to lval_memory.  This is
  973.                required because further evaluation of the expression
  974.                could potentially invoke methods on the return value
  975.                requiring GDB to evaluate the "this" pointer.  To evaluate
  976.                the this pointer, GDB needs the memory address of the
  977.                value.  */
  978.             value_force_lval (retval, struct_addr);
  979.             push_thread_stack_temporary (inferior_ptid, retval);
  980.           }
  981.       }

  982.     do_cleanups (retbuf_cleanup);

  983.     gdb_assert (retval);
  984.     return retval;
  985.   }
  986. }


  987. /* Provide a prototype to silence -Wmissing-prototypes.  */
  988. void _initialize_infcall (void);

  989. void
  990. _initialize_infcall (void)
  991. {
  992.   add_setshow_boolean_cmd ("coerce-float-to-double", class_obscure,
  993.                            &coerce_float_to_double_p, _("\
  994. Set coercion of floats to doubles when calling functions."), _("\
  995. Show coercion of floats to doubles when calling functions"), _("\
  996. Variables of type float should generally be converted to doubles before\n\
  997. calling an unprototyped function, and left alone when calling a prototyped\n\
  998. function.  However, some older debug info formats do not provide enough\n\
  999. information to determine that a function is prototyped.  If this flag is\n\
  1000. set, GDB will perform the conversion for a function it considers\n\
  1001. unprototyped.\n\
  1002. The default is to perform the conversion.\n"),
  1003.                            NULL,
  1004.                            show_coerce_float_to_double_p,
  1005.                            &setlist, &showlist);

  1006.   add_setshow_boolean_cmd ("unwindonsignal", no_class,
  1007.                            &unwind_on_signal_p, _("\
  1008. Set unwinding of stack if a signal is received while in a call dummy."), _("\
  1009. Show unwinding of stack if a signal is received while in a call dummy."), _("\
  1010. The unwindonsignal lets the user determine what gdb should do if a signal\n\
  1011. is received while in a function called from gdb (call dummy).  If set, gdb\n\
  1012. unwinds the stack and restore the context to what as it was before the call.\n\
  1013. The default is to stop in the frame where the signal was received."),
  1014.                            NULL,
  1015.                            show_unwind_on_signal_p,
  1016.                            &setlist, &showlist);

  1017.   add_setshow_boolean_cmd ("unwind-on-terminating-exception", no_class,
  1018.                            &unwind_on_terminating_exception_p, _("\
  1019. Set unwinding of stack if std::terminate is called while in call dummy."), _("\
  1020. Show unwinding of stack if std::terminate() is called while in a call dummy."),
  1021.                            _("\
  1022. The unwind on terminating exception flag lets the user determine\n\
  1023. what gdb should do if a std::terminate() call is made from the\n\
  1024. default exception handler.  If set, gdb unwinds the stack and restores\n\
  1025. the context to what it was before the call.  If unset, gdb allows the\n\
  1026. std::terminate call to proceed.\n\
  1027. The default is to unwind the frame."),
  1028.                            NULL,
  1029.                            show_unwind_on_terminating_exception_p,
  1030.                            &setlist, &showlist);

  1031. }