CacheRecorder.cc revision 6145
15703SN/A
25703SN/A/*
35703SN/A * Copyright (c) 1999-2008 Mark D. Hill and David A. Wood
49988Snilay@cs.wisc.edu * All rights reserved.
58825Snilay@cs.wisc.edu *
69988Snilay@cs.wisc.edu * Redistribution and use in source and binary forms, with or without
77935SN/A * modification, are permitted provided that the following conditions are
87935SN/A * met: redistributions of source code must retain the above copyright
97935SN/A * notice, this list of conditions and the following disclaimer;
105703SN/A * redistributions in binary form must reproduce the above copyright
115703SN/A * notice, this list of conditions and the following disclaimer in the
125703SN/A * documentation and/or other materials provided with the distribution;
1310315Snilay@cs.wisc.edu * neither the name of the copyright holders nor the names of its
145703SN/A * contributors may be used to endorse or promote products derived from
155703SN/A * this software without specific prior written permission.
169885Sstever@gmail.com *
179885Sstever@gmail.com * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
1810900Snilay@cs.wisc.edu * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
199988Snilay@cs.wisc.edu * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
205703SN/A * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
2110900Snilay@cs.wisc.edu * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
2210315Snilay@cs.wisc.edu * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
237670SN/A * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
2410242Ssteve.reinhardt@amd.com * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
255703SN/A * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
269449SAli.Saidi@ARM.com * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
278464SN/A * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
2810798Ssteve.reinhardt@amd.com */
298721SN/A
3010900Snilay@cs.wisc.edu/*
3110900Snilay@cs.wisc.edu * $Id$
325703SN/A *
335703SN/A */
345703SN/A
357935SN/A#include "CacheRecorder.hh"
367935SN/A#include "TraceRecord.hh"
377935SN/A#include "EventQueue.hh"
387935SN/A#include "PrioHeap.hh"
397935SN/A#include "gzstream.hh"
407935SN/A
417935SN/ACacheRecorder::CacheRecorder()
428983Snate@binkert.org{
435703SN/A  m_records_ptr = new PrioHeap<TraceRecord>;
445703SN/A}
455703SN/A
469885Sstever@gmail.comCacheRecorder::~CacheRecorder()
475703SN/A{
489988Snilay@cs.wisc.edu  delete m_records_ptr;
498721SN/A}
508721SN/A
518721SN/Avoid CacheRecorder::addRecord(NodeID id, const Address& data_addr, const Address& pc_addr, CacheRequestType type, Time time)
528983Snate@binkert.org{
538983Snate@binkert.org  m_records_ptr->insert(TraceRecord(id, data_addr, pc_addr, type, time));
545703SN/A}
559885Sstever@gmail.com
569885Sstever@gmail.comint CacheRecorder::dumpRecords(string filename)
579885Sstever@gmail.com{
5810315Snilay@cs.wisc.edu  ogzstream out(filename.c_str());
599988Snilay@cs.wisc.edu  if (out.fail()) {
6010315Snilay@cs.wisc.edu    cout << "Error: error opening file '" << filename << "'" << endl;
619885Sstever@gmail.com    return 0;
629885Sstever@gmail.com  }
635703SN/A
645703SN/A  int counter = 0;
659481Snilay@cs.wisc.edu  while (m_records_ptr->size() != 0) {
665703SN/A    TraceRecord record = m_records_ptr->extractMin();
675703SN/A    record.output(out);
688241SN/A    counter++;
698241SN/A  }
705703SN/A  return counter;
715703SN/A}
725703SN/A
735703SN/Avoid CacheRecorder::print(ostream& out) const
749481Snilay@cs.wisc.edu{
755703SN/A}
765876SN/A