Re: kgdb missing stack frames

From: Ian Dowse <iedowse_at_maths.tcd.ie>
Date: Mon, 19 May 2003 19:25:03 +0100
In message <20030520001750.T23718_at_gamplex.bde.org>, Bruce Evans writes:
>Neither do I, but I know that it more or less works in ddb using the
>magic names "Xintr*" and "calltrap" to decide when to do special frame
>handling.  At least on i386's ddb's special frame handling for interrupts
>starts working when Xintr* calls the interrupt handler and the interrupt
>handler sets up its frame.  ddb doesn't have the detailed knowledge of
>the stack state at every instruction in Xintr* that it would need to do
>better.  gdb knows about the magic names too, but apparently doesn't
>do as much with them as ddb (kvm-fbsd.c seems to only understand tf_eip
>in trap frames, while db_nextframe() understands tf_ebp and tf_esp too.
>I may have broken this in kvm-fbsd.c rev.1.9.  Rev.1.8 seems to be the
>last version that references tf_ebp.  Rev.1.8 uses code much like the
>current code that finds tf_eip to find tf_ebp instead.

Yes, as far as I can tell, the only significant difference between
ddb and gdb (with the patch) is that db_nextframe() in ddb prints
out extra information from the trap frame as it skips over it.
Maybe doing something similar in gdb would output the information
in the correct place in the backtrace.

I think tf_ebp is always the same as the regular frame pointer saved
at the start of the function called by the trap handler, since
Xintr*, calltrap etc. do not change ebp. This means that gdb doesn't
need to know about how to read tf_ebp to find the next frame. The
patch fixes breakage that caused all special handling of trap frames
to be disabled.

FYI, below is my understanding of the stack layout in the example
I included (addresses of values in [] increase from left to right
and then bottom to top, so the stack trace starts from the bottom
and works up).

Ian


  #5	         ,-> fork_exit+xx
	,->[ebp eip]
	|
	|___
  #4	    \    ,-> idle_proc+xx
	,->[ebp eip]
	|\_____________________________
	|___                           |
  #3	    \    ,-> Xintr14+xx        |           ,-> cpu_idle+xx
	,->[ebp eip][   ...    ][... tf_ebp ... tf_eip ...]
	|
	|___
  #2	    \    ,-> sched_ithd+xx
	,->[ebp eip]
	|
	|___
  #1	    \    ,-> ithread_schedule+xx
	,->[ebp eip]
	|
	|___
  #0	    \    ,-> mi_switch+xx
	,->[ebp eip]
	|
	|
Received on Mon May 19 2003 - 09:25:07 UTC

This archive was generated by hypermail 2.4.0 : Wed May 19 2021 - 11:37:08 UTC