Re: gdb cannot cross doreti_ast ?

From: Andriy Gapon <avg_at_freebsd.org>
Date: Tue, 02 Nov 2021 15:38:40 UTC
On 01/11/2021 11:39, Konstantin Belousov wrote:
> On Mon, Nov 01, 2021 at 10:51:11AM +0200, Andriy Gapon wrote:
>>
>> I have a crash dump and kgdb (from gdb 10.2) cannot cross doreti_ast() when
>> examining a stack trace:
>>
>> #0  sched_switch (td=0xfffff801291507c0, newtd=0xfffff80061bc97c0,
>> flags=<optimized out>) at /usr/src/sys/kern/sched_ule.c:2146
>> #1  0xffffffff80748494 in mi_switch (flags=266, newtd=0x0) at
>> /usr/src/sys/kern/kern_synch.c:452
>> #2  0xffffffff80751154 in thread_suspend_switch (td=0xfffff801291507c0,
>> p=<optimized out>) at /usr/src/sys/kern/kern_thread.c:1118
>> #3  0xffffffff80750f74 in thread_single (p=0xfffff8011df70000,
>> mode=<optimized out>) at /usr/src/sys/kern/kern_thread.c:862
>> #4  0xffffffff80702b86 in exit1 (td=0xfffff801291507c0, rval=0, signo=15) at
>> /usr/src/sys/kern/kern_exit.c:240
>> #5  0xffffffff80740f3a in sigexit (td=0xfffff801291507c0, sig=15) at
>> /usr/src/sys/kern/kern_sig.c:3194
>> #6  0xffffffff8074230f in postsig (sig=15) at /usr/src/sys/kern/kern_sig.c:3079
>> #7  0xffffffff80794b43 in ast (framep=0xfffffe0105a76c00) at
>> /usr/src/sys/kern/subr_trap.c:331
>> #8  0xffffffff809b5449 in doreti_ast () at /usr/src/sys/amd64/amd64/exception.S:1150
>> #9  0x00000008020c7400 in ?? ()
>> #10 0x0000000000000011 in ?? ()
>> #11 0x0000000000000000 in ?? ()
>>
>> It's only a minor annoyance, but I would like to get it fixed.
>> Maybe some markers need to be added to doreti_ast?
>> Or some smarts need to be added to gdb to recognize doreti_ast?
> 
> What do you want to see above doreti_ast?  Basically there is no kernel
> frames, except the struct trapframe at the very top.  doreti_ast is the
> last point with interrupts enabled (again) before return to usermode.
> 
> The only wrong thing in this trace is that gdb did not stopped the
> unwinding.  It might be that we could add some dwarf annotation to
> indicate the 'no frame' place.

Oh, oops.  I think I got confused by a post-processed output from ddb and 
expected to see something that couldn't be there.  It looks that ddb also does 
not know that doreti_ast is a "terminal" function.  So, the post processing I 
have here joined stacks from the thread that I showed and a next thread in the 
process but I did not notice that.


-- 
Andriy Gapon