sh Provider
The sh provider makes available probes that can be used to observe the behavior of bourne shell scripts.
This provider is in development and is not currently available
Top
Probes
| Probe |
Description |
| builtin-entry |
Fires on entry to a shell builtin command. |
| builtin-return |
Fires on return from a shell builtin command. |
| command-entry |
Fires when the shell execs an external command. |
| command-return |
Fires on return from an external command. |
| function-entry |
Fires on entry into a shell function. |
| function-return |
Fires on return from a shell function. |
| line |
Fires before commands on a particular line of code are executed. |
| subshell-entry |
Fires when the shell forks a subshell. |
| subshell-return |
Fires on return from a forked subshell. |
| script-start |
Fires before any commands in a script are executed. |
| script-done |
Fires on script exit. |
| variable-set |
Fires on assignment to a variable. |
| variable-unset |
Fires when a variable is unset. |
Note that the use of non-empty module or function names in a sh* probe is undefined at this time.
Top
sh Probe Arguments
| Probe |
args[0] |
args[1] |
args[2] |
args[3] |
args[4] |
| builtin-entry,command-entry,function-entry |
char * |
char * |
int |
int |
char ** |
| builtin-return,command-return,function-return |
char * |
char * |
int |
|
|
| subshell-entry |
char * |
pid_t |
|
|
|
| subshell-return |
char * |
int |
|
|
|
| line |
char * |
int |
|
|
|
| script-start |
char * |
|
|
|
|
| script-done |
char * |
int |
|
|
|
| variable-set |
char * |
char * |
char * |
|
|
| variable-unset |
char * |
char * |
|
|
|
Top
sh Probe Arguments - more detail
builtin-entry,command-entry,function-entry
| char * |
args[0] |
Script Name |
| char * |
args[1] |
Builtin/Command/Function Name |
| int |
args[2] |
Line Number |
| int |
args[3] |
# Arguments |
| char ** |
args[4] |
Pointer to argument list |
builtin-return,command-return,function-return
| char * |
args[0] |
Script Name |
| char * |
args[1] |
Builtin/Command/Function Name |
| int |
args[2] |
Return Value |
subshell-entry
| char * |
args[0] |
Script Name |
| pid_t |
args[1] |
Forked Process ID |
subshell-return
| char * |
args[0] |
Script Name |
| int |
{{args[1] |
Return Value |
line
| char * |
args[0] |
Script Name |
| int |
args[1] |
Line Number |
script-start
| char * |
args[0] |
Script Name |
script-done
| char * |
args[0] |
Script Name |
| int |
args[1] |
Exit Value |
variable-set
| char * |
args[0] |
Script Name |
| char * |
args[1] |
Variable Name |
| char * |
args[2] |
Value |
variable-unset
| char * |
args[0] |
Script Name |
| char * |
args[1] |
Variable Name |
Top
Examples
Some simple examples of sh provider usage follow.
Catching a variable assignment
Say we want to determine which line in the following script has an assignment to WatchedVar:
We could use the following script
Top
Watching the time spent in functions
Similar for the other entry/return probes, with the exception of subshell as the probe name is unavailable.
Wasted time using external functions instead of builtins
This script is copied from the DTrace toolkit. It's function and how it works should be relatively self explanatory.
Given the following silly little script (bad.sh), we can look at the amount of time spent executing external commands and split out the time that has been spent on commands we've defined that could have been builtins.
Top
Stability
The sh provider uses DTrace's stability mechanism to describe its stabilities, as shown in the following table. For more information about the stability mechanism, see Chapter 39, Stability.
| Element |
Name stability |
Data stability |
Dependency class |
| Provider |
Unstable |
Unstable |
Common |
| Module |
Private |
Private |
Unknown |
| Function |
Private |
Private |
Unknown |
| Name |
Unstable |
Unstable |
Common |
| Arguments |
Unstable |
Unstable |
Common |