Building kernel modules with debuginfo and printing line numbers in kernel oops message / coredump

Sankar P sankar.curiosity at gmail.com
Sun Apr 21 02:18:31 EDT 2013


Hi Neha,

On Sat, Apr 20, 2013 at 3:11 AM, neha naik <nehanaik27 at gmail.com> wrote:
> Hi Sankar,
>   I found this article for debugging third party module sometime back. I
> have not used it still (I kind of look at the hexadeciamal gibberish still
> :) ).
>  But you can give it a try :
>
> http://www.linux.com/learn/linux-training/33991-the-kernel-newbie-corner-kernel-and-module-debugging-with-gdb
>


Thanks.

But this article seem to talk about using gdb for the kernel
development. I am more interested in getting the default dmesg output
to show the stack traces with proper filenames and line numbers :)

> Regards,
> Neha
>
> On Fri, Apr 19, 2013 at 12:25 PM, Sankar P <sankar.curiosity at gmail.com>
> wrote:
>>
>> Hi,
>>
>> I have written a kernel module which I build using:
>>
>> Makefile (edited a bit)
>> ==========
>> obj-m := simple.o
>> simple-objs := s.o
>>
>> make -C /lib/modules/$(shell uname -r)/build M=$(PWD) modules
>>
>> =======
>>
>> Everything builds fine. But my kernel module caused an oops and the
>> message was something like:
>>
>> myfunctionname +0x2507 +5679
>>
>> or some hexadecimal gibberish. I know that I can use some external
>> tool to find out what these addresses mean. But, is there a way I can
>> get the kernel oops message to print these information along with line
>> number ?
>>
>> Is there a way to build the kernel module with debug symbols ? In user
>> space, I usually do "-g" or "-ggdb" and it will give me line numbers
>> and filenames neatly while dumping stacktrace. Is there a similar
>> facility available for out of tree kernel modules too ?
>>
>> Even if I give :
>>
>> $ CFLAGS="-ggdb" make
>>
>> The output file size (.ko) is not changed.
>>
>> Can someone help me with building kernel modules with debug info and
>> get the filename and line numbers printed in the oops messages /
>> coredump ?
>>
>> Thanks.
>>
>>
>> --
>> Sankar P
>> http://psankar.blogspot.com
>>
>> _______________________________________________
>> Kernelnewbies mailing list
>> Kernelnewbies at kernelnewbies.org
>> http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies
>
>



--
Sankar P
http://psankar.blogspot.com



More information about the Kernelnewbies mailing list