blob: ed9da966ec8f746a4501224c5c2261cebd645c3d (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
|
/*! @file CoverageWriterTSIM.cc
* @brief CoverageWriterTSIM Implementation
*
* This file contains the implementation of the CoverageWriter class
* for the coverage files written by the SPARC simulator TSIM.
*/
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <fstream>
#include <iomanip>
#include <rld.h>
#include "CoverageWriterTSIM.h"
namespace Coverage {
CoverageWriterTSIM::CoverageWriterTSIM()
{
}
CoverageWriterTSIM::~CoverageWriterTSIM()
{
}
void CoverageWriterTSIM::writeFile(
const std::string& file,
CoverageMapBase* coverage,
uint32_t lowAddress,
uint32_t highAddress
)
{
uint32_t a;
int cover;
std::ofstream coverageFile;
int i;
/*
* read the file and update the coverage map passed in
*/
coverageFile.open( file );
if ( !coverageFile.is_open() ) {
std::ostringstream what;
what << "Unable to open " << file;
throw rld::error( what, "CoverageWriterTSIM::writeFile" );
}
for ( a = lowAddress; a < highAddress; a += 0x80 ) {
coverageFile << std::hex << a << " : " << std::dec;
if ( coverageFile.fail() ) {
break;
}
for ( i = 0; i < 0x80; i += 4 ) {
cover = ( ( coverage->wasExecuted( a + i ) ) ? 1 : 0 );
coverageFile << cover << " ";
if ( coverageFile.fail() ) {
std::ostringstream what;
what << "write to " << file
<< " at address 0x"
<< std::hex << std::setfill( '0' )
<< std::setw( 8 ) << a
<< std::setfill( ' ' ) << std::dec
<< "failed";
throw rld::error( what, "CoverageWriterTSIM::writeFile" );
}
}
coverageFile << std::endl;
}
}
}
|