|
|
1.1 root 1: . \" Copyright 1984,1985,1986,1987,1988,1989,1990 AT&T Bell Laboratories
2: .TH CIN 1
3: .CT 1 prog_c
4: .SH NAME
5: cin \- C interpreter
6: .SH SYNOPSIS
7: .B cin
8: [
9: .I option ...
10: ]
11: [
12: .I file ...
13: ]
14: [
15: .B --
16: .I arg ...
17: ]
18: .SH DESCRIPTION
19: .I Cin
20: interprets a C program comprising the
21: .I file
22: arguments as in
23: .IR cc (1).
24: The special name
25: .L -
26: signifies standard input.
27: When called with no
28: .I file
29: arguments,
30: .I cin
31: defaults to
32: .BR -i .
33: Arguments
34: .I arg
35: are passed to the interpreted program as
36: .BR cin_argv[1] ,
37: .BR cin_argv[2] ,
38: \&...
39: and
40: .BR cin_argc .
41: .PP
42: Options
43: .BI -D name = def ,
44: .BI -D name ,
45: .BI -L name ,
46: .BI -U name ,
47: .BI -I name ,
48: .BI -l x ,
49: .BI -o name ,
50: and
51: .BI -u name
52: are as in
53: .IR cc .
54: Options
55: .B -O
56: and
57: .B -g
58: are ignored.
59: Other options are:
60: .TP
61: .BI -0 name
62: Pass
63: .I name
64: to the interpreted program as
65: .BR cin_argv[0] .
66: .TP
67: .BI -C name
68: Use
69: .I name
70: as the interpreter startup file
71: (by default, the file
72: .FR $HOME/.cin.c ).
73: The interpreter startup file is ignored by using
74: .BR -C/dev/null .
75: .TP
76: .BI -F i : o : e
77: Use file descriptors
78: .IR i , o , e
79: as standard input, standard output, and standard error for the
80: interpreter, as distinct from the interpreted code
81: (by default, 0, 1, and 2).
82: .TP
83: .B -S
84: Enable interactive mode after run-time errors.
85: .TP
86: .BI -V name : n
87: Declare function
88: .I name
89: to have a variable number of arguments, the first
90: .I n
91: of which are to be type-checked.
92: .TP
93: .B -c
94: Parse files but do not execute the program.
95: .TP
96: .B -i
97: Enable interactive interpretation.
98: C statements are evaluated immediately using local and global variables.
99: Non-void values are printed.
100: Function, variable, and C pre-processor declarations are stored
101: in the current `view'.
102: A function definition must include its return type.
103: Declarations and statements can appear in any order and
104: identifiers can be redeclared.
105: .TP
106: .B -r
107: Prohibit multiply-declared global variables.
108: .TP
109: .B -s
110: Do not catch signals using
111: .IR signal (2)
112: (by default,
113: .I cin
114: catches
115: .BR SIGBUS ,
116: .BR SIGEMT ,
117: .BR SIGFPE ,
118: .BR SIGILL ,
119: .BR SIGINT ,
120: .BR SIGIOT ,
121: .BR SIGSEGV ,
122: .BR SIGSYS ,
123: .BR SIGTRAP ).
124: .TP
125: .B -v
126: Print the user and system times associated with loading files and executing
127: the program, as in
128: .IR time (1).
129: .TP
130: .BI + option
131: Turn off the specified
132: .IR option .
133: .PP
134: The functions and variables listed below are predefined in
135: .I cin
136: and
137: .IR libcin.a .
138: Their arguments are typed according to these conventions:
139: .IP
140: .B char
141: .BI * func ,
142: .BI * message ,
143: .BI * mod ,
144: .BI * name ,
145: .BI * ref ,
146: .BI * string ;
147: .br
148: .B enode
149: .BI * code ;
150: .br
151: .B int
152: .IB level ,
153: .IB line ;
154: .br
155: .B long
156: .BI (* after )();
157: .br
158: .B unsigned
159: .B long
160: .IB addr ;
161: .br
162: .B void
163: .BI (* before )(),
164: .BI (* routine )();
165: .PP
166: This first group of functions and variables are the most commonly used.
167: To use them load
168: .F libcin.a
169: and include
170: .FR cin.h .
171: .PP
172: .HP
173: .BI "int cin_break(" name ,
174: .IB line ,
175: .IB string )
176: .br
177: If
178: .I string
179: is
180: .BR "(char *)0" ,
181: place a
182: .B cin_system
183: in file
184: .I name
185: before line number
186: .IR line .
187: Otherwise,
188: place the C-language statement specified by
189: .I string
190: in file
191: .I name
192: before line number
193: .IR line .
194: Thus,
195: .IR string
196: is read and evaluated
197: within the prevailing context of the function
198: without stopping execution.
199: Return 0 if line number
200: .I line
201: cannot be found in file
202: .IR name .
203: .TP
204: .BI "int cin_dump(" name )
205: Create an
206: .F a.out
207: and place it in the file
208: .IR name .
209: Return 0 if
210: .I name
211: cannot be created.
212: .TP
213: .BI "void cin_info(" string )
214: Where
215: .I string
216: is:
217: .RS
218: .TP
219: .B breakpoint
220: Print
221: .IR cin 's
222: .BR cin_break s
223: and
224: .BR cin_stopin s.
225: .TP
226: .B log
227: Print
228: .IR cin 's
229: interactive mode log file name.
230: .TP
231: .B memory
232: Print
233: .IR cin 's
234: memory usage.
235: .TP
236: .B spy
237: Print
238: .IR cin 's
239: spies.
240: .TP
241: .B symboltable
242: Print
243: .IR cin 's
244: symbol table.
245: .TP
246: .B undefined
247: Print
248: .IR cin 's
249: undefined variables.
250: .TP
251: .B usage
252: Print
253: .IR cin 's
254: usage message.
255: .TP
256: .B version
257: Print
258: .IR cin 's
259: version number.
260: .TP
261: .B view
262: List the available views.
263: The current view is starred
264: .RB ( * ).
265: .TP
266: .B where
267: Print a trace of function calls.
268: .TP
269: .B wrapper
270: Print
271: .IR cin 's
272: wrappers.
273: .RE
274: .TP
275: .BI "int cin_load(" string )
276: Evaluate
277: .I string
278: as invocation arguments of
279: .IR cin .
280: Return 0 if arguments are not valid.
281: .TP
282: .BI "int cin_log(" name )
283: .IR mv (1)
284: the interactive mode session log to file
285: .IR name .
286: Return 0 if
287: .I name
288: cannot be
289: .IR mv ed.
290: .TP
291: .BI "void cin_make(" string )
292: If
293: .I string
294: is
295: .BR "(char *)0" ,
296: then re-load any file that is out of date.
297: Otherwise,
298: run
299: .BR $MAKE ,
300: passing
301: .I string
302: as arguments, and scan
303: its standard output for lines that begin with pound sign
304: .RB ( # ).
305: Characters following the pound sign are executed as
306: a C-language statement.
307: .HP
308: .BI "int cin_pp(" func ,
309: .IB level )
310: .br
311: Print the C-language for the function
312: .IR func .
313: Where
314: .I level
315: is:
316: .RS
317: .TP
318: .B 0
319: Print declaration.
320: .TP
321: .B 1
322: Print declaration and body.
323: .PP
324: Return 0 if
325: .I func
326: cannot be found.
327: .RE
328: .TP
329: .B "void cin_quit()"
330: Flush output and exit
331: .IR cin .
332: If all else fails,
333: use
334: .IR _exit(2) .
335: .TP
336: .B "int cin_reset()"
337: Preserve function definitions,
338: zero bss variables,
339: and restore initialized data variables to their original values.
340: Return 0 if
341: state cannot be reset.
342: .TP
343: .B "void cin_return()"
344: Return from a call to
345: .BR cin_system .
346: .TP
347: .BI "void cin_run(" string )
348: Set
349: .BR cin_argv[1] ,
350: .BR cin_argv[2] ,
351: \&...
352: and
353: .B cin_argc
354: from
355: .I string
356: and then
357: .BR "main(cin_argc, cin_argv)" .
358: .HP
359: .BI "int cin_spy(" func ,
360: .IB name ,
361: .IB mod ,
362: .IB ref )
363: .br
364: Trace variable references and modifications.
365: If
366: .I mod
367: is not
368: .BR "(char *)0" ,
369: place the C-language statement specified by
370: .I mod
371: after the variable
372: .I name
373: is modified in the function
374: .IR func .
375: If
376: .I ref
377: is not
378: .BR "(char *)0" ,
379: place the C-language statement specified by
380: .I ref
381: before the variable
382: .I name
383: is referenced in the function
384: .IR func .
385: If function value
386: .I func
387: is
388: .BR "(char *)0" ,
389: search all functions.
390: Return 0 if
391: .I name
392: cannot be found in
393: .IR func .
394: .TP
395: .B "void cin_step()"
396: Step over function calls
397: to the next C-language statement in the current or previous function.
398: .TP
399: .B "void cin_stepin()"
400: Step into any function to the next C-language statement.
401: .TP
402: .B "void cin_stepout()"
403: Step out of the current function back to the next C-language statement
404: in the previous function.
405: .HP
406: .BI "int cin_stopin(" func ,
407: .IB string )
408: .br
409: If
410: .I string
411: is
412: .BR "(char *)0" ,
413: place a
414: .B cin_system
415: before the first
416: executable line in the function
417: .IR func ,
418: either in the current view or wherever
419: .I func
420: can be found.
421: Otherwise,
422: place the C-language statement specified by
423: .I string
424: before the first
425: executable line in the function
426: .IR func ,
427: either in the current view or wherever it can be found.
428: Thus,
429: .IR string
430: is read and evaluated
431: within the prevailing context of the function
432: without stopping execution.
433: Return 0 if function
434: .I func
435: cannot be found.
436: .TP
437: .BI "char *cin_sync(" string )
438: Where
439: .I string
440: is:
441: .RS
442: .TP
443: .B filename
444: Return the non-interactive C source file name being executed.
445: .TP
446: .B lineno
447: Return the non-interactive C source line number being executed.
448: .RE
449: .TP
450: .B "void cin_system()"
451: Start a
452: .BR cin_read - cin_eval - cin_print
453: loop.
454: .HP
455: .BI "int cin_unbreak(" name ,
456: .IB line ,
457: .IB string )
458: .br
459: Clear a
460: .B cin_break
461: or a
462: .B cin_stopin
463: in file
464: .I name
465: before line number
466: .I line
467: with string
468: .IR string .
469: Return 0 if
470: .B cin_break
471: or
472: .B cin_stopin
473: cannot be cleared.
474: .TP
475: .BI "int cin_unload(" name )
476: Unload the object file
477: .IR name .
478: Return 0 if
479: .I name
480: cannot be unloaded.
481: .HP
482: .BI "int cin_unspy(" func ,
483: .IB name ,
484: .IB mod ,
485: .IB ref )
486: .br
487: Remove the C-language statement specified by
488: .I mod
489: after the variable
490: .I name
491: is modified,
492: and the C-language statement specified by
493: .I ref
494: before the variable
495: .I name
496: is referenced in the function
497: .IR func .
498: Return 0 if spy cannot be cleared.
499: .HP
500: .BI "int cin_unstopin(" func ,
501: .IB string )
502: .br
503: Clear a
504: .B cin_stopin
505: or
506: .B cin_break
507: at the first
508: executable line in the function
509: .I func
510: with string
511: .I string
512: in either the current view or wherever
513: .I func
514: can be found.
515: Return 0 if the
516: .B cin_stopin
517: or
518: .B cin_break
519: cannot be cleared.
520: .HP
521: .BI "int cin_unwrapper(" func ,
522: .IB before ,
523: .IB after )
524: .br
525: Remove the call of function
526: .I before
527: before the function
528: .I func
529: is called.
530: Remove the call of function
531: .I after
532: after the function
533: .I func
534: is called.
535: Return 0 if
536: .I func
537: cannot be found.
538: .TP
539: .BI "int cin_view(" name )
540: Change the current view to
541: .IR name .
542: Return 0 if the view cannot be found.
543: .HP
544: .BI "int cin_wrapper(" func ,
545: .IB before ,
546: .IB after )
547: .br
548: If
549: .I before
550: is not
551: .BR "(void (*)())0" ,
552: call the function
553: .I before
554: with the arguments of function
555: .I func
556: before the function
557: .I func
558: is called.
559: If
560: .I after
561: is not
562: .BR "(long (*)())0" ,
563: call the function
564: .I after
565: with the argument of the return value of function
566: .I func
567: after the function
568: .I func
569: is called.
570: The return value of function
571: .I after
572: is substituted for the return value of function
573: .IR func .
574: Return 0 if
575: .I name
576: cannot be found either in the current view or any other view.
577: .TP
578: .B "extern int cin_argc"
579: The number of elements passed to the interpreted program.
580: .TP
581: .B "extern char **cin_argv"
582: An array of the arguments passed to the interpreted program.
583: .TP
584: .B "extern char *cin_filename"
585: The current C source file name being executed.
586: .TP
587: .B "extern int cin_level"
588: The number of nested calls to
589: .BR cin_system .
590: .TP
591: .B "extern char *cin_libpath"
592: A colon
593: .RB ( : )
594: -separated list of libraries to search for undefined routines
595: (by default,
596: the libraries specified on the command line and
597: .FR -lc ).
598: .TP
599: .B "extern int cin_lineno"
600: The current C source line number being executed.
601: .TP
602: .B "extern char *cin_prompt"
603: The interactive mode prompt (by default,
604: the string
605: .RB `` cin> " '')."
606: .PP
607: These are some of the less frequently used functions and variables in
608: .IR cin .
609: They are primarily used by
610: .I cin
611: library or language developers.
612: .TP
613: .BI "enode *cin_compile(" code )
614: Analyze
615: .I code
616: and return an optimized program.
617: Return
618: .B "(enode *)0"
619: if
620: .I code
621: cannot be compiled.
622: .TP
623: .BI "int cin_epp(" func )
624: Print the
625: .BR enode s
626: for function
627: .IR func .
628: Return 0 if
629: .I func
630: cannot be found.
631: .TP
632: .BI "enode *cin_eprint(" code )
633: Print the
634: .I code
635: as
636: .BR enode s.
637: Return the argument.
638: .HP
639: .BI "char *cin_error_code_set(" message ,
640: .IB string )
641: .br
642: Where
643: .I message
644: is:
645: .RS
646: .TP
647: .B dynamic error
648: When
649: .I cin
650: detects
651: a divide by zero,
652: a modulus by zero,
653: a null pointer access,
654: or
655: an abnormal signal
656: execute the C-language statement specified by
657: .IR string .
658: .TP
659: .B undefined function
660: When
661: .I cin
662: detects an undefined function execute the C-language statement specified by
663: .IR string .
664: .TP
665: .B undefined symbol
666: When
667: .I cin
668: detects
669: an undefined symbol execute the C-language statement specified by
670: .IR string .
671: .PP
672: If
673: .I string
674: is
675: .BR "(char *)0" ,
676: execute
677: .BR cin_system() .
678: Return the old
679: .I string
680: for
681: .IR message .
682: .RE
683: .TP
684: .BI "enode *cin_eval(" code )
685: Execute the
686: .I code
687: as if it were present in the program where
688: .B cin_eval
689: is called.
690: Return the resulting program.
691: .TP
692: .BI "ident *cin_find_ident(" name )
693: If
694: .I name
695: is not
696: .BR "(char *)0" ,
697: return the identifier for the variable
698: .I name
699: either in the current view or wherever
700: .I name
701: can be found.
702: If
703: .I name
704: is
705: .BR "(char *)0" ,
706: return the identifier for the previous non-
707: .B "(char *)0"
708: value of the variable
709: .I name
710: in the next view where
711: .I name
712: can be found.
713: Return
714: .B "(ident *)0"
715: if
716: .I name
717: cannot be found.
718: .TP
719: .BI "struct nlist *cin_find_nlist(" addr )
720: Return the loader symbol table entry for the external address
721: .IR addr .
722: Return
723: .B "(struct nlist *)0"
724: if
725: .I addr
726: cannot be found.
727: .HP
728: .BI "void (*cin_info_set())(" string ,
729: .IB routine )
730: .br
731: Inform
732: .B cin_info
733: that it should call
734: .I routine
735: when it is passed
736: .IR string .
737: Return the old
738: .I routine
739: for
740: .IR string .
741: .TP
742: .BI "char *cin_ltof(" line )
743: Return the function name at line number
744: .I line
745: in the current view.
746: Return
747: .B "(char *)0"
748: if a function cannot be found for
749: .IR line .
750: .TP
751: .BI "void cin_pop(" level )
752: Replace
753: .I level
754: interpreted function calls from the stack with
755: .BR cin_system .
756: .HP
757: .BI "enode *cin_print(" code ,
758: .IB level )
759: .br
760: Print the
761: .I code
762: as C-language code.
763: Where
764: .I level
765: is:
766: .RS
767: .TP
768: .B 0
769: Print declaration.
770: .TP
771: .B 1
772: Print declaration and body.
773: .PP
774: Return the
775: .I code
776: argument.
777: .RE
778: .TP
779: .BI "enode *cin_read(" string )
780: Read
781: .I string
782: and return a program.
783: Return
784: .B "(enode *)0"
785: if
786: .I string
787: cannot be parsed.
788: .TP
789: .BI "char *cin_slashify(" string )
790: Return a pointer to storage obtained from
791: .IR malloc (3)
792: and there create a character array from
793: .I string
794: by translating
795: backspace,
796: form feed,
797: newline,
798: carriage return,
799: horizontal tab,
800: vertical tab,
801: backslash,
802: single quote,
803: and double quote
804: into
805: .BR \eb ,
806: .BR \ef ,
807: .BR \en ,
808: .BR \er ,
809: .BR \et ,
810: .BR \ev ,
811: .BR \e\e ,
812: .BR \e' ,
813: and
814: .B \e"
815: respectively.
816: Other non-printable characters are translated into
817: .BI \e ddd
818: octal notation.
819: .TP
820: .B "extern int cin_err_fd"
821: .IR Cin 's
822: standard error file descriptor.
823: .TP
824: .B "extern int cin_in_fd"
825: .IR Cin 's
826: standard input file descriptor.
827: .TP
828: .B "extern int cin_out_fd"
829: .IR Cin 's
830: standard output file descriptor.
831: .TP
832: .B "extern stackelem *cin_stack"
833: The trace of function calls.
834: .TP
835: .B "extern view *cin_views"
836: The list of available views.
837: .SH EXAMPLES
838: .TP
839: The world's shortest ``Hello world'' program.
840: .EX
841: cin> printf("Hello world\en");
842: Hello world
843: (int)12
844: .EE
845: .TP
846: Setting breakpoints and tracing function calls.
847: .EX
848: $ cin -lcin
849: cin> int f(x) { return x <= 1 ? 1 : x * f(x - 1); }
850: extern int f();
851: cin> cin_stopin("f", (char*)0);
852: /tmp/cin006795: 1: f: set breakpoint: (char *)0
853: (int)1
854: cin> f(2);
855: /tmp/int006795: 1: f: stopped execution:
856: cin> cin_return();
857: /tmp/int006795: 1: f: stopped execution:
858: cin> (void)cin_info("where");
859: /tmp/cin006795: 5: cin_system: info: where: ()
860: /tmp/cin006795: 1: f: info: where: (x = (int)1)
861: /tmp/cin006795: 1: f: info: where: (x = (int)2)
862: /tmp/cin006795: 3: cin_system: info: where: ()
863: cin> x;
864: (int)1
865: cin> cin_return();
866: (int)2
867: cin> cin_quit();
868: $
869: .EE
870: .SH FILES
871: .TF /usr/include/cin.h
872: .TP
873: .F /tmp/cin*
874: default interactive log
875: .TP
876: .F /usr/include/cin.h
877: various function and variable declarations
878: .TP
879: .F /usr/lib/libcin.a
880: various predefined functions
881: .TP
882: .F $HOME/.cin.c
883: interpreter startup file
884: .HP
885: other files as in
886: .IR cc (1)
887: .SH "SEE ALSO"
888: .I "Cin User Manual"
889: .br
890: .I "Cin Reference Manual"
891: .br
892: B. W. Kernighan and D. M. Ritchie,
893: .IR "The C Programming Language" ,
894: Prentice-Hall,
895: 1978
896: .br
897: .IR lint (1),
898: .IR ar (1),
899: .IR cc (1)
900: .SH BUGS
901: The addresses of
902: .IR etext ,
903: .IR edata ,
904: and
905: .I end
906: are not meaningful with incrementally loaded code.
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.