public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: "Jeff V. Merkey" <jmerkey@wolfmountaingroup.com>
To: "Jeff V. Merkey" <jmerkey@wolfmountaingroup.com>
Cc: Andi Kleen <ak@suse.de>, jmerkey <jmerkey@utah-nac.org>,
	"Randy.Dunlap" <rdunlap@xenotime.net>,
	Jan Beulich <JBeulich@novell.com>,
	linux-kernel@vger.kernel.org, akpm@osdl.org
Subject: Re: [PATCH 0/39] NLKD - Novell Linux Kernel Debugger
Date: Sat, 12 Nov 2005 20:32:17 -0700	[thread overview]
Message-ID: <4376B3C1.6000409@wolfmountaingroup.com> (raw)
In-Reply-To: <4376B278.2060407@wolfmountaingroup.com>

Jeff V. Merkey wrote:

> Andi Kleen wrote:
>
>> On Sunday 13 November 2005 03:53, jmerkey wrote:
>>
>>  
>>
>>> Yes. This is the way to go. Use kdb as a base and instrument an 
>>> alternate debugger interface. You need to also find a good way to
>>> allow GDB to work properly with alternate debuggers. At present, the 
>>> code in traps.c is mutually exclusive since embedded int3
>>> breakpoints trigger in the kernel for gbd. This is busted.
>>>   
>>
>>
>>
>> I don't think we'll support stacking multiple kernel debuggers (except
>> for special cases like kprobes+another debugger). It's complicated
>> and probably not worth it.
>>
>> -Andi
>>
>>
>>  
>>
> I already instrumented an alternate debugger interface in MDB.  It's 
> not complicated at all.    Here's the code.  All you
> need to do is change two places.  Add the alternate interface into 
> kdb, and fix the int3 contention problem with GDB.  GDB
> support with kdb action involves creating a callback into GDB 
> signaling the int3 POST kdb handling.  In other words, keep
> a table of breakpoints for int3 alternate debuggers they must 
> register, compare against this table and divert the int3 on this basis,
> it is matches the table, send to the registered debugger entry point, 
> if it doesn't match, call the GDB handler and send it to
> userspace.  Seems simple.  Here's part one.  Someone else can write 
> part 2.
>
> Jeff
> diff -Naur ./kdb/kdbmain.c ../linux-2.6.9-mdb/./kdb/kdbmain.c
> --- ./kdb/kdbmain.c    2004-10-18 11:46:59.439535288 -0600
> +++ ../linux-2.6.9-mdb/./kdb/kdbmain.c    2004-10-18 
> 11:44:47.000000000 -0600
> @@ -57,7 +57,12 @@
> int kdb_seqno = 2;                /* how many times kdb has been 
> entered */
>
> volatile int kdb_nextline = 1;
> +
> +#if defined(CONFIG_MDB)
> +volatile int kdb_new_cpu;        /* Which cpu to switch to */
> +#else
> static volatile int kdb_new_cpu;        /* Which cpu to switch to */
> +#endif
>
> volatile int kdb_state[NR_CPUS];        /* Per cpu state */
>
> @@ -1134,8 +1139,13 @@
>
> extern char kdb_prompt_str[];
>
> +#if defined(CONFIG_MDB)
> static int
> kdb_local(kdb_reason_t reason, int error, struct pt_regs *regs, 
> kdb_dbtrap_t db_result)
> +#else
> +int
> +kdb_local(kdb_reason_t reason, int error, struct pt_regs *regs, 
> kdb_dbtrap_t db_result)
> +#endif
> {
>     char *cmdbuf;
>     int diag;
> @@ -1676,6 +1686,27 @@
>     int result = 0;    /* Default is kdb did not handle it */
>     int ss_event;
>     kdb_dbtrap_t db_result=KDB_DB_NOBPT;
> +
> +#if defined(CONFIG_MDB)
> +        extern int AlternateDebuggerRoutine(kdb_reason_t reason, int 
> error,
> +                                     struct pt_regs *ef);
> +    if (!kdb_on)
> +       return 0;
> +
> +        result = AlternateDebuggerRoutine(reason, error, regs);
> +        switch (result)
> +        {
> +           case 1:  // alternate debugger handled event
> +              return 1;
> +
> +           case -1: // alternate debugger did not handle event
> +              return 0;
> +
> +           default: // drop into kdb
> +              break;
> +        }
> +#endif
> +
>     atomic_inc(&kdb_event);
>
>     switch(reason) {
> @@ -3016,6 +3047,40 @@
>  * Remarks:
>  */
>
> +#if defined (CONFIG_MDB)
> +
> +#include <linux/mdbglobals.h>
> +
> +void
> +mdb_ps1(struct task_struct *p)
> +{
> +    DBGPrint("0x%p %8d %8d  %d %4d   %c  0x%p %c%s\n",
> +           (void *)p, p->pid, p->parent->pid,
> +           kdb_task_has_cpu(p), kdb_process_cpu(p),
> +           (p->state == 0) ? 'R' :
> +             (p->state < 0) ? 'U' :
> +             (p->state & TASK_UNINTERRUPTIBLE) ? 'D' :
> +             (p->state & TASK_STOPPED || p->ptrace & PT_PTRACED) ? 'T' :
> +             (p->state & TASK_ZOMBIE) ? 'Z' :
> +             (p->state & TASK_INTERRUPTIBLE) ? 'S' : '?',
> +           (void *)(&p->thread),
> +           (p == current) ? '*': ' ',
> +           p->comm);
> +    if (kdb_task_has_cpu(p)) {
> +        struct kdb_running_process *krp = kdb_running_process + 
> kdb_process_cpu(p);
> +        if (!krp->seqno || !krp->p)
> +            DBGPrint("  Error: no saved data for this cpu\n");
> +        else {
> +            if (krp->seqno < kdb_seqno - 1)
> +                DBGPrint("  Warning: process state is stale\n");
> +            if (krp->p != p)
> +                DBGPrint("  Error: does not match running process 
> table (0x%p)\n", krp->p);
> +        }
> +    }
> +}
> +
> +#endif
> +
> void
> kdb_ps1(struct task_struct *p)
> {
> @@ -3835,6 +3900,10 @@
> void __init
> kdb_init(void)
> {
> +#if defined(CONFIG_MDB)
> +        extern void mdb_init(void);                +#endif
> +
>     kdb_initial_cpu = smp_processor_id();
>     /*
>      * This must be called before any calls to kdb_printf.
> @@ -3855,6 +3924,11 @@
>
>     kdb_cmd_init();        /* Preset commands from kdb_cmds */
>     kdb_initial_cpu = -1;    /* Avoid recursion problems */
> +
> +#if defined(CONFIG_MDB)
> +        mdb_init();                +#endif
> +
>     kdb(KDB_REASON_SILENT, 0, 0);    /* Activate any preset 
> breakpoints on boot cpu */
>     kdb_initial_cpu = smp_processor_id();
>     notifier_chain_register(&panic_notifier_list, &kdb_block);
>
>
Alternate Debuggers should register an init function called from 
kdb_init.   Calling AlternateDebuggerInterface should call all registred 
debuggers
and allow each one to report status.  NetWare has had an alternate 
debugger interface for years.  It's easy to instrument.  The only thing
in Linux that's odd at all is the way GDB int3's are handled.  All this 
other stuff they are making you put in is not the problem of Linux.

Jeff

Jeff

  reply	other threads:[~2005-11-13  3:58 UTC|newest]

Thread overview: 105+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-11-09 13:54 [PATCH 0/39] NLKD - Novell Linux Kernel Debugger Jan Beulich
2005-11-09 13:56 ` [PATCH 1/39] NLKD - an alternative kallsyms approach Jan Beulich
2005-11-09 13:57   ` [PATCH 2/39] NLKD - an alternative early ioremap approach Jan Beulich
2005-11-09 13:58     ` [PATCH 3/39] NLKD - early/late CPU up/down notification Jan Beulich
2005-11-09 13:59       ` [PATCH 4/39] NLKD/i386 " Jan Beulich
2005-11-09 14:01       ` [PATCH 5/39] NLKD/x86-64 " Jan Beulich
2005-11-10 13:10         ` Andi Kleen
2005-11-14  8:04           ` [discuss] " Jan Beulich
2005-11-14 12:37             ` Andi Kleen
2005-11-09 14:01       ` [PATCH 6/39] NLKD - early panic notification Jan Beulich
2005-11-09 14:02         ` [PATCH 7/39] NLKD - task create/destroy notification Jan Beulich
2005-11-09 14:03           ` [PATCH 8/39] NLKD - rmmod notification Jan Beulich
2005-11-09 14:04             ` [PATCH 9/39] NLKD - hotkey notification Jan Beulich
2005-11-09 14:05               ` [PATCH 10/39] NLKD - console layout change notification Jan Beulich
2005-11-09 14:06                 ` [PATCH 11/39] NLKD - time adjustment Jan Beulich
2005-11-09 14:06                   ` [PATCH 12/39] NLKD/i386 " Jan Beulich
2005-11-09 19:10                     ` George Anzinger
2005-11-10  8:12                       ` Jan Beulich
2005-11-11  0:17                         ` George Anzinger
2005-11-09 14:08                   ` [PATCH 13/39] NLKD/x86-64 " Jan Beulich
2005-11-09 14:13                     ` [PATCH 18/39] NLKD/x86-64 - INT1/INT3 handling changes Jan Beulich
2005-11-09 14:14                       ` [PATCH 19/39] NLKD/x86-64 - stack-pointer-invalid markers Jan Beulich
2005-11-09 14:15                         ` [PATCH 20/39] NLKD/x86-64 - switch_to() floating point adjustment Jan Beulich
2005-11-09 14:16                           ` [PATCH 21/39] NLKD/x86-64 - core adjustments Jan Beulich
2005-11-10 13:24                           ` [PATCH 20/39] NLKD/x86-64 - switch_to() floating point adjustment Andi Kleen
2005-11-10 14:07                             ` Jan Beulich
2005-11-10 13:23                         ` [PATCH 19/39] NLKD/x86-64 - stack-pointer-invalid markers Andi Kleen
2005-11-10 14:25                           ` Jan Beulich
2005-11-10 13:21                       ` [PATCH 18/39] NLKD/x86-64 - INT1/INT3 handling changes Andi Kleen
2005-11-10 14:07                         ` Jan Beulich
2005-11-10 14:25                           ` Andi Kleen
2005-11-10 15:00                             ` Jan Beulich
2005-11-11  3:39                               ` [discuss] " Andi Kleen
2005-11-10 13:19                     ` [PATCH 13/39] NLKD/x86-64 - time adjustment Andi Kleen
2005-11-10 14:23                       ` Jan Beulich
2005-11-11  2:12                         ` Andi Kleen
2005-11-12  9:22                           ` Vojtech Pavlik
2005-11-12 17:21                             ` Andi Kleen
2005-11-12 20:44                               ` Vojtech Pavlik
2005-11-15  0:38                                 ` George Anzinger
2005-11-15  1:05                                   ` [discuss] " Andi Kleen
2005-11-15  7:50                                     ` Vojtech Pavlik
2005-11-15  8:24                                       ` Jan Beulich
2005-11-10 14:43                       ` Vojtech Pavlik
2005-11-09 14:09                   ` [PATCH 14/39] NLKD - kernel trace buffer access Jan Beulich
2005-11-09 14:09                     ` [PATCH 15/39] NLKD - early pseudo-fs Jan Beulich
2005-11-09 14:11                       ` [PATCH 16/39] NLKD - core adjustments Jan Beulich
2005-11-09 14:11                         ` [PATCH 17/39] NLKD/i386 " Jan Beulich
2005-11-09 19:00                           ` Adrian Bunk
2005-11-10  8:04                             ` Jan Beulich
2005-11-10 10:29                               ` Adrian Bunk
2005-11-10 11:52                                 ` Jan Beulich
2005-11-10 12:36                                   ` Lars Marowsky-Bree
2005-11-09 14:18                         ` [PATCH 22/39] NLKD - core Jan Beulich
2005-11-09 14:19                           ` [PATCH 23/39] NLKD/x86 " Jan Beulich
2005-11-09 14:20                             ` [PATCH 24/39] NLKD/i386 " Jan Beulich
2005-11-09 14:21                             ` [PATCH 25/39] NLKD/x86-64 " Jan Beulich
2005-11-10 13:30                               ` Andi Kleen
2005-11-09 14:22                           ` [PATCH 26/39] NLKD - run time library Jan Beulich
2005-11-09 14:23                             ` [PATCH 27/39] NLKD/i386 " Jan Beulich
2005-11-09 14:23                               ` [PATCH 28/39] NLKD/x86-64 " Jan Beulich
2005-11-10 13:32                                 ` Andi Kleen
     [not found]                             ` <437214B7.76F0.0078.0@novell.com>
     [not found]                               ` <4372156A.76F0.0078.0@novell.com>
2005-11-09 14:28                                 ` [PATCH 34/39] NLKD/x86 - Console Debug Agent Jan Beulich
     [not found]                                 ` <43721600.76F0.0078.0@novell.com>
2005-11-09 14:30                                   ` [PATCH 38/39] NLKD/i386 - Remote " Jan Beulich
2005-11-09 14:31                                   ` [PATCH 39/39] NLKD/x86-64 " Jan Beulich
2005-11-09 14:29                       ` [PATCH 15/39] NLKD - early pseudo-fs Al Viro
2005-11-09 14:37                         ` Jan Beulich
2005-11-09 15:00                           ` Al Viro
2005-11-09 16:00                             ` Jan Beulich
2005-11-10  5:44                     ` [PATCH 14/39] NLKD - kernel trace buffer access Keith Owens
2005-11-10  8:02                       ` Jan Beulich
2005-11-09 18:51                   ` [PATCH 11/39] NLKD - time adjustment George Anzinger
2005-11-09 16:50         ` [PATCH 6/39] NLKD - early panic notification Greg KH
2005-11-09 16:45       ` [PATCH 3/39] NLKD - early/late CPU up/down notification Greg KH
2005-11-09 17:09         ` Jan Beulich
2005-11-09 17:19           ` Greg KH
2005-11-10  7:41             ` Jan Beulich
2005-11-10 20:59               ` Sam Ravnborg
2005-11-11  7:52                 ` Jan Beulich
2005-11-12 20:52                   ` Randy.Dunlap
2005-11-10 23:01               ` Greg KH
2005-11-11 10:06     ` [PATCH 2/39] NLKD - an alternative early ioremap approach Pavel Machek
2005-11-11 10:19       ` Jan Beulich
2005-11-09 16:50   ` [PATCH 1/39] NLKD - an alternative kallsyms approach Randy.Dunlap
2005-11-09 16:57     ` Greg KH
2005-11-09 17:20     ` Jan Beulich
2005-11-09 16:59 ` [PATCH 0/39] NLKD - Novell Linux Kernel Debugger Jeff Garzik
2005-11-09 17:06   ` Randy.Dunlap
2005-11-09 17:14     ` Jan Beulich
2005-11-09 17:56       ` Alan Cox
2005-11-09 18:05       ` Greg KH
2005-11-09 18:54       ` Paul Jackson
2005-11-10 12:41       ` Christoph Hellwig
2005-11-13  1:09     ` Andi Kleen
2005-11-13  2:53       ` jmerkey
2005-11-13  3:44         ` Andi Kleen
2005-11-13  3:26           ` Jeff V. Merkey
2005-11-13  3:32             ` Jeff V. Merkey [this message]
2005-11-09 17:53   ` Alan Cox
2005-11-09 16:25     ` Jeffrey V. Merkey
2005-11-10 14:48     ` Mark Lord
2005-11-10 15:28       ` Tom Rini
2005-11-10 16:37       ` Alan Cox
2005-11-13  1:11       ` Andi Kleen
     [not found] ` <437214E4.76F0.0078.0@novell.com>
     [not found]   ` <4372153C.76F0.0078.0@novell.com>
2005-11-10 13:33     ` [PATCH 32/39] NLKD/x86-64 - Core Debug Engine Andi Kleen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4376B3C1.6000409@wolfmountaingroup.com \
    --to=jmerkey@wolfmountaingroup.com \
    --cc=JBeulich@novell.com \
    --cc=ak@suse.de \
    --cc=akpm@osdl.org \
    --cc=jmerkey@utah-nac.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=rdunlap@xenotime.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox