2009-11-12 H.J. Lu <hongjiu.lu@intel.com>
[deliverable/binutils-gdb.git] / gdb / infcall.c
index e364f01da6864220a1fa6c2b4271a1d266e161fc..03b1dbf9bbffa4f4ae907fbb423551d97835b21b 100644 (file)
@@ -231,6 +231,7 @@ CORE_ADDR
 find_function_addr (struct value *function, struct type **retval_type)
 {
   struct type *ftype = check_typedef (value_type (function));
+  struct gdbarch *gdbarch = get_type_arch (ftype);
   enum type_code code = TYPE_CODE (ftype);
   struct type *value_type = NULL;
   CORE_ADDR funaddr;
@@ -251,8 +252,7 @@ find_function_addr (struct value *function, struct type **retval_type)
       if (TYPE_CODE (ftype) == TYPE_CODE_FUNC
          || TYPE_CODE (ftype) == TYPE_CODE_METHOD)
        {
-         funaddr = gdbarch_convert_from_func_ptr_addr (current_gdbarch,
-                                                       funaddr,
+         funaddr = gdbarch_convert_from_func_ptr_addr (gdbarch, funaddr,
                                                        &current_target);
          value_type = TYPE_TARGET_TYPE (ftype);
        }
@@ -273,8 +273,7 @@ find_function_addr (struct value *function, struct type **retval_type)
              CORE_ADDR nfunaddr;
              funaddr = value_as_address (value_addr (function));
              nfunaddr = funaddr;
-             funaddr = gdbarch_convert_from_func_ptr_addr (current_gdbarch,
-                                                           funaddr,
+             funaddr = gdbarch_convert_from_func_ptr_addr (gdbarch, funaddr,
                                                            &current_target);
              if (funaddr != nfunaddr)
                found_descriptor = 1;
@@ -289,7 +288,7 @@ find_function_addr (struct value *function, struct type **retval_type)
 
   if (retval_type != NULL)
     *retval_type = value_type;
-  return funaddr + gdbarch_deprecated_function_start_offset (current_gdbarch);
+  return funaddr + gdbarch_deprecated_function_start_offset (gdbarch);
 }
 
 /* For CALL_DUMMY_ON_STACK, push a breakpoint sequence that the called
@@ -442,6 +441,7 @@ call_function_by_hand (struct value *function, int nargs, struct value **args)
   struct gdbarch *gdbarch;
   struct breakpoint *terminate_bp = NULL;
   struct minimal_symbol *tm;
+  struct cleanup *terminate_bp_cleanup = NULL;
   ptid_t call_thread_ptid;
   struct gdb_exception e;
   const char *name;
@@ -562,7 +562,7 @@ call_function_by_hand (struct value *function, int nargs, struct value **args)
 
       /* Tell the target specific argument pushing routine not to
         expect a value.  */
-      target_values_type = builtin_type_void;
+      target_values_type = builtin_type (gdbarch)->builtin_void;
     }
   else
     {
@@ -593,11 +593,6 @@ call_function_by_hand (struct value *function, int nargs, struct value **args)
 
        real_pc = funaddr;
        dummy_addr = entry_point_address ();
-       /* Make certain that the address points at real code, and not a
-          function descriptor.  */
-       dummy_addr = gdbarch_convert_from_func_ptr_addr (gdbarch,
-                                                        dummy_addr,
-                                                        &current_target);
        /* A call dummy always consists of just a single breakpoint, so
           its address is the same as the address of the dummy.  */
        bp_addr = dummy_addr;
@@ -615,14 +610,16 @@ call_function_by_hand (struct value *function, int nargs, struct value **args)
        sym = lookup_minimal_symbol ("__CALL_DUMMY_ADDRESS", NULL, NULL);
        real_pc = funaddr;
        if (sym)
-         dummy_addr = SYMBOL_VALUE_ADDRESS (sym);
+         {
+           dummy_addr = SYMBOL_VALUE_ADDRESS (sym);
+           /* Make certain that the address points at real code, and not
+              a function descriptor.  */
+           dummy_addr = gdbarch_convert_from_func_ptr_addr (gdbarch,
+                                                            dummy_addr,
+                                                            &current_target);
+         }
        else
          dummy_addr = entry_point_address ();
-       /* Make certain that the address points at real code, and not
-          a function descriptor.  */
-       dummy_addr = gdbarch_convert_from_func_ptr_addr (gdbarch,
-                                                        dummy_addr,
-                                                        &current_target);
        /* A call dummy always consists of just a single breakpoint,
           so it's address is the same as the address of the dummy.  */
        bp_addr = dummy_addr;
@@ -734,12 +731,13 @@ call_function_by_hand (struct value *function, int nargs, struct value **args)
     struct breakpoint *bpt;
     struct symtab_and_line sal;
     init_sal (&sal);           /* initialize to zeroes */
+    sal.pspace = current_program_space;
     sal.pc = bp_addr;
     sal.section = find_pc_overlay (sal.pc);
     /* Sanity.  The exact same SP value is returned by
        PUSH_DUMMY_CALL, saved as the dummy-frame TOS, and used by
        dummy_id to form the frame ID's stack address.  */
-    bpt = set_momentary_breakpoint (sal, dummy_id, bp_call_dummy);
+    bpt = set_momentary_breakpoint (gdbarch, sal, dummy_id, bp_call_dummy);
     bpt->disposition = disp_del;
   }
 
@@ -761,7 +759,7 @@ call_function_by_hand (struct value *function, int nargs, struct value **args)
                                                           NULL, NULL);
        if (tm != NULL)
           terminate_bp = set_momentary_breakpoint_at_pc
-            (SYMBOL_VALUE_ADDRESS (tm),  bp_breakpoint);
+            (gdbarch, SYMBOL_VALUE_ADDRESS (tm),  bp_breakpoint);
      }
 
   /* Everything's ready, push all the info needed to restore the
@@ -776,7 +774,7 @@ call_function_by_hand (struct value *function, int nargs, struct value **args)
 
   /* Register a clean-up for unwind_on_terminating_exception_breakpoint.  */
   if (terminate_bp)
-    make_cleanup_delete_breakpoint (terminate_bp);
+    terminate_bp_cleanup = make_cleanup_delete_breakpoint (terminate_bp);
 
   /* - SNIP - SNIP - SNIP - SNIP - SNIP - SNIP - SNIP - SNIP - SNIP -
      If you're looking to implement asynchronous dummy-frames, then
@@ -943,7 +941,7 @@ When the function is done executing, GDB will silently stop."),
                 user.  */
 
              if (terminate_bp != NULL
-                 && (inferior_thread()->stop_bpstat->breakpoint_at->address
+                 && (inferior_thread ()->stop_bpstat->breakpoint_at->address
                      == terminate_bp->loc->address))
                {
                  /* We must get back to the frame we were before the
@@ -991,6 +989,11 @@ When the function is done executing, GDB will silently stop."),
       internal_error (__FILE__, __LINE__, _("... should not be here"));
     }
 
+  /* If we get here and the std::terminate() breakpoint has been set,
+     it has to be cleaned manually.  */
+  if (terminate_bp)
+    do_cleanups (terminate_bp_cleanup);
+
   /* If we get here the called FUNCTION ran to completion,
      and the dummy frame has already been popped.  */
 
This page took 0.025582 seconds and 4 git commands to generate.