diff --git a/ArchImpl/RISCV/RISCVArchSpecificImp.h b/ArchImpl/RISCV/RISCVArchSpecificImp.h index 00b0c4a23f..7dd516dfd0 100755 --- a/ArchImpl/RISCV/RISCVArchSpecificImp.h +++ b/ArchImpl/RISCV/RISCVArchSpecificImp.h @@ -638,12 +638,16 @@ std::shared_ptr RISCVArch::getVirtualStruct(ETISS_CPU *cpu addCSRCustom(3, &((RISCV *)cpu)->FCSR); ret->addField(new FFLAGSField_RISCV(*ret)); ret->addField(new FRMField_RISCV(*ret)); + addCSR(CSR_MSTATUS); addCSR(CSR_MISA); addCSR(CSR_MIE); addCSR(CSR_MTVEC); + addCSR(CSR_MCOUNTEREN); + addCSR(CSR_MSCRATCH); addCSR(CSR_MEPC); addCSR(CSR_MCAUSE); addCSR(CSR_MTVAL); + addCSR(CSR_MIP); return ret; } diff --git a/CMakeLists.txt b/CMakeLists.txt index 43016df431..e18e0ddbea 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -260,6 +260,35 @@ target_include_directories(simpleini PUBLIC install(TARGETS simpleini PUBLIC_HEADER DESTINATION include/simpleini ) +FetchContent_Declare(pugixml_srcs + GIT_REPOSITORY https://github.com/zeux/pugixml.git + GIT_TAG v1.11.4 +) +if(NOT pugixml_srcs_POPULATED) + FetchContent_Populate(pugixml_srcs) + FetchContent_GetProperties(pugixml_srcs) +endif() +add_subdirectory(${pugixml_srcs_SOURCE_DIR} ${pugixml_srcs_BINARY_DIR} EXCLUDE_FROM_ALL) + +FetchContent_Declare(betterenums_srcs + GIT_REPOSITORY https://github.com/aantron/better-enums.git + GIT_TAG 0.11.3 +) +if(NOT betterenums_srcs_POPULATED) + FetchContent_Populate(betterenums_srcs) + FetchContent_GetProperties(betterenums_srcs) +endif() +add_library(betterenums INTERFACE) +set_target_properties(betterenums PROPERTIES + PUBLIC_HEADER "${betterenums_srcs_SOURCE_DIR}/enum.h" +) +target_include_directories(betterenums INTERFACE + $ + $ +) +install(TARGETS betterenums + PUBLIC_HEADER DESTINATION include +) ### Doxyfile set(ETISS_DOX_LOCATIONS ${ETISS_DOX_LOCATIONS} ${PROJECT_BINARY_DIR}/include) @@ -363,7 +392,7 @@ set_target_properties(ETISS PROPERTIES LIBRARY_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/lib/ ) IF(UNIX) - TARGET_LINK_LIBRARIES(ETISS PUBLIC ${Boost_LIBRARIES}) + TARGET_LINK_LIBRARIES(ETISS PUBLIC Boost::filesystem Boost::system Boost::program_options) ELSE(UNIX) TARGET_LINK_LIBRARIES(ETISS PUBLIC Boost::boost Threads::Threads) ENDIF() @@ -385,7 +414,7 @@ TARGET_INCLUDE_DIRECTORIES(ETISS PUBLIC "${PROJECT_BINARY_DIR}/include_c" ${INCGEN_INC_DIR} ) -TARGET_LINK_LIBRARIES(ETISS PUBLIC simpleini elfio) +TARGET_LINK_LIBRARIES(ETISS PUBLIC simpleini elfio pugixml betterenums) GENERATE_EXPORT_HEADER(ETISS BASE_NAME ETISS_PLUGIN diff --git a/include/etiss/CPUCore.h b/include/etiss/CPUCore.h index 78709d38b4..fe0f887cf7 100644 --- a/include/etiss/CPUCore.h +++ b/include/etiss/CPUCore.h @@ -113,7 +113,7 @@ class CPUCore : public VirtualStructSupport, public etiss::ToString friend class CPUArchRegListenerInterface; friend class InterruptVectorWrapper; - private: + protected: /** * @brief Private constructor of CPUCore. * @@ -123,6 +123,7 @@ class CPUCore : public VirtualStructSupport, public etiss::ToString * * @param arch Pointer to the CPU architecture used by the CPU core simulator. */ + CPUCore(std::shared_ptr arch, std::string const& name); CPUCore(std::shared_ptr arch); class InterruptVectorWrapper : public InterruptVector diff --git a/include/etiss/ETISS.h b/include/etiss/ETISS.h index b8956e0017..3a81d0f465 100644 --- a/include/etiss/ETISS.h +++ b/include/etiss/ETISS.h @@ -216,6 +216,27 @@ void initialize(std::vector& args); */ std::shared_ptr getDefaultJIT(); +/** + * @brief Initialize and configure etiss::VirtualStruct root with etiss::CPUCore + * \p cpu_core. + * + * @detail This function also initializes configured faults which require a + * mounted \p core etiss::VirtualStruct. Add the virtual structure of the cpu to + * the VirtualStruct root. This allows to access the field of the cpu from a + * global context. See etiss::VirtualStruct::getVirtualStruct() and + * etiss::VirtualStruct::getResolvedField(). In this case e.g. the + * instructionPointer can be read from a global context by calling + * etiss::VirtualStruct::root()->getResolvedField("core0.instructionPointer") + * ->read(). + */ +void initialize_virtualstruct(std::shared_ptr cpu_core); +/** + * @brief Extension of etiss::initialize_virtualstruct( + * std::shared_ptr) to allow direct setting of custom action for + * \p cpu_core etiss::VirtualStruct with \p fcustom_action. + */ +void initialize_virtualstruct(std::shared_ptr cpu_core, std::function const & fcustom_action); + /** * @brief Shutdown ETISS * diff --git a/include/etiss/IntegratedLibrary/InstructionAccurateCallback.h b/include/etiss/IntegratedLibrary/InstructionAccurateCallback.h index c418282588..011e2eb8fe 100644 --- a/include/etiss/IntegratedLibrary/InstructionAccurateCallback.h +++ b/include/etiss/IntegratedLibrary/InstructionAccurateCallback.h @@ -69,7 +69,7 @@ class InstructionAccurateCallback : public etiss::TranslationPlugin virtual std::string _getPluginName() const; public: - void call(); + etiss_int32 call_on_entry(); }; } // namespace plugin diff --git a/include/etiss/IntegratedLibrary/InstructionSpecificAddressCallback.h b/include/etiss/IntegratedLibrary/InstructionSpecificAddressCallback.h index 1391dd8a40..0b533196b4 100644 --- a/include/etiss/IntegratedLibrary/InstructionSpecificAddressCallback.h +++ b/include/etiss/IntegratedLibrary/InstructionSpecificAddressCallback.h @@ -66,6 +66,8 @@ namespace plugin */ class InstructionSpecificAddressCallback : public etiss::TranslationPlugin { + size_t get_uid_once(void) const {static size_t __uid_cntr{0}; return ++__uid_cntr;} + size_t const uid_; public: struct Data { diff --git a/include/etiss/IntegratedLibrary/fault/MemoryManipulationSystem.h b/include/etiss/IntegratedLibrary/fault/MemoryManipulationSystem.h new file mode 100644 index 0000000000..9b2f488683 --- /dev/null +++ b/include/etiss/IntegratedLibrary/fault/MemoryManipulationSystem.h @@ -0,0 +1,250 @@ +/** + + @copyright + +
+
+        Copyright 2018 Infineon Technologies AG
+
+        This file is part of ETISS tool, see .
+
+        The initial version of this software has been created with the funding support by the German Federal
+        Ministry of Education and Research (BMBF) in the project EffektiV under grant 01IS13022.
+
+        Redistribution and use in source and binary forms, with or without modification, are permitted
+        provided that the following conditions are met:
+
+        1. Redistributions of source code must retain the above copyright notice, this list of conditions and
+        the following disclaimer.
+
+        2. 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.
+
+        3. Neither the name of the copyright holder 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 HOLDER 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.
+
+        
+ + @author Chair of Electronic Design Automation, TUM + + @date November 16, 2021 + + @version 0.1 + +*/ +/** + @file + + @brief simple test system implementation with fault functionality + +*/ + +#ifndef ETISS_INCLUDE_INTEGRATEDLIBRARY_FAULT_MEMORYMANIPULATIONSYSTEM_H_ +#define ETISS_INCLUDE_INTEGRATEDLIBRARY_FAULT_MEMORYMANIPULATIONSYSTEM_H_ +#include "etiss/System.h" +#include "etiss/make_unique.h" +#include + +#include "etiss/SimpleMemSystem.h" + +#include "etiss/VirtualStruct.h" + +#include +#include +#include + +#include + +#include "etiss/fault/Misc.h" +#include "enum.h" + +namespace etiss +{ + +BETTER_ENUM(MM_MemOpType, char, UNDEF = 0, COPY, AND, OR, XOR, NAND, NOR) +BETTER_ENUM(MM_MemManipCmd, char, UNDEF = 0, PUSH, POP, OR, RMW, RRMW) + +//////////////////////////////////////////////////////////////////////////////////////////////////// +/// \brief Memory word faulter base class +class MemoryWordManipulatorBase +{ + public: + typedef MM_MemOpType mem_op_t; + //////////////////////////////////////////////////////////////////////////////////////////////// + /// \brief Memory operation class + class MemOp : mem_op_t + { + public: + //////////////////////////////////////////////////////////////////////////////////////////// + /// \brief executes memory operation with operands \p src1 and \p src2 and returns result + template + word_t operator()(word_t src1, word_t src2) const; + //////////////////////////////////////////////////////////////////////////////////////////// + /// \brief Constructor takes string encoded memory operation \ref MemOpType + MemOp(const std::string &memop_str) : mem_op_t(mem_op_t::_from_string(memop_str.c_str())) {} + } /* class MemOp */; + + //////////////////////////////////////////////////////////////////////////////////////////// + /// \brief Memory operation type code + typedef MM_MemManipCmd mem_manip_cmd_t; + + virtual etiss::int32 push(size_t address) = 0; + virtual etiss::int32 pop(size_t address) = 0; + virtual etiss::int32 rmw(size_t address, MemOp op, etiss::uint64 mod_val) = 0; + virtual etiss::int32 rrmw(size_t dstsrc1_address, MemOp op, size_t src2_address) = 0; +} /* class MemoryWordManipulatorBase */; + +//////////////////////////////////////////////////////////////////////////////////////////////////// +/// \brief Memory word faulter class template \p word_t +template +class MemoryWordManipulator : public MemoryWordManipulatorBase +{ + private: + std::function mem_read_word_; + ///< function to read a single word from memory + std::function mem_write_word_; + ///< function to write a single word to memory + std::stack memstack_{}; + ///< memory stack to allow read modify write manipulations to memory + + public: + //////////////////////////////////////////////////////////////////////////////////////////////// + /// \brief pop the last added element from the memory stack and write it to memory \p address + /// \return etiss::RETURNCODE encoded via \ref MemoryManipulationSystem::dbus_access + virtual etiss::int32 pop(size_t address); + //////////////////////////////////////////////////////////////////////////////////////////////// + /// \brief read memory from \p address and push it to memory stack + /// \return etiss::RETURNCODE encoded via \ref MemoryManipulationSystem::dbus_access + virtual etiss::int32 push(size_t address); + //////////////////////////////////////////////////////////////////////////////////////////////// + /// \brief read-modify-write memory word at \p address with \p mod_val by bit-wise operation \p op + /// \p mod_val is type casted to \p word_t + /// \return etiss::RETURNCODE encoded via \ref MemoryManipulationSystem::dbus_access + virtual etiss::int32 rmw(size_t address, MemOp op, etiss::uint64 mod_val); + //////////////////////////////////////////////////////////////////////////////////////////////// + /// \brief read-readmodify-write memory word at \p dstsrc1_address with memory word at + /// \p src2_address by bit-wise operation \p op + /// \return etiss::RETURNCODE encoded via \ref MemoryManipulationSystem::dbus_access + virtual etiss::int32 rrmw(size_t dstsrc1_address, MemOp op, size_t src2_address); + //////////////////////////////////////////////////////////////////////////////////////////////// + /// \brief Constructor taking \p mem_read_word and \p mem_write_word functions for memory + /// fault action + MemoryWordManipulator( + std::function const &mem_read_word, + std::function const &mem_write_word); +} /* class MemoryWordManipulator */; + +//////////////////////////////////////////////////////////////////////////////////////////////////// +/// \brief Simple etiss:System implementation for testing +class MemoryManipulationSystem : public VirtualStructSupport, public SimpleMemSystem +{ + public: + //////////////////////////////////////////////////////////////////////////////////////////////// + /// \brief Constructor takes \p name for reference of this class as a name \ref Injector + MemoryManipulationSystem(const std::string &name = "system"); + //////////////////////////////////////////////////////////////////////////////////////////////// + /// \brief get virtual struct associated name + inline const std::string &getName() { return name_; } + //////////////////////////////////////////////////////////////////////////////////////////////// + /// \brief get virtual struct + std::shared_ptr getStruct(void); + //////////////////////////////////////////////////////////////////////////////////////////////// + /// \brief initialize this virtual struct and mount it to \p cpu_core + void init_manipulation(std::shared_ptr vs_parent); + + private: + std::string name_; + etiss::uint8 arch_width_; + std::shared_ptr vsystem_; + std::unique_ptr mem_manipulator_; +}; + +/* template "implemenations" */ +template +word_t MemoryWordManipulatorBase::MemOp::operator()(word_t src1, word_t src2) const +{ + switch (*this) + { + case MM_MemOpType::COPY: + return src2; + case MM_MemOpType::AND: + return (src1 & src2); + case MM_MemOpType::OR: + return (src1 | src2); + case MM_MemOpType::XOR: + return (src1 ^ src2); + case MM_MemOpType::NAND: + return ~(src1 & src2); + case MM_MemOpType::NOR: + return ~(src1 | src2); + default: + break; + } + return src1; +} + +template +etiss::int32 MemoryWordManipulator::pop(size_t address) +{ + etiss::int32 return_code; + mem_write_word_(address, memstack_.top(), return_code); + memstack_.pop(); + return return_code; +} + +template +etiss::int32 MemoryWordManipulator::push(size_t address) +{ + etiss::int32 return_code; + memstack_.push(mem_read_word_(address, return_code)); + return return_code; +} + +template +etiss::int32 MemoryWordManipulator::rmw(size_t address, MemOp op, etiss::uint64 mod_val) +{ + etiss::int32 return_code; + word_t mem_val = mem_read_word_(address, return_code); + if (return_code == RETURNCODE::NOERROR) + { + mem_val = op(mem_val, static_cast(mod_val)); + mem_write_word_(address, mem_val, return_code); + } + return return_code; +} +template +etiss::int32 MemoryWordManipulator::rrmw(size_t dstsrc1_address, MemOp op, size_t src2_address) +{ + etiss::int32 return_code; + word_t src1mem_val = mem_read_word_(dstsrc1_address, return_code); + if (return_code == RETURNCODE::NOERROR) + { + word_t src2mem_val = mem_read_word_(src2_address, return_code); + if (return_code == RETURNCODE::NOERROR) + { + src1mem_val = op(src1mem_val, src2mem_val); + mem_write_word_(dstsrc1_address, src1mem_val, return_code); + } + } + return return_code; +} +template +MemoryWordManipulator::MemoryWordManipulator( + std::function const &mem_read_word, + std::function const &mem_write_word) + : mem_read_word_(mem_read_word), mem_write_word_(mem_write_word) +{ +} + +} // namespace etiss + +#endif // ETISS_INCLUDE_INTEGRATEDLIBRARY_FAULT_MEMORYMANIPULATIONSYSTEM_H_ diff --git a/include/etiss/SimpleMemSystem.h b/include/etiss/SimpleMemSystem.h index 099b4061aa..6f92fafb59 100644 --- a/include/etiss/SimpleMemSystem.h +++ b/include/etiss/SimpleMemSystem.h @@ -162,11 +162,13 @@ class SimpleMemSystem : public System etiss::uint64 get_startaddr(void) { return (start_addr_); } void add_memsegment(std::unique_ptr& mseg, const void *raw_data, size_t file_size_bytes); + protected: + template + etiss::int32 dbus_access(ETISS_CPU *cpu, etiss::uint64 addr, etiss::uint8 *buf, etiss::uint32 len); + private: std::vector> msegs_{}; - template - etiss::int32 dbus_access(ETISS_CPU *cpu, etiss::uint64 addr, etiss::uint8 *buf, etiss::uint32 len); etiss::uint64 start_addr_{ 0 }; @@ -193,4 +195,5 @@ class SimpleMemSystem : public System } // namespace etiss +void access_error(ETISS_CPU *cpu, etiss::uint64 addr, etiss::uint32 len, std::string error, etiss::Verbosity verbosity); #endif diff --git a/include/etiss/VirtualStruct.h b/include/etiss/VirtualStruct.h index 00df077b12..0f9dbbad0a 100644 --- a/include/etiss/VirtualStruct.h +++ b/include/etiss/VirtualStruct.h @@ -55,6 +55,10 @@ #include "etiss/Misc.h" #include "etiss/fault/Injector.h" +#include "etiss/fault/Trigger.h" +#include "etiss/fault/Action.h" +#include "etiss/fault/Fault.h" + #include #include @@ -66,7 +70,7 @@ class VSSync; /** abstract representation of an module of a simulation which could be a embedded device of the cpu of an embedded -device. it is recommended to model and address the full hardware hirachy. e.g.
 device1
+device. it is recommended to model and address the full hardware hierachy. e.g. 
 device1
             -> cpu
                 -> cache
             -> bus
@@ -217,7 +221,7 @@ class VirtualStruct : public std::enable_shared_from_this, public
                                  ///< "SR" OR1K CPU register: SPR[0][17]
         const std::string prettyname_; ///< alternative/human readable name of the field. e.g. representing the "SR"
                                        ///< OR1K CPU register: "SR" or "SupervisorRegister"
-        const int flags_;       ///< read write flags as specified by the static const int parameters of Field: R,W,L
+        int flags_;             ///< read write flags as specified by the static const int parameters of Field: R,W,L
         const size_t width_;    ///< width in bytes (rounded up if neccessary)
         const size_t bitwidth_; ///< width in bits
         const AccessMode accessMode_;
@@ -300,8 +304,9 @@ class VirtualStruct : public std::enable_shared_from_this, public
         virtual void _write(uint64_t val) { ((structT *)parent_.structure_)->*field = (retT)val; }
     };
 
-  private:
-    VirtualStruct(void *structure, std::function dtor = [](Field *f) { delete f; });
+  protected:
+    VirtualStruct(
+        void *structure, std::function dtor = [](Field *f) { delete f; });
 
   public:
     virtual ~VirtualStruct();
@@ -335,8 +340,9 @@ class VirtualStruct : public std::enable_shared_from_this, public
             flags |= Field::W;
         if (supportsListener)
             flags |= Field::L;
-        Field *f = new Field(*this, name, prettyname, flags, sizeof(T), false, [read]() { return (uint64_t)read(); },
-                             [write](uint64_t v) { write((T)v); });
+        Field *f = new Field(
+            *this, name, prettyname, flags, sizeof(T), false, [read]() { return (uint64_t)read(); },
+            [write](uint64_t v) { write((T)v); });
         if (addField(f, noerrorprint))
             return true;
         delete f;
@@ -368,6 +374,7 @@ class VirtualStruct : public std::enable_shared_from_this, public
     virtual bool readField(void *fastfieldaccessptr, uint64_t &val, std::string &errormsg);
     virtual bool applyAction(const etiss::fault::Fault &fault, const etiss::fault::Action &action,
                              std::string &errormsg);
+    virtual bool update_field_access_rights(const etiss::fault::Action &action, std::string &errormsg);
 
   public:
     /// set this function to handle custom commands passed by etiss::fault::Action of the type
@@ -449,6 +456,7 @@ class VirtualStructSupport
         @return may never be NULL
     */
     virtual std::shared_ptr getStruct() = 0;
+    virtual const std::string &getName() = 0;
 };
 
 #define ETISS_VIRTUALSTRUCT_ADDFIELD(VIRTUALSTRUCT, STRUCT, FIELD, NAME, PRETTYNAME) \
diff --git a/include/etiss/fault/Action.h b/include/etiss/fault/Action.h
index 30fbda22ae..e966ad5409 100644
--- a/include/etiss/fault/Action.h
+++ b/include/etiss/fault/Action.h
@@ -56,15 +56,12 @@
 #include 
 
 #ifndef NO_ETISS
+#include "etiss/Misc.h"
 #include "etiss/fault/Defs.h"
-#include "etiss/fault/Fault.h"
-#include "etiss/fault/InjectorAddress.h"
-#include "etiss/fault/XML.h"
+#include "enum.h"
 #else
 #include "fault/Defs.h"
-#include "fault/Fault.h"
-#include "fault/InjectorAddress.h"
-#include "fault/XML.h"
+#include "enum.h"
 #endif
 
 namespace etiss
@@ -72,29 +69,41 @@ namespace etiss
 namespace fault
 {
 
-class Fault;
+class FaultRef;
+class InjectorAddress;
+
+//  BITFLIP: applies a bit flip to a bit in a specified field
+//  MASK: applies a mask type injection (field = mask;) where  can be any MaskOp
+//  COMMAND: commands are targetet at Injectors, not fields. in case a command is targetet at a certain field that
+//  information must be passed within the command string INJECTION: an action that injects a fault definition (trigger +
+//  actions) EJECTION: an action that ejects a referenced fault (which must exist)
+//  EVENT: an event that breaks the JIT-block and forces the simulation loop to handle the etiss::RETURNCODE exception
+BETTER_ENUM(Action_Type, char, NOP = 0, BITFLIP, MASK, COMMAND, INJECTION, EJECTION, EVENT)
+BETTER_ENUM(Action_MaskOp, char, NOP = 0, AND, OR, XOR, NAND, NOR)
 
 class Action : public etiss::ToString
 {
   public:
-    enum Type
-    {
-        /// applies a bit flip to a bit in a specified field
-        BITFLIP,
-        /// commands are targetet at Injectors, not fields. in case a command is targetet at a certain field that
-        /// information must be passed within the command string
-        COMMAND,
-        /// NO Operation. used by default constructor
-        NOP,
-        /// an action that injects a fault definition (trigger + actions)
-        INJECTION
-    };
+    typedef Action_Type type_t;
+    typedef Action_MaskOp mask_op_t;
+    /**
+     *	@brief returns true if type_ is an action on a Field
+     */
+    bool is_action_on_field(void) const;
 
     // Constructors
     /**
      * @note Type: NOP (no operation)
      */
     Action();
+#ifndef NO_ETISS
+    /**
+     *	@note Type: Exception
+     *
+     *	@brief A etiss::RETURNCODE \p exception will be injected into the etiss simulation loop
+     */
+    Action(int32_t event);
+#endif
     /**
      *	@note Type: Command
      *
@@ -107,15 +116,31 @@ class Action : public etiss::ToString
      *	@brief the bit at the given position of the given field of the given injector will be flipped
      */
     Action(const InjectorAddress &inj, const std::string &field, unsigned bit);
+    /**
+     *	@note Type: MASK
+     *
+     *	@brief applies a mask type injection (field op= mask;) where  can be bitwise AND, OR, XOR, NAND, NOR
+     */
+    Action(const InjectorAddress &inj, const std::string &field, mask_op_t mask_op, uint64_t mask_value);
     /**
      * @note Type: Injection
      *
      * @brief injects a fault. this is especially usefull with Triggers of type TIMERELATIVE
      */
-    Action(const Fault &fault);
+    Action(const FaultRef &fault_ref, type_t type);
+
+    // Copy Constructors
+    Action(const Action &cpy);
+    Action &operator=(const Action &cpy);
+
+#if CXX0X_UP_SUPPORTED
+    Action(Action &&cpy);
+    Action &operator=(Action &&cpy);
+#endif
 
     // Getters
-    Type getType() const;
+    const type_t &getType() const;
+
     const InjectorAddress &getInjectorAddress() const;
 
     /// COMMAND only
@@ -125,34 +150,51 @@ class Action : public etiss::ToString
     const std::string &getTargetField() const;
     unsigned getTargetBit() const;
 
-    /// INJECTION only
-    const Fault &getFault() const;
+    /// INJECTION and EJECTION only
+    const FaultRef &getFaultRef() const;
 
+    /// MASK only
+    const mask_op_t &getMaskOp() const;
+    uint64_t getMaskValue() const;
+#ifndef NO_ETISS
+    int32_t getEvent() const;
+#endif
     // Members
     std::string toString() const; ///< operator<< can be used.
 
-  private:      // Attributes
-    Type type_; ///< type of the Attribute
-    InjectorAddress inj_;
-    std::string command_;      ///< command e.g. for booting OR1KVCPU
-    std::string field_;        ///< concerning Field (for fault injection)
-    unsigned bit_;             ///< concerning Bit (for fault injection)
-    std::vector fault_; ///< for other injections
-
+  private:                                 // Attributes
+    type_t type_;                          ///< type of the Attribute
+    std::unique_ptr inj_; ///< Address of Injector
+    std::string command_;                  ///< command e.g. for booting OR1KVCPU
+    std::string field_;                    ///< concerning Field (for fault injection)
+    unsigned bit_ = { 0 };                 ///< concerning Bit (for fault injection)
+    mask_op_t mask_op_{ mask_op_t::NOP };  ///< mask operation (for mask injection)
+    uint64_t mask_value_{ 0 };             ///< mask value (for mask injection)
+    std::unique_ptr fault_ref_;  ///< for fault injection
+#ifndef NO_ETISS
+    int32_t event_{ 0 }; ///< exception, or rather etiss::RETURNCODE to
+                         /// to be injected into the simulation loop
+#endif
     // private Members
-    void ensure(Type);
+    void ensure(type_t);
 };
 
+#ifndef NO_ETISS
+/**
+ *	@brief decode etiss::RETURNCODE from string
+ */
+bool returncode_fromstring(int32_t &out, const std::string &in);
+/**
+ *	@brief encode etiss::RETURNCODE to string
+ */
+std::string returncode_tostring(int32_t in);
+#endif
+
 #if ETISS_FAULT_XML
 
 namespace xml
 {
 
-template <>
-bool parse(pugi::xml_node node, etiss::fault::Action &f, Diagnostics &diag);
-template <>
-bool write(pugi::xml_node node, const etiss::fault::Action &f, Diagnostics &diag);
-
 } // namespace xml
 
 #endif
diff --git a/include/etiss/fault/Fault.h b/include/etiss/fault/Fault.h
index 049c3034e6..8b5c260edf 100644
--- a/include/etiss/fault/Fault.h
+++ b/include/etiss/fault/Fault.h
@@ -61,15 +61,10 @@
 #include 
 
 #ifndef NO_ETISS
-#include "etiss/fault/Action.h"
+#include "etiss/Misc.h"
 #include "etiss/fault/Defs.h"
-#include "etiss/fault/Trigger.h"
-#include "etiss/fault/XML.h"
 #else
-#include "fault/Action.h"
 #include "fault/Defs.h"
-#include "fault/Trigger.h"
-#include "fault/XML.h"
 #endif
 
 /// if true then mutex will be used to create unique ids for faults in a threadsafe way
@@ -83,17 +78,19 @@ namespace fault
 typedef uint64_t INT;
 
 class Action;
+class Trigger;
 
 class Fault : public etiss::ToString
 {
   public:
-    Fault(); ///< Constructor: Generates a new Fault with unique ID
-
     std::string toString() const; ///< operator<< can be used.
 
     void resolveTime(uint64_t time); ///< Resolves time for all its Triggers.
     bool isResoved() const;          ///< check all Triggers if they are resolved.
 
+    Fault(); ///< Constructor: Generates a new Fault with unique ID
+    Fault(int nullid);
+
   public:
     std::string name_;
     int32_t id_;                   ///< @attention negative ids are reserved
@@ -101,20 +98,27 @@ class Fault : public etiss::ToString
     std::vector actions;   ///< contains the actions for this fault
 };
 
-#if ETISS_FAULT_XML
+class FaultRef : public etiss::ToString
+{
+  private:
+    mutable Fault fault_; ///< referenced Fault, needs to be resolved during sim. runtime
+    std::string name_;    ///< string identifier, used to resolve actual reference via fault_
 
-bool parseXML(std::vector &vec, std::istream &input, std::ostream &diagnostics_out = std::cout);
+  public:
+    std::string toString() const; ///< operator<< can be used.
+
+    bool is_set() const { return (fault_.name_ == name_); }
+    bool set_fault_reference(const std::string &identifier);
+    bool resolve_reference() const;
+    const Fault &get_fault() const { return fault_; }
+    const std::string &get_name() const { return name_; }
+};
 
-bool writeXML(const std::vector &vec, std::ostream &out, std::ostream &diagnostics_out = std::cout);
+#if ETISS_FAULT_XML
 
 namespace xml
 {
 
-template <>
-bool parse(pugi::xml_node node, etiss::fault::Fault &f, Diagnostics &diag);
-template <>
-bool write(pugi::xml_node node, const etiss::fault::Fault &f, Diagnostics &diag);
-
 } // namespace xml
 
 #endif
diff --git a/include/etiss/fault/Injector.h b/include/etiss/fault/Injector.h
index 6bfcb8cb9b..f041a2a087 100644
--- a/include/etiss/fault/Injector.h
+++ b/include/etiss/fault/Injector.h
@@ -53,9 +53,12 @@
 #define ETISS_INJECTOR_H_
 
 #ifndef NO_ETISS
-#include "etiss/fault/Fault.h"
+#include "etiss/Misc.h"
+#include "etiss/fault/Defs.h"
+#include "etiss/fault/Misc.h"
 #else
-#include "fault/Fault.h"
+#include "fault/Defs.h"
+#include "fault/Misc.h"
 #endif
 
 #if CXX0X_UP_SUPPORTED
@@ -73,6 +76,9 @@ namespace fault
 {
 
 class Stressor;
+class Fault;
+class Trigger;
+class Action;
 
 class Injector
 {
@@ -155,6 +161,12 @@ class Injector
 
     virtual bool acceleratedTrigger(const etiss::fault::Trigger &, int32_t fault_id);
 
+    /**
+        @brief Update the \p field of injector with access rights to allow \p action (used to get type of action).
+        @detail For example, if \p action is of etiss::fault::Action::BITFLIP, \p field requires F flag set
+    */
+    virtual bool update_field_access_rights(const etiss::fault::Action &action, std::string &errormsg) = 0;
+
   public: // static
     /**
     @param injectorPath the full path/name to/off an injector. in case of using ETISS/VirtualStruct please have a look
@@ -175,13 +187,17 @@ class Injector
 #if CXX0X_UP_SUPPORTED
     std::mutex sync;
 #endif
-    volatile bool has_pending_triggers;
-    std::list> pending_triggers; ///> Triggers which were just added
-    std::list> unknown_triggers; ///> Triggers to look at in callbacks
+    bool has_pending_triggers{ false };
+    bool has_remove_triggers{ false };
+    std::list> pending_triggers; ///< Triggers which were just added
+    std::list> unknown_triggers; ///< Triggers to look at in callbacks
+    std::list>
+        remove_triggers; ///< Triggers to synchronously remove on next callback (prio over pending)
     /// TODO specialized lists. e.g. time triggers should be sorted and only the earliest time should be checked
 
-  public: // interface fot stressor
+  public: // interface for Stressor
     void addTrigger(const Trigger &t, int32_t fault_id);
+    void removeTrigger(const Trigger &t, int32_t fault_id);
 };
 
 } // namespace fault
diff --git a/include/etiss/fault/InjectorAddress.h b/include/etiss/fault/InjectorAddress.h
index 05136e948b..897ce55d05 100644
--- a/include/etiss/fault/InjectorAddress.h
+++ b/include/etiss/fault/InjectorAddress.h
@@ -60,10 +60,8 @@
 #ifndef NO_ETISS
 #include "etiss/Misc.h"
 #include "etiss/fault/Defs.h"
-#include "etiss/fault/XML.h"
 #else
 #include "fault/Defs.h"
-#include "fault/XML.h"
 #endif
 
 namespace etiss
@@ -100,18 +98,7 @@ class InjectorAddress : public etiss::ToString
 namespace xml
 {
 
-template <>
-bool parse(pugi::xml_node node, etiss::fault::InjectorAddress &dst, Diagnostics &diag);
-template <>
-bool write(pugi::xml_node node, const etiss::fault::InjectorAddress &src,
-                                          Diagnostics &diag);
-
-template <>
-bool parse(pugi::xml_node node, etiss::fault::InjectorAddress *&dst,
-                                            Diagnostics &diag);
-template <>
-bool write(pugi::xml_node node, const etiss::fault::InjectorAddress *const &src,
-                                                  Diagnostics &diag);
+
 
 } // namespace xml
 
diff --git a/include/etiss/fault/Misc.h b/include/etiss/fault/Misc.h
new file mode 100644
index 0000000000..b5b3178190
--- /dev/null
+++ b/include/etiss/fault/Misc.h
@@ -0,0 +1,72 @@
+/**
+
+        @copyright
+
+        
+
+        Copyright 2018 Infineon Technologies AG
+
+        This file is part of ETISS tool, see .
+
+        The initial version of this software has been created with the funding support by the German Federal
+        Ministry of Education and Research (BMBF) in the project EffektiV under grant 01IS13022.
+
+        Redistribution and use in source and binary forms, with or without modification, are permitted
+        provided that the following conditions are met:
+
+        1. Redistributions of source code must retain the above copyright notice, this list of conditions and
+        the following disclaimer.
+
+        2. 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.
+
+        3. Neither the name of the copyright holder 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 HOLDER 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.
+
+        
+ + @author Chair of Electronic Design Automation, TUM + + @date November 18, 2021 + + @version 0.1 + +*/ +/** + @file + + @brief general helpers for fault + + @detail + + + + +*/ + +#ifndef ETISS_INCLUDE_FAULT_MISC_H_ +#define ETISS_INCLUDE_FAULT_MISC_H_ + +#include +#include +#include + +namespace etiss +{ +namespace fault +{ + +} // end of namespace fault + +} // end of namespace etiss + +#endif /* ETISS_INCLUDE_FAULT_MISC_H_ */ diff --git a/include/etiss/fault/Stressor.h b/include/etiss/fault/Stressor.h index e7b1b562de..b0e5a2c8bd 100644 --- a/include/etiss/fault/Stressor.h +++ b/include/etiss/fault/Stressor.h @@ -54,20 +54,53 @@ #define ETISS_STRESSOR_H_ #ifndef NO_ETISS -#include "etiss/fault/Fault.h" -#else -#include "fault/Fault.h" +#include "etiss/jit/ReturnCode.h" #endif +#include + namespace etiss { namespace fault { +class Fault; +class Trigger; +class Action; +class Injector; + class Stressor { public: + enum Event + { + TERMINATE = (1 << 0) +#ifndef NO_ETISS + , + ETISS_FLUSH_TRANSLATION_CACHE = (1 << 1), + ETISS_RELOAD_TRANSLATION_BLOCK = (1 << 2) +#else +#endif + }; + +#ifndef NO_ETISS + private: + static etiss::int32 event_code_; + + public: + static etiss::int32 get_event(void) { return event_code_; } + static void set_event(etiss::int32 code) { event_code_ = code; } +#else + private: + static int event_code_; + + public: + static int get_event(void) { return event_code_; } + static void set_event(int code) { event_code_ = code; } + static void set_event_flag(Event flag) { event_code_ |= flag; } +#endif + static void reset_event(void) { event_code_ = 0; } /** @brief extracts faults out of the given xml file. * @param file the xmlfile with fault triggers. * @return true if XML file could be loaded. @@ -77,9 +110,22 @@ class Stressor /** @brief adds a fault to a static map that can be accessed * by static std::map & faults(). * @param f the fault for adding to the map. - * @return false if fault already exists in map. + * @return false if fault already exists in map faults(). + */ + static bool addFaultDefinition(const Fault &f); + + /** @brief activates a fault's triggers in their injectors + * @param f the fault to activate + * @return false if refernced fault is not the static fault list faults(). + */ + static bool addFault(const Fault &f, bool injected_fault = false); + + /** @brief removes a fault's active triggers from their injectors, thus, + * deactivating the fault. + * @param f the fault for adding to the map. + * @return false if referenced fault is not the static fault list faults(). */ - static bool addFault(const Fault &f); + static bool removeFault(const Fault &f, bool injected_fault = false); /** @brief Checks if the given trigger is valid and calls applyAction. * @@ -97,6 +143,9 @@ class Stressor /** @brief clears the fault map. */ static void clear(); + /** @brief static map with all referencable faults. + */ + static std::map &faults(); }; } // namespace fault diff --git a/include/etiss/fault/Trigger.h b/include/etiss/fault/Trigger.h index ed72b5562a..477c6e708d 100644 --- a/include/etiss/fault/Trigger.h +++ b/include/etiss/fault/Trigger.h @@ -61,19 +61,20 @@ #ifndef NO_ETISS #include "etiss/Misc.h" -#include "etiss/fault/InjectorAddress.h" -#include "etiss/fault/XML.h" +#include "etiss/fault/Misc.h" #else -#include "fault/InjectorAddress.h" -#include "fault/XML.h" +#include "fault/Misc.h" #endif +#include "enum.h" + namespace etiss { namespace fault { class Injector; +class InjectorAddress; #if CXX0X_UP_SUPPORTED typedef std::shared_ptr Injector_ptr; @@ -81,25 +82,22 @@ typedef std::shared_ptr Injector_ptr; typedef Injector *Injector_ptr; #endif +BETTER_ENUM(Trigger_Type, char, NOP = 0, META_COUNTER, VARIABLEVALUE, TIME, TIMERELATIVE, ASAP) + class Trigger : public etiss::ToString { public: - enum Type - { - META_COUNTER, - VARIABLEVALUE, - TIME, - /// needs to be resolved. this can only be used in connection with an - /// injection action - TIMERELATIVE, - NOP - }; - + typedef Trigger_Type type_t; // constructors /** Type: NOP (no operation) */ Trigger(); + // constructors + /** + Type: typed but empty constructor (used for ASAP) + */ + Trigger(const InjectorAddress &target_injector); /** * @note Type: META_COUNTER * @@ -133,7 +131,6 @@ class Trigger : public etiss::ToString // Getter uint64_t getTriggerCount() const; - Trigger &getSubTrigger(); const Trigger &getSubTrigger() const; uint64_t getTriggerTime() const; const InjectorAddress &getInjectorAddress() const; @@ -141,12 +138,12 @@ class Trigger : public etiss::ToString bool isNOP() const; const std::string &getTriggerField() const; const uint64_t &getTriggerFieldValue() const; - Type getType() const; + const type_t &getType() const; // Members /** @brief this function checks if the Trigger has just fired. */ - bool fired(uint64_t time_ps, etiss::fault::Injector *target_injector); + bool check(uint64_t time_ps, etiss::fault::Injector *target_injector); /** @brief this function calculates in case of a TIMERELATIVE Trigger a * constant TIME trigger @@ -160,32 +157,23 @@ class Trigger : public etiss::ToString std::string toString() const; ///< operator<< can be used. private: // Attributes - Type type_; + type_t type_; std::string field_; - Trigger *sub_; - InjectorAddress inj_; + std::unique_ptr sub_; + std::unique_ptr inj_; void *fieldptr_; - uint64_t param1_; - uint64_t param2_; + uint64_t param1_{ 0 }; + uint64_t param2_{ 0 }; // Private Members - void ensure(Type type) const; + void ensure(type_t type) const; }; #if ETISS_FAULT_XML namespace xml { -template <> -bool parse(pugi::xml_node node, etiss::fault::Trigger *&f, Diagnostics &diag); -template <> -bool write(pugi::xml_node node, const etiss::fault::Trigger *const &f, - Diagnostics &diag); -template <> -bool parse(pugi::xml_node node, etiss::fault::Trigger &f, Diagnostics &diag); -template <> -bool write(pugi::xml_node node, const etiss::fault::Trigger &f, Diagnostics &diag); } // namespace xml #endif diff --git a/include/etiss/fault/XML.h b/include/etiss/fault/XML.h index 729e00c27d..491262c79a 100644 --- a/include/etiss/fault/XML.h +++ b/include/etiss/fault/XML.h @@ -54,13 +54,14 @@ #include #include +#include #ifndef NO_ETISS #include "etiss/fault/Defs.h" -#include "etiss/fault/xml/pugixml.hpp" +#include "pugixml.hpp" #else #include "fault/Defs.h" -#include "fault/xml/pugixml.hpp" +#include "pugixml.hpp" #endif #include @@ -71,6 +72,13 @@ namespace etiss namespace fault { +// forwards +class Trigger; +class Fault; +class FaultRef; +class Action; +class InjectorAddress; + // some helper for changing Core Names extern int coreIDActuallXML; void setCoreName(std::string &str); @@ -211,8 +219,60 @@ pugi::xml_node findSingleNode(pugi::xml_node node, const std::string &name, Diag //////////////////////////////////////////// +// TRIGGER +template <> +bool parse(pugi::xml_node node, etiss::fault::Trigger *&f, Diagnostics &diag); +template <> +bool write(pugi::xml_node node, const etiss::fault::Trigger *const &f, + Diagnostics &diag); + +template <> +bool parse(pugi::xml_node node, etiss::fault::Trigger &f, Diagnostics &diag); +template <> +bool write(pugi::xml_node node, const etiss::fault::Trigger &f, Diagnostics &diag); + +// FAULT +template <> +bool parse(pugi::xml_node node, etiss::fault::Fault &f, Diagnostics &diag); +template <> +bool write(pugi::xml_node node, const etiss::fault::Fault &f, Diagnostics &diag); +template <> +bool parse(pugi::xml_node node, etiss::fault::FaultRef &fref, Diagnostics &diag); +template <> +bool write(pugi::xml_node node, const etiss::fault::FaultRef &fref, Diagnostics &diag); + +// ACTION +template <> +bool parse(pugi::xml_node node, etiss::fault::Action &f, Diagnostics &diag); +template <> +bool write(pugi::xml_node node, const etiss::fault::Action &f, Diagnostics &diag); + +// INJECTORADDRESS +template <> +bool parse(pugi::xml_node node, etiss::fault::InjectorAddress &dst, Diagnostics &diag); +template <> +bool write(pugi::xml_node node, const etiss::fault::InjectorAddress &src, + Diagnostics &diag); + +template <> +bool parse(pugi::xml_node node, etiss::fault::InjectorAddress *&dst, + Diagnostics &diag); +template <> +bool write(pugi::xml_node node, const etiss::fault::InjectorAddress *const &src, + Diagnostics &diag); + } // namespace xml #endif + +/** @brief parse a XML document held in \p input stream and return as \p doc + */ +bool parseXML(pugi::xml_document &doc, std::istream &input, std::ostream &diagnostics_out = std::cout); + +bool parseXML(std::vector &vec, const pugi::xml_document &doc, xml::Diagnostics &diag); +bool parseXML(std::vector &vec, const pugi::xml_document &doc, xml::Diagnostics &diag); + +bool writeXML(const std::vector &vec, std::ostream &out, std::ostream &diagnostics_out = std::cout); + } // namespace fault } // namespace etiss diff --git a/include/etiss/fault/xml/CMakeLists.txt b/include/etiss/fault/xml/CMakeLists.txt deleted file mode 100644 index f8a45aea5a..0000000000 --- a/include/etiss/fault/xml/CMakeLists.txt +++ /dev/null @@ -1,51 +0,0 @@ -# -# Copyright 2018 Infineon Technologies AG -# -# This file is part of ETISS tool, see -# -# The initial version of this software has been created with the funding support by the German Federal -# Ministry of Education and Research(BMBF) in the project EffektiV under grant 01IS13022. -# -# Redistribution and use in source and binary forms, with or without modification, are permitted -# provided that the following conditions are met: -# -# 1. Redistributions of source code must retain the above copyright notice, this list of conditions and -# the following disclaimer. -# -# 2. 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. -# -# 3. Neither the name of the copyright holder 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 HOLDER 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. -# -# -# Author: Marc Greim , Chair of Electronic Design Automation, TUM -# -# Version 0.1 -# - -### recurse into sub directories -unset(LOCAL_SUBDIRS) -FILE(GLOB LOCAL_SUBDIRS ${CMAKE_CURRENT_LIST_DIR}/*) -foreach(subdir ${LOCAL_SUBDIRS}) - if(IS_DIRECTORY ${subdir}) - add_subdirectory(${subdir}) - endif() -endforeach() - - -unset(LOCAL_SOURCE1) -unset(LOCAL_SOURCE2) -FILE(GLOB LOCAL_SOURCE1 RELATIVE ${ETISS_ROOT_DIR} *.h) -FILE(GLOB LOCAL_SOURCE2 RELATIVE ${ETISS_ROOT_DIR} *.hpp) - -set(ETISS_HEADER ${ETISS_HEADER} ${LOCAL_SOURCE1} ${LOCAL_SOURCE2} PARENT_SCOPE) diff --git a/include/etiss/fault/xml/pugiconfig.hpp b/include/etiss/fault/xml/pugiconfig.hpp deleted file mode 100644 index f74c301ccb..0000000000 --- a/include/etiss/fault/xml/pugiconfig.hpp +++ /dev/null @@ -1,72 +0,0 @@ -/** - * pugixml parser - version 1.4 - * -------------------------------------------------------- - * Copyright (C) 2006-2014, by Arseny Kapoulkine (arseny.kapoulkine@gmail.com) - * Report bugs and download new versions at http://pugixml.org/ - * - * This library is distributed under the MIT License. See notice at the end - * of this file. - * - * This work is based on the pugxml parser, which is: - * Copyright (C) 2003, by Kristen Wegner (kristen@tima.net) - */ - -#ifndef HEADER_PUGICONFIG_HPP -#define HEADER_PUGICONFIG_HPP - -// Uncomment this to enable wchar_t mode -// #define PUGIXML_WCHAR_MODE - -// Uncomment this to disable XPath -// #define PUGIXML_NO_XPATH - -// Uncomment this to disable STL -// #define PUGIXML_NO_STL - -// Uncomment this to disable exceptions -// #define PUGIXML_NO_EXCEPTIONS - -// Set this to control attributes for public classes/functions, i.e.: -// #define PUGIXML_API __declspec(dllexport) // to export all public symbols from DLL -// #define PUGIXML_CLASS __declspec(dllimport) // to import all classes from DLL -// #define PUGIXML_FUNCTION __fastcall // to set calling conventions to all public functions to fastcall -// In absence of PUGIXML_CLASS/PUGIXML_FUNCTION definitions PUGIXML_API is used instead - -// Tune these constants to adjust memory-related behavior -// #define PUGIXML_MEMORY_PAGE_SIZE 32768 -// #define PUGIXML_MEMORY_OUTPUT_STACK 10240 -// #define PUGIXML_MEMORY_XPATH_PAGE_SIZE 4096 - -// Uncomment this to switch to header-only version -// #define PUGIXML_HEADER_ONLY -// #include "pugixml.cpp" - -// Uncomment this to enable long long support -#define PUGIXML_HAS_LONG_LONG - -#endif - -/** - * Copyright (c) 2006-2014 Arseny Kapoulkine - * - * Permission is hereby granted, free of charge, to any person - * obtaining a copy of this software and associated documentation - * files (the "Software"), to deal in the Software without - * restriction, including without limitation the rights to use, - * copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following - * conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES - * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT - * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, - * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR - * OTHER DEALINGS IN THE SOFTWARE. - */ diff --git a/include/etiss/fault/xml/pugixml.hpp b/include/etiss/fault/xml/pugixml.hpp deleted file mode 100644 index 99d94297d4..0000000000 --- a/include/etiss/fault/xml/pugixml.hpp +++ /dev/null @@ -1,1336 +0,0 @@ -/** - * pugixml parser - version 1.4 - * -------------------------------------------------------- - * Copyright (C) 2006-2014, by Arseny Kapoulkine (arseny.kapoulkine@gmail.com) - * Report bugs and download new versions at http://pugixml.org/ - * - * This library is distributed under the MIT License. See notice at the end - * of this file. - * - * This work is based on the pugxml parser, which is: - * Copyright (C) 2003, by Kristen Wegner (kristen@tima.net) - */ - -#ifndef PUGIXML_VERSION -// Define version macro; evaluates to major * 100 + minor so that it's safe to use in less-than comparisons -# define PUGIXML_VERSION 140 -#endif - -// Include user configuration file (this can define various configuration macros) -#ifndef NO_ETISS -#include "etiss/fault/xml/pugiconfig.hpp" -#else -#include "fault/xml/pugiconfig.hpp" -#endif - -#ifndef HEADER_PUGIXML_HPP -#define HEADER_PUGIXML_HPP - -// Include stddef.h for size_t and ptrdiff_t -#include - -// Include exception header for XPath -#if !defined(PUGIXML_NO_XPATH) && !defined(PUGIXML_NO_EXCEPTIONS) -# include -#endif - -// Include STL headers -#ifndef PUGIXML_NO_STL -# include -# include -# include -#endif - -// Macro for deprecated features -#ifndef PUGIXML_DEPRECATED -# if defined(__GNUC__) -# define PUGIXML_DEPRECATED __attribute__((deprecated)) -# elif defined(_MSC_VER) && _MSC_VER >= 1300 -# define PUGIXML_DEPRECATED __declspec(deprecated) -# else -# define PUGIXML_DEPRECATED -# endif -#endif - -// If no API is defined, assume default -#ifndef PUGIXML_API -# define PUGIXML_API -#endif - -// If no API for classes is defined, assume default -#ifndef PUGIXML_CLASS -# define PUGIXML_CLASS PUGIXML_API -#endif - -// If no API for functions is defined, assume default -#ifndef PUGIXML_FUNCTION -# define PUGIXML_FUNCTION PUGIXML_API -#endif - -// If the platform is known to have long long support, enable long long functions -#ifndef PUGIXML_HAS_LONG_LONG -# if defined(__cplusplus) && __cplusplus >= 201103 -# define PUGIXML_HAS_LONG_LONG -# elif defined(_MSC_VER) && _MSC_VER >= 1400 -# define PUGIXML_HAS_LONG_LONG -# endif -#endif - -// Character interface macros -#ifdef PUGIXML_WCHAR_MODE -# define PUGIXML_TEXT(t) L ## t -# define PUGIXML_CHAR wchar_t -#else -# define PUGIXML_TEXT(t) t -# define PUGIXML_CHAR char -#endif - -namespace pugi -{ - // Character type used for all internal storage and operations; depends on PUGIXML_WCHAR_MODE - typedef PUGIXML_CHAR char_t; - -#ifndef PUGIXML_NO_STL - // String type used for operations that work with STL string; depends on PUGIXML_WCHAR_MODE - typedef std::basic_string, std::allocator > string_t; -#endif -} - -// The PugiXML namespace -namespace pugi -{ - // Tree node types - enum xml_node_type - { - node_null, // Empty (null) node handle - node_document, // A document tree's absolute root - node_element, // Element tag, i.e. '' - node_pcdata, // Plain character data, i.e. 'text' - node_cdata, // Character data, i.e. '' - node_comment, // Comment tag, i.e. '' - node_pi, // Processing instruction, i.e. '' - node_declaration, // Document declaration, i.e. '' - node_doctype // Document type declaration, i.e. '' - }; - - // Parsing options - - // Minimal parsing mode (equivalent to turning all other flags off). - // Only elements and PCDATA sections are added to the DOM tree, no text conversions are performed. - const unsigned int parse_minimal = 0x0000; - - // This flag determines if processing instructions (node_pi) are added to the DOM tree. This flag is off by default. - const unsigned int parse_pi = 0x0001; - - // This flag determines if comments (node_comment) are added to the DOM tree. This flag is off by default. - const unsigned int parse_comments = 0x0002; - - // This flag determines if CDATA sections (node_cdata) are added to the DOM tree. This flag is on by default. - const unsigned int parse_cdata = 0x0004; - - // This flag determines if plain character data (node_pcdata) that consist only of whitespace are added to the DOM tree. - // This flag is off by default; turning it on usually results in slower parsing and more memory consumption. - const unsigned int parse_ws_pcdata = 0x0008; - - // This flag determines if character and entity references are expanded during parsing. This flag is on by default. - const unsigned int parse_escapes = 0x0010; - - // This flag determines if EOL characters are normalized (converted to #xA) during parsing. This flag is on by default. - const unsigned int parse_eol = 0x0020; - - // This flag determines if attribute values are normalized using CDATA normalization rules during parsing. This flag is on by default. - const unsigned int parse_wconv_attribute = 0x0040; - - // This flag determines if attribute values are normalized using NMTOKENS normalization rules during parsing. This flag is off by default. - const unsigned int parse_wnorm_attribute = 0x0080; - - // This flag determines if document declaration (node_declaration) is added to the DOM tree. This flag is off by default. - const unsigned int parse_declaration = 0x0100; - - // This flag determines if document type declaration (node_doctype) is added to the DOM tree. This flag is off by default. - const unsigned int parse_doctype = 0x0200; - - // This flag determines if plain character data (node_pcdata) that is the only child of the parent node and that consists only - // of whitespace is added to the DOM tree. - // This flag is off by default; turning it on may result in slower parsing and more memory consumption. - const unsigned int parse_ws_pcdata_single = 0x0400; - - // This flag determines if leading and trailing whitespace is to be removed from plain character data. This flag is off by default. - const unsigned int parse_trim_pcdata = 0x0800; - - // This flag determines if plain character data that does not have a parent node is added to the DOM tree, and if an empty document - // is a valid document. This flag is off by default. - const unsigned int parse_fragment = 0x1000; - - // The default parsing mode. - // Elements, PCDATA and CDATA sections are added to the DOM tree, character/reference entities are expanded, - // End-of-Line characters are normalized, attribute values are normalized using CDATA normalization rules. - const unsigned int parse_default = parse_cdata | parse_escapes | parse_wconv_attribute | parse_eol; - - // The full parsing mode. - // Nodes of all types are added to the DOM tree, character/reference entities are expanded, - // End-of-Line characters are normalized, attribute values are normalized using CDATA normalization rules. - const unsigned int parse_full = parse_default | parse_pi | parse_comments | parse_declaration | parse_doctype; - - // These flags determine the encoding of input data for XML document - enum xml_encoding - { - encoding_auto, // Auto-detect input encoding using BOM or < / class xml_object_range - { - public: - typedef It const_iterator; - typedef It iterator; - - xml_object_range(It b, It e): _begin(b), _end(e) - { - } - - It begin() const { return _begin; } - It end() const { return _end; } - - private: - It _begin, _end; - }; - - // Writer interface for node printing (see xml_node::print) - class PUGIXML_CLASS xml_writer - { - public: - virtual ~xml_writer() {} - - // Write memory chunk into stream/file/whatever - virtual void write(const void* data, size_t size) = 0; - }; - - // xml_writer implementation for FILE* - class PUGIXML_CLASS xml_writer_file: public xml_writer - { - public: - // Construct writer from a FILE* object; void* is used to avoid header dependencies on stdio - xml_writer_file(void* file); - - virtual void write(const void* data, size_t size); - - private: - void* file; - }; - - #ifndef PUGIXML_NO_STL - // xml_writer implementation for streams - class PUGIXML_CLASS xml_writer_stream: public xml_writer - { - public: - // Construct writer from an output stream object - xml_writer_stream(std::basic_ostream >& stream); - xml_writer_stream(std::basic_ostream >& stream); - - virtual void write(const void* data, size_t size); - - private: - std::basic_ostream >* narrow_stream; - std::basic_ostream >* wide_stream; - }; - #endif - - // A light-weight handle for manipulating attributes in DOM tree - class PUGIXML_CLASS xml_attribute - { - friend class xml_attribute_iterator; - friend class xml_node; - - private: - xml_attribute_struct* _attr; - - typedef void (*unspecified_bool_type)(xml_attribute***); - - public: - // Default constructor. Constructs an empty attribute. - xml_attribute(); - - // Constructs attribute from internal pointer - explicit xml_attribute(xml_attribute_struct* attr); - - // Safe bool conversion operator - operator unspecified_bool_type() const; - - // Borland C++ workaround - bool operator!() const; - - // Comparison operators (compares wrapped attribute pointers) - bool operator==(const xml_attribute& r) const; - bool operator!=(const xml_attribute& r) const; - bool operator<(const xml_attribute& r) const; - bool operator>(const xml_attribute& r) const; - bool operator<=(const xml_attribute& r) const; - bool operator>=(const xml_attribute& r) const; - - // Check if attribute is empty - bool empty() const; - - // Get attribute name/value, or "" if attribute is empty - const char_t* name() const; - const char_t* value() const; - - // Get attribute value, or the default value if attribute is empty - const char_t* as_string(const char_t* def = PUGIXML_TEXT("")) const; - - // Get attribute value as a number, or the default value if conversion did not succeed or attribute is empty - int as_int(int def = 0) const; - unsigned int as_uint(unsigned int def = 0) const; - double as_double(double def = 0) const; - float as_float(float def = 0) const; - - #ifdef PUGIXML_HAS_LONG_LONG - long long as_llong(long long def = 0) const; - unsigned long long as_ullong(unsigned long long def = 0) const; - #endif - - // Get attribute value as bool (returns true if first character is in '1tTyY' set), or the default value if attribute is empty - bool as_bool(bool def = false) const; - - // Set attribute name/value (returns false if attribute is empty or there is not enough memory) - bool set_name(const char_t* rhs); - bool set_value(const char_t* rhs); - - // Set attribute value with type conversion (numbers are converted to strings, boolean is converted to "true"/"false") - bool set_value(int rhs); - bool set_value(unsigned int rhs); - bool set_value(double rhs); - bool set_value(bool rhs); - - #ifdef PUGIXML_HAS_LONG_LONG - bool set_value(long long rhs); - bool set_value(unsigned long long rhs); - #endif - - // Set attribute value (equivalent to set_value without error checking) - xml_attribute& operator=(const char_t* rhs); - xml_attribute& operator=(int rhs); - xml_attribute& operator=(unsigned int rhs); - xml_attribute& operator=(double rhs); - xml_attribute& operator=(bool rhs); - - #ifdef PUGIXML_HAS_LONG_LONG - xml_attribute& operator=(long long rhs); - xml_attribute& operator=(unsigned long long rhs); - #endif - - // Get next/previous attribute in the attribute list of the parent node - xml_attribute next_attribute() const; - xml_attribute previous_attribute() const; - - // Get hash value (unique for handles to the same object) - size_t hash_value() const; - - // Get internal pointer - xml_attribute_struct* internal_object() const; - }; - -#ifdef __BORLANDC__ - // Borland C++ workaround - bool PUGIXML_FUNCTION operator&&(const xml_attribute& lhs, bool rhs); - bool PUGIXML_FUNCTION operator||(const xml_attribute& lhs, bool rhs); -#endif - - // A light-weight handle for manipulating nodes in DOM tree - class PUGIXML_CLASS xml_node - { - friend class xml_attribute_iterator; - friend class xml_node_iterator; - friend class xml_named_node_iterator; - - protected: - xml_node_struct* _root; - - typedef void (*unspecified_bool_type)(xml_node***); - - public: - // Default constructor. Constructs an empty node. - xml_node(); - - // Constructs node from internal pointer - explicit xml_node(xml_node_struct* p); - - // Safe bool conversion operator - operator unspecified_bool_type() const; - - // Borland C++ workaround - bool operator!() const; - - // Comparison operators (compares wrapped node pointers) - bool operator==(const xml_node& r) const; - bool operator!=(const xml_node& r) const; - bool operator<(const xml_node& r) const; - bool operator>(const xml_node& r) const; - bool operator<=(const xml_node& r) const; - bool operator>=(const xml_node& r) const; - - // Check if node is empty. - bool empty() const; - - // Get node type - xml_node_type type() const; - - // Get node name, or "" if node is empty or it has no name - const char_t* name() const; - - // Get node value, or "" if node is empty or it has no value - // Note: For text node.value() does not return "text"! Use child_value() or text() methods to access text inside nodes. - const char_t* value() const; - - // Get attribute list - xml_attribute first_attribute() const; - xml_attribute last_attribute() const; - - // Get children list - xml_node first_child() const; - xml_node last_child() const; - - // Get next/previous sibling in the children list of the parent node - xml_node next_sibling() const; - xml_node previous_sibling() const; - - // Get parent node - xml_node parent() const; - - // Get root of DOM tree this node belongs to - xml_node root() const; - - // Get text object for the current node - xml_text text() const; - - // Get child, attribute or next/previous sibling with the specified name - xml_node child(const char_t* name) const; - xml_attribute attribute(const char_t* name) const; - xml_node next_sibling(const char_t* name) const; - xml_node previous_sibling(const char_t* name) const; - - // Get child value of current node; that is, value of the first child node of type PCDATA/CDATA - const char_t* child_value() const; - - // Get child value of child with specified name. Equivalent to child(name).child_value(). - const char_t* child_value(const char_t* name) const; - - // Set node name/value (returns false if node is empty, there is not enough memory, or node can not have name/value) - bool set_name(const char_t* rhs); - bool set_value(const char_t* rhs); - - // Add attribute with specified name. Returns added attribute, or empty attribute on errors. - xml_attribute append_attribute(const char_t* name); - xml_attribute prepend_attribute(const char_t* name); - xml_attribute insert_attribute_after(const char_t* name, const xml_attribute& attr); - xml_attribute insert_attribute_before(const char_t* name, const xml_attribute& attr); - - // Add a copy of the specified attribute. Returns added attribute, or empty attribute on errors. - xml_attribute append_copy(const xml_attribute& proto); - xml_attribute prepend_copy(const xml_attribute& proto); - xml_attribute insert_copy_after(const xml_attribute& proto, const xml_attribute& attr); - xml_attribute insert_copy_before(const xml_attribute& proto, const xml_attribute& attr); - - // Add child node with specified type. Returns added node, or empty node on errors. - xml_node append_child(xml_node_type type = node_element); - xml_node prepend_child(xml_node_type type = node_element); - xml_node insert_child_after(xml_node_type type, const xml_node& node); - xml_node insert_child_before(xml_node_type type, const xml_node& node); - - // Add child element with specified name. Returns added node, or empty node on errors. - xml_node append_child(const char_t* name); - xml_node prepend_child(const char_t* name); - xml_node insert_child_after(const char_t* name, const xml_node& node); - xml_node insert_child_before(const char_t* name, const xml_node& node); - - // Add a copy of the specified node as a child. Returns added node, or empty node on errors. - xml_node append_copy(const xml_node& proto); - xml_node prepend_copy(const xml_node& proto); - xml_node insert_copy_after(const xml_node& proto, const xml_node& node); - xml_node insert_copy_before(const xml_node& proto, const xml_node& node); - - // Remove specified attribute - bool remove_attribute(const xml_attribute& a); - bool remove_attribute(const char_t* name); - - // Remove specified child - bool remove_child(const xml_node& n); - bool remove_child(const char_t* name); - - // Parses buffer as an XML document fragment and appends all nodes as children of the current node. - // Copies/converts the buffer, so it may be deleted or changed after the function returns. - // Note: append_buffer allocates memory that has the lifetime of the owning document; removing the appended nodes does not immediately reclaim that memory. - xml_parse_result append_buffer(const void* contents, size_t size, unsigned int options = parse_default, xml_encoding encoding = encoding_auto); - - // Find attribute using predicate. Returns first attribute for which predicate returned true. - template xml_attribute find_attribute(Predicate pred) const - { - if (!_root) return xml_attribute(); - - for (xml_attribute attrib = first_attribute(); attrib; attrib = attrib.next_attribute()) - if (pred(attrib)) - return attrib; - - return xml_attribute(); - } - - // Find child node using predicate. Returns first child for which predicate returned true. - template xml_node find_child(Predicate pred) const - { - if (!_root) return xml_node(); - - for (xml_node node = first_child(); node; node = node.next_sibling()) - if (pred(node)) - return node; - - return xml_node(); - } - - // Find node from subtree using predicate. Returns first node from subtree (depth-first), for which predicate returned true. - template xml_node find_node(Predicate pred) const - { - if (!_root) return xml_node(); - - xml_node cur = first_child(); - - while (cur._root && cur._root != _root) - { - if (pred(cur)) return cur; - - if (cur.first_child()) cur = cur.first_child(); - else if (cur.next_sibling()) cur = cur.next_sibling(); - else - { - while (!cur.next_sibling() && cur._root != _root) cur = cur.parent(); - - if (cur._root != _root) cur = cur.next_sibling(); - } - } - - return xml_node(); - } - - // Find child node by attribute name/value - xml_node find_child_by_attribute(const char_t* name, const char_t* attr_name, const char_t* attr_value) const; - xml_node find_child_by_attribute(const char_t* attr_name, const char_t* attr_value) const; - - #ifndef PUGIXML_NO_STL - // Get the absolute node path from root as a text string. - string_t path(char_t delimiter = '/') const; - #endif - - // Search for a node by path consisting of node names and . or .. elements. - xml_node first_element_by_path(const char_t* path, char_t delimiter = '/') const; - - // Recursively traverse subtree with xml_tree_walker - bool traverse(xml_tree_walker& walker); - - #ifndef PUGIXML_NO_XPATH - // Select single node by evaluating XPath query. Returns first node from the resulting node set. - xpath_node select_single_node(const char_t* query, xpath_variable_set* variables = 0) const; - xpath_node select_single_node(const xpath_query& query) const; - - // Select node set by evaluating XPath query - xpath_node_set select_nodes(const char_t* query, xpath_variable_set* variables = 0) const; - xpath_node_set select_nodes(const xpath_query& query) const; - #endif - - // Print subtree using a writer object - void print(xml_writer& writer, const char_t* indent = PUGIXML_TEXT("\t"), unsigned int flags = format_default, xml_encoding encoding = encoding_auto, unsigned int depth = 0) const; - - #ifndef PUGIXML_NO_STL - // Print subtree to stream - void print(std::basic_ostream >& os, const char_t* indent = PUGIXML_TEXT("\t"), unsigned int flags = format_default, xml_encoding encoding = encoding_auto, unsigned int depth = 0) const; - void print(std::basic_ostream >& os, const char_t* indent = PUGIXML_TEXT("\t"), unsigned int flags = format_default, unsigned int depth = 0) const; - #endif - - // Child nodes iterators - typedef xml_node_iterator iterator; - - iterator begin() const; - iterator end() const; - - // Attribute iterators - typedef xml_attribute_iterator attribute_iterator; - - attribute_iterator attributes_begin() const; - attribute_iterator attributes_end() const; - - // Range-based for support - xml_object_range children() const; - xml_object_range children(const char_t* name) const; - xml_object_range attributes() const; - - // Get node offset in parsed file/string (in char_t units) for debugging purposes - ptrdiff_t offset_debug() const; - - // Get hash value (unique for handles to the same object) - size_t hash_value() const; - - // Get internal pointer - xml_node_struct* internal_object() const; - }; - -#ifdef __BORLANDC__ - // Borland C++ workaround - bool PUGIXML_FUNCTION operator&&(const xml_node& lhs, bool rhs); - bool PUGIXML_FUNCTION operator||(const xml_node& lhs, bool rhs); -#endif - - // A helper for working with text inside PCDATA nodes - class PUGIXML_CLASS xml_text - { - friend class xml_node; - - xml_node_struct* _root; - - typedef void (*unspecified_bool_type)(xml_text***); - - explicit xml_text(xml_node_struct* root); - - xml_node_struct* _data_new(); - xml_node_struct* _data() const; - - public: - // Default constructor. Constructs an empty object. - xml_text(); - - // Safe bool conversion operator - operator unspecified_bool_type() const; - - // Borland C++ workaround - bool operator!() const; - - // Check if text object is empty - bool empty() const; - - // Get text, or "" if object is empty - const char_t* get() const; - - // Get text, or the default value if object is empty - const char_t* as_string(const char_t* def = PUGIXML_TEXT("")) const; - - // Get text as a number, or the default value if conversion did not succeed or object is empty - int as_int(int def = 0) const; - unsigned int as_uint(unsigned int def = 0) const; - double as_double(double def = 0) const; - float as_float(float def = 0) const; - - #ifdef PUGIXML_HAS_LONG_LONG - long long as_llong(long long def = 0) const; - unsigned long long as_ullong(unsigned long long def = 0) const; - #endif - - // Get text as bool (returns true if first character is in '1tTyY' set), or the default value if object is empty - bool as_bool(bool def = false) const; - - // Set text (returns false if object is empty or there is not enough memory) - bool set(const char_t* rhs); - - // Set text with type conversion (numbers are converted to strings, boolean is converted to "true"/"false") - bool set(int rhs); - bool set(unsigned int rhs); - bool set(double rhs); - bool set(bool rhs); - - #ifdef PUGIXML_HAS_LONG_LONG - bool set(long long rhs); - bool set(unsigned long long rhs); - #endif - - // Set text (equivalent to set without error checking) - xml_text& operator=(const char_t* rhs); - xml_text& operator=(int rhs); - xml_text& operator=(unsigned int rhs); - xml_text& operator=(double rhs); - xml_text& operator=(bool rhs); - - #ifdef PUGIXML_HAS_LONG_LONG - xml_text& operator=(long long rhs); - xml_text& operator=(unsigned long long rhs); - #endif - - // Get the data node (node_pcdata or node_cdata) for this object - xml_node data() const; - }; - -#ifdef __BORLANDC__ - // Borland C++ workaround - bool PUGIXML_FUNCTION operator&&(const xml_text& lhs, bool rhs); - bool PUGIXML_FUNCTION operator||(const xml_text& lhs, bool rhs); -#endif - - // Child node iterator (a bidirectional iterator over a collection of xml_node) - class PUGIXML_CLASS xml_node_iterator - { - friend class xml_node; - - private: - mutable xml_node _wrap; - xml_node _parent; - - xml_node_iterator(xml_node_struct* ref, xml_node_struct* parent); - - public: - // Iterator traits - typedef ptrdiff_t difference_type; - typedef xml_node value_type; - typedef xml_node* pointer; - typedef xml_node& reference; - - #ifndef PUGIXML_NO_STL - typedef std::bidirectional_iterator_tag iterator_category; - #endif - - // Default constructor - xml_node_iterator(); - - // Construct an iterator which points to the specified node - xml_node_iterator(const xml_node& node); - - // Iterator operators - bool operator==(const xml_node_iterator& rhs) const; - bool operator!=(const xml_node_iterator& rhs) const; - - xml_node& operator*() const; - xml_node* operator->() const; - - const xml_node_iterator& operator++(); - xml_node_iterator operator++(int); - - const xml_node_iterator& operator--(); - xml_node_iterator operator--(int); - }; - - // Attribute iterator (a bidirectional iterator over a collection of xml_attribute) - class PUGIXML_CLASS xml_attribute_iterator - { - friend class xml_node; - - private: - mutable xml_attribute _wrap; - xml_node _parent; - - xml_attribute_iterator(xml_attribute_struct* ref, xml_node_struct* parent); - - public: - // Iterator traits - typedef ptrdiff_t difference_type; - typedef xml_attribute value_type; - typedef xml_attribute* pointer; - typedef xml_attribute& reference; - - #ifndef PUGIXML_NO_STL - typedef std::bidirectional_iterator_tag iterator_category; - #endif - - // Default constructor - xml_attribute_iterator(); - - // Construct an iterator which points to the specified attribute - xml_attribute_iterator(const xml_attribute& attr, const xml_node& parent); - - // Iterator operators - bool operator==(const xml_attribute_iterator& rhs) const; - bool operator!=(const xml_attribute_iterator& rhs) const; - - xml_attribute& operator*() const; - xml_attribute* operator->() const; - - const xml_attribute_iterator& operator++(); - xml_attribute_iterator operator++(int); - - const xml_attribute_iterator& operator--(); - xml_attribute_iterator operator--(int); - }; - - // Named node range helper - class PUGIXML_CLASS xml_named_node_iterator - { - friend class xml_node; - - public: - // Iterator traits - typedef ptrdiff_t difference_type; - typedef xml_node value_type; - typedef xml_node* pointer; - typedef xml_node& reference; - - #ifndef PUGIXML_NO_STL - typedef std::bidirectional_iterator_tag iterator_category; - #endif - - // Default constructor - xml_named_node_iterator(); - - // Construct an iterator which points to the specified node - xml_named_node_iterator(const xml_node& node, const char_t* name); - - // Iterator operators - bool operator==(const xml_named_node_iterator& rhs) const; - bool operator!=(const xml_named_node_iterator& rhs) const; - - xml_node& operator*() const; - xml_node* operator->() const; - - const xml_named_node_iterator& operator++(); - xml_named_node_iterator operator++(int); - - const xml_named_node_iterator& operator--(); - xml_named_node_iterator operator--(int); - - private: - mutable xml_node _wrap; - xml_node _parent; - const char_t* _name; - - xml_named_node_iterator(xml_node_struct* ref, xml_node_struct* parent, const char_t* name); - }; - - // Abstract tree walker class (see xml_node::traverse) - class PUGIXML_CLASS xml_tree_walker - { - friend class xml_node; - - private: - int _depth; - - protected: - // Get current traversal depth - int depth() const; - - public: - xml_tree_walker(); - virtual ~xml_tree_walker(); - - // Callback that is called when traversal begins - virtual bool begin(xml_node& node); - - // Callback that is called for each node traversed - virtual bool for_each(xml_node& node) = 0; - - // Callback that is called when traversal ends - virtual bool end(xml_node& node); - }; - - // Parsing status, returned as part of xml_parse_result object - enum xml_parse_status - { - status_ok = 0, // No error - - status_file_not_found, // File was not found during load_file() - status_io_error, // Error reading from file/stream - status_out_of_memory, // Could not allocate memory - status_internal_error, // Internal error occurred - - status_unrecognized_tag, // Parser could not determine tag type - - status_bad_pi, // Parsing error occurred while parsing document declaration/processing instruction - status_bad_comment, // Parsing error occurred while parsing comment - status_bad_cdata, // Parsing error occurred while parsing CDATA section - status_bad_doctype, // Parsing error occurred while parsing document type declaration - status_bad_pcdata, // Parsing error occurred while parsing PCDATA section - status_bad_start_element, // Parsing error occurred while parsing start element tag - status_bad_attribute, // Parsing error occurred while parsing element attribute - status_bad_end_element, // Parsing error occurred while parsing end element tag - status_end_element_mismatch,// There was a mismatch of start-end tags (closing tag had incorrect name, some tag was not closed or there was an excessive closing tag) - - status_append_invalid_root, // Unable to append nodes since root type is not node_element or node_document (exclusive to xml_node::append_buffer) - - status_no_document_element // Parsing resulted in a document without element nodes - }; - - // Parsing result - struct PUGIXML_CLASS xml_parse_result - { - // Parsing status (see xml_parse_status) - xml_parse_status status; - - // Last parsed offset (in char_t units from start of input data) - ptrdiff_t offset; - - // Source document encoding - xml_encoding encoding; - - // Default constructor, initializes object to failed state - xml_parse_result(); - - // Cast to bool operator - operator bool() const; - - // Get error description - const char* description() const; - }; - - // Document class (DOM tree root) - class PUGIXML_CLASS xml_document: public xml_node - { - private: - char_t* _buffer; - - char _memory[192]; - - // Non-copyable semantics - xml_document(const xml_document&); - const xml_document& operator=(const xml_document&); - - void create(); - void destroy(); - - public: - // Default constructor, makes empty document - xml_document(); - - // Destructor, invalidates all node/attribute handles to this document - ~xml_document(); - - // Removes all nodes, leaving the empty document - void reset(); - - // Removes all nodes, then copies the entire contents of the specified document - void reset(const xml_document& proto); - - #ifndef PUGIXML_NO_STL - // Load document from stream. - xml_parse_result load(std::basic_istream >& stream, unsigned int options = parse_default, xml_encoding encoding = encoding_auto); - xml_parse_result load(std::basic_istream >& stream, unsigned int options = parse_default); - #endif - - // Load document from zero-terminated string. No encoding conversions are applied. - xml_parse_result load(const char_t* contents, unsigned int options = parse_default); - - // Load document from file - xml_parse_result load_file(const char* path, unsigned int options = parse_default, xml_encoding encoding = encoding_auto); - xml_parse_result load_file(const wchar_t* path, unsigned int options = parse_default, xml_encoding encoding = encoding_auto); - - // Load document from buffer. Copies/converts the buffer, so it may be deleted or changed after the function returns. - xml_parse_result load_buffer(const void* contents, size_t size, unsigned int options = parse_default, xml_encoding encoding = encoding_auto); - - // Load document from buffer, using the buffer for in-place parsing (the buffer is modified and used for storage of document data). - // You should ensure that buffer data will persist throughout the document's lifetime, and free the buffer memory manually once document is destroyed. - xml_parse_result load_buffer_inplace(void* contents, size_t size, unsigned int options = parse_default, xml_encoding encoding = encoding_auto); - - // Load document from buffer, using the buffer for in-place parsing (the buffer is modified and used for storage of document data). - // You should allocate the buffer with pugixml allocation function; document will free the buffer when it is no longer needed (you can't use it anymore). - xml_parse_result load_buffer_inplace_own(void* contents, size_t size, unsigned int options = parse_default, xml_encoding encoding = encoding_auto); - - // Save XML document to writer (semantics is slightly different from xml_node::print, see documentation for details). - void save(xml_writer& writer, const char_t* indent = PUGIXML_TEXT("\t"), unsigned int flags = format_default, xml_encoding encoding = encoding_auto) const; - - #ifndef PUGIXML_NO_STL - // Save XML document to stream (semantics is slightly different from xml_node::print, see documentation for details). - void save(std::basic_ostream >& stream, const char_t* indent = PUGIXML_TEXT("\t"), unsigned int flags = format_default, xml_encoding encoding = encoding_auto) const; - void save(std::basic_ostream >& stream, const char_t* indent = PUGIXML_TEXT("\t"), unsigned int flags = format_default) const; - #endif - - // Save XML to file - bool save_file(const char* path, const char_t* indent = PUGIXML_TEXT("\t"), unsigned int flags = format_default, xml_encoding encoding = encoding_auto) const; - bool save_file(const wchar_t* path, const char_t* indent = PUGIXML_TEXT("\t"), unsigned int flags = format_default, xml_encoding encoding = encoding_auto) const; - - // Get document element - xml_node document_element() const; - }; - -#ifndef PUGIXML_NO_XPATH - // XPath query return type - enum xpath_value_type - { - xpath_type_none, // Unknown type (query failed to compile) - xpath_type_node_set, // Node set (xpath_node_set) - xpath_type_number, // Number - xpath_type_string, // String - xpath_type_boolean // Boolean - }; - - // XPath parsing result - struct PUGIXML_CLASS xpath_parse_result - { - // Error message (0 if no error) - const char* error; - - // Last parsed offset (in char_t units from string start) - ptrdiff_t offset; - - // Default constructor, initializes object to failed state - xpath_parse_result(); - - // Cast to bool operator - operator bool() const; - - // Get error description - const char* description() const; - }; - - // A single XPath variable - class PUGIXML_CLASS xpath_variable - { - friend class xpath_variable_set; - - protected: - xpath_value_type _type; - xpath_variable* _next; - - xpath_variable(); - - // Non-copyable semantics - xpath_variable(const xpath_variable&); - xpath_variable& operator=(const xpath_variable&); - - public: - // Get variable name - const char_t* name() const; - - // Get variable type - xpath_value_type type() const; - - // Get variable value; no type conversion is performed, default value (false, NaN, empty string, empty node set) is returned on type mismatch error - bool get_boolean() const; - double get_number() const; - const char_t* get_string() const; - const xpath_node_set& get_node_set() const; - - // Set variable value; no type conversion is performed, false is returned on type mismatch error - bool set(bool value); - bool set(double value); - bool set(const char_t* value); - bool set(const xpath_node_set& value); - }; - - // A set of XPath variables - class PUGIXML_CLASS xpath_variable_set - { - private: - xpath_variable* _data[64]; - - // Non-copyable semantics - xpath_variable_set(const xpath_variable_set&); - xpath_variable_set& operator=(const xpath_variable_set&); - - xpath_variable* find(const char_t* name) const; - - public: - // Default constructor/destructor - xpath_variable_set(); - ~xpath_variable_set(); - - // Add a new variable or get the existing one, if the types match - xpath_variable* add(const char_t* name, xpath_value_type type); - - // Set value of an existing variable; no type conversion is performed, false is returned if there is no such variable or if types mismatch - bool set(const char_t* name, bool value); - bool set(const char_t* name, double value); - bool set(const char_t* name, const char_t* value); - bool set(const char_t* name, const xpath_node_set& value); - - // Get existing variable by name - xpath_variable* get(const char_t* name); - const xpath_variable* get(const char_t* name) const; - }; - - // A compiled XPath query object - class PUGIXML_CLASS xpath_query - { - private: - void* _impl; - xpath_parse_result _result; - - typedef void (*unspecified_bool_type)(xpath_query***); - - // Non-copyable semantics - xpath_query(const xpath_query&); - xpath_query& operator=(const xpath_query&); - - public: - // Construct a compiled object from XPath expression. - // If PUGIXML_NO_EXCEPTIONS is not defined, throws xpath_exception on compilation errors. - explicit xpath_query(const char_t* query, xpath_variable_set* variables = 0); - - // Destructor - ~xpath_query(); - - // Get query expression return type - xpath_value_type return_type() const; - - // Evaluate expression as boolean value in the specified context; performs type conversion if necessary. - // If PUGIXML_NO_EXCEPTIONS is not defined, throws std::bad_alloc on out of memory errors. - bool evaluate_boolean(const xpath_node& n) const; - - // Evaluate expression as double value in the specified context; performs type conversion if necessary. - // If PUGIXML_NO_EXCEPTIONS is not defined, throws std::bad_alloc on out of memory errors. - double evaluate_number(const xpath_node& n) const; - - #ifndef PUGIXML_NO_STL - // Evaluate expression as string value in the specified context; performs type conversion if necessary. - // If PUGIXML_NO_EXCEPTIONS is not defined, throws std::bad_alloc on out of memory errors. - string_t evaluate_string(const xpath_node& n) const; - #endif - - // Evaluate expression as string value in the specified context; performs type conversion if necessary. - // At most capacity characters are written to the destination buffer, full result size is returned (includes terminating zero). - // If PUGIXML_NO_EXCEPTIONS is not defined, throws std::bad_alloc on out of memory errors. - // If PUGIXML_NO_EXCEPTIONS is defined, returns empty set instead. - size_t evaluate_string(char_t* buffer, size_t capacity, const xpath_node& n) const; - - // Evaluate expression as node set in the specified context. - // If PUGIXML_NO_EXCEPTIONS is not defined, throws xpath_exception on type mismatch and std::bad_alloc on out of memory errors. - // If PUGIXML_NO_EXCEPTIONS is defined, returns empty node set instead. - xpath_node_set evaluate_node_set(const xpath_node& n) const; - - // Get parsing result (used to get compilation errors in PUGIXML_NO_EXCEPTIONS mode) - const xpath_parse_result& result() const; - - // Safe bool conversion operator - operator unspecified_bool_type() const; - - // Borland C++ workaround - bool operator!() const; - }; - - #ifndef PUGIXML_NO_EXCEPTIONS - // XPath exception class - class PUGIXML_CLASS xpath_exception: public std::exception - { - private: - xpath_parse_result _result; - - public: - // Construct exception from parse result - explicit xpath_exception(const xpath_parse_result& result); - - // Get error message - virtual const char* what() const throw(); - - // Get parse result - const xpath_parse_result& result() const; - }; - #endif - - // XPath node class (either xml_node or xml_attribute) - class PUGIXML_CLASS xpath_node - { - private: - xml_node _node; - xml_attribute _attribute; - - typedef void (*unspecified_bool_type)(xpath_node***); - - public: - // Default constructor; constructs empty XPath node - xpath_node(); - - // Construct XPath node from XML node/attribute - xpath_node(const xml_node& node); - xpath_node(const xml_attribute& attribute, const xml_node& parent); - - // Get node/attribute, if any - xml_node node() const; - xml_attribute attribute() const; - - // Get parent of contained node/attribute - xml_node parent() const; - - // Safe bool conversion operator - operator unspecified_bool_type() const; - - // Borland C++ workaround - bool operator!() const; - - // Comparison operators - bool operator==(const xpath_node& n) const; - bool operator!=(const xpath_node& n) const; - }; - -#ifdef __BORLANDC__ - // Borland C++ workaround - bool PUGIXML_FUNCTION operator&&(const xpath_node& lhs, bool rhs); - bool PUGIXML_FUNCTION operator||(const xpath_node& lhs, bool rhs); -#endif - - // A fixed-size collection of XPath nodes - class PUGIXML_CLASS xpath_node_set - { - public: - // Collection type - enum type_t - { - type_unsorted, // Not ordered - type_sorted, // Sorted by document order (ascending) - type_sorted_reverse // Sorted by document order (descending) - }; - - // Constant iterator type - typedef const xpath_node* const_iterator; - - // Default constructor. Constructs empty set. - xpath_node_set(); - - // Constructs a set from iterator range; data is not checked for duplicates and is not sorted according to provided type, so be careful - xpath_node_set(const_iterator begin, const_iterator end, type_t type = type_unsorted); - - // Destructor - ~xpath_node_set(); - - // Copy constructor/assignment operator - xpath_node_set(const xpath_node_set& ns); - xpath_node_set& operator=(const xpath_node_set& ns); - - // Get collection type - type_t type() const; - - // Get collection size - size_t size() const; - - // Indexing operator - const xpath_node& operator[](size_t index) const; - - // Collection iterators - const_iterator begin() const; - const_iterator end() const; - - // Sort the collection in ascending/descending order by document order - void sort(bool reverse = false); - - // Get first node in the collection by document order - xpath_node first() const; - - // Check if collection is empty - bool empty() const; - - private: - type_t _type; - - xpath_node _storage; - - xpath_node* _begin; - xpath_node* _end; - - void _assign(const_iterator begin, const_iterator end); - }; -#endif - -#ifndef PUGIXML_NO_STL - // Convert wide string to UTF8 - std::basic_string, std::allocator > PUGIXML_FUNCTION as_utf8(const wchar_t* str); - std::basic_string, std::allocator > PUGIXML_FUNCTION as_utf8(const std::basic_string, std::allocator >& str); - - // Convert UTF8 to wide string - std::basic_string, std::allocator > PUGIXML_FUNCTION as_wide(const char* str); - std::basic_string, std::allocator > PUGIXML_FUNCTION as_wide(const std::basic_string, std::allocator >& str); -#endif - - // Memory allocation function interface; returns pointer to allocated memory or NULL on failure - typedef void* (*allocation_function)(size_t size); - - // Memory deallocation function interface - typedef void (*deallocation_function)(void* ptr); - - // Override default memory management functions. All subsequent allocations/deallocations will be performed via supplied functions. - void PUGIXML_FUNCTION set_memory_management_functions(allocation_function allocate, deallocation_function deallocate); - - // Get current memory management functions - allocation_function PUGIXML_FUNCTION get_memory_allocation_function(); - deallocation_function PUGIXML_FUNCTION get_memory_deallocation_function(); -} - -#if !defined(PUGIXML_NO_STL) && (defined(_MSC_VER) || defined(__ICC)) -namespace std -{ - // Workarounds for (non-standard) iterator category detection for older versions (MSVC7/IC8 and earlier) - std::bidirectional_iterator_tag PUGIXML_FUNCTION _Iter_cat(const pugi::xml_node_iterator&); - std::bidirectional_iterator_tag PUGIXML_FUNCTION _Iter_cat(const pugi::xml_attribute_iterator&); - std::bidirectional_iterator_tag PUGIXML_FUNCTION _Iter_cat(const pugi::xml_named_node_iterator&); -} -#endif - -#if !defined(PUGIXML_NO_STL) && defined(__SUNPRO_CC) -namespace std -{ - // Workarounds for (non-standard) iterator category detection - std::bidirectional_iterator_tag PUGIXML_FUNCTION __iterator_category(const pugi::xml_node_iterator&); - std::bidirectional_iterator_tag PUGIXML_FUNCTION __iterator_category(const pugi::xml_attribute_iterator&); - std::bidirectional_iterator_tag PUGIXML_FUNCTION __iterator_category(const pugi::xml_named_node_iterator&); -} -#endif - -#endif - -/** - * Copyright (c) 2006-2014 Arseny Kapoulkine - * - * Permission is hereby granted, free of charge, to any person - * obtaining a copy of this software and associated documentation - * files (the "Software"), to deal in the Software without - * restriction, including without limitation the rights to use, - * copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following - * conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES - * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT - * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, - * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR - * OTHER DEALINGS IN THE SOFTWARE. - */ diff --git a/include/etiss/fault/xml/readme_pugixml b/include/etiss/fault/xml/readme_pugixml deleted file mode 100644 index 1d28b5f2e6..0000000000 --- a/include/etiss/fault/xml/readme_pugixml +++ /dev/null @@ -1 +0,0 @@ -The files pugiconfig.hpp,pugixml.hpp and pugixml.cpp (located in src) are from the v1.4 tag of the pugixml git repository (https://github.com/zeux/pugixml.git) diff --git a/src/CPUCore.cpp b/src/CPUCore.cpp index 1aad4f0280..5c482b6f27 100644 --- a/src/CPUCore.cpp +++ b/src/CPUCore.cpp @@ -135,9 +135,9 @@ int CPUCore::getNextID() { return currID; } -CPUCore::CPUCore(std::shared_ptr arch) +CPUCore::CPUCore(std::shared_ptr arch, std::string const& name) : arch_(arch) - , name_("core" + std::to_string(currID)) + , name_(name) , id_(currID++) , cpu_(arch->newCPU()) , vcpu_(arch->getVirtualStruct(cpu_)) @@ -185,6 +185,10 @@ CPUCore::CPUCore(std::shared_ptr arch) } } } +CPUCore::CPUCore(std::shared_ptr arch) + : CPUCore(arch, std::string("core" + std::to_string(currID))) +{ +} void CPUCore::addPlugin(std::shared_ptr plugin) { @@ -261,7 +265,11 @@ std::shared_ptr CPUCore::create(std::string archname, std::string insta } // creat core - std::shared_ptr ret(new CPUCore(arch)); + std::shared_ptr ret{nullptr}; + if(instancename != "") + ret.reset(new CPUCore(arch, instancename));//std::make_shared(arch, instancename); + else + ret.reset(new CPUCore(arch)); //std::make_shared(arch); { std::lock_guard lock(instances_mu_); diff --git a/src/ETISS.cpp b/src/ETISS.cpp index dbd5c02138..f44cb74e6e 100644 --- a/src/ETISS.cpp +++ b/src/ETISS.cpp @@ -35,6 +35,7 @@ #include "etiss/ETISS.h" #include "etiss/fault/Stressor.h" +#include "etiss/IntegratedLibrary/InstructionAccurateCallback.h" #include #include @@ -748,6 +749,7 @@ void etiss_initialize(const std::vector& args, bool forced = false) ("vp.sw_binary_rom", po::value(), "Path to binary file to be loaded into ROM.") ("vp.elf_file", po::value(), "Load ELF file.") ("vp.stats_file_path", po::value(), "Path where the output json file gets stored after bare processor is run.") + ("faults.xml", po::value(), "Path to faults XML file.") ("simple_mem_system.print_dbus_access", po::value(), "Traces accesses to the data bus.") ("simple_mem_system.print_ibus_access", po::value(), "Traces accesses to the instruction bus.") ("simple_mem_system.print_dbgbus_access", po::value(), "Traces accesses to the debug bus.") @@ -862,19 +864,6 @@ void etiss_initialize(const std::vector& args, bool forced = false) } } } - - // load fault files - { - std::string faults = cfg().get("faults.xml", ""); - if (!faults.empty()) - { - std::list ffs = etiss::split(faults, ';'); - for (auto ff : ffs) - { - etiss::fault::Stressor::loadXML(ff); - } - } - } } void etiss::initialize(std::vector& args) @@ -910,6 +899,53 @@ static class helper_class_etiss_1 bool etiss_shutdownOk = false; +void etiss::initialize_virtualstruct(std::shared_ptr cpu_core) +{ + auto mount_successful = etiss::VirtualStruct::root()->mountStruct(cpu_core->getName(), cpu_core->getStruct()); + // check if it the core is already mounted. + if( etiss::VirtualStruct::root()->findStruct(cpu_core->getName()) ) + { + mount_successful = true; // already mounted as a substruct to the root() + } + + if(!mount_successful) + { + etiss::log(etiss::FATALERROR, std::string("Tried to mount ") + cpu_core->getName() + std::string("'s VirtualStruct, but failed: etiss::CPUCore not created!")); + } + else + { + etiss::log(etiss::VERBOSE, std::string("Mounted ") + cpu_core->getName() + std::string("'s VirtualStruct to root VirtualStruct")); + + // load fault files + std::string faults = cfg().get("faults.xml", ""); + if (!faults.empty()) + { + std::list ffs = etiss::split(faults, ';'); + for (const auto& ff : ffs) + { + auto stressor_successful = etiss::fault::Stressor::loadXML(ff, cpu_core->getID()); + if (!stressor_successful) + { + etiss::log(etiss::FATALERROR, std::string("Failed to load requested faults.xml \'") + ff + std::string("\' for ") + cpu_core->getName() + std::string(".")); + } + else + { + etiss::log(etiss::VERBOSE, std::string("Faults from \'") + ff + std::string("\' loaded for ") + cpu_core->getName() + std::string(".")); + } + } + + etiss::log(etiss::VERBOSE, std::string("Add InstructionAccurateCallback Plugin to ") + cpu_core->getName() + std::string(". Required for etiss::fault::Injector.")); + cpu_core->addPlugin(std::make_shared()); + } + } +} + +void etiss::initialize_virtualstruct(std::shared_ptr cpu_core, std::function const & fcustom_action) +{ + etiss::initialize_virtualstruct(cpu_core); + cpu_core->getStruct()->applyCustomAction = fcustom_action; +} + void etiss::shutdown() { if (etiss_shutdownOk) // only on shutdown @@ -1010,4 +1046,3 @@ std::string etiss::errorMessage(etiss::int32 code, CPUArch *arch) } } } - diff --git a/src/IntegratedLibrary/InstructionAccurateCallback.cpp b/src/IntegratedLibrary/InstructionAccurateCallback.cpp index bd07731825..d7d98eb691 100644 --- a/src/IntegratedLibrary/InstructionAccurateCallback.cpp +++ b/src/IntegratedLibrary/InstructionAccurateCallback.cpp @@ -41,15 +41,17 @@ */ #include "etiss/IntegratedLibrary/InstructionAccurateCallback.h" +#include "etiss/fault/Stressor.h" + #include "etiss/CPUCore.h" #include "etiss/Instruction.h" extern "C" { - void etiss_plugin_InstructionAccurateCallback(void *ptr) + etiss_int32 etiss_plugin_InstructionAccurateCallback_OnEntry(void *ptr) { etiss::plugin::InstructionAccurateCallback &vvl = *(etiss::plugin::InstructionAccurateCallback *)ptr; - vvl.call(); + return vvl.call_on_entry(); } } @@ -64,7 +66,7 @@ InstructionAccurateCallback::~InstructionAccurateCallback() {} void InstructionAccurateCallback::initCodeBlock(etiss::CodeBlock &block) const { - block.fileglobalCode().insert("extern void etiss_plugin_InstructionAccurateCallback(void *); "); + block.fileglobalCode().insert("extern etiss_int32 etiss_plugin_InstructionAccurateCallback_OnEntry(void *); "); } void InstructionAccurateCallback::finalizeInstrSet(etiss::instr::ModedInstructionSet &mis) const @@ -74,9 +76,10 @@ void InstructionAccurateCallback::finalizeInstrSet(etiss::instr::ModedInstructio is.foreach ([this](etiss::instr::Instruction &i) { i.addCallback( [this](etiss::instr::BitArray &, etiss::CodeSet &cs, etiss::instr::InstructionContext &) { - etiss::CodePart &p = cs.append(etiss::CodePart::INITIALREQUIRED); - p.getRegisterDependencies().add("cpuTime_ps", 8); - p.code() = std::string("etiss_plugin_InstructionAccurateCallback(") + getPointerCode() + ");"; + etiss::CodePart &pp = cs.prepend(etiss::CodePart::INITIALREQUIRED); + pp.code() = + std::string("etiss_int32 ret_iac = etiss_plugin_InstructionAccurateCallback_OnEntry(") + + getPointerCode() + ");\nif(ret_iac != 0)return(ret_iac);"; return true; }, 0); @@ -90,9 +93,22 @@ std::string InstructionAccurateCallback::_getPluginName() const return std::string("InstructionAccurateCallback"); } -void InstructionAccurateCallback::call() +etiss_int32 InstructionAccurateCallback::call_on_entry() { - plugin_core_->getStruct()->instructionAccurateCallback(plugin_cpu_->cpuTime_ps); + bool trigger_fired = false; + auto time = plugin_cpu_->cpuTime_ps; + + etiss::fault::Stressor::reset_event(); + + trigger_fired |= plugin_core_->getStruct()->instructionAccurateCallback( + time); // call instruction callback of plugin-associated core + plugin_core_->getStruct()->foreachStruct( // call instruction callback of all VirtualStructs mounted on core + [time, &trigger_fired](const std::string &name, VirtualStruct &vs) { + trigger_fired |= vs.instructionAccurateCallback(time); + }); + + return (trigger_fired ? etiss::fault::Stressor::get_event() + : 0); // signal that a trigger has thrown an exception back to the JIT code calling } } // namespace plugin diff --git a/src/IntegratedLibrary/InstructionSpecificAddressCallback.cpp b/src/IntegratedLibrary/InstructionSpecificAddressCallback.cpp index e130b971f8..c32cad206c 100644 --- a/src/IntegratedLibrary/InstructionSpecificAddressCallback.cpp +++ b/src/IntegratedLibrary/InstructionSpecificAddressCallback.cpp @@ -76,6 +76,7 @@ extern "C" using namespace etiss::plugin; InstructionSpecificAddressCallback::InstructionSpecificAddressCallback() + : uid_{get_uid_once()} { pluginData_.state_ = 0; pluginData_.this_ = this; @@ -107,14 +108,14 @@ void InstructionSpecificAddressCallback::finalizeInstrSet(etiss::instr::ModedIns ss.str(""); ss.clear(); - ss << " uint32_t callbackCalled = InstructionSpecificAddressCallback_callback(" + ss << " uint32_t callbackCalled" << uid_ <<" = InstructionSpecificAddressCallback_callback(" << getPointerCode() << ");"; // cs.append(CodePart::APPENDEDREQUIRED).code() = ss.str(); cs.append(CodePart::PREINITIALDEBUGRETURNING).code() = ss.str(); ss.str(""); ss.clear(); - ss << " if(callbackCalled)\n" + ss << " if(callbackCalled" << uid_ <<")\n" << " return ETISS_RETURNCODE_NOERROR;"; // cs.append(CodePart::APPENDEDRETURNINGREQUIRED).code() = ss.str(); cs.append(CodePart::PREINITIALDEBUGRETURNING).code() = ss.str(); diff --git a/src/IntegratedLibrary/fault/MemoryManipulationSystem.cpp b/src/IntegratedLibrary/fault/MemoryManipulationSystem.cpp new file mode 100644 index 0000000000..2d335a9df8 --- /dev/null +++ b/src/IntegratedLibrary/fault/MemoryManipulationSystem.cpp @@ -0,0 +1,237 @@ +/** + + @copyright + +
+
+        Copyright 2018 Infineon Technologies AG
+
+        This file is part of ETISS tool, see .
+
+        The initial version of this software has been created with the funding support by the German Federal
+        Ministry of Education and Research (BMBF) in the project EffektiV under grant 01IS13022.
+
+        Redistribution and use in source and binary forms, with or without modification, are permitted
+        provided that the following conditions are met:
+
+        1. Redistributions of source code must retain the above copyright notice, this list of conditions and
+        the following disclaimer.
+
+        2. 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.
+
+        3. Neither the name of the copyright holder 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 HOLDER 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.
+
+        
+ + @author Chair of Electronic Design Automation, TUM + + @date November 16, 2021 + + @version 0.1 + +*/ +/** + @file + + @brief implementation of etiss/IntegratedLibrary/fault/MemoryManipulationSystem.h + + @detail + +*/ + +#include "etiss/IntegratedLibrary/fault/MemoryManipulationSystem.h" +#include "etiss/Misc.h" +#include "elfio/elfio.hpp" +#include +#include + +using namespace etiss; +using namespace ELFIO; + +std::shared_ptr MemoryManipulationSystem::getStruct(void) +{ + if (!vsystem_) + { + vsystem_ = etiss::VirtualStruct::allocate(this, [](etiss::VirtualStruct::Field *f) { delete f; }); + } + return vsystem_; +} + +void MemoryManipulationSystem::init_manipulation(std::shared_ptr vs_parent) +{ + auto mount_successful = vs_parent->getStruct()->mountStruct(this->getName(), this->getStruct()); + + if (!mount_successful) + { + etiss::log(etiss::FATALERROR, std::string("Failed to mount ") + this->getName() + + std::string("'s VirtualStruct to ") + vs_parent->getName()); + } + else + { + uint8_t arch_width = 0; + + if (etiss::cfg().isSet("arch.cpu")) + { + auto cpu_arch_str = etiss::cfg().get("arch.cpu", ""); + arch_width = cpu_arch_str == "RISCV64" ? 64 : 32; + } + else + { + // get architecture automatically + std::string elf_file = etiss::cfg().get("vp.elf_file", ""); + ELFIO::elfio reader; + if (!reader.load(elf_file)) + { + etiss::log(etiss::FATALERROR, "ELF reader could not process file"); + } + arch_width = reader.get_class() == ELFCLASS64 ? 64 : 32; + } + + etiss::log(etiss::VERBOSE, std::string("Mounted ") + this->getName() + + std::string("'s VirtualStruct to CPUCore ") + vs_parent->getName()); + + if (!etiss::cfg().isSet("vp.elf_file")) + { + etiss::log(etiss::FATALERROR, std::string("MemoryManipulationSystem::initialize_virtualstruct: Requires " + "\"vp.elf_file\" config to retrieve architecture bit-width.")); + } + + std::string elf_file = etiss::cfg().get("vp.elf_file", ""); + + ELFIO::elfio reader; + + if (!reader.load(elf_file)) + { + etiss::log(etiss::FATALERROR, "ELF reader could not process file"); + } + + if (arch_width == 32) + { + auto read = [this](size_t address, etiss::int32 &return_code) + { + etiss::uint32 x; + return_code = dbus_access(nullptr, static_cast(address), + reinterpret_cast(&x), sizeof(x)); + return x; + }; + auto write = [this](size_t address, etiss::uint32 word, etiss::int32 &return_code) + { + return_code = dbus_access(nullptr, static_cast(address), + reinterpret_cast(&word), sizeof(word)); + }; + mem_manipulator_ = std::make_unique>(read, write); + } + else if (arch_width == 64) + { + auto read = [this](size_t address, etiss::int32 &return_code) + { + etiss::uint64 x; + return_code = dbus_access(nullptr, static_cast(address), + reinterpret_cast(&x), sizeof(x)); + return x; + }; + auto write = [this](size_t address, etiss::uint64 word, etiss::int32 &return_code) + { + return_code = dbus_access(nullptr, static_cast(address), + reinterpret_cast(&word), sizeof(word)); + }; + mem_manipulator_ = std::make_unique>(read, write); + } + else + { + etiss::log(etiss::FATALERROR, + std::string("Failed to initiliaze MemStack: Architecture bit width not set.")); + } + + getStruct()->applyCustomAction = + [this](const etiss::fault::Fault &fault, const etiss::fault::Action &action, std::string &errormsg) + { + auto cmd = action.getCommand(); + + size_t pos = 0; + std::vector split_cmd; + while ((pos = cmd.find(" ")) != std::string::npos) + { + split_cmd.push_back(cmd.substr(0, pos)); + cmd.erase(0, pos + 1); + } + split_cmd.push_back(cmd); + if (split_cmd.size() > 1) + { + etiss::uint64 dst_address; + etiss::int32 return_code; + dst_address = std::stoll(split_cmd[1], nullptr, 16); + + std::transform(split_cmd[0].begin(), split_cmd[0].end(), split_cmd[0].begin(), ::toupper); + auto mem_manip_cmd = MemoryWordManipulatorBase::mem_manip_cmd_t::_from_string("UNDEF"); + if (auto maybe = MemoryWordManipulatorBase::mem_manip_cmd_t::_from_string_nothrow(split_cmd[0].c_str())) + { + mem_manip_cmd = MemoryWordManipulatorBase::mem_manip_cmd_t::_from_integral(maybe); + } + + switch (mem_manip_cmd) + { + case MemoryWordManipulatorBase::mem_manip_cmd_t::PUSH: + return_code = mem_manipulator_->push(dst_address); + break; + case MemoryWordManipulatorBase::mem_manip_cmd_t::POP: + return_code = mem_manipulator_->pop(dst_address); + break; + case MemoryWordManipulatorBase::mem_manip_cmd_t::RMW: + { + etiss::uint64 val; + val = std::stoll(split_cmd[3], nullptr, 16); + return_code = + mem_manipulator_->rmw(dst_address, MemoryWordManipulatorBase::MemOp(split_cmd[2]), val); + break; + } + case MemoryWordManipulatorBase::mem_manip_cmd_t::RRMW: + { + etiss::uint64 src2_addr; + src2_addr = std::stoll(split_cmd[3], nullptr, 16); + return_code = + mem_manipulator_->rrmw(dst_address, MemoryWordManipulatorBase::MemOp(split_cmd[2]), src2_addr); + break; + } + default: /* UNDEF */ + etiss::log(etiss::FATALERROR, + std::string("MemoryManipulationSystem/VirtualStruct/applyCustomAction: \'") + + action.getCommand() + + std::string("\' unrecognized Action. Invalid memory manipulation command: ") + + split_cmd[0]); + return false; + } + + if (return_code != etiss::RETURNCODE::NOERROR) + { + etiss::log(etiss::FATALERROR, + std::string("MemoryManipulationSystem/VirtualStruct/applyCustomAction: \'") + + action.getCommand() + std::string("\' memory access error")); + return false; + } + + return true; + } + + etiss::log(etiss::FATALERROR, std::string("MemoryManipulationSystem/VirtualStruct/applyCustomAction: \'") + + action.getCommand() + std::string("\' unrecognized Action")); + return false; + }; + } +} + +MemoryManipulationSystem::MemoryManipulationSystem(const std::string &name) + : SimpleMemSystem(), name_(name), vsystem_(), mem_manipulator_() +{ +} diff --git a/src/Misc.cpp b/src/Misc.cpp index 8569e92c23..d48e361c39 100644 --- a/src/Misc.cpp +++ b/src/Misc.cpp @@ -391,7 +391,7 @@ std::pair etiss::Configuration::set_cmd_line_boost(con etiss::Configuration sobj; if (s.length() > 2) { - if (s.find("-f") == 0) + if (s.find("-f") == 0) { size_t epos = s.find_first_of('='); if (s.length() > 5 && s.substr(2, 3) == "no-") @@ -412,8 +412,8 @@ std::pair etiss::Configuration::set_cmd_line_boost(con etiss::log(etiss::VERBOSE, std::string("CONFIG: removed ") + tmp); return make_pair(std::string(), std::string()); } - } - else + } + else { if (epos == std::string::npos) { @@ -434,8 +434,8 @@ std::pair etiss::Configuration::set_cmd_line_boost(con return make_pair(s.substr(2), tval); } return make_pair(std::string(), std::string()); - } - } + } + } } return make_pair(std::string(), std::string()); } diff --git a/src/VirtualStruct.cpp b/src/VirtualStruct.cpp index e2e3011208..4b19e198e3 100644 --- a/src/VirtualStruct.cpp +++ b/src/VirtualStruct.cpp @@ -178,9 +178,9 @@ bool VirtualStruct::Field::applyBitflip(unsigned position, uint64_t fault_id) bool VirtualStruct::Field::applyAction(const etiss::fault::Fault &f, const etiss::fault::Action &a, std::string &errormsg) { - if (!(flags_ & A)) + if (!(flags_ & (A | F))) { - errormsg = "field doesn't support advanced action handling"; + errormsg = "field doesn't support action handling"; return false; } return _applyAction(f, a, errormsg); @@ -214,6 +214,42 @@ bool VirtualStruct::Field::_applyBitflip(unsigned position, uint64_t fault_id) bool VirtualStruct::Field::_applyAction(const etiss::fault::Fault &f, const etiss::fault::Action &a, std::string &errormsg) { + if (a.getType() == +etiss::fault::Action::type_t::MASK) + { + uint64_t mask_value = a.getMaskValue(); + uint64_t val = read(), errval; + switch (a.getMaskOp()) + { + case etiss::fault::Action::mask_op_t::AND: + errval = (val & mask_value); + break; + case etiss::fault::Action::mask_op_t::OR: + errval = (val | mask_value); + break; + case etiss::fault::Action::mask_op_t::XOR: + errval = (val ^ mask_value); + break; + case etiss::fault::Action::mask_op_t::NAND: + errval = ~(val & mask_value); + break; + case etiss::fault::Action::mask_op_t::NOR: + errval = ~(val | mask_value); + break; + case etiss::fault::Action::mask_op_t::NOP: + errval = val; + break; + } + write(errval); + std::stringstream ss; + ss << "Injected mask fault in " << name_ << " 0x" << std::hex << val << " " << a.getMaskOp() + << " 0x" << mask_value << "->0x" << errval << std::dec; + etiss::log(etiss::INFO, ss.str()); + return true; + } + else if (a.getType() == +etiss::fault::Action::type_t::BITFLIP) + { + return applyBitflip(a.getTargetBit(), f.id_); + } return false; } @@ -408,10 +444,12 @@ bool VirtualStruct::isClosed() std::list VirtualStruct::listFields() { std::list ret; - foreachField([&ret](std::shared_ptr f) { - if (f) - ret.push_back(f->name_); - }); + foreachField( + [&ret](std::shared_ptr f) + { + if (f) + ret.push_back(f->name_); + }); return ret; } std::list VirtualStruct::listSubInjectors() @@ -466,7 +504,7 @@ bool VirtualStruct::applyAction(const etiss::fault::Fault &fault, const etiss::f { switch (action.getType()) { - case etiss::fault::Action::COMMAND: // handle command + case +etiss::fault::Action::type_t::COMMAND: // handle command { if (!applyCustomAction) { @@ -476,7 +514,9 @@ bool VirtualStruct::applyAction(const etiss::fault::Fault &fault, const etiss::f } return applyCustomAction(fault, action, errormsg); } - case etiss::fault::Action::BITFLIP: // handle bitflip + case +etiss::fault::Action::type_t::MASK: + [[fallthrough]]; + case +etiss::fault::Action::type_t::BITFLIP: // handle bitflip { Field *f; auto find = fieldNames_.find(action.getTargetField()); @@ -502,14 +542,10 @@ bool VirtualStruct::applyAction(const etiss::fault::Fault &fault, const etiss::f errormsg = std::string("No such field: ") + getInjectorPath() + "." + action.getTargetField(); return false; } - if (f->flags_ & Field::A) + if (f->flags_ & (Field::A | Field::F)) { return f->applyAction(fault, action, errormsg); } - else if (f->flags_ & Field::F) - { - return f->applyBitflip(action.getTargetBit(), fault.id_); - } } return false; default: @@ -517,6 +553,45 @@ bool VirtualStruct::applyAction(const etiss::fault::Fault &fault, const etiss::f } } +bool VirtualStruct::update_field_access_rights(const etiss::fault::Action &action, std::string &errormsg) +{ + Field *f = nullptr; + auto find = fieldNames_.find(action.getTargetField()); + if (find == fieldNames_.end()) + { + find = fieldPrettyNames_.find(action.getTargetField()); + if (find != fieldPrettyNames_.end()) + { + f = find->second; + } + } + else + { + f = find->second; + } + + if (f) + { + switch (action.getType()) + { + case +etiss::fault::Action::type_t::MASK: + [[fallthrough]]; + case +etiss::fault::Action::type_t::BITFLIP: + f->flags_ |= Field::F; + break; + default: + break; + } + } + else + { + errormsg = + std::string("VirtualStruct:update_field_access_rights(): Required field not a field in VirtualStruct!"); + return false; + } + return true; +} + VSSync::VSSync() { mutex().lock(); @@ -542,55 +617,59 @@ void copy(VirtualStruct &dst, VirtualStruct &src, std::list> dst_known; - src.foreachField([&](std::shared_ptr srcf) { - if (srcf->flags_ & VirtualStruct::Field::P) + src.foreachField( + [&](std::shared_ptr srcf) { - if (src_private) - src_private->push_back(srcf); - return; - } + if (srcf->flags_ & VirtualStruct::Field::P) + { + if (src_private) + src_private->push_back(srcf); + return; + } - auto dstf = dst.findName(srcf->name_); - if (dstf == 0) - { - notPresent.push_back(srcf); - return; - } + auto dstf = dst.findName(srcf->name_); + if (dstf == 0) + { + notPresent.push_back(srcf); + return; + } - if (dstf->flags_ & VirtualStruct::Field::P) - { - notPresent.push_back(srcf); - return; - } + if (dstf->flags_ & VirtualStruct::Field::P) + { + notPresent.push_back(srcf); + return; + } - dst_known.insert(dstf); + dst_known.insert(dstf); - if (!(dstf->flags_ & VirtualStruct::Field::W)) - { - notWriteable.push_back(dstf); - return; - } + if (!(dstf->flags_ & VirtualStruct::Field::W)) + { + notWriteable.push_back(dstf); + return; + } - if (!pretend) - dstf->write(srcf->read()); // copy value - }); + if (!pretend) + dstf->write(srcf->read()); // copy value + }); - dst.foreachField([&](std::shared_ptr dstf) { - if (dst_known.find(dstf) == dst_known.end()) + dst.foreachField( + [&](std::shared_ptr dstf) { - if (dstf->flags_ & VirtualStruct::Field::P) + if (dst_known.find(dstf) == dst_known.end()) { - if (dst_private) + if (dstf->flags_ & VirtualStruct::Field::P) { - dst_private->push_back(dstf); + if (dst_private) + { + dst_private->push_back(dstf); + } + } + else + { + unknown.push_back(dstf); } } - else - { - unknown.push_back(dstf); - } - } - }); + }); } std::shared_ptr VirtualStruct::allocate(void *structure, std::function delete_) diff --git a/src/bare_etiss_processor/CMakeLists.txt b/src/bare_etiss_processor/CMakeLists.txt index 7eb1f0fc60..14fff67e2c 100644 --- a/src/bare_etiss_processor/CMakeLists.txt +++ b/src/bare_etiss_processor/CMakeLists.txt @@ -74,4 +74,5 @@ install(DIRECTORY ${CMAKE_CURRENT_LIST_DIR}/ DESTINATION examples FILES_MATCHING PATTERN "*.ini" + PATTERN "*.xml" ) diff --git a/src/bare_etiss_processor/README.md b/src/bare_etiss_processor/README.md index a1c3d4e8e9..c19aa3f263 100644 --- a/src/bare_etiss_processor/README.md +++ b/src/bare_etiss_processor/README.md @@ -182,3 +182,81 @@ When utilizing **gdbserver** to debug target software. ### ETISS output in terminal ![](etissSnapshot.png "ETISS output in terminal") + +## Fault Injection Demo + +Usage: + +- ./run_helper.sh ELFFILE --faults.xml=/path/to/faults.xml + +`faults.xml` Example and explanations: + +```xml + + + + + + 1 + + core%i% + instructionPointer + b0 + + + + + + core%i% + some string + + + core%i% + X1 + 1 + + + + + + + + + + + + + 10 + + core%i% + + + + + + + + + + + + + core%i% + + + + + core%i% + X2 + OR + 0x55555555 + + + + + + + + + +``` diff --git a/src/bare_etiss_processor/faults.xml b/src/bare_etiss_processor/faults.xml new file mode 100644 index 0000000000..7997884af7 --- /dev/null +++ b/src/bare_etiss_processor/faults.xml @@ -0,0 +1,70 @@ + + + + + + 1 + + core%i% + instructionPointer + b0 + + + + + + core%i%::system + rmw 0x80000 OR 0xFFFFFFFF + + + core%i% + some string + + + core%i% + X1 + 1 + + + + + + + + + + + + + 9 + + core%i% + + + + + + + + + + + + + core%i% + + + + + core%i% + X2 + OR + 0x1 + + + + + + + + diff --git a/src/bare_etiss_processor/main.cpp b/src/bare_etiss_processor/main.cpp index ba60edf0f5..ea9731526d 100644 --- a/src/bare_etiss_processor/main.cpp +++ b/src/bare_etiss_processor/main.cpp @@ -42,9 +42,9 @@ #include "TracePrinter.h" #include "etiss/SimpleMemSystem.h" +#include "etiss/IntegratedLibrary/fault/MemoryManipulationSystem.h" #include "etiss/ETISS.h" - int main(int argc, const char *argv[]) { // by default etiss wil search for plugin libraries in its install path and @@ -55,20 +55,33 @@ int main(int argc, const char *argv[]) // ./main [-o