Indicating if a Type Is Mapped: The vector_validate Callback
The vector_validate procedure checks that this named type matches the expected specification. This function expects the following input:
_Vector_base<int,allo.. class _Vector_base<..
(Private base class)
_Vector_alloc_base.. class _Vector_alloc..
(Public base class)
_M_start int*
_M_finish int*
_M_end_of_storage int*
It also extracts other information about the type and saves it for later use.
proc vector_validate {instance_id} {
global _vector_type_info
set base_id [ultimate_base $instance_id]
set fields [TV::type get $base_id struct_fields]
# Prepare the information that will be saved.
set typeinfo [list {} {} {}]
# Search for _M_start and _M_finish.
foreach field $fields {
set name [lindex $field 0]
set addressing [lindex $field 2]
switch -- $name {
_M_start{
set typeinfo [lreplace $typeinfo 1 1 \
[extract_offset $addressing]]
# Also extract the type
set field_typeid [lindex $field 1]
set typeinfo [lreplace $typeinfo 0 0 \
[TV::type get $field_typeid target]]
}
_M_finish {
set typeinfo [lreplace $typeinfo 2 2 \
[extract_offset $addressing]]
}
}
}
# Check that the target type was found.
if {[lindex $typeinfo 0] == ""} {
return false
}
set _vector_type_info($instance_id) $typeinfo
return true
}
This procedure begins by finding the ultimate base class of the vector type, and then checks that the data type has the named fields. It also checks that the data type really is the class being transformed. Just before returning, it places information needed by other procedures into the _vector_type_info global array.
The vector_validate procedure returns false if it cannot match the target type. This tells TotalView that it should not apply this prototype to the type. TotalView will, however, continue searching for other prototypes whose name matches the type's name.
Note: This procedure could fail if some code is compiled for g++, and some by a vendor's compiler.