Totalview® for HPC Reference Guide : PART II Transformations : Chapter 6 Creating Type Transformations : Creating Structure and Class Transformations : Transforming Structures
Transforming Structures
The following small program contains a structure and the statements necessary to initialize it:
#include <stdio.h>
 
int main () {
struct stuff {
int month;
int day;
int year;
char * pName;
char * pStreet;
char CityState[30];
};
 
struct stuff info;
char my_name[] = "John Smith";
char my_street[] = "24 Prime Parkway, Suite 106";
char my_CityState[] = "Natick, MA 01760";
 
info.month = 6;
info.day = 20;
info.year = 2004;
info.pName = my_name;
info.pStreet = my_street;
strcpy(info.CityState, my_CityState);
 
printf("The year is %d\n", info.year);
}
Suppose that you do not want to see the month and day components. You can do this by creating a transformation that names just the elements you want to include:
::TV::TTF::RTF::build_struct_transform {
name {^struct stuff$}
members {
{ year { year } }
{ pName { * pName } }
{ pStreet { * pStreet } }
}
}
You can apply this transformation to your data in the following ways:
After opening the program, use the Tools > Command Line command to open a CLI Window. Next, type this function call.
If you write the function call into a file, use the Tcl source command. If the name of the file is stuff.tvd, enter the following command into a CLI Window:
source stuff.tvd
You can place the transformation source file into the same directory as the executable, giving it the same root name as the executable. If the executable file has the name stuff, TotalView will automatically execute all commands within a file named stuff.tvd when it loads your executable.
After TotalView processes your transformation, it displays the Variable Window when you dive on the info structure:
 
Figure 7 – Transforming a Structure