Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.programming > #812

Re: How to implement diagnostic messages?

From BGB <cr88192@hotmail.com>
Newsgroups comp.programming
Subject Re: How to implement diagnostic messages?
Date 2011-09-11 11:48 -0700
Organization albasani.net
Message-ID <j4ivps$tmc$1@news.albasani.net> (permalink)
References <4e68c9ed$0$31290$a729d347@news.telepac.pt> <j4eab1$gaq$1@dont-email.me> <4e6cf2ca$0$31289$a729d347@news.telepac.pt>

Show all headers | View raw


On 9/11/2011 10:41 AM, Rui Maciel wrote:
> James Waldby wrote:
>
>> During development of complex code in C, I add (and later remove)
>> many ephemeral printf's.  If it seems probable that I might want to
>> reinstate a printf later, I might comment it out, or preface it by
>> if(0), or save a versioned copy.
>>
>> On those rare occasions where I'm trying to find the point in the
>> program where a seg-fault or similar problem is occurring, I add the
>> letter z at the fronts of several lines, where z invokes a macro
>> defined as follows:
>> #define z fprintf(stderr,"%s@%3d \n",__FILE__,__LINE__);
>> Then a few program runs, with z's added or removed as necessary,
>> will serve to pinpoint the error.  It sometimes is necessary to
>> add if() conditions before the fprintf(), or add critical variables
>> to the fprintf() to make sense of what is happening.
>
> Nice one.  If you don' mind, I'm going to add that to my bag of tricks.  Not
> that I ever write code that segfaults... *cough*
>

on the up-side, segfaults are often on the easier end of things to debug.

on the downside, some things are far worse...


more fun is trying to track down where some code, somewhere, writes to a 
bad address, causing problems in potentially an entirely different part 
of the program.

Back to comp.programming | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

How to implement diagnostic messages? Rui Maciel <rui.maciel@gmail.com> - 2011-09-08 14:58 +0100
  Re: How to implement diagnostic messages? BGB <cr88192@hotmail.com> - 2011-09-08 10:57 -0700
    Re: How to implement diagnostic messages? Ben Bacarisse <ben.usenet@bsb.me.uk> - 2011-09-08 20:53 +0100
      Re: How to implement diagnostic messages? BGB <cr88192@hotmail.com> - 2011-09-08 14:14 -0700
        Re: How to implement diagnostic messages? "Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de> - 2011-09-09 09:30 +0200
    Re: How to implement diagnostic messages? Rui Maciel <rui.maciel@gmail.com> - 2011-09-11 18:27 +0100
      Re: How to implement diagnostic messages? BGB <cr88192@hotmail.com> - 2011-09-11 11:44 -0700
  Re: How to implement diagnostic messages? Ian Collins <ian-news@hotmail.com> - 2011-09-09 10:33 +1200
    Re: How to implement diagnostic messages? Rui Maciel <rui.maciel@gmail.com> - 2011-09-11 18:33 +0100
  Re: How to implement diagnostic messages? James Waldby <not@valid.invalid> - 2011-09-10 00:17 +0000
    Re: How to implement diagnostic messages? Rui Maciel <rui.maciel@gmail.com> - 2011-09-11 18:41 +0100
      Re: How to implement diagnostic messages? BGB <cr88192@hotmail.com> - 2011-09-11 11:48 -0700
        Re: How to implement diagnostic messages? Ian Collins <ian-news@hotmail.com> - 2011-09-12 08:47 +1200
          Re: How to implement diagnostic messages? BGB <cr88192@hotmail.com> - 2011-09-11 14:56 -0700
            Re: How to implement diagnostic messages? Ian Collins <ian-news@hotmail.com> - 2011-09-12 15:00 +1200

csiph-web