Re: Learning C
- From: "Richard G. Riley" <rgrdev@xxxxxxxxx>
- Date: 12 Mar 2006 10:34:36 GMT
On 2006-03-12, Ian Collins <ian-news@xxxxxxxxxxx> wrote:
Richard G. Riley wrote:gives
On 2006-03-11, Keith Thompson <kst-u@xxxxxxx> wrote:There is the middle ground, read the code first and step tough bits you
If I might summarize:
Richard G. Riley really likes debuggers. Not everyone else likes them
as much as Richard does.
I believe that covers all the relevant points.
Next?
Very droll.
But not at all what the crux of this is about : what its about is a
one way of working which can dramatically speed up ones familiarity
with a system. I find it terrifying that there seems to be a fair
number of programmers here who think a debugger is "only for finding bugs"
: it is a limited and naive view.
can't sus out in the debugger. A decent source browser (one that
100% of course. *Nothing* is as good as a good clear printout for an
overview and a familiarity. Hell, I print out man pages still.
you callers and callees) is a better tool for the job, it gives you an
overview of the code, rather than the details of one part of it.
Using a debugger as the main tool for familiarising one's self with a
large body of code is a bit like using a microscope to read a book.
I'm afraid that due to some of the replies I might have become a bit
exasperated and come across as a bit of a fanatic :(
But to close and to summarise some points which a lot of posters dont
seem to be aware of - or at least it appears that way from their
"debuggers are only occasional useful" replies -
1) A debugger can give you that high level overview too
2) It has cross reference facilities for definition finding
3) Ability to give symbolic representation to data
4) Ability to tweak at runtime to force unlikely conditions
5) Abilitiy to see entire dataset : not that determined useful by the
original programmer
6) Watchpoints & HW breakpoints to isolate required conditions.
7) Shows types : reveals bad casts & conversions very quickly in the
datawindow.
There are more. A good print out is good if for nothing else than
sitting on the jacks having a read :) Or annotation. The combo of a
good debugger with the experience of how to use it and possibly a
profiler is nirvana for a C programmer working on a large project.
I've seen old systems where the code is simply unreadable :
multistatements per line, single letter variable names, cast city :
code like this can be a nightmare to read from a printout - it is
useful to watch the program run. Yes, printfs* can be useful if
you have the knowledge and the facility to insert them.
(*) Or home brew multi-platform/interface compatible logging system
like Linux's klogd.
One last point about your microscope comment : this is only true if
you *step* every line. You dont. You place strategic break points at
the page or chapter you are interested in : after all, a C program is
hardly a novel - thought it is a schematic :)
And to anyone that got this far that isnt totally bored by the whole
thing : consider this. You see a function in a source browser :
are you not interested in HOW it was called? Why it was called? You can
guess from 30000 pages of printout or from a call hierachy in a source
analysys tool or IDE : but its 2 seconds work to set a break point
there and examine a few call stacks.
Yes, I'm an advocate. And astonished by the claims of some who say
they havent used a debugger more than twice in over 20 years of C programming.
.
- References:
- Learning C
- From: mfasoccer@xxxxxxxxx
- Re: Learning C
- From: Micah Cowan
- Re: Learning C
- From: mfasoccer@xxxxxxxxx
- Re: Learning C
- From: Nick Keighley
- Re: Learning C
- From: Nick Keighley
- Re: Learning C
- From: Chris Dollin
- Re: Learning C
- From: Nick Keighley
- Re: Learning C
- From: Nick Keighley
- Re: Learning C
- From: Keith Thompson
- Re: Learning C
- From: Richard G. Riley
- Re: Learning C
- From: Ian Collins
- Learning C
- Prev by Date: Re: how to pass arguments with two dimensional array???(Help!)
- Next by Date: Re: give me some tips
- Previous by thread: Re: Learning C
- Next by thread: Re: Learning C
- Index(es):
Relevant Pages
|