ctrace [options] [file]
Ñ╫ÑφÑ░ÑΘÑαñ╬│╞╠┐╬ß╩╕ñ¼╝┬╣╘ñ╡ñ∞ñδñ┤ñ╚ñ╦íóñ╜ñ∞ñ¼├╝╦÷ñ╦ÑΩÑ╣Ñ╚ñ╡ñ∞íóñ╜ñ╬╕σñ╦ñ╜ñ╬╠┐╬ß╩╕ñ╟╗▓╛╚ñ▐ñ┐ñ╧╩╤╣╣ñ╡ñ∞ñ┐ñ╣ñ┘ñ╞ñ╬╩╤┐⌠ñ╬╠╛┴░ñ╚├═ñ¼┬│ñ¡íóñ╡ñΘñ╦ñ╜ñ╬╠┐╬ß╩╕ñ½ñΘñ╬╜╨╬╧ñ¼┬│ñ¡ñ▐ñ╣íúÑ╚Ñ∞í╝Ñ╣╜╨╬╧╞Γñ╬Ñδí╝Ñ╫ñ¼╕í╜╨ñ╡ñ∞íóÑδí╝Ñ╫ñ½ñΘ╚┤ñ▒╜╨ñ╣ñ½íóÑδí╝Ñ╫╞Γñ╬╠┐╬ß╩╕ñ╬╩╠ñ╬Ñ╖í╝Ñ▒Ñ≤Ñ╣ñ¼╝┬╣╘ñ╡ñ∞ñδñ▐ñ╟íóÑ╚Ñ∞í╝Ñ╣ñ╧─Σ╗▀ñ╡ñ∞ñ▐ñ╣íúѵí╝Ñ╢ñ¼╠╡╕┬Ñδí╝Ñ╫ñ≥╕í╜╨ñ╟ñ¡ñδñΦñªíóÑδí╝Ñ╫ñ≥ 1000 ▓≤╖½ñΩ╩╓ñ╣ñ┤ñ╚ñ╦ 1 ▓≤╖┘╣≡ÑßÑ├Ñ╗í╝Ñ╕ñ¼╜╨╬╧ñ╡ñ∞ñ▐ñ╣íúÑ╚Ñ∞í╝Ñ╣╜╨╬╧ñ╧╔╕╜α╜╨╬╧ñ╦╣╘ñ∩ñ∞ñδñ┐ñßíóѵí╝Ñ╢ñ╧ñ╜ñ∞ñ≥Ñ╒ÑíÑñÑδñ╦╞■ñ∞ñ╞íóÑ¿Ñ╟ÑúÑ┐ñΣ bfs(1) ñ▐ñ┐ñ╧ tail(1) Ñ│Ñ▐Ñ≤Ñ╔ñ≥═╤ñññ╞╕í║║ñ╟ñ¡ñ▐ñ╣íú
░∞╚╠ñ╦╗╚═╤ñ╡ñ∞ñδѬÑ╫Ñ╖ÑτÑ≤ñ╧▓╝╡¡ñ╬ñ╚ñ¬ñΩñ╟ñ╣íú
╩╤┐⌠ñ≥╜╨╬╧ñ╣ñδñ┐ñßñ╬íó╛╩╬¼╗■ñ╬╜±╝░ñ╦┬╛ñ╬╜±╝░ñ≥─╔▓├ñ╣ñδñ│ñ╚ñΓñ╟ñ¡ñ▐ñ╣íúlong ╖┐ñ¬ñΦñ╙Ñ▌ÑñÑ≤Ñ┐╖┐╩╤┐⌠ñ╧íó╛∩ñ╦╔Σ╣µ╔╒ñ¡└░┐⌠ñ╚ñ╖ñ╞╜╨╬╧ñ╡ñ∞ñ▐ñ╣íú╩╕╗·╟█╬≤ñ╬Ñ▌ÑñÑ≤Ñ┐ñ╧ñ╜ñ∞ñ¼└╡ñ╖ññ└╡╩╕╗·╬≤ñ≥╝¿ñ╣ñΓñ╬ñ╟ñóñ∞ñ╨╩╕╗·╬≤ñ╚ñ╖ñ╞╜╨╬╧ñ╡ñ∞ñ▐ñ╣íúchar ╖┐íóshort ╖┐íóint ╖┐ñ╬╩╤┐⌠ñ╧╔Σ╣µ╔╒ñ¡└░┐⌠ñ╚ñ╖ñ╞╜╨╬╧ñ╡ñ∞íóñ╜ñ∞ñ¼╩╕╗·ñ╚ñ╖ñ╞┼¼└┌ñ╩╛∞╣τñ╧╩╕╗·ñ╟╜╨╬╧ñ╡ñ∞ñ▐ñ╣íúfloat ╖┐íódouble ╖┐íólong double ╖┐╩╤┐⌠ñ╧íó▓╩│╪╔╜╡¡╦íñ╬╔Γ╞░╛»┐⌠┼└┐⌠ñ╚ñ╖ñ╞╜╨╬╧ñ╡ñ∞ñ▐ñ╣íú│║┼÷ñ╣ñδ╛∞╣τíó▓╝╡¡ñ╬ѬÑ╫Ñ╖ÑτÑ≤ñ╟ñ│ñ∞ñΘñ╬╩╤┐⌠ñ≥─╔▓├ñ╖ñ┐╜±╝░ñ╟ñΓ╜╨╬╧ñ╣ñδñΦñª═╫╡ßñ╟ñ¡ñ▐ñ╣íú
▓╝╡¡ñ╬ѬÑ╫Ñ╖ÑτÑ≤ñ╧╞├─Ωñ╬╛⌡╢╖ñ╟ñ╬ñ▀╗╚═╤ñ╡ñ∞ñ▐ñ╣íú
1 #include <stdio.h> 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 }
▓╝╡¡ñ╬Ñ│Ñ▐Ñ≤Ñ╔ñ¬ñΦñ╙Ñ╞Ñ╣Ñ╚Ñ╟í╝Ñ┐ñ≥╞■╬╧ñ╖ñ┐ñ╚ñ╖ñ▐ñ╣íú
cc lc.c
a.out
1
<Ctrl>-d
ñ│ñ╬Ñ╫ÑφÑ░ÑΘÑαñ╧Ñ│Ñ≤Ñ╤ÑñÑδñ╡ñ∞íó╝┬╣╘ñ╡ñ∞ñ▐ñ╣íúÑ╫ÑφÑ░ÑΘÑαñ╬╜╨╬╧ñ╧íó┐⌠├═ 2 ñ╦ñ╩ñΩñ▐ñ╣ñ¼íóñ│ñ∞ñ╧Ñ╞Ñ╣Ñ╚Ñ╟í╝Ñ┐ñ╬├µñ╦ñ╧ 1 ╣╘ñ╖ñ½ñ╩ñññ┐ñß└╡ñ╖ññ├═ñ╟ñ╧ñóñΩñ▐ñ╗ñ≤íúñ│ñ╬Ñ╫ÑφÑ░ÑΘÑαñ╟ñ╬Ñ¿ÑΘí╝ñ╧íóñΦñ»╡»ñ│ñΩñ▐ñ╣ñ¼íó╜┼┬τñ╩ñΓñ╬ñ╟ñ╧ñóñΩñ▐ñ╗ñ≤íú▓╝╡¡ñ╬Ñ│Ñ▐Ñ≤Ñ╔ñ≥╗╚ñ├ñ╞ ctrace ñ≥╕╞ñ╙╜╨ñ╖ñ┐ñ╚ñ╖ñ▐ñ╖ñτñªíú
ctrace lc.c >temp.c
cc temp.c
a.out
ñ╜ñ╬╜╨╬╧ñ╧▓╝╡¡ñ╬ñΦñªñ╦ñ╩ñΩñ▐ñ╣íú
2 main() 6 nl = 0; / nl == 0 / 7 while ((c = getchar()) != EOF)
Ñ╫ÑφÑ░ÑΘÑαñ╧íóñ│ñ│ñ╟╞■╬╧┬╘ñ┴ñ╬╛⌡┬╓ñ╚ñ╩ñΩñ▐ñ╣íúñΓñ╖┴░ñ╚╞▒ñ╕Ñ╞Ñ╣Ñ╚Ñ╟í╝Ñ┐ñ≥╞■╬╧ñ╣ñδñ╚íóñ╜ñ╬╜╨╬╧ñ╧▓╝╡¡ñ╬ñΦñªñ╦ñ╩ñΩñ▐ñ╣íú
/ 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 */ /* repeating */
ñ│ñ│ñ╟íóÑ¿Ñ≤Ñ╔ѬÑ╓Ñ╒ÑíÑñÑδ╩╕╗·(<Ctrl>-d)ñ≥╞■╬╧ñ╣ñδñ╚íó║╟╜¬╜╨╬╧ñ╧▓╝╡¡ñ╬ñΦñªñ╦ñ╩ñΩñ▐ñ╣íú
/* repeated < 1 time */ 7 while ((c = getchar()) != EOF) /* c == -1 */ 10 printf("%d\n", nl); /* nl == 2 */2/* return */
╛≡╩≤ñ¼íó╣╘ 10 ñ╦┬│ñ»╩╤┐⌠ nl ñ╬Ñ╚Ñ∞í╝Ñ╣╣╘ñ╬╜¬ñ∩ñΩñ╦╜╨╬╧ñ╡ñ∞ñδñ│ñ╚ñ╦├φ░╒ñ╖ñ╞ñ»ñ└ñ╡ññíúñ▐ñ┐íóÑ╚Ñ∞í╝Ñ╣╜╨╬╧ñ╬╜¬ñ∩ñΩñ╦ ctrace ñ╦ñΦñ├ñ╞ return ñ╬├φ╝ßñ¼╔╒▓├ñ╡ñ∞ñδñ│ñ╚ñ╦ñΓ├φ░╒ñ╖ñ╞ñ»ñ└ñ╡ññíúñ│ñ∞ñ╧íó┤╪┐⌠ñ╬├µ│τ╕╠ñ╦ñΦñδ░┼╠█ñ╬ÑΩÑ┐í╝Ñ≤ñ≥╝¿ñ╣ñΓñ╬ñ╟ñ╣íú
ñ│ñ╬Ñ╚Ñ∞í╝Ñ╣╜╨╬╧ñ╧íó╩╤┐⌠ c ñ╧╣╘ 7 ñ╟├═ 1 ñ¼┬σ╞■ñ╡ñ∞ñ╞ñññδñ¼íó╣╘ 8 ñ╟ñ╧``\n''ñ╬├═ñ╦ñ╩ñδñ│ñ╚ñ≥╝¿ñ╖ñ╞ñññ▐ñ╣íúѵí╝Ñ╢ñ¼ñ│ñ╬ if ╩╕ñ╦├σ╠▄ñ╣ñδñ╚íó┼∙╣µ▒Θ╗╗╗╥(==)ñ╬┬σñΩñ╦┬σ╞■▒Θ╗╗╗╥(=)ñ≥╗╚ñ├ñ┐ñ│ñ╚ñ╦╡ñ╔╒ñ»ñ╧ñ║ñ╟ñ╣íúÑ│í╝Ñ╔ñ≥╞╔ñ≤ñ╟ñññδñ╚ñ¡ñ╦ñ╧íó┤╩├▒ñ╦ñ│ñ╬Ñ¿ÑΘí╝ñ≥╕½╞¿ñ╖ñ╞ñ╖ñ▐ñª▓─╟╜└¡ñ¼ñóñΩñ▐ñ╣íú
╝┬╣╘╗■ñ╦Ñ╚Ñ∞í╝Ñ╣ñ≥ѬÑ≤ñ▐ñ┐ñ╧ѬÑ╒ñ╦└┌ñΩ┬╪ñ¿ñδñ╦ñ╧íóÑ╫ÑφÑ░ÑΘÑαñ╦┤╪┐⌠╕╞ñ╙╜╨ñ╖ ctroff() ñ╚ ctron() ñ≥ñ╜ñ∞ñ╛ñ∞─╔▓├ñ╖ñ▐ñ╣íúñ│ñ∞ñ╦ñΦñ├ñ╞íóif ╩╕ñ≥╗╚ñ├ñ╞╩ú╗¿ñ╦Ñ╚Ñ∞í╝Ñ╣└⌐╕µñ≥╣╘ñªñΦñªñ╩Ñ╫ÑφÑ░ÑΘÑαñΓ╝½═│ñ╦┴╚ñαñ│ñ╚ñ¼ñ╟ñ¡íó╔¼═╫ñ╦▒■ñ╕ñ╞ñ│ñ╬Ñ│í╝Ñ╔ñ≥┴▐╞■ñ╣ñδñ│ñ╚ñ¼ñ╟ñ¡ñ▐ñ╣íúñ╩ñ╝ñ╩ñΘ ctrace ñ¼Ñ╫ÑΩÑ╫ÑφÑ╗Ñ├Ñ╡╩╤┐⌠ CTRACE ñ≥─Ω╡┴ñ╖ñ╞ñññδñ½ñΘñ╟ñ╣íú╗╚═╤╬πñ╧▓╝╡¡ñ╬ñ╚ñ¬ñΩñ╟ñ╣íú
#ifdef CTRACE if (c == '!' && i > 1000) ctron(); #endif
-g ѬÑ╫Ñ╖ÑτÑ≤ñ≥╗╪─Ωñ╖ñ╞Ñ│Ñ≤Ñ╤ÑñÑδñ╣ñ∞ñ╨íódebug(1) ñ½ñΘñ│ñ∞ñΘñ╬┤╪┐⌠ñ≥╕╞ñ╙╜╨ñ╣ñ│ñ╚ñΓñ╟ñ¡ñ▐ñ╣íú╬πñ¿ñ╨íó┤╪┐⌠ñ╬ 7 ñ½ñΘ 10 ╣╘ñ≥╜ⁿñ»ñ╣ñ┘ñ╞ñ╬╣╘ñ≥Ñ╚Ñ∞í╝Ñ╣ñ╣ñδñ╦ñ╧íó▓╝╡¡ñ╬ñΦñªñ╦╞■╬╧ñ╖ñ▐ñ╣íú
debug a.out debug> stop lc.c @7 {set ctroff();} EVENT [1] assigned debug> stop lc.c @11 {set ctron();} EVENT [2] assigned debug> run
ñ▐ñ┐íó└┼┼¬╩╤┐⌠ tr_ct_ ñ≥ñ╜ñ∞ñ╛ñ∞ 0 ñ╚ 1 ñ╦└▀─Ωñ╣ñ∞ñ╨íóÑ╚Ñ∞í╝Ñ╣ñ≥ѬÑ╒ñ¬ñΦñ╙ѬÑ≤ñ╦ñ╟ñ¡ñ▐ñ╣íúñ│ñ∞ñ╧íóñ│ñ∞ñΘñ╬┤╪┐⌠ñ≥─╛└▄ñ╦╕╞ñ╙╜╨ñ╗ñ╩ññÑ╟Ñ╨Ñ├Ѽñ≥╗╚═╤ñ╖ñ╞ñññδ╛∞╣τñ╦╠≥╬⌐ñ┴ñ▐ñ╣íú
warning: some variables are not traced in this statement
warning: statement too long to trace
cannot handle preprocessor code, use -P option
'if . . . else if' sequence too long
possible syntax error, try -P option
ctrace ñ╧íóBADMAG ñ¼Ñ╫ÑΩÑ╫ÑφÑ╗Ñ├Ñ╡ñ╬Ñ▐Ñ»Ñφñ╟ñóñδñ│ñ╚íóñ╜ñ╖ñ╞ EOF ñ¬ñΦñ╙ NULL ñ¼ #define ñ╦ñΦñ├ñ╞─Ω╡┴ñ╡ñ∞ñ┐─Ω┐⌠ñ╟ñóñδñ│ñ╚ñ╚┴█─Ωñ╖ñ╞ñññ▐ñ╣íúñ│ñ∞ñΘñ╬ñªñ┴ñ╔ñ∞ñ½ñ≥
"int EOF;" ñ╬ñΦñªñ╦╩╤┐⌠ñ╚ñ╖ñ╞└δ╕└ñ╣ñδñ╚íó╣╜╩╕Ñ¿ÑΘí╝ñ≥░·ñ¡╡»ñ│ñ╖ñ▐ñ╣íú
Ñ▌ÑñÑ≤Ñ┐├═ñ╧╛∩ñ╦íó╩╕╗·╬≤ñ≥╗╪ñ╣Ñ▌ÑñÑ≤Ñ┐ñ╚ñ╖ñ╞░╖ñ∩ñ∞ñ▐ñ╣íú
ctrace ñ╧íó╣╜┬ñ┬╬ñΣ╢ª═╤┬╬ñΣ╟█╬≤ñ╩ñ╔ñ╬╜╕╣τ┬╬ñ╬╣╜└«═╫┴╟ñ╦ñ─ñññ╞ñ╧╛≡╩≤ñ≥═┐ñ¿ñΘñ∞ñ╞ñññ▐ñ╗ñ≤íúñ╜ñ╬ñ┐ñßíóñ│ñ╬ñΦñªñ╩╜╕╣τ┬╬┴┤┬╬ñ╦┬╨ñ╖ñ╞┬σ╞■ñ¼╣╘ñ∩ñ∞ñ┐╛∞╣τíóñ╜ñ∞ñΘñ╬┴┤╣╜└«═╫┴╟ñ≥╜╨╬╧ñ╣ñδ╜±╝░ñ≥┴¬┬≥ñ╣ñδñ│ñ╚ñ╧ñ╟ñ¡ñ▐ñ╗ñ≤íúctrace ñ╧ñ│ñ╬ñΦñªñ╩╜╕╣τ┬╬ñ╬├═ñ≥╜╨╬╧ñ╣ñδñ╚ñ¡ñ╦íóñ╜ñ╬╜╕╣τ┬╬ñ╬ÑóÑ╔Ñ∞Ñ╣ñ≥╜╨╬╧ñ╣ñδñ╬ñ½íóñ╜ñ∞ñ╚ñΓ╕φñ├ñ┐╜±╝░ñ≥╗╚ñª(╬πñ¿ñ╨íó2 ñ─ñ╬└░┐⌠ñ≥ñΓñ─╣╜┬ñ┬╬ñ╦┬╨ñ╖ñ╞ 3.149050e-311 ñ≥╗╚═╤ñ╣ñδ)ñ╬ñññ║ñ∞ñ½ñ≥┴¬┬≥ñ╖ñ▐ñ╣íú
Ñδí╝Ñ╫Ñ╚Ñ∞í╝Ñ╣╜╨╬╧ñ╬╜ⁿ╡εñ╧íó╩ú┐⌠Ñ╒ÑíÑñÑδñ½ñΘñ╩ñδÑ╫ÑφÑ░ÑΘÑαñ╬│╞Ñ╒ÑíÑñÑδñ╜ñ∞ñ╛ñ∞ñ╦┬╨ñ╖ñ╞╞╚╬⌐ñ╦╣╘ñ∩ñ∞ñ▐ñ╣íúñ│ñ╬╖δ▓╠íóÑδí╝Ñ╫ñ½ñΘ╕╞ñ╙╜╨ñ╡ñ∞ñ┐┤╪┐⌠ñ¼Ñ╚Ñ∞í╝Ñ╣ñ╡ñ∞ñ┐ñΩíóñ╜ñ╬Ñ╒ÑíÑñÑδ╞Γñ╬╩╠ñ╬┤╪┐⌠ñ¼╕╞ñ╙╜╨ñ╡ñ∞ñδñ▐ñ╟ñóñδÑ╒ÑíÑñÑδñ╬ 1 ñ─ñ╬┤╪┐⌠ñ╬Ñ╚Ñ∞í╝Ñ╣╜╨╬╧ñ╬╜ⁿ╡εñ¼└╕ñ╕ñ▐ñ╣íú