How can I 'getchar()' in module code?
For debugging purpose, I want something like 'getchar()' that can pause execution in the module code. Do any candidates I can choose?
On Tue, 03 Dec 2013 20:35:41 +0800, 乃宏周 said:
For debugging purpose, I want something like 'getchar()' that can pause execution in the module code. Do any candidates I can choose?
The problem is that pausing execution in module code is dangerous, as if you hold any locks or anything like that, you can hang other threads or even the whole machine. You probablhy want to be looking at the kgdb support, that is coded to work around a lot of the issues and you get full GDB support not just a getchar() pause.
On Die, 2013-12-03 at 08:38 -0500, Valdis.Kletnieks@vt.edu wrote:
On Tue, 03 Dec 2013 20:35:41 +0800, said:
For debugging purpose, I want something like 'getchar()' that can pause execution in the module code. Do any candidates I can choose?
You do not want that - there is way too much parallelism and asynchronous stuff in the kernel. Debugging with getchar() and the like pretty much works only in single-threaded stuff ....
The problem is that pausing execution in module code is dangerous, as if you hold any locks or anything like that, you can hang other threads or even the whole machine.
You probablhy want to be looking at the kgdb support, that is coded to work around a lot of the issues and you get full GDB support not just a getchar() pause.
Or just use printk() to print interesting values in interesting cases. Bernd -- Bernd Petrovitsch Email : bernd@petrovitsch.priv.at LUGA : http://www.luga.at
On Tue, Dec 3, 2013 at 4:20 PM, Bernd Petrovitsch <bernd@petrovitsch.priv.at> wrote:
On Die, 2013-12-03 at 08:38 -0500, Valdis.Kletnieks@vt.edu wrote:
On Tue, 03 Dec 2013 20:35:41 +0800, said:
For debugging purpose, I want something like 'getchar()' that can pause execution in the module code. Do any candidates I can choose?
I think there is a way to stop execution :). Run your image under qemu, and use gdb to set breakpoints. thanks, Daniel.
On Mit, 2013-12-04 at 23:21 +0200, Daniel Baluta wrote:
On Tue, Dec 3, 2013 at 4:20 PM, Bernd Petrovitsch <bernd@petrovitsch.priv.at> wrote:
On Die, 2013-12-03 at 08:38 -0500, Valdis.Kletnieks@vt.edu wrote:
On Tue, 03 Dec 2013 20:35:41 +0800, said:
For debugging purpose, I want something like 'getchar()' that can pause execution in the module code. Do any candidates I can choose?
I think there is a way to stop execution :). Run your image under qemu, and use gdb to set breakpoints.
Yup. Or you can run UML and use the regular gdb and probably even plain-old getchar() as it runs as a user-space process. The question is, if the interesting parts/drivers/subsystems are there too. Bernd -- Bernd Petrovitsch Email : bernd@petrovitsch.priv.at LUGA : http://www.luga.at
yes, exactly - what u are describing is called "kdb". don't mixed up with "kgdb". kdb: this is debugging on the same computer - so no serial ports connection are needed. once exception occurred, you will be popped into a special debugger screen. problem is that now this debugger is running in kernel mode, inside the same computer that have the kernel module crashing, and so everything stop running, only kdb is running. (NOTE: i played with this almost like 8 or 9 years ago, and it seemed now kdb is not updated any more.) kgdb: this always require TWO computer: host + debuggee. kgdb is running inside the debuggee whose kernel has crashed, and gdb is running in host. normally connected via serial port. normally the preferred way is to run the kernel to be debugged inside the VirtualBox, or VMWare, and then gdb host is the virtual machine host. diff between the two is explained here: https://www.kernel.org/pub/linux/kernel/people/jwessel/kdb/CompileKDB.html and setup are here (mainly for kgdb): http://elinux.org/KDB http://allmybrain.com/2010/04/29/debugging-linux-kernel-modules-with-virtual... http://www.linuxforu.com/2011/03/kgdb-with-virtualbox-debug-live-kernel/ have fun. On Tue, Dec 3, 2013 at 8:35 PM, 乃宏周 <naive231@gmail.com> wrote:
For debugging purpose, I want something like 'getchar()' that can pause execution in the module code. Do any candidates I can choose?
_______________________________________________ Kernelnewbies mailing list Kernelnewbies@kernelnewbies.org http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies
-- Regards, Peter Teoh
Thanks your replies! I found the target. 2013/12/5 上午9:34 於 "Peter Teoh" <htmldeveloper@gmail.com> 寫道:
yes, exactly - what u are describing is called "kdb". don't mixed up with "kgdb".
kdb: this is debugging on the same computer - so no serial ports connection are needed. once exception occurred, you will be popped into a special debugger screen. problem is that now this debugger is running in kernel mode, inside the same computer that have the kernel module crashing, and so everything stop running, only kdb is running.
(NOTE: i played with this almost like 8 or 9 years ago, and it seemed now kdb is not updated any more.)
kgdb: this always require TWO computer: host + debuggee. kgdb is running inside the debuggee whose kernel has crashed, and gdb is running in host. normally connected via serial port. normally the preferred way is to run the kernel to be debugged inside the VirtualBox, or VMWare, and then gdb host is the virtual machine host.
diff between the two is explained here:
https://www.kernel.org/pub/linux/kernel/people/jwessel/kdb/CompileKDB.html
and setup are here (mainly for kgdb):
http://allmybrain.com/2010/04/29/debugging-linux-kernel-modules-with-virtual... http://www.linuxforu.com/2011/03/kgdb-with-virtualbox-debug-live-kernel/
have fun.
On Tue, Dec 3, 2013 at 8:35 PM, 乃宏周 <naive231@gmail.com> wrote:
For debugging purpose, I want something like 'getchar()' that can pause execution in the module code. Do any candidates I can choose?
_______________________________________________ Kernelnewbies mailing list Kernelnewbies@kernelnewbies.org http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies
-- Regards, Peter Teoh
On 2013年12月03日 20:35, 乃宏周 wrote:
For debugging purpose, I want something like 'getchar()' that can pause execution in the module code. Do any candidates I can choose?
Create a /proc/knob to turn on or off your code path flow on fly, instead of using user space getchar. Otherwise, you should looking into other more promising debug method.
_______________________________________________ Kernelnewbies mailing list Kernelnewbies@kernelnewbies.org http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies
-- 浮沉随浪只记今朝笑 --fan fan
participants (6)
-
Bernd Petrovitsch -
Daniel Baluta -
Fan Du -
Peter Teoh -
Valdis.Kletnieks@vt.edu -
乃宏周