[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Understanding gdb way down inside.

From: Jim Blandy
Subject: Re: Understanding gdb way down inside.
Date: 19 Jun 2002 14:27:43 -0500
User-agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.1

george anzinger <address@hidden> writes:
> I am working on a kgdb patch for linux x86 kernels.  It
> correctly treats kernel tasks as threads and allows one to
> look at each task in the kernel.
> The problem I am having is understanding how gdb does the
> "up" command.  I assumed that it would use the EBP register
> to find the previous EBP (*EBP) and PC (*(EBP+4)) as well as
> the previous ESP (EBP+8).  It seems to do this "some" of the
> time.  In the failing case it seems to be finding PC by
> using *ESP, which would seem to imply that gdb thinks there
> is no stack frame AND that ESP is as it was when the
> function was entered.  I see several accesses to *PC and
> wonder if someone could tell me what is going on here, or at
> least what bit of code in gdb to study to figure it out.

This is very involved.  Stack unwinding is one of the more complex
parts of GDB.  Although it's generally easy to find the saved PC, GDB
also wants to find all the saved registers in the frame, so it can
print register-allocated variables in frames other than the youngest.

You'll want to look at `struct frame_info', the function
`get_prev_frame', and the frame-related stuff in i386-tdep.c.

There is stuff for handling signal handler invocation frames, but I
doubt there is anything for handling raw IA-32 interrupt frames.
Doesn't the IA-32 switch stacks anyway when it services an interrupt?
(I am very ignorant of how the kernel works.)

reply via email to

[Prev in Thread] Current Thread [Next in Thread]