+ /* A pointer to the ucontext is passed as the fourth argument
+ to the signal handler. */
+ read_memory (bp + 24, buf, 4);
+ si = extract_unsigned_integer (buf, 4, byte_order);
+
+ /* The pointer to mcontext is at offset 28. */
+ read_memory (si + 28, buf, 4);
+
+ /* First register (eax) is at offset 12. */
+ return extract_unsigned_integer (buf, 4, byte_order) + 12;
+}
+
+/* Return true if the PC of THIS_FRAME is in a signal trampoline which
+ may have DWARF-2 CFI.
+
+ On Darwin, signal trampolines have DWARF-2 CFI but it has only one FDE
+ that covers only the indirect call to the user handler.
+ Without this function, the frame is recognized as a normal frame which is
+ not expected. */
+
+int
+darwin_dwarf_signal_frame_p (struct gdbarch *gdbarch,
+ struct frame_info *this_frame)
+{
+ return i386_sigtramp_p (this_frame);
+}
+
+/* Check whether TYPE is a 128-bit vector (__m128, __m128d or __m128i). */
+
+static int
+i386_m128_p (struct type *type)
+{
+ return (type->code () == TYPE_CODE_ARRAY && TYPE_VECTOR (type)
+ && TYPE_LENGTH (type) == 16);
+}
+
+/* Return the alignment for TYPE when passed as an argument. */
+
+static int
+i386_darwin_arg_type_alignment (struct type *type)
+{
+ type = check_typedef (type);
+ /* According to Mac OS X ABI document (passing arguments):
+ 6. The caller places 64-bit vectors (__m64) on the parameter area,
+ aligned to 8-byte boundaries.
+ 7. [...] The caller aligns 128-bit vectors in the parameter area to
+ 16-byte boundaries. */
+ if (type->code () == TYPE_CODE_ARRAY && TYPE_VECTOR (type))
+ return TYPE_LENGTH (type);
+ /* 4. The caller places all the fields of structures (or unions) with no
+ vector elements in the parameter area. These structures are 4-byte
+ aligned.
+ 5. The caller places structures with vector elements on the stack,
+ 16-byte aligned. */
+ if (type->code () == TYPE_CODE_STRUCT
+ || type->code () == TYPE_CODE_UNION)
+ {
+ int i;
+ int res = 4;
+ for (i = 0; i < TYPE_NFIELDS (type); i++)
+ {
+ int align
+ = i386_darwin_arg_type_alignment (TYPE_FIELD_TYPE (type, i));
+
+ res = std::max (res, align);
+ }
+ return res;
+ }
+ /* 2. The caller aligns nonvector arguments to 4-byte boundaries. */
+ return 4;
+}
+
+static CORE_ADDR
+i386_darwin_push_dummy_call (struct gdbarch *gdbarch, struct value *function,
+ struct regcache *regcache, CORE_ADDR bp_addr,
+ int nargs, struct value **args, CORE_ADDR sp,
+ function_call_return_method return_method,
+ CORE_ADDR struct_addr)