This is the mail archive of the gdb@sources.redhat.com 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: Strange code in dwarf2cfi.c:cfi_pop_frame()


Mark Kettenis wrote:
The following bit of code surprises me a bit:

/* Restore the machine to the state it had before the current frame
   was created.  */
void
cfi_pop_frame (struct frame_info *fi)
{
  char regbuf[MAX_REGISTER_RAW_SIZE];
  int regnum;

  fi = get_current_frame ();

  ...

}

Why does it override FI with the current frame?
Because it is expected, that fi will contain a valid frame info when this function returns. But you're right, that line doesn't need to be there, because cfi_pop_frame() is called from:
[blockframe.c]
void
generic_pop_current_frame (void (*popper) (struct frame_info * frame))
{
struct frame_info *frame = get_current_frame ();

if (PC_IN_CALL_DUMMY (frame->pc, frame->frame, frame->frame))
generic_pop_dummy_frame ();
else
(*popper) (frame); // <==== here
}

and so get_current_frame() is called twice. First from generic_pop_current_frame() and then immediately from cfi_pop_frame(). I'll test if it's safe to remove the second call and eventually send a patch.

Michal Ludvig
--
* SuSE CR, s.r.o * mludvig@suse.cz
* +420 2 9654 5373 * http://www.suse.cz



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