This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [RFA] Darwin: recognize signal frames


[Mark, I'd like to make i386_sigtramp_p non-static and use it here.
Let me know if you think it's a bad idea... Thanks!]

> 2008-12-05  Tristan Gingold  <gingold@adacore.com>
> 
> 	* i386-darwin-tdep.c (darwin_sigtramp_p): New function.
> 	(i386_darwin_sigcontext_addr): Ditto.
> 	(amd64_darwin_sigcontext_addr): Ditto.
> 	(darwin_dwarf_signal_frame_p): Ditto.
> 	(i386_darwin_init_abi): Handle signal frames, use the const for
> 	sc_num_regs.
> 	(x86_darwin_init_abi_64): Ditto.

After careful review and much discussion with Tristan, this is mostly OK.

The problem, as explained in the comments is that the DWARF sniffer
for NORMAL_FRAMEs finds a FDE, but then fails to determine that the code
corresponds to a signal frame:

  if (fde->cie->signal_frame
      || dwarf2_frame_signal_frame_p (get_frame_arch (this_frame),
                                      this_frame))

Since fde->cie->signal_frame is not set, we need to configure the dwarf
ops such that dwarf2_frame_signal_frame_p returns non-zero. That's what
darwin_dwarf_signal_frame_p does.

Next, the other problem comes from the fact that the DWARF sniffer
for SIGTRAMP_FRAMEs does not find a FDE. That's because:
  1. The PC returned by get_frame_address_in_block is no longer adjusted
     and thus equal to the return address.
  2. The FDE for the signal frame only covers the one instruction doing
     the indirect call. There is no FDE at the return address, and thus
     the sniffer rejects the frame.

This is why we need unwind this frame by hand, which is what the rest
of the code is about.

> + static int
> + darwin_sigtramp_p (struct frame_info *this_frame)

This function is identical to i386-tdep.c:i386_sigtramp_p. I suggest
we make i386_sigtramp_p non-static, add a declaration in i386-tdep.h,
and then use that instead of having a second version here.

Initially, I thought that we didn't need to do anything, since
i386-tdep.c already sets tdep->sigtramp_p, but this doesn't appear
to be the case in the x86_64 case. So we need to set tdep->sigtramp_p
ourselves at least in the amd64 case.

> +    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.  With this function, the frame is not recognized (because
> +    the pc is not adjusted and points to the next instruction).  As a
> +    consequence we have to use the x86 sigtramp frame unwinders.  */

I think that it is sufficient in this comment to just say that this
is used to make sure that the NORMAL_FRAME DWARF sniffer does not
accept signal frames.  I think that the first part of your comment
explains this part well.  The Part after "which is not expected" deals
with the rest of the code, and is confusing at this location. I would
just remove it.

Pre-approved with the changes above.

-- 
Joel


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]