lkml.org 
[lkml]   [2000]   [Feb]   [12]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: lowlatency-2.2.14-B1 + 2.2.14aa7 fixes crash, but...
Manfred Spraul wrote:
>
> What about writing a generic module that walks through the task array
> and dumps the complete (8kB) kernel stack? The big advantage is that we
> could load it at runtime, and it has zero impact on the normal kernel
> operations. Perhaps even a user space program could do that through
> kcore/kmem.

attached is the adhoc hack i did years ago when i needed a stacktrace
of a hung process.

you need to lookup the address of init_task_union in System.map,
update it, recompile, and insmod the module specifying the pid.

it could be made a lot nicer, but as it has always been enough for my needs...

artur
//gcc -D__KERNEL__ -DMODULE=1 -I/usr/src/linux/include -O2 -fno-strict-aliasing -pipe -c ksmod.c
//insmod -v ./ksmod.o pid=266
/*
* Copyright 1998 Artur Skawina <skawina@geocities.com>
*/
#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/errno.h>
#include <linux/sched.h>

int pid = -1;

MODULE_PARM(pid,"i");

EXPORT_NO_SYMBOLS;

#define init_task_union ((void *)0xc022e000)

void printstack( int pid )
{
struct task_struct *t;
u32 *stack;
u32 a;
printk( KERN_DEBUG "ksmod PID=%d\n", pid );
//for_each_task(t)
for (t = init_task_union; (t = t->next_task) != init_task_union ; )
if (t->pid == pid)
{
printk( KERN_DEBUG
"EIP: [<%08lx>] "
"ESP: %08lx "
"SavedPC: %08lx\n",
t->thread.eip,
t->thread.esp,
thread_saved_pc( &t->thread ) );
stack = (u32 *)t->thread.esp;

while (((u32)stack & 4095) != 0)
{
a = *stack++;
if ( (a > (u32)PAGE_OFFSET) && (a < 0xffffffff) )
printk( KERN_DEBUG "[<%08lx>]\n", a);
}
break;
}
}
int init_module(void)
{
if ( pid==-1 )
{
printk(KERN_ERR "ksmod: pid missing.\n");
return -EINVAL;
}
printstack( pid );

return 0;
}
void cleanup_module(void)
{
}
\
 
 \ /
  Last update: 2005-03-22 13:56    [from the cache]
©2003-2011 Jasper Spaans