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


Groups > comp.lang.c > #12777

Re: Error handling

From Eric Sosman <esosman@ieee-dot-org.invalid>
Newsgroups comp.lang.c
Subject Re: Error handling
Date 2011-11-05 09:55 -0400
Organization A noiseless patient Spider
Message-ID <j93fac$mgp$1@dont-email.me> (permalink)
References <j93dqr$d4u$1@speranza.aioe.org>

Show all headers | View raw


On 11/5/2011 9:31 AM, t1t0 wrote:
> Hi all,
>
> there is a good way to obtain the 'call stack' when errors occur ?
>
> On Linux the S.O. create a core dump file with the debug information, but
> I would like to have a similar information inside the program, to log
> ever the error and send for an application/email/etc.

     C itself provides no means to do this, short of keeping track
of all the calls and returns manually.  However, many debuggers and
core-dump analyzers and so on can do this -- at least, they can
do it if the program is built in a prescribed way ("unstripped,"
for example).

     Since you're interested in generating reports of programs that
are known to be in trouble, it may be best not to rely on the dying
program itself to do its own post-mortem.  An attractive approach on
systems that allow more than one program to execute (again, this is
beyond the realm of the C language) is to write a simple "watchdog"
program that just observes the "worker" program.  If the worker runs
to completion successfully, the watchdog just exits silently.  But if
the worker completes unsuccessfully or abnormally, the watchdog can
scoop up core dumps or whatever other last-gasp breadcrumbs the worker
was able to strew.  Since the watchdog is (presumably) not subject to
the same error that brought down the worker, it has a better chance of
getting the job done than the dying worker does.

     However, all this is well outside what the C language provides.
The systems in which you run C programs quite probably offer some
tools to help with this sort of thing, but C itself does not.

-- 
Eric Sosman
esosman@ieee-dot-org.invalid

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


Thread

Error handling t1t0 <t1t0@noemail.not> - 2011-11-05 13:31 +0000
  Re: Error handling Eric Sosman <esosman@ieee-dot-org.invalid> - 2011-11-05 09:55 -0400
    Re: Error handling t1t0 <t1t0@noemail.not> - 2011-11-05 18:37 +0000
      Re: Error handling Eric Sosman <esosman@ieee-dot-org.invalid> - 2011-11-05 14:50 -0400
        Re: Error handling t1t0 <t1t0@noemail.not> - 2011-11-06 10:36 +0000
      Re: Error handling Kaz Kylheku <kaz@kylheku.com> - 2011-11-06 01:15 +0000
        Re: Error handling t1t0 <t1t0@noemail.not> - 2011-11-06 10:44 +0000
          Re: Error handling Nick Keighley <nick_keighley_nospam@hotmail.com> - 2011-11-06 06:02 -0800
          Re: Error handling Kaz Kylheku <kaz@kylheku.com> - 2011-11-06 16:21 +0000
  Re: Error handling Nobody <nobody@nowhere.com> - 2011-11-05 14:10 +0000
  Re: Error handling Kaz Kylheku <kaz@kylheku.com> - 2011-11-05 15:31 +0000
  Re: Error handling Mike Manilone <zhtx10@gmail.com> - 2011-11-06 03:56 +0000

csiph-web