diff options
-rw-r--r-- | arch/alpha/alpha_memory.cc | 8 | ||||
-rw-r--r-- | arch/alpha/ev5.cc | 10 | ||||
-rw-r--r-- | arch/alpha/isa_desc | 47 | ||||
-rw-r--r-- | base/fast_alloc.cc | 4 | ||||
-rw-r--r-- | base/fast_alloc.hh | 9 | ||||
-rw-r--r-- | base/hostinfo.cc | 29 | ||||
-rw-r--r-- | base/hostinfo.hh | 4 | ||||
-rw-r--r-- | base/pollevent.cc | 4 | ||||
-rw-r--r-- | base/statistics.cc | 10 | ||||
-rw-r--r-- | base/statistics.hh | 4 | ||||
-rw-r--r-- | base/str.hh | 2 | ||||
-rw-r--r-- | base/time.cc | 130 | ||||
-rw-r--r-- | base/time.hh (renamed from sim/sim_time.hh) | 67 | ||||
-rw-r--r-- | base/trace.hh | 2 | ||||
-rw-r--r-- | sim/main.cc | 2 | ||||
-rw-r--r-- | sim/sim_time.cc | 164 | ||||
-rwxr-xr-x | util/rundiff | 14 |
17 files changed, 266 insertions, 244 deletions
diff --git a/arch/alpha/alpha_memory.cc b/arch/alpha/alpha_memory.cc index c79b821d0..d934299b8 100644 --- a/arch/alpha/alpha_memory.cc +++ b/arch/alpha/alpha_memory.cc @@ -436,12 +436,12 @@ AlphaDtb::translate(MemReqPtr req, bool write) const else read_accesses++; - AlphaISA::md_mode_type mode = - (AlphaISA::md_mode_type)DTB_CM_CM(ipr[AlphaISA::IPR_DTB_CM]); + AlphaISA::mode_type mode = + (AlphaISA::mode_type)DTB_CM_CM(ipr[AlphaISA::IPR_DTB_CM]); if (PC_PAL(pc)) { - mode = (req->flags & ALTMODE) ? (AlphaISA::md_mode_type) - (ALT_MODE_AM(ipr[AlphaISA::IPR_ALT_MODE])) + mode = (req->flags & ALTMODE) ? + (AlphaISA::mode_type)ALT_MODE_AM(ipr[AlphaISA::IPR_ALT_MODE]) : AlphaISA::mode_kernel; } diff --git a/arch/alpha/ev5.cc b/arch/alpha/ev5.cc index 6759fdbf9..8494ee9f6 100644 --- a/arch/alpha/ev5.cc +++ b/arch/alpha/ev5.cc @@ -551,16 +551,14 @@ ExecContext::simPalCheck(int palFunc) switch (palFunc) { case PAL::halt: - if (!misspeculating()) { - halt(); - if (--System::numSystemsRunning == 0) - new SimExitEvent("all cpus halted"); - } + halt(); + if (--System::numSystemsRunning == 0) + new SimExitEvent("all cpus halted"); break; case PAL::bpt: case PAL::bugchk: - if (!misspeculating() && system->breakpoint()) + if (system->breakpoint()) return false; break; } diff --git a/arch/alpha/isa_desc b/arch/alpha/isa_desc index aef9135d3..f0a4699f4 100644 --- a/arch/alpha/isa_desc +++ b/arch/alpha/isa_desc @@ -1399,6 +1399,7 @@ declare {{ protected: int palFunc; ///< Function code part of instruction int palOffset; ///< Target PC, offset from IPR_PAL_BASE + bool palValid; ///< is the function code valid? bool palPriv; ///< is this call privileged? /// Constructor. @@ -1407,9 +1408,22 @@ declare {{ : AlphaStaticInst(mnem, _machInst, __opClass), palFunc(PALFUNC) { - palPriv = ((machInst & 0x80) != 0); - int shortPalFunc = (machInst & 0x3f); - palOffset = 0x2001 + (palPriv << 12) + (shortPalFunc << 6); + // From the 21164 HRM (paraphrased): + // Bit 7 of the function code (mask 0x80) indicates + // whether the call is privileged (bit 7 == 0) or + // unprivileged (bit 7 == 1). The privileged call table + // starts at 0x2000, the unprivielged call table starts at + // 0x3000. Bits 5-0 (mask 0x3f) are used to calculate the + // offset. + const int palPrivMask = 0x80; + const int palOffsetMask = 0x3f; + + // Pal call is invalid unless all other bits are 0 + palValid = ((machInst & ~(palPrivMask | palOffsetMask)) == 0); + palPriv = ((machInst & palPrivMask) == 0); + int shortPalFunc = (machInst & palOffsetMask); + // Add 1 to base to set pal-mode bit + palOffset = (palPriv ? 0x2001 : 0x3001) + (shortPalFunc << 6); } std::string generateDisassembly(Addr pc, const SymbolTable *symtab) @@ -2353,24 +2367,33 @@ decode OPCODE default Unknown::unknown() { #ifdef FULL_SYSTEM 0x00: CallPal::call_pal({{ - if (palPriv && !PC_PAL(xc->regs.pc)) { - // attempt to do privileged PAL call in non-PAL mode + if (!palValid || + (palPriv + && xc->readIpr(AlphaISA::IPR_ICM, fault) != AlphaISA::mode_kernel)) { + // invalid pal function code, or attempt to do privileged + // PAL call in non-kernel mode fault = Unimplemented_Opcode_Fault; } else { - // check to see if simulator wants to do something special - // on this PAL call (including maybe suppress it) - bool dopal = xc->simPalCheck(palFunc); + bool dopal = true; if (!xc->misspeculating()) { + // check to see if simulator wants to do something special + // on this PAL call (including maybe suppress it) + dopal = xc->simPalCheck(palFunc); + Annotate::Callpal(xc, palFunc); - } - if (dopal) { - if (!xc->misspeculating()) { + if (dopal) { AlphaISA::swap_palshadow(&xc->regs, true); + xc->setIpr(AlphaISA::IPR_EXC_ADDR, NPC); } - xc->setIpr(AlphaISA::IPR_EXC_ADDR, NPC); + } + + // if we're misspeculating, it's still safe (if + // unrealistic) to set NPC, as the control-flow change + // won't get committed. + if (dopal) { NPC = xc->readIpr(AlphaISA::IPR_PAL_BASE, fault) + palOffset; } } diff --git a/base/fast_alloc.cc b/base/fast_alloc.cc index ff0a40c37..abb50aa0c 100644 --- a/base/fast_alloc.cc +++ b/base/fast_alloc.cc @@ -32,6 +32,8 @@ * by permission. */ +#ifndef NO_FAST_ALLOC + #ifdef __GNUC__ #pragma implementation #endif @@ -189,3 +191,5 @@ fast_alloc_oldest(int n) } #endif + +#endif // NO_FAST_ALLOC diff --git a/base/fast_alloc.hh b/base/fast_alloc.hh index 7d699abd1..81f2f1359 100644 --- a/base/fast_alloc.hh +++ b/base/fast_alloc.hh @@ -68,6 +68,13 @@ // (by bucket). // #define FAST_ALLOC_STATS +#ifdef NO_FAST_ALLOC + +class FastAlloc { +}; + +#else + class FastAlloc { public: @@ -200,4 +207,6 @@ void FastAlloc::operator delete(void *p, size_t sz) deallocate(p, sz); } +#endif // NO_FAST_ALLOC + #endif // __FAST_ALLOC_H__ diff --git a/base/hostinfo.cc b/base/hostinfo.cc index 5efb77356..cb5c04efc 100644 --- a/base/hostinfo.cc +++ b/base/hostinfo.cc @@ -26,16 +26,37 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#include <stdarg.h> -#include <stdio.h> -#include <stdlib.h> -#include <string.h> #include <ctype.h> #include <errno.h> #include <math.h> +#include <unistd.h> +#include <cstdio> +#include <cstdlib> +#include <cstring> +#include <string> + +#include "base/misc.hh" #include "sim/host.hh" +using namespace std; + +string +__get_hostname() +{ + char host[256]; + if (gethostname(host, sizeof host) == -1) + warn("could not get host name!"); + return host; +} + +string & +hostname() +{ + static string hostname = __get_hostname(); + return hostname; +} + uint64_t procInfo(char *filename, char *target) { diff --git a/base/hostinfo.hh b/base/hostinfo.hh index 2293d2b6a..453a1e69a 100644 --- a/base/hostinfo.hh +++ b/base/hostinfo.hh @@ -29,8 +29,12 @@ #ifndef __HOSTINFO_HH__ #define __HOSTINFO_HH__ +#include <string> + #include "sim/host.hh" +std::string &hostname(); + uint64_t procInfo(char *filename, char *target); inline uint64_t memUsage() diff --git a/base/pollevent.cc b/base/pollevent.cc index 619bda887..60a20bd2e 100644 --- a/base/pollevent.cc +++ b/base/pollevent.cc @@ -223,14 +223,14 @@ PollQueue::setupHandler() act.sa_handler = handleIO; sigemptyset(&act.sa_mask); - act.sa_flags = 0; + act.sa_flags = SA_RESTART; if (sigaction(SIGIO, &act, &oldio) == -1) panic("could not do sigaction"); act.sa_handler = handleALRM; sigemptyset(&act.sa_mask); - act.sa_flags = 0; + act.sa_flags = SA_RESTART; if (sigaction(SIGALRM, &act, &oldalrm) == -1) panic("could not do sigaction"); diff --git a/base/statistics.cc b/base/statistics.cc index fe20a7281..726ea3c60 100644 --- a/base/statistics.cc +++ b/base/statistics.cc @@ -223,7 +223,10 @@ Data::mapStat(void *stat, StatData *data) allStats.push_back(data); - bool success = (statMap.insert(make_pair(stat, data))).second; +#ifndef NDEBUG + bool success = +#endif + (statMap.insert(make_pair(stat, data))).second; assert(statMap.find(stat) != statMap.end()); assert(success && "this should never fail"); } @@ -236,7 +239,10 @@ Data::regBin(MainBin *bin, string name) bins.push_back(bin); - bool success = (bin_names.insert(make_pair(bin,name))).second; +#ifndef NDEBUG + bool success = +#endif + (bin_names.insert(make_pair(bin,name))).second; assert(bin_names.find(bin) != bin_names.end()); assert(success && "this should not fail"); diff --git a/base/statistics.hh b/base/statistics.hh index 732d1766a..ed3278e4a 100644 --- a/base/statistics.hh +++ b/base/statistics.hh @@ -1138,6 +1138,8 @@ class Vector2dBase : public DataAccess protected: typedef Storage<T> storage_t; typedef typename storage_t::Params params_t; + + public: typedef typename Bin::VectorBin<storage_t> bin_t; protected: @@ -1675,6 +1677,8 @@ class VectorDistBase : public DataAccess protected: typedef Storage<T> storage_t; typedef typename storage_t::Params params_t; + + public: typedef typename Bin::VectorBin<storage_t> bin_t; protected: diff --git a/base/str.hh b/base/str.hh index 29d2c03db..6c3453b8b 100644 --- a/base/str.hh +++ b/base/str.hh @@ -98,7 +98,7 @@ template <class T> bool to_number(const std::string &value, T &retval); template <class T> -std::string +inline std::string to_string(const T& value) { std::stringstream str; diff --git a/base/time.cc b/base/time.cc new file mode 100644 index 000000000..d2e8f60a5 --- /dev/null +++ b/base/time.cc @@ -0,0 +1,130 @@ +/* + * Copyright (c) 2003 The Regents of The University of Michigan + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer; + * redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution; + * neither the name of the copyright holders nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include <sys/types.h> +#include <sys/time.h> +#include <time.h> +#include <iostream> +#include <string> + +#include "base/time.hh" + +using namespace std; + +struct _timeval +{ + timeval tv; +}; + +double +convert(const timeval &tv) +{ + return (double)tv.tv_sec + (double)tv.tv_usec / 1000000.0; +} + +Time::Time() +{ + time = new _timeval; + ::gettimeofday(&time->tv, NULL); +} + +Time::Time(const timeval &val) +{ + time = new _timeval; + set(val); +} + +Time::Time(const Time &val) +{ + time = new _timeval; + set(val.get()); +} + +Time::~Time() +{ + delete time; +} + +const timeval & +Time::get() const +{ + return time->tv; +} + +void +Time::set(const timeval &tv) +{ + memcpy(&time->tv, &tv, sizeof(timeval)); +} + +void +Time::reset() +{ + ::gettimeofday(&time->tv, NULL); +} + +double +Time::operator()() const +{ + return convert(get()); +} + +string +Time::date(string format) const +{ + const timeval &tv = get(); + time_t sec = tv.tv_sec; + char buf[256]; + + if (format.empty()) { + ctime_r(&sec, buf); + buf[24] = '\0'; + return buf; + } + + struct tm *tm = localtime(&sec); + strftime(buf, sizeof(buf), format.c_str(), tm); + return buf; +} + +ostream & +operator<<(ostream &out, const Time &start) +{ + out << start.date(); + return out; +} + +Time +operator-(const Time &l, const Time &r) +{ + timeval tv; + timersub(&l.get(), &r.get(), &tv); + return tv; +} + +const Time Time::start; diff --git a/sim/sim_time.hh b/base/time.hh index 02ca5534f..64da52e1d 100644 --- a/sim/sim_time.hh +++ b/base/time.hh @@ -32,59 +32,34 @@ #include <sys/time.h> #include <iosfwd> +#include <string> -namespace Time { - struct _timeval; - class Start - { - private: - mutable _timeval *start; +struct _timeval; - public: - Start(); - ~Start(); +class Time +{ + protected: + mutable _timeval *time; - const timeval &get() const; - void reset(); - double operator()() const; - }; + public: + Time(); + Time(const timeval &val); + Time(const Time &val); + ~Time(); - class Now - { - private: - mutable _timeval *now; + const timeval &get() const; + void set(const timeval &val); - public: - Now(); - ~Now(); + void reset(); + double operator()() const; + std::string date(std::string format = "") const; - const timeval &get() const; - double operator()() const; - }; + public: + static const Time start; +}; - class Elapsed - { - private: - mutable _timeval *elapsed; - Start _start; - Now _now; +Time operator-(const Time &l, const Time &r); - public: - Elapsed(); - ~Elapsed(); - - const timeval &get() const; - void reset(); - double operator()() const; - }; - - extern Start start; - extern Now now; - extern Elapsed elapsed; - - std::ostream &operator<<(std::ostream &out, const Start &start); - std::ostream &operator<<(std::ostream &out, const Now &now); - std::ostream &operator<<(std::ostream &out, const Elapsed &elapsed); -} +std::ostream &operator<<(std::ostream &out, const Time &time); #endif // __SIM_TIME_HH__ diff --git a/base/trace.hh b/base/trace.hh index 805a925a6..5aeaac445 100644 --- a/base/trace.hh +++ b/base/trace.hh @@ -36,7 +36,7 @@ #include "sim/universe.hh" #ifndef TRACING_ON -#ifdef DEBUG +#ifndef NDEBUG #define TRACING_ON 1 #else #define TRACING_ON 0 diff --git a/sim/main.cc b/sim/main.cc index 287b3d6e6..3cb6c8b71 100644 --- a/sim/main.cc +++ b/sim/main.cc @@ -42,6 +42,7 @@ #include "base/misc.hh" #include "base/pollevent.hh" #include "base/statistics.hh" +#include "base/time.hh" #include "cpu/base_cpu.hh" #include "cpu/full_cpu/smt.hh" #include "sim/async.hh" @@ -52,7 +53,6 @@ #include "sim/sim_exit.hh" #include "sim/sim_object.hh" #include "sim/sim_stats.hh" -#include "sim/sim_time.hh" using namespace std; diff --git a/sim/sim_time.cc b/sim/sim_time.cc deleted file mode 100644 index 09c5a66de..000000000 --- a/sim/sim_time.cc +++ /dev/null @@ -1,164 +0,0 @@ -/* - * Copyright (c) 2003 The Regents of The University of Michigan - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer; - * redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution; - * neither the name of the copyright holders nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#include <sys/types.h> -#include <sys/time.h> -#include <time.h> -#include <iostream> - -#include "sim/sim_time.hh" - -using namespace std; - -namespace Time -{ - struct _timeval - { - timeval tv; - }; - - double - convert(const timeval &tv) - { - return (double)tv.tv_sec + (double)tv.tv_usec / 1000000.0; - } - - Start::Start() - { - start = new _timeval; - ::gettimeofday(&start->tv, NULL); - } - - Start::~Start() - { - delete start; - } - - const timeval & - Start::get() const - { - return start->tv; - } - - void - Start::reset() - { - ::gettimeofday(&start->tv, NULL); - } - - double - Start::operator()() const - { - return convert(get()); - } - - Now::Now() - : now(0) - { - } - - Now::~Now() - { - if (now) - delete now; - } - - const timeval & - Now::get() const - { - if (!now) - now = new _timeval; - - ::gettimeofday(&now->tv, NULL); - return now->tv; - } - - double - Now::operator()() const - { - return convert(get()); - } - - - Elapsed::Elapsed() - : elapsed(0) - {} - - Elapsed::~Elapsed() - { - if (elapsed) - delete elapsed; - } - - const timeval & - Elapsed::get() const - { - if (!elapsed) - elapsed = new _timeval; - - timersub(&_now.get(), &_start.get(), &elapsed->tv); - return elapsed->tv; - } - - void - Elapsed::reset() - { - _start.reset(); - } - - double - Elapsed::operator()() const - { - return convert(get()); - } - - Start start; - Now now; - Elapsed elapsed; - - ostream & - operator<<(ostream &out, const Start &start) - { - out << ::ctime((const time_t *)&start.get().tv_sec); - return out; - } - - ostream & - operator<<(ostream &out, const Now &now) - { - out << ::ctime((const time_t *)&now.get().tv_sec); - return out; - } - - ostream & - operator<<(ostream &out, const Elapsed &elapsed) - { - out << ::ctime((const time_t *)&elapsed.get().tv_sec); - return out; - } -} diff --git a/util/rundiff b/util/rundiff index 05beba84b..9376e4b9e 100755 --- a/util/rundiff +++ b/util/rundiff @@ -87,6 +87,10 @@ my ($fh1, $fh2); open($fh1, $file1) or die "Can't open $file1"; open($fh2, $file2) or die "Can't open $file2"; +# print files to output so we know which is which +print "-$file1\n"; +print "+$file2\n"; + # buffer of matching lines for pre-diff context my @precontext = (); # number of post-diff matching lines remaining to print @@ -191,7 +195,10 @@ sub printdiff DISCARD_A => \&discard1, DISCARD_B => \&discard2 }); - die "Lost sync!" if (!$match_found); + if (!$match_found) { + printdiff(scalar(@lines1), scalar(@lines2)); + die "Lost sync!"; + } # Since we shouldn't get here unless the first lines of the # buffers are different, then we must discard some lines off @@ -220,7 +227,10 @@ sub checkmatch # treated as common; if that bugs you, use Algorithm::Diff. if ($lines1[$n1] eq $lines2[$n2] && $lines1[$n1+1] eq $lines2[$n2+1]) { printdiff($n1, $n2); + return 1; } + + return 0; } sub simple_diff @@ -240,6 +250,8 @@ sub simple_diff return if checkmatch($cnt, $n); } } + + printdiff(scalar(@lines1), scalar(@lines2)); die "Lost sync!"; } |