Ciro Santilli has submitted this change. (
https://gem5-review.googlesource.com/c/public/gem5/+/37575 )
Change subject: sim,base: make checkpointMapIn warn if an unknown key is
found
......................................................................
sim,base: make checkpointMapIn warn if an unknown key is found
The warning happens when a key is present in the checkpoint but not in the
values that gem5 source code knows about.
To do this, we must expose iteration over IniFile section keys. To not
have to make those classes public, a visitor method is implemented.
Change-Id: I23340a953f3e604642b97690a7328b10fdd740a8
Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/37575
Reviewed-by: Daniel Carvalho <oda...@yahoo.com.br>
Maintainer: Bobby R. Bruce <bbr...@ucdavis.edu>
Tested-by: kokoro <noreply+kok...@google.com>
---
M src/base/inifile.cc
M src/base/inifile.hh
M src/sim/serialize.cc
M src/sim/serialize.hh
4 files changed, 54 insertions(+), 1 deletion(-)
Approvals:
Daniel Carvalho: Looks good to me, approved
Bobby R. Bruce: Looks good to me, approved
kokoro: Regressions pass
diff --git a/src/base/inifile.cc b/src/base/inifile.cc
index 1fbebb4..b2eeafc 100644
--- a/src/base/inifile.cc
+++ b/src/base/inifile.cc
@@ -345,3 +345,25 @@
i->second->dump(i->first);
}
}
+
+IniFile::Section::EntryTable::const_iterator
+IniFile::Section::begin() const
+{
+ return table.begin();
+}
+
+IniFile::Section::EntryTable::const_iterator
+IniFile::Section::end() const
+{
+ return table.end();
+}
+
+void
+IniFile::visitSection(const std::string §ionName,
+ IniFile::VisitSectionCallback cb)
+{
+ const auto& section = *table.at(sectionName);
+ for (const auto& pair : section) {
+ cb(pair.first, pair.second->getValue());
+ }
+}
diff --git a/src/base/inifile.hh b/src/base/inifile.hh
index 095d132..ae6dc45 100644
--- a/src/base/inifile.hh
+++ b/src/base/inifile.hh
@@ -30,6 +30,7 @@
#define __INIFILE_HH__
#include <fstream>
+#include <functional>
#include <list>
#include <string>
#include <unordered_map>
@@ -132,6 +133,9 @@
/// Print the contents of this section to cout (for debugging).
void dump(const std::string §ionName);
+
+ EntryTable::const_iterator begin() const;
+ EntryTable::const_iterator end() const;
};
/// SectionTable type. Map of strings to Section object pointers.
@@ -203,6 +207,13 @@
/// Dump contents to cout. For debugging.
void dump();
+
+ /// Visitor callback that receives key/value pairs.
+ using VisitSectionCallback = std::function<void(
+ const std::string&, const std::string&)>;
+
+ /// Iterate over key/value pairs of the given section.
+ void visitSection(const std::string §ionName, VisitSectionCallback
cb);
};
#endif // __INIFILE_HH__
diff --git a/src/sim/serialize.cc b/src/sim/serialize.cc
index e502d9a..a563332 100644
--- a/src/sim/serialize.cc
+++ b/src/sim/serialize.cc
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2015 ARM Limited
+ * Copyright (c) 2015, 2020 ARM Limited
* All rights reserved
*
* The license below extends only to copyright in the software and shall
@@ -338,6 +338,13 @@
}
void
+CheckpointIn::visitSection(const std::string §ion,
+ IniFile::VisitSectionCallback cb)
+{
+ db->visitSection(section, cb);
+}
+
+void
objParamIn(CheckpointIn &cp, const string &name, SimObject * ¶m)
{
const string §ion(Serializable::currentSection());
diff --git a/src/sim/serialize.hh b/src/sim/serialize.hh
index 9e25d09..80fac66 100644
--- a/src/sim/serialize.hh
+++ b/src/sim/serialize.hh
@@ -55,6 +55,7 @@
#include <unordered_map>
#include <vector>
+#include "base/inifile.hh"
#include "base/logging.hh"
#include "sim/serialize_handlers.hh"
@@ -94,6 +95,8 @@
bool entryExists(const std::string §ion, const std::string &entry);
bool sectionExists(const std::string §ion);
+ void visitSection(const std::string §ion,
+ IniFile::VisitSectionCallback cb);
/** @}*/ //end of api_checkout group
// The following static functions have to do with checkpoint
@@ -555,6 +558,16 @@
param[name_to_index[key]] = value;
}
}
+ cp.visitSection(
+ Serializable::currentSection(),
+ [name_to_index](const std::string& key, const std::string& val)
+ {
+ if (!name_to_index.count(key)) {
+ warn("unknown entry found in checkpoint: %s %s %s\n",
+ Serializable::currentSection(), key, val);
+ }
+ }
+ );
}
//
--
To view, visit https://gem5-review.googlesource.com/c/public/gem5/+/37575
To unsubscribe, or for help writing mail filters, visit
https://gem5-review.googlesource.com/settings
Gerrit-Project: public/gem5
Gerrit-Branch: develop
Gerrit-Change-Id: I23340a953f3e604642b97690a7328b10fdd740a8
Gerrit-Change-Number: 37575
Gerrit-PatchSet: 10
Gerrit-Owner: Ciro Santilli <ciro.santi...@arm.com>
Gerrit-Reviewer: Andreas Sandberg <andreas.sandb...@arm.com>
Gerrit-Reviewer: Bobby R. Bruce <bbr...@ucdavis.edu>
Gerrit-Reviewer: Ciro Santilli <ciro.santi...@arm.com>
Gerrit-Reviewer: Daniel Carvalho <oda...@yahoo.com.br>
Gerrit-Reviewer: Gabe Black <gabebl...@google.com>
Gerrit-Reviewer: Giacomo Travaglini <giacomo.travagl...@arm.com>
Gerrit-Reviewer: Jason Lowe-Power <ja...@lowepower.com>
Gerrit-Reviewer: Richard Cooper <richard.coo...@arm.com>
Gerrit-Reviewer: kokoro <noreply+kok...@google.com>
Gerrit-MessageType: merged
_______________________________________________
gem5-dev mailing list -- gem5-dev@gem5.org
To unsubscribe send an email to gem5-dev-le...@gem5.org
%(web_page_url)slistinfo%(cgiext)s/%(_internal_name)s