sc_report.cc revision 13157
112852Sgabeblack@google.com/* 212852Sgabeblack@google.com * Copyright 2018 Google, Inc. 312852Sgabeblack@google.com * 412852Sgabeblack@google.com * Redistribution and use in source and binary forms, with or without 512852Sgabeblack@google.com * modification, are permitted provided that the following conditions are 612852Sgabeblack@google.com * met: redistributions of source code must retain the above copyright 712852Sgabeblack@google.com * notice, this list of conditions and the following disclaimer; 812852Sgabeblack@google.com * redistributions in binary form must reproduce the above copyright 912852Sgabeblack@google.com * notice, this list of conditions and the following disclaimer in the 1012852Sgabeblack@google.com * documentation and/or other materials provided with the distribution; 1112852Sgabeblack@google.com * neither the name of the copyright holders nor the names of its 1212852Sgabeblack@google.com * contributors may be used to endorse or promote products derived from 1312852Sgabeblack@google.com * this software without specific prior written permission. 1412852Sgabeblack@google.com * 1512852Sgabeblack@google.com * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 1612852Sgabeblack@google.com * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 1712852Sgabeblack@google.com * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 1812852Sgabeblack@google.com * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 1912852Sgabeblack@google.com * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 2012852Sgabeblack@google.com * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 2112852Sgabeblack@google.com * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 2212852Sgabeblack@google.com * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 2312852Sgabeblack@google.com * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 2412852Sgabeblack@google.com * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 2512852Sgabeblack@google.com * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 2612852Sgabeblack@google.com * 2712852Sgabeblack@google.com * Authors: Gabe Black 2812852Sgabeblack@google.com */ 2912852Sgabeblack@google.com 3013157Sgabeblack@google.com#include <cstring> 3113157Sgabeblack@google.com 3212852Sgabeblack@google.com#include "base/logging.hh" 3312852Sgabeblack@google.com#include "systemc/ext/utils/sc_report.hh" 3412997Sgabeblack@google.com#include "systemc/ext/utils/sc_report_handler.hh" 3512852Sgabeblack@google.com 3612852Sgabeblack@google.comnamespace sc_core 3712852Sgabeblack@google.com{ 3812852Sgabeblack@google.com 3913157Sgabeblack@google.comsc_report::sc_report(sc_severity _severity, const char *msg_type, 4013157Sgabeblack@google.com const char *msg, int _verbosity, const char *_fileName, 4112997Sgabeblack@google.com int _lineNumber, sc_time _time, const char *_processName, int _id) : 4213157Sgabeblack@google.com _severity(_severity), _msgType(msg_type), _msg(msg), 4312997Sgabeblack@google.com _verbosity(_verbosity), _fileName(_fileName), _lineNumber(_lineNumber), 4412997Sgabeblack@google.com _time(_time), _processName(_processName), _id(_id) 4512852Sgabeblack@google.com{ 4613157Sgabeblack@google.com if (_msgType) 4713157Sgabeblack@google.com _msgType = strdup(_msgType); 4813157Sgabeblack@google.com if (_msg) 4913157Sgabeblack@google.com _msg = strdup(_msg); 5012997Sgabeblack@google.com _what = sc_report_compose_message(*this); 5112852Sgabeblack@google.com} 5212852Sgabeblack@google.com 5312997Sgabeblack@google.comsc_report::sc_report(const sc_report &r) : 5412997Sgabeblack@google.com sc_report(r._severity, r._msgType, r._msg, r._verbosity, r._fileName, 5512997Sgabeblack@google.com r._lineNumber, r._time, r._processName, r._id) 5612997Sgabeblack@google.com{} 5712997Sgabeblack@google.com 5812852Sgabeblack@google.comsc_report & 5912997Sgabeblack@google.comsc_report::operator = (const sc_report &r) 6012852Sgabeblack@google.com{ 6112997Sgabeblack@google.com _severity = r._severity; 6213157Sgabeblack@google.com free((void *)_msgType); 6313157Sgabeblack@google.com _msgType = r._msgType ? strdup(r._msgType) : nullptr; 6413157Sgabeblack@google.com free((void *)_msg); 6513157Sgabeblack@google.com _msg = r._msg ? strdup(r._msg) : nullptr; 6612997Sgabeblack@google.com _verbosity = r._verbosity; 6712997Sgabeblack@google.com _fileName = r._fileName; 6812997Sgabeblack@google.com _lineNumber = r._lineNumber; 6912997Sgabeblack@google.com _time = r._time; 7012997Sgabeblack@google.com _processName = r._processName; 7112997Sgabeblack@google.com _id = r._id; 7212852Sgabeblack@google.com return *this; 7312852Sgabeblack@google.com} 7412852Sgabeblack@google.com 7513157Sgabeblack@google.comsc_report::~sc_report() throw() 7613157Sgabeblack@google.com{ 7713157Sgabeblack@google.com free((void *)_msgType); 7813157Sgabeblack@google.com free((void *)_msg); 7913157Sgabeblack@google.com} 8012852Sgabeblack@google.com 8112852Sgabeblack@google.comconst char * 8212852Sgabeblack@google.comsc_report::what() const throw() 8312852Sgabeblack@google.com{ 8412997Sgabeblack@google.com return _what.c_str(); 8512852Sgabeblack@google.com} 8612852Sgabeblack@google.com 8712902Sgabeblack@google.comconst char * 8812902Sgabeblack@google.comsc_report::get_message(int id) 8912902Sgabeblack@google.com{ 9012902Sgabeblack@google.com warn("%s not implemented.\n", __PRETTY_FUNCTION__); 9112902Sgabeblack@google.com return ""; 9212902Sgabeblack@google.com} 9312902Sgabeblack@google.com 9412902Sgabeblack@google.combool 9512902Sgabeblack@google.comsc_report::is_suppressed(int id) 9612902Sgabeblack@google.com{ 9712902Sgabeblack@google.com warn("%s not implemented.\n", __PRETTY_FUNCTION__); 9812902Sgabeblack@google.com return false; 9912902Sgabeblack@google.com} 10012902Sgabeblack@google.com 10112902Sgabeblack@google.comvoid 10212902Sgabeblack@google.comsc_report::make_warnings_errors(bool) 10312902Sgabeblack@google.com{ 10412902Sgabeblack@google.com warn("%s not implemented.\n", __PRETTY_FUNCTION__); 10512902Sgabeblack@google.com} 10612902Sgabeblack@google.com 10712902Sgabeblack@google.comvoid 10812902Sgabeblack@google.comsc_report::register_id(int id, const char *msg) 10912902Sgabeblack@google.com{ 11012902Sgabeblack@google.com warn("%s not implemented.\n", __PRETTY_FUNCTION__); 11112902Sgabeblack@google.com} 11212902Sgabeblack@google.com 11312902Sgabeblack@google.comvoid 11412902Sgabeblack@google.comsc_report::suppress_id(int id, bool) 11512902Sgabeblack@google.com{ 11612902Sgabeblack@google.com warn("%s not implemented.\n", __PRETTY_FUNCTION__); 11712902Sgabeblack@google.com} 11812902Sgabeblack@google.com 11912902Sgabeblack@google.comvoid 12012902Sgabeblack@google.comsc_report::suppress_infos(bool) 12112902Sgabeblack@google.com{ 12212902Sgabeblack@google.com warn("%s not implemented.\n", __PRETTY_FUNCTION__); 12312902Sgabeblack@google.com} 12412902Sgabeblack@google.com 12512902Sgabeblack@google.comvoid 12612902Sgabeblack@google.comsc_report::suppress_warnings(bool) 12712902Sgabeblack@google.com{ 12812902Sgabeblack@google.com warn("%s not implemented.\n", __PRETTY_FUNCTION__); 12912902Sgabeblack@google.com} 13012902Sgabeblack@google.com 13112852Sgabeblack@google.comvoid 13212852Sgabeblack@google.comsc_abort() 13312852Sgabeblack@google.com{ 13412997Sgabeblack@google.com panic("simulation aborted"); 13512852Sgabeblack@google.com} 13612852Sgabeblack@google.com 13712852Sgabeblack@google.com} // namespace sc_core 138