lkml.org 
[lkml]   [1999]   [Nov]   [18]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
SubjectRe: 2.2.14pre5: kmem_grow: Called nonatomically from int - size-128
Date
On Thu, 18 Nov 1999 22:23:56 +0100, 
Dominik Kubla <dominik.kubla@uni-mainz.de> wrote:
>On Thu, Nov 18, 1999 at 06:09:01PM +0100, Ingo Molnar wrote:
>> if you put a '*(int *)0=0;' instead of the printk into slab.c then we get
>> an oops + stacktrace of the offending code path.
>Hmm... nice! Is there a way to get a stacktrace without forcing an oops?

The code below is a hacked version of show_registers() from
arch/i386/kernel/traps.c. Include it in slab.c and call kao_trace()
after the printk. It only prints the stack and the back trace, no
registers or code but that is all you want in this case. You still
have to run the output through ksymoops.

/*KAOtrace start*/
#include <asm/desc.h>

extern int kstack_depth_to_print;
extern char _stext, _etext;

/*
* These constants are for searching for possible module text
* segments. VMALLOC_OFFSET comes from mm/vmalloc.c; MODULE_RANGE is
* a guess of how much space is likely to be vmalloced.
*/
#define VMALLOC_OFFSET (8*1024*1024)
#define MODULE_RANGE (8*1024*1024)
static void kao_trace(void)
{
int i;
int in_kernel = 1;
unsigned long esp;
unsigned short ss;
unsigned long *stack, addr, module_start, module_end;
ss = 0;
asm("movl %%esp,%0": "=m" (esp));

store_TR(i);
printk("Process %s (pid: %d, process nr: %d, stackpage=%08lx)",
current->comm, current->pid, 0xffff & i, 4096+(unsigned long)current);
/*
* When in-kernel, we also print out the stack and code at the
* time of the fault..
*/
if (in_kernel) {
printk("\nStack: ");
stack = (unsigned long *) esp;
for(i=0; i < kstack_depth_to_print; i++) {
if (((long) stack & 4095) == 0)
break;
if (i && ((i % 8) == 0))
printk("\n ");
printk("%08lx ", *stack++);
}
printk("\nCall Trace: ");
stack = (unsigned long *) esp;
i = 1;
module_start = PAGE_OFFSET + (max_mapnr << PAGE_SHIFT);
module_start = ((module_start + VMALLOC_OFFSET) & ~(VMALLOC_OFFSET-1));
module_end = module_start + MODULE_RANGE;
while (((long) stack & 4095) != 0) {
addr = *stack++;
/*
* If the address is either in the text segment of the
* kernel, or in the region which contains vmalloc'ed
* memory, it *may* be the address of a calling
* routine; if so, print it so that someone tracing
* down the cause of the crash will be able to figure
* out the call path that was taken.
*/
if (((addr >= (unsigned long) &_stext) &&
(addr <= (unsigned long) &_etext)) ||
((addr >= module_start) && (addr <= module_end))) {
if (i && ((i % 8) == 0))
printk("\n ");
printk("[<%08lx>] ", addr);
i++;
}
}
}
printk("\n");
}
/*KAOtrace end*/

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/

\
 
 \ /
  Last update: 2005-03-22 13:55    [from the cache]
©2003-2011 Jasper Spaans