Target Deployment Technology
Data Retrieval is accomplished through the association of the Target Deployment Port library functions with an execution procedure.
The following examples demonstrate the Standard, User, and Breakpoint Modes, based on a simple program which writes a text message to a file named "cNewTdp\\atl.out".
Standard Mode Example: Native
#define RTRT_FILE FILE *
RTRT_FILE usr_open(char *fileName)
{ return((RTRT_FILE)(fopen(fileName,"w"))); }
void usr_writeln(RTRT_FILE f,char *s)
{ fprintf(f,"%s",s); }
void usr_close(RTRT_FILE f)
{fclose(f) ;}
char atl_buffer[100];
void main(void)
{
RTRT_FILE f ;
strcpy(atl_buffer,"Hello World ");
f=usr_open("cNewTdp\\atl.out");
usr_writeln(f,atl_buffer);
usr_close(f);
}
Execution command : a.out
When executing a.out, cNewTdp\atl.out will be created, and will contain "Hello World".
User Mode Example: BSO-Tasking Crossview
Source code of the program running on the target:
#define RTRT_FILE int
RTRT_FILE usr_open(char *fName) { return(1); }
void usr_writeln(RTRT_FILE f,char *s) { _simo(1,s,80); }
void usr_close(RTRT_FILE f) { ; }
char atl_buffer[100];
void main(void)
{
RTRT_FILE f ;
strcpy(atl_buffer,"Hello World");
f=usr_open("cNewTdp\\atl.out");
usr_writeln(f,atl_buffer);
usr_close(f);
}
Execution command from host:
xfw166.exe a.out -p TestRt.cmd
Content of TestRt.cmd:
1 sio o atl.out
r
q y
In this example, usr_open and usr_close functions are empty. Priv_writeln uses a BSO-Tasking function, _simo, which allows to send the content of the s parameter on the channel number 1 (an equivalent of a file handle).
On another side, on the host machine, the Crossview simulator (launched by the xfw166.exe program) is configured by the command
1 sio o atl.out
indicating to the simulator running on the host, that any character being written on the channel number 1 should be logged into a file name atl.out
The next command is to run the program, and quit at the end.
The original needs, which was to have cNewTdp\atl.out file be written on the host has to completed by a script on the host machine, consisting in moving the atl.out generated in the current directory into the cNewTdp directory. The complete execution step would be in Perl:
SystemP("xfw166.exe a.out -p TestRt.cmd");
If ( ! -r atl.out ) { Error…. return(1);}
move("atl.out","cNewTdp/atl.out");
Breakpoint-Mode :
In all the breakpoint mode examples, the usr_ functions are empty.
Breakpoint Mode Example: Keil MicroVision
Source code of the program running on the target:
#define RTRT_FILE int
RTRT_FILE usr_open(char *fName) { return(1); }
void usr_writeln(RTRT_FILE f,char *s) {;}
void usr_close(RTRT_FILE f) { ; }
char atl_buffer[100];
void main(void)
{
RTRT_FILE f ;
strcpy(atl_buffer,"Hello World");
f=usr_open("cNewTdp\\atl.out");
usr_writeln(f,atl_buffer);
usr_close(f);
}
Execution command from host:
uv2.exe -d TestRt.cmd
Content of TestRt.cmd:
load a.out
func void out(void) {
int i=0;
while(atl_buffer[i]) printf("%c",atl_buffer[i++]);
printf("\n");
}
bs usr_writeln,"out()"
bs usr_close
reset
log > Tmpatl.out
g
exit
In this example, all the usr_ functions are empty. The intelligence is deported into the TestRt.cmd script which a command file for the debugger.
It first loads a.out executable program. It then defines a function, which prints the value of atl_buffer in the MicroVision command window. Then it sets two breakpoints. The first one in usr_writeln, and the second one in usr_close. When usr_writeln is reached, the program halts, and the debugger automatically runs his out() function, which print the value of atl_buffer into its command window. When usr_close is reached, the program halts.
Then, the debugger scripts resets the processor, and logs anything that happens in the debugger command window into a file named Tmpatl.out. It then starts the execution, (which finally halts when usr_close is reached as no action is associated with this breakpoint) and exits.
The final result is contained into Tmpatl.out, which should be cleanup by the host (a little decoder in Perl for example) to give the final expected cNewTdp\atl.out file containing "Hello World". The global execution step in Perl would be:
SystemP("uv2.exe -d TestRt.cmd") ;
# Decode and clean Tmpatl.out and write the results in
# cNewTdp\atl.out
Decode_Tmpatl.out_Into_Final_Intermediate_Report();
Breakpoint Mode Example: PowerPC-SingleStep
Source code of the program running on the target:
#define RTRT_FILE int
RTRT_FILE usr_open(char *fName) { return(1); }
void usr_writeln(RTRT_FILE f,char *s) { _simo(1,s,80); }
void usr_close(RTRT_FILE f) { ; }
char atl_buffer[100];
void main(void)
{
RTRT_FILE f ;
strcpy(atl_buffer,"Hello World");
f=usr_open("cNewTdp\\atl.out");
usr_writeln(f,atl_buffer);
usr_close(f);
}
Execution command from host:
simppc.exe TestRt.cmd
Content of TestRt.cmd:
debug a.out
break usr_close
break usr_writeln -g -c "read atl_buffer >> Tmpatl.out"
go
exit
As in the previous example, all the usr_ functions are empty. The intelligence is deported into the TestRt.cmd script which a command file executed when the SingleStep debugger is launched.
It first loads the executable program, a.out by the debug command.
Then it sets a breakpoint at usr_close function, which serves as an exit-point, then set a breakpoint in the usr_writeln function. The -g flag of the break commmand indicates to continue the execution, whilest the -c specifies a command that should be executed before continuing. This command (read) writes the value of the atl_buffer variable into Tmpatl.out.
The SingleStep debugger then starts the execution. When it stops, it means than usr_close has been reached. It then executes the exit command, to terminate the debugging session.
The final result is contained into Tmpatl.out, and should be cleaned-up by the host (a little decoder in Perl for example) to produce the final expected cNewTdp\atl.out file containing "Hello World".
Based on the "Hello World" program, we should now focus on automating the execution step and having atl.out being written.