diff --git a/.travis.yml b/.travis.yml index 5ae6179..f9c389b 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,61 +1,122 @@ -#The initial configuration came from the article: http://genbattle.bitbucket.org/blog/2016/01/17/c++-travis-ci/ - -sudo: required -dist: trusty - python: - "3.5" + +git: + depth: 5 + +#Disable the default Travis submodule behavior. +git: + submodules: false env: global: - #COVERITY_SCAN_TOKEN - - secure: "OtVLkLQ+O18ZOxFCVTotdxWwxOqE0HcCh7LEguFPpPOp5KX9JsBrRdN8Hq689AK+GnQVuYVHkRPdiduYq8CUoLppZy0AMus7muJp2bdnotwufOIZ0r9lqzau9F4HKcdg8LBjyoHq2gnJZgNsSlrma9AGJ8nKBlVCsOJU/2DB0zJ0ufUR92otRsbKlF0TFXC2SARHYL1fgjoJBtwtKyUkHcn5/85EZjUeZGVvvRIA1oqFN2ksHv2QSevSb4auZgi8Gz4LdkQFfWa+SYDoguMYDZCkJRg4kP/ciuAxWfulroXUyAHOGvg29AwkK7hpnFCiGCxm+mOoDousBrJymuqdblwyTzy3d84i1QZQWEAaSROuPA/cpmSPHBvx+H/YTkmdPKXp46728I1wSILOclN1icWll9KhuiDMGY48e2Zmux5SKuLTjg1wzFNrVEwLeiGT7kExWXeKdPMRo/xmH2vPDlBUVrl2z12RRinpGLW0lgG70f5EJl0K30ArNXmFfFZ775nUBokc9nVgK/bjA9t2olRlOC3tzkhgZnDYp7N/AudKeOnpsWeZEQjf9p/o7SjvMvqgbGXL6kZ74n8Jkau1nKIB+9viplLpBInxEYyMSZ/9qFZf3roYmBVYRA8v6G6PsFagYnqp4vl1zGjiO49KEW1jEF56gWKRYuYHQOaebsI=" #Compilers - CC=gcc-8 - CXX=g++-8 -#Disable the default Travis submodule behavior. -git: - submodules: false +matrix: + fast_finish: true + include: + # Just run tests + - if: NOT branch = coverity_scan + os: linux + dist: trusty + sudo: required + name: "vcdMaker Tests" + addons: + apt: + sources: + - ubuntu-toolchain-r-test + packages: + - gcc-8 + - g++-8 + - txt2man + - doxygen + - graphviz + before_script: + - git submodule update --init --recursive + - cd ./sources + script: + - cmake -DUSE_STATIC_PUGIXML=ON -DCMAKE_BUILD_TYPE=Release . + - VERBOSE=1 make + - make check -addons: - apt: - sources: - - ubuntu-toolchain-r-test - packages: - - gcc-8 - - g++-8 - - txt2man - - doxygen - - graphviz + # Code coverage + - if: NOT branch = coverity_scan + os: linux + dist: xenial + sudo: required + name: "vcdMaker Code Coverage" + addons: + apt: + sources: + - ubuntu-toolchain-r-test + packages: + - gcc-8 + - g++-8 + - txt2man + - doxygen + - graphviz + - lcov + install: + - gem install coveralls-lcov + before_script: + - sudo update-alternatives --install /usr/bin/gcov gcov /usr/bin/gcov-5 0 + - sudo update-alternatives --install /usr/bin/gcov gcov /usr/bin/gcov-8 100 + - sudo update-alternatives --auto gcov + - wget http://mirrors.kernel.org/ubuntu/pool/universe/l/lcov/lcov_1.13-4_all.deb + - sudo dpkg -i lcov_1.13-4_all.deb + - rm -f lcov_1.13-4_all.deb + - git submodule update --init --recursive + - cd ./sources + - lcov --directory . --zerocounters + script: + - cmake -DUSE_STATIC_PUGIXML=ON -DCMAKE_BUILD_TYPE=Debug -DCODE_COVERAGE=ON . + - VERBOSE=1 make + - make check + after_success: + - lcov --directory . --capture --output-file raw.info + - lcov --remove raw.info '/usr/*' '*/3rdParty/*' '*/test/*' --output-file coverage.info + - lcov --list coverage.info + - coveralls-lcov --repo-token ${COVERALLS_REPO_TOKEN} coverage.info - coverity_scan: - project: - name: vcdMaker - version: v3.0 - description: Coverity Scan by Travis CI - notification_email: vcdmaker@mail.com - build_command_prepend: "cov-configure --comptype gcc --compiler g++-8 --template && cmake -DUSE_STATIC_PUGIXML=ON -DCMAKE_BUILD_TYPE=Release ." - build_command: "make" - branch_pattern: coverity_scan - -# Blocklist - branches not to be built. RegEx is allowed. -branches: - except: - - r2_release + # Coverity + - if: branch = coverity_scan + os: linux + dist: trusty + sudo: required + name: "vcdMaker Coverity" + env: + - secure: "OtVLkLQ+O18ZOxFCVTotdxWwxOqE0HcCh7LEguFPpPOp5KX9JsBrRdN8Hq689AK+GnQVuYVHkRPdiduYq8CUoLppZy0AMus7muJp2bdnotwufOIZ0r9lqzau9F4HKcdg8LBjyoHq2gnJZgNsSlrma9AGJ8nKBlVCsOJU/2DB0zJ0ufUR92otRsbKlF0TFXC2SARHYL1fgjoJBtwtKyUkHcn5/85EZjUeZGVvvRIA1oqFN2ksHv2QSevSb4auZgi8Gz4LdkQFfWa+SYDoguMYDZCkJRg4kP/ciuAxWfulroXUyAHOGvg29AwkK7hpnFCiGCxm+mOoDousBrJymuqdblwyTzy3d84i1QZQWEAaSROuPA/cpmSPHBvx+H/YTkmdPKXp46728I1wSILOclN1icWll9KhuiDMGY48e2Zmux5SKuLTjg1wzFNrVEwLeiGT7kExWXeKdPMRo/xmH2vPDlBUVrl2z12RRinpGLW0lgG70f5EJl0K30ArNXmFfFZ775nUBokc9nVgK/bjA9t2olRlOC3tzkhgZnDYp7N/AudKeOnpsWeZEQjf9p/o7SjvMvqgbGXL6kZ74n8Jkau1nKIB+9viplLpBInxEYyMSZ/9qFZf3roYmBVYRA8v6G6PsFagYnqp4vl1zGjiO49KEW1jEF56gWKRYuYHQOaebsI=" + addons: + apt: + sources: + - ubuntu-toolchain-r-test + packages: + - gcc-8 + - g++-8 + - txt2man + - doxygen + - graphviz + coverity_scan: + project: + name: vcdMaker + version: v4.0 + description: Coverity Scan by Travis CI + notification_email: vcdmaker@mail.com + build_command_prepend: "cov-configure --comptype gcc --compiler g++-8 --template && cmake -DUSE_STATIC_PUGIXML=ON -DCMAKE_BUILD_TYPE=Release ." + build_command: "make" + branch_pattern: coverity_scan + before_script: + - git submodule update --init --recursive + - cd ./sources + script: + - tail cov-int/scm_log.txt # Safelist - branches to be built. branches: only: - master - v3_release + - v4_release - coverity_scan - -before_script: - - git submodule update --init --recursive - - cd ./sources - -script: - - cmake -DUSE_STATIC_PUGIXML=ON -DCMAKE_BUILD_TYPE=Release . - - VERBOSE=1 make - - make check diff --git a/LICENSE b/LICENSE index 466bec5..e4efb61 100644 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,6 @@ The MIT License (MIT) -Copyright (c) 2020 vcdMaker team +Copyright (c) 2018 vcdMaker team Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/README.md b/README.md index 866bb68..cd8fa09 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ [![GitHub License](https://github-basic-badges.herokuapp.com/license/WojciechRynczuk/vcdMaker.svg)](https://github.com/WojciechRynczuk/vcdMaker/blob/master/LICENSE) [![GitHub Release](https://github-basic-badges.herokuapp.com/release/WojciechRynczuk/vcdMaker.svg)](https://github.com/WojciechRynczuk/vcdMaker/releases/latest) [![Build Status](https://travis-ci.org/WojciechRynczuk/vcdMaker.svg?branch=master)](https://travis-ci.org/WojciechRynczuk/vcdMaker) -[![Coverity Scan Build Status](https://scan.coverity.com/projects/11276/badge.svg)](https://scan.coverity.com/projects/vcdmaker) +[![Coverity Scan Build Status](https://scan.coverity.com/projects/11276/badge.svg)](https://scan.coverity.com/projects/vcdmaker) [![Coverage Status](https://coveralls.io/repos/github/WojciechRynczuk/vcdMaker/badge.svg)](https://coveralls.io/github/WojciechRynczuk/vcdMaker) ## Basic information diff --git a/development/config/Doxyfile.in b/development/config/Doxyfile.in index a820f73..ef19c21 100644 --- a/development/config/Doxyfile.in +++ b/development/config/Doxyfile.in @@ -38,7 +38,7 @@ PROJECT_NAME = vcdMaker # could be handy for archiving the generated documentation or if some version # control system is used. -PROJECT_NUMBER = 3.0 +PROJECT_NUMBER = 4.0 # Using the PROJECT_BRIEF tag one can provide an optional one line description # for a project that appears at the top of each page and should give viewer a diff --git a/sources/CMakeLists.txt b/sources/CMakeLists.txt index 7cbb832..81b0647 100644 --- a/sources/CMakeLists.txt +++ b/sources/CMakeLists.txt @@ -12,8 +12,9 @@ # - parserSources.cmake: list of parser related files. # - vcdMaker.cmake, vcdMerge.cmake: executable targets with source list. # - unitTests.cmake: list of unit tests. +# - codeCoverage.cmake: enables creating coverage data. Just for Linux target. # -# Copyright (c) 2018 vcdMaker team +# Copyright (c) 2019 vcdMaker team # # Permission is hereby granted, free of charge, to any person obtaining a # copy of this software and associated documentation files (the "Software"), @@ -33,7 +34,7 @@ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS # IN THE SOFTWARE. -cmake_minimum_required(VERSION 3.0) +cmake_minimum_required(VERSION 3.8) include(FeatureSummary) @@ -48,6 +49,8 @@ include(commonSources) include(parserSources) +include(codeCoverage) + include(commonTarget) include(vcdMaker) @@ -74,4 +77,6 @@ include(doxygen) include(pugixml) +include(clean) + feature_summary(WHAT ALL) diff --git a/sources/cmake/clean.cmake b/sources/cmake/clean.cmake new file mode 100644 index 0000000..c75ddf8 --- /dev/null +++ b/sources/cmake/clean.cmake @@ -0,0 +1,26 @@ +# clean.cmake +# +# Make clean. +# +# Copyright (c) 2019 vcdMaker team +# +# 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. + +set_property(DIRECTORY APPEND PROPERTY ADDITIONAL_MAKE_CLEAN_FILES ${MAKE_CLEAN_FILES}) + diff --git a/sources/cmake/codeCoverage.cmake b/sources/cmake/codeCoverage.cmake new file mode 100644 index 0000000..df72a77 --- /dev/null +++ b/sources/cmake/codeCoverage.cmake @@ -0,0 +1,65 @@ +# codeCoverage.cmake +# +# Code Coverage generation. +# +# Copyright (c) 2019 vcdMaker team +# +# 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. + +option(CODE_COVERAGE "Enable code coverage generation") +add_feature_info(GCOV CODE_COVERAGE "Code coverage generation enabled.") + +if (CODE_COVERAGE) + + # Build type must be Debug + if (NOT ${CMAKE_BUILD_TYPE} STREQUAL Debug) + message(FATAL_ERROR "To generate code coverage data Debug build type must be used.") + endif() + + # Generate code coverage just for the Linux target + if (${CMAKE_CXX_COMPILER_ID} STREQUAL GNU) + add_compile_options(--coverage) + link_libraries(--coverage) + else() + message(FATAL_ERROR "Code coverage generation available only for the GNU compiler.") + endif() + + # Clean code coverage html + list(APPEND MAKE_CLEAN_FILES CodeCoverage) + list(APPEND MAKE_CLEAN_FILES raw.info) + list(APPEND MAKE_CLEAN_FILES vcdMaker.coverage) + +endif() + +add_custom_target(coverage_clean + COMMAND rm -rf CodeCoverage + COMMAND rm -f raw.info vcdMaker.coverage + COMMAND find . -type f -name '*.gcda' -delete + COMMENT "Cleaning code coverage data." +) + +add_custom_target(coverage + COMMAND mkdir CodeCoverage + COMMAND lcov --directory . --capture --rc lcov_branch_coverage=1 --output-file=raw.info + COMMAND lcov --remove raw.info '/usr/*' '*/3rdParty/*' '*/test/*' --rc lcov_branch_coverage=1 --output-file=vcdMaker.coverage + COMMAND genhtml --output-directory CodeCoverage --rc lcov_branch_coverage=1 vcdMaker.coverage + DEPENDS coverage_clean check + COMMENT "Generating code coverage." +) + diff --git a/sources/cmake/commonSources.cmake b/sources/cmake/commonSources.cmake index a60d017..9106e79 100644 --- a/sources/cmake/commonSources.cmake +++ b/sources/cmake/commonSources.cmake @@ -2,7 +2,7 @@ # # List of common source files and directories. # -# Copyright (c) 2017 vcdMaker team +# Copyright (c) 2020 vcdMaker team # # Permission is hereby granted, free of charge, to any person obtaining a # copy of this software and associated documentation files (the "Software"), @@ -42,6 +42,8 @@ set(COMMON_SOURCES ${COMMON_SOURCES_DIR}/Signal.cpp ${COMMON_SOURCES_DIR}/SignalDb.cpp ${COMMON_SOURCES_DIR}/SourceRegistry.cpp + ${COMMON_SOURCES_DIR}/SignalDescriptor.cpp + ${COMMON_SOURCES_DIR}/SignalDescriptorRegistry.cpp ${COMMON_SOURCES_DIR}/TxtParser.cpp ${COMMON_SOURCES_DIR}/LogParser.cpp ${COMMON_SOURCES_DIR}/LineCounter.cpp @@ -77,6 +79,8 @@ set(COMMON_HEADERS ${COMMON_HEADERS_DIR}/SignalStructureBuilder.h ${COMMON_HEADERS_DIR}/Signal.h ${COMMON_HEADERS_DIR}/SourceRegistry.h + ${COMMON_HEADERS_DIR}/SignalDescriptor.h + ${COMMON_HEADERS_DIR}/SignalDescriptorRegistry.h ${COMMON_HEADERS_DIR}/SignalDb.h ${COMMON_HEADERS_DIR}/VcdException.h ${COMMON_HEADERS_DIR}/VcdExceptionList.h @@ -88,6 +92,7 @@ set(COMMON_HEADERS ${COMMON_HEADERS_DIR}/VCDTracer.h ${COMMON_HEADERS_DIR}/SafeUInt.h ${COMMON_HEADERS_DIR}/Timestamp.h + ${COMMON_HEADERS_DIR}/OutOfMemory.h ${VERSION_HEADER}) # 3rd party directories. diff --git a/sources/cmake/installCpack.cmake b/sources/cmake/installCpack.cmake index 2db8ac9..a9e6b9b 100644 --- a/sources/cmake/installCpack.cmake +++ b/sources/cmake/installCpack.cmake @@ -2,7 +2,7 @@ # # CPack settings. # -# Copyright (c) 2017 vcdMaker team +# Copyright (c) 2018 vcdMaker team # # Permission is hereby granted, free of charge, to any person obtaining a # copy of this software and associated documentation files (the "Software"), @@ -25,9 +25,10 @@ # Set Cpack. set(AUTHOR "vcdMaker team") -set(WEBSITE "http://vcdmaker.org") -set(DESCRIPTION "Commandline tools that can generate VCD files from text logs") +set(WEBSITE "https://vcdmaker.org") +set(DESCRIPTION "Command line tools that can generate VCD files from text logs") +set(CPACK_PACKAGE_NAME "vcdMaker") set(CPACK_PACKAGE_VENDOR ${AUTHOR}) set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "Generates VCD files from text logs") set(CPACK_PACKAGE_VERSION_MAJOR ${PROJECT_VERSION_MAJOR}) @@ -52,5 +53,6 @@ set(CPACK_DEBIAN_PACKAGE_MAINTAINER ${AUTHOR}) set(CPACK_DEBIAN_PACKAGE_DESCRIPTION ${DESCRIPTION}) set(CPACK_DEBIAN_PACKAGE_SECTION "electronics") set(CPACK_DEBIAN_PACKAGE_HOMEPAGE ${WEBSITE}) +set(CPACK_DEBIAN_PACKAGE_ARCHITECTURE "amd64") include(CPack) diff --git a/sources/cmake/pugixml.cmake b/sources/cmake/pugixml.cmake index 4cc4a90..e270bd9 100644 --- a/sources/cmake/pugixml.cmake +++ b/sources/cmake/pugixml.cmake @@ -62,7 +62,7 @@ if (USE_STATIC_PUGIXML) target_include_directories(${COMMON_LIB_TARGET} PUBLIC ${PUGIXML_INCLUDE_DIR}) - set_directory_properties(PROPERTIES ADDITIONAL_MAKE_CLEAN_FILES ${PUGIXML_LIB_FILE}) + list(APPEND MAKE_CLEAN_FILES ${PUGIXML_LIB_FILE}) else() find_package(pugixml REQUIRED) set_package_properties(pugixml PROPERTIES diff --git a/sources/common/doc/examples/example.vcd b/sources/common/doc/examples/example.vcd index 44ecb94..f4042e9 100644 --- a/sources/common/doc/examples/example.vcd +++ b/sources/common/doc/examples/example.vcd @@ -1,6 +1,6 @@ -$date Tue Aug 28 21:45:21 2018 +$date Tue Dec 18 17:57:25 2018 $end -$version VCD Tracer "Nestor" Release v.3.0.1 +$version VCD Tracer "Nestor" Release v.3.0.2 $end $timescale 1 us $end @@ -24,6 +24,7 @@ $scope module FRDM $end $var wire 7 FRDM.Sensors.Slider Slider $end $upscope $end $upscope $end +$enddefinitions $end $dumpvars bx FRDM.Buttons.SW1 bx FRDM.Buttons.SW3 diff --git a/sources/common/doc/examples/merge_t1_t1.vcd b/sources/common/doc/examples/merge_t1_t1.vcd index 6469142..f148c46 100644 --- a/sources/common/doc/examples/merge_t1_t1.vcd +++ b/sources/common/doc/examples/merge_t1_t1.vcd @@ -1,6 +1,6 @@ -$date Tue Aug 28 21:47:21 2018 +$date Tue Dec 18 17:57:25 2018 $end -$version VCD Tracer "Nestor" Release v.3.0.1 +$version VCD Tracer "Nestor" Release v.3.0.2 $end $timescale 1 us $end @@ -63,6 +63,7 @@ $scope module System2 $end $upscope $end $upscope $end $upscope $end +$enddefinitions $end $dumpvars bx System1.Disco.Buttons.Center bx System1.Disco.Buttons.Down diff --git a/sources/common/doc/examples/merge_t1_t2.vcd b/sources/common/doc/examples/merge_t1_t2.vcd index 35a2722..817f663 100644 --- a/sources/common/doc/examples/merge_t1_t2.vcd +++ b/sources/common/doc/examples/merge_t1_t2.vcd @@ -1,6 +1,6 @@ -$date Tue Aug 28 21:46:07 2018 +$date Tue Dec 18 17:57:25 2018 $end -$version VCD Tracer "Nestor" Release v.3.0.1 +$version VCD Tracer "Nestor" Release v.3.0.2 $end $timescale 1 us $end @@ -63,6 +63,7 @@ $scope module System2 $end $upscope $end $upscope $end $upscope $end +$enddefinitions $end $dumpvars bx System1.Disco.Buttons.Center bx System1.Disco.Buttons.Down diff --git a/sources/common/doc/examples/vcdMaker.xml b/sources/common/doc/examples/vcdMaker.xml index 849bdfa..25c56bc 100644 --- a/sources/common/doc/examples/vcdMaker.xml +++ b/sources/common/doc/examples/vcdMaker.xml @@ -3,7 +3,7 @@ - #([[:d:]]+) ([[:graph:]]+) ([[:d:]]+) ([[:d:]]+) + #([[:d:]]+) ([[:graph:]]+) ([[:d:]]+) ([[:d:]]+)( +.*)? dec(1) txt(2) dec(3) diff --git a/sources/common/doc/manual.odt b/sources/common/doc/manual.odt index a755f5c..b688883 100644 Binary files a/sources/common/doc/manual.odt and b/sources/common/doc/manual.odt differ diff --git a/sources/common/doc/manual.pdf b/sources/common/doc/manual.pdf index 661b9e7..0e58d82 100644 Binary files a/sources/common/doc/manual.pdf and b/sources/common/doc/manual.pdf differ diff --git a/sources/common/inc/DefaultSignalFactory.h b/sources/common/inc/DefaultSignalFactory.h index 7614c73..8ed1f5d 100644 --- a/sources/common/inc/DefaultSignalFactory.h +++ b/sources/common/inc/DefaultSignalFactory.h @@ -7,7 +7,7 @@ /// /// @ingroup Parser /// -/// @par Copyright (c) 2017 vcdMaker team +/// @par Copyright (c) 2020 vcdMaker team /// /// Permission is hereby granted, free of charge, to any person obtaining a /// copy of this software and associated documentation files (the "Software"), @@ -41,7 +41,9 @@ namespace PARSER { public: - /// @copydoc SignalFactory::SignalFactory() - DefaultSignalFactory(); + /// Default signal factory constructor. + /// + /// @param rSignalDescriptorRegistry The unique signal registry. + DefaultSignalFactory(SIGNAL::SignalDescriptorRegistry &rSignalDescriptorRegistry); }; } diff --git a/sources/common/inc/EventSignal.h b/sources/common/inc/EventSignal.h index b6fea09..36cf6eb 100644 --- a/sources/common/inc/EventSignal.h +++ b/sources/common/inc/EventSignal.h @@ -7,7 +7,7 @@ /// /// @ingroup Signal /// -/// @par Copyright (c) 2016 vcdMaker team +/// @par Copyright (c) 2020 vcdMaker team /// /// Permission is hereby granted, free of charge, to any person obtaining a /// copy of this software and associated documentation files (the "Software"), @@ -40,15 +40,13 @@ namespace SIGNAL /// The event signal constructor. /// - /// It initializes the basic signal properties: the name and the timestamp. + /// It sets the event's timestamp. /// - /// The name shall consist of any alphanumeric string in which the module's - /// levels are separated with '.'. - /// E.g. Module1.Level3.Variable6 - EventSignal(const std::string &name, - const TIME::Timestamp &rTimestamp, - SourceRegistry::HandleT sourceHandle) : - Signal(name, 0, rTimestamp, "event", sourceHandle) + /// @param rSignalDescriptor Signal descriptor. + /// @param rTimestamp The timestamp of the event. + EventSignal(const std::shared_ptr &rSignalDescriptor, + const TIME::Timestamp &rTimestamp) : + Signal(rSignalDescriptor, rTimestamp) { } @@ -61,7 +59,7 @@ namespace SIGNAL /// @copydoc Signal::Print() virtual std::string Print() const { - return ("1" + m_Name); + return ("1" + GetName()); } /// @copydoc Signal::Footprint() diff --git a/sources/common/inc/EventSignalCreator.h b/sources/common/inc/EventSignalCreator.h index e686cc3..3303334 100644 --- a/sources/common/inc/EventSignalCreator.h +++ b/sources/common/inc/EventSignalCreator.h @@ -4,7 +4,7 @@ /// /// @ingroup Parser /// -/// @par Copyright (c) 2018 vcdMaker team +/// @par Copyright (c) 2020 vcdMaker team /// /// Permission is hereby granted, free of charge, to any person obtaining a /// copy of this software and associated documentation files (the "Software"), @@ -37,15 +37,18 @@ namespace PARSER public: /// The event signal creator constructor. - EventSignalCreator() : - SignalCreator("#([[:digit:]]+) ([[:graph:]]+) e( +.*)?") + /// + /// @param rDescriptorRegistry The reference to the signal descriptors registry. + EventSignalCreator(SIGNAL::SignalDescriptorRegistry &rDescriptorRegistry) : + SignalCreator(rDescriptorRegistry, "#([[:digit:]]+) ([[:graph:]]+) e( +.*)?") { } /// @copydoc SignalCreator::Create() - virtual SIGNAL::Signal *Create(const std::string &rLogLine, - INSTRUMENT::Instrument::LineNumberT lineNumber, - SIGNAL::SourceRegistry::HandleT sourceHandle) const; + virtual const SIGNAL::Signal *Create(const std::string &rLogLine, + INSTRUMENT::Instrument::LineNumberT lineNumber, + const std::string &rPrefix, + SIGNAL::SourceRegistry::HandleT sourceHandle) const; }; diff --git a/sources/common/inc/FSignal.h b/sources/common/inc/FSignal.h index 65229f4..3246114 100644 --- a/sources/common/inc/FSignal.h +++ b/sources/common/inc/FSignal.h @@ -8,7 +8,7 @@ /// /// @ingroup Signal /// -/// @par Copyright (c) 2016 vcdMaker team +/// @par Copyright (c) 2020 vcdMaker team /// /// Permission is hereby granted, free of charge, to any person obtaining a /// copy of this software and associated documentation files (the "Software"), @@ -44,18 +44,16 @@ namespace SIGNAL /// The floating signal constructor. /// - /// It initializes the basic signal properties: the name, the timestamp - /// and the value. + /// It sets the signal's timestamp and the value. /// - /// The name shall consist of any alphanumeric string in which the module's - /// levels are separated with '.'. - /// E.g. Module1.Level3.Variable6 - FSignal(const std::string &name, + /// @param rSignalDescriptor Signal descriptor. + /// @param rTimestamp Signal timestamp. + /// @param rValue Signal value. + FSignal(const std::shared_ptr &rSignalDescriptor, const TIME::Timestamp &rTimestamp, - const std::string &value, - SourceRegistry::HandleT sourceHandle) : - Signal(name, 64, rTimestamp, "real", sourceHandle), - m_Value(value) + const std::string &rValue) : + Signal(rSignalDescriptor, rTimestamp), + m_Value(rValue) { } @@ -77,7 +75,7 @@ namespace SIGNAL /// @copydoc Signal::Footprint() virtual std::string Footprint() const { - return ("r0.0 " + m_Name); + return ("r0.0 " + GetName()); } protected: diff --git a/sources/common/inc/FSignalCreator.h b/sources/common/inc/FSignalCreator.h index ef443eb..bbb3ad7 100644 --- a/sources/common/inc/FSignalCreator.h +++ b/sources/common/inc/FSignalCreator.h @@ -4,7 +4,7 @@ /// /// @ingroup Parser /// -/// @par Copyright (c) 2018 vcdMaker team +/// @par Copyright (c) 2020 vcdMaker team /// /// Permission is hereby granted, free of charge, to any person obtaining a /// copy of this software and associated documentation files (the "Software"), @@ -39,15 +39,18 @@ namespace PARSER public: /// The real signal creator constructor. - FSignalCreator() : - SignalCreator("#([[:digit:]]+) ([[:graph:]]+) ([[:d:][:punct:]]+) f( +.*)?") + /// + /// @param rDescriptorRegistry The reference to the signal descriptors registry. + FSignalCreator(SIGNAL::SignalDescriptorRegistry &rDescriptorRegistry) : + SignalCreator(rDescriptorRegistry, "#([[:digit:]]+) ([[:graph:]]+) ([[:d:][:punct:]]+) f( +.*)?") { } /// @copydoc SignalCreator::Create() - virtual SIGNAL::Signal *Create(const std::string &rLogLine, - INSTRUMENT::Instrument::LineNumberT lineNumber, - SIGNAL::SourceRegistry::HandleT sourceHandle) const; + virtual const SIGNAL::Signal *Create(const std::string &rLogLine, + INSTRUMENT::Instrument::LineNumberT lineNumber, + const std::string &rPrefix, + SIGNAL::SourceRegistry::HandleT sourceHandle) const; }; diff --git a/sources/common/inc/ISignal.h b/sources/common/inc/ISignal.h index 143b70c..a92b2e3 100644 --- a/sources/common/inc/ISignal.h +++ b/sources/common/inc/ISignal.h @@ -8,7 +8,7 @@ /// /// @ingroup Signal /// -/// @par Copyright (c) 2016 vcdMaker team +/// @par Copyright (c) 2020 vcdMaker team /// /// Permission is hereby granted, free of charge, to any person obtaining a /// copy of this software and associated documentation files (the "Software"), @@ -47,17 +47,14 @@ namespace SIGNAL /// The integer signal constructor. /// - /// It initializes the basic signal properties: the name, the size, the timestamp - /// and the value. + /// It sets the signal's timestamp and the value. /// - /// The name shall consist of any alphanumeric string in which the module's - /// levels are separated with '.'. - /// E.g. Module1.Level3.Variable6 - ISignal(const std::string &name, - size_t size, + /// @param rSignalDescriptor Signal descriptor. + /// @param rTimestamp Signal timestamp. + /// @param value Signal value. + ISignal(const std::shared_ptr &rSignalDescriptor, const TIME::Timestamp &rTimestamp, - uint64_t value, - SourceRegistry::HandleT sourceHandle); + uint64_t value); /// The integer signal cloning method. virtual Signal *Clone() const diff --git a/sources/common/inc/ISignalCreator.h b/sources/common/inc/ISignalCreator.h index 84efcb5..d10adb8 100644 --- a/sources/common/inc/ISignalCreator.h +++ b/sources/common/inc/ISignalCreator.h @@ -4,7 +4,7 @@ /// /// @ingroup Parser /// -/// @par Copyright (c) 2018 vcdMaker team +/// @par Copyright (c) 2020 vcdMaker team /// /// Permission is hereby granted, free of charge, to any person obtaining a /// copy of this software and associated documentation files (the "Software"), @@ -37,15 +37,18 @@ namespace PARSER { public: /// The integer signal creator constructor. - ISignalCreator() : - SignalCreator("#([[:digit:]]+) ([[:graph:]]+) ([[:digit:]]+) ([[:digit:]]+)( +.*)?") + /// + /// @param rDescriptorRegistry The reference to the signal descriptors registry. + ISignalCreator(SIGNAL::SignalDescriptorRegistry &rDescriptorRegistry) : + SignalCreator(rDescriptorRegistry, "#([[:digit:]]+) ([[:graph:]]+) ([[:digit:]]+) ([[:digit:]]+)( +.*)?") { } /// @copydoc SignalCreator::Create() - virtual SIGNAL::Signal *Create(const std::string &rLogLine, - INSTRUMENT::Instrument::LineNumberT lineNumber, - SIGNAL::SourceRegistry::HandleT sourceHandle) const; + virtual const SIGNAL::Signal *Create(const std::string &rLogLine, + INSTRUMENT::Instrument::LineNumberT lineNumber, + const std::string &rPrefix, + SIGNAL::SourceRegistry::HandleT sourceHandle) const; }; } diff --git a/sources/common/inc/LineCounter.h b/sources/common/inc/LineCounter.h index 5efc03a..3a5c163 100644 --- a/sources/common/inc/LineCounter.h +++ b/sources/common/inc/LineCounter.h @@ -8,7 +8,7 @@ /// /// @ingroup Instrument /// -/// @par Copyright (c) 2017 vcdMaker team +/// @par Copyright (c) 2020 vcdMaker team /// /// Permission is hereby granted, free of charge, to any person obtaining a /// copy of this software and associated documentation files (the "Software"), @@ -33,6 +33,7 @@ #include #include "Instrument.h" +#include "SignalDescriptorRegistry.h" namespace INSTRUMENT { @@ -48,10 +49,12 @@ namespace INSTRUMENT /// @param rFilename The name of the file associated with the counter. /// @param rCounterName The counter signal name. /// @param rSourceRegistry Signal sources registry. + /// @param rSignalDescriptorRegistry The registry of unique signal descriptors. /// @param rSignalDb The signal database to be used. LineCounter(const std::string &rFilename, const std::string &rCounterName, SIGNAL::SourceRegistry &rSourceRegistry, + SIGNAL::SignalDescriptorRegistry &rSignalDescriptorRegistry, SIGNAL::SignalDb &rSignalDb); /// @copydoc Instrument::Notify() @@ -103,6 +106,9 @@ namespace INSTRUMENT /// The name of the counter signal high boundary. const std::string m_CounterNameHigh{}; + /// The signal descriptor registry. + SIGNAL::SignalDescriptorRegistry &m_rSignalDescriptorRegistry; + /// The counter storage. CounterSignalT m_Counter{}; }; diff --git a/sources/common/inc/LogParser.h b/sources/common/inc/LogParser.h index 9332ec2..835598a 100644 --- a/sources/common/inc/LogParser.h +++ b/sources/common/inc/LogParser.h @@ -7,7 +7,7 @@ /// /// @ingroup Parser /// -/// @par Copyright (c) 2017 vcdMaker team +/// @par Copyright (c) 2020 vcdMaker team /// /// Permission is hereby granted, free of charge, to any person obtaining a /// copy of this software and associated documentation files (the "Software"), @@ -58,13 +58,7 @@ namespace PARSER /// Returns the non-const reference to the signal database. SIGNAL::SignalDb &GetSignalDb() { - return *(m_pSignalDb.get()); - } - - /// Moves ownership of signal database somewhere else. - std::unique_ptr MoveSignalDb() - { - return std::move(m_pSignalDb); + return *(m_rSignalDb.get()); } /// Invokes the parser. @@ -86,12 +80,12 @@ namespace PARSER /// It opens the input log file and sets the verbose mode. /// /// @throws VcdError if the file cannot be open. - /// @param rFilename The name of the log file to be open. - /// @param rTimeBase The time base used in the log. - /// @param verboseMode Value 'true' enables the verbose mode. + /// @param rFilename The log file name. + /// @param rSignalDb The signal databse. The container for parsed signals. /// @param rSourceRegistry Signal sources registry. + /// @param verboseMode Value 'true' enables the verbose mode. LogParser(const std::string &rFilename, - const std::string &rTimeBase, + std::unique_ptr &rSignalDb, SIGNAL::SourceRegistry &rSourceRegistry, bool verboseMode); @@ -102,7 +96,7 @@ namespace PARSER virtual void Parse() = 0; /// The signal database. - std::unique_ptr m_pSignalDb; + std::unique_ptr &m_rSignalDb; /// Instruments. std::vector m_vpInstruments; diff --git a/sources/common/inc/OutOfMemory.h b/sources/common/inc/OutOfMemory.h new file mode 100644 index 0000000..0093d7a --- /dev/null +++ b/sources/common/inc/OutOfMemory.h @@ -0,0 +1,40 @@ +/// @file common/inc/OutOfMemory.h +/// +/// The common out of memory handler. +/// +/// @par Full Description +/// The common out of memory handler to be used by vcdMaker and vcdMerge. +/// +/// @ingroup Exception +/// +/// @par Copyright (c) 2019 vcdMaker team +/// +/// 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. + +#pragma once + +#include "VcdException.h" + +/// Out of memory handler. +/// +/// @throws EXCEPTION::VcdException. +inline void OutOfMemory() +{ + throw EXCEPTION::VcdException(EXCEPTION::Error::OUT_OF_MEMORY, "Out of memory."); +} diff --git a/sources/common/inc/Signal.h b/sources/common/inc/Signal.h index e2673cc..57f24e7 100644 --- a/sources/common/inc/Signal.h +++ b/sources/common/inc/Signal.h @@ -8,7 +8,7 @@ /// /// @ingroup Signal /// -/// @par Copyright (c) 2018 vcdMaker team +/// @par Copyright (c) 2020 vcdMaker team /// /// Permission is hereby granted, free of charge, to any person obtaining a /// copy of this software and associated documentation files (the "Software"), @@ -41,7 +41,9 @@ #include #include #include +#include +#include "SignalDescriptor.h" #include "SourceRegistry.h" #include "Timestamp.h" @@ -62,29 +64,14 @@ namespace SIGNAL /// The signal constructor. /// - /// This constructor shall be used by the iheriting classes. - /// It initializes the basic signal properties: the name, the size - /// and the type. + /// It sets common signal properties: its descriptor and the timestamp. /// - /// The name shall consist of any alphanumeric string in which the module's - /// levels are separated with '.'. - /// E.g. Module1.Level3.Variable6 - /// - /// The size usually corresponds to any of the integral data type - /// sizes: 8, 16, 32 or 64. - /// - /// The type string is used to produce the VCD header. It describes - /// the type of the signal and shall equal to "wire" or "real". - Signal(const std::string &name, - size_t size, - const TIME::Timestamp &rTimestamp, - const std::string &type, - SourceRegistry::HandleT sourceHandle) : - m_Name(name), - m_Type(type), - m_Size(size), + /// @param rSignalDesc Signal descriptor. + /// @param rTimestamp Signal timestamp. + Signal(const std::shared_ptr &rSignalDesc, + const TIME::Timestamp &rTimestamp) : m_Timestamp(rTimestamp), - m_SourceHandle(sourceHandle) + m_pSignalDesc(rSignalDesc) { } @@ -105,15 +92,7 @@ namespace SIGNAL /// of the VCD file. const std::string &GetName() const { - return m_Name; - } - - /// Sets the new signal's name. - /// - /// @param name The new signal's name. - void SetName(const std::string &name) - { - m_Name = name; + return m_pSignalDesc->GetName(); } /// Returns signal name splited into fields. @@ -127,7 +106,7 @@ namespace SIGNAL /// The method is used while generating the VCD header. size_t GetSize() const { - return m_Size; + return m_pSignalDesc->GetSize(); } /// Returns the signal's timestamp in time units. @@ -151,13 +130,13 @@ namespace SIGNAL /// The method is used while generating the VCD header. const std::string &GetType() const { - return m_Type; + return m_pSignalDesc->GetType(); } /// Returns the source handle of the signal. SourceRegistry::HandleT GetSource() const { - return m_SourceHandle; + return m_pSignalDesc->GetSource(); } /// Checks if two signals are similar (differ by value only) @@ -185,22 +164,9 @@ namespace SIGNAL /// determine its change. virtual bool EqualTo(Signal const &other) const = 0; - /// The signal's name. - std::string m_Name {}; - - /// The signal's type. - const std::string m_Type {}; - - /// The signal's size. - const size_t m_Size = 0; - /// The signal's timestamp. TIME::Timestamp m_Timestamp; - /// The signal's source. - const SourceRegistry::HandleT m_SourceHandle = - SIGNAL::SourceRegistry::BAD_HANDLE; - private: /// The overloaded == operator. @@ -219,6 +185,8 @@ namespace SIGNAL return !lsignal.EqualTo(rsignal); } + /// Signal's description. + std::shared_ptr m_pSignalDesc; }; /// Comparator for multiset. diff --git a/sources/common/inc/SignalCreator.h b/sources/common/inc/SignalCreator.h index 75c8659..4626f6b 100644 --- a/sources/common/inc/SignalCreator.h +++ b/sources/common/inc/SignalCreator.h @@ -8,7 +8,7 @@ /// /// @ingroup Parser /// -/// @par Copyright (c) 2018 vcdMaker team +/// @par Copyright (c) 2020 vcdMaker team /// /// Permission is hereby granted, free of charge, to any person obtaining a /// copy of this software and associated documentation files (the "Software"), @@ -33,6 +33,7 @@ #include #include "Signal.h" +#include "SignalDescriptorRegistry.h" #include "Instrument.h" namespace PARSER @@ -48,10 +49,14 @@ namespace PARSER /// /// The constructor initializes the regular expression member variable /// which will be matched against the log line. - /// @param rSignalRegEx The regular expression to be matech against the log line. - SignalCreator(const std::string &rSignalRegEx) : + /// + /// @param rDescriptorRegistry The reference to the signal descriptors registry. + /// @param rSignalRegEx The regular expression to be match against the log line. + SignalCreator(SIGNAL::SignalDescriptorRegistry &rDescriptorRegistry, + const std::string &rSignalRegEx) : m_SignalRegEx("^" + rSignalRegEx + "\r?$"), - m_RegEx(rSignalRegEx) + m_RegEx(rSignalRegEx), + m_rSignalDescriptorRegistry(rDescriptorRegistry) { } @@ -68,10 +73,12 @@ namespace PARSER /// @param rLogLine The log line serving as the creation specification. /// @param lineNumber The log line number. /// @param sourceHandle Signal source handle. + /// @param rPrefix Signal prefix. /// @return Signal pointer if the object has been created or nullptr. - virtual SIGNAL::Signal *Create(const std::string &rLogLine, - INSTRUMENT::Instrument::LineNumberT lineNumber, - SIGNAL::SourceRegistry::HandleT sourceHandle) const = 0; + virtual const SIGNAL::Signal *Create(const std::string &rLogLine, + INSTRUMENT::Instrument::LineNumberT lineNumber, + const std::string &rPrefix, + SIGNAL::SourceRegistry::HandleT sourceHandle) const = 0; /// Returns the regex. const std::string &GetRegEx() const @@ -86,6 +93,9 @@ namespace PARSER /// The original RegEx string. const std::string m_RegEx; + + /// The signal descriptors registry. + SIGNAL::SignalDescriptorRegistry &m_rSignalDescriptorRegistry; }; inline SignalCreator::~SignalCreator() = default; diff --git a/sources/common/inc/SignalDb.h b/sources/common/inc/SignalDb.h index bd2baf4..1f24ac1 100644 --- a/sources/common/inc/SignalDb.h +++ b/sources/common/inc/SignalDb.h @@ -8,7 +8,7 @@ /// /// @ingroup Signal /// -/// @par Copyright (c) 2017 vcdMaker team +/// @par Copyright (c) 2020 vcdMaker team /// /// Permission is hereby granted, free of charge, to any person obtaining a /// copy of this software and associated documentation files (the "Software"), @@ -43,7 +43,8 @@ namespace SIGNAL /// The SignalDb constructor. /// /// @param rTimeUnit The time unit in which logged signals are timestamped. - SignalDb(const std::string &rTimeUnit); + /// @param rPrefix The collection specific prefix. + SignalDb(const std::string &rTimeUnit, const std::string &rPrefix = ""); /// The destructor. ~SignalDb(); @@ -77,10 +78,19 @@ namespace SIGNAL return m_TimeUnit; } + /// Returns the database prefix. + std::string GetPrefix() const + { + return m_Prefix; + } + private: /// The VCD time unit in which the signals are timestamped. const std::string m_TimeUnit; + /// The collection specifix prefix. + const std::string m_Prefix; + /// The unique signals collection. SIGNAL::UniqueSignalsCollectionT m_AddedSignals; diff --git a/sources/common/inc/SignalDescriptor.h b/sources/common/inc/SignalDescriptor.h new file mode 100644 index 0000000..010267d --- /dev/null +++ b/sources/common/inc/SignalDescriptor.h @@ -0,0 +1,132 @@ +/// @file common/inc/SignalDescriptor.h +/// +/// The signal descriptor. +/// +/// @par Full Description +/// The signal descriptor defines a signal's constant properties such as +/// name, size, type and source. +/// +/// @ingroup Signal +/// +/// @par Copyright (c) 2020 vcdMaker team +/// +/// 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. + +#pragma once + +#include + +#include "SourceRegistry.h" + +namespace SIGNAL +{ + /// A signal descriptor class. + /// The class collects constant signal properties such as its name, size, + /// type and the source. + class SignalDescriptor + { + public: + /// The signal descriptor constructor. + /// + /// It initializes the constant signal properties: the name, the size + /// the type and its source handle. + /// + /// The name shall consist of any alphanumeric string in which the module's + /// levels are separated with '.'. + /// E.g. Module1.Level3.Variable6 + /// + /// The size usually corresponds to any of the integral data type + /// sizes: 8, 16, 32 or 64. + /// + /// The type string is used to produce the VCD header. It describes + /// the type of the signal and shall equal to "wire" or "real". + /// + /// The source handle identifies the origin of the source. + /// + /// @param rName Signal name. + /// @param size Signal size. + /// @param rType Signal type. + /// @param sourceHandle Signal source handle. + SignalDescriptor(const std::string &rName, + size_t size, + const std::string &rType, + SourceRegistry::HandleT sourceHandle) : + m_Name(rName), + m_Type(rType), + m_Size(size), + m_SourceHandle(sourceHandle) + { + } + + /// Returns the signal's name. + const std::string &GetName() const; + + /// Returns the signal's size in bits. + size_t GetSize() const; + + /// Returns the signal's type. + const std::string &GetType() const; + + /// Returns the source handle of the signal. + SourceRegistry::HandleT GetSource() const; + + /// Check signal consistency. + /// + /// To be invoked for the signals having the same name. It verifies the consistency of other + /// signal properties. + /// @param rType Signal type. + /// @param size Signal size. + /// @param sourceHandle Signal source. + bool SimilarTo(const std::string &rType, size_t size, SourceRegistry::HandleT sourceHandle) const; + + private: + + /// The signal's name. + const std::string m_Name {}; + + /// The signal's type. + const std::string m_Type {}; + + /// The signal's size. + const size_t m_Size = 0; + + /// The signal's source. + const SourceRegistry::HandleT m_SourceHandle = + SIGNAL::SourceRegistry::BAD_HANDLE; + + /// Checks if two descriptors match. + bool EqualTo(SignalDescriptor const &other) const; + + /// The overloaded == operator. + /// + /// Checks if two signal descriptors are equal. EqualTo is used. + friend bool operator == (const SignalDescriptor &lSignalDesc, const SignalDescriptor &rSignalDesc) + { + return lSignalDesc.EqualTo(rSignalDesc); + } + + /// The overloaded != operator. + /// + /// Checks if two signal descriptors are not equal. EqualTo is used. + friend bool operator != (const SignalDescriptor &lSignalDesc, const SignalDescriptor &rSignalDesc) + { + return !lSignalDesc.EqualTo(rSignalDesc); + } + }; +} diff --git a/sources/common/inc/SignalDescriptorRegistry.h b/sources/common/inc/SignalDescriptorRegistry.h new file mode 100644 index 0000000..b03d0a4 --- /dev/null +++ b/sources/common/inc/SignalDescriptorRegistry.h @@ -0,0 +1,72 @@ +/// @file common/inc/SignalDescriptorRegistry.h +/// +/// The signal descriptor registry. +/// +/// @par Full Description +/// The signal descriptor registry. It is supposed to create unique signal +/// descriptors and maintain its collection during the whole application lifetime. +/// +/// @ingroup Signal +/// +/// @par Copyright (c) 2020 vcdMaker team +/// +/// 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. + +#pragma once + +#include + +#include "SignalDescriptor.h" + +namespace SIGNAL +{ + /// A signal descriptor database class. + /// The database keep a record of unique signal descriptors. + class SignalDescriptorRegistry + { + public: + /// The signal descriptor databse constructor. + /// + /// Initializes the database. + /// + SignalDescriptorRegistry() : m_SignalDescriptors() + { + } + + /// The default destructor. + ~SignalDescriptorRegistry() = default; + + /// Creates the descriptor and adds it to the database. + /// + /// @param rName Signal name. + /// @param rType Signal type. + /// @param size Signal size. + /// @param sourceHandle Signal source. + /// @return The created signal descriptor. + const std::shared_ptr Register(const std::string &rName, + const std::string &rType, + size_t size, + SourceRegistry::HandleT sourceHandle); + + private: + + /// The set of pointers to signal descriptors indexed by names. + std::map> m_SignalDescriptors{}; + }; +} diff --git a/sources/common/inc/SignalFactory.h b/sources/common/inc/SignalFactory.h index 625e030..cf2fc57 100644 --- a/sources/common/inc/SignalFactory.h +++ b/sources/common/inc/SignalFactory.h @@ -7,7 +7,7 @@ /// /// @ingroup Parser /// -/// @par Copyright (c) 2018 vcdMaker team +/// @par Copyright (c) 2020 vcdMaker team /// /// Permission is hereby granted, free of charge, to any person obtaining a /// copy of this software and associated documentation files (the "Software"), @@ -43,7 +43,7 @@ namespace PARSER { public: - /// The signal factory default constructor. + /// The signal factory constructor. SignalFactory(); /// Creates the appropriate signal objects. @@ -51,11 +51,13 @@ namespace PARSER /// Returns the pointer to the list of created signal objects. /// If emtpy no signal could be created. /// - /// @param logLine One line from the log. + /// @param rLogLine One line from the log. /// @param lineNumber The log line number. + /// @param rPrefix Signal prefix. /// @param sourceHandle Signal source handle. - std::vector Create(std::string &logLine, + std::vector Create(const std::string &rLogLine, INSTRUMENT::Instrument::LineNumberT lineNumber, + const std::string &rPrefix, SIGNAL::SourceRegistry::HandleT sourceHandle) const; protected: @@ -63,6 +65,9 @@ namespace PARSER /// The table of pointers to signal creators. std::vector> m_vpSignalCreators; + /// Factory specific signal prefix. + const std::string m_Prefix; + private: /// Returns log line details. diff --git a/sources/common/inc/TxtParser.h b/sources/common/inc/TxtParser.h index 6f21d87..3762110 100644 --- a/sources/common/inc/TxtParser.h +++ b/sources/common/inc/TxtParser.h @@ -7,7 +7,7 @@ /// /// @ingroup Parser /// -/// @par Copyright (c) 2017 vcdMaker team +/// @par Copyright (c) 2020 vcdMaker team /// /// Permission is hereby granted, free of charge, to any person obtaining a /// copy of this software and associated documentation files (the "Software"), @@ -46,12 +46,12 @@ namespace PARSER /// It opens the input log file, sets the timebase and the verbose mode. /// /// @param rFilename The name of the log file to be open. - /// @param rTimeBase The time base used in the log. + /// @param rSignalDb The signal databse. The container for parsed signals. /// @param rSourceRegistry Signal sources registry. /// @param rSignalFactory The signal factory. /// @param verboseMode Value 'true' enables the verbose mode. TxtParser(const std::string &rFilename, - const std::string &rTimeBase, + std::unique_ptr &rSignalDb, SIGNAL::SourceRegistry &rSourceRegistry, const SignalFactory &rSignalFactory, bool verboseMode); diff --git a/sources/common/inc/VcdExceptionList.h b/sources/common/inc/VcdExceptionList.h index 67b1fe9..5d398c7 100644 --- a/sources/common/inc/VcdExceptionList.h +++ b/sources/common/inc/VcdExceptionList.h @@ -8,7 +8,7 @@ /// /// @ingroup Exception /// -/// @par Copyright (c) 2018 vcdMaker team +/// @par Copyright (c) 2020 vcdMaker team /// /// Permission is hereby granted, free of charge, to any person obtaining a /// copy of this software and associated documentation files (the "Software"), @@ -120,6 +120,9 @@ namespace EXCEPTION /// Vector size exceeded. const uint32_t VECTOR_SIZE_EXCEEDED = 21U; + /// Out of memory. + const uint32_t OUT_OF_MEMORY = 22U; + // Logic errors below shall never happen. // They are enumerated from 9000. @@ -137,5 +140,8 @@ namespace EXCEPTION /// Time unit index out of bounds. const uint32_t TIME_UNIT_INDEX_OUT_OF_BOUNDS = 9004U; + + /// Empty validation list. + const uint32_t EMPTY_VALIDATION_LIST = 9005U; } } diff --git a/sources/common/inc/Version.h b/sources/common/inc/Version.h index bb64eb7..4628355 100644 --- a/sources/common/inc/Version.h +++ b/sources/common/inc/Version.h @@ -5,7 +5,7 @@ /// @par Full Description /// Version information header. /// -/// @par Copyright (c) 2017 vcdMaker team +/// @par Copyright (c) 2018 vcdMaker team /// /// Permission is hereby granted, free of charge, to any person obtaining a /// copy of this software and associated documentation files (the "Software"), @@ -32,7 +32,7 @@ /// @{ #define D_VERSION_MAJOR 3 #define D_VERSION_MINOR 0 -#define D_VERSION_PATCH 1 +#define D_VERSION_PATCH 2 #define D_RELEASE_NAME "Nestor" /// @} @@ -47,20 +47,21 @@ XSTR(D_VERSION_MAJOR) "." XSTR(D_VERSION_MINOR) "." XSTR(D_VERSION_PATCH) /// Version information namespace. -namespace VERSION { +namespace VERSION +{ -/// Application version components. -/// @{ -constexpr int MAJOR = D_VERSION_MAJOR; -constexpr int MINOR = D_VERSION_MINOR; -constexpr int PATCH = D_VERSION_PATCH; -/// @} + /// Application version components. + /// @{ + constexpr int MAJOR = D_VERSION_MAJOR; + constexpr int MINOR = D_VERSION_MINOR; + constexpr int PATCH = D_VERSION_PATCH; + /// @} -/// Application version string. -constexpr const char *STRING = MAKE_VERSION_STR; + /// Application version string. + constexpr const char *STRING = MAKE_VERSION_STR; -/// Application release name. -constexpr const char *RELEASE_NAME = D_RELEASE_NAME; + /// Application release name. + constexpr const char *RELEASE_NAME = D_RELEASE_NAME; } diff --git a/sources/common/inc/XmlEventSignalCreator.h b/sources/common/inc/XmlEventSignalCreator.h index 21fc3cb..b951e49 100644 --- a/sources/common/inc/XmlEventSignalCreator.h +++ b/sources/common/inc/XmlEventSignalCreator.h @@ -4,7 +4,7 @@ /// /// @ingroup Parser /// -/// @par Copyright (c) 2018 vcdMaker team +/// @par Copyright (c) 2020 vcdMaker team /// /// Permission is hereby granted, free of charge, to any person obtaining a /// copy of this software and associated documentation files (the "Software"), @@ -38,19 +38,22 @@ namespace PARSER /// The XML event signal creator constructor. /// + /// @param rSignalDescriptorRegistry The signal descriptors registry. /// @param rRegEx The regular expression matching the log line. /// @param rTimestamp The expression to create the timestamp of the signal. /// @param rName The expression to create the name of the signal. - XmlEventSignalCreator(const std::string &rRegEx, + XmlEventSignalCreator(SIGNAL::SignalDescriptorRegistry &rSignalDescriptorRegistry, + const std::string &rRegEx, const std::string &rTimestamp, const std::string &rName) : - XmlSignalCreator(rRegEx, rTimestamp, rName, "", "") + XmlSignalCreator(rSignalDescriptorRegistry, rRegEx, rTimestamp, rName, "", "") { } /// @copydoc SignalCreator::Create() virtual SIGNAL::Signal *Create(const std::string &rLogLine, INSTRUMENT::Instrument::LineNumberT lineNumber, + const std::string &rPrefix, SIGNAL::SourceRegistry::HandleT sourceHandle) const; }; diff --git a/sources/common/inc/XmlFSignalCreator.h b/sources/common/inc/XmlFSignalCreator.h index c2fcd45..39398f5 100644 --- a/sources/common/inc/XmlFSignalCreator.h +++ b/sources/common/inc/XmlFSignalCreator.h @@ -4,7 +4,7 @@ /// /// @ingroup Parser /// -/// @par Copyright (c) 2018 vcdMaker team +/// @par Copyright (c) 2020 vcdMaker team /// /// Permission is hereby granted, free of charge, to any person obtaining a /// copy of this software and associated documentation files (the "Software"), @@ -40,15 +40,17 @@ namespace PARSER /// The XML real signal creator constructor. /// + /// @param rSignalDescriptorRegistry The signal descriptors registry. /// @param rRegEx The regular expression matching the log line. /// @param rTimestamp The expression to create the timestamp of the signal. /// @param rName The expression to create the name of the signal. /// @param rValue The expression to create the value of the signal. - XmlFSignalCreator(const std::string &rRegEx, + XmlFSignalCreator(SIGNAL::SignalDescriptorRegistry &rSignalDescriptorRegistry, + const std::string &rRegEx, const std::string &rTimestamp, const std::string &rName, const std::string &rValue) : - XmlSignalCreator(rRegEx, rTimestamp, rName, rValue, "") + XmlSignalCreator(rSignalDescriptorRegistry, rRegEx, rTimestamp, rName, rValue, "") { m_FloatEvaluator.ParseFloatString(rValue); } @@ -56,6 +58,7 @@ namespace PARSER /// @copydoc SignalCreator::Create() virtual SIGNAL::Signal *Create(const std::string &rLogLine, INSTRUMENT::Instrument::LineNumberT lineNumber, + const std::string &rPrefix, SIGNAL::SourceRegistry::HandleT sourceHandle) const; }; diff --git a/sources/common/inc/XmlISignalCreator.h b/sources/common/inc/XmlISignalCreator.h index 9d1b776..102f05e 100644 --- a/sources/common/inc/XmlISignalCreator.h +++ b/sources/common/inc/XmlISignalCreator.h @@ -4,7 +4,7 @@ /// /// @ingroup Parser /// -/// @par Copyright (c) 2018 vcdMaker team +/// @par Copyright (c) 2020 vcdMaker team /// /// Permission is hereby granted, free of charge, to any person obtaining a /// copy of this software and associated documentation files (the "Software"), @@ -37,12 +37,13 @@ namespace PARSER { public: /// @copydoc XmlSignalCreator::XmlSignalCreator() - XmlISignalCreator(const std::string &rRegEx, + XmlISignalCreator(SIGNAL::SignalDescriptorRegistry &rSignalDescriptorRegistry, + const std::string &rRegEx, const std::string &rTimestamp, const std::string &rName, const std::string &rValue, const std::string &rSize) : - XmlSignalCreator(rRegEx, rTimestamp, rName, rValue, rSize) + XmlSignalCreator(rSignalDescriptorRegistry, rRegEx, rTimestamp, rName, rValue, rSize) { m_DecimalEvaluator.ParseDecimalString(rValue); m_SizeEvaluator.ParseDecimalString(rSize); @@ -51,6 +52,7 @@ namespace PARSER /// @copydoc SignalCreator::Create() virtual SIGNAL::Signal *Create(const std::string &rLogLine, INSTRUMENT::Instrument::LineNumberT lineNumber, + const std::string &rPrefix, SIGNAL::SourceRegistry::HandleT sourceHandle) const; }; diff --git a/sources/common/inc/XmlSignalCreator.h b/sources/common/inc/XmlSignalCreator.h index 58aaae2..cd076fd 100644 --- a/sources/common/inc/XmlSignalCreator.h +++ b/sources/common/inc/XmlSignalCreator.h @@ -4,7 +4,7 @@ /// /// @ingroup Parser /// -/// @par Copyright (c) 2018 vcdMaker team +/// @par Copyright (c) 2020 vcdMaker team /// /// Permission is hereby granted, free of charge, to any person obtaining a /// copy of this software and associated documentation files (the "Software"), @@ -41,17 +41,19 @@ namespace PARSER public: /// The XML signal creator constructor. /// + /// @param rSignalDescriptorRegistry The signal descriptors registry. /// @param rRegEx The regular expression matching the log line. /// @param rTimestamp The expression to create the timestamp of the signal. /// @param rName The expression to create the name of the signal. /// @param rValue The expression to create the value of the signal. /// @param rSize The expression to create the size of the signal. - XmlSignalCreator(const std::string &rRegEx, + XmlSignalCreator(SIGNAL::SignalDescriptorRegistry &rSignalDescriptorRegistry, + const std::string &rRegEx, const std::string &rTimestamp, const std::string &rName, const std::string &rValue, const std::string &rSize): - SignalCreator(rRegEx), + SignalCreator(rSignalDescriptorRegistry, rRegEx), m_Timestamp(rTimestamp), m_Name(rName), m_Value(rValue), diff --git a/sources/common/inc/XmlSignalFactory.h b/sources/common/inc/XmlSignalFactory.h index fb4d407..3d663dc 100644 --- a/sources/common/inc/XmlSignalFactory.h +++ b/sources/common/inc/XmlSignalFactory.h @@ -8,7 +8,7 @@ /// /// @ingroup Parser /// -/// @par Copyright (c) 2017 vcdMaker team +/// @par Copyright (c) 2020 vcdMaker team /// /// Permission is hereby granted, free of charge, to any person obtaining a /// copy of this software and associated documentation files (the "Software"), @@ -91,9 +91,11 @@ namespace PARSER { public: - /// The XML signal factory default constructor. + /// The XML signal factory constructor. /// + /// @param rSignalDescriptorRegistry The signal descriptors registry. /// @param rXmlFileName The name of the XML file specifying the user log syntax. - XmlSignalFactory(const std::string &rXmlFileName); + XmlSignalFactory(SIGNAL::SignalDescriptorRegistry &rSignalDescriptorRegistry, + const std::string &rXmlFileName); }; } diff --git a/sources/common/src/DefaultSignalFactory.cpp b/sources/common/src/DefaultSignalFactory.cpp index 3dfe2b2..07a9e7f 100644 --- a/sources/common/src/DefaultSignalFactory.cpp +++ b/sources/common/src/DefaultSignalFactory.cpp @@ -7,7 +7,7 @@ /// /// @ingroup Parser /// -/// @par Copyright (c) 2018 vcdMaker team +/// @par Copyright (c) 2020 vcdMaker team /// /// Permission is hereby granted, free of charge, to any person obtaining a /// copy of this software and associated documentation files (the "Software"), @@ -33,14 +33,14 @@ #include "ISignalCreator.h" #include "VcdException.h" -PARSER::DefaultSignalFactory::DefaultSignalFactory() : +PARSER::DefaultSignalFactory::DefaultSignalFactory(SIGNAL::SignalDescriptorRegistry &rSignalDescriptorRegistry) : SignalFactory() { try { - m_vpSignalCreators.push_back(std::make_unique()); - m_vpSignalCreators.push_back(std::make_unique()); - m_vpSignalCreators.push_back(std::make_unique()); + m_vpSignalCreators.push_back(std::make_unique(rSignalDescriptorRegistry)); + m_vpSignalCreators.push_back(std::make_unique(rSignalDescriptorRegistry)); + m_vpSignalCreators.push_back(std::make_unique(rSignalDescriptorRegistry)); } catch (const std::regex_error &) { diff --git a/sources/common/src/EventSignalCreator.cpp b/sources/common/src/EventSignalCreator.cpp index 5f37f4d..e4fad0e 100644 --- a/sources/common/src/EventSignalCreator.cpp +++ b/sources/common/src/EventSignalCreator.cpp @@ -4,7 +4,7 @@ /// /// @ingroup Parser /// -/// @par Copyright (c) 2018 vcdMaker team +/// @par Copyright (c) 2020 vcdMaker team /// /// Permission is hereby granted, free of charge, to any person obtaining a /// copy of this software and associated documentation files (the "Software"), @@ -27,18 +27,21 @@ #include "EventSignalCreator.h" #include "EventSignal.h" -SIGNAL::Signal *PARSER::EventSignalCreator::Create(const std::string &rLogLine, - INSTRUMENT::Instrument::LineNumberT lineNumber, - SIGNAL::SourceRegistry::HandleT sourceHandle) const +const SIGNAL::Signal *PARSER::EventSignalCreator::Create(const std::string &rLogLine, + INSTRUMENT::Instrument::LineNumberT lineNumber, + const std::string &rPrefix, + SIGNAL::SourceRegistry::HandleT sourceHandle) const { std::smatch result; (void)lineNumber; if (true == std::regex_search(rLogLine, result, m_SignalRegEx)) { - return new SIGNAL::EventSignal(result[2].str(), - std::stoll(result[1].str()), - sourceHandle); + return new SIGNAL::EventSignal(m_rSignalDescriptorRegistry.Register(rPrefix + result[2].str(), + "event", + 0, + sourceHandle), + std::stoll(result[1].str())); } else { diff --git a/sources/common/src/FSignal.cpp b/sources/common/src/FSignal.cpp index 1f97795..675284d 100644 --- a/sources/common/src/FSignal.cpp +++ b/sources/common/src/FSignal.cpp @@ -8,7 +8,7 @@ /// /// @ingroup Signal /// -/// @par Copyright (c) 2016 vcdMaker team +/// @par Copyright (c) 2020 vcdMaker team /// /// Permission is hereby granted, free of charge, to any person obtaining a /// copy of this software and associated documentation files (the "Software"), @@ -34,7 +34,7 @@ std::string SIGNAL::FSignal::Print() const { - return ('r' + m_Value + ' ' + m_Name); + return ('r' + m_Value + ' ' + GetName()); } bool SIGNAL::FSignal::EqualTo(Signal const &other) const diff --git a/sources/common/src/FSignalCreator.cpp b/sources/common/src/FSignalCreator.cpp index cd00df7..db6072d 100644 --- a/sources/common/src/FSignalCreator.cpp +++ b/sources/common/src/FSignalCreator.cpp @@ -4,7 +4,7 @@ /// /// @ingroup Parser /// -/// @par Copyright (c) 2018 vcdMaker team +/// @par Copyright (c) 2020 vcdMaker team /// /// Permission is hereby granted, free of charge, to any person obtaining a /// copy of this software and associated documentation files (the "Software"), @@ -27,19 +27,22 @@ #include "FSignalCreator.h" #include "FSignal.h" -SIGNAL::Signal *PARSER::FSignalCreator::Create(const std::string &rLogLine, - INSTRUMENT::Instrument::LineNumberT lineNumber, - SIGNAL::SourceRegistry::HandleT sourceHandle) const +const SIGNAL::Signal *PARSER::FSignalCreator::Create(const std::string &rLogLine, + INSTRUMENT::Instrument::LineNumberT lineNumber, + const std::string &rPrefix, + SIGNAL::SourceRegistry::HandleT sourceHandle) const { std::smatch result; (void)lineNumber; if (true == std::regex_search(rLogLine, result, m_SignalRegEx)) { - return new SIGNAL::FSignal(result[2].str(), + return new SIGNAL::FSignal(m_rSignalDescriptorRegistry.Register(rPrefix + result[2].str(), + "real", + 64, + sourceHandle), std::stoll(result[1].str()), - result[3].str(), - sourceHandle); + result[3].str()); } else { diff --git a/sources/common/src/ISignal.cpp b/sources/common/src/ISignal.cpp index 89d4b49..b243f3f 100644 --- a/sources/common/src/ISignal.cpp +++ b/sources/common/src/ISignal.cpp @@ -8,7 +8,7 @@ /// /// @ingroup Signal /// -/// @par Copyright (c) 2016 vcdMaker team +/// @par Copyright (c) 2020 vcdMaker team /// /// Permission is hereby granted, free of charge, to any person obtaining a /// copy of this software and associated documentation files (the "Software"), @@ -32,14 +32,14 @@ #include "ISignal.h" -SIGNAL::ISignal::ISignal(const std::string &name, - size_t size, +SIGNAL::ISignal::ISignal(const std::shared_ptr &rSignalDescriptor, const TIME::Timestamp &rTimestamp, - uint64_t value, - SourceRegistry::HandleT sourceHandle) : - Signal(name, size, rTimestamp, "wire", sourceHandle), + uint64_t value) : + Signal(rSignalDescriptor, rTimestamp), m_Value(value) { + size_t size = rSignalDescriptor->GetSize(); + if (size > 64) { throw EXCEPTION::VcdException(EXCEPTION::Error::VECTOR_SIZE_EXCEEDED, @@ -57,15 +57,15 @@ std::string SIGNAL::ISignal::Print() const { const std::bitset<64> valueBits(m_Value); const std::string valueBitStr = - valueBits.to_string().substr(valueBits.size() - m_Size); + valueBits.to_string().substr(valueBits.size() - GetSize()); - return ('b' + valueBitStr + ' ' + m_Name); + return ('b' + valueBitStr + ' ' + GetName()); } std::string SIGNAL::ISignal::Footprint() const { - const std::string sizeFootprint(m_Size, 'x'); - return ('b' + sizeFootprint + ' ' + m_Name); + const std::string sizeFootprint(GetSize(), 'x'); + return ('b' + sizeFootprint + ' ' + GetName()); } bool SIGNAL::ISignal::EqualTo(Signal const &other) const diff --git a/sources/common/src/ISignalCreator.cpp b/sources/common/src/ISignalCreator.cpp index 0f4bb86..633b9a5 100644 --- a/sources/common/src/ISignalCreator.cpp +++ b/sources/common/src/ISignalCreator.cpp @@ -4,7 +4,7 @@ /// /// @ingroup Parser /// -/// @par Copyright (c) 2018 vcdMaker team +/// @par Copyright (c) 2020 vcdMaker team /// /// Permission is hereby granted, free of charge, to any person obtaining a /// copy of this software and associated documentation files (the "Software"), @@ -27,20 +27,23 @@ #include "ISignalCreator.h" #include "ISignal.h" -SIGNAL::Signal *PARSER::ISignalCreator::Create(const std::string &rLogLine, - INSTRUMENT::Instrument::LineNumberT lineNumber, - SIGNAL::SourceRegistry::HandleT sourceHandle) const +const SIGNAL::Signal *PARSER::ISignalCreator::Create(const std::string &rLogLine, + INSTRUMENT::Instrument::LineNumberT lineNumber, + const std::string &rPrefix, + SIGNAL::SourceRegistry::HandleT sourceHandle) const { std::smatch result; (void)lineNumber; if (true == std::regex_search(rLogLine, result, m_SignalRegEx)) { - return new SIGNAL::ISignal(result[2].str(), - std::stoi(result[4].str()), + return new SIGNAL::ISignal(m_rSignalDescriptorRegistry.Register(rPrefix + result[2].str(), + "wire", + std::stoi(result[4].str()), + sourceHandle), std::stoll(result[1].str()), - std::stoll(result[3].str()), - sourceHandle); + std::stoll(result[3].str())); + } else { diff --git a/sources/common/src/LineCounter.cpp b/sources/common/src/LineCounter.cpp index e5d001c..99f1b5f 100644 --- a/sources/common/src/LineCounter.cpp +++ b/sources/common/src/LineCounter.cpp @@ -8,7 +8,7 @@ /// /// @ingroup Instrument /// -/// @par Copyright (c) 2017 vcdMaker team +/// @par Copyright (c) 2020 vcdMaker team /// /// Permission is hereby granted, free of charge, to any person obtaining a /// copy of this software and associated documentation files (the "Software"), @@ -39,8 +39,10 @@ const std::string INSTRUMENT::LineCounter::LOW_COUNTER_NAME = "Low"; INSTRUMENT::LineCounter::LineCounter(const std::string &rFilename, const std::string &rCounterName, SIGNAL::SourceRegistry &rSourceRegistry, + SIGNAL::SignalDescriptorRegistry &rSignalDescriptorRegistry, SIGNAL::SignalDb &rSignalDb) : Instrument(rSourceRegistry, rSignalDb, rFilename + LINE_COUNTER_SUFFIX), + m_rSignalDescriptorRegistry(rSignalDescriptorRegistry), m_CounterName(CreateCounterName(rCounterName)), m_CounterNameLow(m_CounterName + SIGNAL::Signal::SIGNAL_NAME_DELIM + LOW_COUNTER_NAME), m_CounterNameHigh(m_CounterName + SIGNAL::Signal::SIGNAL_NAME_DELIM + HIGH_COUNTER_NAME) @@ -80,20 +82,20 @@ void INSTRUMENT::LineCounter::Terminate() const { for (const auto &counterRecord : m_Counter) { + const std::shared_ptr low_descriptor = + m_rSignalDescriptorRegistry.Register(m_rSignalDb.GetPrefix() + m_CounterNameLow, "wire", COUNTER_SIGNAL_SIZE, m_InstrumentHandle); + SIGNAL::ISignal *low_counter = - new SIGNAL::ISignal(m_CounterNameLow, - COUNTER_SIGNAL_SIZE, - counterRecord.first, - counterRecord.second.m_LineLow, - m_InstrumentHandle); + new SIGNAL::ISignal(low_descriptor, counterRecord.first, counterRecord.second.m_LineLow); + m_rSignalDb.Add(low_counter); + const std::shared_ptr high_descriptor = + m_rSignalDescriptorRegistry.Register(m_rSignalDb.GetPrefix() + m_CounterNameHigh, "wire", COUNTER_SIGNAL_SIZE, m_InstrumentHandle); + SIGNAL::ISignal *high_counter = - new SIGNAL::ISignal(m_CounterNameHigh, - COUNTER_SIGNAL_SIZE, - counterRecord.first, - counterRecord.second.m_LineHigh, - m_InstrumentHandle); + new SIGNAL::ISignal(high_descriptor, counterRecord.first, counterRecord.second.m_LineLow); + m_rSignalDb.Add(high_counter); } } diff --git a/sources/common/src/LogParser.cpp b/sources/common/src/LogParser.cpp index 5266494..8bbae91 100644 --- a/sources/common/src/LogParser.cpp +++ b/sources/common/src/LogParser.cpp @@ -7,7 +7,7 @@ /// /// @ingroup Parser /// -/// @par Copyright (c) 2017 vcdMaker team +/// @par Copyright (c) 2020 vcdMaker team /// /// Permission is hereby granted, free of charge, to any person obtaining a /// copy of this software and associated documentation files (the "Software"), @@ -31,10 +31,10 @@ #include "VcdException.h" PARSER::LogParser::LogParser(const std::string &rFilename, - const std::string &rTimeBase, + std::unique_ptr &rSignalDb, SIGNAL::SourceRegistry &rSourceRegistry, bool verboseMode) : - m_pSignalDb(std::make_unique(rTimeBase)), + m_rSignalDb(rSignalDb), m_FileName(rFilename), m_LogFile(m_FileName), m_SourceHandle(rSourceRegistry.Register(rFilename)), diff --git a/sources/common/src/Signal.cpp b/sources/common/src/Signal.cpp index e135dfd..34854a3 100644 --- a/sources/common/src/Signal.cpp +++ b/sources/common/src/Signal.cpp @@ -8,7 +8,7 @@ /// /// @ingroup Signal /// -/// @par Copyright (c) 2018 vcdMaker team +/// @par Copyright (c) 2020 vcdMaker team /// /// Permission is hereby granted, free of charge, to any person obtaining a /// copy of this software and associated documentation files (the "Software"), @@ -33,12 +33,12 @@ SIGNAL::Signal::SignalNameFieldsT SIGNAL::Signal::GetNameFields() const { - return UTILS::Split(m_Name, SIGNAL_NAME_DELIM); + return UTILS::Split(GetName(), SIGNAL_NAME_DELIM); } bool SIGNAL::Signal::SimilarTo(const Signal &rSignal) const { - return ((m_Type == rSignal.GetType()) && - (m_Size == rSignal.GetSize()) && - (m_SourceHandle == rSignal.GetSource())); + return ((GetType() == rSignal.GetType()) && + (GetSize() == rSignal.GetSize()) && + (GetSource() == rSignal.GetSource())); } diff --git a/sources/common/src/SignalDb.cpp b/sources/common/src/SignalDb.cpp index 76dead8..18158d1 100644 --- a/sources/common/src/SignalDb.cpp +++ b/sources/common/src/SignalDb.cpp @@ -8,7 +8,7 @@ /// /// @ingroup Signal /// -/// @par Copyright (c) 2018 vcdMaker team +/// @par Copyright (c) 2020 vcdMaker team /// /// Permission is hereby granted, free of charge, to any person obtaining a /// copy of this software and associated documentation files (the "Software"), @@ -32,8 +32,9 @@ #include "VcdException.h" #include "SourceRegistry.h" -SIGNAL::SignalDb::SignalDb(const std::string &rTimeUnit) : - m_TimeUnit(rTimeUnit) +SIGNAL::SignalDb::SignalDb(const std::string &rTimeUnit, const std::string &rPrefix) : + m_TimeUnit(rTimeUnit), + m_Prefix(rPrefix) { } @@ -62,28 +63,6 @@ void SIGNAL::SignalDb::Add(const SIGNAL::Signal *pSignal) { m_AddedSignals[pSignal->GetName()] = pSignal; } - else - { - // Check signal consistency - if (!it->second->SimilarTo(*pSignal)) - { - std::string signalName(pSignal->GetName()); - std::string signalType(pSignal->GetType()); - std::string signalSize(std::to_string(pSignal->GetSize())); - std::string signalSource(SIGNAL::SourceRegistry::GetInstance().GetSourceName(pSignal->GetSource())); - throw EXCEPTION::VcdException(EXCEPTION::Error::INCONSISTENT_SIGNAL, - "Inconsistent signal: " + - signalName + - ". Types: " + - it->second->GetType() + " / " + signalType + - ". Sizes: " + - std::to_string(it->second->GetSize()) + " / " + signalSize + - ". Sources: " + - SIGNAL::SourceRegistry::GetInstance().GetSourceName(it->second->GetSource()) + - " and " + - signalSource + "."); - } - } // Store the full signal data m_SignalSet.insert(pSignal); diff --git a/sources/common/src/SignalDescriptor.cpp b/sources/common/src/SignalDescriptor.cpp new file mode 100644 index 0000000..21ae4de --- /dev/null +++ b/sources/common/src/SignalDescriptor.cpp @@ -0,0 +1,72 @@ +/// @file common/src/SignalDescriptor.cpp +/// +/// The signal descriptor. +/// +/// @par Full Description +/// The signal descriptor defines a signal's constant properties such as +/// name, size, type and source. +/// +/// @ingroup Signal +/// +/// @par Copyright (c) 2020 vcdMaker team +/// +/// 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. + +#include "SignalDescriptor.h" + +/// Returns the signal's name. +const std::string &SIGNAL::SignalDescriptor::GetName() const +{ + return m_Name; +} + +/// Returns the signal's size in bits. +size_t SIGNAL::SignalDescriptor::GetSize() const +{ + return m_Size; +} + +/// Returns the signal's type. +const std::string &SIGNAL::SignalDescriptor::GetType() const +{ + return m_Type; +} + +/// Returns the source handle of the signal. +SIGNAL::SourceRegistry::HandleT SIGNAL::SignalDescriptor::GetSource() const +{ + return m_SourceHandle; +} + +/// Check signal consistency. +bool SIGNAL::SignalDescriptor::SimilarTo(const std::string &rType, size_t size, SourceRegistry::HandleT sourceHandle) const +{ + return ((GetType() == rType) && + (GetSize() == size) && + (GetSource() == sourceHandle)); +} + +/// Checks if two descriptors match. +bool SIGNAL::SignalDescriptor::EqualTo(SignalDescriptor const &other) const +{ + return ((m_Name == other.GetName()) && + (m_Type == other.GetType()) && + (m_Size == other.GetSize()) && + (m_SourceHandle == other.GetSource())); +} diff --git a/sources/common/src/SignalDescriptorRegistry.cpp b/sources/common/src/SignalDescriptorRegistry.cpp new file mode 100644 index 0000000..c178cb5 --- /dev/null +++ b/sources/common/src/SignalDescriptorRegistry.cpp @@ -0,0 +1,67 @@ +/// @file common/src/SignalDescriptorRegistry.cpp +/// +/// The signal descriptor registry. +/// +/// @par Full Description +/// The signal descriptor registry. It is supposed to create unique signal +/// descriptors and maintain its collection during the whole application lifetime. +/// +/// @ingroup Signal +/// +/// @par Copyright (c) 2020 vcdMaker team +/// +/// 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. + +#include "SignalDescriptorRegistry.h" +#include "VcdException.h" + +const std::shared_ptr SIGNAL::SignalDescriptorRegistry::Register( + const std::string &rName, + const std::string &rType, + size_t size, + SourceRegistry::HandleT sourceHandle) +{ + const auto it = m_SignalDescriptors.find(rName); + + // Is this a new signal to be registered? + if (it == m_SignalDescriptors.end()) + { + auto signalDescriptor = std::make_shared(rName, size, rType, sourceHandle); + m_SignalDescriptors[rName] = signalDescriptor; + return signalDescriptor; + } + + // Check signal consistency. + if (!it->second->SimilarTo(rType, size, sourceHandle)) + { + throw EXCEPTION::VcdException(EXCEPTION::Error::INCONSISTENT_SIGNAL, + "Inconsistent signal: " + + rName + + ". Types: " + + it->second->GetType() + " / " + rType + + ". Sizes: " + + std::to_string(it->second->GetSize()) + " / " + std::to_string(size) + + ". Sources: " + + SIGNAL::SourceRegistry::GetInstance().GetSourceName(it->second->GetSource()) + + " and " + + SIGNAL::SourceRegistry::GetInstance().GetSourceName(sourceHandle) + "."); + } + + return it->second; +} diff --git a/sources/common/src/SignalFactory.cpp b/sources/common/src/SignalFactory.cpp index 0a7d157..693a2a7 100644 --- a/sources/common/src/SignalFactory.cpp +++ b/sources/common/src/SignalFactory.cpp @@ -7,7 +7,7 @@ /// /// @ingroup Parser /// -/// @par Copyright (c) 2018 vcdMaker team +/// @par Copyright (c) 2020 vcdMaker team /// /// Permission is hereby granted, free of charge, to any person obtaining a /// copy of this software and associated documentation files (the "Software"), @@ -40,8 +40,9 @@ PARSER::SignalFactory::SignalFactory() : { } -std::vector PARSER::SignalFactory::Create(std::string &logLine, +std::vector PARSER::SignalFactory::Create(const std::string &rLogLine, INSTRUMENT::Instrument::LineNumberT lineNumber, + const std::string &rPrefix, SIGNAL::SourceRegistry::HandleT sourceHandle) const { if (m_vpSignalCreators.empty()) @@ -54,23 +55,23 @@ std::vector PARSER::SignalFactory::Create(std::string &lo for (const auto &creator : m_vpSignalCreators) { - SIGNAL::Signal *pSignal = nullptr; + const SIGNAL::Signal *pSignal = nullptr; try { // Try to use creator. - pSignal = creator->Create(logLine, lineNumber, sourceHandle); + pSignal = creator->Create(rLogLine, lineNumber, rPrefix, sourceHandle); } catch (const PARSER::EXCEPTIONS::EvaluatorException &evaluatorError) { throw EXCEPTION::VcdException(EXCEPTION::Error::EXPRESSION_EVALUATION_ERROR, - GetLogLineInfo(sourceHandle, lineNumber, logLine) + + GetLogLineInfo(sourceHandle, lineNumber, rLogLine) + evaluatorError.what()); } catch (const EXCEPTION::TooSmallVector &smallVector) { LOGGER::Logger::GetInstance().LogWarning(EXCEPTION::Warning::INSUFFICIENT_VECTOR_SIZE, - GetLogLineInfo(sourceHandle, lineNumber, logLine) + + GetLogLineInfo(sourceHandle, lineNumber, rLogLine) + smallVector.what()); } catch (const std::regex_error ®exError) diff --git a/sources/common/src/TxtParser.cpp b/sources/common/src/TxtParser.cpp index 22e3e1a..a2f7485 100644 --- a/sources/common/src/TxtParser.cpp +++ b/sources/common/src/TxtParser.cpp @@ -7,7 +7,7 @@ /// /// @ingroup Parser /// -/// @par Copyright (c) 2018 vcdMaker team +/// @par Copyright (c) 2020 vcdMaker team /// /// Permission is hereby granted, free of charge, to any person obtaining a /// copy of this software and associated documentation files (the "Software"), @@ -32,11 +32,11 @@ #include "VcdException.h" PARSER::TxtParser::TxtParser(const std::string &rFilename, - const std::string &rTimeBase, + std::unique_ptr &rSignalDb, SIGNAL::SourceRegistry &rSourceRegistry, const PARSER::SignalFactory &rSignalFactory, bool verboseMode) : - LogParser(rFilename, rTimeBase, rSourceRegistry, verboseMode), + LogParser(rFilename, rSignalDb, rSourceRegistry, verboseMode), m_ValidLines(0), m_InvalidLines(0), m_SourceHandle(rSourceRegistry.Register(rFilename)), @@ -65,7 +65,7 @@ void PARSER::TxtParser::Parse() while (std::getline(m_LogFile, input_line)) { std::vector vpSignals = - m_rSignalFactory.Create(input_line, lineNumber, m_SourceHandle); + m_rSignalFactory.Create(input_line, lineNumber, m_rSignalDb->GetPrefix(), m_SourceHandle); const SIGNAL::Signal *pSignal = nullptr; if (!vpSignals.empty()) @@ -76,7 +76,7 @@ void PARSER::TxtParser::Parse() { pSignal = vpSignals.back(); vpSignals.pop_back(); - m_pSignalDb->Add(pSignal); + m_rSignalDb->Add(pSignal); } catch (const EXCEPTION::VcdException &rException) { diff --git a/sources/common/src/VCDTracer.cpp b/sources/common/src/VCDTracer.cpp index bf795fd..cc8b070 100644 --- a/sources/common/src/VCDTracer.cpp +++ b/sources/common/src/VCDTracer.cpp @@ -81,6 +81,7 @@ void TRACER::VCDTracer::GenerateSignalStructure() void TRACER::VCDTracer::GenerateSignalDefaults() { + DumpLine("$enddefinitions $end"); DumpLine("$dumpvars"); for (const auto &signal : m_rSignalDb.GetSignalFootprint()) { diff --git a/sources/common/src/XmlEventSignalCreator.cpp b/sources/common/src/XmlEventSignalCreator.cpp index 8bef82a..bff54ba 100644 --- a/sources/common/src/XmlEventSignalCreator.cpp +++ b/sources/common/src/XmlEventSignalCreator.cpp @@ -4,7 +4,7 @@ /// /// @ingroup Parser /// -/// @par Copyright (c) 2018 vcdMaker team +/// @par Copyright (c) 2020 vcdMaker team /// /// Permission is hereby granted, free of charge, to any person obtaining a /// copy of this software and associated documentation files (the "Software"), @@ -29,15 +29,18 @@ SIGNAL::Signal *PARSER::XmlEventSignalCreator::Create(const std::string &rLogLine, INSTRUMENT::Instrument::LineNumberT lineNumber, + const std::string &rPrefix, SIGNAL::SourceRegistry::HandleT sourceHandle) const { std::smatch result; if (std::regex_search(rLogLine, result, m_SignalRegEx)) { - return new SIGNAL::EventSignal(GetName(result), - GetTimestamp(result, lineNumber), - sourceHandle); + return new SIGNAL::EventSignal(m_rSignalDescriptorRegistry.Register(rPrefix + GetName(result), + "event", + 0, + sourceHandle), + GetTimestamp(result, lineNumber)); } else { diff --git a/sources/common/src/XmlFSignalCreator.cpp b/sources/common/src/XmlFSignalCreator.cpp index 657ef7f..70b4829 100644 --- a/sources/common/src/XmlFSignalCreator.cpp +++ b/sources/common/src/XmlFSignalCreator.cpp @@ -4,7 +4,7 @@ /// /// @ingroup Parser /// -/// @par Copyright (c) 2018 vcdMaker team +/// @par Copyright (c) 2020 vcdMaker team /// /// Permission is hereby granted, free of charge, to any person obtaining a /// copy of this software and associated documentation files (the "Software"), @@ -29,16 +29,19 @@ SIGNAL::Signal *PARSER::XmlFSignalCreator::Create(const std::string &rLogLine, INSTRUMENT::Instrument::LineNumberT lineNumber, + const std::string &rPrefix, SIGNAL::SourceRegistry::HandleT sourceHandle) const { std::smatch result; if (true == std::regex_search(rLogLine, result, m_SignalRegEx)) { - return new SIGNAL::FSignal(GetName(result), + return new SIGNAL::FSignal(m_rSignalDescriptorRegistry.Register(rPrefix + GetName(result), + "real", + 64, + sourceHandle), GetTimestamp(result, lineNumber), - GetFloatValue(result), - sourceHandle); + GetFloatValue(result)); } else { diff --git a/sources/common/src/XmlISignalCreator.cpp b/sources/common/src/XmlISignalCreator.cpp index 410131f..02296d8 100644 --- a/sources/common/src/XmlISignalCreator.cpp +++ b/sources/common/src/XmlISignalCreator.cpp @@ -4,7 +4,7 @@ /// /// @ingroup Parser /// -/// @par Copyright (c) 2018 vcdMaker team +/// @par Copyright (c) 2020 vcdMaker team /// /// Permission is hereby granted, free of charge, to any person obtaining a /// copy of this software and associated documentation files (the "Software"), @@ -29,17 +29,19 @@ SIGNAL::Signal *PARSER::XmlISignalCreator::Create(const std::string &rLogLine, INSTRUMENT::Instrument::LineNumberT lineNumber, + const std::string &rPrefix, SIGNAL::SourceRegistry::HandleT sourceHandle) const { std::smatch result; if (true == std::regex_search(rLogLine, result, m_SignalRegEx)) { - return new SIGNAL::ISignal(GetName(result), - GetSize(result), + return new SIGNAL::ISignal(m_rSignalDescriptorRegistry.Register(rPrefix + GetName(result), + "wire", + GetSize(result), + sourceHandle), GetTimestamp(result, lineNumber), - GetDecimalValue(result).GetValue(), - sourceHandle); + GetDecimalValue(result).GetValue()); } else { diff --git a/sources/common/src/XmlSignalFactory.cpp b/sources/common/src/XmlSignalFactory.cpp index 4db66e8..2d4aa97 100644 --- a/sources/common/src/XmlSignalFactory.cpp +++ b/sources/common/src/XmlSignalFactory.cpp @@ -8,7 +8,7 @@ /// /// @ingroup Parser /// -/// @par Copyright (c) 2018 vcdMaker team +/// @par Copyright (c) 2020 vcdMaker team /// /// Permission is hereby granted, free of charge, to any person obtaining a /// copy of this software and associated documentation files (the "Software"), @@ -120,7 +120,8 @@ const std::string &PARSER::XmlDescription::GetSize() const "XML - No size expression."); } -PARSER::XmlSignalFactory::XmlSignalFactory(const std::string &rXmlFileName) : +PARSER::XmlSignalFactory::XmlSignalFactory(SIGNAL::SignalDescriptorRegistry &rSignalDescriptorRegistry, + const std::string &rXmlFileName) : SignalFactory() { // Parse the XML and add signal creators. @@ -141,7 +142,8 @@ PARSER::XmlSignalFactory::XmlSignalFactory(const std::string &rXmlFileName) : std::unique_ptr description = std::make_unique(signal); if (0 == std::strcmp("vector", signal.name())) { - m_vpSignalCreators.push_back(std::make_unique(description->GetRegex(), + m_vpSignalCreators.push_back(std::make_unique(rSignalDescriptorRegistry, + description->GetRegex(), description->GetTimestamp(), description->GetName(), description->GetValue(), @@ -149,14 +151,16 @@ PARSER::XmlSignalFactory::XmlSignalFactory(const std::string &rXmlFileName) : } else if (0 == std::strcmp("real", signal.name())) { - m_vpSignalCreators.push_back(std::make_unique(description->GetRegex(), + m_vpSignalCreators.push_back(std::make_unique(rSignalDescriptorRegistry, + description->GetRegex(), description->GetTimestamp(), description->GetName(), description->GetValue())); } else if (0 == std::strcmp("event", signal.name())) { - m_vpSignalCreators.push_back(std::make_unique(description->GetRegex(), + m_vpSignalCreators.push_back(std::make_unique(rSignalDescriptorRegistry, + description->GetRegex(), description->GetTimestamp(), description->GetName())); } diff --git a/sources/parsers/auto/DecimalParser.cpp b/sources/parsers/auto/DecimalParser.cpp index 60d021c..1cc938a 100644 --- a/sources/parsers/auto/DecimalParser.cpp +++ b/sources/parsers/auto/DecimalParser.cpp @@ -550,7 +550,7 @@ namespace PARSER { /* Line 670 of lalr1.cc */ #line 115 "DecimalParser.yy" { - (yyval.pExprNode) = new DNHex(evaluator.GetContext(), *(yysemantic_stack_[(1) - (1)].pString)); + (yyval.pExprNode) = new DNHex(evaluator.GetContext(), (yysemantic_stack_[(1) - (1)].pString)); delete (yysemantic_stack_[(1) - (1)].pString); } break; @@ -559,7 +559,7 @@ namespace PARSER { /* Line 670 of lalr1.cc */ #line 120 "DecimalParser.yy" { - (yyval.pExprNode) = new DNDec(evaluator.GetContext(), *(yysemantic_stack_[(1) - (1)].pString)); + (yyval.pExprNode) = new DNDec(evaluator.GetContext(), (yysemantic_stack_[(1) - (1)].pString)); delete (yysemantic_stack_[(1) - (1)].pString); } break; diff --git a/sources/parsers/auto/FloatParser.cpp b/sources/parsers/auto/FloatParser.cpp index 12cc694..f7ba93a 100644 --- a/sources/parsers/auto/FloatParser.cpp +++ b/sources/parsers/auto/FloatParser.cpp @@ -536,7 +536,7 @@ namespace PARSER { /* Line 670 of lalr1.cc */ #line 110 "FloatParser.yy" { - (yyval.pExprNode) = new FNFlt(evaluator.GetContext(), *(yysemantic_stack_[(1) - (1)].pString)); + (yyval.pExprNode) = new FNFlt(evaluator.GetContext(), (yysemantic_stack_[(1) - (1)].pString)); delete (yysemantic_stack_[(1) - (1)].pString); } break; diff --git a/sources/parsers/auto/StringParser.cpp b/sources/parsers/auto/StringParser.cpp index 5b98162..a6f3e54 100644 --- a/sources/parsers/auto/StringParser.cpp +++ b/sources/parsers/auto/StringParser.cpp @@ -50,7 +50,7 @@ /* User implementation prologue. */ /* Line 285 of lalr1.cc */ -#line 87 "StringParser.yy" +#line 84 "StringParser.yy" #include "Evaluator.h" @@ -261,55 +261,34 @@ namespace PARSER { switch (yytype) { - case 3: /* "text" */ + case 7: /* constant */ /* Line 455 of lalr1.cc */ #line 77 "StringParser.yy" - { delete ((*yyvaluep).pString); }; + { delete ((*yyvaluep).pExprNode); }; /* Line 455 of lalr1.cc */ #line 270 "StringParser.cpp" break; - case 4: /* "text constant" */ + case 8: /* variable */ /* Line 455 of lalr1.cc */ #line 78 "StringParser.yy" - { delete ((*yyvaluep).pString); }; + { delete ((*yyvaluep).pExprNode); }; /* Line 455 of lalr1.cc */ #line 277 "StringParser.cpp" break; - case 7: /* constant */ + case 10: /* addexpr */ /* Line 455 of lalr1.cc */ #line 79 "StringParser.yy" { delete ((*yyvaluep).pExprNode); }; /* Line 455 of lalr1.cc */ #line 284 "StringParser.cpp" break; - case 8: /* variable */ + case 11: /* expr */ /* Line 455 of lalr1.cc */ #line 80 "StringParser.yy" { delete ((*yyvaluep).pExprNode); }; /* Line 455 of lalr1.cc */ #line 291 "StringParser.cpp" break; - case 9: /* atomexpr */ -/* Line 455 of lalr1.cc */ -#line 81 "StringParser.yy" - { delete ((*yyvaluep).pExprNode); }; -/* Line 455 of lalr1.cc */ -#line 298 "StringParser.cpp" - break; - case 10: /* addexpr */ -/* Line 455 of lalr1.cc */ -#line 82 "StringParser.yy" - { delete ((*yyvaluep).pExprNode); }; -/* Line 455 of lalr1.cc */ -#line 305 "StringParser.cpp" - break; - case 11: /* expr */ -/* Line 455 of lalr1.cc */ -#line 83 "StringParser.yy" - { delete ((*yyvaluep).pExprNode); }; -/* Line 455 of lalr1.cc */ -#line 312 "StringParser.cpp" - break; default: break; @@ -519,24 +498,24 @@ namespace PARSER { { case 2: /* Line 670 of lalr1.cc */ -#line 103 "StringParser.yy" +#line 100 "StringParser.yy" { - (yyval.pExprNode) = new SNConstant(evaluator.GetContext(), *(yysemantic_stack_[(1) - (1)].pString)); + (yyval.pExprNode) = new SNConstant(evaluator.GetContext(), (yysemantic_stack_[(1) - (1)].pString)); } break; case 3: /* Line 670 of lalr1.cc */ -#line 108 "StringParser.yy" +#line 105 "StringParser.yy" { - (yyval.pExprNode) = new SNTxt(evaluator.GetContext(), *(yysemantic_stack_[(1) - (1)].pString)); + (yyval.pExprNode) = new SNTxt(evaluator.GetContext(), (yysemantic_stack_[(1) - (1)].pString)); delete (yysemantic_stack_[(1) - (1)].pString); } break; case 4: /* Line 670 of lalr1.cc */ -#line 114 "StringParser.yy" +#line 111 "StringParser.yy" { (yyval.pExprNode) = (yysemantic_stack_[(1) - (1)].pExprNode); } @@ -544,7 +523,7 @@ namespace PARSER { case 5: /* Line 670 of lalr1.cc */ -#line 118 "StringParser.yy" +#line 115 "StringParser.yy" { (yyval.pExprNode) = (yysemantic_stack_[(1) - (1)].pExprNode); } @@ -552,7 +531,7 @@ namespace PARSER { case 6: /* Line 670 of lalr1.cc */ -#line 123 "StringParser.yy" +#line 120 "StringParser.yy" { (yyval.pExprNode) = (yysemantic_stack_[(1) - (1)].pExprNode); } @@ -560,7 +539,7 @@ namespace PARSER { case 7: /* Line 670 of lalr1.cc */ -#line 127 "StringParser.yy" +#line 124 "StringParser.yy" { (yyval.pExprNode) = new SNAdd(evaluator.GetContext(), (yysemantic_stack_[(3) - (1)].pExprNode), (yysemantic_stack_[(3) - (3)].pExprNode)); } @@ -568,7 +547,7 @@ namespace PARSER { case 8: /* Line 670 of lalr1.cc */ -#line 132 "StringParser.yy" +#line 129 "StringParser.yy" { (yyval.pExprNode) = (yysemantic_stack_[(1) - (1)].pExprNode); } @@ -576,7 +555,7 @@ namespace PARSER { case 10: /* Line 670 of lalr1.cc */ -#line 138 "StringParser.yy" +#line 135 "StringParser.yy" { evaluator.GetContext().SetExpression((yysemantic_stack_[(3) - (2)].pExprNode)); } @@ -584,7 +563,7 @@ namespace PARSER { /* Line 670 of lalr1.cc */ -#line 588 "StringParser.cpp" +#line 567 "StringParser.cpp" default: break; } @@ -1002,8 +981,8 @@ namespace PARSER { const unsigned char StringParser::yyrline_[] = { - 0, 102, 102, 107, 113, 117, 122, 126, 131, 136, - 137 + 0, 99, 99, 104, 110, 114, 119, 123, 128, 133, + 134 }; // Print the state stack on the debug stream. @@ -1091,9 +1070,9 @@ namespace PARSER { } // PARSER /* Line 1141 of lalr1.cc */ -#line 1095 "StringParser.cpp" +#line 1074 "StringParser.cpp" /* Line 1142 of lalr1.cc */ -#line 142 "StringParser.yy" +#line 139 "StringParser.yy" /*** Additional Code ***/ void PARSER::StringParser::error(const StringParser::location_type& l, diff --git a/sources/parsers/auto/StringScanner.cpp b/sources/parsers/auto/StringScanner.cpp index 49d6c77..4df7e09 100644 --- a/sources/parsers/auto/StringScanner.cpp +++ b/sources/parsers/auto/StringScanner.cpp @@ -1932,7 +1932,7 @@ void yyfree (void * ptr ) namespace PARSER { StringScanner::StringScanner(std::istream* in, - std::ostream* out) + std::ostream* out) : StringFlexLexer(in, out) { } diff --git a/sources/parsers/inc/DecimalNode.h b/sources/parsers/inc/DecimalNode.h index d7351dc..fec8a93 100644 --- a/sources/parsers/inc/DecimalNode.h +++ b/sources/parsers/inc/DecimalNode.h @@ -70,11 +70,11 @@ namespace PARSER /// Constructs a constant type node based on a decimal string. /// /// @param rExpContext The expression context. - /// @param rString The string containing information about the decimal string index in the parsed regex group. - DNDec(ExpressionContext &rExpContext, std::string &rString) : + /// @param pString The string containing information about the decimal string index in the parsed regex group. + DNDec(ExpressionContext &rExpContext, std::string *pString) : ExpressionNode(rExpContext) { - std::string stringIndex(rString, FIRST_STRING_CHARACTER_POS, rString.length() - GROUP_WRAPPER_LENGTH); + std::string stringIndex(*pString, FIRST_STRING_CHARACTER_POS, pString->length() - GROUP_WRAPPER_LENGTH); // Format of the string: dec(position) m_Index = static_cast(std::strtoull(stringIndex.c_str(), nullptr, 10)); @@ -94,11 +94,11 @@ namespace PARSER /// Constructs a constant type node based on a hexadecimal string. /// /// @param rExpContext The expression context. - /// @param rString The string containing information about the hexadecimal string index in the parsed regex group. - DNHex(ExpressionContext &rExpContext, std::string &rString) : + /// @param pString The string containing information about the hexadecimal string index in the parsed regex group. + DNHex(ExpressionContext &rExpContext, std::string *pString) : ExpressionNode(rExpContext) { - std::string stringIndex(rString, FIRST_STRING_CHARACTER_POS, rString.length() - GROUP_WRAPPER_LENGTH); + std::string stringIndex(*pString, FIRST_STRING_CHARACTER_POS, pString->length() - GROUP_WRAPPER_LENGTH); // Format of the string: hex(position) m_Index = static_cast(std::strtoull(stringIndex.c_str(), nullptr, 10)); diff --git a/sources/parsers/inc/Evaluator.h b/sources/parsers/inc/Evaluator.h index 98e9f4e..1c79037 100644 --- a/sources/parsers/inc/Evaluator.h +++ b/sources/parsers/inc/Evaluator.h @@ -8,7 +8,7 @@ /// /// @ingroup Parser /// -/// @par Copyright (c) 2018 vcdMaker team +/// @par Copyright (c) 2020 vcdMaker team /// /// Permission is hereby granted, free of charge, to any person obtaining a /// copy of this software and associated documentation files (the "Software"), @@ -100,13 +100,13 @@ namespace PARSER /// the expected lexer interface. /// The decimal(vector) lexer. - class DecimalScanner *m_pDecimalLexer; + class DecimalScanner *m_pDecimalLexer = nullptr; /// The float lexer. - class FloatScanner *m_pFloatLexer; + class FloatScanner *m_pFloatLexer = nullptr; /// The string lexer. - class StringScanner *m_pStringLexer; + class StringScanner *m_pStringLexer = nullptr; private: /// Parses the input decimal stream. diff --git a/sources/parsers/inc/ExpressionContext.h b/sources/parsers/inc/ExpressionContext.h index 1e017a8..0dd7c5a 100644 --- a/sources/parsers/inc/ExpressionContext.h +++ b/sources/parsers/inc/ExpressionContext.h @@ -53,11 +53,15 @@ namespace PARSER /// @param lineNo The log line number. ExpressionContext(std::smatch *pGroups, uint64_t lineNo) : m_pGroups(pGroups), - m_LineNo(lineNo) + m_LineNo(lineNo), + m_pExpression(nullptr) {} /// Expression context destructor. - ~ExpressionContext() = default; + ~ExpressionContext() + { + delete m_pExpression; + } /// Set the expression context. /// diff --git a/sources/parsers/inc/FloatNode.h b/sources/parsers/inc/FloatNode.h index 53ee6d5..83f2389 100644 --- a/sources/parsers/inc/FloatNode.h +++ b/sources/parsers/inc/FloatNode.h @@ -72,11 +72,11 @@ namespace PARSER /// Constructs a constant type node based on a float string. /// /// @param rExpContext The expression context. - /// @param rString The string containing information about the decimal string index in the parsed regex group. - FNFlt(ExpressionContext &rExpContext, std::string &rString) : + /// @param pString The string containing information about the decimal string index in the parsed regex group. + FNFlt(ExpressionContext &rExpContext, std::string *pString) : ExpressionNode(rExpContext) { - std::string stringIndex(rString, FIRST_STRING_CHARACTER_POS, rString.length() - GROUP_WRAPPER_LENGTH); + std::string stringIndex(*pString, FIRST_STRING_CHARACTER_POS, pString->length() - GROUP_WRAPPER_LENGTH); // Format of the string: flt(position) m_Index = static_cast(std::strtoull(stringIndex.c_str(), nullptr, 10)); diff --git a/sources/parsers/inc/StringNode.h b/sources/parsers/inc/StringNode.h index 632b926..ed35099 100644 --- a/sources/parsers/inc/StringNode.h +++ b/sources/parsers/inc/StringNode.h @@ -40,26 +40,32 @@ namespace PARSER class SNConstant : public ExpressionNode { /// The constatnt value. - std::string &m_rString; + std::string *m_pString; public: /// Constructs a constant type node from a value. /// /// @param rExpContext The expression context. - /// @param value The constant value used to create the node. - SNConstant(ExpressionContext &rExpContext, std::string &value) : + /// @param pValue The constant value used to create the node. + SNConstant(ExpressionContext &rExpContext, std::string *pValue) : ExpressionNode(rExpContext), - m_rString(value) + m_pString(pValue) { } + /// Destructor. + ~SNConstant() + { + delete m_pString; + } + /// @copydoc ExpressionNode::EvaluateString() virtual std::string EvaluateString() const { const uint32_t SKIP_FIRST_QUOTE = 1U; const uint32_t TWO_QUOTE_SIGNS = 2U; - return std::string(m_rString, SKIP_FIRST_QUOTE, m_rString.length() - TWO_QUOTE_SIGNS); + return std::string(*m_pString, SKIP_FIRST_QUOTE, m_pString->length() - TWO_QUOTE_SIGNS); } }; @@ -73,11 +79,11 @@ namespace PARSER /// Constructs a string node. /// /// @param rExpContext The expression context. - /// @param rString The string containing information about the string index in the parsed regex group. - SNTxt(ExpressionContext &rExpContext, std::string &rString) : + /// @param pString The string containing information about the string index in the parsed regex group. + SNTxt(ExpressionContext &rExpContext, std::string *pString) : ExpressionNode(rExpContext) { - std::string stringIndex(rString, FIRST_STRING_CHARACTER_POS, rString.length() - GROUP_WRAPPER_LENGTH); + std::string stringIndex(*pString, FIRST_STRING_CHARACTER_POS, pString->length() - GROUP_WRAPPER_LENGTH); // Format of the string: txt(position) m_Index = static_cast(std::strtoull(stringIndex.c_str(), nullptr, 10)); diff --git a/sources/parsers/model/DecimalParser.yy b/sources/parsers/model/DecimalParser.yy index 6e667b3..a9880d8 100644 --- a/sources/parsers/model/DecimalParser.yy +++ b/sources/parsers/model/DecimalParser.yy @@ -113,12 +113,12 @@ constant : INTEGER variable : HEX { - $$ = new DNHex(evaluator.GetContext(), *$1); + $$ = new DNHex(evaluator.GetContext(), $1); delete $1; } | DEC { - $$ = new DNDec(evaluator.GetContext(), *$1); + $$ = new DNDec(evaluator.GetContext(), $1); delete $1; } | LINE diff --git a/sources/parsers/model/FloatParser.yy b/sources/parsers/model/FloatParser.yy index 62fc97c..ef2afd7 100644 --- a/sources/parsers/model/FloatParser.yy +++ b/sources/parsers/model/FloatParser.yy @@ -108,7 +108,7 @@ constant : DOUBLE variable : FLT { - $$ = new FNFlt(evaluator.GetContext(), *$1); + $$ = new FNFlt(evaluator.GetContext(), $1); delete $1; } diff --git a/sources/parsers/model/StringParser.yy b/sources/parsers/model/StringParser.yy index 4d8259f..167d3ed 100644 --- a/sources/parsers/model/StringParser.yy +++ b/sources/parsers/model/StringParser.yy @@ -74,11 +74,8 @@ %type constant variable atomexpr addexpr expr -%destructor { delete $$; } TXT -%destructor { delete $$; } TXT_CONSTANT %destructor { delete $$; } constant %destructor { delete $$; } variable -%destructor { delete $$; } atomexpr %destructor { delete $$; } addexpr %destructor { delete $$; } expr @@ -101,12 +98,12 @@ constant : TXT_CONSTANT { - $$ = new SNConstant(evaluator.GetContext(), *$1); + $$ = new SNConstant(evaluator.GetContext(), $1); } variable : TXT { - $$ = new SNTxt(evaluator.GetContext(), *$1); + $$ = new SNTxt(evaluator.GetContext(), $1); delete $1; } diff --git a/sources/parsers/model/StringScanner.ll b/sources/parsers/model/StringScanner.ll index ccb5c9f..a49abf1 100644 --- a/sources/parsers/model/StringScanner.ll +++ b/sources/parsers/model/StringScanner.ll @@ -102,7 +102,7 @@ txt\([ ]*[0-9]+[ ]*\) { namespace PARSER { StringScanner::StringScanner(std::istream* in, - std::ostream* out) + std::ostream* out) : StringFlexLexer(in, out) { } diff --git a/sources/vcdMaker/src/vcdMaker.cpp b/sources/vcdMaker/src/vcdMaker.cpp index 18ebc16..6fb602b 100644 --- a/sources/vcdMaker/src/vcdMaker.cpp +++ b/sources/vcdMaker/src/vcdMaker.cpp @@ -2,7 +2,7 @@ /// /// The main module of the vcdMaker application. /// -/// @par Copyright (c) 2018 vcdMaker team +/// @par Copyright (c) 2020 vcdMaker team /// /// Permission is hereby granted, free of charge, to any person obtaining a /// copy of this software and associated documentation files (the "Software"), @@ -33,6 +33,7 @@ #include "Logger.h" #include "XmlSignalFactory.h" #include "DefaultSignalFactory.h" +#include "OutOfMemory.h" /// The vcdMaker main function. /// @@ -44,26 +45,31 @@ int main(int argc, const char *argv[]) // The application execution status. int32_t executionStatus = EXECUTION::APP_OK; + std::set_new_handler(OutOfMemory); + try { // Parse input parameters CLI::CliMaker cli; cli.Parse(argc, argv); - // Build the signal factory. + // Build the signal factory artifacts. std::unique_ptr pSignalFactory = NULL; + SIGNAL::SignalDescriptorRegistry SignalDescriptorRegistry; + std::unique_ptr pSignalDb = std::make_unique(cli.GetTimebase(), ""); + if (!cli.GetUserLogFormat().empty()) { - pSignalFactory = std::make_unique(cli.GetUserLogFormat()); + pSignalFactory = std::make_unique(SignalDescriptorRegistry, cli.GetUserLogFormat()); } else { - pSignalFactory = std::make_unique(); + pSignalFactory = std::make_unique(SignalDescriptorRegistry); } // Create the log parser. PARSER::TxtParser txtLog(cli.GetInputFileName(), - cli.GetTimebase(), + pSignalDb, SIGNAL::SourceRegistry::GetInstance(), *pSignalFactory, cli.IsVerboseMode()); @@ -77,6 +83,7 @@ int main(int argc, const char *argv[]) lineCounter = std::make_unique(cli.GetInputFileName(), cli.GetLineCounterName(), SIGNAL::SourceRegistry::GetInstance(), + SignalDescriptorRegistry, txtLog.GetSignalDb()); txtLog.Attach(*lineCounter); } diff --git a/sources/vcdMaker/test/functional/test.xml b/sources/vcdMaker/test/functional/test.xml index 1b2341f..a391fc7 100644 --- a/sources/vcdMaker/test/functional/test.xml +++ b/sources/vcdMaker/test/functional/test.xml @@ -11,6 +11,7 @@ A sample test definition (containing all tags): False output_filename golden_filename + standard_output_filename input_filename @@ -31,6 +32,7 @@ A sample test definition (containing all tags): test_001.output test_001.vcd + test_001.std test_001.txt @@ -49,6 +51,7 @@ A sample test definition (containing all tags): test_002.output test_002.vcd + test_002.std test_002.txt @@ -66,6 +69,7 @@ A sample test definition (containing all tags): test_003.output test_003.vcd + test_003.std test_003.txt @@ -85,6 +89,7 @@ A sample test definition (containing all tags): ul_test_001.output test_001.vcd + test_001.std test_001.txt @@ -103,6 +108,7 @@ A sample test definition (containing all tags): ul_test_002.output test_002.vcd + test_002.std test_002.txt @@ -120,6 +126,7 @@ A sample test definition (containing all tags): ul_test_003.output test_003.vcd + test_003.std test_003.txt @@ -129,4 +136,22 @@ A sample test definition (containing all tags): + + + Smoke test 7 + Test inconsistent signals. + + + test_007.output + + test_007.std + + + test_007.txt + us + + + + + diff --git a/sources/vcdMaker/test/functional/test_001.std b/sources/vcdMaker/test/functional/test_001.std new file mode 100644 index 0000000..1ef97bc --- /dev/null +++ b/sources/vcdMaker/test/functional/test_001.std @@ -0,0 +1,5 @@ + +Parsed test_001.txt: +Valid lines: 13 +Invalid lines: 0 + diff --git a/sources/vcdMaker/test/functional/test_001.vcd b/sources/vcdMaker/test/functional/test_001.vcd index 7b8a960..896f7be 100644 --- a/sources/vcdMaker/test/functional/test_001.vcd +++ b/sources/vcdMaker/test/functional/test_001.vcd @@ -1,6 +1,6 @@ -$date December 8, 2014 14:15:00 +$date Tue Dec 18 17:57:25 2018 $end -$version VCD Tracer "Nestor" Release v.3.0.1 +$version VCD Tracer "Nestor" Release v.3.0.2 $end $timescale 1 us $end @@ -16,6 +16,7 @@ $scope module Top $end $var wire 64 Top.Counter.Low Low $end $upscope $end $upscope $end +$enddefinitions $end $dumpvars bxxxxxxxx A.Val bxxxxxxxx B.Val diff --git a/sources/vcdMaker/test/functional/test_002.std b/sources/vcdMaker/test/functional/test_002.std new file mode 100644 index 0000000..656f909 --- /dev/null +++ b/sources/vcdMaker/test/functional/test_002.std @@ -0,0 +1,5 @@ + +Parsed test_002.txt: +Valid lines: 888 +Invalid lines: 0 + diff --git a/sources/vcdMaker/test/functional/test_002.vcd b/sources/vcdMaker/test/functional/test_002.vcd index f80c20e..5e90dd8 100644 --- a/sources/vcdMaker/test/functional/test_002.vcd +++ b/sources/vcdMaker/test/functional/test_002.vcd @@ -1,6 +1,6 @@ -$date December 8, 2014 14:15:00 +$date Tue Dec 18 17:57:25 2018 $end -$version VCD Tracer "Nestor" Release v.3.0.1 +$version VCD Tracer "Nestor" Release v.3.0.2 $end $timescale 1 us $end @@ -24,6 +24,7 @@ $scope module FRDM $end $var wire 7 FRDM.Sensors.Slider Slider $end $upscope $end $upscope $end +$enddefinitions $end $dumpvars bx FRDM.Buttons.SW1 bx FRDM.Buttons.SW3 diff --git a/sources/vcdMaker/test/functional/test_003.std b/sources/vcdMaker/test/functional/test_003.std new file mode 100644 index 0000000..2d8204f --- /dev/null +++ b/sources/vcdMaker/test/functional/test_003.std @@ -0,0 +1,5 @@ + +Parsed test_003.txt: +Valid lines: 21 +Invalid lines: 0 + diff --git a/sources/vcdMaker/test/functional/test_003.vcd b/sources/vcdMaker/test/functional/test_003.vcd index e697a2c..0868030 100644 --- a/sources/vcdMaker/test/functional/test_003.vcd +++ b/sources/vcdMaker/test/functional/test_003.vcd @@ -1,6 +1,6 @@ -$date December 8, 2014 14:15:00 +$date Tue Dec 18 17:57:25 2018 $end -$version VCD Tracer "Nestor" Release v.3.0.1 +$version VCD Tracer "Nestor" Release v.3.0.2 $end $timescale 1 us $end @@ -22,6 +22,7 @@ $scope module Top $end $var wire 64 Top.Cnt.Low Low $end $upscope $end $upscope $end +$enddefinitions $end $dumpvars bxxxxxxxx A.Val bxxxxxxxx B.Val diff --git a/sources/vcdMaker/test/functional/test_007.std b/sources/vcdMaker/test/functional/test_007.std new file mode 100644 index 0000000..0e2a194 --- /dev/null +++ b/sources/vcdMaker/test/functional/test_007.std @@ -0,0 +1,2 @@ +[Error 0002]: Inconsistent signal: A.Val. Types: wire / wire. Sizes: 8 / 9. Sources: test_007.txt and test_007.txt. At line 2. + diff --git a/sources/vcdMaker/test/functional/test_007.txt b/sources/vcdMaker/test/functional/test_007.txt new file mode 100644 index 0000000..c526187 --- /dev/null +++ b/sources/vcdMaker/test/functional/test_007.txt @@ -0,0 +1,3 @@ +#1 A.Val 4 8 +#2 A.Val 5 9 + diff --git a/sources/vcdMerge/inc/SignalSource.h b/sources/vcdMerge/inc/SignalSource.h index a5d72d6..4ba2471 100644 --- a/sources/vcdMerge/inc/SignalSource.h +++ b/sources/vcdMerge/inc/SignalSource.h @@ -8,7 +8,7 @@ /// /// @ingroup Merge /// -/// @par Copyright (c) 2017 vcdMaker team +/// @par Copyright (c) 2020 vcdMaker team /// /// Permission is hereby granted, free of charge, to any person obtaining a /// copy of this software and associated documentation files (the "Software"), @@ -88,10 +88,12 @@ namespace MERGE /// shall be validated to return any syntax errors as quickly as possible. /// /// @param rDescription The description of the source. - /// @param rSignalRegistry The reference to the signal registry common for all sources. + /// @param rSignalDescriptorRegistry The descriptors registry. + /// @param rSourceRegistry The reference to the signal source registry. /// @param verboseMode 'true' enables the verbose mode. SignalSource(const std::string &rDescription, - SIGNAL::SourceRegistry &rSignalRegistry, + SIGNAL::SignalDescriptorRegistry &rSignalDescriptorRegistry, + SIGNAL::SourceRegistry &rSourceRegistry, bool verboseMode); /// Creates the source data. @@ -122,7 +124,7 @@ namespace MERGE } /// Returns the source synchronization point. - const TIME::Timestamp& GetSyncPoint() const + const TIME::Timestamp &GetSyncPoint() const { return m_SyncPoint; } @@ -140,8 +142,11 @@ namespace MERGE /// The source description. const std::string m_SourceDescription; - /// The signal registry. - SIGNAL::SourceRegistry &m_rSignalRegistry; + /// The signal source registry. + SIGNAL::SourceRegistry &m_rSourceRegistry; + + /// The signal descriptors registry. + SIGNAL::SignalDescriptorRegistry &m_rSignalDescriptorRegistry; /// The signals database. std::unique_ptr m_pSignalDb; diff --git a/sources/vcdMerge/src/Merge.cpp b/sources/vcdMerge/src/Merge.cpp index 6d19e2e..b08c285 100644 --- a/sources/vcdMerge/src/Merge.cpp +++ b/sources/vcdMerge/src/Merge.cpp @@ -7,7 +7,7 @@ /// /// @ingroup Merge /// -/// @par Copyright (c) 2018 vcdMaker team +/// @par Copyright (c) 2020 vcdMaker team /// /// Permission is hereby granted, free of charge, to any person obtaining a /// copy of this software and associated documentation files (the "Software"), @@ -109,9 +109,6 @@ void MERGE::Merge::Run() continue; } - // Update its name. - pSignal->SetName(pSource->GetPrefix() + pSignal->GetName()); - // Add to the output signals database. m_pMerged->Add(pSignal); } diff --git a/sources/vcdMerge/src/SignalSource.cpp b/sources/vcdMerge/src/SignalSource.cpp index b0b4477..9c6a69d 100644 --- a/sources/vcdMerge/src/SignalSource.cpp +++ b/sources/vcdMerge/src/SignalSource.cpp @@ -8,7 +8,7 @@ /// /// @ingroup Merge /// -/// @par Copyright (c) 2018 vcdMaker team +/// @par Copyright (c) 2020 vcdMaker team /// /// Permission is hereby granted, free of charge, to any person obtaining a /// copy of this software and associated documentation files (the "Software"), @@ -43,10 +43,12 @@ const char MERGE::SignalSource::Formats::VCD_TEXT_FORMAT = 'T'; const char MERGE::SignalSource::Formats::USER_XML_FORMAT = 'U'; MERGE::SignalSource::SignalSource(const std::string &rDescription, - SIGNAL::SourceRegistry &rSignalRegistry, + SIGNAL::SignalDescriptorRegistry &rSignalDescriptorRegistry, + SIGNAL::SourceRegistry &rSourceRegistry, bool verboseMode) : m_SourceDescription(rDescription), - m_rSignalRegistry(rSignalRegistry), + m_rSourceRegistry(rSourceRegistry), + m_rSignalDescriptorRegistry(rSignalDescriptorRegistry), m_pSignalDb(), m_pSignalFactory(), m_SyncPoint(), @@ -81,10 +83,13 @@ TIME::Timestamp MERGE::SignalSource::GetLeadingTime() const void MERGE::SignalSource::Create() { + // Create the unique source signal database. + m_pSignalDb = std::make_unique(m_TimeUnit, m_Prefix); + // Parse the log file. PARSER::TxtParser parser(m_Filename, - m_TimeUnit, - m_rSignalRegistry, + m_pSignalDb, + m_rSourceRegistry, *m_pSignalFactory, m_VerboseMode); @@ -96,22 +101,21 @@ void MERGE::SignalSource::Create() // Register the line counting instrument. lineCounter = std::make_unique(m_Filename, m_LineCounter, - m_rSignalRegistry, + m_rSourceRegistry, + m_rSignalDescriptorRegistry, parser.GetSignalDb()); parser.Attach(*lineCounter); } // Start parsing. parser.Execute(); - - m_pSignalDb = parser.MoveSignalDb(); } void MERGE::SignalSource::SetFormat(const std::string &rFormat) { if (IsVcdFormat(rFormat)) { - m_pSignalFactory = std::make_unique(); + m_pSignalFactory = std::make_unique(m_rSignalDescriptorRegistry); return; } @@ -128,7 +132,7 @@ void MERGE::SignalSource::SetFormat(const std::string &rFormat) ThrowFileInaccessibleException(filename); } - m_pSignalFactory = std::make_unique(filename); + m_pSignalFactory = std::make_unique(m_rSignalDescriptorRegistry, filename); return; } diff --git a/sources/vcdMerge/src/vcdMerge.cpp b/sources/vcdMerge/src/vcdMerge.cpp index 2b3689b..b91e047 100644 --- a/sources/vcdMerge/src/vcdMerge.cpp +++ b/sources/vcdMerge/src/vcdMerge.cpp @@ -2,7 +2,7 @@ /// /// The main module of the vcdMerge application. /// -/// @par Copyright (c) 2018 vcdMaker team +/// @par Copyright (c) 2020 vcdMaker team /// /// Permission is hereby granted, free of charge, to any person obtaining a /// copy of this software and associated documentation files (the "Software"), @@ -29,6 +29,7 @@ #include "SignalSource.h" #include "Merge.h" #include "Logger.h" +#include "OutOfMemory.h" /// The vcdMerge main function. /// @@ -40,22 +41,37 @@ int main(int argc, const char *argv[]) // The application execution status. int32_t executionStatus = EXECUTION::APP_OK; + std::set_new_handler(OutOfMemory); + try { // Parse input parameters - CLI::CliMerge cli; - cli.Parse(argc, argv); + CLI::CliMerge *cli; + try + { + cli = new CLI::CliMerge(); + } + catch (const std::logic_error &) + { + throw EXCEPTION::VcdException(EXCEPTION::Error::EMPTY_VALIDATION_LIST, + "Empty argument initialization list."); + } + + cli->Parse(argc, argv); // Get input sources. - const std::vector &in_parameters = cli.GetInputSources(); + const std::vector &in_parameters = cli->GetInputSources(); // Merging unit. - MERGE::Merge merge(cli.IsVerboseMode(), - cli.GetTimeBase()); + MERGE::Merge merge(cli->IsVerboseMode(), + cli->GetTimeBase()); // All added sources. std::vector> in_sources; + // One signal descriptors registry for all sources. + SIGNAL::SignalDescriptorRegistry SignalDescriptorRegistry; + // There must be at least 2 files to be merged. if (in_parameters.size() < 2) { @@ -66,8 +82,9 @@ int main(int argc, const char *argv[]) for (const std::string &source : in_parameters) { in_sources.push_back(std::make_unique(source, + SignalDescriptorRegistry, SIGNAL::SourceRegistry::GetInstance(), - cli.IsVerboseMode())); + cli->IsVerboseMode())); merge.AddSource(in_sources.back().get()); } @@ -83,8 +100,8 @@ int main(int argc, const char *argv[]) merge.Run(); // Create the VCD tracer and dump the output file. - TRACER::VCDTracer vcd_trace(cli.GetOutputFileName(), merge.GetSignals()); - std::cout << '\n' << "Dumping " << cli.GetOutputFileName() << '\n'; + TRACER::VCDTracer vcd_trace(cli->GetOutputFileName(), merge.GetSignals()); + std::cout << '\n' << "Dumping " << cli->GetOutputFileName() << '\n'; vcd_trace.Dump(); } catch (const EXCEPTION::VcdException &rException) diff --git a/sources/vcdMerge/test/functional/test.xml b/sources/vcdMerge/test/functional/test.xml index 702c652..0160263 100644 --- a/sources/vcdMerge/test/functional/test.xml +++ b/sources/vcdMerge/test/functional/test.xml @@ -11,6 +11,7 @@ A sample test definition (containing all tags): False output_filename golden_filename + standard_output_filename output_time_unit @@ -48,6 +49,7 @@ A sample test definition (containing all tags): False test0_us.output test0_us.vcd + test0_us.std @@ -80,6 +82,7 @@ A sample test definition (containing all tags): False test0_ns.output test0_ns.vcd + test0_ns.std ns @@ -113,6 +116,7 @@ A sample test definition (containing all tags): False test0_ms.output test0_ms.vcd + test0_ms.std ms @@ -146,6 +150,7 @@ A sample test definition (containing all tags): False test1_us.output test1_us.vcd + test1_us.std @@ -178,6 +183,7 @@ A sample test definition (containing all tags): False test1_ns.output test1_ns.vcd + test1_ns.std ns @@ -211,6 +217,7 @@ A sample test definition (containing all tags): False test1_ms.output test1_ms.vcd + test1_ms.std ms @@ -245,6 +252,7 @@ A sample test definition (containing all tags): False ul_test0_us.output test0_us.vcd + test0_us_ul.std @@ -277,6 +285,7 @@ A sample test definition (containing all tags): False ul_test0_ns.output test0_ns.vcd + test0_ns_ul.std ns @@ -310,6 +319,7 @@ A sample test definition (containing all tags): False ul_test0_ms.output test0_ms.vcd + test0_ms_ul.std ms @@ -343,6 +353,7 @@ A sample test definition (containing all tags): False ul_test1_us.output test1_us.vcd + test1_us_ul.std @@ -375,6 +386,7 @@ A sample test definition (containing all tags): False ul_test1_ns.output test1_ns.vcd + test1_ns_ul.std ns @@ -408,6 +420,7 @@ A sample test definition (containing all tags): False ul_test1_ms.output test1_ms.vcd + test1_ms_ul.std ms diff --git a/sources/vcdMerge/test/functional/test0_ms.std b/sources/vcdMerge/test/functional/test0_ms.std new file mode 100644 index 0000000..b6f5209 --- /dev/null +++ b/sources/vcdMerge/test/functional/test0_ms.std @@ -0,0 +1,18 @@ +Reading sources + +T,71050601,us,System1,Counter,system1_time1.txt + +Parsed system1_time1.txt: +Valid lines: 7255 +Invalid lines: 2 + +T,234256037,us,System2,Counter,system2_time2.txt + +Parsed system2_time2.txt: +Valid lines: 4352 +Invalid lines: 1 + +Merging sources + +Dumping test0_ms.output + diff --git a/sources/vcdMerge/test/functional/test0_ms.vcd b/sources/vcdMerge/test/functional/test0_ms.vcd index 4f766ff..c74d811 100644 --- a/sources/vcdMerge/test/functional/test0_ms.vcd +++ b/sources/vcdMerge/test/functional/test0_ms.vcd @@ -1,6 +1,6 @@ -$date December 8, 2014 14:15:00 +$date Tue Dec 18 17:57:25 2018 $end -$version VCD Tracer "Nestor" Release v.3.0.1 +$version VCD Tracer "Nestor" Release v.3.0.2 $end $timescale 1 ms $end @@ -63,6 +63,7 @@ $scope module System2 $end $upscope $end $upscope $end $upscope $end +$enddefinitions $end $dumpvars bx System1.Disco.Buttons.Center bx System1.Disco.Buttons.Down diff --git a/sources/vcdMerge/test/functional/test0_ms_ul.std b/sources/vcdMerge/test/functional/test0_ms_ul.std new file mode 100644 index 0000000..be0da7a --- /dev/null +++ b/sources/vcdMerge/test/functional/test0_ms_ul.std @@ -0,0 +1,18 @@ +Reading sources + +U{..vcdMaker.xml},71050601,us,System1,Counter,system1_time1.txt + +Parsed system1_time1.txt: +Valid lines: 7255 +Invalid lines: 2 + +U{..vcdMaker.xml},234256037,us,System2,Counter,system2_time2.txt + +Parsed system2_time2.txt: +Valid lines: 4352 +Invalid lines: 1 + +Merging sources + +Dumping ul_test0_ms.output + diff --git a/sources/vcdMerge/test/functional/test0_ns.std b/sources/vcdMerge/test/functional/test0_ns.std new file mode 100644 index 0000000..7142bef --- /dev/null +++ b/sources/vcdMerge/test/functional/test0_ns.std @@ -0,0 +1,18 @@ +Reading sources + +T,71050601,us,System1,Counter,system1_time1.txt + +Parsed system1_time1.txt: +Valid lines: 7255 +Invalid lines: 2 + +T,234256037,us,System2,Counter,system2_time2.txt + +Parsed system2_time2.txt: +Valid lines: 4352 +Invalid lines: 1 + +Merging sources + +Dumping test0_ns.output + diff --git a/sources/vcdMerge/test/functional/test0_ns.vcd b/sources/vcdMerge/test/functional/test0_ns.vcd index 891e84b..824f8c4 100644 --- a/sources/vcdMerge/test/functional/test0_ns.vcd +++ b/sources/vcdMerge/test/functional/test0_ns.vcd @@ -1,6 +1,6 @@ -$date December 8, 2014 14:15:00 +$date Tue Dec 18 17:57:25 2018 $end -$version VCD Tracer "Nestor" Release v.3.0.1 +$version VCD Tracer "Nestor" Release v.3.0.2 $end $timescale 1 ns $end @@ -63,6 +63,7 @@ $scope module System2 $end $upscope $end $upscope $end $upscope $end +$enddefinitions $end $dumpvars bx System1.Disco.Buttons.Center bx System1.Disco.Buttons.Down diff --git a/sources/vcdMerge/test/functional/test0_ns_ul.std b/sources/vcdMerge/test/functional/test0_ns_ul.std new file mode 100644 index 0000000..d243f0b --- /dev/null +++ b/sources/vcdMerge/test/functional/test0_ns_ul.std @@ -0,0 +1,18 @@ +Reading sources + +T,71050601,us,System1,Counter,system1_time1.txt + +Parsed system1_time1.txt: +Valid lines: 7255 +Invalid lines: 2 + +U{..vcdMaker.xml},234256037,us,System2,Counter,system2_time2.txt + +Parsed system2_time2.txt: +Valid lines: 4352 +Invalid lines: 1 + +Merging sources + +Dumping ul_test0_ns.output + diff --git a/sources/vcdMerge/test/functional/test0_us.std b/sources/vcdMerge/test/functional/test0_us.std new file mode 100644 index 0000000..8c68cec --- /dev/null +++ b/sources/vcdMerge/test/functional/test0_us.std @@ -0,0 +1,18 @@ +Reading sources + +T,71050601,us,System1,Counter,system1_time1.txt + +Parsed system1_time1.txt: +Valid lines: 7255 +Invalid lines: 2 + +T,234256037,us,System2,Counter,system2_time2.txt + +Parsed system2_time2.txt: +Valid lines: 4352 +Invalid lines: 1 + +Merging sources + +Dumping test0_us.output + diff --git a/sources/vcdMerge/test/functional/test0_us.vcd b/sources/vcdMerge/test/functional/test0_us.vcd index 26985e6..6ec01ab 100644 --- a/sources/vcdMerge/test/functional/test0_us.vcd +++ b/sources/vcdMerge/test/functional/test0_us.vcd @@ -1,6 +1,6 @@ -$date December 8, 2014 14:15:00 +$date Tue Dec 18 17:57:25 2018 $end -$version VCD Tracer "Nestor" Release v.3.0.1 +$version VCD Tracer "Nestor" Release v.3.0.2 $end $timescale 1 us $end @@ -63,6 +63,7 @@ $scope module System2 $end $upscope $end $upscope $end $upscope $end +$enddefinitions $end $dumpvars bx System1.Disco.Buttons.Center bx System1.Disco.Buttons.Down diff --git a/sources/vcdMerge/test/functional/test0_us_ul.std b/sources/vcdMerge/test/functional/test0_us_ul.std new file mode 100644 index 0000000..cb9694a --- /dev/null +++ b/sources/vcdMerge/test/functional/test0_us_ul.std @@ -0,0 +1,18 @@ +Reading sources + +U{..vcdMaker.xml},71050601,us,System1,Counter,system1_time1.txt + +Parsed system1_time1.txt: +Valid lines: 7255 +Invalid lines: 2 + +T,234256037,us,System2,Counter,system2_time2.txt + +Parsed system2_time2.txt: +Valid lines: 4352 +Invalid lines: 1 + +Merging sources + +Dumping ul_test0_us.output + diff --git a/sources/vcdMerge/test/functional/test1_ms.std b/sources/vcdMerge/test/functional/test1_ms.std new file mode 100644 index 0000000..695dad5 --- /dev/null +++ b/sources/vcdMerge/test/functional/test1_ms.std @@ -0,0 +1,18 @@ +Reading sources + +T,0,us,System1,Counter,system1_time1.txt + +Parsed system1_time1.txt: +Valid lines: 7255 +Invalid lines: 2 + +T,0,us,System2,Counter,system2_time1.txt + +Parsed system2_time1.txt: +Valid lines: 4352 +Invalid lines: 1 + +Merging sources + +Dumping test1_ms.output + diff --git a/sources/vcdMerge/test/functional/test1_ms.vcd b/sources/vcdMerge/test/functional/test1_ms.vcd index 2c8a288..6d03f66 100644 --- a/sources/vcdMerge/test/functional/test1_ms.vcd +++ b/sources/vcdMerge/test/functional/test1_ms.vcd @@ -1,6 +1,6 @@ -$date December 8, 2014 14:15:00 +$date Tue Dec 18 17:57:25 2018 $end -$version VCD Tracer "Nestor" Release v.3.0.1 +$version VCD Tracer "Nestor" Release v.3.0.2 $end $timescale 1 ms $end @@ -63,6 +63,7 @@ $scope module System2 $end $upscope $end $upscope $end $upscope $end +$enddefinitions $end $dumpvars bx System1.Disco.Buttons.Center bx System1.Disco.Buttons.Down diff --git a/sources/vcdMerge/test/functional/test1_ms_ul.std b/sources/vcdMerge/test/functional/test1_ms_ul.std new file mode 100644 index 0000000..6a33b2e --- /dev/null +++ b/sources/vcdMerge/test/functional/test1_ms_ul.std @@ -0,0 +1,18 @@ +Reading sources + +U{..vcdMaker.xml},0,us,System1,Counter,system1_time1.txt + +Parsed system1_time1.txt: +Valid lines: 7255 +Invalid lines: 2 + +U{..vcdMaker.xml},0,us,System2,Counter,system2_time1.txt + +Parsed system2_time1.txt: +Valid lines: 4352 +Invalid lines: 1 + +Merging sources + +Dumping ul_test1_ms.output + diff --git a/sources/vcdMerge/test/functional/test1_ns.std b/sources/vcdMerge/test/functional/test1_ns.std new file mode 100644 index 0000000..c299c76 --- /dev/null +++ b/sources/vcdMerge/test/functional/test1_ns.std @@ -0,0 +1,18 @@ +Reading sources + +T,0,us,System1,Counter,system1_time1.txt + +Parsed system1_time1.txt: +Valid lines: 7255 +Invalid lines: 2 + +T,0,us,System2,Counter,system2_time1.txt + +Parsed system2_time1.txt: +Valid lines: 4352 +Invalid lines: 1 + +Merging sources + +Dumping test1_ns.output + diff --git a/sources/vcdMerge/test/functional/test1_ns.vcd b/sources/vcdMerge/test/functional/test1_ns.vcd index dbe37fb..f3e2d8b 100644 --- a/sources/vcdMerge/test/functional/test1_ns.vcd +++ b/sources/vcdMerge/test/functional/test1_ns.vcd @@ -1,6 +1,6 @@ -$date December 8, 2014 14:15:00 +$date Tue Dec 18 17:57:25 2018 $end -$version VCD Tracer "Nestor" Release v.3.0.1 +$version VCD Tracer "Nestor" Release v.3.0.2 $end $timescale 1 ns $end @@ -63,6 +63,7 @@ $scope module System2 $end $upscope $end $upscope $end $upscope $end +$enddefinitions $end $dumpvars bx System1.Disco.Buttons.Center bx System1.Disco.Buttons.Down diff --git a/sources/vcdMerge/test/functional/test1_ns_ul.std b/sources/vcdMerge/test/functional/test1_ns_ul.std new file mode 100644 index 0000000..4135f66 --- /dev/null +++ b/sources/vcdMerge/test/functional/test1_ns_ul.std @@ -0,0 +1,18 @@ +Reading sources + +T,0,us,System1,Counter,system1_time1.txt + +Parsed system1_time1.txt: +Valid lines: 7255 +Invalid lines: 2 + +U{..vcdMaker.xml},0,us,System2,Counter,system2_time1.txt + +Parsed system2_time1.txt: +Valid lines: 4352 +Invalid lines: 1 + +Merging sources + +Dumping ul_test1_ns.output + diff --git a/sources/vcdMerge/test/functional/test1_us.std b/sources/vcdMerge/test/functional/test1_us.std new file mode 100644 index 0000000..3a6437a --- /dev/null +++ b/sources/vcdMerge/test/functional/test1_us.std @@ -0,0 +1,18 @@ +Reading sources + +T,0,us,System1,Counter,system1_time1.txt + +Parsed system1_time1.txt: +Valid lines: 7255 +Invalid lines: 2 + +T,0,us,System2,Counter,system2_time1.txt + +Parsed system2_time1.txt: +Valid lines: 4352 +Invalid lines: 1 + +Merging sources + +Dumping test1_us.output + diff --git a/sources/vcdMerge/test/functional/test1_us.vcd b/sources/vcdMerge/test/functional/test1_us.vcd index 93648a8..2193fdc 100644 --- a/sources/vcdMerge/test/functional/test1_us.vcd +++ b/sources/vcdMerge/test/functional/test1_us.vcd @@ -1,6 +1,6 @@ -$date December 8, 2014 14:15:00 +$date Tue Dec 18 17:57:25 2018 $end -$version VCD Tracer "Nestor" Release v.3.0.1 +$version VCD Tracer "Nestor" Release v.3.0.2 $end $timescale 1 us $end @@ -63,6 +63,7 @@ $scope module System2 $end $upscope $end $upscope $end $upscope $end +$enddefinitions $end $dumpvars bx System1.Disco.Buttons.Center bx System1.Disco.Buttons.Down diff --git a/sources/vcdMerge/test/functional/test1_us_ul.std b/sources/vcdMerge/test/functional/test1_us_ul.std new file mode 100644 index 0000000..a70dc68 --- /dev/null +++ b/sources/vcdMerge/test/functional/test1_us_ul.std @@ -0,0 +1,18 @@ +Reading sources + +U{..vcdMaker.xml},0,us,System1,Counter,system1_time1.txt + +Parsed system1_time1.txt: +Valid lines: 7255 +Invalid lines: 2 + +T,0,us,System2,Counter,system2_time1.txt + +Parsed system2_time1.txt: +Valid lines: 4352 +Invalid lines: 1 + +Merging sources + +Dumping ul_test1_us.output + diff --git a/test/functional/executor.py b/test/functional/executor.py index d7cdd32..dcfa490 100644 --- a/test/functional/executor.py +++ b/test/functional/executor.py @@ -2,7 +2,7 @@ # # The common test executor. # -# Copyright (c) 2017 vcdMaker team +# Copyright (c) 2019 vcdMaker team # # Permission is hereby granted, free of charge, to any person obtaining a # copy of this software and associated documentation files (the "Software"), @@ -44,6 +44,8 @@ def __init__(self, executable, tests, verbose): self.tests = tests self.output_filename = '' self.golden_filename = '' + self.stdout_filename = '' + self.stdout_output = '' self.verbose = verbose def run(self): @@ -57,26 +59,42 @@ def run(self): """ failed = 0 passed = 0 + for test in self.tests: cmd = [self.executable, *test.get_command()] + self.output_filename = test.get_output_file() + self.golden_filename = test.get_golden_file() + self.stdout_filename = test.get_stdout_file() + self.stdout_output = test.get_stdout_file() + '.txt' + ret = subprocess.run(cmd, stdout=subprocess.PIPE, + stderr=subprocess.PIPE) if self.verbose: print('TEST: ', test.get_name()) print('DESCRIPTION: ', test.get_description()) print('RUNNING: ', *cmd) - ret = subprocess.run(cmd, stdout=subprocess.PIPE, - stderr=subprocess.STDOUT) print(ret.stdout.decode(sys.stdout.encoding)) - else: - ret = subprocess.run(cmd, stdout=subprocess.DEVNULL, - stderr=subprocess.DEVNULL) - if ret.returncode != 0: + + if ret.returncode == 0: + with open(self.stdout_output, 'w', newline='') as stdout_file: + print(ret.stdout.decode(sys.stdout.encoding), file=stdout_file) + stdout_file.close() + + if ret.returncode != 0 and self.golden_filename is not None: print('Test FAILED for an unknown reason.') failed += 1 continue - self.output_filename = test.get_output_file() - self.golden_filename = test.get_golden_file() - if self.is_gold_and_output_equal(): - os.remove(test.get_output_file()) + + if ret.returncode != 0 and self.golden_filename is None: + with open(self.stdout_output, 'w', newline='') as stdout_file: + print(ret.stderr.decode(sys.stderr.encoding), file=stdout_file) + stdout_file.close() + + if self.is_gold_and_output_equal() and self.is_standard_output_equal(): + try: + os.remove(test.get_output_file()) + except OSError: + pass + os.remove(self.stdout_output) passed += 1 else: failed += 1 @@ -89,6 +107,9 @@ def is_gold_and_output_equal(self): True if the golden and the output are equal, false otherwise. """ + if not self.golden_filename: + return True + with open(self.golden_filename) as golden_file, open(self.output_filename) as output_file: if not self.is_date_equal(golden_file, output_file): @@ -103,6 +124,29 @@ def is_gold_and_output_equal(self): print('PASS: {} EQUALS {}'.format(self.output_filename, self.golden_filename)) return True + def is_standard_output_equal(self): + """Compares the standard output with the reference file. + + Returns: + True if the standard output and the reference file are equal, false otherwise. + """ + + line_number = 1 + with open(self.stdout_filename) as stdout_ref, open(self.stdout_output) as stdout_out: + for stdout_line, stdref_line in itertools.zip_longest(stdout_out, stdout_ref): + if os.name == 'nt': + stdout_line = re.sub(r'(\w+\\[^\s,\.\{]+\\)', '', stdout_line) + else: + stdout_line = re.sub(r'(\/[^\s,\.\{]+\/)', '', stdout_line) + stdref_line = re.sub(r'(\/[^\s,\.\{]+\/)', '', stdref_line) + if stdout_line != stdref_line: + print('FAIL: STDOUT DOESN\'T EQUAL {} AT LINE {}'.format(self.stdout_filename, line_number)) + return False + line_number += 1 + + print('PASS: STDOUT EQUALS {}'.format(self.output_filename)) + return True + def is_date_equal(self, golden_file, output_file): """Compares dates. @@ -117,7 +161,7 @@ def is_date_equal(self, golden_file, output_file): golden_file.readline() output_date_line = output_file.readline() - if not re.match(r'\$date\s+[a-zA-Z]{3} [a-zA-Z]{3} \d\d \d\d:\d\d:\d\d \d{4}', + if not re.match(r'\$date\s+[a-zA-Z]{3} [a-zA-Z]{3} {1,2}\d{1,2} \d\d:\d\d:\d\d \d{4}', output_date_line): print('FAIL: DATE WRONG IN {}'.format(self.output_filename)) return False diff --git a/test/functional/flat.py b/test/functional/flat.py index e5981da..707a0f5 100644 --- a/test/functional/flat.py +++ b/test/functional/flat.py @@ -2,7 +2,7 @@ # # A storage for parameters read from a flat (not tested) XML structure. # -# Copyright (c) 2017 vcdMaker team +# Copyright (c) 2019 vcdMaker team # # Permission is hereby granted, free of charge, to any person obtaining a # copy of this software and associated documentation files (the "Software"), @@ -37,9 +37,9 @@ def __init__(self, node, parameters): parameters to be read. Example: - parameters = {'name': ['', ''], - 'output_file': ['', 'Missing output file'], - 'golden_file': ['', 'Missing golden file']} + parameters = {'output_file': ['', 'Missing output file'], + 'golden_file': ['', ''], + 'stdout_file': ['', '']} The 'key' is the name of the parameter to be read. @@ -93,7 +93,8 @@ def __init__(self, node, test_directory): test parameters. """ self.common_params = {'output_file': ['', 'Missing output file'], - 'golden_file': ['', 'Missing golden file']} + 'golden_file': ['', ''], + 'stdout_file': ['', '']} self.test_directory = test_directory Flat.__init__(self, node, self.common_params) @@ -106,9 +107,16 @@ def get_output_file(self): def get_golden_file(self): """Returns the absolute golden file path.""" + if self.get_parameter('golden_file'): + return os.path.join(self.test_directory, + self.get_parameter('golden_file')) + return None + + def get_stdout_file(self): + """Returns the absolute standard output file path.""" return os.path.join(self.test_directory, - self.get_parameter('golden_file')) + self.get_parameter('stdout_file')) class InfoFlat(Flat): diff --git a/test/functional/maker.py b/test/functional/maker.py index c64b58f..5869d93 100644 --- a/test/functional/maker.py +++ b/test/functional/maker.py @@ -2,7 +2,7 @@ # # A class representing vcdMaker specific test. # -# Copyright (c) 2017 vcdMaker team +# Copyright (c) 2019 vcdMaker team # # Permission is hereby granted, free of charge, to any person obtaining a # copy of this software and associated documentation files (the "Software"), @@ -61,7 +61,7 @@ def create_command(self, test_directory): if self.unique.get_parameter('line_counter'): self.command.append('-c') self.command.append(self.unique.get_parameter('line_counter')) - + if self.unique.get_parameter('user_format'): self.command.append('-u') self.command.append(self.unique.get_parameter('user_format')) diff --git a/test/functional/test.py b/test/functional/test.py index 0071b66..60b6c6e 100644 --- a/test/functional/test.py +++ b/test/functional/test.py @@ -2,7 +2,7 @@ # # The base test class. # -# Copyright (c) 2017 vcdMaker team +# Copyright (c) 2019 vcdMaker team # # Permission is hereby granted, free of charge, to any person obtaining a # copy of this software and associated documentation files (the "Software"), @@ -57,6 +57,11 @@ def get_golden_file(self): return self.common.get_golden_file() + def get_stdout_file(self): + """Returns the absolute path to the test standard output file.""" + + return self.common.get_stdout_file() + def get_name(self): """Returns the test name.""" diff --git a/windows/Bootstrapper/Bundle.wxs b/windows/Bootstrapper/Bundle.wxs index 544c995..0f7b71a 100644 --- a/windows/Bootstrapper/Bundle.wxs +++ b/windows/Bootstrapper/Bundle.wxs @@ -5,7 +5,7 @@ xmlns:util="http://schemas.microsoft.com/wix/UtilExtension" xmlns:bal="http://schemas.microsoft.com/wix/BalExtension"> - + - + Maximum='3.0.2' IncludeMaximum='no' /> @@ -28,25 +28,25 @@ - + - + - + - + @@ -68,7 +68,7 @@ - + diff --git a/windows/Installer/guid_list.txt b/windows/Installer/guid_list.txt index c8aafc4..b2b608c 100644 --- a/windows/Installer/guid_list.txt +++ b/windows/Installer/guid_list.txt @@ -1,14 +1,14 @@ vcdMaker: {3A563016-E31D-4D93-A36B-105420BA6E57} vcdMaker UpgradeCode -vcdMaker 1.0: +vcdMaker 1.0.1: {0E0B8006-8388-4DC6-B2A2-1EA0E6A954B7} vcdMaker ProductId {CF176F63-6DA4-45A6-837B-CD1AFF3F5C12} vcdMakerExecutable Component {82B593FF-F018-4D28-87F3-A253FE5D4F7D} vcdMakerManual Component {C87B5829-C991-4527-9D16-3507C907395F} SampleFiles Component {FE343CAE-C7B4-47DF-B133-FAAC5F90F2DF} ProgramMenuDir Component -vcdMaker 2.0: +vcdMaker 2.0.1: {E11FE905-A80F-4764-B77C-AC7EADDF98CE} vcdMaker ProductId {5A12ED7E-8977-44D3-BB79-70B7130718F2} vcdMakerExecutable Component {F3A2D8F6-2FE0-4CE9-9A67-C41BBF3F5824} vcdMakerManual Component @@ -16,19 +16,22 @@ vcdMaker 2.0: {8CE0301F-EEC9-4696-B0E8-74F9C1942495} ProgramMenuDir Component {4D660398-6AB3-4B41-BD90-D77581B91A89} vcdMergeExecutable Component -vcdMaker 3.0: +vcdMaker 3.0.1: {3A142969-4CD6-48F2-AB64-D44F690E7193} vcdMaker ProductId {15247FDC-7EA8-4931-B96A-DD3B3926B74E} vcdMakerExecutable Component {11B39AA4-49B4-4D18-AE33-3D278BC8BE84} vcdMakerManual Component {59F4E01F-5FE3-48B3-97A2-8E7808E6EED7} SampleFiles Component {59CBFDEC-3666-4313-9DF6-D6B97768FFD5} ProgramMenuDir Component {2E82E953-9A3F-4AC0-A4C0-9F352C0ACDF1} vcdMergeExecutable Component -{D6123246-8A68-41DB-84BE-F4F690AEC966} -{80B54EC5-B55B-4046-BD32-7B7E2466A3D0} -{CBBA9EBF-0FF3-4A3E-ABE5-04D7689C4456} -{DB87BE16-F437-4FB2-9A6A-07A0CDFB54EE} -{8A677339-2E3E-483C-B102-224988E9FDA8} -{722D9BF2-8D84-4FD7-807A-A77C852B712B} + +vcdMaker 3.0.2: +{D6123246-8A68-41DB-84BE-F4F690AEC966} vcdMaker ProductId +{80B54EC5-B55B-4046-BD32-7B7E2466A3D0} vcdMakerExecutable Component +{CBBA9EBF-0FF3-4A3E-ABE5-04D7689C4456} vcdMakerManual Component +{DB87BE16-F437-4FB2-9A6A-07A0CDFB54EE} SampleFiles Component +{8A677339-2E3E-483C-B102-224988E9FDA8} ProgramMenuDir Component +{722D9BF2-8D84-4FD7-807A-A77C852B712B} vcdMergeExecutable Component + {0A77D082-22B4-42BB-BD23-754C463C30F4} {B29D4B89-2580-4A69-BD4D-33941FD9446D} {7A6FB76B-45F8-4E4C-9381-399D128E6983} diff --git a/windows/Installer/version.wxi b/windows/Installer/version.wxi index 7e8370b..261287f 100644 --- a/windows/Installer/version.wxi +++ b/windows/Installer/version.wxi @@ -1,4 +1,4 @@ - + diff --git a/windows/vcdMaker/vcdMakerCore/vcdMakerCore.vcxproj b/windows/vcdMaker/vcdMakerCore/vcdMakerCore.vcxproj index d96164d..073910b 100644 --- a/windows/vcdMaker/vcdMakerCore/vcdMakerCore.vcxproj +++ b/windows/vcdMaker/vcdMakerCore/vcdMakerCore.vcxproj @@ -152,10 +152,13 @@ + + + @@ -186,6 +189,8 @@ + + diff --git a/windows/vcdMaker/vcdMakerCore/vcdMakerCore.vcxproj.filters b/windows/vcdMaker/vcdMakerCore/vcdMakerCore.vcxproj.filters index 266da69..03c4e70 100644 --- a/windows/vcdMaker/vcdMakerCore/vcdMakerCore.vcxproj.filters +++ b/windows/vcdMaker/vcdMakerCore/vcdMakerCore.vcxproj.filters @@ -110,6 +110,15 @@ Header Files + + Header Files + + + Header Files + + + Header Files + @@ -184,5 +193,11 @@ Source Files + + Source Files + + + Source Files + \ No newline at end of file