[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
RE: Simple question about getting stack size
Yes, this is just for debug purposes.
I added the code to my module, but it wouldn't compile:
# make
make -C /lib/modules/2.6.5-1.358/build SUBDIRS=/test/mydriver modules
make[1]: Entering directory `/lib/modules/2.6.5-1.358/build'
CC [M] /test/mydriver/igg.o
/test/mydriver/igg.c: In function `igg_ioctl':
/test/mydriver/igg.c:2106: warning: asm operand 1 probably doesn't match
constraints
/test/mydriver/igg.c:2106: error: impossible constraint in `asm'
/test/mydriver/igg.c:2104: warning: `esp' might be used uninitialized in
this function
make[2]: *** [/test/mydriver/igg.o] Error 1
make[1]: *** [/test/mydriver] Error 2
make[1]: Leaving directory `/lib/modules/2.6.5-1.358/build'
make: *** [default] Error 2
#
The 2106 lines is the __asm__ line.
I see that there are other lines of code like this is the kernel, so I'm
stumped as to why this won't compile ?
I'm using the kernels Kbuild system so I would have thought that it
would have all the right compile flags set.
Any help appreciated.
Thanks
dom
-----Original Message-----
From: Arjan van de Ven [mailto:arjan@xxxxxxxxxxxxx]
Sent: Sunday, February 27, 2005 5:12 AM
To: Curran, Dominic
Cc: kernelnewbies@xxxxxxxxxxxx
Subject: Re: Simple question about getting stack size
On Sat, 2005-02-26 at 20:28 -0600, Curran, Dominic wrote:
> Hi
>
> Trying to do something very simple and failing miserably...
>
> I want to dump out the amount of stack size I have left at different
> points in my LKM driver.
as a debugging aid I assume
> In order to do this I believe I need to know the value of 'current'
> and 'esp'.
Just copy the following code into yours (your module is gpl so that you
can copy such things I assume):
58 #ifdef CONFIG_DEBUG_STACKOVERFLOW
59 /* Debugging check for stack overflow: is there less than 1KB
free? */
60 {
61 long esp;
62
63 __asm__ __volatile__("andl %%esp,%0" :
64 "=r" (esp) : "" (THREAD_SIZE
- 1));
65 if (unlikely(esp < (sizeof(struct thread_info) +
STACK_WARN))) {
66 printk("do_IRQ: stack overflow: %ld\n",
67 esp - sizeof(struct thread_info));
68 dump_stack();
69 }
70 }
71 #endif
--
Kernelnewbies: Help each other learn about the Linux kernel.
Archive: http://mail.nl.linux.org/kernelnewbies/
FAQ: http://kernelnewbies.org/faq/