Click to See Complete Forum and Search --> : how to interact (user-space programme / kernel module)


srinis
06-09-2004, 02:51 PM
Hi,
What are tha ways/means by which a user-space programme can interact
with a kernel module.

Are there other means other then writing it to
1. a device file something like /dev/myfile and mknod it with a major/minor number.

can the /proc also be used to write information?
How do we debug kernel modules using some debugger like GDB or any other (please suggest) ?

Thanking anyone offering anyhelp in any of these.
Satish
Student

kevinalm
06-09-2004, 11:05 PM
Since you haven't had a reply yet, I'll take a shot.

Mostly /proc is for reading out status info, but iirc there is some ability to alter kernel and/or module behaviour on the fly by writing to certain files in /proc, at least in 2.6.x kernels. I'm going by memory here so I might be wrong, but I'm fairly certain I read something about that in either the menuconfig "help" or in one of the files in the kernel source /Documentation directory (probably 2.6.6 kernel). I also seem to recall something about "userspace" modules. Something fairly recent in the 2.6's but I really don't know anything about that.

Also going by memory (and my memory has been known to be iffy ;)) I don't think you can use gdb. Something about miscalculing offsets. You can recompile the kernel with it's own integral debugging turned on.

bwkaz
06-10-2004, 10:19 PM
I know you can write to files inside /proc/sys. It's sysctl support, or something like that. I don't think you can write to normal /proc files, but I could be wrong.

As for debugging, I think UML (user-mode Linux; it runs as a process inside your current Linux, so you only screw up one process which you can kill from the host, not the whole machine) could be an option. I don't know if you can run UML under gdb, but maybe.

kevinalm
06-11-2004, 12:50 AM
Originally posted by bwkaz

As for debugging, I think UML (user-mode Linux; it runs as a process inside your current Linux, so you only screw up one process which you can kill from the host, not the whole machine) could be an option. I don't know if you can run UML under gdb, but maybe.

Might be worth a try. But I'm pretty sure the problem with debugging the kernel with gdb was a limitation in gdb. I remember reading the phrase "gdb incorrectly ignors offsets in kernel code" or words to that effect. UMI might work around that if it is an emu or something along those lines.