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

Sankar P sankar.curiosity at gmail.com
Mon Apr 22 01:56:53 EDT 2013


On Mon, Apr 22, 2013 at 6:00 AM, arshad hussain <arshad.super at gmail.com> wrote:
>
>
>
> On Mon, Apr 22, 2013 at 5:58 AM, arshad hussain <arshad.super at gmail.com>
> wrote:
>>
>>
>>
>>
>> On Fri, Apr 19, 2013 at 11:55 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
>>
>>
>> "myfunctionname +0x2507 +5679"
>>
>> It's not hex gibberish. What it saying is that, at the time of crash the
>> EIP was pointing
>> withing function "myfunctionname" and offset 0x2507 bytes. Use objdump
>> binary to
>> more detail of your simple.ko
>>

Thanks.

But is there not a way to get the line numbers and filenames printed
automatically instead of the memory addresses ? For example, in gdb,
in userspace, if there is a crash, we can get the line numbers printed
when there is a crash. Can the kernel crash/oops handler similarly not
print the filenames and linenumbers automatically ? Is there a
configuration or hack for getting it that way ?

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


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



More information about the Kernelnewbies mailing list