sc_logger.hh revision 13372
113372Sgabeblack@google.com/* 213372Sgabeblack@google.com * Copyright (c) 2014 ARM Limited 313372Sgabeblack@google.com * All rights reserved 413372Sgabeblack@google.com * 513372Sgabeblack@google.com * The license below extends only to copyright in the software and shall 613372Sgabeblack@google.com * not be construed as granting a license to any other intellectual 713372Sgabeblack@google.com * property including but not limited to intellectual property relating 813372Sgabeblack@google.com * to a hardware implementation of the functionality of the software 913372Sgabeblack@google.com * licensed hereunder. You may use the software subject to the license 1013372Sgabeblack@google.com * terms below provided that you ensure that this notice is replicated 1113372Sgabeblack@google.com * unmodified and in its entirety in all distributions of the software, 1213372Sgabeblack@google.com * modified or unmodified, in source code or in binary form. 1313372Sgabeblack@google.com * 1413372Sgabeblack@google.com * Redistribution and use in source and binary forms, with or without 1513372Sgabeblack@google.com * modification, are permitted provided that the following conditions are 1613372Sgabeblack@google.com * met: redistributions of source code must retain the above copyright 1713372Sgabeblack@google.com * notice, this list of conditions and the following disclaimer; 1813372Sgabeblack@google.com * redistributions in binary form must reproduce the above copyright 1913372Sgabeblack@google.com * notice, this list of conditions and the following disclaimer in the 2013372Sgabeblack@google.com * documentation and/or other materials provided with the distribution; 2113372Sgabeblack@google.com * neither the name of the copyright holders nor the names of its 2213372Sgabeblack@google.com * contributors may be used to endorse or promote products derived from 2313372Sgabeblack@google.com * this software without specific prior written permission. 2413372Sgabeblack@google.com * 2513372Sgabeblack@google.com * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 2613372Sgabeblack@google.com * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 2713372Sgabeblack@google.com * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 2813372Sgabeblack@google.com * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 2913372Sgabeblack@google.com * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 3013372Sgabeblack@google.com * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 3113372Sgabeblack@google.com * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 3213372Sgabeblack@google.com * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 3313372Sgabeblack@google.com * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 3413372Sgabeblack@google.com * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 3513372Sgabeblack@google.com * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 3613372Sgabeblack@google.com * 3713372Sgabeblack@google.com * Authors: Andrew Bardsley 3813372Sgabeblack@google.com */ 3913372Sgabeblack@google.com 4013372Sgabeblack@google.com/** 4113372Sgabeblack@google.com * @file 4213372Sgabeblack@google.com * 4313372Sgabeblack@google.com * A logger to allow SystemC to capture DPRINTF messages (and similar things) 4413372Sgabeblack@google.com * using sc_report 4513372Sgabeblack@google.com */ 4613372Sgabeblack@google.com 4713372Sgabeblack@google.com#ifndef __SIM_SC_LOGGER_H__ 4813372Sgabeblack@google.com#define __SIM_SC_LOGGER_H__ 4913372Sgabeblack@google.com 5013372Sgabeblack@google.com#include <systemc> 5113372Sgabeblack@google.com 5213372Sgabeblack@google.com#include "base/trace.hh" 5313372Sgabeblack@google.com 5413372Sgabeblack@google.comnamespace Gem5SystemC 5513372Sgabeblack@google.com{ 5613372Sgabeblack@google.com 5713372Sgabeblack@google.com/** sc_report logging class */ 5813372Sgabeblack@google.comclass Logger : public Trace::Logger 5913372Sgabeblack@google.com{ 6013372Sgabeblack@google.com protected: 6113372Sgabeblack@google.com /** Stream to offer getOstream. This will cut messages up newlines and 6213372Sgabeblack@google.com * offer them to logMessage */ 6313372Sgabeblack@google.com std::streambuf *cuttingStreambuf; 6413372Sgabeblack@google.com std::ostream stream; 6513372Sgabeblack@google.com 6613372Sgabeblack@google.com public: 6713372Sgabeblack@google.com Logger(); 6813372Sgabeblack@google.com 6913372Sgabeblack@google.com ~Logger(); 7013372Sgabeblack@google.com 7113372Sgabeblack@google.com /** Log a single message as a single sc_report call */ 7213372Sgabeblack@google.com void logMessage(Tick when, const std::string &name, 7313372Sgabeblack@google.com const std::string &message); 7413372Sgabeblack@google.com 7513372Sgabeblack@google.com std::ostream &getOstream(); 7613372Sgabeblack@google.com}; 7713372Sgabeblack@google.com 7813372Sgabeblack@google.com} 7913372Sgabeblack@google.com 8013372Sgabeblack@google.com#endif // __SIM_SC_LOGGER_H__ 81