0707070000020063011006640001460001440000010520720357512565500000500000000004Size150 0707070000020063461006640001460001440000010543420360430631100000500000000051NameCTRACE for the UNIX PC - from THE STORE! 0707070000020063321007750001460001440000010520740357512533600000700000000325Removeecho "Removing CTRACE for the UNIX PC" rm -f /usr/lbin/ctrace echo "Removing CTRACE libraries: /usr/lbin/ctrace_lib" rm -fr /usr/lbin/ctrace_lib message -i "CTRACE has been removed.\n\nTouch to continue." 0707070000020063221007740001460001440000010520760357512533600001000000002175Installcat < to continue END read dummy BINDIR=/usr/lbin MANDIR=/usr/man LIBDIR=${BINDIR}/ctrace_lib for directory in ${MANDIR} ${BINDIR} ${LIBDIR} do if [ ! -d ${directory} ] then echo "Creating directory ${directory}" mkdir ${directory} fi done if [ ! -s ${BINDIR}/man ] then echo "Installing primitive man(1) command in ${BINDIR}" ln man ${BINDIR}/man chmod +x ${BINDIR}/man chown bin ${BINDIR}/man chgrp bin ${BINDIR}/man fi ln ctrace ${BINDIR}/ctrace ln 1.ctrace ${MANDIR}/1.ctrace ln ctrace.1 ${HOME}/Filecabinet/ctrace.1 ln runtime.c ${LIBDIR}/runtime.c chmod +x ${BINDIR}/ctrace chown bin ${BINDIR}/ctrace chgrp bin ${BINDIR}/ctrace for file in runtime.c do chown bin ${LIBDIR}/${file} chgrp bin ${LIBDIR}/${file} done message -i "CTRACE installation is now complete.\nA manual page is available with the man(1) command.\n\nTouch to continue." 0707070000020062761006640001460001440000010521000357512533600000600000000160Files./Size ./Name ./Remove ./Install ./Files ./MAKEcpio ./MAKEflop ./1.ctrace ./ctrace ./ctrace.1 ./man ./runtime.c 0707070000020063051007740001460001440000010521020357512572000001100000000043MAKEcpiocat Files | cpio -ocBv > CTRACE+IN 0707070000020063131007740001460001440000010521030357512533700001100000000061MAKEflopcat Files | cpio -ocBv > /dev/rfp021 dismount -f 07070700000200632510066400014600014400000105210403575125534000011000000436071.ctrace CCCCTTTTRRRRAAAACCCCEEEE((((1111)))) UUUUNNNNIIIIXXXX 5555....0000 CCCCTTTTRRRRAAAACCCCEEEE((((1111)))) NNNNAAAAMMMMEEEE ctrace - C program debugger SSSSYYYYNNNNOOOOPPPPSSSSIIIISSSS ccccttttrrrraaaacccceeee [ options ] [ file ] DDDDEEEESSSSCCCCRRRRIIIIPPPPTTTTIIIIOOOONNNN _C_t_r_a_c_e allows you to follow the execution of a C program, statement by statement. The effect is similar to executing a shell procedure with the ----xxxx option. _C_t_r_a_c_e reads the C program in _f_i_l_e (or from standard input if you do not specify _f_i_l_e), inserts statements to print the text of each executable statement and the values of all variables referenced or modified, and writes the modified program to the standard output. You must put the output of _c_t_r_a_c_e into a temporary file because the _c_c(1) command does not allow the use of a pipe. You then compile and execute this file. As each statement in the program executes it will be listed at the terminal, followed by the name and value of any variables referenced or modified in the statement, followed by any output from the statement. Loops in the trace output are detected and tracing is stopped until the loop is exited or a different sequence of statements within the loop is executed. A warning message is printed every 1000 times through the loop to help you detect infinite loops. The trace output goes to the standard output so you can put it into a file for examination with an editor or the _b_f_s(1) or _t_a_i_l(1) commands. The only _o_p_t_i_o_n_s you will commonly use are: ----ffff _f_u_n_c_t_i_o_n_s Trace only these _f_u_n_c_t_i_o_n_s. ----vvvv _f_u_n_c_t_i_o_n_s Trace all but these _f_u_n_c_t_i_o_n_s. You may want to add to the default formats for printing variables. Long and pointer variables are always printed as signed integers. Pointers to character arrays are also printed as strings if appropriate. Char, short, and int variables are also printed as signed integers and, if appropriate, as characters. Double variables are printed as floating point numbers in scientific notation. You can request that variables be printed in additional formats, if appropriate, with these _o_p_t_i_o_n_s: ----oooo Octal ----xxxx Hexadecimal ----uuuu Unsigned ----eeee Floating point These _o_p_t_i_o_n_s are used only in special circumstances: Page 1 (printed 12/4/85) CCCCTTTTRRRRAAAACCCCEEEE((((1111)))) UUUUNNNNIIIIXXXX 5555....0000 CCCCTTTTRRRRAAAACCCCEEEE((((1111)))) ----llll _n Check _n consecutively executed statements for looping trace output, instead of the default of 20. Use 0 to get all the trace output from loops. ----ssss Suppress redundant trace output from simple assignment statements and string copy function calls. This option can hide a bug caused by use of the = operator in place of the == operator. ----tttt _n Trace _n variables per statement instead of the default of 10 (the maximum number is 20). The Diagnostics section explains when to use this option. ----PPPP Run the C preprocessor on the input before tracing it. You can also use the ----DDDD, ----IIII, and ----UUUU _c_c(1) preprocessor options. These _o_p_t_i_o_n_s are used to tailor the run-time trace package when the traced program will run in a non-UNIX system environment: ----bbbb Use only basic functions in the trace code, that is, those in _c_t_y_p_e(3C), _p_r_i_n_t_f(3S), and _s_t_r_i_n_g(3C). These are usually available even in cross-compilers for microprocessors. In particular, this option is needed when the traced program runs under an operating system that does not have _s_i_g_n_a_l(2), _f_f_l_u_s_h(3S), _l_o_n_g_j_m_p(3C), or _s_e_t_j_m_p(3C). ----pppp '_s' Change the trace print function from the default of 'printf('. For example, 'fprintf(stderr,' would send the trace to the standard error output. ----rrrr ffff Use file _f in place of the _r_u_n_t_i_m_e._c trace function package. This lets you change the entire print function, instead of just the name and leading arguments (see the ----pppp option). EEEEXXXXAAAAMMMMPPPPLLLLEEEE If the file _l_c._c contains this C program: 1 #include 2 main() /* count lines in input */ 3 { 4 int c, nl; 5 6 nl = 0; 7 while ((c = getchar()) != EOF) 8 if (c = '\n') 9 ++nl; 10 printf("%d\n", nl); 11 } and you enter these commands and test data: cc lc.c a.out Page 2 (printed 12/4/85) CCCCTTTTRRRRAAAACCCCEEEE((((1111)))) UUUUNNNNIIIIXXXX 5555....0000 CCCCTTTTRRRRAAAACCCCEEEE((((1111)))) 1 (cntl-d) the program will be compiled and executed. The output of the program will be the number 2222, which is not correct because there is only one line in the test data. The error in this program is common, but subtle. If you invoke _c_t_r_a_c_e with these commands: ctrace lc.c >temp.c cc temp.c a.out the output will be: 2 main() 6 nl = 0; /* nl == 0 */ 7 while ((c = getchar()) != EOF) The program is now waiting for input. If you enter the same test data as before, the output will be: /* c == 49 or '1' */ 8 if (c = '\n') /* c == 10 or '\n' */ 9 ++nl; /* nl == 1 */ 7 while ((c = getchar()) != EOF) /* c == 10 or '\n' */ 8 if (c = '\n') /* c == 10 or '\n' */ 9 ++nl; /* nl == 2 */ 7 while ((c = getchar()) != EOF) If you now enter an end of file character (cntl-d) the final output will be: /* c == -1 */ 10 printf("%d\n", nl); /* nl == 2 */2 /* return */ Note that the program output printed at the end of the trace line for the nnnnllll variable. Also note the rrrreeeettttuuuurrrrnnnn comment added by _c_t_r_a_c_e at the end of the trace output. This shows the implicit return at the terminating brace in the function. The trace output shows that variable cccc is assigned the value Page 3 (printed 12/4/85) CCCCTTTTRRRRAAAACCCCEEEE((((1111)))) UUUUNNNNIIIIXXXX 5555....0000 CCCCTTTTRRRRAAAACCCCEEEE((((1111)))) '1' in line 7, but in line 8 it has the value '\n'. Once your attention is drawn to this iiiiffff statement, you will probably realize that you used the assignment operator (=) in place of the equal operator (==). You can easily miss this error during code reading. EEEEXXXXEEEECCCCUUUUTTTTIIIIOOOONNNN----TTTTIIIIMMMMEEEE TTTTRRRRAAAACCCCEEEE CCCCOOOONNNNTTTTRRRROOOOLLLL The default operation for _c_t_r_a_c_e is to trace the entire program file, unless you use the ----ffff or ----vvvv options to trace specific functions. This does not give you statement by statement control of the tracing, nor does it let you turn the tracing off and on when executing the traced program. You can do both of these by adding _c_t_r_o_f_f() and _c_t_r_o_n() function calls to your program to turn the tracing off and on, respectively, at execution time. Thus, you can code arbitrarily complex criteria for trace control with _i_f statements, and you can even conditionally include this code because _c_t_r_a_c_e defines the CCCCTTTTRRRRAAAACCCCEEEE preprocessor variable. For example: #ifdef CTRACE if (c == '!' && i > 1000) ctron(); #endif You can also call these functions from _s_d_b(1) if you compile with the ----gggg option. For example, to trace all but lines 7 to 10 in the main function, enter: sdb a.out main:7b ctroff() main:11b ctron() r You can also turn the trace off and on by setting static variable tr_ct_ to 0 and 1, respectively. This is useful if you are using a debugger that cannot call these functions directly, such as _a_d_b(1). DDDDIIIIAAAAGGGGNNNNOOOOSSSSTTTTIIIICCCCSSSS This section contains diagnostic messages from both _c_t_r_a_c_e and _c_c(1), since the traced code often gets some _c_c warning messages. You can get _c_c error messages in some rare cases, all of which can be avoided. CCCCttttrrrraaaacccceeee DDDDiiiiaaaaggggnnnnoooossssttttiiiiccccssss _w_a_r_n_i_n_g: _s_o_m_e _v_a_r_i_a_b_l_e_s _a_r_e _n_o_t _t_r_a_c_e_d _i_n _t_h_i_s _s_t_a_t_e_m_e_n_t Only 10 variables are traced in a statement to prevent the C compiler "out of tree space; simplify expression" error. Use the ----tttt option to increase this number. Page 4 (printed 12/4/85) CCCCTTTTRRRRAAAACCCCEEEE((((1111)))) UUUUNNNNIIIIXXXX 5555....0000 CCCCTTTTRRRRAAAACCCCEEEE((((1111)))) _w_a_r_n_i_n_g: _s_t_a_t_e_m_e_n_t _t_o_o _l_o_n_g _t_o _t_r_a_c_e This statement is over 400 characters long. Make sure that you are using tabs to indent your code, not spaces. _c_a_n_n_o_t _h_a_n_d_l_e _p_r_e_p_r_o_c_e_s_s_o_r _c_o_d_e, _u_s_e -_P _o_p_t_i_o_n This is usually caused by #ifdef/#endif preprocessor statements in the middle of a C statement, or by a semicolon at the end of a #define preprocessor statement. '_i_f ... _e_l_s_e _i_f' _s_e_q_u_e_n_c_e _t_o_o _l_o_n_g Split the sequence by removing an eeeellllsssseeee from the middle. _p_o_s_s_i_b_l_e _s_y_n_t_a_x _e_r_r_o_r, _t_r_y -_P _o_p_t_i_o_n Use the ----PPPP option to preprocess the _c_t_r_a_c_e input, along with any appropriate ----DDDD, ----IIII, and ----UUUU preprocessor options. If you still get the error message, check the Warnings section below. CCCCcccc DDDDiiiiaaaaggggnnnnoooossssttttiiiiccccssss _w_a_r_n_i_n_g: _f_l_o_a_t_i_n_g _p_o_i_n_t _n_o_t _i_m_p_l_e_m_e_n_t_e_d _w_a_r_n_i_n_g: _i_l_l_e_g_a_l _c_o_m_b_i_n_a_t_i_o_n _o_f _p_o_i_n_t_e_r _a_n_d _i_n_t_e_g_e_r _w_a_r_n_i_n_g: _s_i_z_e_o_f _r_e_t_u_r_n_s _0 _w_a_r_n_i_n_g: _s_i_z_e_o_f _r_e_t_u_r_n_s _v_a_l_u_e _l_e_s_s _t_h_a_n _o_r _e_q_u_a_l _t_o _z_e_r_o _w_a_r_n_i_n_g: _s_t_a_t_e_m_e_n_t _n_o_t _r_e_a_c_h_e_d Ignore these messages. _c_o_m_p_i_l_e_r _t_a_k_e_s _s_i_z_e _o_f _f_u_n_c_t_i_o_n See the _c_t_r_a_c_e "possible syntax error" message above. _y_a_c_c _s_t_a_c_k _o_v_e_r_f_l_o_w See the _c_t_r_a_c_e "'if ... else if' sequence too long" message above. _o_u_t _o_f _t_r_e_e _s_p_a_c_e; _s_i_m_p_l_i_f_y _e_x_p_r_e_s_s_i_o_n Use the ----tttt option to reduce the number of traced variables per statement from the default of 10. Ignore the "ctrace: too many variables to trace" warnings you will now get. _r_e_d_e_c_l_a_r_a_t_i_o_n _o_f _s_i_g_n_a_l Either correct this declaration of _s_i_g_n_a_l(2), or remove it and #include . _u_n_i_m_p_l_e_m_e_n_t_e_d _s_t_r_u_c_t_u_r_e _a_s_s_i_g_n_m_e_n_t This is caused by a bug in the C compiler for the PDP-11. Use _p_c_c(1) instead of _c_c(1). _e_x_p_r_e_s_s_i_o_n _c_a_u_s_e_s _c_o_m_p_i_l_e_r _l_o_o_p: _t_r_y _s_i_m_p_l_i_f_y_i_n_g This is caused by a bug in the UNIX/370 C compiler. Unfortunately, the only way to avoid it is to use the Page 5 (printed 12/4/85) CCCCTTTTRRRRAAAACCCCEEEE((((1111)))) UUUUNNNNIIIIXXXX 5555....0000 CCCCTTTTRRRRAAAACCCCEEEE((((1111)))) _c_t_r_a_c_e ----vvvv option to not trace the function containing this line. WWWWAAAARRRRNNNNIIIINNNNGGGGSSSS You will get a _c_t_r_a_c_e syntax error if you omit the semicolon at the end of the last element declaration in a structure or union, just before the right brace (}). This is optional in some C compilers. Defining a function with the same name as a system function may cause a syntax error if the number of arguments is changed. Just use a different name. _C_t_r_a_c_e assumes that BADMAG is a preprocessor macro, and that EOF and NULL are #defined constants. Declaring any of these to be variables, e.g. "int EOF;", will cause a syntax error. BBBBUUUUGGGGSSSS _C_t_r_a_c_e does not know about the components of aggregates like structures, unions, and arrays. It cannot choose a format to print all the components of an aggregate when an assignment is made to the entire aggregate. _C_t_r_a_c_e may choose to print the address of an aggregate or use the wrong format (e.g., %e for a structure with two integer members) when printing the value of an aggregate. Pointer values are always treated as pointers to character strings. The loop trace output elimination is done separately for each file of a multi-file program. This can result in functions called from a loop still being traced, or the elimination of trace output from one function in a file until another in the same file is called. FFFFIIIILLLLEEEESSSS runtime.c run-time trace package SSSSEEEEEEEE AAAALLLLSSSSOOOO ctc(1), signal(2), ctype(3C), fflush(3S), longjmp(3C), printf(3S), setjmp(3C), string(3C) in the _U_N_I_X _S_y_s_t_e_m _P_r_o_g_r_a_m_m_e_r _R_e_f_e_r_e_n_c_e _M_a_n_u_a_l. AAAAUUUUTTTTHHHHOOOORRRR Joe Steffen Page 6 (printed 12/4/85) 0707070000020063141007750001460001440000010521270357512540400000700000103674ctraceR& >C& .text> .data CD@.bss C C&.lib jf jf/< jfN1X OQ./HJf/H#0N# 4`2.N.j`$p# ( n A# C`VpѮ n -P n -g.N1 U"n 1.fp `&.N1 ro nB(R @SnR` nPpѮ nJfopѮ n -P n 0m 9n.N1V-@f .tf.HH./< `.HH lg& tf&#   op# `# ,SopѮ n P -g#0 5JoL n # 8. n/9 8N1RX @# 5f$. 8/< p/<0N1Pp.N1xJ gp. /9 8N1XJg. 8/9 CNRX @# C. /9 CN1X @# 5f. /<0N1Xp.N1x. N1J fJ gJ $g . N1. 8/< N1XN-J $fN S0mr y0R0r `n nHH./< /<0N1P. /<0N1X. */<0N1Xp.N1xR`,.0p /N1XJ DgJ gJ $gN"NN^NuNVH. N1 $.N1 ЂX./.N1NX @-Hf. /<0N1Xp.N1x. /.N1X. /.N1X. /.N1X n LN^NuNVJ (gB M`p# MB . @l4"y C./.N1XJf,J (g p# M`B MJ Mgp# DN^NuR`NVHJ ?hg. N1. +`J f . UN1J ?lfJ f . iN1. /< ~N1X. 0/< N1XJ g . N1J g . N1J g . N1J g . N1J g . N1J ,g. ,/< N1XJ $g. `. N1. 'HnN1XJ 4g. 4HnN1X. FHnN1RX @$H f&Hn/< H/<0N1 p.N1xHn/< rN1P`. y0R0"`.0 2/N1XSm jRp`.N1$pg S0m`LN^NuNV.Np# t/< /<0N1PN^NuNV  Y [>d`J `f pL<N^Nup# ` "| &1 oJ `lNx# `lB `ֹ `m^ Vm`T "| b&1 "| (^ 1 `f0p# ` | M"| M"""$J `oS `` "| .B&1pfJ `lNx# `lB `*| `P f -f`d. D(N.j`B `p# `J f.` *rl *`p# C. | ` //< D(N1P 9 C"| D(`J g# >t C CpO. | ` //< CN1P`x# M"`bJ gX *rl *`p# C. | ` //< CN1P 9 C"| CB1`. aN/p# `. CN0. 4N1`rB B J fp./< 4p/`. aN/# >t CpP./< ` /< CN1PB `tJ gB `p./< C/9 CN=&Pp# `@J gB `p./< ` /9 >tN=&P. aN/`B `. aN/`p./< ` /9 >tN=&P`N/`p./< ` /9 >tN=&P. ap/N4XN0S0l.0p{/N1X`xS0l .0p}/N1X`X. aN/S0m y0R0r{`.0p{/N1Xp./< ` /9 >tN=&`S0l.0p}/N1X`p./< ` /9 >tN=&P.p/N4Xp./< ` /9 >tN=&P *g>J Mg6J 5f.S0m y0R0r,`.0p,/N1X. a/*N4XN0S0l.0p{/N1X`$S0l.0p}/N1X`.p/N4Xp./< ` /9 >tN=&PJ Mg6J 5f.S0m y0R0r,`.0p,/N1X. a/*N4XN0S0m y0R0r{`,.0p{/N1X`XS0m y0R0r}`:.0p}/N1X`$p./< ` /9 >tN=&PS0m y0R0r}`.0p}/N1X. ap/N4XN0`p./< ` /9 >tN=&P. ap/N4XN0p# ` *# M"# M`r# M"`J# M" o *`p"*o ` o *`p# M& gA./(/(N2PJ gJgJ g| fp./*/*`X# M" o *`p"*o ` o *`p# M& gA./(/(N2Pp./*/*`J# M" o *`p"*o ` o *`p"*زnP o *`p"*n4 o *`p# M&` fp./*//*/*/*N1`# M"# M& f./*/*/*/*`# M"B M& fp# M&./*/*`4# M"B M&`># M" o *`p# M& fp./*//*/*/*N1`# M" o *`p# M& gp./*/*/*/*/*N1`# M" o *`p# M& glp./*/*A/(/(/(N1`@# M"# M&`,# M" *䰪n *# M& gp# M&`# M"p# M&`A./(/(N3hP# M"p`# M"# M&./*A`.p`# M"# M& f./*A/(/(/(N2`X# M"p# M&g@p`# M"p# M&g$p./*/*A`# M"p# M&g(p./*/*A/(/(/(N1 gJgp./*/*A/(/(/(N1`# M"p# M&gzp./*/*A/(/(/(`# M"p# M&gBJ g(Jf"B M&A./(/(N2P`J g, f"p# M&A./(/(N2P`8 g.Jg(p./*/*A/(/(/(N1p./*/*A`* g`# M" *䰪n *# M& g.Jg(p./*/*A/(/(/(N1 g"Jgp./*/*A/(/(/(N1`# M" *䰪n *"*̲o ` *䰪n *`# M"# M& gJgp./*/*A/(/(/(N1`f[ bZ@0; NJ$JJ4>JJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJ\JJJJJJJJJJJJJJJJJJJTJJJJJJJJJD\x JJJJDNJ^44JJJJJ^JJJJJzzJzJJJHh(H(JJ|f` Rf~JJJJJJJJJ<^JJJPJm  `f&-lp`Jg# _$K "| %(1f "ЀЁA "| M""" "| !&1 则 "| 1ДR$ Vl& "| b$1 "| (^ 1"Dg$ "| 1"| b$1` "ЀЁA "| M""" "| !&1 则 "| 1ДR$ Vl$ "| b$1 "| (^ 1"Dg "| 1"| b$1# _# _# _ 9 _`NVN -@mt . #b6@0; NJ$HX 6@DPPr N JgpN^Nu | ` a# DRN y DR df 9 a"| ` 1;f . >N. DP/< D2/< >/9 DRN1 rg*. DP/< D2/< >/9 DRN1 rf./< D2N.X. >t/< >/9 DRN1Prfv >tp"./9 DRN1&X @# DVgRp"./N1,X @B y DVA.N/ @# 8f . ?Np./9 DVN1&X @"J gtp./< ?/9 DRN1PJf.`"p./< ?/9 DRN1PJf.N F`dp./< ?/9 DRN1PJf.`J gFS 5 | ` 5./< ?N1X 9 5"| ` B1# 5 ap# a`B 5J >tf. 8/< ?"N1X`L. 8/9 >t/< ?0N1P`.U aNr`JJ 5f. ` /< ?@`f# a 5p# a`J 5f # a 5# a 5p# a`J 5f# a 5p(./< ` /< aN1P`. `p'`p".Nh` 9 5 5g  5f.` | ` 5.N-`. | ` 5/N.X`x.`:.`0.`&.`.`.`.`.`. `. ` 9 a"| ` 1HH.`./< ?C/9 5 N1P`NVH a >xcp >x y >xHH`* y 5Sm y 5"hRp` . 5N1# ar fR >t` 9 arfp` 9 aHH"|0 1g. ?X/< ` N1XZ aHH# a fS >t y >xR >x aJ f.. ` /< ?^/9 5 N1P`N`HH# a fS >t y >xR >x a` /g \fJ f6 y 5 Sm y 5 "hR`. 5 0/N1X  al 9 aR a"| `  a >xcp >x y >xHH`* y 5Sm y 5"hRp` . 5N1# ar fR >t` 9 arfp` 9 aJ f y 5 Sm y 5 "hR` a >xcp >x y >xHH`* y 5Sm y 5"hRp` . 5N1# ar fR >t` 9 arfp` 9 a *f:`.. 5 0/N1X  al 9 aR a"| `  a >xcp >x y >xHH`* y 5Sm y 5"hRp` . 5N1# ar fR >t` 9 arfp` 9 a  g HH`HH# a fS >t y >xR >x a 9 a"| ` B1L N^NuNVH . ?aN1 a >xcp >x y >xHH`* y 5Sm y 5"hRp` . 5N1# ar fR >t` 9 arfp` 9 aS0m0 y0R0`6S0m y0R0`.00/N1X a >xcp >x y >xHH`* y 5Sm y 5"hRp` . 5N1# ar fR >t` 9 arfp` 9 afP`*.00/N1X *f /g`ZL N^NuNVH<. `HHJg` \f a >xcp >x y >xHH`* y 5Sm y 5"hRp` . 5N1# ar fR >t` 9 arfp` 9 a 9 aR a"| `   amN 9 aR a( a >xcp >x y >xHH`* y 5Sm y 5"hRp` . 5N1# ar fR >t` 9 arfp` 9 a"| ` f 9 a"| ` B1 < L|f (R 6fJf-jg n 6g a >xcp >x y >xHH`* y 5Sm y 5"hRp` . 5N1# ar fR >t` 9 arfp` 9 a-@"nRB-L 6o .Ѐ"L`p 6l < 6Ѐ"| 6A-H(H .ЀI =bHH"ЀЁ"| ;,Ag@ ."| =1HHЀ"nI =bZHH"ЀЁ"| ;,Af>,HH"ЀЁ"| ;,Ag4,HH"ЀЁ"| ;,E&`d$j g (R 6fp` KY cc$ nSBJg S# jbg y jbJo# j^ y jb "| >JJ1gb`6Y nSHH# a fS >t y >xR >x a y jb D. S/(NtXrg cb nHH# >|# jZ  ` R# a"| ` B1 y jbX jb LN^Nu nHH# a fS >t y >xR >x a`J9 ` f# a >xp` a >xcp >x y >xHH`* y 5Sm y 5"hRp` . 5N1# ar fR >t` 9 arfp` 9 a ` HH# >|Jo8 y 5 Sm y 5 "hR >`. 5 p9 >/N1X-| ` `NVJfpN^Nu nJgX  fp`NV a >xcp >x y >xHH`* y 5Sm y 5"hRp` . 5N1# ar fR >t` 9 arfpN^Nu 9 a`NV y 5 Sm y 5 "hR. N^Nu. 5 p. /N1X`NV# a afS >t y >xR >x aN^NuNVHt` "ЀЁ"| ?pA.NrRp/eLN^NuNVH $n.N"| DZ&q g6./ N1XJf< +f p# ?h` ,fp# ?l <L N^Nu +`&k`NV./.NXN^NuNV.Nh-@ fxp .N1B @-H.g.Nd @"n"f. BN`B n". !A-A.Nl  f . B n/N1XJfp# ?h .N^NuNV.N1 R.N1B @-Hg./N1X n N^NuNVH$n.N&$ "| DZ%q #LN^NuNVH$nt`HHԀJfp/. N1 LN^NuNV. aN . 8/9 >t/< BN1PN^NuNVH $. am.0/< ` N1Xp`nv`BS0m y0R0"| ` 18`.0 | ` r08/N1XRm | ` A(./< ` N1X 9 a# 5# aB BL N^NuNVp# 5# a# BJ Bg. BNB BJ 5g. C*N. aNB 5N^NuNVHJ MgH 9 BS$`6 "Ё"| K 1f "Ё"| K 1 gSJl` LN^NuJl 9 B氹 l|R B$ "Ё"| K~# "Ё"| K#  "Ё"| K# "Ё"| K# "Ё"| K#`jp# B`^NVH 9 BS$`l "Ё"| K~A". & "Ё"| K# "Ё"| KA". ( "Ё"| K#LN^NuJm "Ё"| K 1f( "Ё"| K 1 f g`RS`NVH$ 9 BS$`4 R"Ё* "Ё"| K~A R`@SJmD "Ё"| K 1f "Ё"| K 1 fS B洹 BmL$N^NuNVHL 9 BS$`v "Ё"| K 1mX "Ё 1 nBS B&`0 R"Ё, "Ё"| K~A R BmSJlLLN^NuNVH$. J 5f<&.` "| E>BRmv`j "Ё"| K 1"| E> "Ё"| K 1"| E> "Ё"| K 1"| E>R Bm&.` "| E>1gx` "Ё"| K 1f.NJf4. CFN1.N "Ё"| K~A./(NJX. CIN1 "Ё"| K f. CM`*LN^Nu "Ё"| K f. CTN1`" "Ё"| K~A./(NX "Ё"| K f "Ё"| K 1"| ` 1+f,S0m y0R0r-`*.0p-/N1X`.S0m y0R0r+`.0p+/N1XS0m y0R0r1`.0p1/N1XS0m y0R0r)`.0p)/N1XR Bm( "| E>1gx` "Ё"| K 1fS0m y0R0r(`.0p(/N1X.NJg.N`H "Ё"| K f. C[` "Ё"| K f . CeN1R BmTS0m y0R0"| ` 18`.0 | ` r08/N1XRl`NVH$. "Ё"| K~.1 "Ё"| K 1f" "Ё"| K-q "Ё"| K 1fv Blжg "Ё"| K~-q "Ё"| K 1m2 "Ё"| K-q "Ё"| K 1oh "Ё"| K~-q "Ё"| K 1g6 "Ё"| K-q "Ё"| K 1gR`* Bf pLN^Nup`NVH$. "Ё"| K g "Ё f. Co`. CwN1v`HH.NR | a08f. CN1 "Ё"| K~A./(NX. CN1 "Ё"| K gN "Ё g:. CN1 "Ё"| K~A./(NPX. CN1LN^NuNVH$.` | ` 0(HH.NR mLN^NuNVH S0m ."| ` 1"y0R0`.0 | ` p/N1X .R$`N "| E>1gv` "Ё"| K 1f "Ё"| K f "Ё"| K 1"| ` 1+f,S0m y0R0r-`*.0p-/N1X`.S0m y0R0r+`.0p+/N1X. CN1` "Ё"| K f0 "Ё"| K 1Sn "Ё"| K`R Bm "| E>1gv` "Ё"| K 1f "Ё"| K f.S0m y0R0r(`.0p(/N1X "Ё"| K f8 "Ё"| K~ 1So ` "Ё"| K~ 1S$`LR BmBS0m y0R0"| ` 1(`.0 | ` r0(/N1XR mL N^NuNVH J MgJ 5f. CN1JfF. CN1 n  fv` .NR`v n 08HH$ |0 0(f`L n  f@v` p fSR n 08HH$f./< CN1Xv` .N@R`v n 08HH$f. CN1Jg . CN1L N^NuNVH$.  g6 g6 "g \f.. CN1LN^Nu. C`. C`. C`S0m y0R0"`.0 2/N1X`  H Pprintf(/lib/cpp -C -DCTRACEctrace: out of storagectrace: version 3.3 ctrace: -%c option: missing or invalid numeric value ctrace: unknown option: -%c Usage: ctrace [-beosuxPV] [C preprocessor options] [-f|v functions] [-p string] [-r file] [-l number] [-t number] [file] rctrace: cannot open file %s rctrace: cannot run preprocessor#define CTRACE 1 #include #line 1 "%s" ctrace: out of storage ''#undef stdout #define stdout (&_iob[1]) #undef stderr #define stderr (&_iob[2]) #include #include #define VM_CT_ %d #define PF_CT_ %s #define O_CT_ #define X_CT_ #define U_CT_ #define E_CT_ #define B_CT_ #define LM_CT_ %d #define S_CT_ #define S_CT_ static /usr/lbin/ctrace_lib/runtime.crctrace: cannot open runtime code file %s #line 1 "%s" %s warning: %s ctrace: "%s", line %d: ctrace: see man page Diagnostics section for what to do next *(;#$%&'()*,N;N,M;MK/{*(1{!}WR4:5:N{h}]r E-, `B v!"P {20;.~7QtHQoYx=t3@|jB5[V=n7k8:<9;<O@H4:>Q=js>8Jqr} T`>SVQw KJ6KTl`SNeVGEDCQDf!"F!Tg`SV*dv/1Cu!TA`qSnVb ?aIXL>(NM 'Q&S%UT$+#R9!T_`SWV= hilkcm?AsF G owx zyM!IL6 uf[WUX_45"2+,0.3-Z)1/abcgeidh `uWUX_45"Y2+,0.3-Z)1/abcgeidh WUX_45"2+,0.3-Z)1/abcgeidh RWUX_45"2+,0.3-Z)1/abcgeidhT`SVWUXI_\]T` SVZabcgeidhT`SVT`SVT`SVWUXp_\]mZOabcgeidh!"#$%('*&)!"#$%('*&)WUX_\]WUXZ_\]abcgeidhZabcgeidhWUX_\]WUXZ_\]abcgeidhWUXZ_\]abcgeidhZabcgeidh!"!"#$%('*&)!"#$%('*&)p#$%('*&)^\  Z78P^    - 5 - P5 R7?mbbbbbbb2   bBbbbbbbbbbbbbbbbbbb bbbbbbbbbh 0 b0NwH" F!qponhbbbbbbbbb +FS,-bb<b6b9 2bbbb bbbU   A -bN~}{;Bzvut>srp<%Qonml:kjdb`^][VTSPJGEC>=;930.'7c !!$##%%&&'''''(((((()**,,++++.0.// --"12564337777<777799999::BB;;;C8DEDFG=HIHJ>K?L@MA NN OOOOOO                   ! ;*(#$%)'&*( {{,([([=)()]*& -  (#$%)'&*()))]{),,={],=?|^&+-* [( (((((((((]{}:})*(,,::])))[),,,,,,)})))}](),)),}{" );;}::((((;));:;);)")(};));) [IAX:LEF&N 6<YCGDV"$J =>Z;@78OB+W \?9VQTH',./125#%V-4]P03bSU ^cdefgh_ymnopqrjklbvxti`swub|~zbacannot handle preprocessor code, use -P optionyacc stack overflow'if ... else if' sequence too longsyntax errorpossible syntax error, try -P optionyacc stack overflowsyntax errorchar *_ctstr;int _ctint;/* return */00""" """""""" """""" """!     "  #'$ !%  ()  *3*3 ! ,- &&&&&&&&&&&&&&&&&&&&&2 &&&&&&05&050505****&**&&&&&&*+*05&0505&05005*05...*/0111.........../.0.4.4.4.4.4.4.4.4.4.4.4.4.4.4.4.4.4.4.4.4.4.4.4.4.4.4.4.4.4.4.4.4.4.4.4.4.4.4.4.4.4.4.4.4.4.4.4.4.4.4.4.4.411111111111111111111111111111111111/1101111144444444444444444444111111144444444444444444444444444444444444444444444444444441111441444444444444444444444444444444444444444444444444444411111 6 6 ;8 6 5& 7 5. 7 5> 7 5J 6 5V 7 5b 7( 5n 7 ; 5z 6 5 6 ; 5 6 ; 5 7 ; 5 7^ 5 7 ; 5 7| 5 7 ; 5 7 5 7, ; 5 5@ 5 6 ; 6 6 6 6 ;\ 6 6 6" 7 7( ;h 6* 6 62 7 6 6: 6 ; 6B 7 6 6J 6 6R 6 6Z 6 6b 6 < 6j 6 ; 6r 6 6z 6 < 6 6 6 7 6 6 6 6 6 6 < 6 96 6 6 5 3 <( 6 6 6 6 6 :* 6 6 6 ;( ;8  %%%%%.%0000000000<=<AAAAAAGGGGGAGGGGGGGGGGGAGG%GAAAAAAGGGGGAGGGGGGGGGGGAGG% a cannot handle preprocessor code, use -P optiondefine %[a-zA-Z0-9_](%*[^)]) %*[^,.=;{}]%1cdefine %[a-zA-Z0-9_] %*[^,.=;{}]%1cline %dout of storageifelen%s #line 1 "%s" #line %d "%s" %sbad switch yylook %dline %s/*%s A A A A A A A A A A A A A A A$ A B B B $ B B B B B# B, B3 B9 B@# BH BO BV B\ Bc% Bj& Bq' Bx( B) B* B B B! B B B B" B+ B,BADMAGEOFNULLautobreakcasecharcontinuedefaultdodoubleelseenumexternfgetsfloatforfortrangetsgotoifintlongregisterreturnshortsizeofsprintfstaticstderrstdinstdoutstrcatstrcmpstrcpystrlenstrncatstrncmpstructswitchtypedefunionunsignedvoidwhile_iobufjmp_bufout of storageFILE #line %d "%s" some variables are not traced in this statementstatement too long to trace, ), _ctint_ctstr_ctint = _ctstr = s_ct_("u_ct_("/* ",sizeof(),1)t_ct_("\n \n%3d "); \"\\\t\n0707070000020063311006440001460001440000010527470357512542100001100000026156ctrace.1.ig EMACS_MODES: fill .. .de DS .P .RS .nf .. .de DE .fi .RE .P .. .TH CTRACE 1 .SH NAME ctrace \- C program debugger .SH SYNOPSIS \f3ctrace\fR [ options ] [ file ] .SH DESCRIPTION .ad b \f2Ctrace\fR allows you to follow the execution of a C program, statement by statement. The effect is similar to executing a shell procedure with the \f3-x\fR option. \f2Ctrace\fR reads the C program in \f2file\fR (or from standard input if you do not specify \f2file\fR), inserts statements to print the text of each executable statement and the values of all variables referenced or modified, and writes the modified program to the standard output. You must put the output of \f2ctrace\fR into a temporary file because the \f2cc\fR(1) command does not allow the use of a pipe. You then compile and execute this file. .P As each statement in the program executes it will be listed at the terminal, followed by the name and value of any variables referenced or modified in the statement, followed by any output from the statement. Loops in the trace output are detected and tracing is stopped until the loop is exited or a different sequence of statements within the loop is executed. A warning message is printed every 1000 times through the loop to help you detect infinite loops. The trace output goes to the standard output so you can put it into a file for examination with an editor or the \f2bfs\fR(1) or \f2tail\fR(1) commands. .P The only .I options you will commonly use are: .P .PD 0 .TP 14 .BI \-f " functions\^" Trace only these .I functions. .TP .BI \-v " functions\^" Trace all but these .I functions. .PD .P You may want to add to the default formats for printing variables. Long and pointer variables are always printed as signed integers. Pointers to character arrays are also printed as strings if appropriate. Char, short, and int variables are also printed as signed integers and, if appropriate, as characters. Double variables are printed as floating point numbers in scientific notation. .ig String arguments to the .IR string (3C) functions and return values from .IR fgets (3S), .IR gets (3S), and .IR sprintf (3S) are printed as strings. .. You can request that variables be printed in additional formats, if appropriate, with these \f2options\fR: .P .PD 0 .TP 7 .B \-o Octal .TP .B \-x Hexadecimal .TP .B \-u Unsigned .TP .B \-e Floating point .PD .P These \f2options\fR are used only in special circumstances: .P .PD 0 .TP 7 .BI \-l " n\^" Check .I n consecutively executed statements for looping trace output, instead of the default of 20. Use 0 to get all the trace output from loops. .TP .B \-s Suppress redundant trace output from simple assignment statements and string copy function calls. This option can hide a bug caused by use of the = operator in place of the == operator. .TP .BI \-t " n\^" Trace .I n variables per statement instead of the default of 10 (the maximum number is 20). The Diagnostics section explains when to use this option. .TP .B \-P Run the C preprocessor on the input before tracing it. You can also use the .BR -D , .BR -I , and .B -U .IR cc (1) preprocessor options. .PD .P These \f2options\fR are used to tailor the run-time trace package when the traced program will run in a non-UNIX system environment: .P .PD 0 .TP 7 .B \-b Use only basic functions in the trace code, that is, those in .IR ctype (3C), .IR printf (3S), and .IR string (3C). These are usually available even in cross-compilers for microprocessors. In particular, this option is needed when the traced program runs under an operating system that does not have .IR signal (2), .IR fflush (3S), .IR longjmp (3C), or .IR setjmp (3C). .TP .BI \-p " 's'\^" Change the trace print function from the default of 'printf('. For example, 'fprintf(stderr,' would send the trace to the standard error output. .TP .B -r f Use file .I f in place of the .I runtime.c trace function package. This lets you change the entire print function, instead of just the name and leading arguments (see the .B -p option). .PD .SH EXAMPLE If the file \f2lc.c\fR contains this C program: .DS I 1 #include 2 main() /* count lines in input */ 3 { 4 int c, nl; 5 6 nl = 0; 7 while ((c = getchar()) != EOF) 8 if (c = '\\n') 9 ++nl; 10 printf("%d\\n", nl); 11 } .DE and you enter these commands and test data: .DS I cc lc.c a.out 1 (cntl-d) .DE the program will be compiled and executed. The output of the program will be the number \f32\fR, which is not correct because there is only one line in the test data. The error in this program is common, but subtle. If you invoke \f2ctrace\fR with these commands: .DS I ctrace lc.c >temp.c cc temp.c a.out .DE the output will be: .DS I 2 main() 6 nl = 0; /* nl == 0 */   7 while ((c = getchar()) != EOF) .DE The program is now waiting for input. If you enter the same test data as before, the output will be: .DS I /* c == 49 or '1' */ 8 if (c = '\\n') /* c == 10 or '\\n' */   9 ++nl; /* nl == 1 */ 7 while ((c = getchar()) != EOF) /* c == 10 or '\\n' */ 8 if (c = '\\n') /* c == 10 or '\\n' */   9 ++nl; /* nl == 2 */ 7 while ((c = getchar()) != EOF) .DE If you now enter an end of file character (cntl-d) the final output will be: .DS I /* c == -1 */ 10 printf("%d\\n", nl); /* nl == 2 */2 /* return */ .DE Note that the program output printed at the end of the trace line for the \f3nl\fR variable. Also note the \f3return\fR comment added by \f2ctrace\fR at the end of the trace output. This shows the implicit return at the terminating brace in the function. .P The trace output shows that variable \f3c\fR is assigned the value '1' in line 7, but in line 8 it has the value '\\n'. Once your attention is drawn to this \f3if\fR statement, you will probably realize that you used the assignment operator (=) in place of the equal operator (==). You can easily miss this error during code reading. .SH EXECUTION-TIME TRACE CONTROL The default operation for .I ctrace is to trace the entire program file, unless you use the .B -f or .B -v options to trace specific functions. This does not give you statement by statement control of the tracing, nor does it let you turn the tracing off and on when executing the traced program. .P You can do both of these by adding .IR ctroff () and .IR ctron () function calls to your program to turn the tracing off and on, respectively, at execution time. Thus, you can code arbitrarily complex criteria for trace control with .I if statements, and you can even conditionally include this code because .I ctrace defines the .B CTRACE preprocessor variable. For example: .DS #ifdef CTRACE if (c == '!' && i > 1000) ctron(); #endif .DE You can also call these functions from .IR sdb (1) if you compile with the .B -g option. For example, to trace all but lines 7 to 10 in the main function, enter: .DS sdb a.out main:7b ctroff() main:11b ctron() r .DE You can also turn the trace off and on by setting static variable tr_ct_ to 0 and 1, respectively. This is useful if you are using a debugger that cannot call these functions directly, such as .IR adb (1). .SH DIAGNOSTICS This section contains diagnostic messages from both .I ctrace and .IR cc (1), since the traced code often gets some .I cc warning messages. You can get .I cc error messages in some rare cases, all of which can be avoided. .P .SS Ctrace Diagnostics .I "warning: some variables are not traced in this statement" .RS Only 10 variables are traced in a statement to prevent the C compiler "out of tree space; simplify expression" error. Use the \f3-t\fR option to increase this number. .RE .P .I "warning: statement too long to trace" .RS This statement is over 400 characters long. Make sure that you are using tabs to indent your code, not spaces. .RE .P .I "cannot handle preprocessor code, use -P option" .RS This is usually caused by #ifdef/#endif preprocessor statements in the middle of a C statement, or by a semicolon at the end of a #define preprocessor statement. .RE .P .I "'if ... else if' sequence too long" .RS Split the sequence by removing an \f3else\fR from the middle. .RE .P .I "possible syntax error, try -P option" .RS Use the .B -P option to preprocess the .I ctrace input, along with any appropriate .BR -D , .BR -I , and .B -U preprocessor options. If you still get the error message, check the Warnings section below. .RE .P .SS Cc Diagnostics .I "warning: floating point not implemented" .br .I "warning: illegal combination of pointer and integer" .br .I "warning: sizeof returns 0" .br .I "warning: sizeof returns value less than or equal to zero" .br .I "warning: statement not reached" .RS Ignore these messages. .RE .P .I "compiler takes size of function" .RS See the .I ctrace "possible syntax error" message above. .RE .P .I "yacc stack overflow" .RS See the .I ctrace "'if ... else if' sequence too long" message above. .RE .P .I "out of tree space; simplify expression" .RS Use the \f3-t\fR option to reduce the number of traced variables per statement from the default of 10. Ignore the "ctrace: too many variables to trace" warnings you will now get. .RE .P .I "redeclaration of signal" .RS Either correct this declaration of .IR signal (2), or remove it and #include . .RE .P .I "unimplemented structure assignment" .RS This is caused by a bug in the C compiler for the PDP\-11. Use .IR pcc (1) instead of .IR cc (1). .RE .ig .P .I "offset xxxx in control section ..." .RS This is caused by a problem in the current UNIX/370 C compiler. Use the .IR cc (1) .B -b2,2 option. .RE .. .P .I "expression causes compiler loop: try simplifying" .RS This is caused by a bug in the UNIX/370 C compiler. Unfortunately, the only way to avoid it is to use the .I ctrace .B -v option to not trace the function containing this line. .RE .SH WARNINGS You will get a .I ctrace syntax error if you omit the semicolon at the end of the last element declaration in a structure or union, just before the right brace (}). This is optional in some C compilers. .P Defining a function with the same name as a system function may cause a syntax error if the number of arguments is changed. Just use a different name. .P \f2Ctrace\fR assumes that BADMAG is a preprocessor macro, and that EOF and NULL are #defined constants. Declaring any of these to be variables, e.g. "int EOF;", will cause a syntax error. .SH BUGS \f2Ctrace\fR does not know about the components of aggregates like structures, unions, and arrays. It cannot choose a format to print all the components of an aggregate when an assignment is made to the entire aggregate. \f2Ctrace\fR may choose to print the address of an aggregate or use the wrong format (e.g., %e for a structure with two integer members) when printing the value of an aggregate. .P Pointer values are always treated as pointers to character strings. .P The loop trace output elimination is done separately for each file of a multi-file program. This can result in functions called from a loop still being traced, or the elimination of trace output from one function in a file until another in the same file is called. .SH FILES runtime.c run-time trace package .SH SEE ALSO .fi ctc(1), signal(2), ctype(3C), fflush(3S), longjmp(3C), printf(3S), setjmp(3C), string(3C) in the \f2\s-1UNIX\s+1 System Programmer Reference Manual\fR. .SH AUTHOR Joe Steffen 0707070000020063041007750001460001440000010535610357512535200000400000000616manif [ $# -eq 1 ] then if [ -s /usr/man/1.$1 ] then cat /usr/man/1.$1 exit 0 else echo "$0: cannot find /usr/man/1.$1" >&2 exit 1 fi fi echo "Usage: $0 command_name Only one command name may be specified. This is not a full implementation of the man command as this machine does not have many manual pages. For a list of manual pages available, list the /usr/man directory" >&2 exit 2 0707070000020062771006440001460001440000010535620357512567000001200000020360runtime.c/* ctrace - C program debugging tool * * run-time package of trace functions */ #define M_CT_ "" /* mark was " \b" for obsolete tool tlimit */ #ifndef B_CT_ /* signal catching function used by u_ct_ */ static jmp_buf sj_ct_; static f_ct_() { longjmp(sj_ct_, 1); } #endif #ifdef LM_CT_ #define I_CT_(x) ((x + LM_CT_) % LM_CT_) /* global data used by loop detection code */ static int ts_ct_; /* trace state */ #endif /* global data used by duplicate variable trace code */ static int vc_ct_; /* var trace count within statement */ static struct { /* var values within statement */ char *vn_ct_; /* var name */ int vt_ct_; /* var type (0 is string, > 0 is size) */ union { /* var value */ char *vs_ct_;/* string */ int vi_ct_; /* int */ long vl_ct_; /* long */ double vd_ct_; /* double */ } vv_ct_; } v_ct_[VM_CT_]; /* trace on/off control */ S_CT_ int tr_ct_ = 1; S_CT_ ctron() { tr_ct_ = 1; t_ct_("\n ctron();"); /* suppress "ctron();" in loops */ } S_CT_ ctroff() { tr_ct_ = 0; } /* print the statement text */ S_CT_ t_ct_(text) register char *text; { #ifdef LM_CT_ static int loop_start; static int next_stmt; static char *stmt[LM_CT_]; static long loops; register int i; register char *s; register char c; #endif /* return if tracing is off */ if (!tr_ct_) { return; } #ifdef LM_CT_ if (ts_ct_ == 2) /* if not tracing */ if (strcmp(text, stmt[next_stmt]) == 0) { if (strcmp(text, stmt[loop_start]) == 0) { ++loops; if (loops % 1000 == 0) PF_CT_"%s\n\r /* still repeating after %ld times */%s", M_CT_, loops, M_CT_); next_stmt = loop_start; } next_stmt = I_CT_(next_stmt + 1); vc_ct_ = 0; /* reset the var count */ return; } else { /* doesn't match next statement */ PF_CT_"%s\n\r /* repeated ", M_CT_); if (loops == 0) PF_CT_"< 1 time"); else PF_CT_"%ld times", loops); PF_CT_" */%s", M_CT_); loops = 0; PF_CT_"%s%s%s", M_CT_, stmt[I_CT_(next_stmt - 1)], M_CT_); /* print last statement */ ts_ct_ = 4; /* force var printing */ for (i = 0; i < vc_ct_; ++i) /* print its vars */ if (v_ct_[i].vt_ct_ == 0) /* string? */ s_ct_(v_ct_[i].vn_ct_, v_ct_[i].vv_ct_.vs_ct_); /* yes */ else if (v_ct_[i].vt_ct_ == sizeof(int)) u_ct_(v_ct_[i].vn_ct_, v_ct_[i].vt_ct_, v_ct_[i].vv_ct_.vi_ct_); else if (v_ct_[i].vt_ct_ == sizeof(long)) u_ct_(v_ct_[i].vn_ct_, v_ct_[i].vt_ct_, v_ct_[i].vv_ct_.vl_ct_); else /* double */ u_ct_(v_ct_[i].vn_ct_, v_ct_[i].vt_ct_, v_ct_[i].vv_ct_.vd_ct_); ts_ct_ = 0; /* start tracing */ } #endif vc_ct_ = 0; /* reset the var count */ #ifdef LM_CT_ if (ts_ct_ == 0) { /* if looking for the start of a loop */ /* if statement in list */ for (i = I_CT_(next_stmt - 2); i != I_CT_(next_stmt - 1); i = I_CT_(i - 1)) if ((s = stmt[i]) != 0 && /* saved text could be null */ strcmp(text, s) == 0 && /* if text matches */ (c = s[strlen(s) - 1]) != '{' && c != '}') { /* and is not a brace */ ts_ct_ = 1; /* look for the loop end */ loop_start = i; next_stmt = I_CT_(loop_start + 1); goto print_stmt; } } else /* if looking for the loop end */ if (strcmp(text, stmt[loop_start]) == 0) { /* if start stmt */ ts_ct_ = 2; /* stop tracing */ PF_CT_"%s\n\r /* repeating */%s", M_CT_, M_CT_); stmt[next_stmt] = text; /* save as end marker */ next_stmt = I_CT_(loop_start + 1); return; } else if (strcmp(text, stmt[next_stmt]) != 0) /* if not next stmt */ ts_ct_ = 0; /* look for the start of a loop */ stmt[next_stmt] = text; /* save this statement */ next_stmt = I_CT_(next_stmt + 1); /* inc the pointer */ print_stmt: #endif /* goto the beginning of the line even if in raw mode */ if (text[0] == '\n') { PF_CT_"\r"); } PF_CT_"%s%s%s", M_CT_, text, M_CT_); /* print this statement */ #ifndef B_CT_ fflush(stdout); /* flush the output buffer */ #endif } /* dump a string variable */ S_CT_ s_ct_(name, value) char *name; char *value; { /* return if tracing is off */ if (!tr_ct_) { return; } #ifdef LM_CT_ /* save the var name and value */ if (ts_ct_ != 4) { /* if not forcing var printing */ v_ct_[vc_ct_].vn_ct_ = name; v_ct_[vc_ct_].vt_ct_ = 0; /* var type is string */ v_ct_[vc_ct_].vv_ct_.vs_ct_ = value; ++vc_ct_; } if (ts_ct_ == 2) /* if not tracing */ return; #endif PF_CT_"%s\n\r %s == \"", M_CT_, name); /* flush before printing the string because it may cause an abort if it is not null terminated */ #ifndef B_CT_ fflush(stdout); #endif PF_CT_"%s\" */%s", value, M_CT_); #ifndef B_CT_ fflush(stdout); #endif } /* dump a variable of an unknown type */ S_CT_ u_ct_(name, _size, value) /* size is a macro in */ char *name; register int _size; union { char *p; int i; long l; double d; } value; { #ifndef isprint #include #endif register int i; register char *s; register char c; /* return if tracing is off */ if (!tr_ct_) { return; } /* normalize the size (pointer and float are the same size as either int or long) */ if (_size == sizeof(char) || _size == sizeof(short)) _size = sizeof(int); else if (_size != sizeof(int) && _size != sizeof(long) && _size != sizeof(double)) /* this is an extern pointer (size=0), or array or struct address */ _size = sizeof(char *); #ifdef LM_CT_ if (ts_ct_ != 4) { /* if not forcing var printing */ #endif /* don't dump the variable if its value is the same */ for (i = 0; i < vc_ct_; ++i) if (_size == v_ct_[i].vt_ct_ && strcmp(name, v_ct_[i].vn_ct_) == 0) if (_size == sizeof(int)) { if (value.i == v_ct_[i].vv_ct_.vi_ct_) return; } else if (_size == sizeof(long)) { if (value.l == v_ct_[i].vv_ct_.vl_ct_) return; } else /* double */ if (value.d == v_ct_[i].vv_ct_.vd_ct_) return; /* save the var name and value */ v_ct_[vc_ct_].vn_ct_ = name; v_ct_[vc_ct_].vt_ct_ = _size; if (_size == sizeof(int)) { v_ct_[vc_ct_].vv_ct_.vi_ct_ = value.i; } else if (_size == sizeof(long)) { v_ct_[vc_ct_].vv_ct_.vl_ct_ = value.l; } else /* double */ v_ct_[vc_ct_].vv_ct_.vd_ct_ = value.d; ++vc_ct_; #ifdef LM_CT_ } if (ts_ct_ == 2) /* if not tracing */ return; #endif /* determine the variable type and print it */ PF_CT_"%s\n\r %s == ", M_CT_, name); if (_size == sizeof(int)) { PF_CT_"%d", value.i); /* decimal */ #ifdef O_CT_ if ((unsigned) value.i > 7) /* octal */ PF_CT_" or 0%o", value.i); #endif #ifdef X_CT_ if ((unsigned) value.i > 9) /* hexadecimal */ PF_CT_" or 0x%x", value.i); #endif #ifdef U_CT_ if (value.i < 0) /* unsigned */ PF_CT_" or %u", value.i); #endif #ifdef E_CT_ if (_size == sizeof(float)) /* float */ PF_CT_" or %e", value.i); #endif if ((unsigned) value.i <= 255) /* character */ if (isprint(value.i)) PF_CT_" or '%c'", value.i); else if (iscntrl(value.i)) { switch (value.i) { case '\n': c = 'n'; break; case '\t': c = 't'; break; case '\b': c = 'b'; break; case '\r': c = 'r'; break; case '\f': c = 'f'; break; case '\v': c = 'v'; break; default: c = '\0'; } if (c != '\0') PF_CT_" or '\\%c'", c); } } else if (_size == sizeof(long)) { PF_CT_"%ld", value.l); /* decimal */ #ifdef O_CT_ if ((unsigned) value.l > 7) /* octal */ PF_CT_" or 0%lo", value.l); #endif #ifdef X_CT_ if ((unsigned) value.l > 9) /* hexadecimal */ PF_CT_" or 0x%lx", value.l); #endif #ifdef U_CT_ if (value.l < 0) /* unsigned */ PF_CT_" or %lu", value.l); #endif #ifdef E_CT_ if (_size == sizeof(float)) /* float */ PF_CT_" or %e", value.l); #endif } else if (_size == sizeof(double)) /* double */ PF_CT_"%e", value.d); #ifndef B_CT_ /* check for a possible non-null pointer */ if (_size == sizeof(char *) && value.p != 0) { int (*sigbus)(), (*sigsegv)(); /* see if this is a non-null string */ if (setjmp(sj_ct_) == 0) { sigbus = signal(SIGBUS, f_ct_); sigsegv = signal(SIGSEGV, f_ct_); if (*value.p != '\0') for (s = value.p; ; ++s) { if ((c = *s) == '\0') { PF_CT_" or \"%s\"", value.p); break; } /* don't use isspace(3) because \v and others will not print properly */ if (!isprint(c) && c != '\t' && c != '\n') break; /* not string */ } } signal(SIGBUS, sigbus); signal(SIGSEGV, sigsegv); } #endif PF_CT_" */%s", M_CT_); #ifndef B_CT_ fflush(stdout); #endif } 0707070000020062771006440001460001440000010535620357512567000001300000000000TRAILER!!!ct_[vc_ct_].vv_ct_.vs_ct_ = value; ++vc_ct_; } if (ts_ct_ == 2) /* if not tracing */ return; #endif PF_CT_"%s\n\r %s == \"", M_CT_, name); /* flush before printing the string because it may cause an abort if it is not null terminated */ #ifndef B_CT_ fflush(stdout); #endif PF_CT_"%s\" */%s", value, M_CT_); #ifndef B_CT_ fflush(stdout); #endif } /* dump a variable of an unknown type */ S_CT_ u_ct_(name, _size, value) /* size is a macro in */ char *name; register int _size; union { char *p; int i; long l; double d; } value; { #ifndef isprint #include #endif register int i; register char *s; register char c; /* return if tracing is off */ if (!tr_ct_) { return; } /* normalize the size (pointer and float are the same size as either int or long) */ if (_size == sizeof(char) || _size