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: question on gdbarch_skip_prologue()


>>>>> On Thu, 7 Mar 2002 01:11:17 -0700, Kevin Buettner <kevinb@redhat.com> said:

  Kevin> GDB currently expects that the skip_prologue() function will
  Kevin> return a PC that's after the last prologue instruction that
  Kevin> saved an argument to its "home" location (if any) in memory
  Kevin> (or whereever the debug info says that a parameter's location
  Kevin> is).  The difficulty with this, of course, is that with
  Kevin> optimized code, it can be very difficult to discern where
  Kevin> this is.

So, if I may paraphrase, skip_prologue() returns the PC of the first
instruction for which the debug info will be valid, right?

If so, I'd argue this has much more to do with debug info than with
unwind info.  For example, hand-written assembly routines often have
sizable prologues, but a programmer would almost certainly want a
breakpoint to be placed right at the beginning of the function, not at
the end of the prologue.

Now, I wonder whether it wouldn't be possible and indeed better to
implement skip_prologue() based on debug info.  Unfortunately, I'm not
very familiar with, say, DWARF2.  However, I did notice that applying
the "info line" command to the first line of source code in a C
program does indeed return a starting address that corresponds to the
value that ought to be returned by skip_prologue().

Perhaps skip_prologue() could look for the first PC that is covered by
line info and return that value (or the original PC if there is no
such PC)?  To be on the safe side, skip_prologue() probably ought to
give up the search as soon as it sees a branch instruction.

Would this be a safe algorithm?

	--david


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