Chapter Contents |
Previous |
Next |
btrace |
Portability: | SAS/C extension |
SYNOPSIS | |
DESCRIPTION | |
RETURN VALUE | |
EXAMPLE | |
SEE ALSO |
SYNOPSIS |
#include <lclib.h> void btrace(void (*fp)(const char *));
DESCRIPTION |
btrace
generates a library traceback similar to the traceback generated when an ABEND
occurs.
btrace
is useful for debugging
or diagnosing error conditions.
fp
may be
NULL
or a pointer to a function. If it is
NULL
, then
btrace
writes the traceback
to
stderr
(the standard error file). If
fp
is not
NULL
,
then
btrace
calls the function for each
line of the traceback. One traceback line, in the form of a string, is passed
to the function. (The traceback line does not terminate in a newline character.)
RETURN VALUE |
btrace
has no return value.
EXAMPLE |
This example defines a function to write traceback lines to a file:
#include <lclib.h> #include <stdio.h> static void btrace_out(const char *line) { static FILE *tbf; /* If first call, open traceback file. */ if (tbf == NULL) { tbf = fopen("TRACBACK", "w"); if (tbf == NULL) exit(12); } /* Write one line of traceback information. */ fputs(line, tbf); putc('\n', tbf); } /* Define a function to send a message */ /* to stderr and then call btrace(). */ void genbtrac(char *msg) { fputs(msg, stderr); btrace(&btrace_out); fputs("Traceback generated.\n", stderr); exit(12); }
SEE ALSO |
Chapter Contents |
Previous |
Next |
Top of Page |
Copyright © 2001 by SAS Institute Inc., Cary, NC, USA. All rights reserved.