aboutsummaryrefslogtreecommitdiff
path: root/Examples/sh_calls_example.txt
blob: 064cf977936f3ee27d2a93852d4d6614ddf17c05 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
The following are examples of sh_calls.d.

This is a simple script to count Bourne shell calls. Here it traces an
example program, Code/Perl/func_abc.sh.

   # sh_calls.d 
   Tracing... Hit Ctrl-C to end.
   ^C
    FILE                   TYPE       NAME                                COUNT
    func_abc.sh            func       func_a                                  1
    func_abc.sh            func       func_b                                  1
    func_abc.sh            func       func_c                                  1
    func_abc.sh            builtin    echo                                    3
    func_abc.sh            cmd        sleep                                   3

While tracing, function func_a() from the program "func_abc.sh" was executed
once, along with func_b() and func_c(). The "echo" builtin was called 3
times, as was the "sleep" command.


The following traced the firefox start script,

   # sh_calls.d 
   Tracing... Hit Ctrl-C to end.
   ^C
    FILE                   TYPE       NAME                                COUNT
    firefox                builtin    .                                       1
    firefox                builtin    break                                   1
    firefox                builtin    exit                                    1
    firefox                builtin    pwd                                     1
    firefox                builtin    test                                    1
    firefox                cmd        /usr/lib/firefox/run-mozilla.sh         1
    run-mozilla.sh         builtin    break                                   1
    run-mozilla.sh         builtin    exit                                    1
    run-mozilla.sh         builtin    return                                  1
    run-mozilla.sh         builtin    shift                                   1
    run-mozilla.sh         builtin    type                                    1
    run-mozilla.sh         cmd        /usr/lib/firefox/firefox-bin            1
    run-mozilla.sh         func       moz_run_program                         1
    run-mozilla.sh         func       moz_test_binary                         1
    firefox                builtin    echo                                    2
    firefox                func       moz_pis_startstop_scripts               2
    firefox                builtin    cd                                      3
    firefox                builtin    export                                  3
    run-mozilla.sh         builtin    export                                  3
    firefox                builtin    :                                       6
    firefox                func       moz_spc_verbose_echo                    6
    run-mozilla.sh         subsh      -                                       9
    firefox                builtin    [                                      18
    firefox                subsh      -                                      20
    run-mozilla.sh         builtin    [                                      20

The firefox start script called run-mozilla.sh, which can be seen both
as a "cmd" call in the above output from the "firefox" script, and as
additionall calls from the "run-mozilla.sh" script.

The builtin called "[" is the test builtin, and was called 20 times by
"run-mozilla.sh" and 18 times by "firefox". The "firefox" script also called
20 subshells.