[LCP]debugging?

Bill Rausch BRausch at owt.com
Mon Feb 7 10:17:02 UTC 2005


At 19:40 -0500 2/6/05, Zachary Uram wrote:
>hi,
>
>i would like to know any tips on debugging.
>
>if my program halts with "Segmentation fault - core dumped" how can i
>diagnose this?
>
>how can i check if my memory management was good?
>
>PS: What is "stubbing a function" ? (code example)
>
>zach

Stub is a replacement function that you use to test a program. For 
example, if a program calls a function that does lots of complex 
stuff, you could replace the function with something really simple 
that takes the same parameters but skips the calculation. This allows 
you to test the calling routine without worrying about the details of 
the called function.

Segmentation fault is almost always a bad pointer or bad parameter 
passed to a function.  For example, you malloc some space for a 
pointer x, later you free it, and then even later you use x as though 
you hadn't freed it. It will compile ok, and might even run ok most 
of the time but once in a while you'll get in trouble because once 
you've freed it you are never supposed to refer to it again until you 
malloc some new space.

-- 
Bill Rausch

The best things in life are nearest: Breath in your nostrils, light in your
eyes, flowers at your feet, duties at your hand, the path of right just
before you. -Robert Louis Stevenson, novelist, essayist, and poet
(1850-1894)




More information about the linuxCprogramming mailing list