Cross Reference: debug.c
xref
: /
ast
/
src
/
lib
/
libtksh
/
src
/
debug.c
Home
History
Annotate
Line#
Navigate
Download
Search
only in
./
debug.c revision 3f54fd611f536639ec30dd53c48e5ec1897cc7d9
949
N/A
#
pragma
prototyped
949
N/A
#
ifndef
DEBUG
949
N/A
949
N/A
int
_STUB_debug
;
/* Some compilers require a statement in the file */
949
N/A
949
N/A
#
else
949
N/A
949
N/A
#
include
"
tkshlib.h
"
949
N/A
#
include
<
ast.h
>
949
N/A
949
N/A
static
int
debugLevel
,
debugInitialized
;
949
N/A
static
void
dinit
(
void
);
949
N/A
static
void
printState
(
char
*
file
,
int
line
);
949
N/A
static
Sfio_t
*
outFile
;
949
N/A
static
Interp
*
debugInterp
;
949
N/A
1176
N/A
int
__dprintfLevel
()
949
N/A
{
949
N/A
return
debugLevel
;
949
N/A
}
949
N/A
1176
N/A
void
__dprintfInterp
(
Tcl_Interp
*
interp
)
949
N/A
{
949
N/A
debugInterp
= (
Interp
*)
interp
;
949
N/A
}
1176
N/A
1176
N/A
int
__dprintfOK
(
char
*
file
,
int
line
,
int
level
)
1176
N/A
{
949
N/A
if
(!
debugInitialized
)
949
N/A
dinit
();
949
N/A
if
(
debugLevel
<
level
)
949
N/A
return
0;
949
N/A
printState
(
file
,
line
);
1176
N/A
return
1
;
1176
N/A
}
1176
N/A
949
N/A
void
__dprintf
(
char
*
format
,
char
*
a1
,
char
*
a2
,
char
*
a3
,
char
*
a4
,
949
N/A
char
*
a5
,
char
*
a6
,
char
*
a7
,
char
*
a8
,
char
*
a9
,
char
*
a10
)
949
N/A
{
949
N/A
sfprintf
(
outFile
,
format
,
a1
,
a2
,
a3
,
a4
,
a5
,
a6
,
a7
,
a8
,
a9
,
a10
);
949
N/A
}
1176
N/A
1176
N/A
void
__dprintfNum
(
char
*
before
,
int
num
,
char
*
after
)
1176
N/A
{
949
N/A
sfprintf
(
outFile
,
"%s%d%s"
,
before
,
num
,
after
);
949
N/A
}
949
N/A
949
N/A
void
__dprintfArgs
(
char
*
string
,
int
argc
,
char
*
argv
[])
949
N/A
{
1176
N/A
int
arg
;
1176
N/A
sfprintf
(
outFile
,
string
);
1176
N/A
if
(
argc
)
949
N/A
{
949
N/A
for
(
arg
=0;
arg
<
argc
;
arg
++)
949
N/A
sfprintf
(
outFile
,
" <%.10s>"
,
argv
[
arg
]);
949
N/A
}
949
N/A
else
949
N/A
{
949
N/A
for
(
arg
=0;
argv
[
arg
];
arg
++)
949
N/A
sfprintf
(
outFile
,
" <%.10s>"
,
argv
[
arg
]);
949
N/A
}
949
N/A
sfprintf
(
outFile
,
"\n"
);
1176
N/A
}
1176
N/A
1176
N/A
static
void
dinit
()
949
N/A
{
949
N/A
char
*
lev
;
949
N/A
949
N/A
debugInitialized
=
1
;
949
N/A
if
((
lev
=
getenv
(
"JDEBUG"
)))
1176
N/A
{
1176
N/A
debugLevel
=
atoi
(
lev
);
1176
N/A
if
(
debugLevel
== 0)
949
N/A
debugLevel
=
1
;
949
N/A
/* outFile = sfopen(NIL(Sfio_t *), "goober", "w+"); */
949
N/A
outFile
=
sfstderr
;
949
N/A
sfprintf
(
outFile
,
"Debug routines initialized,compiled %s %s\n"
,
949
N/A
__DATE__
,
__TIME__
);
1176
N/A
}
1176
N/A
}
1176
N/A
949
N/A
static
void
printState
(
char
*
file
,
int
line
)
949
N/A
{
949
N/A
sfprintf
(
outFile
,
"[%s]%s:%d: "
,
949
N/A
Tksh_InterpString
(
debugInterp
->
interpType
),
file
,
line
);
949
N/A
}
1176
N/A
1176
N/A
1176
N/A
#
endif
949
N/A