Re: KGDB stack traces in the kernel.

From: Julian Elischer <julian_at_freebsd.org>
Date: Wed, 06 Apr 2011 10:17:00 -0700
On 4/6/11 5:45 AM, John Baldwin wrote:
> On Tuesday, April 05, 2011 4:35:44 pm Navdeep Parhar wrote:
>> On Tue, Apr 5, 2011 at 1:33 PM, Julian Elischer<julian_at_freebsd.org>  wrote:
>>> On 4/4/11 6:04 PM, Justin Hibbits wrote:
>>>
>> What does ddb do?  It always seems to get this stuff correct.
> ddb knows to stop when it gets to a non-kernel address, and it uses string
> compares on function names to identify trap frames.  For example in
> sys/amd64/amd64/db_trace.c:
>
>
>                  if (strcmp(name, "calltrap") == 0 ||
>                      strcmp(name, "fork_trampoline") == 0 ||
>                      strcmp(name, "nmi_calltrap") == 0 ||
>                      strcmp(name, "Xdblfault") == 0)
>                          frame_type = TRAP;
>
> Hah, kgdb just needs to be updated (this is from trgt_amd64.c):
>
> const struct frame_unwind *
> kgdb_trgt_trapframe_sniffer(struct frame_info *next_frame)
> {
>          char *pname;
>          CORE_ADDR pc;
>
>          pc = frame_pc_unwind(next_frame);
>          pname = NULL;
>          find_pc_partial_function(pc,&pname, NULL, NULL);
>          if (pname == NULL)
>                  return (NULL);
>          if (strcmp(pname, "calltrap") == 0 ||
>              strcmp(pname, "nmi_calltrap") == 0 ||
>              (pname[0] == 'X'&&  pname[1] != '_'))
>                  return (&kgdb_trgt_trapframe_unwind);
>          /* printf("%s: %lx =%s\n", __func__, pc, pname); */
>          return (NULL);
> }
>

I'll give that a try

> Can probably just add 'fork_trampoline' to that conditional.  I think i386
> needs a similar fix in kgdb.  Not sure about other architectures:
>
> Index: trgt_amd64.c
> ===================================================================
> --- trgt_amd64.c	(revision 220190)
> +++ trgt_amd64.c	(working copy)
> _at__at_ -184,6 +184,7 _at__at_
>   	if (pname == NULL)
>   		return (NULL);
>   	if (strcmp(pname, "calltrap") == 0 ||
> +	    strcmp(pname, "fork_trampoline") == 0 ||
>   	    strcmp(pname, "nmi_calltrap") == 0 ||
>   	    (pname[0] == 'X'&&  pname[1] != '_'))
>   		return (&kgdb_trgt_trapframe_unwind);
> Index: trgt_i386.c
> ===================================================================
> --- trgt_i386.c	(revision 220190)
> +++ trgt_i386.c	(working copy)
> _at__at_ -374,6 +374,7 _at__at_
>   	if (strcmp(pname, "dblfault_handler") == 0)
>   		return (&kgdb_trgt_dblfault_unwind);
>   	if (strcmp(pname, "calltrap") == 0 ||
> +	    strcmp(pname, "fork_trampoline") == 0 ||
>   	    (pname[0] == 'X'&&  pname[1] != '_'))
>   		return (&kgdb_trgt_trapframe_unwind);
>   	/* printf("%s: %llx =%s\n", __func__, pc, pname); */
>
Received on Wed Apr 06 2011 - 15:16:32 UTC

This archive was generated by hypermail 2.4.0 : Wed May 19 2021 - 11:40:13 UTC