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: RFC: implement DW_OP_call_frame_cfa


>>>>> "Daniel" == Daniel Jacobowitz <drow@false.org> writes:

Tom> A prerequisite to this is that GDB understand this.  So, this patch
Tom> implements this feature.  This is PR 10224.

Tom> I'm interested in feedback on this.  I am not sure whether the
Tom> implementation of dwarf2_frame_cfa is ok.

Daniel> It isn't, sorry.  It will crash with bad debug info (e.g. manually
Daniel> stripped .debug_frame), because it runs the unwinder without passing
Daniel> through the sniffer.  It also allocates an entire unwinding cache for
Daniel> every local variable using this operation, which is very wasteful.

Daniel> I think, as much as we've tried to avoid it, you're going to need a
Daniel> back channel to find the existing cache iff the frame has a particular
Daniel> unwinder type.

I looked into this a little today.

My understanding is that we can only really implement
DW_OP_call_frame_cfa for the case where a frame is found by the
dwarf frame-sniffing code.

So, I ended up just adding a simple checking function:

int
frame_base_is (struct frame_info *fi, struct frame_base *base)
{
  if (fi->base == NULL)
    fi->base = frame_base_find_by_frame (fi);
  return fi->base == base;
}


Then the code to implement DW_OP_call_frame_cfa checks this before
fetching the frame base.

CORE_ADDR
dwarf2_frame_cfa (struct frame_info *this_frame)
{
  if (! frame_base_is (this_frame, &dwarf2_frame_base))
    error (_("can't compute CFA for this frame"));
  return get_frame_base_address (this_frame);
}


This fixes the cache problem as a side effect.

Is this the sort of thing you were thinking of?
I've dug through the frame code a bit, but I'm still by no means an
expert.  I'd appreciate any advice you might have.

Tom


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