1 1.1 christos The following are examples of sh_flow.d. 2 1.1 christos 3 1.1 christos This is a simple script to trace the flow of Bourne shell functions, 4 1.1 christos builtins and external commands. Here it traces the example program, 5 1.1 christos Code/Shell/func_abc.sh. 6 1.1 christos 7 1.1 christos # sh_flow.d 8 1.1 christos C TIME(us) FILE -- NAME 9 1.1 christos 0 3060274370505 func_abc.sh -> func_a 10 1.1 christos 0 3060274370529 func_abc.sh > echo 11 1.1 christos 0 3060274372742 func_abc.sh | sleep 12 1.1 christos 0 3060275381634 func_abc.sh -> func_b 13 1.1 christos 0 3060275381660 func_abc.sh > echo 14 1.1 christos 0 3060275383852 func_abc.sh | sleep 15 1.1 christos 0 3060276391653 func_abc.sh -> func_c 16 1.1 christos 0 3060276391679 func_abc.sh > echo 17 1.1 christos 0 3060276393671 func_abc.sh | sleep 18 1.1 christos 0 3060277401753 func_abc.sh <- func_c 19 1.1 christos 0 3060277401767 func_abc.sh <- func_b 20 1.1 christos 0 3060277401775 func_abc.sh <- func_a 21 1.1 christos ^C 22 1.1 christos 23 1.1 christos As each function is entered, the third column is indented by 2 spaces. This 24 1.1 christos shows which function is calling who - the output abovebegins by showing that 25 1.1 christos func_a() began, and then called func_b(). 26 1.1 christos 27 1.1 christos If the output looks shuffled, check the CPU "C" and "TIME" columns, and 28 1.1 christos post sort based on TIME if necessary. 29 1.1 christos 30 1.1 christos See Notes/ALLflow_notes.txt for important notes about reading flow outputs. 31 1.1 christos 32 1.1 christos 33 1.1 christos 34 1.1 christos The following traces the firefox startup script. 35 1.1 christos 36 1.1 christos # sh_flow.d 37 1.1 christos C TIME(us) FILE -- NAME 38 1.1 christos 0 3060321598138 firefox > test 39 1.1 christos 0 3060321603730 firefox > [ 40 1.1 christos 0 3060321603796 firefox > cd 41 1.1 christos 0 3060321603878 firefox > [ 42 1.1 christos 0 3060321603900 firefox > [ 43 1.1 christos 0 3060321604099 firefox > [ 44 1.1 christos 0 3060321609050 firefox > echo 45 1.1 christos 0 3060321620601 firefox > echo 46 1.1 christos 0 3060321626369 firefox > [ 47 1.1 christos 0 3060321626432 firefox > export 48 1.1 christos 0 3060321626459 firefox -> moz_pis_startstop_scripts 49 1.1 christos 0 3060321626519 firefox > export 50 1.1 christos 0 3060321626966 firefox > [ 51 1.1 christos 0 3060321627031 firefox > . 52 1.1 christos 0 3060321628446 firefox -> moz_spc_verbose_echo 53 1.1 christos 0 3060321628458 firefox > : 54 1.1 christos 0 3060321628467 firefox <- moz_spc_verbose_echo 55 1.1 christos 0 3060321636461 firefox > [ 56 1.1 christos 0 3060321636738 firefox -> moz_spc_verbose_echo 57 1.1 christos 0 3060321636751 firefox > : 58 1.1 christos 0 3060321636760 firefox <- moz_spc_verbose_echo 59 1.1 christos 0 3060321636778 firefox > [ 60 1.1 christos 0 3060321636793 firefox > [ 61 1.1 christos 0 3060321636817 firefox > [ 62 1.1 christos 0 3060321637126 firefox -> moz_spc_verbose_echo 63 1.1 christos 0 3060321637136 firefox > : 64 1.1 christos 0 3060321637143 firefox <- moz_spc_verbose_echo 65 1.1 christos 0 3060321666922 firefox -> moz_spc_verbose_echo 66 1.1 christos 0 3060321666952 firefox > : 67 1.1 christos 0 3060321666964 firefox <- moz_spc_verbose_echo 68 1.1 christos 0 3060321674929 firefox > [ 69 1.1 christos 0 3060321680246 firefox > [ 70 1.1 christos 0 3060321680312 firefox -> moz_spc_verbose_echo 71 1.1 christos 0 3060321680323 firefox > : 72 1.1 christos 0 3060321680331 firefox <- moz_spc_verbose_echo 73 1.1 christos 0 3060321680356 firefox -> moz_spc_verbose_echo 74 1.1 christos 0 3060321680363 firefox > : 75 1.1 christos 0 3060321680370 firefox <- moz_spc_verbose_echo 76 1.1 christos 0 3060321680396 firefox > [ 77 1.1 christos 0 3060321680428 firefox <- moz_pis_startstop_scripts 78 1.1 christos 0 3060321680525 firefox > [ 79 1.1 christos 0 3060321680580 firefox > [ 80 1.1 christos 0 3060321685358 firefox | /usr/lib/firefox/run-mozilla.sh 81 1.1 christos 0 3060321700731 run-mozilla.sh > [ 82 1.1 christos 0 3060321700950 run-mozilla.sh > break 83 1.1 christos 0 3060321703259 run-mozilla.sh > [ 84 1.1 christos 0 3060321703292 run-mozilla.sh > shift 85 1.1 christos 0 3060321703382 run-mozilla.sh > [ 86 1.1 christos 0 3060321703421 run-mozilla.sh > [ 87 1.1 christos 0 3060321703493 run-mozilla.sh > [ 88 1.1 christos 0 3060321703642 run-mozilla.sh > [ 89 1.1 christos 0 3060321703669 run-mozilla.sh > export 90 1.1 christos 0 3060321703706 run-mozilla.sh > [ 91 1.1 christos 0 3060321703725 run-mozilla.sh > [ 92 1.1 christos 0 3060321703857 run-mozilla.sh > [ 93 1.1 christos 0 3060321703880 run-mozilla.sh > export 94 1.1 christos 0 3060321703925 run-mozilla.sh > export 95 1.1 christos 0 3060321703954 run-mozilla.sh > [ 96 1.1 christos 0 3060321703982 run-mozilla.sh -> moz_run_program 97 1.1 christos 0 3060321704013 run-mozilla.sh > [ 98 1.1 christos 0 3060321704049 run-mozilla.sh -> moz_test_binary 99 1.1 christos 0 3060321704065 run-mozilla.sh > [ 100 1.1 christos 0 3060321704097 run-mozilla.sh > [ 101 1.1 christos 0 3060321704127 run-mozilla.sh > return 102 1.1 christos 0 3060321704137 run-mozilla.sh <- moz_test_binary 103 1.1 christos 0 3060321704151 run-mozilla.sh > [ 104 1.1 christos 0 3060321709953 run-mozilla.sh > type 105 1.1 christos 0 3060321724260 run-mozilla.sh > [ 106 1.1 christos 0 3060321724559 run-mozilla.sh > [ 107 1.1 christos 0 3060321724574 run-mozilla.sh > [ 108 1.1 christos 0 3060321727396 run-mozilla.sh | /usr/lib/firefox/firefox-bin 109 1.1 christos 0 3060325513871 run-mozilla.sh > [ 110 1.1 christos 0 3060325513898 run-mozilla.sh > [ 111 1.1 christos 0 3060325513929 run-mozilla.sh > [ 112 1.1 christos 0 3060325513940 run-mozilla.sh <- moz_run_program 113 1.1 christos 0 3060325513967 run-mozilla.sh > exit 114 1.1 christos 0 3060325515113 firefox -> moz_pis_startstop_scripts 115 1.1 christos 0 3060325515189 firefox > export 116 1.1 christos 0 3060325515431 firefox > [ 117 1.1 christos 0 3060325515466 firefox > [ 118 1.1 christos 0 3060325515487 firefox <- moz_pis_startstop_scripts 119 1.1 christos 0 3060325515503 firefox > exit 120 1.1 christos 121 1.1 christos This shows the flow, incluing the handover between the "firefox" script 122 1.1 christos and the "run-mozilla.sh" script. 123 1.1 christos 124 1.1 christos There is a point in the output where flow appears to reverse (at time 125 1.1 christos 3060321709953, with the entry "> type"). This is due to another instance 126 1.1 christos of the run-mozilla.sh script running, which is indistinguishable from 127 1.1 christos the other lines in the output. To confirm this for yourself, add a PID 128 1.1 christos column to the flow script (or use sh_flowinfo.d). 129 1.1 christos 130