xref: /netbsd-src/external/cddl/dtracetoolkit/dist/Docs/Examples/sh_calls_example.txt (revision c29d51755812ace2e87aeefdb06cb2b4dac7087a)
1The following are examples of sh_calls.d.
2
3This is a simple script to count Bourne shell calls. Here it traces an
4example program, Code/Perl/func_abc.sh.
5
6   # sh_calls.d
7   Tracing... Hit Ctrl-C to end.
8   ^C
9    FILE                   TYPE       NAME                                COUNT
10    func_abc.sh            func       func_a                                  1
11    func_abc.sh            func       func_b                                  1
12    func_abc.sh            func       func_c                                  1
13    func_abc.sh            builtin    echo                                    3
14    func_abc.sh            cmd        sleep                                   3
15
16While tracing, function func_a() from the program "func_abc.sh" was executed
17once, along with func_b() and func_c(). The "echo" builtin was called 3
18times, as was the "sleep" command.
19
20
21The following traced the firefox start script,
22
23   # sh_calls.d
24   Tracing... Hit Ctrl-C to end.
25   ^C
26    FILE                   TYPE       NAME                                COUNT
27    firefox                builtin    .                                       1
28    firefox                builtin    break                                   1
29    firefox                builtin    exit                                    1
30    firefox                builtin    pwd                                     1
31    firefox                builtin    test                                    1
32    firefox                cmd        /usr/lib/firefox/run-mozilla.sh         1
33    run-mozilla.sh         builtin    break                                   1
34    run-mozilla.sh         builtin    exit                                    1
35    run-mozilla.sh         builtin    return                                  1
36    run-mozilla.sh         builtin    shift                                   1
37    run-mozilla.sh         builtin    type                                    1
38    run-mozilla.sh         cmd        /usr/lib/firefox/firefox-bin            1
39    run-mozilla.sh         func       moz_run_program                         1
40    run-mozilla.sh         func       moz_test_binary                         1
41    firefox                builtin    echo                                    2
42    firefox                func       moz_pis_startstop_scripts               2
43    firefox                builtin    cd                                      3
44    firefox                builtin    export                                  3
45    run-mozilla.sh         builtin    export                                  3
46    firefox                builtin    :                                       6
47    firefox                func       moz_spc_verbose_echo                    6
48    run-mozilla.sh         subsh      -                                       9
49    firefox                builtin    [                                      18
50    firefox                subsh      -                                      20
51    run-mozilla.sh         builtin    [                                      20
52
53The firefox start script called run-mozilla.sh, which can be seen both
54as a "cmd" call in the above output from the "firefox" script, and as
55additionall calls from the "run-mozilla.sh" script.
56
57The builtin called "[" is the test builtin, and was called 20 times by
58"run-mozilla.sh" and 18 times by "firefox". The "firefox" script also called
5920 subshells.
60
61