kernelnewbies.kernelnewbies.org archive mirror
 help / color / mirror / Atom feed
* How can I 'getchar()' in module code?
@ 2013-12-03 12:35 乃宏周
  2013-12-03 13:20 ` Daniel Baluta
                   ` (3 more replies)
  0 siblings, 4 replies; 9+ messages in thread
From: 乃宏周 @ 2013-12-03 12:35 UTC (permalink / raw)
  To: kernelnewbies

For debugging purpose, I want something like 'getchar()' that can pause
execution in the module code. Do any candidates I can choose?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.kernelnewbies.org/pipermail/kernelnewbies/attachments/20131203/e40d8410/attachment.html 

^ permalink raw reply	[flat|nested] 9+ messages in thread

* How can I 'getchar()' in module code?
  2013-12-03 12:35 How can I 'getchar()' in module code? 乃宏周
@ 2013-12-03 13:20 ` Daniel Baluta
  2013-12-03 13:38 ` Valdis.Kletnieks at vt.edu
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 9+ messages in thread
From: Daniel Baluta @ 2013-12-03 13:20 UTC (permalink / raw)
  To: kernelnewbies

On Tue, Dec 3, 2013 at 2: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?

No.

^ permalink raw reply	[flat|nested] 9+ messages in thread

* How can I 'getchar()' in module code?
  2013-12-03 12:35 How can I 'getchar()' in module code? 乃宏周
  2013-12-03 13:20 ` Daniel Baluta
@ 2013-12-03 13:38 ` Valdis.Kletnieks at vt.edu
  2013-12-03 14:20   ` Bernd Petrovitsch
  2013-12-05  1:34 ` Peter Teoh
  2013-12-06  1:40 ` Fan Du
  3 siblings, 1 reply; 9+ messages in thread
From: Valdis.Kletnieks at vt.edu @ 2013-12-03 13:38 UTC (permalink / raw)
  To: kernelnewbies

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.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 865 bytes
Desc: not available
Url : http://lists.kernelnewbies.org/pipermail/kernelnewbies/attachments/20131203/a4fdc09b/attachment-0001.bin 

^ permalink raw reply	[flat|nested] 9+ messages in thread

* How can I 'getchar()' in module code?
  2013-12-03 13:38 ` Valdis.Kletnieks at vt.edu
@ 2013-12-03 14:20   ` Bernd Petrovitsch
  2013-12-04 21:21     ` Daniel Baluta
  0 siblings, 1 reply; 9+ messages in thread
From: Bernd Petrovitsch @ 2013-12-03 14:20 UTC (permalink / raw)
  To: kernelnewbies

On Die, 2013-12-03 at 08:38 -0500, Valdis.Kletnieks at 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 at petrovitsch.priv.at
                     LUGA : http://www.luga.at

^ permalink raw reply	[flat|nested] 9+ messages in thread

* How can I 'getchar()' in module code?
  2013-12-03 14:20   ` Bernd Petrovitsch
@ 2013-12-04 21:21     ` Daniel Baluta
  2013-12-05 13:14       ` Bernd Petrovitsch
  0 siblings, 1 reply; 9+ messages in thread
From: Daniel Baluta @ 2013-12-04 21:21 UTC (permalink / raw)
  To: kernelnewbies

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 at 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.

^ permalink raw reply	[flat|nested] 9+ messages in thread

* How can I 'getchar()' in module code?
  2013-12-03 12:35 How can I 'getchar()' in module code? 乃宏周
  2013-12-03 13:20 ` Daniel Baluta
  2013-12-03 13:38 ` Valdis.Kletnieks at vt.edu
@ 2013-12-05  1:34 ` Peter Teoh
  2013-12-05  4:45   ` 乃宏周
  2013-12-06  1:40 ` Fan Du
  3 siblings, 1 reply; 9+ messages in thread
From: Peter Teoh @ 2013-12-05  1:34 UTC (permalink / raw)
  To: kernelnewbies

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-virtualbox-and-kgdb/
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 at kernelnewbies.org
> http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies
>
>


-- 
Regards,
Peter Teoh
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.kernelnewbies.org/pipermail/kernelnewbies/attachments/20131205/9c63bf88/attachment.html 

^ permalink raw reply	[flat|nested] 9+ messages in thread

* How can I 'getchar()' in module code?
  2013-12-05  1:34 ` Peter Teoh
@ 2013-12-05  4:45   ` 乃宏周
  0 siblings, 0 replies; 9+ messages in thread
From: 乃宏周 @ 2013-12-05  4:45 UTC (permalink / raw)
  To: kernelnewbies

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://elinux.org/KDB
>
> http://allmybrain.com/2010/04/29/debugging-linux-kernel-modules-with-virtualbox-and-kgdb/
> 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 at kernelnewbies.org
>> http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies
>>
>> --
> Regards,
> Peter Teoh
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.kernelnewbies.org/pipermail/kernelnewbies/attachments/20131205/6ef7c453/attachment-0001.html 

^ permalink raw reply	[flat|nested] 9+ messages in thread

* How can I 'getchar()' in module code?
  2013-12-04 21:21     ` Daniel Baluta
@ 2013-12-05 13:14       ` Bernd Petrovitsch
  0 siblings, 0 replies; 9+ messages in thread
From: Bernd Petrovitsch @ 2013-12-05 13:14 UTC (permalink / raw)
  To: kernelnewbies

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 at 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 at petrovitsch.priv.at
                     LUGA : http://www.luga.at

^ permalink raw reply	[flat|nested] 9+ messages in thread

* How can I 'getchar()' in module code?
  2013-12-03 12:35 How can I 'getchar()' in module code? 乃宏周
                   ` (2 preceding siblings ...)
  2013-12-05  1:34 ` Peter Teoh
@ 2013-12-06  1:40 ` Fan Du
  3 siblings, 0 replies; 9+ messages in thread
From: Fan Du @ 2013-12-06  1:40 UTC (permalink / raw)
  To: kernelnewbies



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 at kernelnewbies.org
> http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies

-- 
?????????

--fan fan

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2013-12-06  1:40 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-12-03 12:35 How can I 'getchar()' in module code? 乃宏周
2013-12-03 13:20 ` Daniel Baluta
2013-12-03 13:38 ` Valdis.Kletnieks at vt.edu
2013-12-03 14:20   ` Bernd Petrovitsch
2013-12-04 21:21     ` Daniel Baluta
2013-12-05 13:14       ` Bernd Petrovitsch
2013-12-05  1:34 ` Peter Teoh
2013-12-05  4:45   ` 乃宏周
2013-12-06  1:40 ` Fan Du

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).