#include <Basic_Consumer.hh>
Inheritance diagram for Basic_Consumer:
Public Methods | |
Basic_Consumer (Reference_Reader *const reference_reader, const char *const kernel_pathname, const char *const output_file_pathname) | |
The constructor. | |
virtual | ~Basic_Consumer () |
The deconstructor. | |
Protected Methods | |
virtual void | initialize () |
Called before processing begins -- Does nothing. | |
virtual void | clean_up () |
Called after processing ends -- Does nothing. | |
virtual void | act_on_reference_record () |
Called after processing a reference record. | |
virtual void | act_on_kernel_record () |
Called after processing a kernel record -- Does nothing. | |
Protected Attributes | |
FILE * | output_stream |
The output file stream. |
It relies on Consumer to reconcile virtual pages to canonical pages, and then emits a string of references to those canonical pages.
Definition at line 54 of file Basic_Consumer.hh.
|
The constructor.
Definition at line 35 of file Basic_Consumer.cc. References output_stream.
00037 : 00038 Consumer(reference_reader, kernel_pathname) { 00039 00040 // Open the output file, checking for success. 00041 output_stream = fopen(output_file_pathname, "w"); 00042 if (output_stream == NULL) { 00043 perror("Failure opening output file"); 00044 exit(1); 00045 } 00046 00047 } // Basic_Consumer::Basic_Consumer // =================================================================== |
|
The deconstructor. Close the output file. Definition at line 53 of file Basic_Consumer.cc.
00053 { 00054 00055 // Close the output file, checking for success. 00056 int close_result = fclose(output_stream); 00057 if (close_result == EOF) { 00058 perror("Failure closing output file"); 00059 exit(1); 00060 } 00061 00062 } // Basic_Consumer::~Basic_Consumer |
|
Called after processing a kernel record -- Does nothing.
Implements Consumer. Definition at line 97 of file Basic_Consumer.hh.
00097 {} |
|
Called after processing a reference record. Transform the reference type into one valid for the output trace. Lookup the canonical page underlying the referenced virtual page. Emit both to the output trace. Implements Consumer. Definition at line 69 of file Basic_Consumer.cc. References canonical_page_ID_t, virtual_page_s::context_ID, context_ID_t, KERNEL_CONTEXT, KERNEL_VIRTUAL_PAGE_OFFSET, Consumer::lookup_canonical_page_ID(), virtual_page_s::page_ID, Consumer::reference_record, Consumer::safe_context_ID_to_process(), reference_record_s::tag, TAG_KERNEL_INSTRUCTION_FETCH, TAG_KERNEL_READ, TAG_KERNEL_WRITE, tag_t, TAG_USER_INSTRUCTION_FETCH, TAG_USER_READ, TAG_USER_WRITE, reference_record_s::virtual_page, Process::virtual_to_canonical_map, and virtual_to_canonical_map_t.
00069 { 00070 00071 // Convert the input record's tag to a valid output tag. 00072 tag_t output_tag = 0; 00073 switch (reference_record->tag) { 00074 00075 case TAG_USER_READ: 00076 case TAG_KERNEL_READ: 00077 case TAG_USER_INSTRUCTION_FETCH: 00078 case TAG_KERNEL_INSTRUCTION_FETCH: 00079 00080 output_tag = TAG_KERNEL_READ; 00081 break; 00082 00083 case TAG_USER_WRITE: 00084 case TAG_KERNEL_WRITE: 00085 00086 output_tag = TAG_KERNEL_WRITE; 00087 break; 00088 00089 default: 00090 fprintf(stderr, 00091 "act_on_reference_record(): Invalid tag %c(%d)\n", 00092 reference_record->tag, 00093 (int)reference_record->tag); 00094 exit(1); 00095 00096 } 00097 00098 // If the page referenced is in the kernel's address range, we need 00099 // to use the kernel's context. 00100 context_ID_t context_ID; 00101 if (reference_record->virtual_page.page_ID < 00102 KERNEL_VIRTUAL_PAGE_OFFSET) { 00103 00104 context_ID = reference_record->virtual_page.context_ID; 00105 00106 } else { 00107 00108 context_ID = KERNEL_CONTEXT; 00109 00110 } 00111 Process* process = safe_context_ID_to_process(context_ID); 00112 virtual_to_canonical_map_t* map = process->virtual_to_canonical_map; 00113 00114 // Lookup the canonical page ID if one exists. 00115 bool V2C_mapping_exists; 00116 canonical_page_ID_t canonical_page_ID; 00117 lookup_canonical_page_ID(&V2C_mapping_exists, 00118 &canonical_page_ID, 00119 map, 00120 reference_record->virtual_page.page_ID); 00121 00122 // Emit the new record only if a mapping was found (that is, if this 00123 // is not a reference to a buffer cache page). 00124 if (V2C_mapping_exists) { 00125 fprintf(output_stream, "%c %lx\n", output_tag, canonical_page_ID); 00126 } 00127 00128 } // act_on_reference_record |
|
Called after processing ends -- Does nothing.
Implements Consumer. Definition at line 84 of file Basic_Consumer.hh.
00084 {} |
|
Called before processing begins -- Does nothing.
Implements Consumer. Definition at line 81 of file Basic_Consumer.hh.
00081 {} |
|
The output file stream.
Definition at line 102 of file Basic_Consumer.hh. Referenced by Basic_Consumer(). |