Main Page   Compound List   File List   Compound Members   File Members  

main.cc File Reference

The code for raw-reference-binary-to-text. More...

#include <stdio.h>
#include <stdlib.h>

Go to the source code of this file.

Compounds

struct  reference_record_s
 A record structure in which a reference record will be passed and stored. More...


Typedefs

typedef char tag_t
 The type for the tag that indicates the type of a reference.

typedef unsigned long long int timestamp_t
 The type for the cycle counter timestamp.

typedef unsigned char length_t
 The type for length values.

typedef unsigned long int address_space_ID_t
 The type for the address space identifier, a.k.a. the page number holding the base level of the page table.

typedef unsigned long int address_t
 The type for virtual addresses.


Functions

int main (const unsigned int argc, const char **const argv)
 The entry point.


Variables

const tag_t TAG_END_OF_TRACE = 'e'


Detailed Description

The code for raw-reference-binary-to-text.

Author:
Scott F. H. Kaplan <sfkaplan@cs.amherst.edu>
Date:
December 2002
This file contains all of the code for raw-reference-binary-to-text, which converts the binary output of the Laplace raw reference trace into a simple text format. Note that this version is not optimized: It relies on printf() to produce the output, and performs no buffering of its own output. Such optimizations should be applied later, as reference handling is the key bottleneck to trace collection.

Definition in file main.cc.


Typedef Documentation

typedef unsigned long int address_space_ID_t
 

The type for the address space identifier, a.k.a. the page number holding the base level of the page table.

Definition at line 42 of file main.cc.

typedef unsigned long int address_t
 

The type for virtual addresses.

Definition at line 45 of file main.cc.

typedef unsigned char length_t
 

The type for length values.

Definition at line 38 of file main.cc.

typedef char tag_t
 

The type for the tag that indicates the type of a reference.

Definition at line 32 of file main.cc.

typedef unsigned long long int timestamp_t
 

The type for the cycle counter timestamp.

Definition at line 35 of file main.cc.


Function Documentation

int main const unsigned int    argc,
const char **const    argv
 

The entry point.

Parameters:
argc The number of arguments given at the command line.
argv The vector of argument strings passed at the command line.
Returns:
An execution result code.
Parse the command line arguments. For this utility, there should be none, as input is taken from stdin, and output is sent to stdout.

Definition at line 85 of file main.cc.

References reference_record_s::tag, and TAG_END_OF_TRACE.

00085                                                         {
00086 
00087   // Were the correct number of arguments passed?
00088   if (argc != 1) {
00089 
00090     // No.  Emit usage and exit.
00091     fprintf(stderr, "Usage: %s <NO ARGUMENTS>\n", argv[0]);
00092     return 1;
00093 
00094   }
00095 
00096   // Allocate a single reference record into which the binary source
00097   // will be read, one record at a time.
00098   reference_record_s binary_record;
00099 
00100   // Read binary records until the end of the trace has been reached.
00101   do {
00102 
00103     // Attempt to read the next record.
00104     size_t read_result = fread(&binary_record,
00105              sizeof(binary_record),
00106              1,
00107              stdin);
00108 
00109     // Ensure that the read succeeded; otherwise, bail out.
00110     if (read_result != 1) {
00111 
00112       if (feof(stdin)) {
00113   fprintf(stderr, "Premature EOF\n");
00114       } else {
00115   fprintf(stderr, "Failed in reading binary record\n");
00116       }
00117 
00118       exit(1);
00119 
00120     }
00121 
00122     // Emit the binary record as text.  If the record is the
00123     // end-of-trace record, then emit just the tag.
00124     if (binary_record.tag == TAG_END_OF_TRACE) {
00125 
00126       printf("%c\n", binary_record.tag);
00127 
00128     } else {
00129 
00130       printf("%c %qx %hx %lx %lx\n",
00131        binary_record.tag,
00132        binary_record.timestamp,
00133        binary_record.length,
00134        binary_record.address_space_ID,
00135        binary_record.virtual_address);
00136 
00137     }
00138 
00139   } while (binary_record.tag != TAG_END_OF_TRACE);
00140 
00141   // Exit successfully.
00142   return 0;
00143 
00144 } // main


Variable Documentation

const tag_t TAG_END_OF_TRACE = 'e'
 

Definition at line 65 of file main.cc.

Referenced by main().


Generated on Tue Jan 21 10:43:31 2003 for raw-reference-binary-to-text by doxygen1.3-rc2