User-defined I/O primitives
This section demonstrates how to define your our own I/O primitives for the dump phase.
Again, create a new TDP based on the one created previously.
To create a new TDP:
- Open the cwingccmingw2.xdp TDP in the TDP Editor
- Select the top-level node and rename it My MinGW UserMode2
- Save the current TDP as cwingccmingw3.xdp.
- Collapse all the nodes in the Navigation window as this section concentrates only on the Build Settings and Library Settings nodes of the TDP Editor.
To set up user-defined I/O primitives:
- Expand Build Settings and select the Execution function.
- Delete the >$out parameter that was added to the SystemP statement:
SystemP("$exe $parameters");
- Expand Library Settings, Data retrieval and error output and select Data retrieval to locate the RTRT_IO macro definition.
- Select the RTRT_USR entry.
- On the Settings tab, in RTRT_FILE_TYPE, change int to FILE*.
- Add your own code for the following functions:
- usr_open function:
printf("...Opening file...\n"); return(fopen(fileName,"w"));Add your own code for the usr_init function: return(null); Add your own code for the usr_w
- usr_init function:
return(null); Add your own code for the usr_writeln function: printf("...Dumping : %s\n",s); fprintf(f,"%s",s);
- usr_close function:
printf("...Closing file...\n"); fclose(f);
- usr_open function:
- Save the TDP, update the Configuration in Rational® Test RealTime and Build the add.c example.
The examples described here make no sense in real life as they are functionally identical the standard I/O mechanism. However, they show how easy it is to map user-defined I/O primitives to the data retrieval mechanism implemented by the TDP.
Move on the next section: Using a Debugger