All of lore.kernel.org
 help / color / mirror / Atom feed
* Debug only with printk ?
@ 2009-04-28 21:27 Dragoslav Zaric
  2009-04-29  3:15 ` Valdis.Kletnieks
  2009-04-29 17:15 ` Lennart Sorensen
  0 siblings, 2 replies; 3+ messages in thread
From: Dragoslav Zaric @ 2009-04-28 21:27 UTC (permalink / raw)
  To: LKML

Hello,

I am relatively new in linux kernel and since debugging is key
element of programming, I am wondering is it really necessary
to use various debugging tools for kernel debugging ?

Is simple printing with printk enough to debug any kind of kernel problem,
and if not, what are the cases when printk is not enough ?

Also, is there possibility when using debugging tools to affect
kernel environment, because debugging tool will also take cpu time and
memory resources ?

thanks

Dragoslav Zaric
[Programmer; M Sc Astrophysics]

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

* Re: Debug only with printk ?
  2009-04-28 21:27 Debug only with printk ? Dragoslav Zaric
@ 2009-04-29  3:15 ` Valdis.Kletnieks
  2009-04-29 17:15 ` Lennart Sorensen
  1 sibling, 0 replies; 3+ messages in thread
From: Valdis.Kletnieks @ 2009-04-29  3:15 UTC (permalink / raw)
  To: Dragoslav Zaric; +Cc: LKML

[-- Attachment #1: Type: text/plain, Size: 1689 bytes --]

On Tue, 28 Apr 2009 23:27:42 +0200, Dragoslav Zaric said:
> I am relatively new in linux kernel and since debugging is key
> element of programming, I am wondering is it really necessary
> to use various debugging tools for kernel debugging ?

'git bisect' and friends are your friends if you're trying to track down
a bug in somebody else's code.

It's not *mandatory* to use other tools, but it certainly helps.

> Is simple printing with printk enough to debug any kind of kernel problem,
> and if not, what are the cases when printk is not enough ?

Usually, printk's are sufficient *if* you can use them.  Times when this
may not be true:

1) Debugging an early-boot crash, before even the earlyprintk stuff is alive.

2) "Add a printk, recompile, reboot" gets pretty boring pretty fast, so
it may be a *lot* faster if you can use one of the kernel debugging/tracing
tools to do "Well, maybe we should check this... or this.. or wait, how
about *this*?" testing.

3) If you're trying to debug an issue on a production server, you may not
have the *option* to do a lot of compile/reboot cycles, and be forced to
use whatever debug/trace support is present in the already-running kernel.

> Also, is there possibility when using debugging tools to affect
> kernel environment, because debugging tool will also take cpu time and
> memory resources ?

If I had a <monetary unit> for every time when even adding a printk call
was enough to change the timing and cause a Heisenbug to change its behavior,
I'd have a lot of monetary units.

Yes, debugging tools and printks will change code and data offsets and timing
so data overlays and race conditions change or even dissapear/reappear.

[-- Attachment #2: Type: application/pgp-signature, Size: 226 bytes --]

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

* Re: Debug only with printk ?
  2009-04-28 21:27 Debug only with printk ? Dragoslav Zaric
  2009-04-29  3:15 ` Valdis.Kletnieks
@ 2009-04-29 17:15 ` Lennart Sorensen
  1 sibling, 0 replies; 3+ messages in thread
From: Lennart Sorensen @ 2009-04-29 17:15 UTC (permalink / raw)
  To: Dragoslav Zaric; +Cc: LKML

On Tue, Apr 28, 2009 at 11:27:42PM +0200, Dragoslav Zaric wrote:
> I am relatively new in linux kernel and since debugging is key
> element of programming, I am wondering is it really necessary
> to use various debugging tools for kernel debugging ?
> 
> Is simple printing with printk enough to debug any kind of kernel problem,
> and if not, what are the cases when printk is not enough ?
> 
> Also, is there possibility when using debugging tools to affect
> kernel environment, because debugging tool will also take cpu time and
> memory resources ?

So far I have used printk's, parsing of the OOPS when I do something
stupid, educated guesing looking at the code following an OOPS or other
problem, and in a couple of cases using firescope.  I have used firescope
to monitor the DMA ring buffer for the pcnet32 driver once.

-- 
Len Sorensen

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

end of thread, other threads:[~2009-04-29 17:16 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-04-28 21:27 Debug only with printk ? Dragoslav Zaric
2009-04-29  3:15 ` Valdis.Kletnieks
2009-04-29 17:15 ` Lennart Sorensen

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.