"Nick"posted the following on 2006-03-11:
"debugger" / "debuggers" whatever. I've used ddd.
ddd is a front end to gdb.
I stress that I talking about "stepping through an application". I have
*no*
objection to examining existing code. One way to learn is to look at
good
examples (and sometimes at bad).
And how can stepping through an app be bad? Were you never put onto a
new project with a code base of several hundred thousand lines of code
and told to isolate some relatively bugs to get you familiar with the
code base?
yes, but you don't have to keep on inserting them. Debuggers are
generally manual.
I beg to differ.
I meant me pointing out they are useless in most server based apps or
message driven GUI apps.
ok I'm not saying you are wrong. I'm just pointing out that not
everyone
works and learns the way you do. I don't single step debuggers to
examine other people's applications
Thats fine Nick : I dont expect you too - but you seem to have strong
reasons for making a point against it whereas I see *only* benefits.
using a debugger to examine existing applications
We wont get into the pissing contest of who has worked on more
apps/platforms etc but I find it a good teaching tool to get people up
to speed with an app and its internal data structures : modify on the
fly, symbol tables etc. Cant do that with a print out or printfs.
*examining* existing applications and other examples, yes.
*stepping* existing applications and other examples, no.
for me "examining" is "stepping" : but obviously with some
strategically placed break points and a few retunr to callers etc
right. BUT NOT IN A DEBUGGER
Really : in a debugger. Do you really advocate printfs over a debugger
in a huge code base? How do you map data values to their equivalent
constants? To me it sounds incredible. If you hadnt mentioned ddd I
would wonder if we are talking about the same thing.
really? *all* universities encourage the use of stepping?
Do you have statistics?
Maybe stepping is the key word here : it does not mean every line. It
means strategically placed break points and data analysis at those
points. It is an art.
Could you go back and *read* what I and other posters have actually
been saying?
I did. Some people seem to think that a debugger is just for finding
bugs : it is not. It is also useful for examining runtime trends. Far
more useful than hard to decipher printfs, especially in a non console mode.
yes! absoloutly!
well you don't "add to an existing module" by using a debugger.
Of course you do. You use it to examine the data flow between the
system and your module.
yes yes
I think I'll give up here. My point wasn't that important. Just trying
to
make the point that different people do thinks in different ways. Linux
is not the only platform. Not everyone uses debuggers the way you do
Nobody said it was : you came flying in with that. The OP had
expressed an intrest in Linux and the fact that it comes with free
industry strength compilers and debuggers as well as hundreds of rock
solid C apps complete with build packages makes it a good bet for
someone to learn how to structure and analyse an application in
C. Windows can not compete with that IMO.
(some people only use them when they suspect a compiler error). A
If there is a compile error, you wont be using a debugger.
newbie should be aware there are different ways to do things and not
lock themselves into a particular approach too early.
A newbie needs to examine other peoples stuff : especially when
adding/fixing bugs. Approaches vary, but it can never hurt to get down
and dirty to be sure.
A newbie certainly shouldnt dedicate his life to printf()'s : they
simply do not work in a lot of environments, are inflexible, and only
show the data that you WANT to see, not the data you SHOULD see. This
is where a debuggers "locals" view etc comes in. You see alllocal
data. Not what someone thinks they need to see.
Maybe I'll even get my debugger out and step through a program
sometime to see if it brings me any insights. Maybe you should try
a "debugger free day" and try and see what you have to do to manage
without. Try reasoning about the program. Consider invariants and
post/pre conditions. Try adding asserts etc.
If you recall I did mention that a home brew logging system is
prefential to printf : I have nothing against them and have
implemented many with various backend report generators to examine the
data. A debugger isnt the only tool : and I never said it was. What it
can do is allow you to see the flow of an application while watching
live data, allow you to modify that data and to examine and ensure
data typing is consistant from skillful use of register/pointer/memory
examinations : it is why they exist.
no way is the One True Way
And no where did I say it was. The whole crux here is you doubting
that stepping an existing app can help a user understand it : after
many, many and varied projects on various platforms in various
languages I find it incredulous how you could doubt this would be
beneficial. In order to even put in these printfs() you need some
understanding of whats going : that does not come from a print out all
the time. It does not some from a func spec which is not always
there. It does not come from holistic overview : it comes from
stepping through and examining what is going on. From finding out when
and why certain modules are called. From knowing what that little bit
of bit fiddling results in, from forcing a function call at runtime in
order to test a different calling parameter. The list goes on. Of
course none of this is "the only way" : but its a good way and one
thats been used a lot for years.
Do you need a debugger for a ten line string rversal func? Maybe not :
but I'll tell you a little secret, I'd still use one to test it
rigorously before handing it in to a system for an integration
test. Total extra effort? About 5 minutes.
I realise that there is a core here who seem to think a debugger is
almost evil : I sometimes question if they have used a real
debugger on a real system in the real world where programmers are
cycled on and off projects and people want to optimise their "up to
speed" figures. I realise that according to some posters some projects
get by without a debugger : I've never had the pleasure of such a
project/system.