TotalView Reference Guide : Part I: CLI Commands : Batch Debugging Using tvscript : tvscript External Script Files : Example tvscript Script File
Example tvscript Script File
The following information is passed to tvscript as follows:
tvscript -script_file script_file
This script installs an error handler and an action point handler. When an error is encountered during execution, tvscript passes an array of information to the error handler. Similarly, when an action point is hit, it passes an array of information to the action point handler. These arrays are described in Event API”.
# Get the process so we have some information about it
tvscript_log "PID: \
[tvscript_get_process_property 1 "syspid"]";
tvscript_log "Status: \
[tvscript_get_process_property 1 "state"]";
tvscript_log "Executable: \
[tvscript_get_process_property 1 "executable"]";
 
#############################################################
proc error_handler {error_data} {
tvscript_log "Inside error_handle: $error_data"
 
# Change the incoming list into an array.
# It contains the following indices:
# process_id
# thread_id
# error_message
array set error_data_array $error_data
# Get the process so we have some information about it
temp = [tvscript_get_process_property \
$error_data_array(process_id) "syspid"];
tvscript_log " Process ID: $temp";
 
temp = [tvscript_get_thread_property \
$error_data_array(thread_id) "systid"];
tvscript_log " Thread ID: $temp";
 
temp = $error_data_array(error_message);
tvscript_log " Error Message: $temp";
 
}
 
#############################################################
# Action point handlers
 
proc l1_actionpoint_handler {event_data} {
tvscript_log "Inside l1_actionpnt_handler: $event_data"
tvscript_slog "Inside l1_actionpnt_handler: $event_data"
 
# Change the incoming list into an array.
# It contains the following indices:
# actionpoint_id
# actionpoint_source_loc_expr
# event
# process_id
# thread_id
array set event_data_array $event_data
# Get the process so we have some information about it
temp = [tvscript_get_process_property \
$event_data_array(process_id) "syspid"];
tvscript_log " Process ID: $temp";
temp = [tvscript_get_thread_property \
$event_data_array(thread_id) "systid"];
tvscript_log " Thread ID: $temp";
temp = [tvscript_get_process_property \
$event_data_array(process_id) "state"];
tvscript_log " Status: $temp";
temp = [tvscript_get_process_property \
$event_data_array(process_id) "executable"]
tvscript_log " Executable: $temp";
temp = $event_data_array(actionpoint_source_loc_expr)
tvscript_log "Action point Expression: $temp"
tvscript_log "Value of i:"
set output [capture "dprint i"]
tvscript_log $output
}
#######################################################
# Event handlers
proc generic_actionpoint_event_handler {actionpoint_data} {
tvscript_log \
"Inside generic_actionpoint_event_handler: "
tvscript_log $actionpoint_data
tvscript_slog "Inside generic_actionpoint_event_handler: "
tvscript_slog $actionpoint_data
# Change the incoming list into an array.
# It contains the following indices:
# actionpoint_id
# actionpoint_source_loc_expr
# event
# process_id
# thread_id
array set actionpnt_data_array $actionpoint_data
temp = $actionpnt_data_array(process_id)
tvscript_log " Process ID: $temp"
temp = $actionpnt_data_array(thread_id)
tvscript_log " Thread ID: $temp"
temp = $actionpnt_data_array(actionpoint_id)
tvscript_log " Action Point ID: $temp"
temp = $actionpnt_data_array(actionpoint_source_loc_expr)
tvscript_log "Action Point Expression: "
}
#############################################################
# Add event handlers
# Setup action points and action point handlers
set actionpoint_id [tvscript_create_actionpoint "l1"]
tvscript_add_actionpoint_handler $actionpoint_id \
"l1_actionpoint_handler"
# Setup a generic actionpoint handler
tvscript_add_event_handler "actionpoint" \
"generic_actionpoint_event_handler"
#######################################################
# Add error handler
tvscript_add_event_handler "error" "error_handler"