diff --git a/.gitignore b/.gitignore index 6c38e62..a697307 100644 --- a/.gitignore +++ b/.gitignore @@ -27,24 +27,15 @@ *.vcxproj.user version-* -.vs/ +priv*/ +bin*/ html/ latex/ -test_priv/ -bin/*.exe -bin/*.dll -bin/*.conf -bin/qspy -bin/qclean -bin/qfsgen gnu_arm-eabi/ libexec/ -dbg/ -rel/ -spy/ -settings/ share/ +.vs/ Debug/ Release/ Spy/ @@ -52,5 +43,3 @@ Spy/ lib/ obj/ output/ - -qspy/doxygen/html/ diff --git a/CMakeLists.txt b/CMakeLists.txt deleted file mode 100644 index 3ea7bf6..0000000 --- a/CMakeLists.txt +++ /dev/null @@ -1,68 +0,0 @@ -# use a recent CMake version -cmake_minimum_required(VERSION 3.23 FATAL_ERROR) -cmake_policy(VERSION 3.23) -cmake_policy(SET CMP0083 NEW) - -# first of all protect against in-source builds -file(REAL_PATH "${CMAKE_SOURCE_DIR}" _srcdir) -file(REAL_PATH "${CMAKE_BINARY_DIR}" _bindir) - -if(${_srcdir} STREQUAL ${_bindir}) - message(FATAL_ERROR " FATAL: In-source builds are not allowed! - You should create a separate directory for build files.") -endif() -unset(_srcdir) -unset(_bindir) - -# update CMAKE_MODULE_PATH -list(PREPEND CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/source/cmake ${CMAKE_SOURCE_DIR}/cmake ${CMAKE_SOURCE_DIR} ${HOME_PATH}/cmake) - -if(NOT SW_VERSION) - set(SW_VERSION "7.3.3" CACHE STRING "Software Version") -endif() - -message(STATUS "`qtools` - see \"https://www.state-machine.com/qtools/\" for further details.") - -# the `qtools` project, consisting of the tools listed below -# qtools - https://www.state-machine.com/qtools/ -project( - qtools - VERSION ${SW_VERSION} - DESCRIPTION "QTools - https://www.state-machine.com/qtools/" - HOMEPAGE_URL "https://www.state-machine.com/qtools/" - LANGUAGES C -) - -# select target platform specific source directory -if(WIN32 OR CMAKE_SYSTEM_NAME STREQUAL Windows) - set(PLATFORM_DIR win32) -else() - set(PLATFORM_DIR posix) -endif() - -# the qclean tool - https://www.state-machine.com/qtools/qclean.html -add_executable(qclean) -add_subdirectory(qclean) - -# the qfsgen tool - https://www.state-machine.com/qtools/qfsgen.html -add_executable(qfsgen) -add_subdirectory(qfsgen) - -# the qspy tool - https://www.state-machine.com/qtools/qspy.html -add_executable(qspy) -add_subdirectory(qspy) - -# the `install` targets -set(QDATAROOT share/qtools) -set(QTARGETS qclean qfsgen qspy) -set(QDIRS qcalc qutest qview qwin) -set(QBIN cmock generate_test_runner python3 qcalc qspy_exit sha256) -list(TRANSFORM QBIN APPEND .bat) -list(APPEND QBIN Termite.ini) -list(TRANSFORM QBIN PREPEND bin/) - -install(TARGETS ${QTARGETS}) -install(PROGRAMS ${BIN_FILES} TYPE BIN) -install(DIRECTORY doc LICENSES DESTINATION ${QDATAROOT}/doc) -install(FILES README.md DESTINATION ${QDATAROOT}/doc) -install(DIRECTORY ${QDIRS} DESTINATION ${QDATAROOT}/data) diff --git a/CMakePresets.json b/CMakePresets.json deleted file mode 100644 index c60f449..0000000 --- a/CMakePresets.json +++ /dev/null @@ -1,38 +0,0 @@ -{ - "version": 6, - "cmakeMinimumRequired": { - "major": 3, - "minor": 23, - "patch": 0 - }, - - "configurePresets": [ - { - "name": "qtools", - "displayName": "qtools", - "description": "Build all qtools", - "binaryDir": "${sourceDir}/build", - "generator": "Ninja Multi-Config", - "cacheVariables": { - "CMAKE_CONFIGURATION_TYPES": { - "type": "STRING", - "value": "Debug;Release" - }, - "CMAKE_BUILD_TYPE": { - "type": "STRING", - "value": "Debug" - } - } - } - ], - - "buildPresets": [ - { - "name": "qtools", - "displayName": "qtools", - "description": "Build all qtools", - "configurePreset": "qtools", - "configuration": "Release" - } - ] -} diff --git a/LICENSES/LICENSE-qspy.txt b/LICENSES/LICENSE-qspy.txt new file mode 100644 index 0000000..d7e08c6 --- /dev/null +++ b/LICENSES/LICENSE-qspy.txt @@ -0,0 +1,85 @@ +QUANTUM LEAPS QSPY SOFTWARE TRACING HOST UTILITY SOFTWARE +END USER LICENSE AGREEMENT + +These license terms are an agreement between Quantum Leaps and you. +Please read them. They apply to the QSPY tool as well as to any +accompanying documentation and examples. BY USING THE SOFTWARE, YOU ACCEPT +THESE TERMS. IF YOU DO NOT ACCEPT THEM, DO NOT USE THE SOFTWARE. + + +1. DEFINITIONS +1.1. QSPY is a console-based software tracing host utilty for receiving, +visualizing, and communicating with the remote Target systems running +QP/Spy tracing software. QSPY provides textual output to the screen and +various network interfaces to communicate with the external applications +(e.g., QUTest testing or QView monitoring). QSPY is currently available for +Windows, Linux and macOS hosts. + +1.2. QP/Spy software tracing system is part of the QP Real-Time Embedded +Frameworks (RTEFs). + +1.3. "Licensed Software" means the QSPY executable, documentation, and +examples. The Licensed Software expressly does NOT include the products of +software tracing, such as the saved binary files, screen output logs, +"dictionary" files, or generated sequence diagrams. + + +2. GRANT OF COPYRIGHT LICENSE +Quantum Leaps grants to you, and you hereby accept, a nonexclusive, +nontransferable license to do the following: + +2.1. to install and use the QSPY software for the purpose of tracing, +testing, and monitoring your programs. + +3. EXCLUSIONS FROM LICENSE GRANT +The Licensed Software is licensed by this Agreement, not sold or given away. +This Agreement only grants you some rights to use the software. Quantum Leaps +reserves all other rights. + +3.1. No right is granted to trademarks, copyrights, patents, trade secrets or +any other Intellectual Property of Quantum Leaps, even if such trademarks are +included in the Licensed Software. + +3.2. Nothing in this Agreement shall be interpreted to prohibit Quantum Leaps +from licensing under different terms from this Agreement any original work +that Quantum Leaps otherwise would have a right to license. + + +4. LIMITATIONS ON THE USE OF THE LICENSED SOFTWARE +You may use the Licensed Software only as expressly permitted in this +Agreement. In doing so, you must comply with any technical limitations in +the software that only allow you to use it in certain ways. By accepting +this Agreement you agree to the following: + +4.1. You may not remove or modify any copyright notes, legal notes, license +information, attribution notes, logos, URLs, or e-mail addresses embedded in +the source code generated by QM, or in the QM executable and in the QSPY +documentation; + +4.2. You may not sell, rent, lease or lend the Licensed Software; and + +4.3. You may not use the Licensed Software to create similar stand-alone +products based on the QP/Spy software tracing system. + + +5. DISCLAIMER OF WARRANTY +BECAUSE THE QM SOFTWARE IS LICENSED FREE OF CHARGE, IT IS LICENSED "AS IS" +WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT +NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF +THE LICENSED SOFTWARE IS WITH YOU. SHOULD THE SOFTWARE PROVE DEFECTIVE, +YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. + +IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW SHALL QUANTUM LEAPS BE LIABLE +TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR +CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OF OR INABILITY TO USE THE +LICENSED SOFTWARE (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING +RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE +OF THE SOFTWARE TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR +OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. NO LICENSE +TO THE LICENSED SOFTWARE IS GRANTED HEREUNDER EXCEPT UNDER THIS DISCLAIMER. + +6. CONTACT INFORMATION +Any questions or concerns related to this Agreement should be directed to +Quantum Leaps at the following e-mail address: +- mailto:info@state-machine.com diff --git a/LICENSES/LICENSE.txt b/LICENSES/LICENSE.txt index bd703d7..1c1225c 100644 --- a/LICENSES/LICENSE.txt +++ b/LICENSES/LICENSE.txt @@ -1,33 +1,30 @@ -QTools Collection -================= -Most tools included in the QTools collection for Windows are distributed -under the terms of the GNU General Public License (GPL) as published by -the Free Software Foundation, either version 2 of the License, or (at -your option) any later version. The text of GPL version 2 is included -in the file qtools/LICENSES/GPL-2.0-or-later.txt. - -Some of the tools are distributed under the terms of the MIT open source -license. The complete text of the MIT license is included in the file -qtools/LICENSES/LICENSE-MIT.txt as well as in the source code comments. - -The Python package is distributed under the terms of the PYTHON LICENSE -AGREEMENT, included in the file PYTHON_LICENSE.txt in the file -qtools/LICENSES/LICENSE-Python.txt. - -The LMFlash utility for Windows is is distributed under the terms -of the LMFlash license, included in the file: -qtools/LICENSES/LICENSE-LMFlash.txt - -Specifically, the LMFlash utility is distributed according to Section 2a -"Demonstration License". - -The freewaer Termite utility for Windows is is distributed under the terms -of the zlib/libpng License included in the file: -qtools/LICENSES/LICENS-Termite.txt - - -Contact Information: -============= -- https://www.state-machine.com -- mailto:info@state-machine.com - +The various licenses for QTools components are located in the +LICENSES/ sub-directory of this QTools distribution. + +- The [qspy host utility](https://www.state-machine.com/qtools/qspy.html) +is distributed under the terms of QSPY LICENSE AGREEMENT, included in the file +`LICENSE-qspy.txt` in the `LICENSES/` sub-directory. + +- The [Termite host utility for Windows](https://www.compuphase.com/software_termite.htm) +is is distributed under the terms of the Termite license, included in the file +`LICENSE-Termite.txt` in the `LICENSES/` sub-directory. + +- The [LMFlash host utility for Windows](https://www.ti.com/tool/LMFLASHPROGRAMMER) +is is distributed under the terms of the LMFlash license, included in the file +`LICENSE-LMFlash.txt` in the `LICENSES/` sub-directory. Specifically, the LMFlash +utility is distributed according to Section 2a "Demonstration License". + +- The [Python package for Windows](https://www.python.org/) is distributed +under the terms of the PYTHON LICENSE AGREEMENT, included in the file +`LICENSE-Python.txt` in the `LICENSES/` sub-directory. + +Most other tools included in this collection are distributed under the +terms of the GNU General Public License (GPL) as published by the Free +Software Foundation, either version 2 of the License, or (at your +option) any later version. The text of GPL version 2 is included in the +file GPL-2.0-or-later.txt in the `LICENSES/` sub-directory. + +Some other the tools are distributed under the terms of the MIT open +source license. The complete text of the MIT license is included in the +comments and also in the file LICENSE-MIT.txt in the `LICENSES/` +sub-directory. diff --git a/README.md b/README.md index 30fa0db..5567c80 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,8 @@ -![QTools Collection](https://www.state-machine.com/img/qtools_banner.jpg) +

+ + + +

# What's New? [![GitHub release (latest by date)](https://img.shields.io/github/v/release/QuantumLeaps/qtools)](https://github.com/QuantumLeaps/qtools/releases/latest) @@ -25,63 +29,63 @@ The following open-source tools are currently provided (NOTE: tools starting with 'q' are contributed by Quantum Leaps) 1. [qspy](https://www.state-machine.com/qtools/qspy.html) - - host application for receiving and displaying the - real-time data from embedded targets running the QS - software tracing. + host application for receiving and displaying the real-time data from + embedded targets running the QS software tracing. 2. [qutest](https://www.state-machine.com/qtools/qutest.html) - - Python extension of the QSPY host application for **uint testing** - specifically designed for embedded systems, but also supports - unit testing of embedded code on host computers - ("dual targeting"). + Python extension of the `qspy` host application for + **unit and integration testing** specifically designed for embedded systems, + but also supports unit testing of embedded code on host computers + ("dual targeting"). 3. [qview](https://www.state-machine.com/qtools/qview.html) - - Python extension of the QSPY host application for - visualization and monitoring of the QS real-time tracing - data from embedded targets at real-time. QView enables - developers to quickly build both GUI-based and "headless" - scripts for their specific applications. + Python extension of the `qspy` host application for visualization and + monitoring of the QS real-time tracing data from embedded targets at + real-time. QView enables developers to quickly build both GUI-based and + "headless" scripts for their specific applications. 4. [qwin](https://www.state-machine.com/qtools/qwin.html) - - QWIN GUI toolkit for prototyping embedded systems on - Windows in the C programming language. QWIN allows you - to build realistic embedded front panels consisting of - LCD displays (both graphical and segmented), buttons, - and LEDs. QWIN is based on the Win32 API. + QWIN GUI toolkit for prototyping embedded systems on Windows in the + C programming language. QWIN enables developers to build realistic embedded + front panels consisting of LCD displays (both graphical and segmented), + buttons, and LEDs. QWIN is based on the Win32 API. 5. [qcalc](https://www.state-machine.com/qtools/qcalc.html) - programmer's calculator specifically designed for embedded systems programmers. 6. [qclean](https://www.state-machine.com/qtools/qclean.html) - - for cleanup of white space (tabs, trailing spaces, end-of-line) in source code files + for *fast* cleanup of white space (tabs, trailing spaces, end-of-line) + in source code files 7. [qfsgen](https://www.state-machine.com/qtools/qfsgen.html) - for generating ROM-based file systems to be used in embedded web pages served by the HTTP server -8. Unity - traditional unit testing harness (framework) for embedded C - (version 2.5.2) +8. Unity - traditional unit testing harness (framework) for embedded C + (version 2.5.2) Additionally, QTools for Windows contains the following open-source, 3rd-party tools: -9. GNU-make for Windows (32-bit version 4.2.1) +9. `make` for Windows (GNU-make-32-bit version 4.2.1) -10. cmake for Windows (version 3.29.0-rc1) +10. `cmake` for Windows (version 3.29.0-rc1) -11. ninja for Windows (version 1.11.1) +11. `ninja` for Windows (version 1.11.1) -12. LMFlash for Windows (32-bit build 1613) +12. Termite serial terminal for Windows (version 3.4) + +13. LMFlash for Windows (32-bit build 1613) Additionally, the QTools directory in the QP-bundle contains the following 3rd-party tools: -13. GNU C/C++ toolset for Windows (MinGW 32-bit version 9.2.0) +14. GNU C/C++ toolset for Windows (MinGW 32-bit version 9.2.0) -14. GNU C/C++ toolset for ARM-EABI (GCC version 10.3-2021.10) +15. GNU C/C++ toolset for ARM-EABI (GCC version 10.3-2021.10) -15. Python for Windows (version 3.10 32-bit) +16. Python for Windows (version 3.10 32-bit) # Downloading and Installation @@ -107,14 +111,13 @@ On Windows, installation of QTools consists of unzipping the although the recommended default is `C:\qp`. After unzipping the archive, you need to add the following directories -to the PATH: - -- \qtools\bin -- \qtools\mingw32\bin +to the PATH (`` stands for the directory, where you installed qp): +- `\qtools\bin` +- `\qtools\mingw32\bin` -Also, to use the [QUTest unit testing][QUTest] you need to -define the environment variable `QTOOLS` to point to the -installation directory of QTools. +> NOTE: To use the [QUTest unit testing][QUTest] you need to define the +environment variable `QTOOLS` to point to the installation directory +of QTools. ## QTools on Linux/macOS @@ -122,88 +125,46 @@ On Linux/MacOS, installation of QTools consists of unzipping the `qtools-posix_.zip` archive into a directory of your choice, although the recommended default is `~/qp`. -> NOTE: To use the QTools, you first need to **build** the tools on -your machine. - -For example, to build the QSPY host application, you need to go to the -directory qtools/qspy/posix and type make to build the executable. -The provided Makefile will automatically copy the qspy executable to -the qtools/bin directory. - -Simiarly, you need to build the QCLEAN and QFSGEN utilities. - -> NOTE: To use the [QUTest unit testing][QUTest] you need to -define the environment variable `QTOOLS` to point to the -installation directory of QTools. - - -## Build using `cmake` -With the right set of C compilation tools on your Windows or Linux -computer, you can build the tools by yourself. - -On a MS-Windows machine a setup with [MSys/MinGW64](https://www.msys2.org/) is recommended to -perform the build. With this environment you will still be able to -generate MS-Windows executable applications. -Another alternative would be to install [MS Visual Studio](https://visualstudio.microsoft.com/). -`CMake` is also able to generate build systems for this development environment. -This however will not be a topic of this discussion. Please see the -[CMake Documentation](https://cmake.org/cmake/help/latest/) for further -details. Especially refer to the section on -[cmake generators](https://cmake.org/cmake/help/latest/manual/cmake-generators.7.html). - -An appropriate [CMakeLists.txt](./CMakeLists.txt) file together with a [cmake presets -file](./CMakePresets.json) is provided with this source code package. - -From within the `qtools` directory you may use `cmake` to build and -install the 3 tools. For this you need the following in addition to the tools -mentioned [above](#about-qtools) - -1. [CMake](https://cmake.org/) - build system generator ([cmake features](https://cmake.org/features/)) - -2. [Ninja](https://ninja-build.org/) - small build system with a focus on speed - -To build with `cmake` -1. From within the `qtools` directory do `cmake --preset qtools` -2. Then build with - - `cmake --build --preset qtools` to build all tools at once or - - `cmake --build --preset qtools --target ` with tool being `qclean`, `qfsgen` or `qspy` - - to build the `Debug` configuration use `cmake --build --preset qtools --config Debug` - - `Release` is the default configuration, if you don't specify a desired config -3. The binaries are created in the `.../qtools/build/` directory -4. To install - - Build the `qtools` preset then - - call `cmake --install build [--config ]` - - The default installation location would be `/usr/local/bin` on a Linux machine or within - a MinGW environment on a Windows machine. - - add `--prefix ` to the installation command line to select a different installation destination. - E.g. `cmake --install build --prefix /usr` will install the built applications from the `Release` - configuration into `/usr/bin`. On a Linux machine you might need to use `sudo` to raise your access rights - in order to install into system directories. +After unzipping the archive, you need to add the following directories +to the PATH (`` stands for the directory, where you installed qp): +- `/qtools/bin` + +> NOTE: To use the [QUTest unit testing][QUTest] you need to define the +environment variable `QTOOLS` to point to the installation directory +of QTools. # Licensing The various Licenses for distributed components are located in the LICENSES/ sub-directory of this QTools distribution. -Most tools included in this collection are distributed under the terms -of the GNU General Public License (GPL) as published by the Free -Software Foundation, either version 2 of the License, or (at your -option) any later version. The text of GPL version 2 is included in the -file GPL-2.0-or-later.txt in the LICENSES/ sub-directory. +- The [qspy host utility](https://www.state-machine.com/qtools/qspy.html) +is distributed under the terms of QSPY LICENSE AGREEMENT, included in the file +`LICENSE-qspy.txt` in the `LICENSES/` sub-directory. -Some of the tools are distributed under the terms of the MIT open source -license. The complete text of the MIT license is included in the comments -and also in the file LICENSE-MIT.txt in the LICENSES/ sub-directory. +- The [Termite host utility for Windows](https://www.compuphase.com/software_termite.htm) +is is distributed under the terms of the Termite license, included in the file +`LICENSE-Termite.txt` in the `LICENSES/` sub-directory. +- The [LMFlash host utility for Windows](https://www.ti.com/tool/LMFLASHPROGRAMMER) +is is distributed under the terms of the LMFlash license, included in the file +`LICENSE-LMFlash.txt` in the `LICENSES/` sub-directory. Specifically, the LMFlash +utility is distributed according to Section 2a "Demonstration License". -The Python package is distributed under the terms of the PYTHON LICENSE -AGREEMENT, included in the file LICENSE-Python.txt in the LICENSES/ -sub-directory. +- The [Python package for Windows](https://www.python.org/) is distributed +under the terms of the PYTHON LICENSE AGREEMENT, included in the file +`LICENSE-Python.txt` in the `LICENSES/` sub-directory. + +Most other tools included in this collection are distributed under the +terms of the GNU General Public License (GPL) as published by the Free +Software Foundation, either version 2 of the License, or (at your +option) any later version. The text of GPL version 2 is included in the +file GPL-2.0-or-later.txt in the `LICENSES/` sub-directory. -The LMFlash utility for Windows is is distributed under the terms of the -LMFlash license, included in the file LICENSE-LMFlash.txt in the LICENSES/ -sub-directory. Specifically, the LMFlash utility is distributed according -to Section 2a "Demonstration License". +Some other the tools are distributed under the terms of the MIT open +source license. The complete text of the MIT license is included in the +comments and also in the file LICENSE-MIT.txt in the `LICENSES/` +sub-directory. # Source Code @@ -222,7 +183,7 @@ the files have been pruned to reduce the size of the distribution. Please refer to the MinGW project for the source code. ### The GNU-ARM Embedded Toolchain for Windows -Have been takend from: +Have been taken from: - https://developer.arm.com/open-source/gnu-toolchain/gnu-rm/downloads The installer gcc-arm-none-eabi-8-2018-q4-major-win32-sha1.exe has been used. @@ -241,10 +202,10 @@ Has been taken from the GitHub at: # How to Help this Project? -If you like this project, please give it a star (in the upper-right corner of your browser window): - -![GitHub star](https://www.state-machine.com/img/github-star.jpg) +If you like this project, please give it a star (in the upper-right corner +of your browser window): +

# Contact information: - https://www.state-machine.com diff --git a/bin/Termite.ini b/bin/Termite.ini deleted file mode 100644 index b37cf63..0000000 --- a/bin/Termite.ini +++ /dev/null @@ -1,28 +0,0 @@ -[Settings] -Port=COM16 -Baud=115200 -DataBits=8 -StopBits=1 -Parity=0 -Handshake=0 -ForwardPort= -[Options] -LocalEcho=1 -AppendLine=0 -Window=156 1460 639 504 -FontType=1 -Polling=100 -MaxLines=0 -WordWrap=1 -AutoComplete=1 -KeepHistory=0 -CloseOnCancel=1 -Topmost=0 -AutoClosePort=0 -Language=English (en) -[History] -cmd1=x -cmd2=y -cmd3=s -cmd4=a -cmd5=dfsdfa diff --git a/bin/cmock.bat b/bin/cmock.bat deleted file mode 100644 index 8aa5948..0000000 --- a/bin/cmock.bat +++ /dev/null @@ -1 +0,0 @@ -ruby %QTOOLS%\unity\extras\cmock\lib\cmock.rb %1 %2 %3 %4 %5 %6 %7 %8 %9 \ No newline at end of file diff --git a/bin/generate_test_runner.bat b/bin/generate_test_runner.bat deleted file mode 100644 index b948bc6..0000000 --- a/bin/generate_test_runner.bat +++ /dev/null @@ -1 +0,0 @@ -ruby %QTOOLS%\unity\auto\generate_test_runner.rb %1 %2 %3 %4 %5 %6 %7 %8 %9 \ No newline at end of file diff --git a/bin/python3.bat b/bin/python3.bat deleted file mode 100644 index 9ea7d12..0000000 --- a/bin/python3.bat +++ /dev/null @@ -1,2 +0,0 @@ -@echo off -@%~dp0..\Python3\python.exe %1 %2 %3 %4 %5 %6 %7 %8 diff --git a/bin/qcalc.bat b/bin/qcalc.bat deleted file mode 100644 index 52fd70f..0000000 --- a/bin/qcalc.bat +++ /dev/null @@ -1,2 +0,0 @@ -@echo off -@%~dp0..\Python3\python.exe %~dp0..\qcalc\qcalc.py %1 %2 %3 %4 %5 %6 %7 %8 diff --git a/bin/qcalc.lnk b/bin/qcalc.lnk deleted file mode 100644 index 5a3619b..0000000 Binary files a/bin/qcalc.lnk and /dev/null differ diff --git a/bin/qspy_exit.bat b/bin/qspy_exit.bat deleted file mode 100644 index 6b0a02b..0000000 --- a/bin/qspy_exit.bat +++ /dev/null @@ -1,2 +0,0 @@ -@echo off -@%~dp0..\Python3\python.exe %~dp0..\qspy\qspy_exit.py %1 %2 %3 %4 diff --git a/bin/sha256.bat b/bin/sha256.bat deleted file mode 100644 index 8ea8b73..0000000 --- a/bin/sha256.bat +++ /dev/null @@ -1,2 +0,0 @@ -@echo off -@certutil -hashfile %1 SHA256 diff --git a/qclean/CMakeLists.txt b/qclean/CMakeLists.txt deleted file mode 100644 index 2e3e420..0000000 --- a/qclean/CMakeLists.txt +++ /dev/null @@ -1,11 +0,0 @@ -message(STATUS "`qtools/qclean` - see \"https://www.state-machine.com/qtools/qclean.html\" for further details.") - -# the main target -target_sources(qclean PRIVATE - source/main.c - source/getopt.c - ${PLATFORM_DIR}/filesearch.c -) - -# add include dirs to target (-I...) -target_include_directories(qclean PRIVATE include) diff --git a/qclean/include/qclean.h b/qclean/include/qclean.h index 00540cf..4d0a3b8 100644 --- a/qclean/include/qclean.h +++ b/qclean/include/qclean.h @@ -1,43 +1,41 @@ -/*============================================================================ -* QP/C Real-Time Embedded Framework (RTEF) -* Copyright (C) 2005 Quantum Leaps, LLC. All rights reserved. -* -* SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-QL-commercial -* -* This software is dual-licensed under the terms of the open source GNU -* General Public License version 3 (or any later version), or alternatively, -* under the terms of one of the closed source Quantum Leaps commercial -* licenses. -* -* The terms of the open source GNU General Public License version 3 -* can be found at: -* -* The terms of the closed source Quantum Leaps commercial licenses -* can be found at: -* -* Redistributions in source code must retain this top-level comment block. -* Plagiarizing this software to sidestep the license obligations is illegal. -* -* Contact information: -* -* -============================================================================*/ -/*! -* @date Last updated on: 2024-02-19 -* @version Last updated for version: 7.3.3 -* -* @file -* @brief QClean internal interface -*/ +//============================================================================ +// QClean white space cleanup host utility +// +// Q u a n t u m L e a P s +// ------------------------ +// Modern Embedded Software +// +// Copyright (C) 2005 Quantum Leaps, LLC. +// +// SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-QL-commercial +// +// This software is dual-licensed under the terms of the open source GNU +// General Public License version 3 (or any later version), or alternatively, +// under the terms of one of the closed source Quantum Leaps commercial +// licenses. +// +// The terms of the open source GNU General Public License version 3 +// can be found at: +// +// The terms of the closed source Quantum Leaps commercial licenses +// can be found at: +// +// Redistributions in source code must retain this top-level comment block. +// Plagiarizing this software to sidestep the license obligations is illegal. +// +// Contact information: +// +// +//============================================================================ #ifndef QCLEAN_H_ #define QCLEAN_H_ -#define VERSION "7.3.3" +#define VERSION "8.0.0" unsigned isMatching (char const *fullPath); void onMatchFound(char const *fullPath, unsigned flags, int ro_info); void filesearch (char const *dirname); -extern char const dir_separator; /* platform-dependent directory separator */ +extern char const dir_separator; // platform-dependent directory separator -#endif /* QCLEAN_H_ */ +#endif // QCLEAN_H_ diff --git a/qclean/include/safe_std.h b/qclean/include/safe_std.h index d8da8f0..921ea5d 100644 --- a/qclean/include/safe_std.h +++ b/qclean/include/safe_std.h @@ -1,34 +1,32 @@ -/*============================================================================ -* QP/C Real-Time Embedded Framework (RTEF) -* Copyright (C) 2005 Quantum Leaps, LLC. All rights reserved. -* -* SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-QL-commercial -* -* This software is dual-licensed under the terms of the open source GNU -* General Public License version 3 (or any later version), or alternatively, -* under the terms of one of the closed source Quantum Leaps commercial -* licenses. -* -* The terms of the open source GNU General Public License version 3 -* can be found at: -* -* The terms of the closed source Quantum Leaps commercial licenses -* can be found at: -* -* Redistributions in source code must retain this top-level comment block. -* Plagiarizing this software to sidestep the license obligations is illegal. -* -* Contact information: -* -* -============================================================================*/ -/*! -* @date Last updated on: 2022-07-30 -* @version Last updated for: @ref qpc_7_1_3 -* -* @file -* @brief "safe" and facilities -*/ +//============================================================================ +// QClean white space cleanup host utility +// +// Q u a n t u m L e a P s +// ------------------------ +// Modern Embedded Software +// +// Copyright (C) 2005 Quantum Leaps, LLC. +// +// SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-QL-commercial +// +// This software is dual-licensed under the terms of the open source GNU +// General Public License version 3 (or any later version), or alternatively, +// under the terms of one of the closed source Quantum Leaps commercial +// licenses. +// +// The terms of the open source GNU General Public License version 3 +// can be found at: +// +// The terms of the closed source Quantum Leaps commercial licenses +// can be found at: +// +// Redistributions in source code must retain this top-level comment block. +// Plagiarizing this software to sidestep the license obligations is illegal. +// +// Contact information: +// +// +//============================================================================ #ifndef SAFE_STD_H_ #define SAFE_STD_H_ diff --git a/qclean/posix/Makefile b/qclean/posix/Makefile deleted file mode 100644 index 5f487f6..0000000 --- a/qclean/posix/Makefile +++ /dev/null @@ -1,193 +0,0 @@ -############################################################################## -# Product: Makefile for QCLEAN console, POSIX(Linux/Mac-OS), GNU compiler -# Last updated for version 7.2.2 -# Last updated on 2023-01-25 -# -# Q u a n t u m L e a P s -# ------------------------ -# Modern Embedded Software -# -# Copyright (C) 2005 Quantum Leaps, LLC. All rights reserved. -# -# This program is open source software: you can redistribute it and/or -# modify it under the terms of the GNU General Public License as published -# by the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# Alternatively, this program may be distributed and modified under the -# terms of Quantum Leaps commercial licenses, which expressly supersede -# the GNU General Public License and are specifically designed for -# licensees interested in retaining the proprietary status of their code. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . -# -# Contact information: -# -# -############################################################################## -# examples of invoking this Makefile: -# building configurations: Debug (default), Release, and Spy -# make -# make CONF=dbg -# -# cleaning configurations: Debug (default), Release, and Spy -# make clean -# make CONF=dbg clean - -#----------------------------------------------------------------------------- -# project name -# -PROJECT := qclean - -#----------------------------------------------------------------------------- -# project directories: -# - -# list of all source directories used by this project -VPATH := . \ - ../source - -# list of all include directories needed by this project -INCLUDES := -I. \ - -I../include - - -#----------------------------------------------------------------------------- -# project files: -# - -# C source files... -C_SRCS := \ - main.c \ - getopt.c \ - filesearch.c - -# C++ source files... -CPP_SRCS := - -LIB_DIRS := -LIBS := - -#----------------------------------------------------------------------------- -# GNU toolset: -# -CC := gcc -CPP := g++ -LINK := gcc # for C programs -#LINK := g++ # for C++ programs - -#----------------------------------------------------------------------------- -# basic utilities: -# -MKDIR := mkdir -p -RM := rm - -#----------------------------------------------------------------------------- -# build configurations... -# - -ifeq (dbg, $(CONF)) # Debug configuration .................................... - -BIN_DIR := dbg - -CFLAGS = -c -g -ffunction-sections -fdata-sections \ - -O -Wall -Wextra $(INCLUDES) $(DEFINES) - -CPPFLAGS = -c -g -ffunction-sections -fdata-sections \ - -O -Wall -Wextra $(INCLUDES) $(DEFINES) - -else # default Release configuration ........................................ - -BIN_DIR := rel - -CFLAGS = -c -ffunction-sections -fdata-sections \ - -O3 -Wall -Wextra $(INCLUDES) $(DEFINES) -DNDEBUG - -CPPFLAGS = -c -ffunction-sections -fdata-sections \ - -O3 -Wall -Wextra $(INCLUDES) $(DEFINES) -DNDEBUG - -endif # ..................................................................... - -UNAME := $(shell uname) -ifeq ($(UNAME), Darwin) - LINKFLAGS := -else -ifndef GCC_OLD - LINKFLAGS := -no-pie -endif -endif - -#----------------------------------------------------------------------------- -C_OBJS := $(patsubst %.c,%.o, $(C_SRCS)) -CPP_OBJS := $(patsubst %.cpp,%.o, $(CPP_SRCS)) - -TARGET_EXE := $(BIN_DIR)/$(PROJECT)$(TARGET_EXT) -C_OBJS_EXT := $(addprefix $(BIN_DIR)/, $(C_OBJS)) -C_DEPS_EXT := $(patsubst %.o,%.d, $(C_OBJS_EXT)) -CPP_OBJS_EXT := $(addprefix $(BIN_DIR)/, $(CPP_OBJS)) -CPP_DEPS_EXT := $(patsubst %.o,%.d, $(CPP_OBJS_EXT)) - -# create $(BIN_DIR) if it does not exist -ifeq ("$(wildcard $(BIN_DIR))","") -$(shell $(MKDIR) $(BIN_DIR)) -endif - -#----------------------------------------------------------------------------- -# rules -# - -all: $(TARGET_EXE) - -$(TARGET_EXE) : $(C_OBJS_EXT) $(CPP_OBJS_EXT) $(RC_OBJS_EXT) - $(LINK) $(LINKFLAGS) $(LIB_DIRS) -o $@ $^ $(LIBS) - cp $@ ../../bin - -$(BIN_DIR)/%.d : %.cpp - $(CPP) -MM -MT $(@:.d=.o) $(CPPFLAGS) $< > $@ - -$(BIN_DIR)/%.d : %.c - $(CC) -MM -MT $(@:.d=.o) $(CFLAGS) $< > $@ - -$(BIN_DIR)/%.o : %.cpp - $(CPP) $(CPPFLAGS) $< -o $@ - -$(BIN_DIR)/%.o : %.c - $(CC) $(CFLAGS) $< -o $@ - -.PHONY : clean show - -# include dependency files only if our goal depends on their existence -ifneq ($(MAKECMDGOALS),clean) - ifneq ($(MAKECMDGOALS),show) --include $(C_DEPS_EXT) $(CPP_DEPS_EXT) - endif -endif - -.PHONY : clean show - -clean: - -$(RM) $(BIN_DIR)/*.o \ - $(BIN_DIR)/*.d \ - $(TARGET_EXE) - -show: - @echo PROJECT = $(PROJECT) - @echo TARGET_EXE = $(TARGET_EXE) - @echo VPATH = $(VPATH) - @echo C_SRCS = $(C_SRCS) - @echo CPP_SRCS = $(CPP_SRCS) - @echo C_DEPS_EXT = $(C_DEPS_EXT) - @echo C_OBJS_EXT = $(C_OBJS_EXT) - @echo C_DEPS_EXT = $(C_DEPS_EXT) - @echo CPP_DEPS_EXT = $(CPP_DEPS_EXT) - @echo CPP_OBJS_EXT = $(CPP_OBJS_EXT) - @echo LIB_DIRS = $(LIB_DIRS) - @echo LIBS = $(LIBS) - @echo DEFINES = $(DEFINES) - diff --git a/qclean/posix/filesearch.c b/qclean/source/filesearch_posix.c similarity index 53% rename from qclean/posix/filesearch.c rename to qclean/source/filesearch_posix.c index 76d39d4..3ea1556 100644 --- a/qclean/posix/filesearch.c +++ b/qclean/source/filesearch_posix.c @@ -1,34 +1,32 @@ -/*============================================================================ -* QP/C Real-Time Embedded Framework (RTEF) -* Copyright (C) 2005 Quantum Leaps, LLC. All rights reserved. -* -* SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-QL-commercial -* -* This software is dual-licensed under the terms of the open source GNU -* General Public License version 3 (or any later version), or alternatively, -* under the terms of one of the closed source Quantum Leaps commercial -* licenses. -* -* The terms of the open source GNU General Public License version 3 -* can be found at: -* -* The terms of the closed source Quantum Leaps commercial licenses -* can be found at: -* -* Redistributions in source code must retain this top-level comment block. -* Plagiarizing this software to sidestep the license obligations is illegal. -* -* Contact information: -* -* -============================================================================*/ -/*! -* @date Last updated on: 2022-12-03 -* @version Last updated for: @ref qtools_7_1_3 -* -* @file -* @brief QClean implementation for POSIX -*/ +//============================================================================ +// QClean white space cleanup host utility +// +// Q u a n t u m L e a P s +// ------------------------ +// Modern Embedded Software +// +// Copyright (C) 2005 Quantum Leaps, LLC. +// +// SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-QL-commercial +// +// This software is dual-licensed under the terms of the open source GNU +// General Public License version 3 (or any later version), or alternatively, +// under the terms of one of the closed source Quantum Leaps commercial +// licenses. +// +// The terms of the open source GNU General Public License version 3 +// can be found at: +// +// The terms of the closed source Quantum Leaps commercial licenses +// can be found at: +// +// Redistributions in source code must retain this top-level comment block. +// Plagiarizing this software to sidestep the license obligations is illegal. +// +// Contact information: +// +// +//============================================================================ #include #include #include diff --git a/qclean/win32/filesearch.c b/qclean/source/filesearch_win.c similarity index 66% rename from qclean/win32/filesearch.c rename to qclean/source/filesearch_win.c index f72f227..d0df859 100644 --- a/qclean/win32/filesearch.c +++ b/qclean/source/filesearch_win.c @@ -1,34 +1,32 @@ -/*============================================================================ -* QP/C Real-Time Embedded Framework (RTEF) -* Copyright (C) 2005 Quantum Leaps, LLC. All rights reserved. -* -* SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-QL-commercial -* -* This software is dual-licensed under the terms of the open source GNU -* General Public License version 3 (or any later version), or alternatively, -* under the terms of one of the closed source Quantum Leaps commercial -* licenses. -* -* The terms of the open source GNU General Public License version 3 -* can be found at: -* -* The terms of the closed source Quantum Leaps commercial licenses -* can be found at: -* -* Redistributions in source code must retain this top-level comment block. -* Plagiarizing this software to sidestep the license obligations is illegal. -* -* Contact information: -* -* -============================================================================*/ -/*! -* @date Last updated on: 2022-12-03 -* @version Last updated for: @ref qtools_7_1_3 -* -* @file -* @brief file search implementation for Windows -*/ +//============================================================================ +// QClean white space cleanup host utility +// +// Q u a n t u m L e a P s +// ------------------------ +// Modern Embedded Software +// +// Copyright (C) 2005 Quantum Leaps, LLC. +// +// SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-QL-commercial +// +// This software is dual-licensed under the terms of the open source GNU +// General Public License version 3 (or any later version), or alternatively, +// under the terms of one of the closed source Quantum Leaps commercial +// licenses. +// +// The terms of the open source GNU General Public License version 3 +// can be found at: +// +// The terms of the closed source Quantum Leaps commercial licenses +// can be found at: +// +// Redistributions in source code must retain this top-level comment block. +// Plagiarizing this software to sidestep the license obligations is illegal. +// +// Contact information: +// +// +//============================================================================ #include #include #include @@ -47,11 +45,11 @@ char const dir_separator = '\\'; /* platform-dependent directory separator */ void filesearch(char const *dirname) { static char buffer[1024]; struct _finddata_t fdata; - long hnd; + intptr_t hnd; unsigned flags; _chdir(dirname); - hnd = _findfirst("*", &fdata); /* set _findfirst to find everthing */ + hnd = _findfirst("*", &fdata); /* set _findfirst to find everything */ if (hnd == -1) { /* if handle fails, directory is empty... */ return; } diff --git a/qclean/source/main.c b/qclean/source/main.c index 5380b67..9e52683 100644 --- a/qclean/source/main.c +++ b/qclean/source/main.c @@ -1,39 +1,32 @@ -/*============================================================================ -* QTools Collection -* -* Q u a n t u m L e a P s -* ------------------------ -* Modern Embedded Software -* -* Copyright (C) 2005 Quantum Leaps, LLC. All rights reserved. -* -* SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-QL-commercial -* -* This software is dual-licensed under the terms of the open source GNU -* General Public License version 3 (or any later version), or alternatively, -* under the terms of one of the closed source Quantum Leaps commercial -* licenses. -* -* The terms of the open source GNU General Public License version 3 -* can be found at: -* -* The terms of the closed source Quantum Leaps commercial licenses -* can be found at: -* -* Redistributions in source code must retain this top-level comment block. -* Plagiarizing this software to sidestep the license obligations is illegal. -* -* Contact information: -* -* -============================================================================*/ -/*! -* @date Last updated on: 2024-02-20 -* @version Last updated for version: 7.3.3 -* -* @file -* @brief main for QClean host utility -*/ +//============================================================================ +// QClean white space cleanup host utility +// +// Q u a n t u m L e a P s +// ------------------------ +// Modern Embedded Software +// +// Copyright (C) 2005 Quantum Leaps, LLC. +// +// SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-QL-commercial +// +// This software is dual-licensed under the terms of the open source GNU +// General Public License version 3 (or any later version), or alternatively, +// under the terms of one of the closed source Quantum Leaps commercial +// licenses. +// +// The terms of the open source GNU General Public License version 3 +// can be found at: +// +// The terms of the closed source Quantum Leaps commercial licenses +// can be found at: +// +// Redistributions in source code must retain this top-level comment block. +// Plagiarizing this software to sidestep the license obligations is illegal. +// +// Contact information: +// +// +//============================================================================ #include #include #include @@ -122,7 +115,7 @@ static FileType const l_fileTypes[] = { { ".project", 8, CR_FLG }, /* Eclipse project */ { ".cproject",9, CR_FLG }, /* Eclipse CDT project */ - { ".md5", 4, CR_FLG | TAB_FLG }, /* MD5 file */ + { ".sha1", 5, CR_FLG | TAB_FLG }, /* Sha1 file */ { ".pro", 4, CR_FLG | TAB_FLG }, /* Qt project */ { ".m", 2, CR_FLG | TAB_FLG | LONG_LINE_FLG }, /* MATLAB */ @@ -141,7 +134,7 @@ static int const l_fileNum = sizeof(l_fileTypes)/sizeof(l_fileTypes[0]); * the function returns 0. */ unsigned isMatching(char const *fname) { - int const flen = strlen(fname); + int const flen = (int)strlen(fname); FileType const *ft = &l_fileTypes[0]; for (int n = l_fileNum; n > 0; --n, ++ft) { /* go over all file types.. */ @@ -206,7 +199,8 @@ void onMatchFound(char const *fname, unsigned flags, int ro_info) { char *src = src_buf; static char dst_buf[10*1024*1024]; /* 10MB buffer */ char *dst = dst_buf; - int nBytes = FREAD_S(src_buf, sizeof(src_buf), 1U, sizeof(src_buf), f); + int nBytes = (int)FREAD_S(src_buf, sizeof(src_buf), + 1U, sizeof(src_buf), f); fclose(f); if (nBytes == sizeof(src_buf)) { /* full buffer? */ PRINTF_S("\n%s(too big -- skipped)\n", fname); diff --git a/qclean/win32/Makefile b/qclean/win32/Makefile deleted file mode 100644 index 22518ae..0000000 --- a/qclean/win32/Makefile +++ /dev/null @@ -1,199 +0,0 @@ -#============================================================================= -# Product: Makefile for qclean console, Win32, MinGW -# Last updated for version 7.3.0 -# Last updated on 2023-09-26 -# -# Q u a n t u m L e a P s -# ------------------------ -# Modern Embedded Software -# -# Copyright (C) 2005 Quantum Leaps, LLC. All rights reserved. -# -# SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-QL-commercial -# -# This software is dual-licensed under the terms of the open source GNU -# General Public License version 3 (or any later version), or alternatively, -# under the terms of one of the closed source Quantum Leaps commercial -# licenses. -# -# The terms of the open source GNU General Public License version 3 -# can be found at: -# -# The terms of the closed source Quantum Leaps commercial licenses -# can be found at: -# -# Redistributions in source code must retain this top-level comment block. -# Plagiarizing this software to sidestep the license obligations is illegal. -# -# Contact information: -# -# -#============================================================================= -# examples of invoking this Makefile: -# building configurations: Debug (default), Release, and Spy -# make -# make CONF=dbg -# -# cleaning configurations: Debug (default), Release, and Spy -# make clean -# make CONF=dbg clean -# -# NOTE: -# To use this Makefile on Windows, you will need the GNU make utility, which -# is included in the Qtools collection for Windows, see: -# https://github.com/QuantumLeaps/qtools/releases -# - -#----------------------------------------------------------------------------- -# project name: -# -PROJECT := qclean - -#----------------------------------------------------------------------------- -# project directories: -# - -# list of all source directories used by this project -VPATH := . \ - ../source - -# list of all include directories needed by this project -INCLUDES := -I. \ - -I../include - -#----------------------------------------------------------------------------- -# project files: -# - -# C source files... -C_SRCS := \ - main.c \ - getopt.c \ - filesearch.c - -# C++ source files... -CPP_SRCS := - -DEFINES := -LIB_DIRS := -LIBS := - -#----------------------------------------------------------------------------- -# MinGW toolset (NOTE: assumed to be on your PATH) -# -# NOTE: -# MinGW toolset is included in the Qtools collection for Windows, see: -# https://github.com/QuantumLeaps/qtools/releases - -CC := gcc -CPP := g++ -LINK := gcc - - -############################################################################## -# Typically, you should not need to change anything below this line - -# basic utilities (included in QTools for Windows), see: -# https://github.com/QuantumLeaps/qtools/releases - -MKDIR := mkdir -RM := rm - -#----------------------------------------------------------------------------- -# build options for various configurations -# - -ifeq (dbg, $(CONF)) # Debug configuration .................................... - -BIN_DIR := dbg - -CFLAGS = -c -g -std=c11 \ - -O -Wall -Wextra -Wpedantic $(INCLUDES) $(DEFINES) - -CPPFLAGS = -c -g -std=c++11 -fno-rtti -fno-exceptions \ - -O -Wall -Wextra -Wpedantic $(INCLUDES) $(DEFINES) - -else # default Release configuration ........................................ - -BIN_DIR := rel - -CFLAGS = -c -std=c11 \ - -Ofast -Wall -Wextra -Wpedantic $(INCLUDES) $(DEFINES) -DNDEBUG - -CPPFLAGS = -c -std=c++11 -fno-rtti -fno-exceptions \ - -Ofast -Wall -Wextra -Wpedantic $(INCLUDES) $(DEFINES) -DNDEBUG - -endif # ..................................................................... - -LINKFLAGS := -Wl,-Map,$(BIN_DIR)/$(PROJECT).map,--cref,--gc-sections - -#----------------------------------------------------------------------------- - -C_OBJS := $(patsubst %.c, %.o, $(C_SRCS)) -CPP_OBJS := $(patsubst %.cpp, %.o, $(CPP_SRCS)) -RC_OBJS := $(patsubst %.rc, %.o, $(RC_SRCS)) - -TARGET_BIN := $(BIN_DIR)/$(PROJECT).bin -TARGET_EXE := $(BIN_DIR)/$(PROJECT).exe -C_OBJS_EXT := $(addprefix $(BIN_DIR)/, $(C_OBJS)) -C_DEPS_EXT := $(patsubst %.o, %.d, $(C_OBJS_EXT)) -CPP_OBJS_EXT := $(addprefix $(BIN_DIR)/, $(CPP_OBJS)) -CPP_DEPS_EXT := $(patsubst %.o, %.d, $(CPP_OBJS_EXT)) -RC_OBJS_EXT := $(addprefix $(BIN_DIR)/, $(RC_OBJS)) - -# create $(BIN_DIR) if it does not exist -ifeq ("$(wildcard $(BIN_DIR))","") -$(shell $(MKDIR) $(BIN_DIR)) -endif - -#----------------------------------------------------------------------------- -# rules -# - -all: $(TARGET_EXE) - -$(TARGET_EXE) : $(C_OBJS_EXT) $(CPP_OBJS_EXT) $(RC_OBJS_EXT) - $(LINK) $(LINKFLAGS) $(LIB_DIRS) -o $@ $^ $(LIBS) - -$(BIN_DIR)/%.d : %.cpp - $(CPP) -MM -MT $(@:.d=.o) $(CPPFLAGS) $< > $@ - -$(BIN_DIR)/%.d : %.c - $(CC) -MM -MT $(@:.d=.o) $(CFLAGS) $< > $@ - -$(BIN_DIR)/%.o : %.cpp - $(CPP) $(CPPFLAGS) $< -o $@ - -$(BIN_DIR)/%.o : %.c - $(CC) $(CFLAGS) $< -o $@ - -# include dependency files only if our goal depends on their existence -ifneq ($(MAKECMDGOALS),clean) - ifneq ($(MAKECMDGOALS),show) --include $(C_DEPS_EXT) $(CPP_DEPS_EXT) - endif -endif - -.PHONY : clean show - -clean: - -$(RM) $(BIN_DIR)/*.o \ - $(BIN_DIR)/*.d \ - $(BIN_DIR)/*.map \ - $(TARGET_EXE) - -show: - @echo PROJECT = $(PROJECT) - @echo TARGET_EXE = $(TARGET_EXE) - @echo VPATH = $(VPATH) - @echo C_SRCS = $(C_SRCS) - @echo CPP_SRCS = $(CPP_SRCS) - @echo C_DEPS_EXT = $(C_DEPS_EXT) - @echo C_OBJS_EXT = $(C_OBJS_EXT) - @echo C_DEPS_EXT = $(C_DEPS_EXT) - @echo CPP_DEPS_EXT = $(CPP_DEPS_EXT) - @echo CPP_OBJS_EXT = $(CPP_OBJS_EXT) - @echo LIB_DIRS = $(LIB_DIRS) - @echo LIBS = $(LIBS) - @echo DEFINES = $(DEFINES) - diff --git a/qclean/win32/make-vs.bat b/qclean/win32/make-vs.bat deleted file mode 100644 index bca550b..0000000 --- a/qclean/win32/make-vs.bat +++ /dev/null @@ -1,24 +0,0 @@ -:: Batch file for building the specified PROJ (solution) prepared for -:: Microsoft Visual Studio -:: -:: usage: -:: make -:: -@setlocal - -:: specifiy project and build configuration (Debug|Release|Spy) -@set PROJ=qclean -@set CONF=Release - -:: adjust the MSBuild location for your system -@set MSBuild="C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Current\Bin\MSBuild.exe" - -:: execute the build... -%MSBuild% %PROJ%.sln -t:Build -p:Configuration=%CONF% -p:Platform=Win32 - -:: cleanup after the build... -rmdir /S /Q %CONF%\%PROJ%.tlog -del %CONF%\%PROJ%.vcxproj* %CONF%\%PROJ%.log %CONF%\*.obj %CONF%\*.pdb - -@endlocal - diff --git a/qclean/win32/qclean.sln b/qclean/win32/qclean.sln deleted file mode 100644 index 80ad8ee..0000000 --- a/qclean/win32/qclean.sln +++ /dev/null @@ -1,31 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio Version 17 -VisualStudioVersion = 17.7.34031.279 -MinimumVisualStudioVersion = 10.0.40219.1 -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "qclean", "qclean.vcxproj", "{CBECC159-8744-4517-828D-D3C740E68AA5}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|x64 = Debug|x64 - Debug|x86 = Debug|x86 - Release|x64 = Release|x64 - Release|x86 = Release|x86 - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {CBECC159-8744-4517-828D-D3C740E68AA5}.Debug|x64.ActiveCfg = Debug|x64 - {CBECC159-8744-4517-828D-D3C740E68AA5}.Debug|x64.Build.0 = Debug|x64 - {CBECC159-8744-4517-828D-D3C740E68AA5}.Debug|x86.ActiveCfg = Debug|Win32 - {CBECC159-8744-4517-828D-D3C740E68AA5}.Debug|x86.Build.0 = Debug|Win32 - {CBECC159-8744-4517-828D-D3C740E68AA5}.Release|x64.ActiveCfg = Release|x64 - {CBECC159-8744-4517-828D-D3C740E68AA5}.Release|x64.Build.0 = Release|x64 - {CBECC159-8744-4517-828D-D3C740E68AA5}.Release|x86.ActiveCfg = Release|Win32 - {CBECC159-8744-4517-828D-D3C740E68AA5}.Release|x86.Build.0 = Release|Win32 - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection - GlobalSection(ExtensibilityGlobals) = postSolution - SolutionGuid = {72F1DD46-1083-46CF-9E35-E3CD17D5165D} - EndGlobalSection -EndGlobal diff --git a/qclean/win32/qclean.vcxproj b/qclean/win32/qclean.vcxproj deleted file mode 100644 index 1d61409..0000000 --- a/qclean/win32/qclean.vcxproj +++ /dev/null @@ -1,156 +0,0 @@ - - - - - Debug - Win32 - - - Release - Win32 - - - Debug - x64 - - - Release - x64 - - - - 17.0 - Win32Proj - {cbecc159-8744-4517-828d-d3c740e68aa5} - qclean - 10.0 - - - - Application - true - v143 - NotSet - - - Application - false - v143 - true - NotSet - - - Application - true - v143 - NotSet - - - Application - false - v143 - true - NotSet - - - - - - - - - - - - - - - - - - - - - - Level3 - true - qclean_APP;WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - ../include - - - Console - true - ws2_32.lib;$(CoreLibraryDependencies);%(AdditionalDependencies) - - - - - Level3 - true - true - true - qclean_APP;WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - ../include - - - Console - true - true - true - ws2_32.lib;$(CoreLibraryDependencies);%(AdditionalDependencies) - - - - - Level3 - true - qclean_APP;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - stdc11 - ../include - - - Console - true - ws2_32.lib;$(CoreLibraryDependencies);%(AdditionalDependencies) - - - - - Level3 - true - true - true - qclean_APP;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - stdc11 - ../include - - - Console - true - true - true - ws2_32.lib;$(CoreLibraryDependencies);%(AdditionalDependencies) - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/qclean/win32/qclean.vcxproj.filters b/qclean/win32/qclean.vcxproj.filters deleted file mode 100644 index a6fbe50..0000000 --- a/qclean/win32/qclean.vcxproj.filters +++ /dev/null @@ -1,51 +0,0 @@ - - - - - {4FC737F1-C7A5-4376-A066-2A32D752A2FF} - cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx - - - {93995380-89BD-4b04-88EB-625FBE52EBFB} - h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd - - - {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} - rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms - - - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - - - Source Files - - - Source Files - - - Source Files - - - \ No newline at end of file diff --git a/qfsgen/CMakeLists.txt b/qfsgen/CMakeLists.txt deleted file mode 100644 index 5afc129..0000000 --- a/qfsgen/CMakeLists.txt +++ /dev/null @@ -1,11 +0,0 @@ -# QTools/qfsgen -message(STATUS "`qtools/qfsgen` - see \"https://www.state-machine.com/qtools/qfsgen.html\" for further details.") - -# the main target -target_sources(qfsgen PRIVATE - source/main.c - ${PLATFORM_DIR}/filesearch.c -) - -# add include dirs to target (-I...) -target_include_directories(qfsgen PRIVATE include) diff --git a/qfsgen/include/qfsgen.h b/qfsgen/include/qfsgen.h index 438d655..0bbe462 100644 --- a/qfsgen/include/qfsgen.h +++ b/qfsgen/include/qfsgen.h @@ -1,43 +1,41 @@ -/*============================================================================ -* QP/C Real-Time Embedded Framework (RTEF) -* Copyright (C) 2005 Quantum Leaps, LLC. All rights reserved. -* -* SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-QL-commercial -* -* This software is dual-licensed under the terms of the open source GNU -* General Public License version 3 (or any later version), or alternatively, -* under the terms of one of the closed source Quantum Leaps commercial -* licenses. -* -* The terms of the open source GNU General Public License version 3 -* can be found at: -* -* The terms of the closed source Quantum Leaps commercial licenses -* can be found at: -* -* Redistributions in source code must retain this top-level comment block. -* Plagiarizing this software to sidestep the license obligations is illegal. -* -* Contact information: -* -* -============================================================================*/ -/*! -* @date Last updated on: 2022-12-03 -* @version Last updated for: @ref qtools_7_1_3 -* -* @file -* @brief QFSgen ROM file system generator internal interface -*/ +//============================================================================ +// QFSGEN ROM file system generation host utility +// +// Q u a n t u m L e a P s +// ------------------------ +// Modern Embedded Software +// +// Copyright (C) 2005 Quantum Leaps, LLC. +// +// SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-QL-commercial +// +// This software is dual-licensed under the terms of the open source GNU +// General Public License version 3 (or any later version), or alternatively, +// under the terms of one of the closed source Quantum Leaps commercial +// licenses. +// +// The terms of the open source GNU General Public License version 3 +// can be found at: +// +// The terms of the closed source Quantum Leaps commercial licenses +// can be found at: +// +// Redistributions in source code must retain this top-level comment block. +// Plagiarizing this software to sidestep the license obligations is illegal. +// +// Contact information: +// +// +//============================================================================ #ifndef QFSGEN_H_ #define QFSGEN_H_ -#define VERSION "6.9.0" +#define VERSION "8.0.0" unsigned isMatching (char const *fullPath); void onMatchFound(char const *fullPath, unsigned flags, int ro_info); void filesearch (char const *dirname); -extern char const dir_separator; /* platform-dependent directory separator */ +extern char const dir_separator; // platform-dependent directory separator -#endif /* QFSGEN_H_ */ +#endif // QFSGEN_H_ diff --git a/qfsgen/include/safe_std.h b/qfsgen/include/safe_std.h index d8da8f0..921ea5d 100644 --- a/qfsgen/include/safe_std.h +++ b/qfsgen/include/safe_std.h @@ -1,34 +1,32 @@ -/*============================================================================ -* QP/C Real-Time Embedded Framework (RTEF) -* Copyright (C) 2005 Quantum Leaps, LLC. All rights reserved. -* -* SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-QL-commercial -* -* This software is dual-licensed under the terms of the open source GNU -* General Public License version 3 (or any later version), or alternatively, -* under the terms of one of the closed source Quantum Leaps commercial -* licenses. -* -* The terms of the open source GNU General Public License version 3 -* can be found at: -* -* The terms of the closed source Quantum Leaps commercial licenses -* can be found at: -* -* Redistributions in source code must retain this top-level comment block. -* Plagiarizing this software to sidestep the license obligations is illegal. -* -* Contact information: -* -* -============================================================================*/ -/*! -* @date Last updated on: 2022-07-30 -* @version Last updated for: @ref qpc_7_1_3 -* -* @file -* @brief "safe" and facilities -*/ +//============================================================================ +// QClean white space cleanup host utility +// +// Q u a n t u m L e a P s +// ------------------------ +// Modern Embedded Software +// +// Copyright (C) 2005 Quantum Leaps, LLC. +// +// SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-QL-commercial +// +// This software is dual-licensed under the terms of the open source GNU +// General Public License version 3 (or any later version), or alternatively, +// under the terms of one of the closed source Quantum Leaps commercial +// licenses. +// +// The terms of the open source GNU General Public License version 3 +// can be found at: +// +// The terms of the closed source Quantum Leaps commercial licenses +// can be found at: +// +// Redistributions in source code must retain this top-level comment block. +// Plagiarizing this software to sidestep the license obligations is illegal. +// +// Contact information: +// +// +//============================================================================ #ifndef SAFE_STD_H_ #define SAFE_STD_H_ diff --git a/qfsgen/posix/Makefile b/qfsgen/posix/Makefile deleted file mode 100644 index 3a594eb..0000000 --- a/qfsgen/posix/Makefile +++ /dev/null @@ -1,192 +0,0 @@ -############################################################################## -# Product: Makefile for QFSGEN console, POSIX (Linux/Mac-OS), GNU compiler -# Last updated for version 7.2.2 -# Last updated on 2023-01-25 -# -# Q u a n t u m L e a P s -# ------------------------ -# Modern Embedded Software -# -# Copyright (C) 2005 Quantum Leaps, LLC. All rights reserved. -# -# This program is open source software: you can redistribute it and/or -# modify it under the terms of the GNU General Public License as published -# by the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# Alternatively, this program may be distributed and modified under the -# terms of Quantum Leaps commercial licenses, which expressly supersede -# the GNU General Public License and are specifically designed for -# licensees interested in retaining the proprietary status of their code. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . -# -# Contact information: -# -# -############################################################################## -# examples of invoking this Makefile: -# building configurations: Debug (default), Release, and Spy -# make -# make CONF=dbg -# -# cleaning configurations: Debug (default), Release, and Spy -# make clean -# make CONF=dbg clean - -#----------------------------------------------------------------------------- -# project name -# -PROJECT := qfsgen - -#----------------------------------------------------------------------------- -# project directories: -# - -# list of all source directories used by this project -VPATH := . \ - ../source - -# list of all include directories needed by this project -INCLUDES := -I. \ - -I../include - - -#----------------------------------------------------------------------------- -# project files: -# - -# C source files... -C_SRCS := \ - main.c \ - filesearch.c - -# C++ source files... -CPP_SRCS := - -LIB_DIRS := -LIBS := - -#----------------------------------------------------------------------------- -# GNU toolset: -# -CC := gcc -CPP := g++ -LINK := gcc # for C programs -#LINK := g++ # for C++ programs - -#----------------------------------------------------------------------------- -# basic utilities: -# -MKDIR := mkdir -p -RM := rm - -#----------------------------------------------------------------------------- -# build configurations... -# - -ifeq (dbg, $(CONF)) # Debug configuration .................................... - -BIN_DIR := dbg - -CFLAGS = -c -g -std=gnu11 -ffunction-sections -fdata-sections \ - -O -Wall -Wextra -Wpedantic $(INCLUDES) $(DEFINES) - -CPPFLAGS = -c -g -ffunction-sections -fdata-sections \ - -O -Wall -Wextra $(INCLUDES) $(DEFINES) - -else # default Release configuration ........................................ - -BIN_DIR := rel - -CFLAGS = -c -std=gnu11 -ffunction-sections -fdata-sections \ - -O3 -Wall -Wextra -Wpedantic $(INCLUDES) $(DEFINES) -DNDEBUG - -CPPFLAGS = -c -ffunction-sections -fdata-sections \ - -O3 -Wall -Wextra $(INCLUDES) $(DEFINES) -DNDEBUG - -endif # ..................................................................... - -UNAME := $(shell uname) -ifeq ($(UNAME), Darwin) - LINKFLAGS := -else -ifndef GCC_OLD - LINKFLAGS := -no-pie -endif -endif - -#----------------------------------------------------------------------------- -C_OBJS := $(patsubst %.c,%.o, $(C_SRCS)) -CPP_OBJS := $(patsubst %.cpp,%.o, $(CPP_SRCS)) - -TARGET_EXE := $(BIN_DIR)/$(PROJECT)$(TARGET_EXT) -C_OBJS_EXT := $(addprefix $(BIN_DIR)/, $(C_OBJS)) -C_DEPS_EXT := $(patsubst %.o,%.d, $(C_OBJS_EXT)) -CPP_OBJS_EXT := $(addprefix $(BIN_DIR)/, $(CPP_OBJS)) -CPP_DEPS_EXT := $(patsubst %.o,%.d, $(CPP_OBJS_EXT)) - -# create $(BIN_DIR) if it does not exist -ifeq ("$(wildcard $(BIN_DIR))","") -$(shell $(MKDIR) $(BIN_DIR)) -endif - -#----------------------------------------------------------------------------- -# rules -# - -all: $(TARGET_EXE) - -$(TARGET_EXE) : $(C_OBJS_EXT) $(CPP_OBJS_EXT) $(RC_OBJS_EXT) - $(LINK) $(LINKFLAGS) $(LIB_DIRS) -o $@ $^ $(LIBS) - cp $@ ../../bin - -$(BIN_DIR)/%.d : %.cpp - $(CPP) -MM -MT $(@:.d=.o) $(CPPFLAGS) $< > $@ - -$(BIN_DIR)/%.d : %.c - $(CC) -MM -MT $(@:.d=.o) $(CFLAGS) $< > $@ - -$(BIN_DIR)/%.o : %.cpp - $(CPP) $(CPPFLAGS) $< -o $@ - -$(BIN_DIR)/%.o : %.c - $(CC) $(CFLAGS) $< -o $@ - -.PHONY : clean show - -# include dependency files only if our goal depends on their existence -ifneq ($(MAKECMDGOALS),clean) - ifneq ($(MAKECMDGOALS),show) --include $(C_DEPS_EXT) $(CPP_DEPS_EXT) - endif -endif - -.PHONY : clean show - -clean: - -$(RM) $(BIN_DIR)/*.o \ - $(BIN_DIR)/*.d \ - $(TARGET_EXE) - -show: - @echo PROJECT = $(PROJECT) - @echo TARGET_EXE = $(TARGET_EXE) - @echo VPATH = $(VPATH) - @echo C_SRCS = $(C_SRCS) - @echo CPP_SRCS = $(CPP_SRCS) - @echo C_DEPS_EXT = $(C_DEPS_EXT) - @echo C_OBJS_EXT = $(C_OBJS_EXT) - @echo C_DEPS_EXT = $(C_DEPS_EXT) - @echo CPP_DEPS_EXT = $(CPP_DEPS_EXT) - @echo CPP_OBJS_EXT = $(CPP_OBJS_EXT) - @echo LIB_DIRS = $(LIB_DIRS) - @echo LIBS = $(LIBS) - @echo DEFINES = $(DEFINES) - diff --git a/qfsgen/posix/filesearch.c b/qfsgen/source/filesearch_posix.c similarity index 58% rename from qfsgen/posix/filesearch.c rename to qfsgen/source/filesearch_posix.c index fcbfee6..33ccd8e 100644 --- a/qfsgen/posix/filesearch.c +++ b/qfsgen/source/filesearch_posix.c @@ -1,34 +1,32 @@ -/*============================================================================ -* QP/C Real-Time Embedded Framework (RTEF) -* Copyright (C) 2005 Quantum Leaps, LLC. All rights reserved. -* -* SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-QL-commercial -* -* This software is dual-licensed under the terms of the open source GNU -* General Public License version 3 (or any later version), or alternatively, -* under the terms of one of the closed source Quantum Leaps commercial -* licenses. -* -* The terms of the open source GNU General Public License version 3 -* can be found at: -* -* The terms of the closed source Quantum Leaps commercial licenses -* can be found at: -* -* Redistributions in source code must retain this top-level comment block. -* Plagiarizing this software to sidestep the license obligations is illegal. -* -* Contact information: -* -* -============================================================================*/ -/*! -* @date Last updated on: 2022-12-03 -* @version Last updated for: @ref qtools_7_1_3 -* -* @file -* @brief QFSGen implementation for POSIX -*/ +//============================================================================ +// QFSGEN ROM file system generation host utility +// +// Q u a n t u m L e a P s +// ------------------------ +// Modern Embedded Software +// +// Copyright (C) 2005 Quantum Leaps, LLC. +// +// SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-QL-commercial +// +// This software is dual-licensed under the terms of the open source GNU +// General Public License version 3 (or any later version), or alternatively, +// under the terms of one of the closed source Quantum Leaps commercial +// licenses. +// +// The terms of the open source GNU General Public License version 3 +// can be found at: +// +// The terms of the closed source Quantum Leaps commercial licenses +// can be found at: +// +// Redistributions in source code must retain this top-level comment block. +// Plagiarizing this software to sidestep the license obligations is illegal. +// +// Contact information: +// +// +//============================================================================ #include #include #include diff --git a/qfsgen/win32/filesearch.c b/qfsgen/source/filesearch_win.c similarity index 67% rename from qfsgen/win32/filesearch.c rename to qfsgen/source/filesearch_win.c index dd29c25..87f09b3 100644 --- a/qfsgen/win32/filesearch.c +++ b/qfsgen/source/filesearch_win.c @@ -1,34 +1,32 @@ -/*============================================================================ -* QP/C Real-Time Embedded Framework (RTEF) -* Copyright (C) 2005 Quantum Leaps, LLC. All rights reserved. -* -* SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-QL-commercial -* -* This software is dual-licensed under the terms of the open source GNU -* General Public License version 3 (or any later version), or alternatively, -* under the terms of one of the closed source Quantum Leaps commercial -* licenses. -* -* The terms of the open source GNU General Public License version 3 -* can be found at: -* -* The terms of the closed source Quantum Leaps commercial licenses -* can be found at: -* -* Redistributions in source code must retain this top-level comment block. -* Plagiarizing this software to sidestep the license obligations is illegal. -* -* Contact information: -* -* -============================================================================*/ -/*! -* @date Last updated on: 2022-12-03 -* @version Last updated for: @ref qtools_7_1_3 -* -* @file -* @brief file search implementation for Windows -*/ +//============================================================================ +// QFSGEN ROM file system generation host utility +// +// Q u a n t u m L e a P s +// ------------------------ +// Modern Embedded Software +// +// Copyright (C) 2005 Quantum Leaps, LLC. +// +// SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-QL-commercial +// +// This software is dual-licensed under the terms of the open source GNU +// General Public License version 3 (or any later version), or alternatively, +// under the terms of one of the closed source Quantum Leaps commercial +// licenses. +// +// The terms of the open source GNU General Public License version 3 +// can be found at: +// +// The terms of the closed source Quantum Leaps commercial licenses +// can be found at: +// +// Redistributions in source code must retain this top-level comment block. +// Plagiarizing this software to sidestep the license obligations is illegal. +// +// Contact information: +// +// +//============================================================================ #include #include #include diff --git a/qfsgen/source/main.c b/qfsgen/source/main.c index 1867339..7bd5600 100644 --- a/qfsgen/source/main.c +++ b/qfsgen/source/main.c @@ -1,34 +1,32 @@ -/*============================================================================ -* QP/C Real-Time Embedded Framework (RTEF) -* Copyright (C) 2005 Quantum Leaps, LLC. All rights reserved. -* -* SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-QL-commercial -* -* This software is dual-licensed under the terms of the open source GNU -* General Public License version 3 (or any later version), or alternatively, -* under the terms of one of the closed source Quantum Leaps commercial -* licenses. -* -* The terms of the open source GNU General Public License version 3 -* can be found at: -* -* The terms of the closed source Quantum Leaps commercial licenses -* can be found at: -* -* Redistributions in source code must retain this top-level comment block. -* Plagiarizing this software to sidestep the license obligations is illegal. -* -* Contact information: -* -* -============================================================================*/ -/*! -* @date Last updated on: 2023-10-26 -* @version Last updated for: @ref qtools_7_3_0 -* -* @file -* @brief QFSgen ROM file system generator main function -*/ +//============================================================================ +// QFSGEN ROM file system generation host utility +// +// Q u a n t u m L e a P s +// ------------------------ +// Modern Embedded Software +// +// Copyright (C) 2005 Quantum Leaps, LLC. +// +// SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-QL-commercial +// +// This software is dual-licensed under the terms of the open source GNU +// General Public License version 3 (or any later version), or alternatively, +// under the terms of one of the closed source Quantum Leaps commercial +// licenses. +// +// The terms of the open source GNU General Public License version 3 +// can be found at: +// +// The terms of the closed source Quantum Leaps commercial licenses +// can be found at: +// +// Redistributions in source code must retain this top-level comment block. +// Plagiarizing this software to sidestep the license obligations is illegal. +// +// Contact information: +// +// +//============================================================================ #include #include "safe_std.h" /* "safe" and facilities */ @@ -113,7 +111,7 @@ void onMatchFound(char const *fullPath, unsigned flags, int ro_info) { } ++l_nFiles; - /* copy the file name into the buffer and masage it a bit */ + /* copy the file name into the buffer and massage it a bit */ s = fname; d = buf; while (*s != '\0') { @@ -130,7 +128,7 @@ void onMatchFound(char const *fullPath, unsigned flags, int ro_info) { PRINTF_S("\nAdding: %s%s", l_fsDir, buf); FPRINTF_S(l_file, "/* %s */\x0A", buf); - /* defive the C-variable name from the file name */ + /* define the C-variable name from the file name */ s = buf + 1; /* skip the first '/' */ d = fvar; while (*s != '\0') { @@ -216,7 +214,7 @@ void onMatchFound(char const *fullPath, unsigned flags, int ro_info) { i = 0; while ((nBytes = fread(buf, 1, sizeof(buf), fin)) != 0) { char const *pc = buf; - int n = nBytes; + size_t n = nBytes; while (n-- != 0) { if (i == 0) { /* new line? */ ++i; @@ -258,7 +256,7 @@ void onMatchFound(char const *fullPath, unsigned flags, int ro_info) { int main(int argc, char *argv[]) { char const *fileName = "fsdata.h"; - PRINTF_S("QFSGen %s Copyright (c) 2005-2020 Quantum Leaps\n" + PRINTF_S("QFSGen %s Copyright (c) 2005 Quantum Leaps\n" "Documentation: https://state-machine.com/qtools/qfsgen.html\n", VERSION); PRINTF_S("Usage: qfsgen fs-dir [output-file] [-h]\n" diff --git a/qfsgen/win32/Makefile b/qfsgen/win32/Makefile deleted file mode 100644 index d3ae106..0000000 --- a/qfsgen/win32/Makefile +++ /dev/null @@ -1,198 +0,0 @@ -#============================================================================= -# Product: Makefile for qfsgen console, Win32, MinGW -# Last updated for version 7.3.0 -# Last updated on 2023-09-26 -# -# Q u a n t u m L e a P s -# ------------------------ -# Modern Embedded Software -# -# Copyright (C) 2005 Quantum Leaps, LLC. All rights reserved. -# -# SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-QL-commercial -# -# This software is dual-licensed under the terms of the open source GNU -# General Public License version 3 (or any later version), or alternatively, -# under the terms of one of the closed source Quantum Leaps commercial -# licenses. -# -# The terms of the open source GNU General Public License version 3 -# can be found at: -# -# The terms of the closed source Quantum Leaps commercial licenses -# can be found at: -# -# Redistributions in source code must retain this top-level comment block. -# Plagiarizing this software to sidestep the license obligations is illegal. -# -# Contact information: -# -# -#============================================================================= -# examples of invoking this Makefile: -# building configurations: Debug (default), Release, and Spy -# make -# make CONF=dbg -# -# cleaning configurations: Debug (default), Release, and Spy -# make clean -# make CONF=dbg clean -# -# NOTE: -# To use this Makefile on Windows, you will need the GNU make utility, which -# is included in the Qtools collection for Windows, see: -# https://github.com/QuantumLeaps/qtools/releases -# - -#----------------------------------------------------------------------------- -# project name: -# -PROJECT := qfsgen - -#----------------------------------------------------------------------------- -# project directories: -# - -# list of all source directories used by this project -VPATH := . \ - ../source - -# list of all include directories needed by this project -INCLUDES := -I. \ - -I../include - -#----------------------------------------------------------------------------- -# project files: -# - -# C source files... -C_SRCS := \ - main.c \ - filesearch.c - -# C++ source files... -CPP_SRCS := - -DEFINES := -LIB_DIRS := -LIBS := - -#----------------------------------------------------------------------------- -# MinGW toolset (NOTE: assumed to be on your PATH) -# -# NOTE: -# MinGW toolset is included in the Qtools collection for Windows, see: -# https://github.com/QuantumLeaps/qtools/releases - -CC := gcc -CPP := g++ -LINK := gcc - - -############################################################################## -# Typically, you should not need to change anything below this line - -# basic utilities (included in QTools for Windows), see: -# https://github.com/QuantumLeaps/qtools/releases - -MKDIR := mkdir -RM := rm - -#----------------------------------------------------------------------------- -# build options for various configurations -# - -ifeq (dbg, $(CONF)) # Debug configuration .................................... - -BIN_DIR := dbg - -CFLAGS = -c -g -std=c11 \ - -O -Wall -Wextra -Wpedantic $(INCLUDES) $(DEFINES) - -CPPFLAGS = -c -g -std=c++11 -fno-rtti -fno-exceptions \ - -O -Wall -Wextra -Wpedantic $(INCLUDES) $(DEFINES) - -else # default Release configuration ........................................ - -BIN_DIR := rel - -CFLAGS = -c -std=c11 \ - -Ofast -Wall -Wextra -Wpedantic $(INCLUDES) $(DEFINES) -DNDEBUG - -CPPFLAGS = -c -std=c++11 -fno-rtti -fno-exceptions \ - -Ofast -Wall -Wextra -Wpedantic $(INCLUDES) $(DEFINES) -DNDEBUG - -endif # ..................................................................... - -LINKFLAGS := -Wl,-Map,$(BIN_DIR)/$(PROJECT).map,--cref,--gc-sections - -#----------------------------------------------------------------------------- - -C_OBJS := $(patsubst %.c, %.o, $(C_SRCS)) -CPP_OBJS := $(patsubst %.cpp, %.o, $(CPP_SRCS)) -RC_OBJS := $(patsubst %.rc, %.o, $(RC_SRCS)) - -TARGET_BIN := $(BIN_DIR)/$(PROJECT).bin -TARGET_EXE := $(BIN_DIR)/$(PROJECT).exe -C_OBJS_EXT := $(addprefix $(BIN_DIR)/, $(C_OBJS)) -C_DEPS_EXT := $(patsubst %.o, %.d, $(C_OBJS_EXT)) -CPP_OBJS_EXT := $(addprefix $(BIN_DIR)/, $(CPP_OBJS)) -CPP_DEPS_EXT := $(patsubst %.o, %.d, $(CPP_OBJS_EXT)) -RC_OBJS_EXT := $(addprefix $(BIN_DIR)/, $(RC_OBJS)) - -# create $(BIN_DIR) if it does not exist -ifeq ("$(wildcard $(BIN_DIR))","") -$(shell $(MKDIR) $(BIN_DIR)) -endif - -#----------------------------------------------------------------------------- -# rules -# - -all: $(TARGET_EXE) - -$(TARGET_EXE) : $(C_OBJS_EXT) $(CPP_OBJS_EXT) $(RC_OBJS_EXT) - $(LINK) $(LINKFLAGS) $(LIB_DIRS) -o $@ $^ $(LIBS) - -$(BIN_DIR)/%.d : %.cpp - $(CPP) -MM -MT $(@:.d=.o) $(CPPFLAGS) $< > $@ - -$(BIN_DIR)/%.d : %.c - $(CC) -MM -MT $(@:.d=.o) $(CFLAGS) $< > $@ - -$(BIN_DIR)/%.o : %.cpp - $(CPP) $(CPPFLAGS) $< -o $@ - -$(BIN_DIR)/%.o : %.c - $(CC) $(CFLAGS) $< -o $@ - -# include dependency files only if our goal depends on their existence -ifneq ($(MAKECMDGOALS),clean) - ifneq ($(MAKECMDGOALS),show) --include $(C_DEPS_EXT) $(CPP_DEPS_EXT) - endif -endif - -.PHONY : clean show - -clean: - -$(RM) $(BIN_DIR)/*.o \ - $(BIN_DIR)/*.d \ - $(BIN_DIR)/*.map \ - $(TARGET_EXE) - -show: - @echo PROJECT = $(PROJECT) - @echo TARGET_EXE = $(TARGET_EXE) - @echo VPATH = $(VPATH) - @echo C_SRCS = $(C_SRCS) - @echo CPP_SRCS = $(CPP_SRCS) - @echo C_DEPS_EXT = $(C_DEPS_EXT) - @echo C_OBJS_EXT = $(C_OBJS_EXT) - @echo C_DEPS_EXT = $(C_DEPS_EXT) - @echo CPP_DEPS_EXT = $(CPP_DEPS_EXT) - @echo CPP_OBJS_EXT = $(CPP_OBJS_EXT) - @echo LIB_DIRS = $(LIB_DIRS) - @echo LIBS = $(LIBS) - @echo DEFINES = $(DEFINES) - diff --git a/qfsgen/win32/make-vs.bat b/qfsgen/win32/make-vs.bat deleted file mode 100644 index ba689b6..0000000 --- a/qfsgen/win32/make-vs.bat +++ /dev/null @@ -1,24 +0,0 @@ -:: Batch file for building the specified PROJ (solution) prepared for -:: Microsoft Visual Studio -:: -:: usage: -:: make -:: -@setlocal - -:: specifiy project and build configuration (Debug|Release|Spy) -@set PROJ=qfsgen -@set CONF=Release - -:: adjust the MSBuild location for your system -@set MSBuild="C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Current\Bin\MSBuild.exe" - -:: execute the build... -%MSBuild% %PROJ%.sln -t:Build -p:Configuration=%CONF% -p:Platform=Win32 - -:: cleanup after the build... -rmdir /S /Q %CONF%\%PROJ%.tlog -del %CONF%\%PROJ%.vcxproj* %CONF%\%PROJ%.log %CONF%\*.obj %CONF%\*.pdb - -@endlocal - diff --git a/qfsgen/win32/qfsgen.sln b/qfsgen/win32/qfsgen.sln deleted file mode 100644 index 4100529..0000000 --- a/qfsgen/win32/qfsgen.sln +++ /dev/null @@ -1,31 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio Version 17 -VisualStudioVersion = 17.7.34031.279 -MinimumVisualStudioVersion = 10.0.40219.1 -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "qfsgen", "qfsgen.vcxproj", "{CBECC159-8744-4517-828D-D3C740E68AA5}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|x64 = Debug|x64 - Debug|x86 = Debug|x86 - Release|x64 = Release|x64 - Release|x86 = Release|x86 - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {CBECC159-8744-4517-828D-D3C740E68AA5}.Debug|x64.ActiveCfg = Debug|x64 - {CBECC159-8744-4517-828D-D3C740E68AA5}.Debug|x64.Build.0 = Debug|x64 - {CBECC159-8744-4517-828D-D3C740E68AA5}.Debug|x86.ActiveCfg = Debug|Win32 - {CBECC159-8744-4517-828D-D3C740E68AA5}.Debug|x86.Build.0 = Debug|Win32 - {CBECC159-8744-4517-828D-D3C740E68AA5}.Release|x64.ActiveCfg = Release|x64 - {CBECC159-8744-4517-828D-D3C740E68AA5}.Release|x64.Build.0 = Release|x64 - {CBECC159-8744-4517-828D-D3C740E68AA5}.Release|x86.ActiveCfg = Release|Win32 - {CBECC159-8744-4517-828D-D3C740E68AA5}.Release|x86.Build.0 = Release|Win32 - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection - GlobalSection(ExtensibilityGlobals) = postSolution - SolutionGuid = {72F1DD46-1083-46CF-9E35-E3CD17D5165D} - EndGlobalSection -EndGlobal diff --git a/qfsgen/win32/qfsgen.vcxproj b/qfsgen/win32/qfsgen.vcxproj deleted file mode 100644 index 40c6e1b..0000000 --- a/qfsgen/win32/qfsgen.vcxproj +++ /dev/null @@ -1,155 +0,0 @@ - - - - - Debug - Win32 - - - Release - Win32 - - - Debug - x64 - - - Release - x64 - - - - 17.0 - Win32Proj - {cbecc159-8744-4517-828d-d3c740e68aa5} - qfsgen - 10.0 - - - - Application - true - v143 - NotSet - - - Application - false - v143 - true - NotSet - - - Application - true - v143 - NotSet - - - Application - false - v143 - true - NotSet - - - - - - - - - - - - - - - - - - - - - - Level3 - true - qfsgen_APP;WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - ../include - - - Console - true - ws2_32.lib;$(CoreLibraryDependencies);%(AdditionalDependencies) - - - - - Level3 - true - true - true - qfsgen_APP;WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - ../include - - - Console - true - true - true - ws2_32.lib;$(CoreLibraryDependencies);%(AdditionalDependencies) - - - - - Level3 - true - qfsgen_APP;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - stdc11 - ../include - - - Console - true - ws2_32.lib;$(CoreLibraryDependencies);%(AdditionalDependencies) - - - - - Level3 - true - true - true - qfsgen_APP;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - stdc11 - ../include - - - Console - true - true - true - ws2_32.lib;$(CoreLibraryDependencies);%(AdditionalDependencies) - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/qfsgen/win32/qfsgen.vcxproj.filters b/qfsgen/win32/qfsgen.vcxproj.filters deleted file mode 100644 index 42b6602..0000000 --- a/qfsgen/win32/qfsgen.vcxproj.filters +++ /dev/null @@ -1,48 +0,0 @@ - - - - - {4FC737F1-C7A5-4376-A066-2A32D752A2FF} - cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx - - - {93995380-89BD-4b04-88EB-625FBE52EBFB} - h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd - - - {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} - rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms - - - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - - - Source Files - - - Source Files - - - \ No newline at end of file diff --git a/qspy/CMakeLists.txt b/qspy/CMakeLists.txt deleted file mode 100644 index 87bd68e..0000000 --- a/qspy/CMakeLists.txt +++ /dev/null @@ -1,28 +0,0 @@ -# QTools/qspy -message(STATUS "`qtools/qspy` - see \"https://www.state-machine.com/qtools/qspy.html\" for further details.") - -# the main target -target_sources(qspy PRIVATE - source/qspy.c - source/qspy_main.c - source/qspy_be.c - source/qspy_dict.c - source/qspy_seq.c - source/qspy_tx.c - source/getopt.c - ${PLATFORM_DIR}/qspy_pal.c -) - -# add include dirs to target (-I...) -target_include_directories(qspy PRIVATE - ${PLATFORM_DIR} - include -) - -# set defines (-D...) -target_compile_definitions(qspy PRIVATE QSPY_APP) - -# add link libraries (-l...) -if(CMAKE_SYSTEM_NAME STREQUAL Windows) - target_link_libraries(qspy PRIVATE ws2_32) -endif() diff --git a/qspy/LICENSE-qspy.txt b/qspy/LICENSE-qspy.txt new file mode 100644 index 0000000..d7e08c6 --- /dev/null +++ b/qspy/LICENSE-qspy.txt @@ -0,0 +1,85 @@ +QUANTUM LEAPS QSPY SOFTWARE TRACING HOST UTILITY SOFTWARE +END USER LICENSE AGREEMENT + +These license terms are an agreement between Quantum Leaps and you. +Please read them. They apply to the QSPY tool as well as to any +accompanying documentation and examples. BY USING THE SOFTWARE, YOU ACCEPT +THESE TERMS. IF YOU DO NOT ACCEPT THEM, DO NOT USE THE SOFTWARE. + + +1. DEFINITIONS +1.1. QSPY is a console-based software tracing host utilty for receiving, +visualizing, and communicating with the remote Target systems running +QP/Spy tracing software. QSPY provides textual output to the screen and +various network interfaces to communicate with the external applications +(e.g., QUTest testing or QView monitoring). QSPY is currently available for +Windows, Linux and macOS hosts. + +1.2. QP/Spy software tracing system is part of the QP Real-Time Embedded +Frameworks (RTEFs). + +1.3. "Licensed Software" means the QSPY executable, documentation, and +examples. The Licensed Software expressly does NOT include the products of +software tracing, such as the saved binary files, screen output logs, +"dictionary" files, or generated sequence diagrams. + + +2. GRANT OF COPYRIGHT LICENSE +Quantum Leaps grants to you, and you hereby accept, a nonexclusive, +nontransferable license to do the following: + +2.1. to install and use the QSPY software for the purpose of tracing, +testing, and monitoring your programs. + +3. EXCLUSIONS FROM LICENSE GRANT +The Licensed Software is licensed by this Agreement, not sold or given away. +This Agreement only grants you some rights to use the software. Quantum Leaps +reserves all other rights. + +3.1. No right is granted to trademarks, copyrights, patents, trade secrets or +any other Intellectual Property of Quantum Leaps, even if such trademarks are +included in the Licensed Software. + +3.2. Nothing in this Agreement shall be interpreted to prohibit Quantum Leaps +from licensing under different terms from this Agreement any original work +that Quantum Leaps otherwise would have a right to license. + + +4. LIMITATIONS ON THE USE OF THE LICENSED SOFTWARE +You may use the Licensed Software only as expressly permitted in this +Agreement. In doing so, you must comply with any technical limitations in +the software that only allow you to use it in certain ways. By accepting +this Agreement you agree to the following: + +4.1. You may not remove or modify any copyright notes, legal notes, license +information, attribution notes, logos, URLs, or e-mail addresses embedded in +the source code generated by QM, or in the QM executable and in the QSPY +documentation; + +4.2. You may not sell, rent, lease or lend the Licensed Software; and + +4.3. You may not use the Licensed Software to create similar stand-alone +products based on the QP/Spy software tracing system. + + +5. DISCLAIMER OF WARRANTY +BECAUSE THE QM SOFTWARE IS LICENSED FREE OF CHARGE, IT IS LICENSED "AS IS" +WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT +NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF +THE LICENSED SOFTWARE IS WITH YOU. SHOULD THE SOFTWARE PROVE DEFECTIVE, +YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. + +IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW SHALL QUANTUM LEAPS BE LIABLE +TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR +CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OF OR INABILITY TO USE THE +LICENSED SOFTWARE (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING +RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE +OF THE SOFTWARE TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR +OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. NO LICENSE +TO THE LICENSED SOFTWARE IS GRANTED HEREUNDER EXCEPT UNDER THIS DISCLAIMER. + +6. CONTACT INFORMATION +Any questions or concerns related to this Agreement should be directed to +Quantum Leaps at the following e-mail address: +- mailto:info@state-machine.com diff --git a/qspy/dict/dpp-qpc-no-dict.bin b/qspy/dict/dpp-qpc-no-dict.bin deleted file mode 100644 index 1ab3a6a..0000000 Binary files a/qspy/dict/dpp-qpc-no-dict.bin and /dev/null differ diff --git a/qspy/dict/dpp-qpc.bin b/qspy/dict/dpp-qpc.bin deleted file mode 100644 index 597e5a4..0000000 Binary files a/qspy/dict/dpp-qpc.bin and /dev/null differ diff --git a/qspy/dict/qspy211020_120243.dic b/qspy/dict/qspy211020_120243.dic deleted file mode 100644 index 0b7c834..0000000 --- a/qspy/dict/qspy211020_120243.dic +++ /dev/null @@ -1,63 +0,0 @@ --v694 --T4 --O4 --F4 --S2 --E4 --Q4 --P4 --B4 --C4 --t211020_120243 - -Obj-Dic: -4 -0x0040B11B l_clock_tick -0x004124C0 Philo_inst[0] -0x004124EC Philo_inst[0].timeEvt -0x00412500 Philo_inst[1] -0x0041252C Philo_inst[1].timeEvt -0x00412540 Philo_inst[2] -0x0041256C Philo_inst[2].timeEvt -0x00412580 Philo_inst[3] -0x004125AC Philo_inst[3].timeEvt -0x004125C0 Philo_inst[4] -0x004125EC Philo_inst[4].timeEvt -0x00412600 Table_inst -0x00412640 EvtPool1 -0x00412840 QS_RX -*** -Fun-Dic: -4 -0x004019DC Philo_initial -0x00401B72 Philo_eating -0x00401C6B Philo_hungry -0x00401D3C Philo_thinking -0x00401FC6 Table_paused -0x00402104 Table_active -0x00402149 Table_serving -*** -Usr-Dic: -1 -0x00000064 PHILO_STAT -0x0000007C QUTEST_ON_POST -*** -Sig-Dic: -4 -00000004 0x00000000 EAT_SIG -00000005 0x00000000 DONE_SIG -00000006 0x00000000 PAUSE_SIG -00000007 0x00000000 SERVE_SIG -00000008 0x00000000 TEST_SIG -00000010 0x004124C0 HUNGRY_SIG -00000010 0x004125C0 HUNGRY_SIG -00000010 0x00412540 HUNGRY_SIG -00000010 0x00412580 HUNGRY_SIG -00000010 0x00412500 HUNGRY_SIG -00000010 0x00412600 HUNGRY_SIG -00000011 0x004124C0 TIMEOUT_SIG -00000011 0x00412500 TIMEOUT_SIG -00000011 0x004125C0 TIMEOUT_SIG -00000011 0x00412540 TIMEOUT_SIG -00000011 0x00412580 TIMEOUT_SIG -*** diff --git a/qspy/dict/test_dpp-qpc.bat b/qspy/dict/test_dpp-qpc.bat deleted file mode 100644 index 2cb5d54..0000000 --- a/qspy/dict/test_dpp-qpc.bat +++ /dev/null @@ -1 +0,0 @@ -qspy -f dpp-qpc-no-dict.bin -d qspy211020_120243.dic \ No newline at end of file diff --git a/qspy/include/be.h b/qspy/include/be.h deleted file mode 100644 index 2547022..0000000 --- a/qspy/include/be.h +++ /dev/null @@ -1,51 +0,0 @@ -/*============================================================================ -* QP/C Real-Time Embedded Framework (RTEF) -* Copyright (C) 2005 Quantum Leaps, LLC. All rights reserved. -* -* SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-QL-commercial -* -* This software is dual-licensed under the terms of the open source GNU -* General Public License version 3 (or any later version), or alternatively, -* under the terms of one of the closed source Quantum Leaps commercial -* licenses. -* -* The terms of the open source GNU General Public License version 3 -* can be found at: -* -* The terms of the closed source Quantum Leaps commercial licenses -* can be found at: -* -* Redistributions in source code must retain this top-level comment block. -* Plagiarizing this software to sidestep the license obligations is illegal. -* -* Contact information: -* -* -============================================================================*/ -/*! -* @date Last updated on: 2021-12-23 -* @version Last updated for version: 7.0.0 -* -* @file -* @brief Back-End connection point for the external Front-Ends -*/ -#ifndef BE_H_ -#define BE_H_ - -#ifdef __cplusplus -extern "C" { -#endif - -void BE_parse(unsigned char *buf, uint32_t nBytes); -void BE_parseRecFromFE (QSpyRecord * const qrec); -int BE_parseRecFromTarget(QSpyRecord * const qrec); /*see QSPY_CustParseFun*/ - -void BE_onStartup(void); -void BE_onCleanup(void); -void BE_sendLine(void); /* send the QSPY parsed line to the Front-End */ - -#ifdef __cplusplus -} -#endif - -#endif /* BE_H_ */ diff --git a/qspy/include/getopt.h b/qspy/include/getopt.h deleted file mode 100644 index d46fca1..0000000 --- a/qspy/include/getopt.h +++ /dev/null @@ -1,49 +0,0 @@ -/***************************************************************************** -* getopt.c - competent and free getopt library. -* -* Copyright (c) 2002-2003, Mark K. Kim -* Copyright (c) 2012-2017, Kim Grasman -* -* Modified by Quantum Leaps 2018 -* -* Redistribution and use in source and binary forms, with or without -* modification, are permitted provided that the following conditions are met: -* * Redistributions of source code must retain the above copyright -* notice, this list of conditions and the following disclaimer. -* * Redistributions in binary form must reproduce the above copyright -* notice, this list of conditions and the following disclaimer in the -* documentation and/or other materials provided with the distribution. -* * Neither the name of Kim Grasman nor the -* names of contributors may be used to endorse or promote products -* derived from this software without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -* ARE DISCLAIMED. IN NO EVENT SHALL KIM GRASMAN BE LIABLE FOR ANY -* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND -* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*****************************************************************************/ -#ifndef GETOPT_H_ -#define GETOPT_H_ - -#if defined(__cplusplus) -extern "C" { -#endif - -extern char const *optarg; /* argument of current option */ -extern int optind; /* index of first non-option in argv */ -extern int optopt; /* single option character, as parsed */ -extern int opterr; /* flag to enable built-in diagnostics */ - -int getopt(int argc, char *argv[], char const *optstr); - -#if defined(__cplusplus) -} -#endif - -#endif /* GETOPT_H_ */ diff --git a/qspy/include/pal.h b/qspy/include/pal.h deleted file mode 100644 index f0ea219..0000000 --- a/qspy/include/pal.h +++ /dev/null @@ -1,100 +0,0 @@ -/*============================================================================ -* QP/C Real-Time Embedded Framework (RTEF) -* Copyright (C) 2005 Quantum Leaps, LLC. All rights reserved. -* -* SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-QL-commercial -* -* This software is dual-licensed under the terms of the open source GNU -* General Public License version 3 (or any later version), or alternatively, -* under the terms of one of the closed source Quantum Leaps commercial -* licenses. -* -* The terms of the open source GNU General Public License version 3 -* can be found at: -* -* The terms of the closed source Quantum Leaps commercial licenses -* can be found at: -* -* Redistributions in source code must retain this top-level comment block. -* Plagiarizing this software to sidestep the license obligations is illegal. -* -* Contact information: -* -* -============================================================================*/ -/*! -* @date Last updated on: 2024-06-21 -* @version Last updated for version: 7.4.0 -* -* @file -* @brief Platform Abstraction Layer (PAL) -*/ -#ifndef PAL_H_ -#define PAL_H_ - -#ifdef __cplusplus -extern "C" { -#endif - -/* events for the QSPY event loop... */ -typedef enum { - QSPY_NO_EVT, - QSPY_TARGET_INPUT_EVT, - QSPY_FE_INPUT_EVT, - QSPY_KEYBOARD_EVT, - QSPY_DONE_EVT, - QSPY_ERROR_EVT -} QSPYEvtType; - -/* The PAL "virtual table" contains operations that are dependent -* on the choice of target connection. This connection is chosen -* by command-line options and is established by calling one of the -* PAL_openTarget???() functions -*/ -typedef struct { - QSPYEvtType (*getEvt)(unsigned char *buf, uint32_t *pBytes); - QSpyStatus (*send2Target)(unsigned char *buf, uint32_t nBytes); - void (*cleanup)(void); -} PAL_VtblType; - -extern PAL_VtblType PAL_vtbl; - -/* typedefs needed for qpc_qs.h */ -typedef int int_t; -typedef int enum_t; -typedef float float32_t; -typedef double float64_t; - -QSpyStatus PAL_openBE(int portNum); /* open Back-End socket */ -void PAL_closeBE(void); /* close Back-End socket */ -void PAL_send2FE(unsigned char const *buf, uint32_t nBytes); /* to Front-End */ -void PAL_detachFE(void); /* detach Front-End */ -void PAL_clearScreen(void); - -QSpyStatus PAL_openTargetSer(char const *comName, int baudRate); -QSpyStatus PAL_openTargetTcp(int portNum); -QSpyStatus PAL_openTargetFile(char const *fName); - -QSpyStatus PAL_openKbd(bool kbd_inp, bool color); -void PAL_closeKbd(void); -void PAL_exit(void); - -QSPYEvtType PAL_receiveBe (unsigned char *buf, uint32_t *pBytes); -QSPYEvtType PAL_receiveKbd(unsigned char *buf, uint32_t *pBytes); -void PAL_updateReadySet(int targetConn); - -#ifdef __cplusplus -} -#endif - -/* QSPY assertions... */ -#ifdef Q_NASSERT /* Q_NASSERT defined--assertion checking disabled */ -#define Q_ASSERT(test_) ((void)0) -#else /* assertion checking enabled */ -#define Q_ASSERT(test_) ((test_) \ - ? (void)0 : Q_onError(__FILE__, __LINE__)) - -_Noreturn void Q_onError(char const * const module, int const id); -#endif - -#endif /* PAL_H_ */ diff --git a/qspy/include/qpc_qs.h b/qspy/include/qpc_qs.h deleted file mode 100644 index 0610613..0000000 --- a/qspy/include/qpc_qs.h +++ /dev/null @@ -1,1033 +0,0 @@ -//$file${include::qs.h} vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv -// -// Model: qpc.qm -// File: ${include::qs.h} -// -// This code has been generated by QM 6.1.1 . -// DO NOT EDIT THIS FILE MANUALLY. All your changes will be lost. -// -// This code is covered by the following QP license: -// License # : LicenseRef-QL-dual -// Issued to : Any user of the QP/C real-time embedded framework -// Framework(s) : qpc -// Support ends : 2024-12-31 -// License scope: -// -// Copyright (C) 2005 Quantum Leaps, LLC . -// -// Q u a n t u m L e a P s -// ------------------------ -// Modern Embedded Software -// -// SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-QL-commercial -// -// This software is dual-licensed under the terms of the open source GNU -// General Public License version 3 (or any later version), or alternatively, -// under the terms of one of the closed source Quantum Leaps commercial -// licenses. -// -// The terms of the open source GNU General Public License version 3 -// can be found at: -// -// The terms of the closed source Quantum Leaps commercial licenses -// can be found at: -// -// Redistributions in source code must retain this top-level comment block. -// Plagiarizing this software to sidestep the license obligations is illegal. -// -// Contact information: -// -// -// -//$endhead${include::qs.h} ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -#ifndef QS_H_ -#define QS_H_ - -#ifndef Q_SPY -#error "Q_SPY must be defined to include qs.h" -#endif - -//============================================================================ -//! @cond INTERNAL - -#ifndef QS_CTR_SIZE -#define QS_CTR_SIZE 2U -#endif - -#ifndef QS_TIME_SIZE -#define QS_TIME_SIZE 4U -#endif - -//! @endcond -//============================================================================ - -//$declare${QS::types} vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv - -//${QS::types::QS} ........................................................... -//! @class QS -typedef struct QS { - //! @cond INTERNAL - uint8_t dummy; - //! @endcond -} QS; - -//${QS::types::QSpyPre} ...................................................... -//! @static @public @memberof QS -//! pre-defined QS record IDs -enum QSpyPre { - // [0] QS session (not maskable) - QS_EMPTY, //!< QS record for cleanly starting a session - - // [1] SM records - QS_QEP_STATE_ENTRY, //!< a state was entered - QS_QEP_STATE_EXIT, //!< a state was exited - QS_QEP_STATE_INIT, //!< an initial transition was taken in a state - QS_QEP_INIT_TRAN, //!< the top-most initial transition was taken - QS_QEP_INTERN_TRAN, //!< an internal transition was taken - QS_QEP_TRAN, //!< a regular transition was taken - QS_QEP_IGNORED, //!< an event was ignored (silently discarded) - QS_QEP_DISPATCH, //!< an event was dispatched (begin of RTC step) - QS_QEP_UNHANDLED, //!< an event was un-handled due to a guard - - // [10] Active Object (AO) records - QS_QF_ACTIVE_DEFER, //!< AO deferred an event - QS_QF_ACTIVE_RECALL, //!< AO recalled an event - QS_QF_ACTIVE_SUBSCRIBE, //!< an AO subscribed to an event - QS_QF_ACTIVE_UNSUBSCRIBE, //!< an AO unsubscribed to an event - QS_QF_ACTIVE_POST, //!< an event was posted (FIFO) directly to AO - QS_QF_ACTIVE_POST_LIFO, //!< an event was posted (LIFO) directly to AO - QS_QF_ACTIVE_GET, //!< AO got an event and its queue is not empty - QS_QF_ACTIVE_GET_LAST,//!< AO got an event and its queue is empty - QS_QF_ACTIVE_RECALL_ATTEMPT, //!< AO attempted to recall an event - - // [19] Event Queue (EQ) records - QS_QF_EQUEUE_POST, //!< an event was posted (FIFO) to a raw queue - QS_QF_EQUEUE_POST_LIFO, //!< an event was posted (LIFO) to a raw queue - QS_QF_EQUEUE_GET, //!< get an event and queue still not empty - QS_QF_EQUEUE_GET_LAST,//!< get the last event from the queue - - // [23] Framework (QF) records - QS_QF_NEW_ATTEMPT, //!< an attempt to allocate an event failed - - // [24] Memory Pool (MP) records - QS_QF_MPOOL_GET, //!< a memory block was removed from memory pool - QS_QF_MPOOL_PUT, //!< a memory block was returned to memory pool - - // [26] Additional Framework (QF) records - QS_QF_PUBLISH, //!< an event was published to active objects - QS_QF_NEW_REF, //!< new event reference was created - QS_QF_NEW, //!< new event was created - QS_QF_GC_ATTEMPT, //!< garbage collection attempt - QS_QF_GC, //!< garbage collection - QS_QF_TICK, //!< QTimeEvt tick was called - - // [32] Time Event (TE) records - QS_QF_TIMEEVT_ARM, //!< a time event was armed - QS_QF_TIMEEVT_AUTO_DISARM, //!< a time event expired and was disarmed - QS_QF_TIMEEVT_DISARM_ATTEMPT,//!< attempt to disarm a disarmed QTimeEvt - QS_QF_TIMEEVT_DISARM, //!< true disarming of an armed time event - QS_QF_TIMEEVT_REARM, //!< rearming of a time event - QS_QF_TIMEEVT_POST, //!< a time event posted itself directly to an AO - - // [38] Additional Framework (QF) records - QS_QF_DELETE_REF, //!< an event reference is about to be deleted - QS_QF_CRIT_ENTRY, //!< critical section was entered - QS_QF_CRIT_EXIT, //!< critical section was exited - QS_QF_ISR_ENTRY, //!< an ISR was entered - QS_QF_ISR_EXIT, //!< an ISR was exited - QS_QF_INT_DISABLE, //!< interrupts were disabled - QS_QF_INT_ENABLE, //!< interrupts were enabled - - // [45] Additional Active Object (AO) records - QS_QF_ACTIVE_POST_ATTEMPT,//!< attempt to post an evt to AO failed - - // [46] Additional Event Queue (EQ) records - QS_QF_EQUEUE_POST_ATTEMPT,//!< attempt to post evt to QEQueue failed - - // [47] Additional Memory Pool (MP) records - QS_QF_MPOOL_GET_ATTEMPT, //!< attempt to get a memory block failed - - // [48] Scheduler (SC) records - QS_SCHED_PREEMPT, //!< scheduler asynchronously preempted a task - QS_SCHED_RESTORE, //!< scheduler restored preempted task - QS_SCHED_LOCK, //!< scheduler was locked - QS_SCHED_UNLOCK, //!< scheduler was unlocked - QS_SCHED_NEXT, //!< scheduler started next task - QS_SCHED_IDLE, //!< scheduler restored the idle task - - // [54] Miscellaneous QS records (not maskable) - QS_ENUM_DICT, //!< enumeration dictionary entry - - // [55] Additional QEP records - QS_QEP_TRAN_HIST, //!< a tran to history was taken - QS_QEP_TRAN_EP, //!< a tran to entry point into a submachine - QS_QEP_TRAN_XP, //!< a tran to exit point out of a submachine - - // [58] Miscellaneous QS records (not maskable) - QS_TEST_PAUSED, //!< test has been paused - QS_TEST_PROBE_GET, //!< reports that Test-Probe has been used - QS_SIG_DICT, //!< signal dictionary entry - QS_OBJ_DICT, //!< object dictionary entry - QS_FUN_DICT, //!< function dictionary entry - QS_USR_DICT, //!< user QS record dictionary entry - QS_TARGET_INFO, //!< reports the Target information - QS_TARGET_DONE, //!< reports completion of a user callback - QS_RX_STATUS, //!< reports QS data receive status - QS_QUERY_DATA, //!< reports the data from "current object" query - QS_PEEK_DATA, //!< reports the data from the PEEK query - QS_ASSERT_FAIL, //!< assertion failed in the code - QS_QF_RUN, //!< QF_run() was entered - - // [71] Semaphore (SEM) records - QS_SEM_TAKE, //!< a semaphore was taken by a thread - QS_SEM_BLOCK, //!< a semaphore blocked a thread - QS_SEM_SIGNAL, //!< a semaphore was signaled - QS_SEM_BLOCK_ATTEMPT, //!< a semaphore blocked was attempted - - // [75] Mutex (MTX) records - QS_MTX_LOCK, //!< a mutex was locked - QS_MTX_BLOCK, //!< a mutex blocked a thread - QS_MTX_UNLOCK, //!< a mutex was unlocked - QS_MTX_LOCK_ATTEMPT, //!< a mutex lock was attempted - QS_MTX_BLOCK_ATTEMPT, //!< a mutex blocking was attempted - QS_MTX_UNLOCK_ATTEMPT,//!< a mutex unlock was attempted - - // [81] - QS_PRE_MAX //!< the # predefined signals -}; - -//${QS::types::QSpyGroups} ................................................... -//! @static @public @memberof QS -//! QS-TX record groups for QS_GLB_FILTER() -enum QSpyGroups { - QS_ALL_RECORDS = 0xF0,//!< all maskable QS records - QS_SM_RECORDS, //!< State Machine QS records - QS_AO_RECORDS, //!< Active Object QS records - QS_EQ_RECORDS, //!< Event Queues QS records - QS_MP_RECORDS, //!< Memory Pools QS records - QS_TE_RECORDS, //!< Time Events QS records - QS_QF_RECORDS, //!< QF QS records - QS_SC_RECORDS, //!< Scheduler QS records - QS_SEM_RECORDS, //!< Semaphore QS records - QS_MTX_RECORDS, //!< Mutex QS records - QS_U0_RECORDS, //!< User Group 100-104 records - QS_U1_RECORDS, //!< User Group 105-109 records - QS_U2_RECORDS, //!< User Group 110-114 records - QS_U3_RECORDS, //!< User Group 115-119 records - QS_U4_RECORDS, //!< User Group 120-124 records - QS_UA_RECORDS //!< All User records -}; - -//${QS::types::QSpyUserOffsets} .............................................. -//! @static @public @memberof QS -//! QS user record group offsets for QS_GLB_FILTER() -enum QSpyUserOffsets { - QS_USER = 100, //!< the first record available to QS users - QS_USER0 = QS_USER, //!< offset for User Group 0 - QS_USER1 = (enum_t)QS_USER0 + 5, //!< offset for User Group 1 - QS_USER2 = (enum_t)QS_USER1 + 5, //!< offset for User Group 2 - QS_USER3 = (enum_t)QS_USER2 + 5, //!< offset for User Group 3 - QS_USER4 = (enum_t)QS_USER3 + 5 //!< offset for User Group 4 -}; - -//${QS::types::QSpyIdOffsets} ................................................ -//! @static @public @memberof QS -//! QS ID offsets for QS_LOC_FILTER() -enum QSpyIdOffsets { - QS_AO_ID = 0, //!< offset for AO priorities - QS_EP_ID = 64, //!< offset for event-pool IDs - QS_EQ_ID = 80, //!< offset for event-queue IDs - QS_AP_ID = 96 //!< offset for Application-specific IDs -}; - -//${QS::types::QSpyIdGroups} ................................................. -//! @static @public @memberof QS -//! QS ID groups for QS_LOC_FILTER() -enum QSpyIdGroups { - QS_ALL_IDS = 0xF0, //!< all QS IDs - QS_AO_IDS = 0x80 + (enum_t)QS_AO_ID, //!< AO IDs (priorities) - QS_EP_IDS = 0x80 + (enum_t)QS_EP_ID, //!< event-pool IDs - QS_EQ_IDS = 0x80 + (enum_t)QS_EQ_ID, //!< event-queue IDs - QS_AP_IDS = 0x80 + (enum_t)QS_AP_ID //!< Application-specific IDs -}; - -//${QS::types::QSpyId} ....................................................... -//! @struct QSpyId -typedef struct { uint8_t prio; } QSpyId; - -//${QS::types::QSObj} ........................................................ -#if (QS_OBJ_PTR_SIZE == 2U) -typedef uint16_t QSObj; -#endif // (QS_OBJ_PTR_SIZE == 2U) - -//${QS::types::QSObj} ........................................................ -#if (QS_OBJ_PTR_SIZE == 4U) -typedef uint32_t QSObj; -#endif // (QS_OBJ_PTR_SIZE == 4U) - -//${QS::types::QSObj} ........................................................ -#if (QS_OBJ_PTR_SIZE == 8U) -typedef uint64_t QSObj; -#endif // (QS_OBJ_PTR_SIZE == 8U) - -//${QS::types::QSFun} ........................................................ -#if (QS_FUN_PTR_SIZE == 2U) -typedef uint16_t QSFun; -#endif // (QS_FUN_PTR_SIZE == 2U) - -//${QS::types::QSFun} ........................................................ -#if (QS_FUN_PTR_SIZE == 4U) -typedef uint32_t QSFun; -#endif // (QS_FUN_PTR_SIZE == 4U) - -//${QS::types::QSFun} ........................................................ -#if (QS_FUN_PTR_SIZE == 8U) -typedef uint64_t QSFun; -#endif // (QS_FUN_PTR_SIZE == 8U) - -//${QS::types::QSpyFunPtr} ................................................... -//! @static @private @memberof QS -typedef void (* QSpyFunPtr )(void); - -//${QS::types::QSCtr} ........................................................ -#if (QS_CTR_SIZE == 2U) -typedef uint16_t QSCtr; -#endif // (QS_CTR_SIZE == 2U) - -//${QS::types::QSCtr} ........................................................ -#if (QS_CTR_SIZE == 4U) -typedef uint32_t QSCtr; -#endif // (QS_CTR_SIZE == 4U) - -//${QS::types::QSTimeCtr} .................................................... -#if (QS_TIME_SIZE == 2U) -typedef uint16_t QSTimeCtr; -#endif // (QS_TIME_SIZE == 2U) - -//${QS::types::QSTimeCtr} .................................................... -#if (QS_TIME_SIZE == 4U) -typedef uint32_t QSTimeCtr; -#endif // (QS_TIME_SIZE == 4U) -//$enddecl${QS::types} ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -//$declare${QS::filters} vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv - -//${QS::filters::Filter} ..................................................... -//! @struct QS_Filter -typedef struct { -// public: - uint8_t glb[16]; - uint8_t loc[16]; -} QS_Filter; - -//${QS::filters::filt_} ...................................................... -//! @static @private @memberof QS -extern QS_Filter QS_filt_; -//$enddecl${QS::filters} ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -//$declare${QS-macros} vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv - -//${QS-macros::QS_INIT} ...................................................... -#define QS_INIT(arg_) (QS_onStartup(arg_)) - -//${QS-macros::QS_EXIT} ...................................................... -#define QS_EXIT() (QS_onCleanup()) - -//${QS-macros::QS_OUTPUT} .................................................... -#define QS_OUTPUT() (QS_output()) - -//${QS-macros::QS_RX_INPUT} .................................................. -#define QS_RX_INPUT() (QS_rx_input()) - -//${QS-macros::QS_GLB_FILTER} ................................................ -#define QS_GLB_FILTER(rec_) (QS_glbFilter_((int_fast16_t)(rec_))) - -//${QS-macros::QS_LOC_FILTER} ................................................ -#define QS_LOC_FILTER(qsId_) (QS_locFilter_((int_fast16_t)(qsId_))) - -//${QS-macros::QS_BEGIN_ID} .................................................. -#define QS_BEGIN_ID(rec_, qsId_) \ -if (QS_GLB_CHECK_(rec_) && QS_LOC_CHECK_(qsId_)) { \ - QS_CRIT_STAT \ - QS_CRIT_ENTRY(); \ - QS_MEM_SYS(); \ - QS_beginRec_((uint_fast8_t)(rec_)); \ - QS_TIME_PRE_(); { - -//${QS-macros::QS_END} ....................................................... -#define QS_END() } \ - QS_endRec_(); \ - QS_MEM_APP(); \ - QS_CRIT_EXIT(); \ -} - -//${QS-macros::QS_FLUSH} ..................................................... -#define QS_FLUSH() (QS_onFlush()) - -//${QS-macros::QS_BEGIN_INCRIT} .............................................. -#define QS_BEGIN_INCRIT(rec_, qsId_) \ -if (QS_GLB_CHECK_(rec_) && QS_LOC_CHECK_(qsId_)) { \ - QS_beginRec_((uint_fast8_t)(rec_)); \ - QS_TIME_PRE_(); { - -//${QS-macros::QS_END_INCRIT} ................................................ -#define QS_END_INCRIT() } \ - QS_endRec_(); \ -} - -//${QS-macros::QS_GLB_CHECK_} ................................................ -#define QS_GLB_CHECK_(rec_) \ - (((uint_fast8_t)QS_filt_.glb[(uint_fast8_t)(rec_) >> 3U] \ - & ((uint_fast8_t)1U << ((uint_fast8_t)(rec_) & 7U))) != 0U) - -//${QS-macros::QS_LOC_CHECK_} ................................................ -#define QS_LOC_CHECK_(qsId_) \ - (((uint_fast8_t)QS_filt_.loc[(uint_fast8_t)(qsId_) >> 3U] \ - & ((uint_fast8_t)1U << ((uint_fast8_t)(qsId_) & 7U))) != 0U) - -//${QS-macros::QS_REC_DONE} .................................................. -#ifndef QS_REC_DONE -#define QS_REC_DONE() ((void)0) -#endif // ndef QS_REC_DONE - -//${QS-macros::QS_I8} ........................................................ -#define QS_I8(width_, data_) \ - (QS_u8_fmt_((uint8_t)(((width_) << 4U) & 0x7U) | (uint8_t)QS_I8_ENUM_T, \ - (data_))) - -//${QS-macros::QS_U8} ........................................................ -#define QS_U8(width_, data_) \ - (QS_u8_fmt_((uint8_t)(((width_) << 4)) | (uint8_t)QS_U8_T, (data_))) - -//${QS-macros::QS_I16} ....................................................... -#define QS_I16(width_, data_) \ - (QS_u16_fmt_((uint8_t)(((width_) << 4)) | (uint8_t)QS_I16_T, (data_))) - -//${QS-macros::QS_U16} ....................................................... -#define QS_U16(width_, data_) \ - (QS_u16_fmt_((uint8_t)(((width_) << 4)) | (uint8_t)QS_U16_T, (data_))) - -//${QS-macros::QS_I32} ....................................................... -#define QS_I32(width_, data_) \ - (QS_u32_fmt_((uint8_t)(((width_) << 4)) | (uint8_t)QS_I32_T, (data_))) - -//${QS-macros::QS_U32} ....................................................... -#define QS_U32(width_, data_) \ - (QS_u32_fmt_((uint8_t)(((width_) << 4)) | (uint8_t)QS_U32_T, (data_))) - -//${QS-macros::QS_I64} ....................................................... -#define QS_I64(width_, data_) \ - (QS_u64_fmt_((uint8_t)(((width_) << 4)) | (uint8_t)QS_I64_T, (data_))) - -//${QS-macros::QS_U64} ....................................................... -#define QS_U64(width_, data_) \ - (QS_u64_fmt_((uint8_t)(((width_) << 4)) | (uint8_t)QS_U64_T, (data_))) - -//${QS-macros::QS_F32} ....................................................... -#define QS_F32(width_, data_) \ - (QS_f32_fmt_((uint8_t)(((width_) << 4)) | (uint8_t)QS_F32_T, (data_))) - -//${QS-macros::QS_F64} ....................................................... -#define QS_F64(width_, data_) \ - (QS_f64_fmt_((uint8_t)(((width_) << 4)) | (uint8_t)QS_F64_T, (data_))) - -//${QS-macros::QS_STR} ....................................................... -#define QS_STR(str_) (QS_str_fmt_((str_))) - -//${QS-macros::QS_MEM} ....................................................... -#define QS_MEM(mem_, size_) (QS_mem_fmt_((mem_), (size_))) - -//${QS-macros::QS_ENUM} ...................................................... -#define QS_ENUM(group_, value_) \ - (QS_u8_fmt_((uint8_t)(0x80U | ((group_) << 4U)) | (uint8_t)QS_I8_ENUM_T,\ - (uint8_t)(value_))) - -//${QS-macros::QS_TIME_PRE_} ................................................. -#if (QS_TIME_SIZE == 2U) -#define QS_TIME_PRE_() (QS_u16_raw_(QS_onGetTime())) -#endif // (QS_TIME_SIZE == 2U) - -//${QS-macros::QS_TIME_PRE_} ................................................. -#if (QS_TIME_SIZE == 4U) -#define QS_TIME_PRE_() (QS_u32_raw_(QS_onGetTime())) -#endif // (QS_TIME_SIZE == 4U) - -//${QS-macros::QS_OBJ} ....................................................... -#if (QS_OBJ_PTR_SIZE == 2U) -#define QS_OBJ(obj_) (QS_u16_fmt_(QS_OBJ_T, (uint16_t)(obj_))) -#endif // (QS_OBJ_PTR_SIZE == 2U) - -//${QS-macros::QS_OBJ} ....................................................... -#if (QS_OBJ_PTR_SIZE == 4U) -#define QS_OBJ(obj_) (QS_u32_fmt_(QS_OBJ_T, (uint32_t)(obj_))) -#endif // (QS_OBJ_PTR_SIZE == 4U) - -//${QS-macros::QS_OBJ} ....................................................... -#if (QS_OBJ_PTR_SIZE == 8U) -#define QS_OBJ(obj_) (QS_u64_fmt_(QS_OBJ_T, (uint64_t)(obj_))) -#endif // (QS_OBJ_PTR_SIZE == 8U) - -//${QS-macros::QS_FUN} ....................................................... -#if (QS_FUN_PTR_SIZE == 2U) -#define QS_FUN(fun_) (QS_u16_fmt_(QS_FUN_T, (uint16_t)(fun_))) -#endif // (QS_FUN_PTR_SIZE == 2U) - -//${QS-macros::QS_FUN} ....................................................... -#if (QS_FUN_PTR_SIZE == 4U) -#define QS_FUN(fun_) (QS_u32_fmt_(QS_FUN_T, (uint32_t)(fun_))) -#endif // (QS_FUN_PTR_SIZE == 4U) - -//${QS-macros::QS_FUN} ....................................................... -#if (QS_FUN_PTR_SIZE == 8U) -#define QS_FUN(fun_) (QS_u64_fmt_(QS_FUN_T, (uint64_t)(fun_))) -#endif // (QS_FUN_PTR_SIZE == 8U) - -//${QS-macros::QS_SIG} ....................................................... -#if (Q_SIGNAL_SIZE == 1U) -#define QS_SIG(sig_, obj_) \ - QS_u8_fmt_(QS_SIG_T, (sig_)); \ - QS_obj_raw_(obj_) -#endif // (Q_SIGNAL_SIZE == 1U) - -//${QS-macros::QS_SIG} ....................................................... -#if (Q_SIGNAL_SIZE == 2U) -#define QS_SIG(sig_, obj_) \ - QS_u16_fmt_(QS_SIG_T, (sig_)); \ - QS_obj_raw_(obj_) -#endif // (Q_SIGNAL_SIZE == 2U) - -//${QS-macros::QS_SIG} ....................................................... -#if (Q_SIGNAL_SIZE == 4U) -#define QS_SIG(sig_, obj_) \ - QS_u32_fmt_(QS_SIG_T, (sig_)); \ - QS_obj_raw_(obj_) -#endif // (Q_SIGNAL_SIZE == 4U) - -//${QS-macros::QS_SIG_DICTIONARY} ............................................ -#define QS_SIG_DICTIONARY(sig_, obj_) \ - (QS_sig_dict_pre_((QSignal)(sig_), (obj_), #sig_)) - -//${QS-macros::QS_OBJ_DICTIONARY} ............................................ -#define QS_OBJ_DICTIONARY(obj_) \ - (QS_obj_dict_pre_((obj_), #obj_)) - -//${QS-macros::QS_OBJ_ARR_DICTIONARY} ........................................ -#define QS_OBJ_ARR_DICTIONARY(obj_, idx_) \ - (QS_obj_arr_dict_pre_((obj_), (idx_), #obj_)) - -//${QS-macros::QS_FUN_DICTIONARY} ............................................ -#define QS_FUN_DICTIONARY(fun_) \ - (QS_fun_dict_pre_((void (*)(void))(fun_), #fun_)) - -//${QS-macros::QS_USR_DICTIONARY} ............................................ -#define QS_USR_DICTIONARY(rec_) \ - (QS_usr_dict_pre_((rec_), #rec_)) - -//${QS-macros::QS_ENUM_DICTIONARY} ........................................... -#define QS_ENUM_DICTIONARY(value_, group_) \ - (QS_enum_dict_pre_((value_), (group_), #value_)) - -//${QS-macros::QS_RX_PUT} .................................................... -#define QS_RX_PUT(b_) (QS_rxPut((b_))) - -//${QS-macros::QS_TR_CRIT_ENTRY} ............................................. -#define QS_TR_CRIT_ENTRY() - -//${QS-macros::QS_TR_CRIT_EXIT} .............................................. -#define QS_TR_CRIT_EXIT() - -//${QS-macros::QS_TR_ISR_ENTRY} .............................................. -#define QS_TR_ISR_ENTRY(isrnest, prio) do { \ - QS_BEGIN_PRE_(QS_QF_ISR_ENTRY, 0U) \ - QS_TIME_PRE_(); \ - QS_2u8_raw_(isrnest, prio); \ - QS_END_PRE_() \ -} - -//${QS-macros::QS_TR_ISR_EXIT} ............................................... -void QS_TR_ISR_EXIT( - uint_fast8_t isrnest, - uint_fast8_t prio); - -//${QS-macros::QS_ONLY} ...................................................... -#define QS_ONLY(code_) (code_) - -//${QS-macros::QS_ASSERTION} ................................................. -#define QS_ASSERTION(module_, id_, delay_) \ - (QS_assertion_pre_((module_), (id_), (delay_))) - -//${QS-macros::QS_EOD} ....................................................... -#define QS_EOD ((uint16_t)0xFFFFU) - -//${QS-macros::QS_CMD} ....................................................... -#define QS_CMD ((uint8_t)7U) - -//${QS-macros::QS_HEX_FMT} ................................................... -#define QS_HEX_FMT ((uint8_t)0x0FU) - -//${QS-macros::QS_CRIT_STAT} ................................................. -#ifndef QS_CRIT_STAT -#define QS_CRIT_STAT QF_CRIT_STAT -#endif // ndef QS_CRIT_STAT - -//${QS-macros::QS_CRIT_ENTRY} ................................................ -#ifndef QS_CRIT_ENTRY -#define QS_CRIT_ENTRY() QF_CRIT_ENTRY() -#endif // ndef QS_CRIT_ENTRY - -//${QS-macros::QS_CRIT_EXIT} ................................................. -#ifndef QS_CRIT_EXIT -#define QS_CRIT_EXIT() QF_CRIT_EXIT() -#endif // ndef QS_CRIT_EXIT - -//${QS-macros::QS_MEM_SYS} ................................................... -#ifndef QS_MEM_SYS -#define QS_MEM_SYS() QF_MEM_SYS() -#endif // ndef QS_MEM_SYS - -//${QS-macros::QS_MEM_APP} ................................................... -#ifndef QS_MEM_APP -#define QS_MEM_APP() QF_MEM_APP() -#endif // ndef QS_MEM_APP -//$enddecl${QS-macros} ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -//============================================================================ -//! @cond INTERNAL - -typedef struct { - void const * locFilter_AP; //!< @deprecated - uint8_t * buf; - QSCtr end; - QSCtr volatile head; - QSCtr volatile tail; - QSCtr volatile used; - uint8_t volatile seq; - uint8_t volatile chksum; - uint8_t volatile critNest; - uint8_t flags; -} QS_Attr; - -extern QS_Attr QS_priv_; - -void QS_glbFilter_(int_fast16_t const filter); -void QS_locFilter_(int_fast16_t const filter); - -void QS_beginRec_(uint_fast8_t const rec); -void QS_endRec_(void); - -void QS_u8_raw_(uint8_t const d); -void QS_2u8_raw_(uint8_t const d1, uint8_t const d2); -void QS_u16_raw_(uint16_t const d); -void QS_u32_raw_(uint32_t const d); -void QS_u64_raw_(uint64_t const d); -void QS_obj_raw_(void const * const obj); -void QS_str_raw_(char const * const str); - -void QS_u8_fmt_(uint8_t const format, uint8_t const d); -void QS_u16_fmt_(uint8_t const format, uint16_t const d); -void QS_u32_fmt_(uint8_t const format, uint32_t const d); -void QS_u64_fmt_(uint8_t const format, uint64_t const d); -void QS_f32_fmt_(uint8_t const format, float32_t const f); -void QS_f64_fmt_(uint8_t const format, float64_t const d); -void QS_str_fmt_(char const * const str); -void QS_mem_fmt_(uint8_t const * const blk, uint8_t const size); - -void QS_sig_dict_pre_(QSignal const sig, void const * const obj, - char const * const name); -void QS_obj_dict_pre_(void const * const obj, char const * const name); -void QS_obj_arr_dict_pre_(void const * const obj, uint_fast16_t const idx, - char const * const name); -void QS_fun_dict_pre_(QSpyFunPtr const fun, char const * const name); -void QS_usr_dict_pre_(enum_t const rec, char const * const name); -void QS_enum_dict_pre_(enum_t const value, uint8_t const group, - char const * const name); - -void QS_assertion_pre_(char const * const module, int_t const id, - uint32_t const delay); - -void QS_target_info_pre_(uint8_t const isReset); - -//! @endcond -//============================================================================ - -//$declare${QS::QS-TX} vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv - -//${QS::QS-TX::preType} ...................................................... -//! Enumerates data elements for app-specific trace records -enum QS_preType { - QS_I8_ENUM_T, //!< signed 8-bit integer or enum format - QS_U8_T, //!< unsigned 8-bit integer format - QS_I16_T, //!< signed 16-bit integer format - QS_U16_T, //!< unsigned 16-bit integer format - QS_I32_T, //!< signed 32-bit integer format - QS_U32_T, //!< unsigned 32-bit integer format - QS_F32_T, //!< 32-bit floating point format - QS_F64_T, //!< 64-bit floating point format - QS_STR_T, //!< zero-terminated ASCII string format - QS_MEM_T, //!< up to 255-bytes memory block format - QS_SIG_T, //!< event signal format - QS_OBJ_T, //!< object pointer format - QS_FUN_T, //!< function pointer format - QS_I64_T, //!< signed 64-bit integer format - QS_U64_T //!< unsigned 64-bit integer format -}; - -//${QS::QS-TX::initBuf} ...................................................... -//! @static @public @memberof QS -void QS_initBuf( - uint8_t * const sto, - uint_fast32_t const stoSize); - -//${QS::QS-TX::getByte} ...................................................... -//! @static @public @memberof QS -uint16_t QS_getByte(void); - -//${QS::QS-TX::getBlock} ..................................................... -//! @static @public @memberof QS -uint8_t const * QS_getBlock(uint16_t * const pNbytes); - -//${QS::QS-TX::doOutput} ..................................................... -//! @static @public @memberof QS -void QS_doOutput(void); - -//${QS::QS-TX::onStartup} .................................................... -//! @static @public @memberof QS -uint8_t QS_onStartup(void const * arg); - -//${QS::QS-TX::onCleanup} .................................................... -//! @static @public @memberof QS -void QS_onCleanup(void); - -//${QS::QS-TX::onFlush} ...................................................... -//! @static @public @memberof QS -void QS_onFlush(void); - -//${QS::QS-TX::onGetTime} .................................................... -//! @static @public @memberof QS -QSTimeCtr QS_onGetTime(void); -//$enddecl${QS::QS-TX} ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -//============================================================================ -#ifdef Q_UTEST - -//$declare${QS::QUTest} vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv - -//${QS::QUTest::TProbe} ...................................................... -// @struct TProbe -struct QS_TProbe { - QSFun addr; - uint32_t data; - uint8_t idx; -}; - -//${QS::QUTest::onTestSetup} ................................................. -//! @static @public @memberof QS -void QS_onTestSetup(void); - -//${QS::QUTest::onTestTeardown} .............................................. -//! @static @public @memberof QS -void QS_onTestTeardown(void); - -//${QS::QUTest::onTestEvt} ................................................... -//! @static @public @memberof QS -void QS_onTestEvt(QEvt * e); - -//${QS::QUTest::onTestPost} .................................................. -//! @static @public @memberof QS -void QS_onTestPost( - void const * sender, - QActive * recipient, - QEvt const * e, - bool status); - -//${QS::QUTest::onTestLoop} .................................................. -//! @static @public @memberof QS -void QS_onTestLoop(void); -//$enddecl${QS::QUTest} ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -#define QUTEST_ON_POST 124 - -//============================================================================ -//! @cond INTERNAL - -typedef struct { - struct QS_TProbe tpBuf[16]; - uint8_t tpNum; - QSTimeCtr testTime; - QPSet readySet; - QPSet readySet_dis; - uint_fast8_t intLock; -} QSTestAttr; - -extern QSTestAttr QS_tstPriv_; - -void QS_test_pause_(void); -uint32_t QS_getTestProbe_(QSpyFunPtr const api); - -//! @endcond -//============================================================================ - -// QP-stub for QUTest -// NOTE: The QP-stub is needed for unit testing QP applications, -// but might NOT be needed for testing QP itself. -#if (Q_UTEST != 0) - -//$declare${QS::QUTest-stub::QHsmDummy} vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv - -//${QS::QUTest-stub::QHsmDummy} .............................................. -//! @class QHsmDummy -//! @extends QHsm -typedef struct { -// protected: - QAsm super; -} QHsmDummy; - -// public: - -//! @public @memberof QHsmDummy -void QHsmDummy_ctor(QHsmDummy * const me); - -//! @private @memberof QHsmDummy -void QHsmDummy_init_( - QAsm * const me, - void const * const par, - uint_fast8_t const qsId); - -// private: - -//! @private @memberof QHsmDummy -void QHsmDummy_dispatch_( - QAsm * const me, - QEvt const * const e, - uint_fast8_t const qsId); -//$enddecl${QS::QUTest-stub::QHsmDummy} ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -//$declare${QS::QUTest-stub::QActiveDummy} vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv - -//${QS::QUTest-stub::QActiveDummy} ........................................... -//! @class QActiveDummy -//! @extends QActive -typedef struct { -// protected: - QActive super; -} QActiveDummy; - -// public: - -//! @public @memberof QActiveDummy -void QActiveDummy_ctor(QActiveDummy * const me); - -// private: - -//! @private @memberof QActiveDummy -void QActiveDummy_init_( - QAsm * const me, - void const * const par, - uint_fast8_t const qsId); - -//! @private @memberof QActiveDummy -void QActiveDummy_dispatch_( - QAsm * const me, - QEvt const * const e, - uint_fast8_t const qsId); - -//! @private @memberof QActiveDummy -bool QActiveDummy_fakePost_( - QActive * const me, - QEvt const * const e, - uint_fast16_t const margin, - void const * const sender); - -//! @private @memberof QActiveDummy -void QActiveDummy_fakePostLIFO_( - QActive * const me, - QEvt const * const e); -//$enddecl${QS::QUTest-stub::QActiveDummy} ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -#endif // Q_UTEST != 0 - -#define QS_TEST_PROBE_DEF(fun_) \ - uint32_t const qs_tp_ = QS_getTestProbe_((void (*)(void))(fun_)); - -#define QS_TEST_PROBE(code_) \ - if (qs_tp_ != 0U) { code_ } - -#define QS_TEST_PROBE_ID(id_, code_) \ - if (qs_tp_ == (uint32_t)(id_)) { code_ } - -#define QS_TEST_PAUSE() (QS_test_pause_()) - -#else // Q_UTEST not defined - -// dummy definitions when not building for QUTEST -#define QS_TEST_PROBE_DEF(fun_) -#define QS_TEST_PROBE(code_) -#define QS_TEST_PROBE_ID(id_, code_) -#define QS_TEST_PAUSE() ((void)0) - -#endif // Q_UTEST - -//============================================================================ -//! @cond INTERNAL - -typedef struct { - uint32_t param1; - uint32_t param2; - uint32_t param3; - uint8_t idx; - uint8_t cmdId; -} CmdVar; - -typedef struct { - uint_fast8_t rate; -} TickVar; - -typedef struct { - uint16_t offs; - uint8_t size; - uint8_t num; - uint8_t idx; -} PeekVar; - -typedef struct { - uint32_t data; - uint16_t offs; - uint8_t size; - uint8_t num; - uint8_t idx; - uint8_t fill; -} PokeVar; - -typedef struct { - uint8_t data[16]; - uint8_t idx; - int8_t recId; // global/local -} FltVar; - -typedef struct { - QSObj addr; - uint8_t idx; - uint8_t kind; // see qs.h, enum QSpyObjKind - int8_t recId; -} ObjVar; - -typedef struct { - QEvt *e; - uint8_t *p; - QSignal sig; - uint16_t len; - uint8_t prio; - uint8_t idx; -} EvtVar; - -typedef struct { - void * currObj[8]; - uint8_t * buf; - QSCtr end; - QSCtr volatile head; - QSCtr volatile tail; - uint8_t state; - uint8_t esc; - uint8_t seq; - uint8_t chksum; -#ifdef Q_UTEST - bool inTestLoop; -#endif - union Variant { - CmdVar cmd; - TickVar tick; - PeekVar peek; - PokeVar poke; - FltVar flt; - ObjVar obj; - EvtVar evt; -#ifdef Q_UTEST - struct QS_TProbe tp; -#endif // Q_UTEST - } var; -} QS_RxAttr; - -//! @endcond - -//! @static @private @memberof QS -extern QS_RxAttr QS_rxPriv_; - -//============================================================================ - -//$declare${QS::QS-RX} vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv - -//${QS::QS-RX::QSpyObjKind} .................................................. -//! @static @public @memberof QS -//! Kinds of objects used in QS-RX -enum QS_QSpyObjKind { - SM_OBJ, //!< state machine object - AO_OBJ, //!< active object - MP_OBJ, //!< event pool object - EQ_OBJ, //!< raw queue object - TE_OBJ, //!< time event object - AP_OBJ, //!< generic Application-specific object - MAX_OBJ -}; - -//${QS::QS-RX::OSpyObjComb} .................................................. -//! @static @public @memberof QS -//! Object combinations for QS-RX -enum QS_OSpyObjComb { - SM_AO_OBJ = (enum_t)MAX_OBJ //!< combination of SM and AO -}; - -//${QS::QS-RX::rxInitBuf} .................................................... -//! @static @public @memberof QS -void QS_rxInitBuf( - uint8_t * const sto, - uint16_t const stoSize); - -//${QS::QS-RX::rxPut} ........................................................ -//! @static @public @memberof QS -static inline bool QS_rxPut(uint8_t const b) { - // NOTE: does not need critical section - // But requires system-level memory access (QF_MEM_SYS()). - - QSCtr head = QS_rxPriv_.head + 1U; - if (head == QS_rxPriv_.end) { - head = 0U; - } - if (head != QS_rxPriv_.tail) { // buffer NOT full? - QS_rxPriv_.buf[QS_rxPriv_.head] = b; - QS_rxPriv_.head = head; // update the head to a *valid* index - return true; // byte placed in the buffer - } - else { - return false; // byte NOT placed in the buffer - } -} - -//${QS::QS-RX::rxParse} ...................................................... -//! @static @public @memberof QS -void QS_rxParse(void); - -//${QS::QS-RX::setCurrObj} ................................................... -//! @static @public @memberof QS -void QS_setCurrObj( - uint8_t const obj_kind, - void * const obj_ptr); - -//${QS::QS-RX::rxGetNfree} ................................................... -//! @static @public @memberof QS -uint16_t QS_rxGetNfree(void); - -//${QS::QS-RX::doInput} ...................................................... -//! @static @public @memberof QS -void QS_doInput(void); - -//${QS::QS-RX::onReset} ...................................................... -//! @static @public @memberof QS -void QS_onReset(void); - -//${QS::QS-RX::onCommand} .................................................... -//! @static @public @memberof QS -void QS_onCommand( - uint8_t cmdId, - uint32_t param1, - uint32_t param2, - uint32_t param3); -//$enddecl${QS::QS-RX} ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -#endif // QS_H_ diff --git a/qspy/include/qpc_qs_pkg.h b/qspy/include/qpc_qs_pkg.h deleted file mode 100644 index 1bfcfa3..0000000 --- a/qspy/include/qpc_qs_pkg.h +++ /dev/null @@ -1,176 +0,0 @@ -//$file${include::qs_pkg.h} vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv -// -// Model: qpc.qm -// File: ${include::qs_pkg.h} -// -// This code has been generated by QM 6.1.1 . -// DO NOT EDIT THIS FILE MANUALLY. All your changes will be lost. -// -// This code is covered by the following QP license: -// License # : LicenseRef-QL-dual -// Issued to : Any user of the QP/C real-time embedded framework -// Framework(s) : qpc -// Support ends : 2024-12-31 -// License scope: -// -// Copyright (C) 2005 Quantum Leaps, LLC . -// -// Q u a n t u m L e a P s -// ------------------------ -// Modern Embedded Software -// -// SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-QL-commercial -// -// This software is dual-licensed under the terms of the open source GNU -// General Public License version 3 (or any later version), or alternatively, -// under the terms of one of the closed source Quantum Leaps commercial -// licenses. -// -// The terms of the open source GNU General Public License version 3 -// can be found at: -// -// The terms of the closed source Quantum Leaps commercial licenses -// can be found at: -// -// Redistributions in source code must retain this top-level comment block. -// Plagiarizing this software to sidestep the license obligations is illegal. -// -// Contact information: -// -// -// -//$endhead${include::qs_pkg.h} ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -#ifndef QS_PKG_H_ -#define QS_PKG_H_ - -//============================================================================ -//! @cond INTERNAL - -//! QS received record types (RX channel) -enum QSpyRxRecords { - QS_RX_INFO, //!< query Target info (ver, config, tstamp) - QS_RX_COMMAND, //!< execute a user-defined command in the Target - QS_RX_RESET, //!< reset the Target - QS_RX_TICK, //!< call system clock tick in the Target - QS_RX_PEEK, //!< peek Target memory - QS_RX_POKE, //!< poke Target memory - QS_RX_FILL, //!< fill Target memory - QS_RX_TEST_SETUP, //!< test setup - QS_RX_TEST_TEARDOWN, //!< test teardown - QS_RX_TEST_PROBE, //!< set a Test-Probe in the Target - QS_RX_GLB_FILTER, //!< set global filters in the Target - QS_RX_LOC_FILTER, //!< set local filters in the Target - QS_RX_AO_FILTER, //!< set local AO filter in the Target - QS_RX_CURR_OBJ, //!< set the "current-object" in the Target - QS_RX_TEST_CONTINUE, //!< continue a test after QS_TEST_PAUSE() - QS_RX_QUERY_CURR, //!< query the "current object" in the Target - QS_RX_EVENT //!< inject an event to the Target -}; - -//---------------------------------------------------------------------------- -#define QS_FRAME 0x7EU -#define QS_ESC 0x7DU -#define QS_ESC_XOR 0x20U -#define QS_GOOD_CHKSUM 0xFFU - -//---------------------------------------------------------------------------- -#define QS_BEGIN_PRE_(rec_, qsId_) \ - if (QS_GLB_CHECK_(rec_) && QS_LOC_CHECK_(qsId_)) { \ - QS_beginRec_((uint_fast8_t)(rec_)); -#define QS_END_PRE_() QS_endRec_(); } - -#define QS_U8_PRE_(data_) (QS_u8_raw_((uint8_t)(data_))) -#define QS_2U8_PRE_(data1_, data2_) \ - (QS_2u8_raw_((uint8_t)(data1_), (uint8_t)(data2_))) -#define QS_U16_PRE_(data_) (QS_u16_raw_((uint16_t)(data_))) -#define QS_U32_PRE_(data_) (QS_u32_raw_((uint32_t)(data_))) -#define QS_STR_PRE_(msg_) (QS_str_raw_((msg_))) -#define QS_OBJ_PRE_(obj_) (QS_obj_raw_(obj_)) - -#if (!defined Q_SIGNAL_SIZE || (Q_SIGNAL_SIZE == 1U)) - #define QS_SIG_PRE_(sig_) (QS_u8_raw_((uint8_t)sig_)) -#elif (Q_SIGNAL_SIZE == 2U) - #define QS_SIG_PRE_(sig_) (QS_u16_raw_((uint16_t)sig_)) -#elif (Q_SIGNAL_SIZE == 4U) - #define QS_SIG_PRE_(sig_) (QS_u32_raw_((uint32_t)sig_)) -#endif - -#if (!defined QS_FUN_PTR_SIZE || (QS_FUN_PTR_SIZE == 2U)) - #define QS_FUN_PRE_(fun_) (QS_u16_raw_((uint16_t)(fun_))) -#elif (QS_FUN_PTR_SIZE == 4U) - #define QS_FUN_PRE_(fun_) (QS_u32_raw_((uint32_t)(fun_))) -#elif (QS_FUN_PTR_SIZE == 8U) - #define QS_FUN_PRE_(fun_) (QS_u64_raw_((uint64_t)(fun_))) -#else - #define QS_FUN_PRE_(fun_) (QS_u32_raw_((uint32_t)(fun_))) -#endif - -//---------------------------------------------------------------------------- -#if (!defined QF_EQUEUE_CTR_SIZE || (QF_EQUEUE_CTR_SIZE == 1U)) - #define QS_EQC_PRE_(ctr_) QS_u8_raw_((uint8_t)(ctr_)) -#elif (QF_EQUEUE_CTR_SIZE == 2U) - #define QS_EQC_PRE_(ctr_) QS_u16_raw_((uint16_t)(ctr_)) -#elif (QF_EQUEUE_CTR_SIZE == 4U) - #define QS_EQC_PRE_(ctr_) QS_u32_raw_((uint32_t)(ctr_)) -#endif - -#if (!defined QF_EVENT_SIZ_SIZE || (QF_EVENT_SIZ_SIZE == 1U)) - #define QS_EVS_PRE_(size_) QS_u8_raw_((uint8_t)(size_)) -#elif (QF_EVENT_SIZ_SIZE == 2U) - #define QS_EVS_PRE_(size_) QS_u16_raw_((uint16_t)(size_)) -#elif (QF_EVENT_SIZ_SIZE == 4U) - #define QS_EVS_PRE_(size_) QS_u32_raw_((uint32_t)(size_)) -#endif - -#if (!defined QF_MPOOL_SIZ_SIZE || (QF_MPOOL_SIZ_SIZE == 1U)) - #define QS_MPS_PRE_(size_) QS_u8_raw_((uint8_t)(size_)) -#elif (QF_MPOOL_SIZ_SIZE == 2U) - #define QS_MPS_PRE_(size_) QS_u16_raw_((uint16_t)(size_)) -#elif (QF_MPOOL_SIZ_SIZE == 4U) - #define QS_MPS_PRE_(size_) QS_u32_raw_((uint32_t)(size_)) -#endif - -#if (!defined QF_MPOOL_CTR_SIZE || (QF_MPOOL_CTR_SIZE == 1U)) - #define QS_MPC_PRE_(ctr_) QS_u8_raw_((uint8_t)(ctr_)) -#elif (QF_MPOOL_CTR_SIZE == 2U) - #define QS_MPC_PRE_(ctr_) QS_u16_raw_((uint16_t)(ctr_)) -#elif (QF_MPOOL_CTR_SIZE == 4U) - #define QS_MPC_PRE_(ctr_) QS_u32_raw_((uint16_t)(ctr_)) -#endif - -#if (!defined QF_TIMEEVT_CTR_SIZE || (QF_TIMEEVT_CTR_SIZE == 1U)) - #define QS_TEC_PRE_(ctr_) QS_u8_raw_((uint8_t)(ctr_)) -#elif (QF_TIMEEVT_CTR_SIZE == 2U) - #define QS_TEC_PRE_(ctr_) QS_u16_raw_((uint16_t)(ctr_)) -#elif (QF_TIMEEVT_CTR_SIZE == 4U) - #define QS_TEC_PRE_(ctr_) QS_u32_raw_((uint32_t)(ctr_)) -#endif - -//---------------------------------------------------------------------------- -#define QS_INSERT_BYTE_(b_) \ - buf[head] = (b_); \ - ++head; \ - if (head == end) { \ - head = 0U; \ - } - -#define QS_INSERT_ESC_BYTE_(b_) \ - chksum = (uint8_t)(chksum + (b_)); \ - if (((b_) != QS_FRAME) && ((b_) != QS_ESC)) { \ - QS_INSERT_BYTE_(b_) \ - } \ - else { \ - QS_INSERT_BYTE_(QS_ESC) \ - QS_INSERT_BYTE_((uint8_t)((b_) ^ QS_ESC_XOR))\ - ++QS_priv_.used; \ - } - -//---------------------------------------------------------------------------- -#if (defined Q_UTEST) && (Q_UTEST != 0) -void QS_processTestEvts_(void); -#endif // Q_UTEST != 0 - -//! @endcond -//============================================================================ - -#endif // QS_PKG_H_ diff --git a/qspy/include/qspy.h b/qspy/include/qspy.h deleted file mode 100644 index 24d8532..0000000 --- a/qspy/include/qspy.h +++ /dev/null @@ -1,355 +0,0 @@ -/*============================================================================ -* QTools Collection -* -* Q u a n t u m L e a P s -* ------------------------ -* Modern Embedded Software -* -* Copyright (C) 2005 Quantum Leaps, LLC. All rights reserved. -* -* SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-QL-commercial -* -* This software is dual-licensed under the terms of the open source GNU -* General Public License version 3 (or any later version), or alternatively, -* under the terms of one of the closed source Quantum Leaps commercial -* licenses. -* -* The terms of the open source GNU General Public License version 3 -* can be found at: -* -* The terms of the closed source Quantum Leaps commercial licenses -* can be found at: -* -* Redistributions in source code must retain this top-level comment block. -* Plagiarizing this software to sidestep the license obligations is illegal. -* -* Contact information: -* -* -============================================================================*/ -/*! -* @date Last updated on: 2024-06-21 -* @version Last updated for version: 7.4.0 -* -* @file -* @brief Host API -*/ -#ifndef QSPY_H_ -#define QSPY_H_ - -#define QSPY_VER "7.4.0" - -#ifdef __cplusplus -extern "C" { -#endif - -/*! low-level facilities for configuring QSpy and parsing QS records ...*/ -typedef enum { - QSPY_ERROR, - QSPY_SUCCESS -} QSpyStatus; - -/*! typedef for inclusion of qpc_qs.h */ -typedef uint16_t QSignal; - -/*! QSPY record being processed */ -typedef struct { - uint8_t const *start; /*!< start of the record */ - uint8_t const *pos; /*!< current position in the stream */ - uint32_t tot_len; /*!< total length of the record, including chksum */ - int32_t len; /*!< current length of the stream */ - uint8_t rec; /*!< the record-ID (see enum QSpyRecords in qs.h) */ -} QSpyRecord; - -/* limits */ -enum { - QS_RECORD_SIZE_MAX = 512, /* max QS record size [bytes] */ - QS_LINE_LEN_MAX = 1000, /* max length of a QSPY line [chars] */ - QS_FNAME_LEN_MAX = 256, /* max length of filenames [chars] */ - QS_SEQ_LIST_LEN_MAX = 300, /* max length of the Seq list [chars] */ - QS_DNAME_LEN_MAX = 64, /* max dictionary name length [chars] */ -}; - -/* pointer to the callback function for customized QS record parsing */ -typedef int (*QSPY_CustParseFun)(QSpyRecord * const me); -typedef void (*QSPY_resetFun)(void); - -void QSpyRecord_init (QSpyRecord * const me, - uint8_t const *start, uint32_t tot_len); -QSpyStatus QSpyRecord_OK (QSpyRecord * const me); -uint32_t QSpyRecord_getUint32(QSpyRecord * const me, uint8_t size); -int32_t QSpyRecord_getInt32 (QSpyRecord * const me, uint8_t size); -uint64_t QSpyRecord_getUint64(QSpyRecord * const me, uint8_t size); -int64_t QSpyRecord_getInt64 (QSpyRecord * const me, uint8_t size); -char const *QSpyRecord_getStr (QSpyRecord * const me); -uint8_t const *QSpyRecord_getMem(QSpyRecord * const me, - uint8_t size, - uint32_t *pNum); - -/* QSPY configuration and high-level interface .............................*/ -/*! QSPY configuration parameters. @sa QSPY_config() */ -typedef struct { - uint16_t version; - uint8_t endianness; - uint8_t objPtrSize; - uint8_t funPtrSize; - uint8_t tstampSize; - uint8_t sigSize; - uint8_t evtSize; - uint8_t queueCtrSize; - uint8_t poolCtrSize; - uint8_t poolBlkSize; - uint8_t tevtCtrSize; - uint8_t tstamp[6]; -} QSpyConfig; - -typedef uint64_t KeyType; -typedef uint32_t SigType; -typedef uint64_t ObjType; - -void QSPY_config(QSpyConfig const *config, - QSPY_CustParseFun custParseFun); -void QSPY_configTxReset(QSPY_resetFun txResetFun); -void QSPY_configMatFile(void *matFile); - -void QSPY_reset(void); -void QSPY_parse(uint8_t const *buf, uint32_t nBytes); -void QSPY_txReset(void); - -/* command options */ -enum { - CMD_OPT_OFF, - CMD_OPT_ON, - CMD_OPT_TOGGLE, -}; -bool QSPY_command(uint8_t cmdId, uint8_t opt); - -void QSPY_sendEvt(QSpyRecord const * const qrec); -void QSPY_sendObj(QSpyRecord const * const qrec); -void QSPY_sendCmd(QSpyRecord const * const qrec); -void QSPY_sendTP (QSpyRecord const * const qrec); -void QSPY_showNote(QSpyRecord const * const qrec); - -uint32_t QSPY_encode(uint8_t *dstBuf, uint32_t dstSize, - uint8_t const *srcBuf, uint32_t srcBytes); -uint32_t QSPY_encodeResetCmd(uint8_t *dstBuf, uint32_t dstSize); -uint32_t QSPY_encodeInfoCmd (uint8_t *dstBuf, uint32_t dstSize); -uint32_t QSPY_encodeTickCmd (uint8_t *dstBuf, uint32_t dstSize, uint8_t rate); - -SigType QSPY_findSig(char const *name, ObjType obj); -KeyType QSPY_findObj(char const *name); -KeyType QSPY_findFun(char const *name); -KeyType QSPY_findUsr(char const *name); -KeyType QSPY_findEnum(char const *name, uint8_t group); - -#define SIG_NOT_FOUND ((SigType)-1) -#define KEY_NOT_FOUND ((KeyType)-1) - -void QSPY_cleanup(void); /* cleanup after the run */ - -char const* QSPY_tstampStr(void); - -void QSPY_onPrintLn(void); /* callback to print the last line of output */ - -/* prints information message to the QSPY output (without sending it to FE) */ -void QSPY_printInfo(void); - -/* prints error message to the QSPY output (sending it to FE) */ -void QSPY_printError(void); - -/* last human-readable line of output from QSPY ............................*/ -#define QS_LINE_OFFSET 8 -enum QSPY_LastOutputType { - /* output forwarded to the back-end... */ - REG_OUT, /* regular output from the Target */ - ERR_OUT, /* error output from QSPY */ - /* ... */ - BE_OUT, /* last message forwarded to the back-end */ - - /* output NOT forwarded to the back-end... */ - INF_OUT, /* internal info from QSPY */ - USR_OUT, /* generic user message from BE */ - TST_OUT, /* test message from BE */ -}; -typedef struct { - char buf[QS_LINE_OFFSET + QS_LINE_LEN_MAX]; - int len; /* the length of the composed string */ - int rec; /* the corresponding QS record ID */ - int type; /* the type of the output */ - int rx_status; /* the type of the RX status */ -} QSPY_LastOutput; - -typedef enum { - GRP_ERR, - GRP_INF, - GRP_DIC, - GRP_TST, - GRP_SM, - GRP_AO, - GRP_EQ, - GRP_MP, - GRP_TE, - GRP_QF, - GRP_SC, - GRP_SEM, - GRP_MTX, - GRP_USR -} QSRreRecGroup; - -/* returns the "group" of a given QS record-ID */ -QSRreRecGroup QSPY_getGroup(int recId); - -/* last output generated */ -extern QSPY_LastOutput QSPY_output; - -/* beginning of QSPY line to print */ -extern char const * const QSPY_line; - -#define SNPRINTF_LINE(format_, ...) do { \ - int n_ = SNPRINTF_S(&QSPY_output.buf[QS_LINE_OFFSET], \ - (QS_LINE_LEN_MAX - QS_LINE_OFFSET), \ - format_, __VA_ARGS__); \ - if ((0 < n_) && (n_ < QS_LINE_LEN_MAX - QS_LINE_OFFSET)) { \ - QSPY_output.len = n_; \ - } \ - else { \ - QSPY_output.len = QS_LINE_LEN_MAX - QS_LINE_OFFSET; \ - } \ -} while (0) - -#define SNPRINTF_APPEND(format_, ...) do { \ - int n_ = SNPRINTF_S(&QSPY_output.buf[QS_LINE_OFFSET + QSPY_output.len],\ - (QS_LINE_LEN_MAX - QS_LINE_OFFSET - QSPY_output.len), \ - format_, __VA_ARGS__); \ - if ((0 < n_) \ - && (n_ < QS_LINE_LEN_MAX - QS_LINE_OFFSET - QSPY_output.len)) { \ - QSPY_output.len += n_; \ - } \ - else { \ - QSPY_output.len = QS_LINE_LEN_MAX - QS_LINE_OFFSET; \ - } \ -} while (0) - -#define CONFIG_UPDATE(member_, new_, diff_) \ - if (QSPY_conf.member_ != (new_)) { \ - QSPY_conf.member_ = (new_); \ - (diff_) = 1U; \ - } else (void)0 - -/* Dictionaries ............................................................*/ -typedef struct { - KeyType key; - char name[QS_DNAME_LEN_MAX]; -} DictEntry; - -typedef struct { - DictEntry notFound; - DictEntry* sto; - int capacity; - int entries; - int keySize; -} Dictionary; - -void Dictionary_ctor(Dictionary* const me, - DictEntry* sto, uint32_t capacity); -void Dictionary_config(Dictionary* const me, int keySize); -char const* Dictionary_at(Dictionary* const me, unsigned idx); -void Dictionary_put(Dictionary* const me, KeyType key, char const* name); -char const* Dictionary_get(Dictionary* const me, KeyType key, char* buf); -int Dictionary_find(Dictionary* const me, KeyType key); -KeyType Dictionary_findKey(Dictionary* const me, char const* name); -void Dictionary_reset(Dictionary* const me); - -typedef struct { - SigType sig; - ObjType obj; - char name[QS_DNAME_LEN_MAX]; -} SigDictEntry; - -typedef struct { - SigDictEntry notFound; - SigDictEntry* sto; - int capacity; - int entries; - int ptrSize; -} SigDictionary; - -void SigDictionary_ctor(SigDictionary* const me, - SigDictEntry* sto, uint32_t capacity); -void SigDictionary_config(SigDictionary* const me, int ptrSize); -void SigDictionary_put(SigDictionary* const me, - SigType sig, ObjType obj, char const* name); -char const* SigDictionary_get(SigDictionary* const me, - SigType sig, ObjType obj, char* buf); -int SigDictionary_find(SigDictionary* const me, - SigType sig, ObjType obj); -SigType SigDictionary_findSig(SigDictionary* const me, - char const* name, ObjType obj); -void SigDictionary_reset(SigDictionary* const me); -void QSPY_resetAllDictionaries(void); - -/*==========================================================================*/ -/* facilities used by the QSPY host app only (but not for QSPY parser) */ -#ifdef QSPY_APP - -/*! commands to QSPY; @sa "packet IDs" in qutest.py or qview.py scripts */ -typedef enum { - QSPY_ATTACH = 128, /*!< attach to the QSPY Back-End */ - QSPY_DETACH, /*!< detach from the QSPY Back-End */ - QSPY_SAVE_DICT, /*!< save dictionaries to a file in QSPY */ - QSPY_TEXT_OUT, /*!< toggle text output to a file in QSPY */ - QSPY_BIN_OUT, /*!< toggle binary output to a file in QSPY */ - QSPY_MATLAB_OUT, /*!< toggle Matlab output to a file in QSPY */ - QSPY_SEQUENCE_OUT, /*!< toggle Sequence output to a file in QSPY */ - QSPY_SEND_EVENT, /*!< send event (QSPY supplying signal) */ - QSPY_SEND_AO_FILTER, /*!< send Local Filter (QSPY supplying addr) */ - QSPY_SEND_CURR_OBJ, /*!< send current Object (QSPY supplying addr) */ - QSPY_SEND_COMMAND, /*!< send command (QSPY supplying cmdId) */ - QSPY_SEND_TEST_PROBE, /*!< send Test-Probe (QSPY supplying apiId) */ - QSPY_CLEAR_SCREEN, /*!< clear the QSPY screen */ - QSPY_SHOW_NOTE, /*!< show a note in QSPY output */ - /* ... */ -} QSpyCommands; - -extern QSpyConfig QSPY_conf; -extern Dictionary QSPY_funDict; -extern Dictionary QSPY_objDict; -extern Dictionary QSPY_usrDict; -extern SigDictionary QSPY_sigDict; -extern Dictionary QSPY_enumDict[8]; - -void QSPY_setExternDict(char const* dictName); -QSpyStatus QSPY_readDict(void); -QSpyStatus QSPY_writeDict(void); - -bool QDIC_isActive(void); - -void Dictionary_write(Dictionary const* const me, FILE* stream); -bool Dictionary_read(Dictionary* const me, FILE* stream); - -void SigDictionary_write(SigDictionary const* const me, FILE* stream); -bool SigDictionary_read(SigDictionary* const me, FILE* stream); -char const* QSPY_getMatDict(char const* s); - -void QSEQ_configFile(void *seqFile); -bool QSEQ_isActive(void); -void QSEQ_config(void* seqFile, char const* seqList); -void QSEQ_updateDictionary(char const* name, KeyType key); -int QSEQ_find(KeyType key); -void QSEQ_genHeader(void); -void QSEQ_genPost(uint32_t tstamp, int src, int dst, char const* sig, - bool isAttempt); -void QSEQ_genPostLIFO(uint32_t tstamp, int src, char const* sig); -void QSEQ_genTran(uint32_t tstamp, int obj, char const* state); -void QSEQ_genPublish(uint32_t tstamp, int obj, char const* sig); -void QSEQ_genAnnotation(uint32_t tstamp, int obj, char const* ann); -void QSEQ_genTick(uint32_t rate, uint32_t nTick); -void QSEQ_dictionaryReset(void); - -#endif /* QSPY_APP */ - -#ifdef __cplusplus -} -#endif - -#endif /* QSPY_H_ */ diff --git a/qspy/include/safe_std.h b/qspy/include/safe_std.h deleted file mode 100644 index 3aba5e5..0000000 --- a/qspy/include/safe_std.h +++ /dev/null @@ -1,106 +0,0 @@ -//============================================================================ -// QP/C Real-Time Embedded Framework (RTEF) -// Copyright (C) 2005 Quantum Leaps, LLC. All rights reserved. -// -// SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-QL-commercial -// -// This software is dual-licensed under the terms of the open source GNU -// General Public License version 3 (or any later version), or alternatively, -// under the terms of one of the closed source Quantum Leaps commercial -// licenses. -// -// The terms of the open source GNU General Public License version 3 -// can be found at: -// -// The terms of the closed source Quantum Leaps commercial licenses -// can be found at: -// -// Redistributions in source code must retain this top-level comment block. -// Plagiarizing this software to sidestep the license obligations is illegal. -// -// Contact information: -// -// -//============================================================================ -//! @date Last updated on: 2024-06-21 -//! @version Last updated for: @ref qtools_7_4_0 -//! -//! @file -//! @brief "safe" and facilities -#ifndef SAFE_STD_H -#define SAFE_STD_H - -#include -#include - -// portable "safe" facilities from and ................ -#ifdef _WIN32 // Windows OS? - -#define MEMMOVE_S(dest_, num_, src_, count_) \ - (void)memmove_s(dest_, num_, src_, count_) - -#define STRNCPY_S(dest_, destsiz_, src_) \ - (void)strncpy_s(dest_, destsiz_, src_, _TRUNCATE) - -#define STRCAT_S(dest_, destsiz_, src_) \ - (void)strcat_s(dest_, destsiz_, src_) - -#define SNPRINTF_S(buf_, bufsiz_, format_, ...) \ - _snprintf_s(buf_, bufsiz_, _TRUNCATE, format_, __VA_ARGS__) - -#define PRINTF_S(format_, ...) \ - (void)printf_s(format_, __VA_ARGS__) - -#define FPRINTF_S(fp_, format_, ...) \ - (void)fprintf_s(fp_, format_, __VA_ARGS__) - -#ifdef _MSC_VER -#define FREAD_S(buf_, bufsiz_, elsiz_, count_, fp_) \ - fread_s(buf_, bufsiz_, elsiz_, count_, fp_) -#else -#define FREAD_S(buf_, bufsiz_, elsiz_, count_, fp_) \ - (void)fread(buf_, elsiz_, count_, fp_) -#endif // _MSC_VER - -#define FOPEN_S(fp_, fName_, mode_) \ -if (fopen_s(&fp_, fName_, mode_) != 0) { \ - fp_ = (FILE *)0; \ -} else (void)0 - -#define LOCALTIME_S(tm_, time_) \ - localtime_s(tm_, time_) - -#else // other OS (Linux, MacOS, etc.) ..................................... - -#define MEMMOVE_S(dest_, num_, src_, count_) \ - (void)memmove(dest_, src_, count_) - -#define STRNCPY_S(dest_, destsiz_, src_) do { \ - (void)strncpy(dest_, src_, destsiz_); \ - dest_[(destsiz_) - 1] = '\0'; \ -} while (false) - -#define STRCAT_S(dest_, destsiz_, src_) \ - (void)strcat(dest_, src_) - -#define SNPRINTF_S(buf_, bufsiz_, format_, ...) \ - snprintf(buf_, bufsiz_, format_, __VA_ARGS__) - -#define PRINTF_S(format_, ...) \ - (void)printf(format_, __VA_ARGS__) - -#define FPRINTF_S(fp_, format_, ...) \ - (void)fprintf(fp_, format_, __VA_ARGS__) - -#define FREAD_S(buf_, bufsiz_, elsiz_, count_, fp_) \ - fread(buf_, elsiz_, count_, fp_) - -#define FOPEN_S(fp_, fName_, mode_) \ - (fp_ = fopen(fName_, mode_)) - -#define LOCALTIME_S(tm_, time_) \ - memcpy(tm_, localtime(time_), sizeof(struct tm)) - -#endif // _WIN32 - -#endif // SAFE_STD_H diff --git a/qspy/posix/Makefile b/qspy/posix/Makefile deleted file mode 100644 index 5b1d482..0000000 --- a/qspy/posix/Makefile +++ /dev/null @@ -1,199 +0,0 @@ -############################################################################## -# Product: Makefile for QSPY console, POSIX (Linux/Mac-OS), GNU compiler -# Last updated for version 7.2.2 -# Last updated on 2023-01-25 -# -# Q u a n t u m L e a P s -# ------------------------ -# Modern Embedded Software -# -# Copyright (C) 2005 Quantum Leaps, LLC. All rights reserved. -# -# This program is open source software: you can redistribute it and/or -# modify it under the terms of the GNU General Public License as published -# by the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# Alternatively, this program may be distributed and modified under the -# terms of Quantum Leaps commercial licenses, which expressly supersede -# the GNU General Public License and are specifically designed for -# licensees interested in retaining the proprietary status of their code. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . -# -# Contact information: -# -# -############################################################################## -# examples of invoking this Makefile: -# building configurations: Debug (default), Release, and Spy -# make -# make CONF=dbg -# -# cleaning configurations: Debug (default), Release, and Spy -# make clean -# make CONF=dbg clean - -#----------------------------------------------------------------------------- -# project name -# -PROJECT := qspy - -#----------------------------------------------------------------------------- -# project directories: -# - -# list of all source directories used by this project -VPATH := . \ - ../source - -# list of all include directories needed by this project -INCLUDES := -I. \ - -I../include - - -#----------------------------------------------------------------------------- -# project files: -# - -# C source files... -C_SRCS := \ - getopt.c \ - qspy_pal.c \ - qspy_be.c \ - qspy_main.c \ - qspy_dict.c \ - qspy_seq.c \ - qspy_tx.c \ - qspy.c - -# C++ source files... -CPP_SRCS := - -DEFINES := -DQSPY_APP -LIB_DIRS := -LIBS := - -#----------------------------------------------------------------------------- -# GNU toolset: -# -CC := gcc -CPP := g++ -LINK := gcc # for C programs -#LINK := g++ # for C++ programs - -#----------------------------------------------------------------------------- -# basic utilities: -# -MKDIR := mkdir -p -RM := rm - -#----------------------------------------------------------------------------- -# build configurations... -# - -ifeq (dbg, $(CONF)) # Debug configuration .................................... - -BIN_DIR := dbg - -CFLAGS = -c -g -O -ffunction-sections -fdata-sections \ - -pedantic -Wall -Wextra -Wno-strict-overflow $(INCLUDES) $(DEFINES) - -CPPFLAGS = -c -g -O -ffunction-sections -fdata-sections \ - -pedantic -Wall -Wextra -Wno-strict-overflow $(INCLUDES) $(DEFINES) - -else # default Release configuration ........................................ - -BIN_DIR := rel - -CFLAGS = -c -O3 -ffunction-sections -fdata-sections -DNDEBUG \ - -pedantic -Wall -Wextra -Wno-strict-overflow $(INCLUDES) $(DEFINES) - -CPPFLAGS = -c -O3 -ffunction-sections -fdata-sections -DNDEBUG \ - -pedantic-Wall -Wextra -Wno-strict-overflow $(INCLUDES) $(DEFINES) - -endif # ..................................................................... - -UNAME := $(shell uname) -ifeq ($(UNAME), Darwin) - LINKFLAGS := -else -ifndef GCC_OLD - LINKFLAGS := -no-pie -endif -endif - -#----------------------------------------------------------------------------- -C_OBJS := $(patsubst %.c,%.o, $(C_SRCS)) -CPP_OBJS := $(patsubst %.cpp,%.o, $(CPP_SRCS)) - -TARGET_EXE := $(BIN_DIR)/$(PROJECT)$(TARGET_EXT) -C_OBJS_EXT := $(addprefix $(BIN_DIR)/, $(C_OBJS)) -C_DEPS_EXT := $(patsubst %.o,%.d, $(C_OBJS_EXT)) -CPP_OBJS_EXT := $(addprefix $(BIN_DIR)/, $(CPP_OBJS)) -CPP_DEPS_EXT := $(patsubst %.o,%.d, $(CPP_OBJS_EXT)) - -# create $(BIN_DIR) if it does not exist -ifeq ("$(wildcard $(BIN_DIR))","") -$(shell $(MKDIR) $(BIN_DIR)) -endif - -#----------------------------------------------------------------------------- -# rules -# - -all: $(TARGET_EXE) - -$(TARGET_EXE) : $(C_OBJS_EXT) $(CPP_OBJS_EXT) $(RC_OBJS_EXT) - $(LINK) $(LINKFLAGS) $(LIB_DIRS) -o $@ $^ $(LIBS) - cp $@ ../../bin - -$(BIN_DIR)/%.d : %.cpp - $(CPP) -MM -MT $(@:.d=.o) $(CPPFLAGS) $< > $@ - -$(BIN_DIR)/%.d : %.c - $(CC) -MM -MT $(@:.d=.o) $(CFLAGS) $< > $@ - -$(BIN_DIR)/%.o : %.cpp - $(CPP) $(CPPFLAGS) $< -o $@ - -$(BIN_DIR)/%.o : %.c - $(CC) $(CFLAGS) $< -o $@ - -.PHONY : clean show - -# include dependency files only if our goal depends on their existence -ifneq ($(MAKECMDGOALS),clean) - ifneq ($(MAKECMDGOALS),show) --include $(C_DEPS_EXT) $(CPP_DEPS_EXT) - endif -endif - -.PHONY : clean show - -clean: - -$(RM) $(BIN_DIR)/*.o \ - $(BIN_DIR)/*.d \ - $(TARGET_EXE) - -show: - @echo PROJECT = $(PROJECT) - @echo TARGET_EXE = $(TARGET_EXE) - @echo VPATH = $(VPATH) - @echo C_SRCS = $(C_SRCS) - @echo CPP_SRCS = $(CPP_SRCS) - @echo C_DEPS_EXT = $(C_DEPS_EXT) - @echo C_OBJS_EXT = $(C_OBJS_EXT) - @echo C_DEPS_EXT = $(C_DEPS_EXT) - @echo CPP_DEPS_EXT = $(CPP_DEPS_EXT) - @echo CPP_OBJS_EXT = $(CPP_OBJS_EXT) - @echo LIB_DIRS = $(LIB_DIRS) - @echo LIBS = $(LIBS) - @echo DEFINES = $(DEFINES) - diff --git a/qspy/posix/qspy_pal.c b/qspy/posix/qspy_pal.c deleted file mode 100644 index 94d4c02..0000000 --- a/qspy/posix/qspy_pal.c +++ /dev/null @@ -1,828 +0,0 @@ -/*============================================================================ -* QP/C Real-Time Embedded Framework (RTEF) -* Copyright (C) 2005 Quantum Leaps, LLC. All rights reserved. -* -* SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-QL-commercial -* -* This software is dual-licensed under the terms of the open source GNU -* General Public License version 3 (or any later version), or alternatively, -* under the terms of one of the closed source Quantum Leaps commercial -* licenses. -* -* The terms of the open source GNU General Public License version 3 -* can be found at: -* -* The terms of the closed source Quantum Leaps commercial licenses -* can be found at: -* -* Redistributions in source code must retain this top-level comment block. -* Plagiarizing this software to sidestep the license obligations is illegal. -* -* Contact information: -* -* -============================================================================*/ -/*! -* @date Last updated on: 2023-03-12 -* @version Last updated for version: 7.2.2 -* -* @file -* @brief QSPY PAL implementation for POSIX -*/ -#include /* for system() */ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "safe_std.h" /* "safe" and facilities */ -#include "qspy.h" /* QSPY data parser */ -#include "be.h" /* Back-End interface */ -#include "pal.h" /* Platform Abstraction Layer */ - -/*..........................................................................*/ -PAL_VtblType PAL_vtbl; /* global PAL virtual table */ - -/* specific implementations of the PAL "virutal functions" .................*/ -static QSPYEvtType ser_getEvt(unsigned char *buf, uint32_t *pBytes); -static QSpyStatus ser_send2Target(unsigned char *buf, uint32_t nBytes); -static void ser_cleanup(void); - -static QSPYEvtType tcp_getEvt(unsigned char *buf, uint32_t *pBytes); -static QSpyStatus tcp_send2Target(unsigned char *buf, uint32_t nBytes); -static void tcp_cleanup(void); - -static QSPYEvtType file_getEvt(unsigned char *buf, uint32_t *pBytes); -static QSpyStatus file_send2Target(unsigned char *buf, uint32_t nBytes); -static void file_cleanup(void); - -/*..........................................................................*/ -enum PAL_Constants { /* local constants... */ - INVALID_SOCKET = -1, - SOCKET_ERROR = -1, - FE_DETACHED = 0, /* Front-End detached */ - PAL_TOUT_MS = 10, /* determines how long to wait for an event [ms] */ -}; - -/* fron-end address */ -typedef union { - uint64_t data[2]; - struct sockaddr addr; -} fe_addr; - -static bool l_kbd_inp = false; - -static int l_serFD = 0; /* Serial port file descriptor */ -static int l_serverSock = INVALID_SOCKET; -static int l_clientSock = INVALID_SOCKET; -static int l_beSock = INVALID_SOCKET; - -static fe_addr l_feAddr; -static socklen_t l_feAddrSize = FE_DETACHED; - -static FILE *l_file = (FILE *)0; - -static struct termios l_termios_saved; /* saved terminal attributes */ -static fd_set l_readSet; /* descriptor set for reading all input sources */ -static int l_maxFd; /* maximum file descriptor for select() */ - -/*==========================================================================*/ -/* Keyboard input */ -static void sigExitHandler(int dummy) { - (void)dummy; /* unused parameter */ - QSPY_cleanup(); - exit(0); -} - -QSpyStatus PAL_openKbd(bool kbd_inp, bool color) { - struct sigaction sig_act; - memset(&sig_act, 0, sizeof(sig_act)); - - (void)color; /* unused parameter */ - - /* install the SIGINT (Ctrl-C) signal handler */ - sig_act.sa_handler = &sigExitHandler; - sigaction(SIGINT, &sig_act, NULL); - - /* install the SIGTERM (kill) signal handler */ - sig_act.sa_handler = &sigExitHandler; - sig_act.sa_flags = SA_SIGINFO; - sigaction(SIGTERM, &sig_act, NULL); - - if (kbd_inp) { - struct termios t; - - /* modify the terminal attributes... */ - /* get the original terminal settings */ - if (tcgetattr(0, &l_termios_saved) == -1) { - SNPRINTF_LINE(" ERROR %s", - "getting terminal attributes"); - QSPY_printError(); - return QSPY_ERROR; - } - - t = l_termios_saved; - t.c_lflag &= ~(ICANON | ECHO); /* disable canonical mode and echo */ - if (tcsetattr(0, TCSANOW, &t) == -1) { - SNPRINTF_LINE(" ERROR %s", - "setting terminal attributes"); - QSPY_printError(); - return QSPY_ERROR; - } - - l_kbd_inp = true; - } - return QSPY_SUCCESS; -} -/*..........................................................................*/ -void PAL_closeKbd(void) { - if (l_kbd_inp) { - /* restore the saved terminal settings */ - tcsetattr(0, TCSANOW, &l_termios_saved); - l_kbd_inp = false; - } -} -/*..........................................................................*/ -void PAL_exit(void) { - QSPY_cleanup(); - exit(0); -} -/*==========================================================================*/ -/* POSIX serial communication with the Target */ -QSpyStatus PAL_openTargetSer(char const *comName, int baudRate) { - struct termios t; - speed_t spd; - - /* setup the PAL virtual table for the Serial communication... */ - PAL_vtbl.getEvt = &ser_getEvt; - PAL_vtbl.send2Target = &ser_send2Target; - PAL_vtbl.cleanup = &ser_cleanup; - - l_serFD = open(comName, O_RDWR | O_NOCTTY | O_NONBLOCK);/* R/W,no-block */ - if (l_serFD == -1) { - SNPRINTF_LINE(" ERROR " - "Opening serial port Port=%s,Baud=%d", - comName, baudRate); - QSPY_printError(); - return QSPY_ERROR; /* open failed */ - } - - if (tcgetattr(l_serFD, &t) == -1) { - SNPRINTF_LINE(" ERROR " - "cannot get serial attributes errno=%d", - errno); - QSPY_printError(); - return QSPY_ERROR; /* getting attributes failed */ - } - t.c_cc[VMIN] = 0; - t.c_cc[VTIME] = 1; - - t.c_iflag = 0; - t.c_iflag &= ~(BRKINT | IGNPAR | PARMRK | INPCK | - ISTRIP | INLCR | IGNCR | ICRNL | IXON | IXOFF); - t.c_iflag |= IGNBRK; - - t.c_oflag = 0; - t.c_oflag &= ~OPOST; - - t.c_lflag = 0; - t.c_lflag &= ~(ECHO | ECHOE | ECHOK | ECHONL | - ICANON | ISIG | NOFLSH | TOSTOP); - - t.c_cflag = 0; - t.c_cflag &= ~(CSIZE | HUPCL); - t.c_cflag |= (CLOCAL | CREAD); - - spd = B115200; /* the default speed of the Serial port */ - switch (baudRate) { - case 200: spd = B200; break; - case 300: spd = B300; break; - case 600: spd = B600; break; - case 1200: spd = B1200; break; - case 1800: spd = B1800; break; - case 2400: spd = B2400; break; - case 4800: spd = B4800; break; - case 9600: spd = B9600; break; - case 19200: spd = B19200; break; - case 38400: spd = B38400; break; - case 57600: spd = B57600; break; - case 115200: spd = B115200; break; - - /* high baud rates (might not be supported)... */ -#ifdef B230400 - case 230400: spd = B230400; break; -#endif -#ifdef B460800 - case 460800: spd = B460800; break; -#endif -#ifdef B500000 - case 500000: spd = B500000; break; -#endif -#ifdef B576000 - case 576000: spd = B576000; break; -#endif -#ifdef B921600 - case 921600: spd = B921600; break; -#endif -#ifdef B1000000 - case 1000000: spd = B1000000; break; -#endif -#ifdef B1152000 - case 1152000: spd = B1152000; break; -#endif -#ifdef B1500000 - case 1500000: spd = B1500000; break; -#endif -#ifdef B2000000 - case 2000000: spd = B2000000; break; -#endif -#ifdef B2500000 - case 2500000: spd = B2500000; break; -#endif -#ifdef B3000000 - case 3000000: spd = B3000000; break; -#endif -#ifdef B3500000 - case 3500000: spd = B3500000; break; -#endif -#ifdef B4000000 - case 4000000: spd = B4000000; break; -#endif - - default: - SNPRINTF_LINE(" ERROR Unsupported rate Baud=%d", - baudRate); - QSPY_printError(); - return QSPY_ERROR; - } - - t.c_cflag &= ~(PARENB | PARODD); /* no parity */ - t.c_cflag |= (CS8); /* 8 bits in a byte */ - t.c_cflag &= ~(CSTOPB); /* 1 stop bit */ - - if (cfsetispeed(&t, spd) == -1) { - SNPRINTF_LINE(" ERROR %s", - "setting input speed failed"); - QSPY_printError(); - return QSPY_ERROR; - } - if (cfsetospeed(&t, spd) == -1) { - SNPRINTF_LINE(" ERROR %s", - "setting output speed failed"); - QSPY_printError(); - return QSPY_ERROR; - } - if (tcflush(l_serFD, TCIFLUSH) == -1) { - SNPRINTF_LINE(" ERROR %s", - "flushing serial port failed"); - QSPY_printError(); - return QSPY_ERROR; - } - if (tcsetattr(l_serFD, TCSANOW, &t) == -1) { - SNPRINTF_LINE(" ERROR %s", - "seting serial attributes failed"); - QSPY_printError(); - return QSPY_ERROR; - } - - PAL_updateReadySet(l_serFD); /* Serial port to be checked in select() */ - - return QSPY_SUCCESS; -} -/*..........................................................................*/ -static QSPYEvtType ser_getEvt(unsigned char *buf, uint32_t *pBytes) { - QSPYEvtType evtType; - fd_set readSet = l_readSet; - - /* block indefinitely until any input source has input */ - int nrec = select(l_maxFd, &readSet, 0, 0, NULL); - - if (nrec == 0) { - return QSPY_NO_EVT; - } - else if (nrec < 0) { - SNPRINTF_LINE(" ERROR select() errno=%d", errno); - QSPY_printError(); - return QSPY_ERROR_EVT; - } - - /* any input available from the keyboard? */ - if (l_kbd_inp && FD_ISSET(0, &readSet)) { - evtType = PAL_receiveKbd(buf, pBytes); - if (evtType != QSPY_NO_EVT) { - return evtType; - } - } - - /* any input available from the Back-End socket? */ - if ((l_beSock != INVALID_SOCKET) && FD_ISSET(l_beSock, &readSet)) { - evtType = PAL_receiveBe(buf, pBytes); - if (evtType != QSPY_NO_EVT) { - return evtType; - } - } - - /* any input available from the Serial port? */ - if (FD_ISSET(l_serFD, &readSet)) { - uint32_t nBytes = read(l_serFD, buf, *pBytes); - if (nBytes > 0) { - *pBytes = (uint32_t)nBytes; - return QSPY_TARGET_INPUT_EVT; - } - } - - return QSPY_NO_EVT; -} -/*..........................................................................*/ -static QSpyStatus ser_send2Target(unsigned char *buf, uint32_t nBytes) { - uint32_t nBytesWritten = write(l_serFD, buf, nBytes); - if (nBytesWritten == (uint32_t)nBytes) { - return QSPY_SUCCESS; - } - else { - SNPRINTF_LINE(" ERROR writing serial port errno=%d", - errno); - QSPY_printError(); - return QSPY_ERROR; - } -} -/*..........................................................................*/ -static void ser_cleanup(void) { - if (l_serFD != 0) { - close(l_serFD); /* close the serial port */ - l_serFD = 0; - } -} - -/*==========================================================================*/ -/* POSIX TCP/IP communication with the Target */ - -struct sockaddr_in l_clientAddr; - -/*..........................................................................*/ -QSpyStatus PAL_openTargetTcp(int portNum) { - struct sockaddr_in local; - - /* setup the PAL virtual table for the TCP/IP Target connection... */ - PAL_vtbl.getEvt = &tcp_getEvt; - PAL_vtbl.send2Target = &tcp_send2Target; - PAL_vtbl.cleanup = &tcp_cleanup; - - /* create TCP socket */ - l_serverSock = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP); - if (l_serverSock == INVALID_SOCKET) { - SNPRINTF_LINE(" ERROR server socket open errno=%d", - errno); - QSPY_printError(); - return QSPY_ERROR; - } - - memset(&local, 0, sizeof(local)); - local.sin_family = AF_INET; - local.sin_addr.s_addr = INADDR_ANY; - local.sin_port = htons((unsigned short)portNum); - - /* bind() associates a local address and port combination with the - * socket just created. This is most useful when the application is a - * server that has a well-known port that clients know about in advance. - */ - if (bind(l_serverSock, (struct sockaddr *)&local, sizeof(local)) - == SOCKET_ERROR) - { - SNPRINTF_LINE(" ERROR socket binding errno=%d", errno); - QSPY_printError(); - return QSPY_ERROR; - } - - if (listen(l_serverSock, 1) == SOCKET_ERROR) { - SNPRINTF_LINE(" ERROR socket listen errno=%d", errno); - QSPY_printError(); - return QSPY_ERROR; - } - - PAL_updateReadySet(l_serverSock); /* to be checked in select() */ - - return QSPY_SUCCESS; -} -/*..........................................................................*/ -static void tcp_cleanup(void) { - if (l_serverSock != INVALID_SOCKET) { - close(l_serverSock); - } -} -/*..........................................................................*/ -static QSPYEvtType tcp_getEvt(unsigned char *buf, uint32_t *pBytes) { - QSPYEvtType evtType; - fd_set readSet = l_readSet; - - /* block indefinitely until any input source has input */ - int nrec = select(l_maxFd, &readSet, 0, 0, NULL); - - if (nrec == 0) { - return QSPY_NO_EVT; - } - else if (nrec < 0) { - SNPRINTF_LINE(" ERROR select() errno=%d", errno); - QSPY_printError(); - return QSPY_ERROR_EVT; - } - - /* any input available from the keyboard? */ - if (l_kbd_inp && FD_ISSET(0, &readSet)) { - evtType = PAL_receiveKbd(buf, pBytes); - if (evtType != QSPY_NO_EVT) { - return evtType; - } - } - - /* any input available from the Back-End socket? */ - if ((l_beSock != INVALID_SOCKET) && FD_ISSET(l_beSock, &readSet)) { - evtType = PAL_receiveBe(buf, pBytes); - if (evtType != QSPY_NO_EVT) { - return evtType; - } - } - - /* still waiting for the client? */ - if (l_clientSock == INVALID_SOCKET) { - if (FD_ISSET(l_serverSock, &readSet)) { - socklen_t clientAddrLen = (socklen_t)sizeof(l_clientAddr); - l_clientSock = accept(l_serverSock, - (struct sockaddr *)&l_clientAddr, - &clientAddrLen); - if (l_clientSock == INVALID_SOCKET) { - SNPRINTF_LINE(" ERROR socket accept errno=%d", - errno); - QSPY_printError(); - return QSPY_ERROR_EVT; - } - - QSPY_reset(); /* reset the QSPY parser to start over cleanly */ - QSPY_txReset(); /* reset the QSPY transmitter */ - - SNPRINTF_LINE(" TCP-IP Connected to Host=%s,Port=%d", - inet_ntoa(l_clientAddr.sin_addr), - (int)ntohs(l_clientAddr.sin_port)); - QSPY_printInfo(); - - /* re-evaluate the ready set and max FD for select() */ - PAL_updateReadySet(l_clientSock); - } - } - else { - if (FD_ISSET(l_clientSock, &readSet)) { - nrec = recv(l_clientSock, (char *)buf, *pBytes, 0); - - if (nrec <= 0) { /* the client hang up */ - SNPRINTF_LINE(" TCP-IP Disconn from " - "Host=%s,Port=%d", - inet_ntoa(l_clientAddr.sin_addr), - (int)ntohs(l_clientAddr.sin_port)); - QSPY_printInfo(); - - /* go back to waiting for a client */ - close(l_clientSock); - l_clientSock = INVALID_SOCKET; - - /* re-evaluate the ready set and max FD for select() */ - PAL_updateReadySet(l_serverSock); - } - else { - *pBytes = (uint32_t)nrec; - return QSPY_TARGET_INPUT_EVT; - } - } - } - - return QSPY_NO_EVT; -} -/*..........................................................................*/ -static QSpyStatus tcp_send2Target(unsigned char *buf, uint32_t nBytes) { - if (l_clientSock == INVALID_SOCKET) { - return QSPY_ERROR; - } - if (send(l_clientSock, buf, nBytes, 0) == SOCKET_ERROR) { - SNPRINTF_LINE(" ERROR Writing to TCP socket errno=%d", - errno); - QSPY_printError(); - return QSPY_ERROR; - } - return QSPY_SUCCESS; -} - -/*==========================================================================*/ -/* File communication with the "Target" */ -QSpyStatus PAL_openTargetFile(char const *fName) { - int fd; - - /* setup the PAL virtual table for the File connection... */ - PAL_vtbl.getEvt = &file_getEvt; - PAL_vtbl.send2Target = &file_send2Target; - PAL_vtbl.cleanup = &file_cleanup; - - FOPEN_S(l_file, fName, "rb"); /* open for reading binary */ - if (l_file == (FILE *)0) { - SNPRINTF_LINE(" ERROR Cannot find File=%s", fName); - QSPY_printError(); - return QSPY_ERROR; - } - - QSPY_reset(); /* reset the QSPY parser to start over cleanly */ - QSPY_txReset(); /* reset the QSPY transmitter */ - - fd = fileno(l_file); /* FILE* to file-descriptor */ - PAL_updateReadySet(fd); /* fd to be checked in select() */ - - SNPRINTF_LINE(" File Opened File=%s", fName); - QSPY_printInfo(); - - return QSPY_SUCCESS; -} -/*..........................................................................*/ -static QSPYEvtType file_getEvt(unsigned char *buf, uint32_t *pBytes) { - QSPYEvtType evtType; - uint32_t nBytes; - fd_set readSet = l_readSet; - - /* block indefinitely until any input source has input */ - int nrec = select(l_maxFd, &readSet, 0, 0, NULL); - - if (nrec == 0) { - return QSPY_NO_EVT; - } - else if (nrec < 0) { - SNPRINTF_LINE(" ERROR select() errno=%d", errno); - QSPY_printError(); - return QSPY_ERROR_EVT; - } - - /* any input available from the keyboard? */ - if (l_kbd_inp && FD_ISSET(0, &readSet)) { - evtType = PAL_receiveKbd(buf, pBytes); - if (evtType != QSPY_NO_EVT) { - return evtType; - } - } - - /* any input available from the Back-End socket? */ - if ((l_beSock != INVALID_SOCKET) && FD_ISSET(l_beSock, &readSet)) { - evtType = PAL_receiveBe(buf, pBytes); - if (evtType != QSPY_NO_EVT) { - return evtType; - } - } - - /* try to receive data from the File... */ - nBytes = FREAD_S(buf, *pBytes, 1U, *pBytes, l_file); - if (nBytes > 0) { - *pBytes = nBytes; - return QSPY_TARGET_INPUT_EVT; - } - - /* no more input available from the file, QSPY is done */ - return QSPY_DONE_EVT; -} -/*..........................................................................*/ -static QSpyStatus file_send2Target(unsigned char *buf, uint32_t nBytes) { - (void)buf; - (void)nBytes; - return QSPY_ERROR; -} -/*..........................................................................*/ -static void file_cleanup(void) { - if (l_file != (FILE *)0) { - fclose(l_file); - l_file = (FILE *)0; - } -} - - -/*==========================================================================*/ -/* Front-End interface */ -QSpyStatus PAL_openBE(int portNum) { - struct sockaddr_in local; - int flags; - - l_beSock = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP); /* UDP socket */ - if (l_beSock == INVALID_SOCKET){ - SNPRINTF_LINE(" ERROR UDP socket create errno=%d", - errno); - QSPY_printError(); - return QSPY_ERROR; - } - - /* bind the socket... - * bind() associates a local address and port combination with the - * socket just created. This is most useful when the application is a - * server that has a well-known port that clients know about in advance. - */ - memset(&local, 0, sizeof(local)); - local.sin_family = AF_INET; - local.sin_addr.s_addr = INADDR_ANY; - local.sin_port = htons((unsigned short)portNum); - if (bind(l_beSock, (struct sockaddr *)&local, sizeof(local)) - == SOCKET_ERROR) - { - SNPRINTF_LINE(" ERROR UDP socket binding errno=%d", - errno); - QSPY_printError(); - return QSPY_ERROR; - } - - /* put the socket into NON-BLOCKING mode... */ - flags = fcntl(l_beSock, F_GETFL, 0); - if (flags == SOCKET_ERROR) { - SNPRINTF_LINE(" ERROR UDP socket fcntl() get errno=%d", - errno); - QSPY_printError(); - return QSPY_ERROR; - } - flags |= O_NONBLOCK; - if (fcntl(l_beSock, F_SETFL, flags) != 0) { - SNPRINTF_LINE(" ERROR " - "UDP socket fcntl() set errno=%d", errno); - QSPY_printError(); - return QSPY_ERROR; - } - - BE_onStartup(); /* Back-End startup callback */ - - /* NOTE: - * The Back-End socket l_beSock needs to be checked in select() just - * like all other sources of input. However, the l_beSock socket is - * added automatically in the PAL_updateReadySet() function *later* in - * the initialization phase. This assumes that PAL_openBE() is called - * always *before* opening the specific Target link (see configure() in - * main.c). - */ - - return QSPY_SUCCESS; -} -/*..........................................................................*/ -void PAL_closeBE(void) { - if (l_beSock != INVALID_SOCKET) { - if (l_feAddrSize != FE_DETACHED) { /* front-end attached? */ - fd_set writeSet; - struct timeval delay; - - /* Back-End cleanup callback (send detach packet)... */ - BE_onCleanup(); - - /* block until the packet comes out... */ - FD_ZERO(&writeSet); - FD_SET(l_beSock, &writeSet); - delay.tv_sec = 2U; /* delay for up to 2 seconds */ - delay.tv_usec = 0U; - if (select(l_beSock + 1, (fd_set *)0, - &writeSet, (fd_set *)0, &delay) - == SOCKET_ERROR) - { - SNPRINTF_LINE(" ERROR " - "UDP socket select errno=%d", - errno); - QSPY_printError(); - } - } - - close(l_beSock); - l_beSock = INVALID_SOCKET; - } -} -/*..........................................................................*/ -void PAL_send2FE(unsigned char const *buf, uint32_t nBytes) { - if (l_feAddrSize != FE_DETACHED) { /* front-end attached? */ - if (sendto(l_beSock, (char *)buf, (int)nBytes, 0, - &l_feAddr.addr, l_feAddrSize) == SOCKET_ERROR) - { - PAL_detachFE(); /* detach the Front-End */ - - SNPRINTF_LINE(" ERROR UDP socket failed errno=%d", - errno); - QSPY_printError(); - } - } -} -/*..........................................................................*/ -void PAL_detachFE(void) { - l_feAddrSize = FE_DETACHED; -} - -/*..........................................................................*/ -void PAL_clearScreen(void) { - int status = system("clear"); - if (status < 0) { - SNPRINTF_LINE(" ERROR %s", - "clearing the screen failed"); - QSPY_printError(); - } -} - -/*--------------------------------------------------------------------------*/ -QSPYEvtType PAL_receiveBe(unsigned char *buf, uint32_t *pBytes) { - fe_addr feAddr; - socklen_t feAddrSize; - uint32_t nBytes; - - if (l_beSock == INVALID_SOCKET) { /* Back-End socket not initialized? */ - return QSPY_NO_EVT; - } - - /* receive a packet from the Back-End socket */ - feAddrSize = sizeof(feAddr); - nBytes = recvfrom(l_beSock, buf, *pBytes, 0, - &feAddr.addr, &feAddrSize); - - if (nBytes == 0) { /* socket error */ - PAL_detachFE(); /* detach from the Front-End */ - SNPRINTF_LINE(" ERROR " - "UDP socket recvfrom() errno=%d", errno); - QSPY_printError(); - return QSPY_ERROR_EVT; - } - else if (l_feAddrSize == 0) { /* not attached yet? */ - if (feAddrSize > sizeof(l_feAddr)) { - SNPRINTF_LINE(" ERROR UDP address error size=%d", - feAddrSize); - QSPY_printError(); - return QSPY_ERROR_EVT; - } - memcpy(&l_feAddr, &feAddr, feAddrSize); - l_feAddrSize = feAddrSize; /* attach connection */ - *pBytes = nBytes; - return QSPY_FE_INPUT_EVT; - } - else { /* already attached */ - /* is this from the attached front-end address? */ - if ((feAddrSize == l_feAddrSize) - && (feAddr.data[1] == l_feAddr.data[1]) - && (feAddr.data[0] == l_feAddr.data[0])) - { - *pBytes = nBytes; - return QSPY_FE_INPUT_EVT; - } - else { - SNPRINTF_LINE(" WARN %s", - "UDP socket in use"); - QSPY_printError(); - /* this packet is from a DIFFERENT front-end -- ignore it */ - } - } - return QSPY_NO_EVT; -} - -/*..........................................................................*/ -QSPYEvtType PAL_receiveKbd(unsigned char *buf, uint32_t *pBytes) { - *pBytes = read(0, buf, 1); /* the key pressed */ - if (*pBytes > 0) { - return QSPY_KEYBOARD_EVT; - } - return QSPY_NO_EVT; -} -/*..........................................................................*/ -void PAL_updateReadySet(int targetConn) { - FD_ZERO(&l_readSet); - FD_SET(0, &l_readSet); /* terminal to be checked in select */ - l_maxFd = 1; - FD_SET(targetConn, &l_readSet); /* check in select */ - if (l_maxFd < targetConn + 1) { - l_maxFd = targetConn + 1; - } - if (l_beSock != INVALID_SOCKET) { - FD_SET(l_beSock, &l_readSet); /* check in select */ - if (l_maxFd < l_beSock + 1) { - l_maxFd = l_beSock + 1; - } - } -} - -/*..........................................................................*/ -/* simplified strncpy_s() implementation "good enough" for the intended use */ -int strncpy_s(char* strDest, uint32_t numberOfElements, - const char* strSource, uint32_t count) -{ - uint32_t n; - for (n = (numberOfElements < count) ? numberOfElements : count; - n > 0; - --n, ++strSource, ++strDest) - { - if (*strSource != '\0') { - *strDest = *strSource; - } - else { - *strDest = '\0'; - return 0; /* destination fits the source */ - } - } - strDest[numberOfElements - 1] = '\0'; - return -1; /* destination holds truncated source */ -} diff --git a/qspy/seq/dpp-qpc.bin b/qspy/seq/dpp-qpc.bin deleted file mode 100644 index 597e5a4..0000000 Binary files a/qspy/seq/dpp-qpc.bin and /dev/null differ diff --git a/qspy/seq/dpp-qpcpp.bin b/qspy/seq/dpp-qpcpp.bin deleted file mode 100644 index bf98564..0000000 Binary files a/qspy/seq/dpp-qpcpp.bin and /dev/null differ diff --git a/qspy/seq/qspy221128_101107.seq b/qspy/seq/qspy221128_101107.seq deleted file mode 100644 index 80a8d6e..0000000 --- a/qspy/seq/qspy221128_101107.seq +++ /dev/null @@ -1,164 +0,0 @@ --g l_SysTick_Handler,Table_inst,Philo_inst[0],Philo_inst[1],Philo_inst[2],Philo_inst[3],Philo_inst[4] - - +-------+-------+ +-------+-------+ +-------+-------+ +-------+-------+ +-------+-------+ +-------+-------+ +-------+-------+ - |l_SysTick_Handl| | Table_inst | | Philo_inst[0] | | Philo_inst[1] | | Philo_inst[2] | | Philo_inst[3] | | Philo_inst[4] | - +-------+-------+ +-------+-------+ +-------+-------+ +-------+-------+ +-------+-------+ +-------+-------+ +-------+-------+ -2950460426 | |<------------------+-------------------+-------------------+-------------------+-------HUNGRY_SIG--* -2950460524 | | | | | | -2950464438 . . . . | . . . . . . . . . * .EAT_SIG. . . . . | . . . . . . . . . | . . . . . . . . . | . . . . . . . . . | . . . . . . . . . | . . . -2950464451 | *--EAT_SIG----------+-------------------+-------------------+-------------------+------------------>| -2950464514 | *--EAT_SIG----------+-------------------+-------------------+------------------>| | -2950464551 | *--EAT_SIG----------+-------------------+------------------>| | | -2950464589 | *--EAT_SIG----------+------------------>| | | | -2950464635 | *--EAT_SIG--------->| | | | | -2950477451 | | | | | | -2950772367 | |<------------------+-------------------+-------HUNGRY_SIG--* | | -2950772457 | | | | | | -2950785279 . . . . | . . . . . . . . . * .EAT_SIG. . . . . | . . . . . . . . . | . . . . . . . . . | . . . . . . . . . | . . . . . . . . . | . . . -2950785311 | *--EAT_SIG----------+-------------------+-------------------+-------------------+------------------>| -2950785419 | *--EAT_SIG----------+-------------------+-------------------+------------------>| | -2950785460 | *--EAT_SIG----------+-------------------+------------------>| | | -2950785496 | *--EAT_SIG----------+------------------>| | | | -2950785534 | *--EAT_SIG--------->| | | | | -2950843875 | | | | | | -2952334542 | |<------------------+-------HUNGRY_SIG--* | | | -2952334648 | | | | | | -2960692857 | |<------HUNGRY_SIG--* | | | | -2960693442 | | | | | | -2965066265 | |<------------------+-------------------+-------------------+-------HUNGRY_SIG--* | -2965066355 | | | | | | -2976002932 . . . . | . . . . . . . . . | . . . . . . . . . | . . . . . . . . . | . . . . . . . . . * .DONE_SIG . . . . | . . . . . . . . . | . . . -2976002943 | |<------------------+-------------------+---------DONE_SIG--* | | -2976003120 | | | | | | -2976006906 . . . . | . . . . . . . . . * .EAT_SIG. . . . . | . . . . . . . . . | . . . . . . . . . | . . . . . . . . . | . . . . . . . . . | . . . -2976006921 | *--EAT_SIG----------+-------------------+-------------------+-------------------+------------------>| -2976006995 | *--EAT_SIG----------+-------------------+-------------------+------------------>| | -2976007039 | *--EAT_SIG----------+-------------------+------------------>| | | -2976007077 | *--EAT_SIG----------+------------------>| | | | -2976007122 | *--EAT_SIG--------->| | | | | -2976050570 | | | | | | -2977878544 . . . . | . . . . . . . . . | . . . . . . . . . | . . . . . . . . . | . . . . . . . . . | . . . . . . . . . | . . . . DONE_SIG. * . . . -2977878559 | |<------------------+-------------------+-------------------+-------------------+---------DONE_SIG--* -2977878666 | | | | | | -2977882747 . . . . | . . . . . . . . . * .EAT_SIG. . . . . | . . . . . . . . . | . . . . . . . . . | . . . . . . . . . | . . . . . . . . . | . . . -2977882761 | *--EAT_SIG----------+-------------------+-------------------+-------------------+------------------>| -2977882827 | *--EAT_SIG----------+-------------------+-------------------+------------------>| | -2977882865 | *--EAT_SIG----------+-------------------+------------------>| | | -2977882903 | *--EAT_SIG----------+------------------>| | | | -2977882941 | *--EAT_SIG--------->| | | | | -2977939575 | | | | | | -2987877146 | |<------------------+-------------------+-------HUNGRY_SIG--* | | -2987877249 | | | | | | -2999439616 . . . . | . . . . . . . . . | . . . . . . . . . | . . . . . . . . . * .DONE_SIG . . . . | . . . . . . . . . | . . . . . . . . . | . . . -2999439628 | |<------------------+---------DONE_SIG--* | | | -2999439760 | | | | | | -2999450115 . . . . | . . . . . . . . . * .EAT_SIG. . . . . | . . . . . . . . . | . . . . . . . . . | . . . . . . . . . | . . . . . . . . . | . . . -2999450135 | *--EAT_SIG----------+-------------------+-------------------+-------------------+------------------>| -2999450219 | *--EAT_SIG----------+-------------------+-------------------+------------------>| | -2999450281 | *--EAT_SIG----------+-------------------+------------------>| | | -2999450343 | *--EAT_SIG----------+------------------>| | | | -2999450405 | *--EAT_SIG--------->| | | | | -2999474571 | | | | | | -3000376186 | |<------------------+-------------------+-------------------+-------------------+-------HUNGRY_SIG--* -3000376294 | | | | | | -3001940688 . . . . | . . . . . . . . . | . . . . . . . . . | . . . . . . . . . | . . . . . . . . . | . . . . . . . . . * .DONE_SIG . . . . | . . . -3001940701 | |<------------------+-------------------+-------------------+---------DONE_SIG--* | -3001940818 | | | | | | -3001947262 . . . . | . . . . . . . . . * .EAT_SIG. . . . . | . . . . . . . . . | . . . . . . . . . | . . . . . . . . . | . . . . . . . . . | . . . -3001947279 | *--EAT_SIG----------+-------------------+-------------------+-------------------+------------------>| -3001947350 | *--EAT_SIG----------+-------------------+-------------------+------------------>| | -3001947391 | *--EAT_SIG----------+-------------------+------------------>| | | -3001947428 | *--EAT_SIG----------+------------------>| | | | -3001947466 | *--EAT_SIG--------->| | | | | -3001997648 | | | | | | -3007664142 | |<------------------+-------HUNGRY_SIG--* | | | -3007664222 | | | | | | -3014538302 | |<------------------+-------------------+-------------------+-------HUNGRY_SIG--* | -3014538385 | | | | | | -3020475405 . . . . | . . . . . . . . . | . . . . . . . . . * .DONE_SIG . . . . | . . . . . . . . . | . . . . . . . . . | . . . . . . . . . | . . . -3020475417 | |<--------DONE_SIG--* | | | | -3020475544 | | | | | | -3020480662 . . . . | . . . . . . . . . * .EAT_SIG. . . . . | . . . . . . . . . | . . . . . . . . . | . . . . . . . . . | . . . . . . . . . | . . . -3020480674 | *--EAT_SIG----------+-------------------+-------------------+-------------------+------------------>| -3020480748 | *--EAT_SIG----------+-------------------+-------------------+------------------>| | -3020480781 | *--EAT_SIG----------+-------------------+------------------>| | | -3020480811 | *--EAT_SIG----------+------------------>| | | | -3020480842 | *--EAT_SIG--------->| | | | | -3020525503 | | | | | | -3022663580 . . . . | . . . . . . . . . | . . . . . . . . . | . . . . . . . . . | . . . . . . . . . * .DONE_SIG . . . . | . . . . . . . . . | . . . -3022663593 | |<------------------+-------------------+---------DONE_SIG--* | | -3022663691 | | | | | | -3022669874 . . . . | . . . . . . . . . * .EAT_SIG. . . . . | . . . . . . . . . | . . . . . . . . . | . . . . . . . . . | . . . . . . . . . | . . . -3022669887 | *--EAT_SIG----------+-------------------+-------------------+-------------------+------------------>| -3022669951 | *--EAT_SIG----------+-------------------+-------------------+------------------>| | -3022669988 | *--EAT_SIG----------+-------------------+------------------>| | | -3022670029 | *--EAT_SIG----------+------------------>| | | | -3022670075 | *--EAT_SIG--------->| | | | | -3022727265 | | | | | | -3034224201 | |<------HUNGRY_SIG--* | | | | -3034224368 | | | | | | -3036114669 | | | | | | -3037349111 . . . . | . . . . . . . . . | . . . . . . . . . | . . . . . . . . . | . . . . . . . . . | . . . . . . . . . | . . . . DONE_SIG. * . . . -3037349125 | |<------------------+-------------------+-------------------+-------------------+---------DONE_SIG--* - +-------+-------+ +-------+-------+ +-------+-------+ +-------+-------+ +-------+-------+ +-------+-------+ +-------+-------+ - |l_SysTick_Handl| | Table_inst | | Philo_inst[0] | | Philo_inst[1] | | Philo_inst[2] | | Philo_inst[3] | | Philo_inst[4] | - +-------+-------+ +-------+-------+ +-------+-------+ +-------+-------+ +-------+-------+ +-------+-------+ +-------+-------+ -3037349235 | | | | | | -3040473731 | |<------------------+-------------------+-------HUNGRY_SIG--* | | -3040473819 | | | | | | -3045473194 | |<------------------+-------------------+-------------------+-------------------+-------HUNGRY_SIG--* -3045473281 | | | | | | -3046723257 . . . . | . . . . . . . . . | . . . . . . . . . | . . . . . . . . . * .DONE_SIG . . . . | . . . . . . . . . | . . . . . . . . . | . . . -3046723268 | |<------------------+---------DONE_SIG--* | | | -3046723371 | | | | | | -3065159882 | |<------------------+-------HUNGRY_SIG--* | | | -3065159972 | | | | | | -3096103901 . . . . | . . . . . . . . . * .EAT_SIG. . . . . | . . . . . . . . . | . . . . . . . . . | . . . . . . . . . | . . . . . . . . . | . . . -3096103911 | *--EAT_SIG----------+-------------------+-------------------+-------------------+------------------>| -3096103953 | *--EAT_SIG----------+-------------------+-------------------+------------------>| | -3096103973 | *--EAT_SIG----------+-------------------+------------------>| | | -3096103990 | *--EAT_SIG----------+------------------>| | | | -3096104007 | *--EAT_SIG--------->| | | | | -3096139647 . . . . | . . . . . . . . . * .EAT_SIG. . . . . | . . . . . . . . . | . . . . . . . . . | . . . . . . . . . | . . . . . . . . . | . . . -3096139655 | *--EAT_SIG----------+-------------------+-------------------+-------------------+------------------>| -3096139662 | *--EAT_SIG----------+-------------------+-------------------+------------------>| | -3096139666 | *--EAT_SIG----------+-------------------+------------------>| | | -3096139670 | *--EAT_SIG----------+------------------>| | | | -3096139674 | *--EAT_SIG--------->| | | | | -3096150159 | | | | | | -3096150249 | | | | | | -3096150283 | | | | | | -3116326521 . . . . | . . . . . . . . . | . . . . . . . . . * .DONE_SIG . . . . | . . . . . . . . . | . . . . . . . . . | . . . . . . . . . | . . . -3116326533 | |<--------DONE_SIG--* | | | | -3116326642 | | | | | | -3116332079 . . . . | . . . . . . . . . * .EAT_SIG. . . . . | . . . . . . . . . | . . . . . . . . . | . . . . . . . . . | . . . . . . . . . | . . . -3116332092 | *--EAT_SIG----------+-------------------+-------------------+-------------------+------------------>| -3116332159 | *--EAT_SIG----------+-------------------+-------------------+------------------>| | -3116332198 | *--EAT_SIG----------+-------------------+------------------>| | | -3116332237 | *--EAT_SIG----------+------------------>| | | | -3116332275 | *--EAT_SIG--------->| | | | | -3116376931 | | | | | | -3125074203 . . . . | . . . . . . . . . | . . . . . . . . . | . . . . . . . . . | . . . . . . . . . * .DONE_SIG . . . . | . . . . . . . . . | . . . -3125074208 | |<------------------+-------------------+---------DONE_SIG--* | | -3125074247 | | | | | | -3125076384 . . . . | . . . . . . . . . * .EAT_SIG. . . . . | . . . . . . . . . | . . . . . . . . . | . . . . . . . . . | . . . . . . . . . | . . . -3125076390 | *--EAT_SIG----------+-------------------+-------------------+-------------------+------------------>| -3125076416 | *--EAT_SIG----------+-------------------+-------------------+------------------>| | -3125076431 | *--EAT_SIG----------+-------------------+------------------>| | | -3125076445 | *--EAT_SIG----------+------------------>| | | | -3125076464 | *--EAT_SIG--------->| | | | | -3125097552 | | | | | | -3134762047 | |<------------------+-------------------+-------HUNGRY_SIG--* | | -3134762114 | | | | | | -3136011926 . . . . | . . . . . . . . . | . . . . . . . . . | . . . . . . . . . | . . . . . . . . . | . . . . . . . . . | . . . . DONE_SIG. * . . . -3136011938 | |<------------------+-------------------+-------------------+-------------------+---------DONE_SIG--* -3136012059 | | | | | | -3136017328 . . . . | . . . . . . . . . * .EAT_SIG. . . . . | . . . . . . . . . | . . . . . . . . . | . . . . . . . . . | . . . . . . . . . | . . . -3136017345 | *--EAT_SIG----------+-------------------+-------------------+-------------------+------------------>| -3136017418 | *--EAT_SIG----------+-------------------+-------------------+------------------>| | -3136017459 | *--EAT_SIG----------+-------------------+------------------>| | | -3136017498 | *--EAT_SIG----------+------------------>| | | | -3136017537 | *--EAT_SIG--------->| | | | | -3136059869 | | | | | | -3136949926 | |<------HUNGRY_SIG--* | | | | -3136950011 | | | | | | diff --git a/qspy/seq/qspy221128_101112.seq b/qspy/seq/qspy221128_101112.seq deleted file mode 100644 index a402f0e..0000000 --- a/qspy/seq/qspy221128_101112.seq +++ /dev/null @@ -1,152 +0,0 @@ --g l_SysTick_Handler,Table::inst,Philo::inst[0],Philo::inst[1],Philo::inst[2],Philo::inst[3],Philo::inst[4] - - +-------+-------+ +-------+-------+ +-------+-------+ +-------+-------+ +-------+-------+ +-------+-------+ +-------+-------+ - |l_SysTick_Handl| | Table::inst | |Philo::inst[0] | |Philo::inst[1] | |Philo::inst[2] | |Philo::inst[3] | |Philo::inst[4] | - +-------+-------+ +-------+-------+ +-------+-------+ +-------+-------+ +-------+-------+ +-------+-------+ +-------+-------+ -3536596640 | |<------------------+-------------------+-------------------+-------------------+-------HUNGRY_SIG--* -3536596732 | | | | | | -3536604068 . . . . | . . . . . . . . . * .EAT_SIG. . . . . | . . . . . . . . . | . . . . . . . . . | . . . . . . . . . | . . . . . . . . . | . . . -3536604085 | *--EAT_SIG----------+-------------------+-------------------+-------------------+------------------>| -3536604163 | *--EAT_SIG----------+-------------------+-------------------+------------------>| | -3536604202 | *--EAT_SIG----------+-------------------+------------------>| | | -3536604240 | *--EAT_SIG----------+------------------>| | | | -3536604280 | *--EAT_SIG--------->| | | | | -3536650735 | | | | | | -3542079593 | |<------HUNGRY_SIG--* | | | | -3542079692 | | | | | | -3545094237 | |<------------------+-------------------+-------HUNGRY_SIG--* | | -3545094326 | | | | | | -3545099292 . . . . | . . . . . . . . . * .EAT_SIG. . . . . | . . . . . . . . . | . . . . . . . . . | . . . . . . . . . | . . . . . . . . . | . . . -3545099309 | *--EAT_SIG----------+-------------------+-------------------+-------------------+------------------>| -3545099383 | *--EAT_SIG----------+-------------------+-------------------+------------------>| | -3545099422 | *--EAT_SIG----------+-------------------+------------------>| | | -3545099461 | *--EAT_SIG----------+------------------>| | | | -3545099500 | *--EAT_SIG--------->| | | | | -3545146312 | | | | | | -3546096614 | |<------------------+-------HUNGRY_SIG--* | | | -3546096678 | | | | | | -3552970579 | |<------------------+-------------------+-------------------+-------HUNGRY_SIG--* | -3552970670 | | | | | | -3568182990 . . . . | . . . . . . . . . | . . . . . . . . . | . . . . . . . . . | . . . . . . . . . | . . . . . . . . . | . . . . DONE_SIG. * . . . -3568183004 | |<------------------+-------------------+-------------------+-------------------+---------DONE_SIG--* -3568183144 | | | | | | -3568187349 . . . . | . . . . . . . . . * .EAT_SIG. . . . . | . . . . . . . . . | . . . . . . . . . | . . . . . . . . . | . . . . . . . . . | . . . -3568187366 | *--EAT_SIG----------+-------------------+-------------------+-------------------+------------------>| -3568187434 | *--EAT_SIG----------+-------------------+-------------------+------------------>| | -3568187472 | *--EAT_SIG----------+-------------------+------------------>| | | -3568187511 | *--EAT_SIG----------+------------------>| | | | -3568187549 | *--EAT_SIG--------->| | | | | -3568237065 | | | | | | -3571892216 | | | | | | -3575519270 . . . . | . . . . . . . . . | . . . . . . . . . | . . . . . . . . . | . . . . . . . . . * .DONE_SIG . . . . | . . . . . . . . . | . . . -3575519296 | |<------------------+-------------------+---------DONE_SIG--* | | -3575519403 | | | | | | -3587105836 | |<------------------+-------------------+-------------------+-------------------+-------HUNGRY_SIG--* -3587105928 | | | | | | -3597453138 . . . . | . . . . . . . . . | . . . . . . . . . * .DONE_SIG . . . . | . . . . . . . . . | . . . . . . . . . | . . . . . . . . . | . . . -3597453153 | |<--------DONE_SIG--* | | | | -3597453293 | | | | | | -3600147801 | |<------------------+-------------------+-------HUNGRY_SIG--* | | -3600147874 | | | | | | -3610333896 | |<------HUNGRY_SIG--* | | | | -3610333942 | | | | | | -3642120316 . . . . | . . . . . . . . . * .EAT_SIG. . . . . | . . . . . . . . . | . . . . . . . . . | . . . . . . . . . | . . . . . . . . . | . . . -3642120329 | *--EAT_SIG----------+-------------------+-------------------+-------------------+------------------>| -3642120402 | *--EAT_SIG----------+-------------------+-------------------+------------------>| | -3642120433 | *--EAT_SIG----------+-------------------+------------------>| | | -3642120463 | *--EAT_SIG----------+------------------>| | | | -3642120494 | *--EAT_SIG--------->| | | | | -3642155875 . . . . | . . . . . . . . . * .EAT_SIG. . . . . | . . . . . . . . . | . . . . . . . . . | . . . . . . . . . | . . . . . . . . . | . . . -3642155889 | *--EAT_SIG----------+-------------------+-------------------+-------------------+------------------>| -3642155897 | *--EAT_SIG----------+-------------------+-------------------+------------------>| | -3642155903 | *--EAT_SIG----------+-------------------+------------------>| | | -3642155908 | *--EAT_SIG----------+------------------>| | | | -3642155913 | *--EAT_SIG--------->| | | | | -3642174256 | | | | | | -3642174443 | | | | | | -3642174509 | | | | | | -3659015190 . . . . | . . . . . . . . . | . . . . . . . . . | . . . . . . . . . | . . . . . . . . . * .DONE_SIG . . . . | . . . . . . . . . | . . . -3659015205 | |<------------------+-------------------+---------DONE_SIG--* | | -3659015349 | | | | | | -3659019523 . . . . | . . . . . . . . . * .EAT_SIG. . . . . | . . . . . . . . . | . . . . . . . . . | . . . . . . . . . | . . . . . . . . . | . . . -3659019542 | *--EAT_SIG----------+-------------------+-------------------+-------------------+------------------>| -3659019609 | *--EAT_SIG----------+-------------------+-------------------+------------------>| | -3659019645 | *--EAT_SIG----------+-------------------+------------------>| | | -3659019685 | *--EAT_SIG----------+------------------>| | | | -3659019723 | *--EAT_SIG--------->| | | | | -3659080543 | | | | | | -3670208832 . . . . | . . . . . . . . . | . . . . . . . . . * .DONE_SIG . . . . | . . . . . . . . . | . . . . . . . . . | . . . . . . . . . | . . . -3670208845 | |<--------DONE_SIG--* | | | | -3670208934 | | | | | | -3670213302 . . . . | . . . . . . . . . * .EAT_SIG. . . . . | . . . . . . . . . | . . . . . . . . . | . . . . . . . . . | . . . . . . . . . | . . . -3670213313 | *--EAT_SIG----------+-------------------+-------------------+-------------------+------------------>| -3670213374 | *--EAT_SIG----------+-------------------+-------------------+------------------>| | -3670213410 | *--EAT_SIG----------+-------------------+------------------>| | | -3670213450 | *--EAT_SIG----------+------------------>| | | | -3670213487 | *--EAT_SIG--------->| | | | | -3670270131 | | | | | | -3678552423 | |<------------------+-------------------+-------HUNGRY_SIG--* | | -3678552515 | | | | | | -3678711856 . . . . | . . . . . . . . . | . . . . . . . . . | . . . . . . . . . | . . . . . . . . . | . . . . . . . . . * .DONE_SIG . . . . | . . . -3678711870 | |<------------------+-------------------+-------------------+---------DONE_SIG--* | -3678711975 | | | | | | -3678733205 . . . . | . . . . . . . . . * .EAT_SIG. . . . . | . . . . . . . . . | . . . . . . . . . | . . . . . . . . . | . . . . . . . . . | . . . -3678733224 | *--EAT_SIG----------+-------------------+-------------------+-------------------+------------------>| -3678733324 | *--EAT_SIG----------+-------------------+-------------------+------------------>| | -3678733362 | *--EAT_SIG----------+-------------------+------------------>| | | -3678733401 | *--EAT_SIG----------+------------------>| | | | -3678733439 | *--EAT_SIG--------->| | | | | -3678755354 | | | | | | -3687747470 . . . . | . . . . . . . . . | . . . . . . . . . | . . . . . . . . . * .DONE_SIG . . . . | . . . . . . . . . | . . . . . . . . . | . . . -3687747485 | |<------------------+---------DONE_SIG--* | | | -3687747627 | | | | | | - +-------+-------+ +-------+-------+ +-------+-------+ +-------+-------+ +-------+-------+ +-------+-------+ +-------+-------+ - |l_SysTick_Handl| | Table::inst | |Philo::inst[0] | |Philo::inst[1] | |Philo::inst[2] | |Philo::inst[3] | |Philo::inst[4] | - +-------+-------+ +-------+-------+ +-------+-------+ +-------+-------+ +-------+-------+ +-------+-------+ +-------+-------+ -3687752506 . . . . | . . . . . . . . . * .EAT_SIG. . . . . | . . . . . . . . . | . . . . . . . . . | . . . . . . . . . | . . . . . . . . . | . . . -3687752523 | *--EAT_SIG----------+-------------------+-------------------+-------------------+------------------>| -3687752602 | *--EAT_SIG----------+-------------------+-------------------+------------------>| | -3687752643 | *--EAT_SIG----------+-------------------+------------------>| | | -3687752684 | *--EAT_SIG----------+------------------>| | | | -3687752723 | *--EAT_SIG--------->| | | | | -3687796458 | | | | | | -3690128845 | |<------HUNGRY_SIG--* | | | | -3690128941 | | | | | | -3699943848 . . . . | . . . . . . . . . | . . . . . . . . . | . . . . . . . . . | . . . . . . . . . | . . . . . . . . . | . . . . DONE_SIG. * . . . -3699943861 | |<------------------+-------------------+-------------------+-------------------+---------DONE_SIG--* -3699944086 | | | | | | -3699949351 . . . . | . . . . . . . . . * .EAT_SIG. . . . . | . . . . . . . . . | . . . . . . . . . | . . . . . . . . . | . . . . . . . . . | . . . -3699949366 | *--EAT_SIG----------+-------------------+-------------------+-------------------+------------------>| -3699949438 | *--EAT_SIG----------+-------------------+-------------------+------------------>| | -3699949477 | *--EAT_SIG----------+-------------------+------------------>| | | -3699949515 | *--EAT_SIG----------+------------------>| | | | -3699949553 | *--EAT_SIG--------->| | | | | -3699993604 | | | | | | -3700791185 | |<------------------+-------------------+-------------------+-------HUNGRY_SIG--* | -3700791229 | | | | | | -3704646786 | |<------------------+-------HUNGRY_SIG--* | | | -3704646858 | | | | | | -3718532798 . . . . | . . . . . . . . . | . . . . . . . . . | . . . . . . . . . | . . . . . . . . . * .DONE_SIG . . . . | . . . . . . . . . | . . . -3718532818 | |<------------------+-------------------+---------DONE_SIG--* | | -3718532922 | | | | | | -3718539406 . . . . | . . . . . . . . . * .EAT_SIG. . . . . | . . . . . . . . . | . . . . . . . . . | . . . . . . . . . | . . . . . . . . . | . . . -3718539417 | *--EAT_SIG----------+-------------------+-------------------+-------------------+------------------>| -3718539482 | *--EAT_SIG----------+-------------------+-------------------+------------------>| | -3718539520 | *--EAT_SIG----------+-------------------+------------------>| | | -3718539558 | *--EAT_SIG----------+------------------>| | | | -3718539597 | *--EAT_SIG--------->| | | | | -3718583900 | | | | | | -3719382150 . . . . | . . . . . . . . . | . . . . . . . . . * .DONE_SIG . . . . | . . . . . . . . . | . . . . . . . . . | . . . . . . . . . | . . . -3719382162 | |<--------DONE_SIG--* | | | | -3719382257 | | | | | | -3719388749 . . . . | . . . . . . . . . * .EAT_SIG. . . . . | . . . . . . . . . | . . . . . . . . . | . . . . . . . . . | . . . . . . . . . | . . . -3719388807 | *--EAT_SIG----------+-------------------+-------------------+-------------------+------------------>| -3719388896 | *--EAT_SIG----------+-------------------+-------------------+------------------>| | -3719388932 | *--EAT_SIG----------+-------------------+------------------>| | | -3719388988 | *--EAT_SIG----------+------------------>| | | | -3719389026 | *--EAT_SIG--------->| | | | | -3719427946 | | | | | | -3724081113 | |<------------------+-------------------+-------------------+-------------------+-------HUNGRY_SIG--* -3724081256 | | | | | | -3728720237 | |<------HUNGRY_SIG--* | | | | -3728720345 | | | | | | diff --git a/qspy/source/getopt.c b/qspy/source/getopt.c deleted file mode 100644 index 95ca102..0000000 --- a/qspy/source/getopt.c +++ /dev/null @@ -1,254 +0,0 @@ -/*============================================================================ -* getopt.c - competent and free getopt library. -* -* getopt() return values: -* -1 end of processing -* '?' unknown option -* '!' unexpected option argument -* '$' option argument required -* -* Copyright (c) 2002-2003, Mark K. Kim -* Copyright (c) 2012-2017, Kim Grasman -* Copyright (c) 2018-2020, Quantum Leaps 2018 -* -* Redistribution and use in source and binary forms, with or without -* modification, are permitted provided that the following conditions are met: -* * Redistributions of source code must retain the above copyright -* notice, this list of conditions and the following disclaimer. -* * Redistributions in binary form must reproduce the above copyright -* notice, this list of conditions and the following disclaimer in the -* documentation and/or other materials provided with the distribution. -* * Neither the name of Kim Grasman nor the -* names of contributors may be used to endorse or promote products -* derived from this software without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -* ARE DISCLAIMED. IN NO EVENT SHALL KIM GRASMAN BE LIABLE FOR ANY -* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND -* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -============================================================================*/ -#include - -#include "safe_std.h" /* "safe" and facilities */ -#include "getopt.h" - -char const *optarg = NULL; -int optind = 0; -int optopt = '?'; -int opterr = 1; - -static char **prev_argv = NULL; /* Keep a copy of argv and argc to */ -static int prev_argc = 0; /* tell if getopt params change */ -static int argv_index = 0; /* Option we're checking */ -static int argv_index2 = 0; /* Option argument we're checking */ -static int opt_offset = 0; /* Index into compounded "-option" */ -static int dashdash = 0; /* True if "--" option reached */ -static int nonopt = 0; /* How many nonopts we've found */ - -static void increment_index(void); /* prototype */ -static int permute_argv_once(void); /* prototype */ - -static void increment_index(void) { - /* Move onto the next option */ - if (argv_index < argv_index2) { - while (prev_argv[++argv_index] - && (prev_argv[argv_index][0] != '-') - && (argv_index < argv_index2 + 1)) - {} - } - else { - ++argv_index; - } - opt_offset = 1; -} - -/* -* Permutes argv[] so that the argument currently being processed is moved -* to the end. -*/ -static int permute_argv_once(void) { - /* Movability check */ - if (argv_index + nonopt >= prev_argc) { - return 1; - } - /* Move the current option to the end, bring the others to front */ - else { - char *tmp = prev_argv[argv_index]; - - /* Move the data */ - (void)memmove(&prev_argv[argv_index], &prev_argv[argv_index + 1], - sizeof(char**) * (size_t)(prev_argc - (argv_index + 1))); - prev_argv[prev_argc - 1] = tmp; - - nonopt++; - return 0; - } -} - -int getopt(int argc, char *argv[], char const *optstr) { - int c = 0; - - /* If we have new argv, reinitialize */ - if (prev_argv != argv || prev_argc != argc) { - /* Initialize variables */ - prev_argv = argv; - prev_argc = argc; - argv_index = 1; - argv_index2 = 1; - opt_offset = 1; - dashdash = 0; - nonopt = 0; - } - - /* Jump point in case we want to ignore the current argv_index */ - getopt_top: - - /* Misc. initializations */ - optarg = NULL; - - /* Dash-dash check */ - if (argv[argv_index] && !strcmp(argv[argv_index], "--")) { - dashdash = 1; - increment_index(); - } - - /* If we're at the end of argv, that's it. */ - if (argv[argv_index] == NULL) { - c = -1; - } - /* Are we looking at a string? Single dash is also a string */ - else if (dashdash || argv[argv_index][0] != '-' - || !strcmp(argv[argv_index], "-")) - { - /* If we want a string... */ - if (optstr[0] == '-') { - c = 1; - optarg = argv[argv_index]; - increment_index(); - } - /* If we really don't want it (we're in POSIX mode), we're done */ - else if (optstr[0] == '+' -#ifndef _MSC_VER /* NOT Microsoft Compiler */ - || getenv("POSIXLY_CORRECT") -#endif - ) - { - c = -1; - - /* Everything else is a non-opt argument */ - nonopt = argc - argv_index; - } - /* If we mildly don't want it, then move it back */ - else { - if (!permute_argv_once()) { - goto getopt_top; - } - else { - c = -1; - } - } - } - /* Otherwise we're looking at an option */ - else { - char const *opt_ptr = NULL; - - /* Grab the option */ - c = argv[argv_index][opt_offset++]; - - /* Is the option in the optstr? */ - if (optstr[0] == '-') { - opt_ptr = strchr(optstr+1, c); - } - else { - opt_ptr = strchr(optstr, c); - } - /* Invalid argument */ - if (!opt_ptr) { - if (opterr) { - FPRINTF_S(stderr, "\nERROR: -%c command-line option " - "takes no arguments\n", optopt); - } - optopt = c; - c = '!'; /* notify the caller about invalid argument */ - - /* Move onto the next option */ - increment_index(); - } - /* Option takes argument */ - else if (opt_ptr[1] == ':') { - /* ie, -oARGUMENT, -xxxoARGUMENT, etc. */ - if (argv[argv_index][opt_offset] != '\0') { - optarg = &argv[argv_index][opt_offset]; - increment_index(); - } - /* ie, -o ARGUMENT (only if it's a required argument) */ - else if (opt_ptr[2] != ':') { - /* "you're not expected to understand this" moment... */ - if (argv_index2 < argv_index) { - argv_index2 = argv_index; - } - while (argv[++argv_index2] && argv[argv_index2][0] == '-') { - } - optarg = argv[argv_index2]; - - /* Don't cross into the non-option argument list */ - if (argv_index2 + nonopt >= prev_argc) { - optarg = NULL; - } - - /* Move onto the next option */ - increment_index(); - } - else { /* optional argument */ - if (argv[argv_index + 1] && argv[argv_index + 1][0] != '-') { - argv_index2 = argv_index + 1; - optarg = argv[argv_index2]; - /* Don't cross into the non-option argument list */ - if (argv_index2 + nonopt >= prev_argc) { - optarg = NULL; - } - } - else { - optarg = NULL; /* no argument */ - } - - /* Move onto the next option */ - increment_index(); - } - - /* If we got no argument for an option with required argument */ - if (optarg == NULL && opt_ptr[2] != ':') { - optopt = c; - c = '$'; /* notify the caller about required argument(s) */ - - if (opterr) { - FPRINTF_S(stderr, "\nERROR: -%c command-line option " - "requires argument(s)\n", optopt); - } - } - } - /* Option does not take argument */ - else { - /* Next argv_index */ - if (argv[argv_index][opt_offset] == '\0') { - increment_index(); - } - } - } - - /* Calculate optind */ - if (c == -1) { - optind = argc - nonopt; - } - else { - optind = argv_index; - } - - return c; -} diff --git a/qspy/source/qspy.c b/qspy/source/qspy.c deleted file mode 100644 index bc84489..0000000 --- a/qspy/source/qspy.c +++ /dev/null @@ -1,2731 +0,0 @@ -//============================================================================ -// QSPY software tracing host-side utility -// Copyright (C) 2005 Quantum Leaps, LLC. All rights reserved. -// -// SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-QL-commercial -// -// This software is dual-licensed under the terms of the open source GNU -// General Public License version 3 (or any later version), or alternatively, -// under the terms of one of the closed source Quantum Leaps commercial -// licenses. -// -// The terms of the open source GNU General Public License version 3 -// can be found at: -// -// The terms of the closed source Quantum Leaps commercial licenses -// can be found at: -// -// Redistributions in source code must retain this top-level comment block. -// Plagiarizing this software to sidestep the license obligations is illegal. -// -// Contact information: -// -// -//============================================================================ -//! @date Last updated on: 2024-06-21 -//! @version Last updated for version: 7.4.0 -//! -//! @file -//! @brief QSPY host utility: main parser - -#include -#include -#include -#include -#include - -#include "safe_std.h" /* "safe" and facilities */ -#include "qspy.h" /* QSPY data parser */ -#include "pal.h" /* Platform Abstraction Layer */ - -#define Q_SPY 1 // this is QP implementation -#define QP_IMPL 1 // this is QP implementation -typedef uint32_t QSObj; // dummy definition for including "qpc_qs.h" -typedef uint32_t QEvt; // dummy definition for including "qpc_qs.h" -#include "qpc_qs.h" // QS target-resident interface -#include "qpc_qs_pkg.h" // QS package-scope interface - -/* global objects ..........................................................*/ -QSPY_LastOutput QSPY_output; -char const * const QSPY_line = &QSPY_output.buf[QS_LINE_OFFSET]; - -QSpyConfig QSPY_conf; -Dictionary QSPY_funDict; -Dictionary QSPY_objDict; -Dictionary QSPY_usrDict; -SigDictionary QSPY_sigDict; -Dictionary QSPY_enumDict[8]; - -/*==========================================================================*/ -enum { - OLD_QS_USER = 70, /* old QS_USER used before QS 6.6.0 */ -}; - -/*..........................................................................*/ -static DictEntry l_funSto[512]; -static DictEntry l_objSto[256]; -static DictEntry l_usrSto[128 + 1 - OLD_QS_USER]; -static SigDictEntry l_sigSto[512]; -static DictEntry l_enumSto[8][256]; - -/*..........................................................................*/ -static FILE *l_matFile; -static uint32_t l_userRec; -static QSPY_CustParseFun l_custParseFun; -static QSPY_resetFun l_txResetFun; - -typedef struct { - char const *name; /* name of the record, e.g. "QS_QF_PUBLISH" */ - int const group; /* group of the record (for rendering/coloring) */ -} QSpyRecRender; - -/* rendering information for QSPY records */ -/* QS record names... NOTE: keep in synch with qspy_qs.h */ -QSpyRecRender const l_recRender[QS_USER] = { - { "QS_EMPTY", GRP_INF }, - - /* [1] QEP records */ - { "QS_QEP_STATE_ENTRY", GRP_SM }, - { "QS_QEP_STATE_EXIT", GRP_SM }, - { "QS_QEP_STATE_INIT", GRP_SM }, - { "QS_QEP_INIT_TRAN", GRP_SM }, - { "QS_QEP_INTERN_TRAN", GRP_SM }, - { "QS_QEP_TRAN", GRP_SM }, - { "QS_QEP_IGNORED", GRP_SM }, - { "QS_QEP_DISPATCH", GRP_SM }, - { "QS_QEP_UNHANDLED", GRP_SM }, - - /* [10] QF (AP) records */ - { "QS_QF_ACTIVE_DEFER", GRP_AO }, - { "QS_QF_ACTIVE_RECALL", GRP_AO }, - { "QS_QF_ACTIVE_SUBSCRIBE", GRP_AO }, - { "QS_QF_ACTIVE_UNSUBSCRIBE", GRP_AO }, - { "QS_QF_ACTIVE_POST", GRP_AO }, - { "QS_QF_ACTIVE_POST_LIFO", GRP_AO }, - { "QS_QF_ACTIVE_GET", GRP_AO }, - { "QS_QF_ACTIVE_GET_LAST", GRP_AO }, - { "QS_QF_ACTIVE_RECALL_ATTEMPT", GRP_AO }, - - /* [19] QF (EQ) records */ - { "QS_QF_EQUEUE_POST", GRP_EQ }, - { "QS_QF_EQUEUE_POST_LIFO", GRP_EQ }, - { "QS_QF_EQUEUE_GET", GRP_EQ }, - { "QS_QF_EQUEUE_GET_LAST", GRP_EQ }, - - /* [23] QF records */ - { "QS_QF_NEW_ATTEMPT", GRP_QF }, - - /* [24] Memory Pool (MP) records */ - { "QS_QF_MPOOL_GET", GRP_MP }, - { "QS_QF_MPOOL_PUT", GRP_MP }, - - /* [26] Additional Framework (QF) records */ - { "QS_QF_PUBLISH", GRP_QF }, - { "QS_QF_NEW_REF", GRP_QF }, - { "QS_QF_NEW", GRP_QF }, - { "QS_QF_GC_ATTEMPT", GRP_QF }, - { "QS_QF_GC", GRP_QF }, - { "QS_QF_TICK", GRP_QF }, - - /* [32] Time Event (TE) records */ - { "QS_QF_TIMEEVT_ARM", GRP_TE }, - { "QS_QF_TIMEEVT_AUTO_DISARM", GRP_TE }, - { "QS_QF_TIMEEVT_DISARM_ATTEMPT", GRP_TE }, - { "QS_QF_TIMEEVT_DISARM", GRP_TE }, - { "QS_QF_TIMEEVT_REARM", GRP_TE }, - { "QS_QF_TIMEEVT_POST", GRP_TE }, - - /* [38] Additional Framework (QF) records */ - { "QS_QF_DELETE_REF", GRP_QF }, - { "QS_QF_CRIT_ENTRY", GRP_QF }, - { "QS_QF_CRIT_EXIT", GRP_QF }, - { "QS_QF_ISR_ENTRY", GRP_QF }, - { "QS_QF_ISR_EXIT", GRP_QF }, - { "QS_QF_INT_DISABLE", GRP_QF }, - { "QS_QF_INT_ENABLE", GRP_QF }, - - /* [45] Additional Active Object (AO) records */ - { "QS_QF_ACTIVE_POST_ATTEMPT", GRP_AO }, - - /* [46] Additional Event Queue (EQ) records */ - { "QS_QF_EQUEUE_POST_ATTEMPT", GRP_EQ }, - - /* [47] Additional Memory Pool (MP) records */ - { "QS_QF_MPOOL_GET_ATTEMPT", GRP_MP }, - - /* [48] Scheduler (SC) records */ - { "QS_SCHED_PREEMPT", GRP_SC }, - { "QS_SCHED_RESTORE", GRP_SC }, - { "QS_SCHED_LOCK", GRP_SC }, - { "QS_SCHED_UNLOCK", GRP_SC }, - { "QS_SCHED_NEXT", GRP_SC }, - { "QS_SCHED_IDLE", GRP_SC }, - { "QS_ENUM_DICT", GRP_DIC }, - - /* [55] Additional QEP records */ - { "QS_QEP_TRAN_HIST", GRP_SM }, - { "QS_QEP_TRAN_EP", GRP_SM }, - { "QS_QEP_TRAN_XP", GRP_SM }, - - /* [58] Miscellaneous QS records (not maskable) */ - { "QS_TEST_PAUSED", GRP_TST }, - { "QS_TEST_PROBE_GET", GRP_TST }, - { "QS_SIG_DICT", GRP_DIC }, - { "QS_OBJ_DICT", GRP_DIC }, - { "QS_FUN_DICT", GRP_DIC }, - { "QS_USR_DICT", GRP_DIC }, - { "QS_TARGET_INFO", GRP_INF }, - { "QS_TARGET_DONE", GRP_TST }, - { "QS_RX_STATUS", GRP_TST }, - { "QS_QUERY_DATA", GRP_TST }, - { "QS_PEEK_DATA", GRP_TST }, - { "QS_ASSERT_FAIL", GRP_ERR }, - { "QS_QF_RUN", GRP_INF }, - - /* [71] Semaphore (SEM) records */ - { "QS_SEM_TAKE", GRP_SEM }, - { "QS_SEM_BLOCK", GRP_SEM }, - { "QS_SEM_SIGNAL", GRP_SEM }, - { "QS_SEM_BLOCK_ATTEMPT", GRP_SEM }, - - /* [75] Mutex (MTX) records */ - { "QS_MTX_LOCK", GRP_MTX }, - { "QS_MTX_BLOCK", GRP_MTX }, - { "QS_MTX_UNLOCK", GRP_MTX }, - { "QS_MTX_LOCK_ATTEMPT", GRP_MTX }, - { "QS_MTX_BLOCK_ATTEMPT", GRP_MTX }, - { "QS_MTX_UNLOCK_ATTEMPT", GRP_MTX }, - - /* [81] reserved and unused */ - { "QS_RESERVED", GRP_ERR }, - { "QS_RESERVED", GRP_ERR }, - { "QS_RESERVED", GRP_ERR }, - { "QS_RESERVED", GRP_ERR }, - { "QS_RESERVED", GRP_ERR }, - { "QS_RESERVED", GRP_ERR }, - { "QS_RESERVED", GRP_ERR }, - { "QS_RESERVED", GRP_ERR }, - { "QS_RESERVED", GRP_ERR }, - { "QS_RESERVED", GRP_ERR }, - { "QS_RESERVED", GRP_ERR }, - { "QS_RESERVED", GRP_ERR }, - { "QS_RESERVED", GRP_ERR }, - { "QS_RESERVED", GRP_ERR }, - { "QS_RESERVED", GRP_ERR }, - { "QS_RESERVED", GRP_ERR }, - { "QS_RESERVED", GRP_ERR }, - { "QS_RESERVED", GRP_ERR }, - { "QS_RESERVED", GRP_ERR }, -}; - -/* QS object kinds... NOTE: keep in synch with qspy_qs.h */ -static char const * l_qs_obj[] = { - "SM", - "AO", - "MP", - "EQ", - "TE", - "AP", - "SM_AO" -}; - -/* QS-RX record names... NOTE: keep in synch with qspy_qs_pkg.h */ -static char const * l_qs_rx_rec[] = { - "QS_RX_INFO", - "QS_RX_COMMAND", - "QS_RX_RESET", - "QS_RX_TICK", - "QS_RX_PEEK", - "QS_RX_POKE", - "QS_RX_FILL", - "QS_RX_TEST_SETUP", - "QS_RX_TEST_TEARDOWN", - "QS_RX_TEST_PROBE", - "QS_RX_GLB_FILTER", - "QS_RX_LOC_FILTER", - "QS_RX_AO_FILTER", - "QS_RX_CURR_OBJ", - "QS_RX_TEST_CONTINUE", - "QS_RX_QUERY_CURR", - "QS_RX_EVENT" -}; - -/* facilities for QSPY host application only (but not for QSPY parser) */ -#ifdef QSPY_APP - -#define FPRINF_MATFILE(format_, ...) \ - if (l_matFile != (FILE *)0) { \ - FPRINTF_S(l_matFile, format_, __VA_ARGS__); \ - } else (void)0 - -#else - -#define FPRINF_MATFILE(format_, ...) ((void)0) - -#endif /* QSPY_APP */ - -/*==========================================================================*/ -void QSPY_config(QSpyConfig const *config, - QSPY_CustParseFun custParseFun) -{ - MEMMOVE_S(&QSPY_conf, sizeof(QSPY_conf), config, sizeof(*config)); - l_custParseFun = custParseFun; - - Dictionary_ctor(&QSPY_funDict, l_funSto, - sizeof(l_funSto)/sizeof(l_funSto[0])); - Dictionary_config(&QSPY_funDict, QSPY_conf.funPtrSize); - - Dictionary_ctor(&QSPY_objDict, l_objSto, - sizeof(l_objSto)/sizeof(l_objSto[0])); - Dictionary_config(&QSPY_objDict, QSPY_conf.objPtrSize); - - Dictionary_ctor(&QSPY_usrDict, l_usrSto, - sizeof(l_usrSto)/sizeof(l_usrSto[0])); - Dictionary_config(&QSPY_usrDict, 1); - - SigDictionary_ctor(&QSPY_sigDict, l_sigSto, - sizeof(l_sigSto)/sizeof(l_sigSto[0])); - SigDictionary_config(&QSPY_sigDict, QSPY_conf.objPtrSize); - - for (unsigned i = 0U; - i < sizeof(QSPY_enumDict)/sizeof(QSPY_enumDict[0]); - ++i) - { - Dictionary_ctor(&QSPY_enumDict[i], l_enumSto[i], - sizeof(l_enumSto[i])/sizeof(l_enumSto[i][0])); - Dictionary_config(&QSPY_enumDict[i], 1); - } - - QSPY_conf.tstamp[5] = 0U; /* invalidate the year-part of the timestamp */ - l_userRec = ((QSPY_conf.version < 660U) ? OLD_QS_USER : QS_USER); -} -/*..........................................................................*/ -void QSPY_configTxReset(QSPY_resetFun txResetFun) { - l_txResetFun = txResetFun; -} -/*..........................................................................*/ -void QSPY_configMatFile(void *matFile) { - if (l_matFile != (FILE *)0) { - fclose(l_matFile); - } - l_matFile = (FILE *)matFile; -} - -/*..........................................................................*/ -void QSpyRecord_init(QSpyRecord * const me, - uint8_t const *start, uint32_t tot_len) -{ - me->start = start; - me->tot_len = (uint32_t)tot_len; - me->len = (uint32_t)(tot_len - 3U); - me->pos = start + 2; - me->rec = start[1]; - - /* set the current QS record-ID for any subsequent output */ - QSPY_output.rec = me->rec; - QSPY_output.rx_status = -1; -} -/*..........................................................................*/ -QSpyStatus QSpyRecord_OK(QSpyRecord * const me) { - if (me->len != 0) { - SNPRINTF_LINE(" %s", "ERROR "); - if (me->len > 0) { - SNPRINTF_APPEND("%d bytes unused in ", me->len); - } - else { - SNPRINTF_APPEND("%d bytes needed in ", -(int)me->len); - } - - /* is this a pre-defined QS record? */ - if (me->rec < l_userRec) { - SNPRINTF_APPEND("Rec=%s", l_recRender[me->rec].name); - } - else { /* application-specific (user) record */ - SNPRINTF_APPEND("Rec=USER+%3d", (int)(me->rec - l_userRec)); - } - QSPY_onPrintLn(); - return QSPY_ERROR; - } - return QSPY_SUCCESS; -} -/*..........................................................................*/ -uint32_t QSpyRecord_getUint32(QSpyRecord * const me, uint8_t size) { - uint32_t ret = 0U; - - if (me->len >= size) { - if (size == 1U) { - ret = (uint32_t)me->pos[0]; - } - else if (size == 2U) { - ret = (((uint32_t)me->pos[1] << 8) | (uint32_t)me->pos[0]); - } - else if (size == 4U) { - ret = ((((((uint32_t)me->pos[3] << 8) - | (uint32_t)me->pos[2]) << 8) - | (uint32_t)me->pos[1]) << 8) - | (uint32_t)me->pos[0]; - } - else { - Q_ASSERT(0); - } - me->pos += size; - me->len -= size; - } - else { - SNPRINTF_LINE(" ERROR %d more bytes needed for uint%d_t ", - (int)(size - me->len), (int)(size*8U)); - me->len = -1; - QSPY_onPrintLn(); - } - return ret; -} -/*..........................................................................*/ -int32_t QSpyRecord_getInt32(QSpyRecord * const me, uint8_t size) { - int32_t ret = (int32_t)0; - - if (me->len >= size) { - if (size == 1U) { - ret = (uint32_t)me->pos[0]; - ret <<= 24; - ret >>= 24; /* sign-extend */ - } - else if (size == 2U) { - ret = ((uint32_t)me->pos[1] << 8) - | (uint32_t)me->pos[0]; - ret <<= 16; - ret >>= 16; /* sign-extend */ - } - else if (size == 4U) { - ret = ((((((int32_t)me->pos[3] << 8) - | (uint32_t)me->pos[2]) << 8) - | (uint32_t)me->pos[1]) << 8) - | (uint32_t)me->pos[0]; - } - else { - Q_ASSERT(0); - } - me->pos += size; - me->len -= size; - } - else { - SNPRINTF_LINE(" ERROR %d more bytes needed for int%d_t ", - (int)(size - me->len), (int)(size*8U)); - me->len = -1; - QSPY_onPrintLn(); - } - return ret; -} -/*..........................................................................*/ -uint64_t QSpyRecord_getUint64(QSpyRecord * const me, uint8_t size) { - uint64_t ret = 0U; - - if (me->len >= size) { - if (size == 1U) { - ret = (uint64_t)me->pos[0]; - } - else if (size == 2U) { - ret = (((uint64_t)me->pos[1] << 8) - | (uint32_t)me->pos[0]); - } - else if (size == 4U) { - ret = ((((((uint64_t)me->pos[3] << 8) - | (uint64_t)me->pos[2]) << 8) - | (uint64_t)me->pos[1]) << 8) - | (uint64_t)me->pos[0]; - } - else if (size == 8U) { - ret = ((((((((((((((uint64_t)me->pos[7] << 8) - | (uint64_t)me->pos[6]) << 8) - | (uint64_t)me->pos[5]) << 8) - | (uint64_t)me->pos[4]) << 8) - | (uint64_t)me->pos[3]) << 8) - | (uint64_t)me->pos[2]) << 8) - | (uint64_t)me->pos[1]) << 8) - | (uint64_t)me->pos[0]; - } - else { - Q_ASSERT(0); - } - me->pos += size; - me->len -= size; - } - else { - SNPRINTF_LINE(" ERROR %d more bytes needed for uint%d_t ", - (int)(size - me->len), (int)(size*8U)); - me->len = -1; - QSPY_onPrintLn(); - } - return ret; -} -/*..........................................................................*/ -int64_t QSpyRecord_getInt64(QSpyRecord * const me, uint8_t size) { - int64_t ret = (int64_t)0; - - if (me->len >= size) { - if (size == 1U) { - ret = (uint64_t)me->pos[0]; - ret <<= 56; - ret >>= 56; /* sign-extend */ - } - else if (size == 2U) { - ret = (((uint64_t)me->pos[1] << 8) - | (uint32_t)me->pos[0]); - ret <<= 48; - ret >>= 48; /* sign-extend */ - } - else if (size == 4U) { - ret = ((((((uint64_t)me->pos[3] << 8) - | (uint64_t)me->pos[2]) << 8) - | (uint64_t)me->pos[1]) << 8) - | (uint64_t)me->pos[0]; - ret <<= 32; - ret >>= 32; /* sign-extend */ - } - else if (size == 8U) { - ret = ((((((((((((((uint64_t)me->pos[7] << 8) - | (uint64_t)me->pos[6]) << 8) - | (uint64_t)me->pos[5]) << 8) - | (uint64_t)me->pos[4]) << 8) - | (uint64_t)me->pos[3]) << 8) - | (uint64_t)me->pos[2]) << 8) - | (uint64_t)me->pos[1]) << 8) - | (uint64_t)me->pos[0]; - } - else { - Q_ASSERT(0); - } - me->pos += size; - me->len -= size; - } - else { - SNPRINTF_LINE(" ERROR %d more bytes needed for int%d_t ", - (int)(size - me->len), (int)(size*8U)); - me->len = -1; - QSPY_onPrintLn(); - } - return ret; -} -/*..........................................................................*/ -char const *QSpyRecord_getStr(QSpyRecord * const me) { - uint8_t const *p; - int32_t l; - - /* is the string empty? */ - if (*me->pos == 0U) { - /* adjust the stream for the next token */ - --me->len; - ++me->pos; - - /* return explicit empty string as two single-quotes '' */ - return "''"; - } - - for (l = me->len, p = me->pos; l > 0; --l, ++p) { - if (*p == 0U) { /* zero-terminated end of the string? */ - char const *s = (char const *)me->pos; - - /* adjust the stream for the next token */ - me->len = l - 1; - me->pos = p + 1; - return s; /* normal return */ - } - } - - /* error case... */ - SNPRINTF_LINE(" ERROR %d more bytes needed for string", - (int)me->len); - me->len = -1; - QSPY_onPrintLn(); - return ""; -} -/*..........................................................................*/ -uint8_t const *QSpyRecord_getMem(QSpyRecord * const me, - uint8_t size, - uint32_t *pNum) -{ - if ((me->len >= 1) && ((*me->pos) <= me->len)) { - uint8_t num = *me->pos; - uint8_t const *mem = me->pos + 1; - *pNum = num; - me->len -= 1 + (num * size); - me->pos += 1 + (num * size); - return mem; - } - - /* error case... */ - SNPRINTF_LINE(" ERROR %d more bytes needed for memory-dump", - (int)me->len); - me->len = -1; - *pNum = 0U; - QSPY_onPrintLn(); - - return (uint8_t *)0; -} - -/*==========================================================================*/ -/* application-specific (user) QS records... */ -static void QSpyRecord_processUser(QSpyRecord * const me) { - int64_t i64; - uint64_t u64; - int32_t i32; - uint32_t u32; - static char const *ifmt[] = { - "%li", "%1li", "%2li", "%3li", - "%4li", "%5li", "%6li", "%7li", - "%8li", "%9li", "%10li", "%11li", - "%12li", "%13li", "%14li", "%15li" - }; - static char const *ufmt[] = { - "%lu", "%1lu", "%2lu", "%3lu", - "%4lu", "%5lu", "%6lu", "%7lu", - "%8lu", "%9lu", "%10lu", "%11lu", - "%12lu", "%13lu", "%14lu", "%15lu" - }; - static char const *uhfmt[] = { - "0x%0lX", "0x%01lX", "0x%02lX", "0x%03lX", - "0x%04lX", "0x%05lX", "0x%06lX", "0x%07lX", - "0x%08lX", "0x%09lX", "0x%010lX", "0x%011lX", - "0x%012lX", "0x%013lX", "0x%014lX", "0x%015lX" - }; - static char const *ilfmt[] = { - "%2"PRIi64, "%4"PRIi64, "%6"PRIi64, "%8"PRIi64, - "%10"PRIi64, "%12"PRIi64, "%14"PRIi64, "%16"PRIi64, - "%18"PRIi64, "%"PRIi64, "%22"PRIi64, "%24"PRIi64, - "%26"PRIi64, "%28"PRIi64, "%30"PRIi64, "%32"PRIi64 - }; - static char const *ulfmt[] = { - "%2"PRIu64, "%4"PRIu64, "%6"PRIu64, "%8"PRIu64, - "%10"PRIu64, "%12"PRIu64, "%14"PRIu64, "%16"PRIu64, - "%18"PRIu64, "%20"PRIu64, "%22"PRIu64, "%24"PRIu64, - "%26"PRIu64, "%28"PRIu64, "%30"PRIu64, "%32"PRIu64 - }; - static char const *efmt[] = { - "%7.0e", "%9.1e", "%10.2e", "%11.3e", - "%12.4e", "%13.5e", "%14.6e", "%15.7e", - "%16.8e", "%17.9e", "%18.10e", "%19.11e", - "%20.12e", "%21.13e", "%22.14e", "%23.15e", - }; - - u32 = QSpyRecord_getUint32(me, QSPY_conf.tstampSize); - i32 = Dictionary_find(&QSPY_usrDict, me->rec); - if (i32 >= 0) { - SNPRINTF_LINE("%010u %s", u32, Dictionary_at(&QSPY_usrDict, i32)); - } - else { - SNPRINTF_LINE("%010u USER+%03d", u32, (int)(me->rec - l_userRec)); - } - - FPRINF_MATFILE("%d %u", (int)me->rec, u32); - - while (me->len > 0) { - /* get the format byte */ - uint32_t fmt = QSpyRecord_getUint32(me, 1); - uint32_t width = (fmt >> 4U) & 0x0FU; - bool is_hex = (width == (uint32_t)QS_HEX_FMT); - fmt &= 0x0FU; - - SNPRINTF_APPEND("%c", ' '); - FPRINF_MATFILE("%c", ' '); - - char const *s; - switch (fmt) { - case QS_I8_ENUM_T: { - if ((width & 0x8U) == 0U) { /* QS_I8() data element */ - i32 = QSpyRecord_getInt32(me, 1); - SNPRINTF_APPEND(ifmt[width], (long)i32); - FPRINF_MATFILE(ifmt[width], (long)i32); - } - else { /* QS_ENUM() data element */ - u32 = QSpyRecord_getUint32(me, 1); - SNPRINTF_APPEND("%s", - Dictionary_get(&QSPY_enumDict[width & 0x7U], - u32, (char *)0)); - FPRINF_MATFILE(ufmt[1], (unsigned long)u32); - } - break; - } - case QS_U8_T: { - u32 = QSpyRecord_getUint32(me, 1); - SNPRINTF_APPEND(is_hex ? uhfmt[2] : ufmt[width], - (unsigned long)u32); - FPRINF_MATFILE(ufmt[width], (unsigned long)u32); - break; - } - case QS_I16_T: { - i32 = QSpyRecord_getInt32(me, 2); - SNPRINTF_APPEND(ifmt[width], (long)i32); - FPRINF_MATFILE(ifmt[width], (long)i32); - break; - } - case QS_U16_T: { - u32 = QSpyRecord_getUint32(me, 2); - SNPRINTF_APPEND(is_hex ? uhfmt[4] : ufmt[width], - (unsigned long)u32); - FPRINF_MATFILE(ufmt[width], (unsigned long)u32); - break; - } - case QS_I32_T: { - i32 = QSpyRecord_getInt32(me, 4); - SNPRINTF_APPEND(ifmt[width], (long)i32); - FPRINF_MATFILE(ifmt[width], (long)i32); - break; - } - case QS_U32_T: { - u32 = QSpyRecord_getUint32(me, 4); - SNPRINTF_APPEND(is_hex ? uhfmt[8] : ufmt[width], - (unsigned long)u32); - FPRINF_MATFILE(ufmt[width], (unsigned long)u32); - break; - } - case QS_F32_T: { - union { - uint32_t u; - float f; - } x; - x.u = QSpyRecord_getUint32(me, 4); - SNPRINTF_APPEND(efmt[width], (double)x.f); - FPRINF_MATFILE(efmt[width], (double)x.f); - break; - } - case QS_F64_T: { - union F64Rep { - uint64_t u; - double d; - } data; - data.u = QSpyRecord_getUint64(me, 8); - SNPRINTF_APPEND(efmt[width], data.d); - FPRINF_MATFILE(efmt[width], data.d); - break; - } - case QS_STR_T: { - s = QSpyRecord_getStr(me); - SNPRINTF_APPEND("%s", s); - FPRINF_MATFILE("%s", s); - break; - } - case QS_MEM_T: { - uint8_t const *mem = QSpyRecord_getMem(me, 1, &u32); - if (mem) { - for (; u32 > 0U; --u32, ++mem) { - SNPRINTF_APPEND(" %02X", (unsigned int)*mem); - FPRINF_MATFILE(" %03d", (unsigned int)*mem); - } - } - break; - } - case QS_SIG_T: { - u32 = QSpyRecord_getUint32(me, QSPY_conf.sigSize); - u64 = QSpyRecord_getUint64(me, QSPY_conf.objPtrSize); - if (u64 != 0U) { - SNPRINTF_APPEND("%s,Obj=%s", - SigDictionary_get(&QSPY_sigDict, u32, u64, (char *)0), - Dictionary_get(&QSPY_objDict, u64, (char *)0)); - } - else { - SNPRINTF_APPEND("%s", - SigDictionary_get(&QSPY_sigDict, u32, u64, (char *)0)); - } - FPRINF_MATFILE("%u %"PRId64, u32, u64); - break; - } - case QS_OBJ_T: { - u64 = QSpyRecord_getUint64(me, QSPY_conf.objPtrSize); - SNPRINTF_APPEND("%s", - Dictionary_get(&QSPY_objDict, u64, (char *)0)); - FPRINF_MATFILE("%"PRId64, u64); - break; - } - case QS_FUN_T: { - u64 = QSpyRecord_getUint64(me, QSPY_conf.funPtrSize); - SNPRINTF_APPEND("%s", - Dictionary_get(&QSPY_funDict, u64, (char *)0)); - FPRINF_MATFILE("%"PRId64, u64); - break; - } - case QS_I64_T: { - i64 = QSpyRecord_getInt64(me, 8); - SNPRINTF_APPEND(ilfmt[width], i64); - FPRINF_MATFILE(ilfmt[width], i64); - break; - } - case QS_U64_T: { - u64 = QSpyRecord_getUint64(me, 8); - SNPRINTF_APPEND(is_hex ? "0x%16"PRIX64 : ulfmt[width], u64); - FPRINF_MATFILE(ulfmt[width], u64); - break; - } - case 0x0FU: { /* former QS_U32_HEX_T */ - u32 = QSpyRecord_getUint32(me, 4); - SNPRINTF_APPEND(uhfmt[width], (unsigned long)u32); - FPRINF_MATFILE(uhfmt[width], (unsigned long)u32); - break; - } - default: { - SNPRINTF_APPEND("%s", "Unknown format"); - me->len = -1; - break; - } - } - } - QSPY_onPrintLn(); - FPRINF_MATFILE("%c", '\n'); -} - -/*==========================================================================*/ -/* predefined QS records... */ -static void QSpyRecord_process(QSpyRecord * const me) { - uint32_t t, a, b, c, d, e; - uint64_t p, q, r; - char buf[QS_FNAME_LEN_MAX]; - char const *s = 0; - char const *w = 0; - - switch (me->rec) { - /* Session start ...................................................*/ - case QS_EMPTY: { - if (QSPY_conf.version >= 550U) { - /* silently ignore */ - } - else { - if (QSpyRecord_OK(me)) { - SNPRINTF_LINE(" Trg-RST %u", - (unsigned)QSPY_conf.version); - QSPY_onPrintLn(); - - QSPY_resetAllDictionaries(); - } - } - break; - } - - /* QEP records .....................................................*/ - case QS_QEP_STATE_ENTRY: - s = "St-Entry"; - //lint -fallthrough - case QS_QEP_STATE_EXIT: { - if (s == 0) s = "St-Exit "; - p = QSpyRecord_getUint64(me, QSPY_conf.objPtrSize); - q = QSpyRecord_getUint64(me, QSPY_conf.funPtrSize); - if (QSpyRecord_OK(me)) { - SNPRINTF_LINE("===RTC===> %s Obj=%s,State=%s", - s, - Dictionary_get(&QSPY_objDict, p, (char *)0), - Dictionary_get(&QSPY_funDict, q, (char *)0)); - QSPY_onPrintLn(); - FPRINF_MATFILE("%d %"PRId64" %"PRId64"\n", - (int)me->rec, p, q); - } - break; - } - case QS_QEP_STATE_INIT: - s = "St-Init "; - //lint -fallthrough - case QS_QEP_TRAN_HIST: - if (s == 0) s = "St-Hist "; - //lint -fallthrough - case QS_QEP_TRAN_EP: - if (s == 0) s = "St-EP "; - //lint -fallthrough - case QS_QEP_TRAN_XP: { - if (s == 0) s = "St-XP "; - p = QSpyRecord_getUint64(me, QSPY_conf.objPtrSize); - q = QSpyRecord_getUint64(me, QSPY_conf.funPtrSize); - r = QSpyRecord_getUint64(me, QSPY_conf.funPtrSize); - if (QSpyRecord_OK(me)) { - SNPRINTF_LINE("===RTC===> %s Obj=%s,State=%s->%s", - s, - Dictionary_get(&QSPY_objDict, p, (char *)0), - Dictionary_get(&QSPY_funDict, q, (char *)0), - Dictionary_get(&QSPY_funDict, r, buf)); - QSPY_onPrintLn(); - FPRINF_MATFILE("%d %"PRId64" %"PRId64" %"PRId64"\n", - (int)me->rec, p, q, r); - } - break; - } - case QS_QEP_INIT_TRAN: { - t = QSpyRecord_getUint32(me, QSPY_conf.tstampSize); - p = QSpyRecord_getUint64(me, QSPY_conf.objPtrSize); - q = QSpyRecord_getUint64(me, QSPY_conf.funPtrSize); - if (QSpyRecord_OK(me)) { - SNPRINTF_LINE("%010u Init===> Obj=%s,State=%s", - t, - Dictionary_get(&QSPY_objDict, p, (char *)0), - Dictionary_get(&QSPY_funDict, q, (char *)0)); - QSPY_onPrintLn(); - FPRINF_MATFILE("%d %u %"PRId64" %"PRId64"\n", - (int)me->rec, t, p, q); - } - break; - } - case QS_QEP_INTERN_TRAN: { - t = QSpyRecord_getUint32(me, QSPY_conf.tstampSize); - a = QSpyRecord_getUint32(me, QSPY_conf.sigSize); - p = QSpyRecord_getUint64(me, QSPY_conf.objPtrSize); - q = QSpyRecord_getUint64(me, QSPY_conf.funPtrSize); - if (QSpyRecord_OK(me)) { - SNPRINTF_LINE("%010u =>Intern Obj=%s,Sig=%s,State=%s", - t, - Dictionary_get(&QSPY_objDict, p, (char *)0), - SigDictionary_get(&QSPY_sigDict, a, p, (char *)0), - Dictionary_get(&QSPY_funDict, q, (char *)0)); - QSPY_onPrintLn(); - FPRINF_MATFILE("%d %u %u %"PRId64 - " %"PRId64"\n", - (int)me->rec, t, a, p, q); - } - break; - } - case QS_QEP_TRAN: { - t = QSpyRecord_getUint32(me, QSPY_conf.tstampSize); - a = QSpyRecord_getUint32(me, QSPY_conf.sigSize); - p = QSpyRecord_getUint64(me, QSPY_conf.objPtrSize); - q = QSpyRecord_getUint64(me, QSPY_conf.funPtrSize); - r = QSpyRecord_getUint64(me, QSPY_conf.funPtrSize); - if (QSpyRecord_OK(me)) { - w = Dictionary_get(&QSPY_funDict, r, buf); - SNPRINTF_LINE("%010u ===>Tran " - "Obj=%s,Sig=%s,State=%s->%s", - t, - Dictionary_get(&QSPY_objDict, p, (char *)0), - SigDictionary_get(&QSPY_sigDict, a, p, (char *)0), - Dictionary_get(&QSPY_funDict, q, (char *)0), - w); - QSPY_onPrintLn(); - FPRINF_MATFILE("%d %u %u %"PRId64" %"PRId64" %"PRId64"\n", - (int)me->rec, t, a, p, q, r); -#ifdef QSPY_APP - if (QSEQ_isActive()) { - int obj = QSEQ_find(p); - if (obj >= 0) { - QSEQ_genTran(t, obj, w); - } - } -#endif - } - break; - } - case QS_QEP_IGNORED: { - t = QSpyRecord_getUint32(me, QSPY_conf.tstampSize); - a = QSpyRecord_getUint32(me, QSPY_conf.sigSize); - p = QSpyRecord_getUint64(me, QSPY_conf.objPtrSize); - q = QSpyRecord_getUint64(me, QSPY_conf.funPtrSize); - if (QSpyRecord_OK(me)) { - SNPRINTF_LINE("%010u =>Ignore Obj=%s,Sig=%s,State=%s", - t, - Dictionary_get(&QSPY_objDict, p, (char *)0), - SigDictionary_get(&QSPY_sigDict, a, p, (char *)0), - Dictionary_get(&QSPY_funDict, q, (char *)0)); - QSPY_onPrintLn(); - FPRINF_MATFILE("%d %u %u %"PRId64" %"PRId64"\n", - (int)me->rec, t, a, p, q); - } - break; - } - case QS_QEP_DISPATCH: { - t = QSpyRecord_getUint32(me, QSPY_conf.tstampSize); - a = QSpyRecord_getUint32(me, QSPY_conf.sigSize); - p = QSpyRecord_getUint64(me, QSPY_conf.objPtrSize); - q = QSpyRecord_getUint64(me, QSPY_conf.funPtrSize); - if (QSpyRecord_OK(me)) { - SNPRINTF_LINE("%010u Disp===> Obj=%s,Sig=%s,State=%s", - t, - Dictionary_get(&QSPY_objDict, p, (char *)0), - SigDictionary_get(&QSPY_sigDict, a, p, (char *)0), - Dictionary_get(&QSPY_funDict, q, (char *)0)); - QSPY_onPrintLn(); - FPRINF_MATFILE("%d %u %u %"PRId64" %"PRId64"\n", - (int)me->rec, t, a, p, q); - } - break; - } - case QS_QEP_UNHANDLED: { - a = QSpyRecord_getUint32(me, QSPY_conf.sigSize); - p = QSpyRecord_getUint64(me, QSPY_conf.objPtrSize); - q = QSpyRecord_getUint64(me, QSPY_conf.funPtrSize); - if (QSpyRecord_OK(me)) { - SNPRINTF_LINE("===RTC===> St-Unhnd Obj=%s,Sig=%s,State=%s", - Dictionary_get(&QSPY_objDict, p, (char *)0), - SigDictionary_get(&QSPY_sigDict, a, p, (char *)0), - Dictionary_get(&QSPY_funDict, q, (char *)0)); - QSPY_onPrintLn(); - FPRINF_MATFILE("%d %u %"PRId64" %"PRId64"\n", - (int)me->rec, a, p, q); - } - break; - } - - /* QF records ......................................................*/ - case QS_QF_ACTIVE_DEFER: - if (QSPY_conf.version >= 620U) { - s = "Defer"; - } - else { /* former QS_QF_ACTIVE_ADD */ - s = "Add "; - } - //lint -fallthrough - case QS_QF_ACTIVE_RECALL: { - if (QSPY_conf.version >= 620U) { - if (s == 0) s = "RCall"; - t = QSpyRecord_getUint32(me, QSPY_conf.tstampSize); - p = QSpyRecord_getUint64(me, QSPY_conf.objPtrSize); - q = QSpyRecord_getUint64(me, QSPY_conf.objPtrSize); - a = QSpyRecord_getUint32(me, QSPY_conf.sigSize); - b = QSpyRecord_getUint32(me, 1); - c = QSpyRecord_getUint32(me, 1); - if (QSpyRecord_OK(me)) { - SNPRINTF_LINE("%010u AO-%s Obj=%s,Que=%s," - "Evt", - t, - s, - Dictionary_get(&QSPY_objDict, p, (char *)0), - Dictionary_get(&QSPY_objDict, q, (char *)0), - SigDictionary_get(&QSPY_sigDict, a, p, (char *)0), - b, c); - QSPY_onPrintLn(); - FPRINF_MATFILE("%d %u %"PRId64" %"PRId64" %u %u %u\n", - (int)me->rec, t, p, q, a, b, c); -#ifdef QSPY_APP - if (QSEQ_isActive()) { - int obj = QSEQ_find(p); - if (obj >= 0) { - QSEQ_genAnnotation(t, obj, s); - } - } -#endif - } - } - else if (me->rec == QS_QF_ACTIVE_RECALL) { /* former... */ - /*... QS_QF_ACTIVE_REMOVE */ - if (s == 0) s = "Remov"; - t = QSpyRecord_getUint32(me, QSPY_conf.tstampSize); - p = QSpyRecord_getUint64(me, QSPY_conf.objPtrSize); - a = QSpyRecord_getUint32(me, 1); - if (QSpyRecord_OK(me)) { - SNPRINTF_LINE("%010u AO-%s Obj=%s,Pri=%u", - t, - s, - Dictionary_get(&QSPY_objDict, p, (char *)0), - a); - QSPY_onPrintLn(); - FPRINF_MATFILE("%d %u %"PRId64" %u\n", - (int)me->rec, t, p, a); - } - } - break; - } - case QS_QF_ACTIVE_RECALL_ATTEMPT: { - if (QSPY_conf.version >= 620U) { - t = QSpyRecord_getUint32(me, QSPY_conf.tstampSize); - p = QSpyRecord_getUint64(me, QSPY_conf.objPtrSize); - q = QSpyRecord_getUint64(me, QSPY_conf.objPtrSize); - if (QSpyRecord_OK(me)) { - SNPRINTF_LINE("%010u AO-RCllA Obj=%s,Que=%s", - t, - Dictionary_get(&QSPY_objDict, p, (char *)0), - Dictionary_get(&QSPY_objDict, q, (char *)0)); - QSPY_onPrintLn(); - FPRINF_MATFILE("%d %u %"PRId64" %"PRId64"\n", - (int)me->rec, t, p, q); -#ifdef QSPY_APP - if (QSEQ_isActive()) { - int obj = QSEQ_find(p); - if (obj >= 0) { - QSEQ_genAnnotation(t, obj, "RCallA"); - } - } -#endif - } - } - else { /* former QS_QF_EQUEUE_INIT */ - p = QSpyRecord_getUint64(me, QSPY_conf.objPtrSize); - b = QSpyRecord_getUint32(me, QSPY_conf.queueCtrSize); - if (QSpyRecord_OK(me)) { - SNPRINTF_LINE(" EQ-Init Obj=%s,Len=%u", - Dictionary_get(&QSPY_objDict, p, (char *)0), - b); - QSPY_onPrintLn(); - FPRINF_MATFILE("%d %"PRId64" %u\n", - (int)me->rec, p, b); - } - } - break; - } - - case QS_QF_ACTIVE_SUBSCRIBE: - s = "Subsc"; - //lint -fallthrough - case QS_QF_ACTIVE_UNSUBSCRIBE: { - if (s == 0) s = "Unsub"; - t = QSpyRecord_getUint32(me, QSPY_conf.tstampSize); - a = QSpyRecord_getUint32(me, QSPY_conf.sigSize); - p = QSpyRecord_getUint64(me, QSPY_conf.objPtrSize); - if (QSpyRecord_OK(me)) { - SNPRINTF_LINE("%010u AO-%s Obj=%s,Sig=%s", - t, - s, - Dictionary_get(&QSPY_objDict, p, (char *)0), - SigDictionary_get(&QSPY_sigDict, a, p, (char *)0)); - QSPY_onPrintLn(); - FPRINF_MATFILE("%d %u %u %"PRId64"\n", - (int)me->rec, t, a, p); - } - break; - } - case QS_QF_ACTIVE_POST: - s = "Post "; - //lint -fallthrough - case QS_QF_ACTIVE_POST_ATTEMPT: { - if (s == 0) s = "PostA"; - t = QSpyRecord_getUint32(me, QSPY_conf.tstampSize); - if (QSPY_conf.version >= 420U) { - q = QSpyRecord_getUint64(me, QSPY_conf.objPtrSize); - } - else { - q = 0U; - } - a = QSpyRecord_getUint32(me, QSPY_conf.sigSize); - p = QSpyRecord_getUint64(me, QSPY_conf.objPtrSize); - if (QSPY_conf.version >= 420U) { - b = QSpyRecord_getUint32(me, 1); - c = QSpyRecord_getUint32(me, 1); - } - else { - b = QSpyRecord_getUint32(me, 1); - c = b & 0x3F; - b >>= 6; - } - d = QSpyRecord_getUint32(me, QSPY_conf.queueCtrSize); - e = QSpyRecord_getUint32(me, QSPY_conf.queueCtrSize); - if (QSpyRecord_OK(me)) { - w = SigDictionary_get(&QSPY_sigDict, a, p, (char *)0); - SNPRINTF_LINE("%010u AO-%s Sdr=%s,Obj=%s," - "Evt," - "Que", - t, - s, - Dictionary_get(&QSPY_objDict, q, (char *)0), - Dictionary_get(&QSPY_objDict, p, buf), - w, - b, c, d, - (me->rec == QS_QF_ACTIVE_POST ? "Min" : "Mar"), - e); - QSPY_onPrintLn(); - FPRINF_MATFILE("%d %u %"PRId64" %u %"PRId64" %u %u %u %u\n", - (int)me->rec, t, q, a, p, b, c, d, e); -#ifdef QSPY_APP - if (QSEQ_isActive()) { - int src = QSEQ_find(q); - int dst = QSEQ_find(p); - QSEQ_genPost(t, src, dst, w, - (me->rec == QS_QF_ACTIVE_POST_ATTEMPT)); - } -#endif - } - break; - } - case QS_QF_ACTIVE_POST_LIFO: { - t = QSpyRecord_getUint32(me, QSPY_conf.tstampSize); - a = QSpyRecord_getUint32(me, QSPY_conf.sigSize); - p = QSpyRecord_getUint64(me, QSPY_conf.objPtrSize); - if (QSPY_conf.version >= 420U) { - b = QSpyRecord_getUint32(me, 1); - c = QSpyRecord_getUint32(me, 1); - } - else { - b = QSpyRecord_getUint32(me, 1); - c = b & 0x3F; - b >>= 6; - } - d = QSpyRecord_getUint32(me, QSPY_conf.queueCtrSize); - e = QSpyRecord_getUint32(me, QSPY_conf.queueCtrSize); - if (QSpyRecord_OK(me)) { - w = SigDictionary_get(&QSPY_sigDict, a, p, (char *)0); - SNPRINTF_LINE("%010u AO-LIFO Obj=%s," - "Evt," - "Que", - t, - Dictionary_get(&QSPY_objDict, p, (char *)0), - w, - b, c, d, e); - QSPY_onPrintLn(); - FPRINF_MATFILE("%d %u %u %"PRId64" %u %u %u %u\n", - (int)me->rec, t, a, p, b, c, d, e); -#ifdef QSPY_APP - if (QSEQ_isActive()) { - int src = QSEQ_find(p); - if (src >= 0) { - QSEQ_genPostLIFO(t, src, w); - } - } -#endif - } - break; - } - case QS_QF_ACTIVE_GET: - s = "AO-Get "; - //lint -fallthrough - case QS_QF_EQUEUE_GET: { - if (s == 0) s = "EQ-Get "; - t = QSpyRecord_getUint32(me, QSPY_conf.tstampSize); - a = QSpyRecord_getUint32(me, QSPY_conf.sigSize); - p = QSpyRecord_getUint64(me, QSPY_conf.objPtrSize); - if (QSPY_conf.version >= 420U) { - b = QSpyRecord_getUint32(me, 1); - c = QSpyRecord_getUint32(me, 1); - } - else { - b = QSpyRecord_getUint32(me, 1); - c = b & 0x3F; - b >>= 6; - } - d = QSpyRecord_getUint32(me, QSPY_conf.queueCtrSize); - if (QSpyRecord_OK(me)) { - SNPRINTF_LINE("%010u %s Obj=%s,Evt," - "Que", - t, - s, - Dictionary_get(&QSPY_objDict, p, (char *)0), - SigDictionary_get(&QSPY_sigDict, a, p, (char *)0), - b, c, d); - QSPY_onPrintLn(); - FPRINF_MATFILE("%d %u %u %"PRId64" %u %u %u\n", - (int)me->rec, t, a, p, b, c, d); - } - break; - } - case QS_QF_ACTIVE_GET_LAST: - s = "AO-GetL "; - //lint -fallthrough - case QS_QF_EQUEUE_GET_LAST: { - if (s == 0) s = "EQ-GetL "; - t = QSpyRecord_getUint32(me, QSPY_conf.tstampSize); - a = QSpyRecord_getUint32(me, QSPY_conf.sigSize); - p = QSpyRecord_getUint64(me, QSPY_conf.objPtrSize); - if (QSPY_conf.version >= 420U) { - b = QSpyRecord_getUint32(me, 1); - c = QSpyRecord_getUint32(me, 1); - } - else { - b = QSpyRecord_getUint32(me, 1); - c = b & 0x3F; - b >>= 6; - } - if (QSpyRecord_OK(me)) { - SNPRINTF_LINE("%010u %s Obj=%s,Evt", - t, - s, - Dictionary_get(&QSPY_objDict, p, (char *)0), - SigDictionary_get(&QSPY_sigDict, a, p, (char *)0), - b, c); - QSPY_onPrintLn(); - FPRINF_MATFILE("%d %u %u %"PRId64" %u %u\n", - (int)me->rec, t, a, p, b, c); - } - break; - } - - case QS_QF_EQUEUE_POST: - s = "Post "; - w = "Min"; - //lint -fallthrough - case QS_QF_EQUEUE_POST_ATTEMPT: - if (s == 0) s = "PostA"; - if (w == 0) w = "Mar"; - //lint -fallthrough - case QS_QF_EQUEUE_POST_LIFO: { - if (s == 0) s = "LIFO"; - if (w == 0) w = "Min"; - t = QSpyRecord_getUint32(me, QSPY_conf.tstampSize); - a = QSpyRecord_getUint32(me, QSPY_conf.sigSize); - p = QSpyRecord_getUint64(me, QSPY_conf.objPtrSize); - if (QSPY_conf.version >= 420U) { - b = QSpyRecord_getUint32(me, 1); - c = QSpyRecord_getUint32(me, 1); - } - else { - b = QSpyRecord_getUint32(me, 1); - c = b & 0x3F; - b >>= 6; - } - d = QSpyRecord_getUint32(me, QSPY_conf.queueCtrSize); - e = QSpyRecord_getUint32(me, QSPY_conf.queueCtrSize); - if (QSpyRecord_OK(me)) { - SNPRINTF_LINE("%010u EQ-%s Obj=%s," - "Evt," - "Que", - t, - s, - Dictionary_get(&QSPY_objDict, p, (char *)0), - SigDictionary_get(&QSPY_sigDict, a, p, (char *)0), - b, c, d, - w, - e); - QSPY_onPrintLn(); - FPRINF_MATFILE("%d %u %u %"PRId64" %u %u %u %u\n", - (int)me->rec, t, a, p, - b, c, d, e); - } - break; - } - - case QS_QF_MPOOL_GET: - s = "Get "; - w = "Min"; - //lint -fallthrough - case QS_QF_MPOOL_GET_ATTEMPT: { - if (s == 0) s = "GetA "; - if (w == 0) w = "Mar"; - t = QSpyRecord_getUint32(me, QSPY_conf.tstampSize); - p = QSpyRecord_getUint64(me, QSPY_conf.objPtrSize); - b = QSpyRecord_getUint32(me, QSPY_conf.poolCtrSize); - c = QSpyRecord_getUint32(me, QSPY_conf.poolCtrSize); - if (QSpyRecord_OK(me)) { - SNPRINTF_LINE("%010u MP-%s Obj=%s,Free=%u,%s=%u", - t, - s, - Dictionary_get(&QSPY_objDict, p, (char *)0), - b, - w, - c); - QSPY_onPrintLn(); - FPRINF_MATFILE("%d %u %"PRId64" %u %u\n", - (int)me->rec, t, p, b, c); - } - break; - } - case QS_QF_MPOOL_PUT: { - t = QSpyRecord_getUint32(me, QSPY_conf.tstampSize); - p = QSpyRecord_getUint64(me, QSPY_conf.objPtrSize); - b = QSpyRecord_getUint32(me, QSPY_conf.poolCtrSize); - if (QSpyRecord_OK(me)) { - SNPRINTF_LINE("%010u MP-Put Obj=%s,Free=%u", - t, - Dictionary_get(&QSPY_objDict, p, (char *)0), - b); - QSPY_onPrintLn(); - FPRINF_MATFILE("%d %u %"PRId64" %u\n", - (int)me->rec, t, p, b); - } - break; - } - - /* QF */ - case QS_QF_NEW_ATTEMPT: - s = "QF-NewA "; - //lint -fallthrough - case QS_QF_NEW: { - if (s == 0) s = "QF-New "; - t = QSpyRecord_getUint32(me, QSPY_conf.tstampSize); - a = QSpyRecord_getUint32(me, QSPY_conf.evtSize); - c = QSpyRecord_getUint32(me, QSPY_conf.sigSize); - if (QSpyRecord_OK(me)) { - SNPRINTF_LINE("%010u %s Sig=%s,Size=%u", - t, s, - SigDictionary_get(&QSPY_sigDict, c, 0, (char *)0), - a); - QSPY_onPrintLn(); - FPRINF_MATFILE("%d %u %u %u\n", - (int)me->rec, t, a, c); - } - break; - } - - case QS_QF_PUBLISH: { - t = QSpyRecord_getUint32(me, QSPY_conf.tstampSize); - if (QSPY_conf.version >= 420U) { - p = QSpyRecord_getUint64(me, QSPY_conf.objPtrSize); - a = QSpyRecord_getUint32(me, QSPY_conf.sigSize); - b = QSpyRecord_getUint32(me, 1); - c = QSpyRecord_getUint32(me, 1); - } - else { - p = 0U; - a = QSpyRecord_getUint32(me, QSPY_conf.sigSize); - b = QSpyRecord_getUint32(me, 1); - c = b & 0x3F; - b >>= 6; - } - if (QSpyRecord_OK(me)) { - w = SigDictionary_get(&QSPY_sigDict, a, 0, buf); - SNPRINTF_LINE("%010u QF-Pub Sdr=%s," - "Evt", - t, - Dictionary_get(&QSPY_objDict, p, (char *)0), - w, - b, c); - QSPY_onPrintLn(); - FPRINF_MATFILE("%d %u %"PRId64" %u %u\n", - (int)me->rec, t, p, a, b); -#ifdef QSPY_APP - if (QSEQ_isActive()) { - int obj = QSEQ_find(p); - QSEQ_genPublish(t, obj, w); - } -#endif - } - break; - } - - case QS_QF_NEW_REF: { - t = QSpyRecord_getUint32(me, QSPY_conf.tstampSize); - a = QSpyRecord_getUint32(me, QSPY_conf.sigSize); - b = QSpyRecord_getUint32(me, 1); - c = QSpyRecord_getUint32(me, 1); - if (QSpyRecord_OK(me)) { - SNPRINTF_LINE("%010u QF-NewRf Evt", - t, - SigDictionary_get(&QSPY_sigDict, a, 0, (char *)0), - b, c); - QSPY_onPrintLn(); - FPRINF_MATFILE("%d %u %u %u %u\n", - (int)me->rec, t, a, b, c); - } - break; - } - - case QS_QF_DELETE_REF: { - if (QSPY_conf.version >= 620U) { - t = QSpyRecord_getUint32(me, QSPY_conf.tstampSize); - a = QSpyRecord_getUint32(me, QSPY_conf.sigSize); - b = QSpyRecord_getUint32(me, 1); - c = QSpyRecord_getUint32(me, 1); - if (QSpyRecord_OK(me)) { - SNPRINTF_LINE("%010u QF-DelRf Evt", - t, - SigDictionary_get(&QSPY_sigDict, a, 0, (char *)0), - b, c); - QSPY_onPrintLn(); - FPRINF_MATFILE("%d %u %u %u %u\n", - (int)me->rec, t, a, b, c); - } - } - else { /* former QS_QF_TIMEEVT_CTR */ - t = QSpyRecord_getUint32(me, QSPY_conf.tstampSize); - p = QSpyRecord_getUint64(me, QSPY_conf.objPtrSize); - q = QSpyRecord_getUint64(me, QSPY_conf.objPtrSize); - c = QSpyRecord_getUint32(me, QSPY_conf.tevtCtrSize); - d = QSpyRecord_getUint32(me, QSPY_conf.tevtCtrSize); - if (QSPY_conf.version >= 500U) { - b = QSpyRecord_getUint32(me, 1); - } - else { - b = 0U; - } - if (QSpyRecord_OK(me)) { - SNPRINTF_LINE("%010u TE%1u-Ctr Obj=%s,AO=%s," - "Tim=%u,Int=%u", - t, - b, - Dictionary_get(&QSPY_objDict, p, (char *)0), - Dictionary_get(&QSPY_objDict, q, buf), - c, d); - QSPY_onPrintLn(); - FPRINF_MATFILE("%d %u %"PRId64" %"PRId64" %u %u\n", - (int)me->rec, t, p, q, c, d); - } - } - break; - } - - case QS_QF_GC_ATTEMPT: - s = "QF-gcA "; - //lint -fallthrough - case QS_QF_GC: { - if (s == 0) s = "QF-gc "; - t = QSpyRecord_getUint32(me, QSPY_conf.tstampSize); - a = QSpyRecord_getUint32(me, QSPY_conf.sigSize); - if (QSPY_conf.version >= 420U) { - b = QSpyRecord_getUint32(me, 1); - c = QSpyRecord_getUint32(me, 1); - } - else { - b = QSpyRecord_getUint32(me, 1); - c = b & 0x3F; - b >>= 6; - } - if (QSpyRecord_OK(me)) { - SNPRINTF_LINE("%010u %s Evt", - t, - s, - SigDictionary_get(&QSPY_sigDict, a, 0, (char *)0), - b, c); - QSPY_onPrintLn(); - FPRINF_MATFILE("%d %u %u %u %u\n", - (int)me->rec, t, a, b, c); - } - break; - } - case QS_QF_TICK: { - a = QSpyRecord_getUint32(me, QSPY_conf.tevtCtrSize); - if (QSPY_conf.version >= 500U) { - b = QSpyRecord_getUint32(me, 1); - } - else { - b = 0U; - } - if (QSpyRecord_OK(me)) { - SNPRINTF_LINE(" Tick<%1u> Ctr=%010u", - b, - a); - QSPY_onPrintLn(); - FPRINF_MATFILE("%d %u\n", (int)me->rec, a); -#ifdef QSPY_APP - if (QSEQ_isActive()) { - QSEQ_genTick(b, a); - } -#endif - } - break; - } - case QS_QF_TIMEEVT_ARM: - s = "Arm "; - //lint -fallthrough - case QS_QF_TIMEEVT_DISARM: { - if (s == 0) s = "Dis "; - t = QSpyRecord_getUint32(me, QSPY_conf.tstampSize); - p = QSpyRecord_getUint64(me, QSPY_conf.objPtrSize); - q = QSpyRecord_getUint64(me, QSPY_conf.objPtrSize); - c = QSpyRecord_getUint32(me, QSPY_conf.tevtCtrSize); - d = QSpyRecord_getUint32(me, QSPY_conf.tevtCtrSize); - if (QSPY_conf.version >= 500U) { - b = QSpyRecord_getUint32(me, 1); - } - else { - b = 0U; - } - if (QSpyRecord_OK(me)) { - SNPRINTF_LINE("%010u TE%1u-%s Obj=%s,AO=%s,Tim=%u,Int=%u", - t, - b, - s, - Dictionary_get(&QSPY_objDict, p, (char *)0), - Dictionary_get(&QSPY_objDict, q, buf), - c, d); - QSPY_onPrintLn(); - FPRINF_MATFILE("%d %u %"PRId64" %"PRId64" %u %u\n", - (int)me->rec, t, p, q, c, d); - } - break; - } - case QS_QF_TIMEEVT_AUTO_DISARM: { - p = QSpyRecord_getUint64(me, QSPY_conf.objPtrSize); - q = QSpyRecord_getUint64(me, QSPY_conf.objPtrSize); - if (QSPY_conf.version >= 500U) { - b = QSpyRecord_getUint32(me, 1); - } - else { - b = 0U; - } - if (QSpyRecord_OK(me)) { - SNPRINTF_LINE(" TE%1u-ADis Obj=%s,AO=%s", - b, - Dictionary_get(&QSPY_objDict, p, (char *)0), - Dictionary_get(&QSPY_objDict, q, buf)); - QSPY_onPrintLn(); - FPRINF_MATFILE("%d %"PRId64" %"PRId64"\n", - (int)me->rec, p, q); - } - break; - } - case QS_QF_TIMEEVT_DISARM_ATTEMPT: { - t = QSpyRecord_getUint32(me, QSPY_conf.tstampSize); - p = QSpyRecord_getUint64(me, QSPY_conf.objPtrSize); - q = QSpyRecord_getUint64(me, QSPY_conf.objPtrSize); - if (QSPY_conf.version >= 500U) { - b = QSpyRecord_getUint32(me, 1); - } - else { - b = 0U; - } - if (QSpyRecord_OK(me)) { - SNPRINTF_LINE("%010u TE%1u-DisA Obj=%s,AO=%s", - t, - b, - Dictionary_get(&QSPY_objDict, p, (char *)0), - Dictionary_get(&QSPY_objDict, q, buf)); - QSPY_onPrintLn(); - FPRINF_MATFILE("%d %u %"PRId64" %"PRId64"\n", - (int)me->rec, t, p, q); - } - break; - } - case QS_QF_TIMEEVT_REARM: { - t = QSpyRecord_getUint32(me, QSPY_conf.tstampSize); - p = QSpyRecord_getUint64(me, QSPY_conf.objPtrSize); - q = QSpyRecord_getUint64(me, QSPY_conf.objPtrSize); - c = QSpyRecord_getUint32(me, QSPY_conf.tevtCtrSize); - d = QSpyRecord_getUint32(me, QSPY_conf.tevtCtrSize); - e = QSpyRecord_getUint32(me, 1); - if (QSPY_conf.version >= 500U) { - b = QSpyRecord_getUint32(me, 1); - } - else { - b = 0U; - } - if (QSpyRecord_OK(me)) { - SNPRINTF_LINE("%010u TE%1u-Rarm Obj=%s,AO=%s," - "Tim=%u,Int=%u,Was=%1u", - t, - b, - Dictionary_get(&QSPY_objDict, p, (char *)0), - Dictionary_get(&QSPY_objDict, q, buf), - c, d, e); - QSPY_onPrintLn(); - FPRINF_MATFILE("%d %u %"PRId64" %"PRId64" %u %u %u\n", - (int)me->rec, t, p, q, c, d, e); - } - break; - } - case QS_QF_TIMEEVT_POST: { - t = QSpyRecord_getUint32(me, QSPY_conf.tstampSize); - p = QSpyRecord_getUint64(me, QSPY_conf.objPtrSize); - a = QSpyRecord_getUint32(me, QSPY_conf.sigSize); - q = QSpyRecord_getUint64(me, QSPY_conf.objPtrSize); - if (QSPY_conf.version >= 500U) { - b = QSpyRecord_getUint32(me, 1); - } - else { - b = 0U; - } - if (QSpyRecord_OK(me)) { - SNPRINTF_LINE("%010u TE%1u-Post Obj=%s,Sig=%s,AO=%s", - t, - b, - Dictionary_get(&QSPY_objDict, p, (char *)0), - SigDictionary_get(&QSPY_sigDict, a, q, (char *)0), - Dictionary_get(&QSPY_objDict, q, buf)); - QSPY_onPrintLn(); - FPRINF_MATFILE("%d %u %"PRId64" %u %"PRId64"\n", - (int)me->rec, t, p, a, q); - } - break; - } - case QS_QF_CRIT_ENTRY: - s = "QF-CritE"; - //lint -fallthrough - case QS_QF_CRIT_EXIT: { - if (s == 0) s = "QF-CritX"; - t = QSpyRecord_getUint32(me, QSPY_conf.tstampSize); - a = QSpyRecord_getUint32(me, 1); - if (QSpyRecord_OK(me)) { - SNPRINTF_LINE("%010u %s Nest=%d", - t, - s, - a); - QSPY_onPrintLn(); - FPRINF_MATFILE("%d %u %u\n", - (int)me->rec, t, a); - } - break; - } - case QS_QF_ISR_ENTRY: - s = "QF-IsrE"; - //lint -fallthrough - case QS_QF_ISR_EXIT: { - if (s == 0) s = "QF-IsrX"; - t = QSpyRecord_getUint32(me, QSPY_conf.tstampSize); - a = QSpyRecord_getUint32(me, 1); - b = QSpyRecord_getUint32(me, 1); - if (QSpyRecord_OK(me)) { - SNPRINTF_LINE("%010u %s Nest=%u,Pri=%u", - t, - s, - a, b); - QSPY_onPrintLn(); - FPRINF_MATFILE("%d %u %u %u\n", - (int)me->rec, t, a, b); - } - break; - } - - /* scheduler records ...............................................*/ - case QS_SCHED_PREEMPT: - if (QSPY_conf.version < 710U) { - /* old QS_MUTEX_LOCK */ - if (s == 0) s = "Mtx-Lock"; - } - else { - if (s == 0) s = "Sch-Pre "; - } - //lint -fallthrough - case QS_SCHED_RESTORE: { - t = QSpyRecord_getUint32(me, QSPY_conf.tstampSize); - a = QSpyRecord_getUint32(me, 1); - b = QSpyRecord_getUint32(me, 1); - if (QSpyRecord_OK(me)) { - if (QSPY_conf.version < 710U) { - /* old QS_MUTEX_UNLOCK */ - if (s == 0) s = "Mtx-Unlk"; - SNPRINTF_LINE("%010u %s Pro=%u,Ceil=%u", - t, s, a, b); - QSPY_onPrintLn(); - FPRINF_MATFILE("%d %u %u %u\n", - (int)me->rec, t, a, b); - } - else { - if (s == 0) s = "Sch-Rest"; - SNPRINTF_LINE("%010u %s Pri=%u->%u", - t, s, b, a); - QSPY_onPrintLn(); - FPRINF_MATFILE("%d %u %u %u\n", - (int)me->rec, t, b, a); - } - } - break; - } - - case QS_SCHED_LOCK: - if (s == 0) s = "Sch-Lock"; - //lint -fallthrough - case QS_SCHED_UNLOCK: { - if (s == 0) s = "Sch-Unlk"; - t = QSpyRecord_getUint32(me, QSPY_conf.tstampSize); - a = QSpyRecord_getUint32(me, 1); - b = QSpyRecord_getUint32(me, 1); - if (QSpyRecord_OK(me)) { - SNPRINTF_LINE("%010u %s Ceil=%u->%u", - t, - s, - a, b); - QSPY_onPrintLn(); - FPRINF_MATFILE("%d %u %u %u\n", - (int)me->rec, t, a, b); - } - break; - } - case QS_SCHED_NEXT: { - t = QSpyRecord_getUint32(me, QSPY_conf.tstampSize); - a = QSpyRecord_getUint32(me, 1); - b = QSpyRecord_getUint32(me, 1); - if (QSpyRecord_OK(me)) { - SNPRINTF_LINE("%010u Sch-Next Pri=%u->%u", - t, b, a); - QSPY_onPrintLn(); - FPRINF_MATFILE("%d %u %u %u\n", - (int)me->rec, t, a, b); - } - break; - } - case QS_SCHED_IDLE: { - t = QSpyRecord_getUint32(me, QSPY_conf.tstampSize); - a = QSpyRecord_getUint32(me, 1); - if (QSpyRecord_OK(me)) { - SNPRINTF_LINE("%010u Sch-Idle Pri=%u->0", - t, a); - QSPY_onPrintLn(); - FPRINF_MATFILE("%d %u %u\n", - (int)me->rec, t, a); - } - break; - } - - /* enum dictionary .................................................*/ - case QS_ENUM_DICT: { - a = QSpyRecord_getUint32(me, 1); - b = QSpyRecord_getUint32(me, 1) & 0x7U; - s = QSpyRecord_getStr(me); - if (QSpyRecord_OK(me)) { - Dictionary_put(&QSPY_enumDict[b], a, s); - SNPRINTF_LINE(" Enum-Dic %03d,Grp=%1d->%s", - a, b, s); - QSPY_onPrintLn(); - } - break; - } - - /* Miscellaneous built-in QS records ...............................*/ - case QS_TEST_PAUSED: { - if (QSpyRecord_OK(me)) { - SNPRINTF_LINE(" %s", "TstPause"); - QSPY_onPrintLn(); - } - break; - } - - case QS_TEST_PROBE_GET: { - t = QSpyRecord_getUint32(me, QSPY_conf.tstampSize); - q = QSpyRecord_getUint64(me, QSPY_conf.funPtrSize); - a = QSpyRecord_getUint32(me, 4U); - if (QSpyRecord_OK(me)) { - SNPRINTF_LINE("%010u TstProbe Fun=%s,Data=%d", - t, Dictionary_get(&QSPY_funDict, - q, (char *)0), a); - QSPY_onPrintLn(); - } - break; - } - - case QS_SIG_DICT: { - a = QSpyRecord_getUint32(me, QSPY_conf.sigSize); - p = QSpyRecord_getUint64(me, QSPY_conf.objPtrSize); - s = QSpyRecord_getStr(me); - if (QSpyRecord_OK(me)) { - SigDictionary_put(&QSPY_sigDict, (SigType)a, p, s); - if (QSPY_conf.objPtrSize <= 4) { - SNPRINTF_LINE(" Sig-Dict %08d," - "Obj=0x%08X->%s", - a, (unsigned)p, s); - } - else { - SNPRINTF_LINE(" Sig-Dict %08d," - "Obj=0x%016"PRIX64"->%s", - a, p, s); - } - QSPY_onPrintLn(); - FPRINF_MATFILE("%d %s=[%u %"PRId64"];\n", - (int)me->rec, QSPY_getMatDict(s), a, p); - } - break; - } - - case QS_OBJ_DICT: { - p = QSpyRecord_getUint64(me, QSPY_conf.objPtrSize); - s = QSpyRecord_getStr(me); - - /* for backward compatibility replace the '['/']' with '<'/'>' */ - if (QSPY_conf.version < 690U) { - char *ps; - for (ps = (char *)s; *ps != '\0'; ++ps) { - if (*ps == '[') { - *ps = '<'; - } - else if (*ps == ']') { - *ps = '>'; - } - } - } - if (QSpyRecord_OK(me)) { - Dictionary_put(&QSPY_objDict, p, s); - if (QSPY_conf.objPtrSize <= 4) { - SNPRINTF_LINE(" Obj-Dict 0x%08X->%s", - (unsigned)p, s); - } - else { - SNPRINTF_LINE(" Obj-Dict 0x%016"PRIX64"->%s", - p, s); - } - QSPY_onPrintLn(); - FPRINF_MATFILE("%d %s=%"PRId64";\n", - (int)me->rec, QSPY_getMatDict(s), p); -#ifdef QSPY_APP - /* if needed, update the object in the Sequence dictionary */ - QSEQ_updateDictionary(s, p); -#endif - } - break; - } - - case QS_FUN_DICT: { - p = QSpyRecord_getUint64(me, QSPY_conf.funPtrSize); - s = QSpyRecord_getStr(me); - if (QSpyRecord_OK(me)) { - Dictionary_put(&QSPY_funDict, p, s); - if (QSPY_conf.funPtrSize <= 4) { - SNPRINTF_LINE(" Fun-Dict 0x%08X->%s", - (unsigned)p, s); - } - else { - SNPRINTF_LINE(" Fun-Dict 0x%016"PRIX64"->%s", - p, s); - } - QSPY_onPrintLn(); - FPRINF_MATFILE("%d %s=%"PRId64";\n", - (int)me->rec, QSPY_getMatDict(s), p); - } - break; - } - - case QS_USR_DICT: { - a = QSpyRecord_getUint32(me, 1); - s = QSpyRecord_getStr(me); - if (QSpyRecord_OK(me)) { - Dictionary_put(&QSPY_usrDict, a, s); - SNPRINTF_LINE(" Usr-Dict %08d->%s", - a, s); - QSPY_onPrintLn(); - } - break; - } - - case QS_TARGET_INFO: { - a = QSpyRecord_getUint32(me, 1); - b = QSpyRecord_getUint32(me, 2); - - /* extract the data bytes... */ - for (e = 0U; e < 13U; ++e) { - buf[e] = (char)QSpyRecord_getUint32(me, 1); - } - - if (QSpyRecord_OK(me)) { - s = (a != 0U) ? "Trg-RST " : "Trg-Info"; - - /* save the year-part of the timestamp - * NOTE: (year-part == 0) means that we don't have target info - */ - c = QSPY_conf.tstamp[5]; - - /* apply the target info... - * find differences from the current config and store in 'd' - */ - d = 0U; /* assume no difference in the target info */ - CONFIG_UPDATE(version , (uint16_t)(b & 0x7FFFU), d); - CONFIG_UPDATE(endianness, (uint8_t)((b >> 15) & 0x01U), d); - CONFIG_UPDATE(objPtrSize, (uint8_t)(buf[3] & 0xFU), d); - CONFIG_UPDATE(funPtrSize, (uint8_t)((buf[3] >> 4) & 0xFU),d); - CONFIG_UPDATE(tstampSize, (uint8_t)(buf[4] & 0xFU), d); - CONFIG_UPDATE(sigSize, (uint8_t)(buf[0] & 0xFU), d); - CONFIG_UPDATE(evtSize, (uint8_t)((buf[0] >> 4) & 0xFU),d); - CONFIG_UPDATE(queueCtrSize,(uint8_t)(buf[1] & 0x0FU), d); - CONFIG_UPDATE(poolCtrSize, (uint8_t)((buf[2] >> 4) & 0xFU),d); - CONFIG_UPDATE(poolBlkSize, (uint8_t)(buf[2] & 0xFU), d); - CONFIG_UPDATE(tevtCtrSize, (uint8_t)((buf[1] >> 4) & 0xFU),d); - - /* update the user record offset */ - l_userRec = ((QSPY_conf.version < 660U) - ? OLD_QS_USER : QS_USER); - - for (e = 0U; e < sizeof(QSPY_conf.tstamp); ++e) { - CONFIG_UPDATE(tstamp[e], (uint8_t)buf[7U + e], d); - } - - SNPRINTF_LINE(" %s QP-Ver=%u," - "Build=%02u%02u%02u_%02u%02u%02u", - s, - b, - (unsigned)QSPY_conf.tstamp[5], - (unsigned)QSPY_conf.tstamp[4], - (unsigned)QSPY_conf.tstamp[3], - (unsigned)QSPY_conf.tstamp[2], - (unsigned)QSPY_conf.tstamp[1], - (unsigned)QSPY_conf.tstamp[0]); - QSPY_onPrintLn(); - - /* any difference in configuration found - * and this is not the first target info? - */ - if ((d != 0U) && (c != 0U)) { - SNPRINTF_LINE(" %s", - "Target info mismatch " - "(dictionaries discarded)"); - QSPY_printInfo(); - QSPY_resetAllDictionaries(); - } - - if (a != 0U) { /* is this also Target RESET? */ - - /* always reset dictionaries upon target reset */ - QSPY_resetAllDictionaries(); - - /* reset the QSPY-Tx channel, if available */ - if (l_txResetFun != (QSPY_resetFun)0) { - (*l_txResetFun)(); - } - /*TBD: close and re-open MATLAB, Sequence file, etc. */ - } - -#ifdef QSPY_APP - /* should external dictionaries be used (-d option)? */ - if (QDIC_isActive()) { - QSPY_readDict(); - } -#endif - } - break; - } - - case QS_TARGET_DONE: { - t = QSpyRecord_getUint32(me, QSPY_conf.tstampSize); - a = QSpyRecord_getUint32(me, 1U); - if (QSpyRecord_OK(me)) { - if (a < sizeof(l_qs_rx_rec)/sizeof(l_qs_rx_rec[0])) { - SNPRINTF_LINE("%010u Trg-Done %s", - t, l_qs_rx_rec[a]); - } - else { - SNPRINTF_LINE("%010u Trg-Done %d", - t, a); - } - QSPY_onPrintLn(); - } - break; - } - - case QS_RX_STATUS: { - if (QSPY_conf.version >= 580U) { - } - else { - t = QSpyRecord_getUint32(me, QSPY_conf.tstampSize); - } - a = QSpyRecord_getUint32(me, 1U); - QSPY_output.rx_status = (int)a; - if (QSpyRecord_OK(me)) { - if (a < 128U) { /* Ack? */ - if (a < sizeof(l_qs_rx_rec)/sizeof(l_qs_rx_rec[0])) { - SNPRINTF_LINE(" Trg-Ack %s", - l_qs_rx_rec[a]); - } - else { - SNPRINTF_LINE(" Trg-Ack %d", a); - } - } - else { - a &= 0x7FU; - if (a < sizeof(l_qs_rx_rec)/sizeof(l_qs_rx_rec[0])) { - SNPRINTF_LINE(" Trg-ERR %s", - l_qs_rx_rec[a]); - } - else { - SNPRINTF_LINE(" Trg-ERR 0x%02X", a); - } - } - QSPY_onPrintLn(); - } - break; - } - - case QS_QUERY_DATA: { - t = QSpyRecord_getUint32(me, QSPY_conf.tstampSize); - a = QSpyRecord_getUint32(me, 1U); - b = 0; - c = 0; - d = 0; - e = 0; - p = QSpyRecord_getUint64(me, QSPY_conf.objPtrSize); - q = 0; - switch (a) { - case SM_OBJ: - q = QSpyRecord_getUint64(me, QSPY_conf.funPtrSize); - break; - case MP_OBJ: - b = QSpyRecord_getUint32(me, QSPY_conf.poolCtrSize); - c = QSpyRecord_getUint32(me, QSPY_conf.poolCtrSize); - break; - case EQ_OBJ: - b = QSpyRecord_getUint32(me, QSPY_conf.queueCtrSize); - c = QSpyRecord_getUint32(me, QSPY_conf.queueCtrSize); - break; - case TE_OBJ: - q = QSpyRecord_getUint64(me, QSPY_conf.objPtrSize); - b = QSpyRecord_getUint32(me, QSPY_conf.tevtCtrSize); - c = QSpyRecord_getUint32(me, QSPY_conf.tevtCtrSize); - d = QSpyRecord_getUint32(me, QSPY_conf.sigSize); - e = QSpyRecord_getUint32(me, 1); - break; - case AP_OBJ: - break; - default: - break; - } - if (QSPY_conf.version < 690U) { - switch (a) { - case AO_OBJ: - b = QSpyRecord_getUint32(me, QSPY_conf.queueCtrSize); - c = QSpyRecord_getUint32(me, QSPY_conf.queueCtrSize); - break; - } - } - else { - switch (a) { - case AO_OBJ: - q = QSpyRecord_getUint64(me, QSPY_conf.funPtrSize); - break; - } - } - if (QSpyRecord_OK(me)) { - SNPRINTF_LINE("%010u Query-%s Obj=%s", - t, - l_qs_obj[a], - Dictionary_get(&QSPY_objDict, p, (char *)0)); - switch (a) { - case SM_OBJ: - SNPRINTF_APPEND(",State=%s", - Dictionary_get(&QSPY_funDict, q, (char *)0)); - break; - case MP_OBJ: - SNPRINTF_APPEND(",Free=%u,Min=%u", - b, c); - break; - case EQ_OBJ: - SNPRINTF_APPEND(",Que", - b, c); - break; - case TE_OBJ: - SNPRINTF_APPEND( - ",Rate=%u,Sig=%s,Tim=%u,Int=%u,Flags=0x%02X", - (e & 0x0FU), - SigDictionary_get(&QSPY_sigDict, d, q, (char *)0), - b, c, - (e & 0xF0U)); - break; - case AP_OBJ: - break; - default: - break; - } - if (QSPY_conf.version < 690U) { - switch (a) { - case AO_OBJ: - SNPRINTF_APPEND(",Que", - b, c); - break; - } - } - else { - switch (a) { - case AO_OBJ: - SNPRINTF_APPEND(",State=%s", - Dictionary_get(&QSPY_funDict, q, (char *)0)); - break; - } - } - QSPY_onPrintLn(); - } - break; - } - - case QS_PEEK_DATA: { - t = QSpyRecord_getUint32(me, QSPY_conf.tstampSize); - a = QSpyRecord_getUint32(me, 2); /* offset */ - b = QSpyRecord_getUint32(me, 1); /* data size */ - w = (char const *)QSpyRecord_getMem(me, (uint8_t)b, &c); - if (QSpyRecord_OK(me) && w) { - SNPRINTF_LINE("%010u Trg-Peek Offs=%d,Size=%d,Num=%d,Data=<", - t, a, b, c); - for (; c > 1U; --c, w += b) { - switch (b) { - case 1: - SNPRINTF_APPEND("%02X,", (int)(*w & 0xFFU)); - break; - case 2: - SNPRINTF_APPEND("%04X,", - (int)(*(uint16_t *)w & 0xFFFFU)); - break; - case 4: - SNPRINTF_APPEND("%08X,", (int)(*(uint32_t *)w)); - break; - } - } - switch (b) { - case 1: - SNPRINTF_APPEND("%02X>", (int)(*w & 0xFFU)); - break; - case 2: - SNPRINTF_APPEND("%04X>", - (int)(*(uint16_t *)w & 0xFFFFU)); - break; - case 4: - SNPRINTF_APPEND("%08X>", (int)(*(uint32_t *)w)); - break; - } - QSPY_onPrintLn(); - } - break; - } - - case QS_ASSERT_FAIL: { - t = QSpyRecord_getUint32(me, QSPY_conf.tstampSize); - a = QSpyRecord_getUint32(me, 2); - s = QSpyRecord_getStr(me); - if (QSpyRecord_OK(me)) { - SNPRINTF_LINE("%010u =ASSERT= Mod=%s,Loc=%u", - t, s, a); - QSPY_onPrintLn(); - FPRINF_MATFILE("%d %u %u %s\n", - (int)me->rec, (unsigned)t, (unsigned)a, s); - } - break; - } - - case QS_QF_RUN: { - if (QSpyRecord_OK(me)) { - SNPRINTF_LINE(" %s", "QF_RUN"); - QSPY_onPrintLn(); -#ifdef QSPY_APP - if (QDIC_isActive()) { - QSPY_writeDict(); - } -#endif - } - break; - } - - /* Semaphore records ...............................................*/ - case QS_SEM_TAKE: - if (s == 0) s = "Sem-Take"; - //lint -fallthrough - case QS_SEM_BLOCK: - if (s == 0) s = "Sem-Blk "; - //lint -fallthrough - case QS_SEM_SIGNAL: - if (s == 0) s = "Sem-Sgnl"; - //lint -fallthrough - case QS_SEM_BLOCK_ATTEMPT: { - if (s == 0) s = "Sem-BlkA"; - t = QSpyRecord_getUint32(me, QSPY_conf.tstampSize); - p = QSpyRecord_getUint64(me, QSPY_conf.objPtrSize); - a = QSpyRecord_getUint32(me, 1); - b = QSpyRecord_getUint32(me, 1); - if (QSpyRecord_OK(me)) { - SNPRINTF_LINE("%010u %s %s,Thr=%u,Cnt=%u", - t, - s, - Dictionary_get(&QSPY_objDict, p, (char *)0), - a, b); - QSPY_onPrintLn(); - FPRINF_MATFILE("%d %u %"PRId64" %u %u\n", - (int)me->rec, (unsigned)t, p, a, b); - } - break; - } - - /* Mutex records ...............................................*/ - case QS_MTX_LOCK: - if (s == 0) s = "Mtx-Lock"; - //lint -fallthrough - case QS_MTX_UNLOCK: - if (s == 0) s = "Mtx-Unlk"; - //lint -fallthrough - case QS_MTX_LOCK_ATTEMPT: - if (s == 0) s = "Mtx-LckA"; - //lint -fallthrough - case QS_MTX_UNLOCK_ATTEMPT: { - if (s == 0) s = "Mtx-UlkA"; - t = QSpyRecord_getUint32(me, QSPY_conf.tstampSize); - p = QSpyRecord_getUint64(me, QSPY_conf.objPtrSize); - a = QSpyRecord_getUint32(me, 1); - b = QSpyRecord_getUint32(me, 1); - if (QSpyRecord_OK(me)) { - SNPRINTF_LINE("%010u %s %s,Hldr=%u,Nest=%u", - t, - s, - Dictionary_get(&QSPY_objDict, p, (char *)0), - a, b); - QSPY_onPrintLn(); - FPRINF_MATFILE("%d %u %"PRId64" %u %u\n", - (int)me->rec, (unsigned)t, p, a, b); - } - break; - } - case QS_MTX_BLOCK: - if (s == 0) s = "Mtx-Blk "; - //lint -fallthrough - case QS_MTX_BLOCK_ATTEMPT: { - if (s == 0) s = "Mtx-BlkA"; - t = QSpyRecord_getUint32(me, QSPY_conf.tstampSize); - p = QSpyRecord_getUint64(me, QSPY_conf.objPtrSize); - a = QSpyRecord_getUint32(me, 1); - b = QSpyRecord_getUint32(me, 1); - if (QSpyRecord_OK(me)) { - SNPRINTF_LINE("%010u %s %s,Hldr=%u,Thr=%u", - t, - s, - Dictionary_get(&QSPY_objDict, p, (char *)0), - a, b); - QSPY_onPrintLn(); - FPRINF_MATFILE("%d %u %"PRId64" %u %u\n", - (int)me->rec, (unsigned)t, p, a, b); - } - break; - } - - - /* Unknown records .................................................*/ - /* NOTE: the Application-Specific records have been already - * sifted out in QSPY_parse() - */ - default: { - SNPRINTF_LINE(" Unknown Rec=%d,Len=%d", - (int)me->rec, (int)me->len); - QSPY_onPrintLn(); - break; - } - } -} -/*..........................................................................*/ -void QSPY_printInfo(void) { - QSPY_output.type = INF_OUT; /* this is an internal info message */ - QSPY_onPrintLn(); -} -/*..........................................................................*/ -void QSPY_printError(void) { - QSPY_output.type = ERR_OUT; /* this is an error message */ - QSPY_onPrintLn(); -} - -/*==========================================================================*/ -static uint8_t l_record[QS_RECORD_SIZE_MAX]; -static uint8_t *l_pos = l_record; /* position within the record */ -static uint8_t l_chksum = 0U; -static uint8_t l_esc = 0U; -static uint8_t l_seq = 0U; - -/*..........................................................................*/ -void QSPY_reset(void) { - l_pos = l_record; /* position within the record */ - l_chksum = 0U; - l_esc = 0U; - l_seq = 0U; -} -/*..........................................................................*/ -void QSPY_parse(uint8_t const *buf, uint32_t nBytes) { - static bool isJustStarted = true; - - for (; nBytes != 0U; --nBytes) { - uint8_t b = *buf++; - - if (l_esc) { /* escaped byte arrived? */ - l_esc = 0U; - b ^= QS_ESC_XOR; - - l_chksum = (uint8_t)(l_chksum + b); - if (l_pos < &l_record[sizeof(l_record)]) { - *l_pos++ = b; - } - else { - SNPRINTF_LINE(" ERROR Record too long at " - "Seq=%u(?),", (unsigned)l_seq); - /* is it a standard QS record? */ - if (l_record[1] < l_userRec) { - SNPRINTF_APPEND("Rec=%s(?)", - l_recRender[l_record[1]].name); - } - else { /* this is a USER-specific record */ - SNPRINTF_APPEND("Rec=USER+%u(?)", - (unsigned)(l_record[1] - l_userRec)); - } - QSPY_printError(); - l_chksum = 0U; - l_pos = l_record; - l_esc = 0U; - } - } - else if (b == QS_ESC) { /* transparent byte? */ - l_esc = 1U; - } - else if (b == QS_FRAME) { /* frame byte? */ - if (l_chksum != QS_GOOD_CHKSUM) { /* bad checksum? */ - if (!isJustStarted) { - SNPRINTF_LINE(" ERROR %s", - "Bad checksum in "); - if (l_record[1] < l_userRec) { - SNPRINTF_APPEND("Rec=%s(?),", - l_recRender[l_record[1]].name); - } - else { - SNPRINTF_APPEND("Rec=USER+%u(?),", - (unsigned)(l_record[1] - l_userRec)); - } - SNPRINTF_APPEND("Seq=%u", (unsigned)l_seq); - QSPY_printError(); - } - } - else if (l_pos < &l_record[3]) { /* record too short? */ - SNPRINTF_LINE(" ERROR Record too short at " - "Seq=%u(?),", - (unsigned)l_seq); - if (l_record[1] < l_userRec) { - SNPRINTF_APPEND("Rec=%s", l_recRender[l_record[1]].name); - } - else { - SNPRINTF_APPEND("Rec=USER+%u(?)", - (unsigned)(l_record[1] - l_userRec)); - } - QSPY_printError(); - } - else { /* a healthy record received */ - QSpyRecord qrec; - int parse = 1; - ++l_seq; /* increment with natural wrap-around */ - - if (!isJustStarted) { - /* data discontinuity found? - * but not for the QS_EMPTY record? - */ - if ((l_seq != l_record[0]) - && (l_record[1] != QS_EMPTY)) - { - SNPRINTF_LINE(" ERROR Discontinuity " - "Seq=%u->%u", - (unsigned)(l_seq - 1), (unsigned)l_record[0]); - QSPY_printError(); - } - } - else { - isJustStarted = false; - } - l_seq = l_record[0]; - - QSpyRecord_init(&qrec, l_record, (int32_t)(l_pos - l_record)); - - if (l_custParseFun != (QSPY_CustParseFun)0) { - parse = (*l_custParseFun)(&qrec); - if (parse) { - /* re-initialize the record for parsing again */ - QSpyRecord_init(&qrec, - l_record, (int32_t)(l_pos - l_record)); - } - } - if (parse) { - if (qrec.rec < l_userRec) { - QSpyRecord_process(&qrec); - } - else { - QSpyRecord_processUser(&qrec); - } - } - } - - /* get ready for the next record ... */ - l_chksum = 0U; - l_pos = l_record; - l_esc = 0U; - } - else { /* a regular un-escaped byte */ - l_chksum = (uint8_t)(l_chksum + b); - if (l_pos < &l_record[sizeof(l_record)]) { - *l_pos++ = b; - } - else { - SNPRINTF_LINE(" ERROR Record too long at " - "Seq=%3u,", - (unsigned)l_seq); - if (l_record[1] < l_userRec) { - SNPRINTF_APPEND("Rec=%s", l_recRender[l_record[1]].name); - } - else { - SNPRINTF_APPEND("Rec=USER+%3u", - (unsigned)(l_record[1] - l_userRec)); - } - QSPY_printError(); - l_chksum = 0U; - l_pos = l_record; - l_esc = 0U; - } - } - } -} - -/*..........................................................................*/ -void QSPY_resetAllDictionaries(void) { - Dictionary_reset(&QSPY_funDict); - Dictionary_reset(&QSPY_objDict); - Dictionary_reset(&QSPY_usrDict); - SigDictionary_reset(&QSPY_sigDict); - -#ifdef QSPY_APP - QSEQ_dictionaryReset(); - /* find out if NULL needs to be added to the Sequence dictionary... */ - QSEQ_updateDictionary("NULL", 0); -#endif - - /* pre-fill known user entries */ - Dictionary_put(&QSPY_usrDict, 124, "QUTEST_ON_POST"); -} -/*..........................................................................*/ -SigType QSPY_findSig(char const* name, ObjType obj) { - return SigDictionary_findSig(&QSPY_sigDict, name, obj); -} -/*..........................................................................*/ -KeyType QSPY_findObj(char const* name) { - return Dictionary_findKey(&QSPY_objDict, name); -} -/*..........................................................................*/ -KeyType QSPY_findFun(char const* name) { - return Dictionary_findKey(&QSPY_funDict, name); -} -/*..........................................................................*/ -KeyType QSPY_findUsr(char const* name) { - return Dictionary_findKey(&QSPY_usrDict, name); -} -/*..........................................................................*/ -KeyType QSPY_findEnum(char const *name, uint8_t group) { - Q_ASSERT(group < sizeof(QSPY_enumDict)/sizeof(QSPY_enumDict[0])); - return Dictionary_findKey(&QSPY_enumDict[group], name); -} -/*..........................................................................*/ -QSRreRecGroup QSPY_getGroup(int recId) { - return recId < QS_USER - ? l_recRender[recId].group - : GRP_USR; -} - -/* Dictionary class ========================================================*/ -int Dictionary_comp(void const *arg1, void const *arg2) { - KeyType key1 = ((DictEntry const *)arg1)->key; - KeyType key2 = ((DictEntry const *)arg2)->key; - if (key1 > key2) { - return 1; - } - else if (key1 < key2) { - return -1; - } - else { - return 0; - } -} - -/*..........................................................................*/ -void Dictionary_ctor(Dictionary * const me, - DictEntry *sto, uint32_t capacity) -{ - me->sto = sto; - me->capacity = capacity; - me->entries = 0; - me->keySize = 4; -} -/*..........................................................................*/ - void Dictionary_config(Dictionary * const me, int keySize) { - me->keySize = keySize; -} -/*..........................................................................*/ -char const *Dictionary_at(Dictionary * const me, unsigned idx) { - if (idx < (unsigned)me->entries) { - return me->sto[idx].name; - } - else { - return ""; - } -} -/*..........................................................................*/ -void Dictionary_put(Dictionary * const me, - KeyType key, char const *name) -{ - int idx = Dictionary_find(me, key); - int n = me->entries; - char *dst; - if (idx >= 0) { /* the key found? */ - Q_ASSERT((idx <= n) || (n == 0)); - dst = me->sto[idx].name; - STRNCPY_S(dst, sizeof(me->sto[idx].name), name); - dst[sizeof(me->sto[idx].name) - 1] = '\0'; /* zero-terminate */ - } - else if (n < me->capacity - 1) { - me->sto[n].key = key; - dst = me->sto[n].name; - STRNCPY_S(dst, sizeof(me->sto[n].name), name); - dst[sizeof(me->sto[idx].name) - 1] = '\0'; /* zero-terminate */ - ++me->entries; - /* keep the entries sorted by the key */ - qsort(me->sto, (uint32_t)me->entries, sizeof(me->sto[0]), - &Dictionary_comp); - } -} -/*..........................................................................*/ -char const *Dictionary_get(Dictionary * const me, KeyType key, char *buf) { - int idx; - if ((key == 0U) && (me->keySize >= 4)) { - return "NULL"; - } - idx = Dictionary_find(me, key); - if (idx >= 0) { /* key found? */ - return me->sto[idx].name; - } - else { /* key not found */ - if (buf == 0) { /* extra buffer not provided? */ - buf = me->notFound.name; /* use the internal location */ - } - /* otherwise use the provided buffer... */ - if (me->keySize <= 1) { - SNPRINTF_S(buf, QS_DNAME_LEN_MAX, "%03d", (unsigned)key); - } - else if (me->keySize <= 4) { - SNPRINTF_S(buf, QS_DNAME_LEN_MAX, "0x%08X", (unsigned)key); - } - else { - SNPRINTF_S(buf, QS_DNAME_LEN_MAX, "0x%016"PRIX64"", key); - } - //Dictionary_put(me, key, buf); /* put into the dictionary */ - return buf; - } -} -/*..........................................................................*/ -int Dictionary_find(Dictionary * const me, KeyType key) { - /* binary search algorithm... */ - int first = 0; - int last = me->entries; - if (last > 0) { /* not empty? */ - while (first <= last) { - int mid = (first + last) / 2; - if (me->sto[mid].key == key) { - return mid; - } - if (me->sto[mid].key > key) { - last = mid - 1; - } - else { - first = mid + 1; - } - } - } - return -1; /* entry not found */ -} -/*..........................................................................*/ -KeyType Dictionary_findKey(Dictionary * const me, char const *name) { - /* brute-force search algorithm... */ - for (int i = 0; i < me->entries; ++i) { - if (strncmp(me->sto[i].name, name, sizeof(me->sto[i].name)) == 0) { - return me->sto[i].key; - } - } - return KEY_NOT_FOUND; -} -/*..........................................................................*/ -void Dictionary_reset(Dictionary * const me) { - for (int i = 0; i < me->capacity; ++i) { - me->sto[i].key = (KeyType)0; - } - me->entries = 0; -} - -/* SigDictionary class =====================================================*/ -static int SigDictionary_comp(void const *arg1, void const *arg2) { - SigType sig1 = ((SigDictEntry const *)arg1)->sig; - SigType sig2 = ((SigDictEntry const *)arg2)->sig; - if (sig1 > sig2) { - return 1; - } - else if (sig1 < sig2) { - return -1; - } - else { /* sig1 == sig2 */ - return 0; - } -} -/*..........................................................................*/ -void SigDictionary_ctor(SigDictionary * const me, - SigDictEntry *sto, uint32_t capacity) -{ - me->sto = sto; - me->capacity = capacity; - me->entries = 0; - me->ptrSize = 4; -} -/*..........................................................................*/ -void SigDictionary_config(SigDictionary * const me, int ptrSize) { - me->ptrSize = ptrSize; -} -/*..........................................................................*/ -void SigDictionary_put(SigDictionary * const me, - SigType sig, ObjType obj, char const *name) -{ - int idx = SigDictionary_find(me, sig, obj); - int n = me->entries; - char *dst; - if (idx >= 0) { /* the key found? */ - Q_ASSERT((idx <= n) || (n == 0)); - me->sto[idx].obj = obj; - dst = me->sto[idx].name; - STRNCPY_S(dst, sizeof(me->sto[idx].name), name); - dst[sizeof(me->sto[idx].name) - 1] = '\0'; /* zero-terminate */ - } - else if (n < me->capacity - 1) { - me->sto[n].sig = sig; - me->sto[n].obj = obj; - dst = me->sto[n].name; - STRNCPY_S(dst, sizeof(me->sto[n].name), name); - dst[sizeof(me->sto[idx].name) - 1] = '\0'; /* zero-terminate */ - ++me->entries; - /* keep the entries sorted by the sig */ - qsort(me->sto, (uint32_t)me->entries, sizeof(me->sto[0]), - &SigDictionary_comp); - } -} -/*..........................................................................*/ -char const *SigDictionary_get(SigDictionary * const me, - SigType sig, ObjType obj, char *buf) -{ - int idx; - if (sig == 0) { - return "NULL"; - } - idx = SigDictionary_find(me, sig, obj); - if (idx >= 0) { - return me->sto[idx].name; - } - else { /* key not found */ - if (buf == 0) { /* extra buffer not provided? */ - buf = me->notFound.name; /* use the internal location */ - } - /* otherwise use the provided buffer... */ - if (me->ptrSize <= 4) { - SNPRINTF_S(buf, QS_DNAME_LEN_MAX, "%08d,Obj=0x%08X", - (int)sig, (int)obj); - } - else { - SNPRINTF_S(buf, QS_DNAME_LEN_MAX, "%08d,Obj=0x%016"PRIX64"", - (int)sig, obj); - } - //SigDictionary_put(me, sig, obj, buf); /* put into the dictionary */ - return buf; - } -} -/*..........................................................................*/ -int SigDictionary_find(SigDictionary * const me, - SigType sig, ObjType obj) -{ - /* binary search algorithm ... */ - int mid; - int first = 0; - int last = me->entries; - while (first <= last) { - mid = (first + last) / 2; - if (me->sto[mid].sig == sig) { - if (obj == 0) { /* global/generic signal? */ - return mid; - } - else { - first = mid; - do { - if ((me->sto[first].obj == 0) - || (me->sto[first].obj == obj)) - { - return first; - } - --first; - } while ((first >= 0) && (me->sto[first].sig == sig)); - last = mid + 1; - while ((last < me->entries) && (me->sto[last].sig == sig)) { - if ((me->sto[last].obj == 0) - || (me->sto[last].obj == obj)) - { - return last; - } - ++last; - } - return -1; /* entry not found */ - } - } - if (me->sto[mid].sig > sig) { - last = mid - 1; - } - else { - first = mid + 1; - } - } - - return -1; /* entry not found */ -} -/*..........................................................................*/ -SigType SigDictionary_findSig(SigDictionary * const me, - char const *name, ObjType obj) -{ - /* brute-force search algorithm... */ - int i; - for (i = 0; i < me->entries; ++i) { - if (((me->sto[i].obj == obj) || (me->sto[i].obj == (ObjType)0)) - && (strncmp(me->sto[i].name, name, sizeof(me->sto[i].name)) == 0)) - { - return me->sto[i].sig; - } - } - return (SigType)0; /* not found */ -} -/*..........................................................................*/ -void SigDictionary_reset(SigDictionary * const me) { - int i; - for (i = 0; i < me->capacity; ++i) { - me->sto[i].sig = (SigType)0; - } - me->entries = 0; -} diff --git a/qspy/source/qspy_be.c b/qspy/source/qspy_be.c deleted file mode 100644 index 538e337..0000000 --- a/qspy/source/qspy_be.c +++ /dev/null @@ -1,317 +0,0 @@ -//============================================================================ -// QSPY software tracing host-side utility -// Copyright (C) 2005 Quantum Leaps, LLC. All rights reserved. -// -// SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-QL-commercial -// -// This software is dual-licensed under the terms of the open source GNU -// General Public License version 3 (or any later version), or alternatively, -// under the terms of one of the closed source Quantum Leaps commercial -// licenses. -// -// The terms of the open source GNU General Public License version 3 -// can be found at: -// -// The terms of the closed source Quantum Leaps commercial licenses -// can be found at: -// -// Redistributions in source code must retain this top-level comment block. -// Plagiarizing this software to sidestep the license obligations is illegal. -// -// Contact information: -// -// -//============================================================================ -//! @date Last updated on: 2024-06-21 -//! @version Last updated for version: 7.4.0 -//! -//! @file -//! @brief Back-End connection point for the external Front-Ends - -#include -#include - -#include "safe_std.h" /* "safe" and facilities */ -#include "qspy.h" /* QSPY data parser */ -#include "be.h" /* Back-End interface */ -#include "pal.h" /* Platform Abstraction Layer */ - -#define Q_SPY 1 // this is QP implementation -#define QP_IMPL 1 // this is QP implementation -typedef uint32_t QSObj; // dummy definition for including "qpc_qs.h" -typedef uint32_t QEvt; // dummy definition for including "qpc_qs.h" -#include "qpc_qs.h" // QS target-resident interface -#include "qpc_qs_pkg.h" // QS package-scope interface - -/*..........................................................................*/ -static uint8_t l_rxBeSeq; /* receive Back-End sequence number */ -static uint8_t l_txBeSeq; /* transmit Back-End sequence number */ -static uint8_t l_channels; /* channels of the output (bitmask) */ - -enum Channels { - BINARY_CH = 1U, // (1U << 0U) - TEXT_CH = (1U << 1U) -}; - -/* send a packet to Front-End */ -static void BE_sendShortPkt(int pktId); - -#define BIN_FORMAT "%c%c%c%c%c%c%c%c" -#define BYTE_TO_BIN(byte_) \ - (byte_ & 0x80 ? '1' : '0'), \ - (byte_ & 0x40 ? '1' : '0'), \ - (byte_ & 0x20 ? '1' : '0'), \ - (byte_ & 0x10 ? '1' : '0'), \ - (byte_ & 0x08 ? '1' : '0'), \ - (byte_ & 0x04 ? '1' : '0'), \ - (byte_ & 0x02 ? '1' : '0'), \ - (byte_ & 0x01 ? '1' : '0') - -/*..........................................................................*/ -#ifndef NDEBUG -static FILE *l_testFile; -#endif - -void BE_onStartup(void) { - l_rxBeSeq = 0U; - l_txBeSeq = 0U; - l_channels = 0U; - -#ifndef NDEBUG - FOPEN_S(l_testFile, "fromFE.bin", "wb"); -#endif -} -/*..........................................................................*/ -void BE_onCleanup(void) { - BE_sendShortPkt(QSPY_DETACH); -#ifndef NDEBUG - fclose(l_testFile); -#endif -} - -/*..........................................................................*/ -void BE_parse(unsigned char *buf, uint32_t nBytes) { - /* By nature of UDP, each transmission from the Front-End contains - * one complete UDP packet, which contains one complete QS record. - * This is a greatly simplifying assumption in this routine. - * - * NOTE: if the communication mechanism would change from UDP to - * to something else (e.g. TCP), the following code would need to - * change, as the packet-boundaries might not be preserved. - */ - - /* check the continuity of the data from the Front-End... */ - if (l_channels != 0U) { /* is a Front-End attached? */ - ++l_rxBeSeq; - if (buf[0] != l_rxBeSeq) { - SNPRINTF_LINE(" ERROR Data Discontinuity " - "Seq=%u->%u", - (unsigned)l_rxBeSeq, (unsigned)buf[0]); - QSPY_printError(); - l_rxBeSeq = buf[0]; - } - } - - /* check if this is a packet to be forwarded directly to the Target */ - if (buf[1] < 128) { - static uint8_t qbuf[QS_RECORD_SIZE_MAX]; /* encoded QS record */ - - /* encode the packet according to the QS/QSPY protocol */ - uint32_t len = QSPY_encode(qbuf, sizeof(qbuf), buf, nBytes); - if (len > 0U) { - if ((*PAL_vtbl.send2Target)(qbuf, len) != QSPY_SUCCESS) { - SNPRINTF_LINE(" ERROR Sending Data " - "to the Target Rec=%d,Len=%d", - (int)buf[1], (int)len); - QSPY_printError(); - } - } - else { - SNPRINTF_LINE(" ERROR Target packet too big Len=%d", - (int)len); - QSPY_printError(); - } - } - else { - QSpyRecord qrec; - QSpyRecord_init(&qrec, buf, nBytes); /* buf contains one QS record */ - BE_parseRecFromFE(&qrec); /* parse the QS record from Front-End */ - } -} - -/*..........................................................................*/ -void BE_parseRecFromFE(QSpyRecord * const qrec) { - uint8_t action; - switch (qrec->rec) { - case QSPY_ATTACH: { /* attach to the Front-End */ - if (l_channels == 0U) { /* no Front-End attached yet? */ - SNPRINTF_LINE(" Attached Chan="BIN_FORMAT, - BYTE_TO_BIN(qrec->start[2])); - QSPY_printInfo(); - } - - if (qrec->tot_len > 2U) { /* payload contains channels? */ - l_channels = qrec->start[2]; - } - else { /* old payload without channels */ - l_channels = BINARY_CH; /* default to binary channel */ - } - l_rxBeSeq = qrec->start[0]; /* re-start the receive sequence */ - l_txBeSeq = 0U; /* re-start the transmit sequence */ - - /* send the attach confirmation packet back to the Front-End */ - BE_sendShortPkt(QSPY_ATTACH); - - break; - } - case QSPY_DETACH: { /* detach from the Front-End */ - PAL_detachFE(); - l_channels = 0U; /* mark as detached from the Front-End */ - - if (qrec->tot_len > 2U) { /* payload contains exit request? */ - SNPRINTF_LINE(" Forced EXIT %s", - "###################################"); - QSPY_printInfo(); - PAL_exit(); - } - else { /* detach request without exit */ - SNPRINTF_LINE(" Detached %s", - "######################################"); - QSPY_printInfo(); - } - break; - } - case QSPY_SAVE_DICT: { /* save dictionaries collected so far */ - QSPY_command('d', CMD_OPT_TOGGLE); - break; - } - case QSPY_TEXT_OUT: { - action = CMD_OPT_TOGGLE; - if (qrec->tot_len > 2U) { /* payload contains action? */ - action = qrec->start[2]; - } - QSPY_command('o', action); - break; - } - case QSPY_BIN_OUT: { - action = CMD_OPT_TOGGLE; - if (qrec->tot_len > 2U) { /* payload contains action? */ - action = qrec->start[2]; - } - QSPY_command('s', action); - break; - } - case QSPY_MATLAB_OUT: { - action = CMD_OPT_TOGGLE; - if (qrec->tot_len > 2U) { /* payload contains action? */ - action = qrec->start[2]; - } - QSPY_command('m', action); - break; - } - case QSPY_SEQUENCE_OUT: { - action = CMD_OPT_TOGGLE; - if (qrec->tot_len > 2U) { /* payload contains action? */ - action = qrec->start[2]; - } - QSPY_command('g', action); - break; - } - - case QSPY_SEND_EVENT: { - QSPY_sendEvt(qrec); - break; - } - case QSPY_SEND_AO_FILTER: - case QSPY_SEND_CURR_OBJ: { - QSPY_sendObj(qrec); - break; - } - case QSPY_SEND_COMMAND: { - QSPY_sendCmd(qrec); - break; - } - case QSPY_SEND_TEST_PROBE: { - QSPY_sendTP(qrec); - break; - } - case QSPY_SHOW_NOTE: { - QSPY_showNote(qrec); - break; - } - case QSPY_CLEAR_SCREEN: { - QSPY_command('c', CMD_OPT_OFF); - break; - } - - default: { - SNPRINTF_LINE(" ERROR Unrecognized command Rec=%d", - (int)qrec->rec); - QSPY_printError(); - break; - } - } -} -/*..........................................................................*/ -int BE_parseRecFromTarget(QSpyRecord * const qrec) { - if ((l_channels & BINARY_CH) != 0) { - if (qrec->rec != QS_EMPTY) { - /* forward the Target binary record to the Front-End... */ - PAL_send2FE(qrec->start, qrec->tot_len - 1U); - } - } - else if (l_channels != 0U) { - if (qrec->rec == QS_TARGET_INFO) { - /* forward the Target Info record to the Front-End... */ - PAL_send2FE(qrec->start, qrec->tot_len - 1U); - } - } - return 1; /* continue with the standard QSPY processing */ -} - -/*--------------------------------------------------------------------------*/ -static void BE_sendShortPkt(int pktId) { - if ((pktId >= 128) || ((l_channels & BINARY_CH) != 0)) { - uint8_t buf[4]; - uint8_t *pos = &buf[0]; - ++l_txBeSeq; - *pos++ = l_txBeSeq; - *pos++ = (uint8_t)pktId; - PAL_send2FE(buf, (uint32_t)(pos - &buf[0])); - } -} -/*..........................................................................*/ -void BE_sendLine(void) { - if ((l_channels & TEXT_CH) != 0) { - /* filter for permanently enabled QS records - * that should NOT be forwarded to BE: - * QS_EMPTY, - * QS_SIG_DICT, - * QS_OBJ_DICT, - * QS_FUN_DICT, - * QS_USR_DICT, - * QS_ENUM_DICT, - * QS_TARGET_INFO - */ - static uint8_t const dont_forward[32] = { - 0x01U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x40U, 0xF0U, - 0x01U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, - 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, - 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U - }; - uint8_t rec = (uint8_t)QSPY_output.rec; - - /* should this QS record be forwarded? */ - if ((dont_forward[rec >> 3] & (1U << (rec & 7U))) == 0U) { - ++l_txBeSeq; - - /* prepend the BE UDP packet header in front of the string */ - QSPY_output.buf[QS_LINE_OFFSET - 3] = l_txBeSeq; - QSPY_output.buf[QS_LINE_OFFSET - 2] = QS_EMPTY; - QSPY_output.buf[QS_LINE_OFFSET - 1] = rec; - - PAL_send2FE((uint8_t const *)&QSPY_output.buf[QS_LINE_OFFSET - 3], - QSPY_output.len + 3); - } - } -} diff --git a/qspy/source/qspy_dict.c b/qspy/source/qspy_dict.c deleted file mode 100644 index 0af6094..0000000 --- a/qspy/source/qspy_dict.c +++ /dev/null @@ -1,467 +0,0 @@ -//============================================================================ -// QSPY software tracing host-side utility -// Copyright (C) 2005 Quantum Leaps, LLC. All rights reserved. -// -// SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-QL-commercial -// -// This software is dual-licensed under the terms of the open source GNU -// General Public License version 3 (or any later version), or alternatively, -// under the terms of one of the closed source Quantum Leaps commercial -// licenses. -// -// The terms of the open source GNU General Public License version 3 -// can be found at: -// -// The terms of the closed source Quantum Leaps commercial licenses -// can be found at: -// -// Redistributions in source code must retain this top-level comment block. -// Plagiarizing this software to sidestep the license obligations is illegal. -// -// Contact information: -// -// -//============================================================================ -//! @date Last updated on: 2024-02-23 -//! @version Last updated for version: 7.3.3 -//! -//! @file -//! @brief QSPY host uility: dictionary file reading/writing - -#include -#include -#include -#include -#include - -#include "safe_std.h" /* "safe" and facilities */ -#include "qspy.h" /* QSPY data parser */ -#include "pal.h" /* Platform Abstraction Layer */ - -/*..........................................................................*/ -static char l_dictFileName[QS_FNAME_LEN_MAX]; - -/*..........................................................................*/ -bool QDIC_isActive(void) { - return l_dictFileName[0] != '\0'; -} - -/*..........................................................................*/ -void QSPY_setExternDict(char const *dictName) { - SNPRINTF_S(l_dictFileName, sizeof(l_dictFileName), "%s", dictName); -} -/*..........................................................................*/ -QSpyStatus QSPY_writeDict(void) { - FILE *dictFile = (FILE *)0; - char buf[QS_FNAME_LEN_MAX]; - - /* no external dictionaries configured? */ - if (l_dictFileName[0] == '\0') { - SNPRINTF_LINE(" %s", - "Dictionaries NOT configured (no -d option)"); - QSPY_printError(); - return QSPY_ERROR; - } - - /* no external dictionaries configured or no target config yet? */ - if (QSPY_conf.tstamp[5] == 0U) { - SNPRINTF_LINE(" %s", - "Dictionaries NOT saved (no target info)"); - QSPY_printError(); - return QSPY_ERROR; - } - - /* synthesize dictionary name from the timestamp */ - SNPRINTF_S(buf, sizeof(buf), - "qspy%02u%02u%02u_%02u%02u%02u.dic", - (unsigned)QSPY_conf.tstamp[5], - (unsigned)QSPY_conf.tstamp[4], - (unsigned)QSPY_conf.tstamp[3], - (unsigned)QSPY_conf.tstamp[2], - (unsigned)QSPY_conf.tstamp[1], - (unsigned)QSPY_conf.tstamp[0]); - - FOPEN_S(dictFile, buf, "w"); - if (dictFile == (FILE *)0) { - SNPRINTF_LINE(" Cannot save dictionaries to File=%s", buf); - QSPY_printError(); - return QSPY_ERROR; - } - - FPRINTF_S(dictFile, "-v%03d\n", (int)QSPY_conf.version); - FPRINTF_S(dictFile, "-T%01d\n", (int)QSPY_conf.tstampSize); - FPRINTF_S(dictFile, "-O%01d\n", (int)QSPY_conf.objPtrSize); - FPRINTF_S(dictFile, "-F%01d\n", (int)QSPY_conf.funPtrSize); - FPRINTF_S(dictFile, "-S%01d\n", (int)QSPY_conf.sigSize); - FPRINTF_S(dictFile, "-E%01d\n", (int)QSPY_conf.evtSize); - FPRINTF_S(dictFile, "-Q%01d\n", (int)QSPY_conf.queueCtrSize); - FPRINTF_S(dictFile, "-P%01d\n", (int)QSPY_conf.poolCtrSize); - FPRINTF_S(dictFile, "-B%01d\n", (int)QSPY_conf.poolBlkSize); - FPRINTF_S(dictFile, "-C%01d\n", (int)QSPY_conf.tevtCtrSize); - FPRINTF_S(dictFile, "-t%02d%02d%02d_%02d%02d%02d\n\n", - (int)QSPY_conf.tstamp[5], - (int)QSPY_conf.tstamp[4], - (int)QSPY_conf.tstamp[3], - (int)QSPY_conf.tstamp[2], - (int)QSPY_conf.tstamp[1], - (int)QSPY_conf.tstamp[0]); - - FPRINTF_S(dictFile, "%s\n", "Obj-Dic:"); - Dictionary_write(&QSPY_objDict, dictFile); - - FPRINTF_S(dictFile, "%s\n", "Fun-Dic:"); - Dictionary_write(&QSPY_funDict, dictFile); - - FPRINTF_S(dictFile, "%s\n", "Usr-Dic:"); - Dictionary_write(&QSPY_usrDict, dictFile); - - FPRINTF_S(dictFile, "%s\n", "Sig-Dic:"); - SigDictionary_write(&QSPY_sigDict, dictFile); - - fclose(dictFile); - - SNPRINTF_LINE(" Dictionaries saved to File=%s", buf); - QSPY_printInfo(); - - return QSPY_SUCCESS; -} -/*..........................................................................*/ -QSpyStatus QSPY_readDict(void) { - FILE *dictFile; - char name[QS_FNAME_LEN_MAX]; - char buf[256]; - uint32_t c = QSPY_conf.tstamp[5]; /* save the year-part of the tstamp */ - uint32_t d = 0U; /* assume no difference in the configuration */ - QSpyStatus stat = QSPY_SUCCESS; /* assume success */ - - /* no external dictionaries configured? */ - if (l_dictFileName[0] == '\0') { - SNPRINTF_LINE(" %s", - "Dictionaries NOT configured (no -d option)"); - QSPY_printError(); - return QSPY_ERROR; - } - else if (l_dictFileName[0] == '?') { /* automatic dictionaries? */ - - /* no target timestamp yet? */ - if (c == 0U) { - SNPRINTF_LINE(" %s", - "No Target info yet to read dictionaries"); - QSPY_printError(); - return QSPY_ERROR; - } - - /* synthesize dictionary name from the timestamp */ - SNPRINTF_S(name, sizeof(name), - "qspy%02u%02u%02u_%02u%02u%02u.dic", - (unsigned)QSPY_conf.tstamp[5], - (unsigned)QSPY_conf.tstamp[4], - (unsigned)QSPY_conf.tstamp[3], - (unsigned)QSPY_conf.tstamp[2], - (unsigned)QSPY_conf.tstamp[1], - (unsigned)QSPY_conf.tstamp[0]); - } - else { /* manual dictionaries */ - SNPRINTF_S(name, sizeof(name), "%s", l_dictFileName); - } - - FOPEN_S(dictFile, name, "r"); - if (dictFile == (FILE *)0) { - SNPRINTF_LINE(" Dictionaries not found File=%s", name); - QSPY_printError(); - return QSPY_ERROR; - } - - /* output the status to the user */ - SNPRINTF_LINE(" Reading dictionaries from File=%s", name); - QSPY_onPrintLn(); - - while (fgets(buf, sizeof(buf), (FILE *)dictFile) != (char *)0) { - switch (buf[0]) { - case '#': /* comment beginning */ - case '\r': /* empty line (DOS) */ - case '\n': /* empty line (Unix) */ - /* skip the comment */ - break; - case '-': - switch (buf[1]) { - case 'v': - CONFIG_UPDATE(version, - (100U*(buf[2] - '0') - + 10U*(buf[3] - '0') - + (buf[4] - '0')), d); - break; - case 'T': - CONFIG_UPDATE(tstampSize, (buf[2] - '0'), d); - break; - case 'O': - CONFIG_UPDATE(objPtrSize, (buf[2] - '0'), d); - break; - case 'F': - CONFIG_UPDATE(funPtrSize, (buf[2] - '0'), d); - break; - case 'S': - CONFIG_UPDATE(sigSize, (buf[2] - '0'), d); - break; - case 'E': - CONFIG_UPDATE(evtSize, (buf[2] - '0'), d); - break; - case 'Q': - CONFIG_UPDATE(queueCtrSize, (buf[2] - '0'), d); - break; - case 'P': - CONFIG_UPDATE(poolCtrSize, (buf[2] - '0'), d); - break; - case 'B': - CONFIG_UPDATE(poolBlkSize, (buf[2] - '0'), d); - break; - case 'C': - CONFIG_UPDATE(tevtCtrSize, (buf[2] - '0'), d); - break; - case 't': - CONFIG_UPDATE(tstamp[5], - ((buf[2 + 0] - '0')*10 + buf[2 + 1] - '0'), d); - CONFIG_UPDATE(tstamp[4], - ((buf[2 + 2] - '0')*10 + buf[2 + 3] - '0'), d); - CONFIG_UPDATE(tstamp[3], - ((buf[2 + 4] - '0')*10 + buf[2 + 5] - '0'), d); - CONFIG_UPDATE(tstamp[2], - ((buf[2 + 7] - '0')*10 + buf[2 + 8] - '0'), d); - CONFIG_UPDATE(tstamp[1], - ((buf[2 + 9] - '0')*10 + buf[2 +10] - '0'), d); - CONFIG_UPDATE(tstamp[0], - ((buf[2 +11] - '0')*10 + buf[2 +12] - '0'), d); - break; - default: - SNPRINTF_LINE(" Unexpected option in " - "Dictionary File=%s,Opt=%c", name, buf[1]); - QSPY_printError(); - stat = QSPY_ERROR; - goto error; - } - break; - case 'O': /* object dictionary */ - if (!Dictionary_read(&QSPY_objDict, (FILE *)dictFile)) { - SNPRINTF_LINE(" Parsing OBJ dictionaries failed" - " File=%s", name); - QSPY_printError(); - stat = QSPY_ERROR; - goto error; - } -#ifdef QSPY_APP - QSEQ_dictionaryReset(); - int i; - for (i = 0; i < QSPY_objDict.entries; ++i) { - QSEQ_updateDictionary(QSPY_objDict.sto[i].name, - QSPY_objDict.sto[i].key); - } -#endif - break; - case 'F': /* function dictionary */ - if (!Dictionary_read(&QSPY_funDict, (FILE *)dictFile)) { - SNPRINTF_LINE(" Parsing FUN dictionaries failed" - " File=%s", name); - QSPY_printError(); - stat = QSPY_ERROR; - goto error; - } - break; - case 'U': /* user dictionary */ - if (!Dictionary_read(&QSPY_usrDict, (FILE *)dictFile)) { - SNPRINTF_LINE(" Parsing USR dictionaries failed" - " File=%s", name); - QSPY_printError(); - stat = QSPY_ERROR; - goto error; - } - break; - case 'S': /* signal dictionary */ - if (!SigDictionary_read(&QSPY_sigDict, (FILE *)dictFile)) { - SNPRINTF_LINE(" Parsing SIG dictionaries failed" - " File=%s", name); - QSPY_printError(); - stat = QSPY_ERROR; - goto error; - } - break; - /* don't read the sequence dictionary */ - default: - SNPRINTF_LINE(" Unexpected line in " - "Dictionary File=%s,Char=%c", name, buf[0]); - QSPY_printError(); - stat = QSPY_ERROR; - goto error; - } - } - -error: - fclose(dictFile); - - /* any differences in config and not the first time through? */ - if ((stat != QSPY_ERROR) && (d != 0U) && (c != 0U)) { - SNPRINTF_LINE(" %s", - "Dictionaries mismatch the Target (discarded)"); - QSPY_printInfo(); - - QSPY_resetAllDictionaries(); - stat = QSPY_ERROR; - } - - return stat; -} - -/*..........................................................................*/ -void Dictionary_write(Dictionary const * const me, FILE *stream) { - int i; - - FPRINTF_S(stream, "%d\n", me->keySize); - for (i = 0; i < me->entries; ++i) { - DictEntry const *e = &me->sto[i]; - if (me->keySize <= 4) { - FPRINTF_S(stream, "0x%08X %s\n", (unsigned)e->key, e->name); - } - else { - FPRINTF_S(stream, "0x%016"PRIX64" %s\n", e->key, e->name); - } - } - FPRINTF_S(stream, "%s\n", "***"); /* close marker for a dictionary */ -} -/*..........................................................................*/ -bool Dictionary_read(Dictionary * const me, FILE *stream) { - char dictLine[80]; - - if (fgets(dictLine, sizeof(dictLine), stream) == (char *)0) { - goto error; - } - me->keySize = (int)strtol(dictLine, NULL, 10); - if ((me->keySize == 0) || (me->keySize > 8)) { - goto error; - } - - Dictionary_reset(me); - while (me->entries < me->capacity) { - uint64_t key = 0; - char *name = NULL; - char *str_end = NULL; - - if (fgets(dictLine, sizeof(dictLine), stream) == (char *)0) { - break; - } - if ((dictLine[0] != '0') || (dictLine[1] != 'x')) { - break; - } - if (me->keySize <= 4) { - dictLine[10] = '\0'; - name = &dictLine[11]; - key = (uint64_t)strtoul(dictLine, &str_end, 16); - } - else { - dictLine[18] = '\0'; - key = strtoull(dictLine, &str_end, 16); - name = &dictLine[19]; - } - if (str_end == dictLine) { - goto error; - } - /* remove the '\n' from the end of the name string */ - name[strlen(name) - 1] = '\0'; - Dictionary_put(me, key, name); - } - return true; - -error: - Dictionary_reset(me); - return false; -} -/*..........................................................................*/ -void SigDictionary_write(SigDictionary const* const me, FILE* stream) { - int i; - - FPRINTF_S(stream, "%d\n", me->ptrSize); - for (i = 0; i < me->entries; ++i) { - SigDictEntry const* e = &me->sto[i]; - if (me->ptrSize <= 4) { - FPRINTF_S(stream, "%08d 0x%08X %s\n", - e->sig, (unsigned)e->obj, e->name); - } - else { - FPRINTF_S(stream, "%08d 0x%016"PRIX64" %s\n", - e->sig, e->obj, e->name); - } - } - FPRINTF_S(stream, "%s\n", "***"); /* close marker for a dictionary */ -} -/*..........................................................................*/ -bool SigDictionary_read(SigDictionary * const me, FILE *stream) { - char dictLine[80]; - - if (fgets(dictLine, sizeof(dictLine), stream) == (char *)0) { - goto error; - } - me->ptrSize = (int)strtol(dictLine, NULL, 10); - if ((me->ptrSize == 0) || (me->ptrSize > 8)) { - goto error; - } - - SigDictionary_reset(me); - while (me->entries < me->capacity) { - uint32_t sig = 0; - uint64_t obj = 0; - char *name = NULL; - char *str_end = NULL; - - if (fgets(dictLine, sizeof(dictLine), stream) == (char *)0) { - break; - } - if (dictLine[0] != '0') { - break; - } - - /* parse the sig */ - dictLine[8] = '\0'; - sig = strtoul(dictLine, NULL, 10); - if (sig == 0) { - goto error; - } - /* parse the obj and name */ - if (me->ptrSize <= 4) { - dictLine[19] = '\0'; - name = &dictLine[20]; - obj = (uint64_t)strtoul(&dictLine[9], &str_end, 16); - } - else { - dictLine[27] = '\0'; - name = &dictLine[28]; - obj = strtoull(&dictLine[9], &str_end, 16); - } - if (str_end == &dictLine[9]) { - goto error; - } - /* remove the '\n' from the end of the name string */ - name[strlen(name) - 1] = '\0'; - SigDictionary_put(me, sig, obj, name); - } - return true; - -error: - SigDictionary_reset(me); - return false; -} -/*..........................................................................*/ -char const* QSPY_getMatDict(char const* s) { - static char dict[65]; - char* pc = dict; - while ((*s != '\0') && (pc < &dict[sizeof(dict)] - 1)) { - if ((*s == '[') || (*s == ']') - || (*s == '.') || (*s == ':')) - { - *pc++ = '_'; - ++s; - } - else { - *pc++ = *s++; - } - } - *pc = '\0'; - return (dict[0] == '&' ? dict + 1 : dict); -} diff --git a/qspy/source/qspy_main.c b/qspy/source/qspy_main.c deleted file mode 100644 index c110ce8..0000000 --- a/qspy/source/qspy_main.c +++ /dev/null @@ -1,1034 +0,0 @@ -//============================================================================ -// QSPY software tracing host-side utility -// Copyright (C) 2005 Quantum Leaps, LLC. All rights reserved. -// -// SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-QL-commercial -// -// This software is dual-licensed under the terms of the open source GNU -// General Public License version 3 (or any later version), or alternatively, -// under the terms of one of the closed source Quantum Leaps commercial -// licenses. -// -// The terms of the open source GNU General Public License version 3 -// can be found at: -// -// The terms of the closed source Quantum Leaps commercial licenses -// can be found at: -// -// Redistributions in source code must retain this top-level comment block. -// Plagiarizing this software to sidestep the license obligations is illegal. -// -// Contact information: -// -// -//============================================================================ -//! @date Last updated on: 2024-06-21 -//! @version Last updated for version: 7.4.0 -//! -//! @file -//! @brief main for QSPY host utility - -#include -#include -#include -#include - -#include "safe_std.h" /* "safe" and facilities */ -#include "qspy.h" /* QSPY data parser */ -#include "be.h" /* Back-End interface */ -#include "pal.h" /* Platform Abstraction Layer */ -#include "getopt.h" /* command-line option processor */ - -/*..........................................................................*/ -typedef enum { - NO_LINK, - FILE_LINK, - SERIAL_LINK, - TCP_LINK -} TargetLink; - -static TargetLink l_link = NO_LINK; -static int l_quiet = -1; -static int l_quiet_ctr = 0; -static bool l_kbd_inp = true; /* keyboard input supported */ -static FILE *l_outFile = (FILE *)0; -static FILE *l_savFile = (FILE *)0; -static FILE *l_matFile = (FILE *)0; -static FILE *l_seqFile = (FILE *)0; - -static char l_comPort [QS_FNAME_LEN_MAX]; -static char l_inpFileName[QS_FNAME_LEN_MAX]; -static char l_outFileName[QS_FNAME_LEN_MAX]; -static char l_savFileName[QS_FNAME_LEN_MAX]; -static char l_matFileName[QS_FNAME_LEN_MAX]; -static char l_seqFileName[QS_FNAME_LEN_MAX]; -static char l_dicFileName[QS_FNAME_LEN_MAX]; - -static char l_tstampStr [16]; -static char l_seqList[QS_SEQ_LIST_LEN_MAX]; - -static int l_bePort = 7701; /* default UDP port */ -static int l_tcpPort = 6601; /* default TCP port */ -static int l_baudRate = 115200; /* default serial baud rate */ - -/* color rendering */ -extern char const * const l_darkPalette[]; -extern char const * const l_lightPalette[]; -static char const * const *l_colorPalette = l_darkPalette; - -static char const l_introStr[] = \ - "QSPY %s Copyright (c) 2005-2024 Quantum Leaps\n" \ - "Documentation: https://www.state-machine.com/qtools/qspy.html\n" \ - "Current timestamp: %s\n"; - -static char const l_helpStr[] = - "Usage: qspy [options] = required, [arg] = optional\n" - "\n" - "OPTION DEFAULT COMMENT\n" - " (key)\n" - "---------------------------------------------------------------\n" - "-h help (show this message)\n" - "-q [num] (key-q) quiet mode (no QS data output)\n" - "-u [UDP_port|0] 7701 UDP socket with optional port, 0-no UDP\n" - "-v 7.0 compatibility with QS version\n" - "-r c1 rendering (c0=no-color, c1-color1, )\n" - "-k suppress keyboard input\n" - "-o (key-o) save screen output to a file\n" - "-s (key-s) save binary QS data to a file\n" - "-m produce Matlab output to a file\n" - "-g produce Sequence diagram to a file\n" - "-t [TCP_port] 6601 TCP/IP input with optional port\n" -#ifdef _WIN32 - "-c COM1 com port input (default)\n" -#elif (defined __linux) || (defined __linux__) || (defined __posix) - "-c /dev/ttyS0 serial port input (default)\n" -#endif - "-b 115200 baud rate for the com port\n" - "-f file input (postprocessing)\n" - "-d [file_name] dictionary files\n" - "-T 4 QS timestamp size (bytes)\n" - "-O 4 object pointer size (bytes)\n" - "-F 4 function pointer size (bytes)\n" - "-S 2 event signal size (bytes)\n" - "-E 2 event size size (bytes)\n" - "-Q 1 queue counter size (bytes)\n" - "-P 2 pool counter size (bytes)\n" - "-B 2 pool block-size size (bytes)\n" - "-C 4 QTimeEvt counter size (bytes)\n"; - -static char const l_kbdHelpStr[] = - "Keyboard shortcuts (valid when -k option is absent):\n" - "KEY(s) ACTION\n" - "----------------------------------------------------------------\n" - "/x/X Exit QSPY\n" - " h display keyboard help and QSPY status\n" - " c clear the screen\n" - " q toggle quiet mode (no Target data from QS)\n" - " r send RESET command to the target\n" - " i send INFO request to the target\n" - " t send TICK[0] command to the target\n" - " u send TICK[1] command to the target\n" - " d trigger saving dictionaries to a file\n" - " o toggle screen file output (close/re-open)\n" - " s/b toggle binary file output (close/re-open)\n" - " m toggle Matlab file output (close/re-open)\n" - " g toggle Message sequence output (close/re-open)\n"; - -/*..........................................................................*/ -static QSpyStatus configure(int argc, char *argv[]); -static void colorPrintLn(void); -static uint8_t l_buf[8*1024]; /* process input in 8K chunks */ - -/*..........................................................................*/ -int main(int argc, char *argv[]) { - int status = 0; - - /* parse the command-line options and configure QSPY ...................*/ - if (configure(argc, argv) != QSPY_SUCCESS) { - status = -1; - } - else { - uint32_t nBytes; - bool isRunning = true; - - status = 0; /* assume success */ - while (isRunning) { /* QSPY event loop... */ - - /* get the event from the PAL... */ - nBytes = sizeof(l_buf); - QSPYEvtType evt = (*PAL_vtbl.getEvt)(l_buf, &nBytes); - Q_ASSERT(nBytes <= sizeof(l_buf)); - - switch (evt) { - case QSPY_NO_EVT: /* all intputs timed-out this time around */ - break; - - case QSPY_TARGET_INPUT_EVT: /* the Target sent some data... */ - if (nBytes > 0) { - QSPY_parse(l_buf, (uint32_t)nBytes); - if (l_savFile != (FILE *)0) { - (void)fwrite(l_buf, 1, nBytes, l_savFile); - } - } - break; - - case QSPY_FE_INPUT_EVT: /* the Front-End sent some data... */ - Q_ASSERT(l_bePort != 0); - if (nBytes > 0) { - BE_parse(l_buf, nBytes); - } - break; - - case QSPY_KEYBOARD_EVT: /* the User pressed a key... */ - isRunning = QSPY_command(l_buf[0], CMD_OPT_TOGGLE); - break; - - case QSPY_DONE_EVT: /* done (e.g., file processed) */ - isRunning = false; /* terminate the event loop */ - break; - - case QSPY_ERROR_EVT: /* unrecoverable error */ - isRunning = false; /* terminate the event loop */ - status = -1; /* error return */ - break; - } - } - } - - /* cleanup .............................................................*/ - QSPY_cleanup(); - return status; -} - -/*..........................................................................*/ -void QSPY_cleanup(void) { - PAL_closeKbd(); /* close the keyboard input (if open) */ - - if (l_savFile != (FILE *)0) { - (void)fclose(l_savFile); - } - if (l_outFile != (FILE *)0) { - (void)fclose(l_outFile); - } - - QSEQ_configFile((void*)0); - QSPY_configMatFile((void*)0); - - if (l_bePort != 0) { - PAL_closeBE(); /* close the Back-End connection */ - } - - if (PAL_vtbl.cleanup != 0) { - (*PAL_vtbl.cleanup)(); /* close the target connection */ - } - - PRINTF_S("\n%s\n", "QSPY Done"); -} - -/*..........................................................................*/ -void Q_onError(char const * const module, int const id) { - PRINTF_S("\n QSPY ASSERTION failed in Module=%s:%d\n", - module, id); - QSPY_cleanup(); - exit(-1); -} - -/*..........................................................................*/ -void QSPY_onPrintLn(void) { - if (l_outFile != (FILE *)0) { - /* output file receives all trace records, regardles of -q mode */ - (void)fputs(&QSPY_output.buf[QS_LINE_OFFSET], l_outFile); - (void)fputc('\n', l_outFile); - } - - if (QSPY_output.type < BE_OUT) { /* message to be forwarded to BE? */ - BE_sendLine(); /* forward to the back-end */ - } - - if (l_quiet < 0) { - if (l_colorPalette) { - colorPrintLn(); - } - else { - (void)fputs(&QSPY_output.buf[QS_LINE_OFFSET], stdout); - (void)fputc('\n', stdout); - } - } - else if (l_quiet > 0) { - if ((l_quiet_ctr == 0U) || (QSPY_output.type != REG_OUT)) { - if ((l_quiet < 99) || (QSPY_output.type != REG_OUT)) { - if (l_quiet_ctr != l_quiet - 1) { - (void)fputc('\n', stdout); - } - if (l_colorPalette) { - colorPrintLn(); - } - else { - (void)fputs(&QSPY_output.buf[QS_LINE_OFFSET], stdout); - (void)fputc('\n', stdout); - } - l_quiet_ctr = l_quiet; - } - } - else { - (void)fputc('.', stdout); - } - --l_quiet_ctr; - } - - QSPY_output.type = REG_OUT; /* reset for the next time */ -} - -/*..........................................................................*/ -static QSpyStatus configure(int argc, char *argv[]) { - static char const getoptStr[] = - "hq::u::v:r:kosmg:c:b:t::p:f:d::T:O:F:S:E:Q:P:B:C:"; - - /* default configuration options... */ - QSpyConfig config = { - .version = 700U, - .endianness = 0U, - .objPtrSize = 4U, - .funPtrSize = 4U, - .tstampSize = 4U, - .sigSize = 2U, - .evtSize = 2U, - .queueCtrSize = 1U, - .poolCtrSize = 2U, - .poolBlkSize = 2U, - .tevtCtrSize = 4U, - }; - int optChar; - - STRNCPY_S(l_outFileName, sizeof(l_outFileName), "OFF"); - STRNCPY_S(l_savFileName, sizeof(l_savFileName), "OFF"); - STRNCPY_S(l_matFileName, sizeof(l_matFileName), "OFF"); - STRNCPY_S(l_seqFileName, sizeof(l_seqFileName), "OFF"); - STRNCPY_S(l_dicFileName, sizeof(l_dicFileName), "OFF"); - - STRNCPY_S(l_tstampStr, sizeof(l_tstampStr), QSPY_tstampStr()); - PRINTF_S(l_introStr, QSPY_VER, l_tstampStr); - - STRNCPY_S(l_inpFileName, sizeof(l_inpFileName), "qs.bin"); -#ifdef _WIN32 - STRNCPY_S(l_comPort, sizeof(l_comPort), "COM1"); -#elif (defined __linux) || (defined __linux__) || (defined __posix) - STRNCPY_S(l_comPort, sizeof(l_comPort), "/dev/ttyS0"); -#endif - l_seqList[0] = '\0'; - - /* parse the command-line parameters ...................................*/ - while ((optChar = getopt(argc, argv, getoptStr)) != -1) { - switch (optChar) { - case 'q': { /* quiet mode */ - if (optarg != NULL) { /* is optional argument provided? */ - l_quiet = (int)strtoul(optarg, NULL, 10); - } - else { /* apply the default */ - l_quiet = 0; - } - break; - } - case 'u': { /* UDP control port */ - if (optarg != NULL) { /* is optional argument provided? */ - l_bePort = (int)strtoul(optarg, NULL, 10); - PRINTF_S("-u %d\n", l_bePort); - } - else { /* apply the default */ - l_bePort = 7701; - } - break; - } - case 'v': { /* compatibility with QS version */ - if (('0' <= optarg[0] && optarg[0] <= '9') - && (optarg[1] == '.') - && ('0' <= optarg[2] && optarg[2] <= '9')) - { - config.version = (((optarg[0] - '0') * 10) - + (optarg[2] - '0')) * 10; - PRINTF_S("-v %c.%c\n", optarg[0], optarg[2]); - } - else { - FPRINTF_S(stderr, "Incorrect version number: %s", optarg); - return QSPY_ERROR; - } - break; - } - case 'r': { /* rendering options */ - if (optarg != NULL) { /* is optional argument provided? */ - PRINTF_S("-r %s\n", optarg); - if (optarg[0] == 'c') { - if (optarg[1] == '1') { - l_colorPalette = l_darkPalette; - } - else if (optarg[1] == '2') { - l_colorPalette = l_lightPalette; - } - else { - l_colorPalette = (char const * const *)0; - } - } - } - break; - } - case 'k': { /* suppress keyboard input */ - l_kbd_inp = false; - break; - } - case 'o': { /* save screen output to a file */ - (void)SNPRINTF_S(l_outFileName, sizeof(l_outFileName) - 1U, - "qspy%s.txt", l_tstampStr); - PRINTF_S("-o (%s)\n", l_outFileName); - break; - } - case 's': { /* save binary data to a file */ - (void)SNPRINTF_S(l_savFileName, sizeof(l_savFileName) - 1U, - "qspy%s.bin", l_tstampStr); - PRINTF_S("-s (%s)\n", l_savFileName); - break; - } - case 'm': { /* Matlab/Octave file output */ - (void)SNPRINTF_S(l_matFileName, sizeof(l_matFileName) - 1U, - "qspy%s.mat", l_tstampStr); - PRINTF_S("-m (%s)\n", l_matFileName); - break; - } - case 'g': { /* Sequence file output */ - if (optarg != NULL) { /* is optional argument provided? */ - STRNCPY_S(l_seqList, sizeof(l_seqList), optarg); - } - else { - FPRINTF_S(stderr, "%s", - "empty object-list for sequence diagram"); - return QSPY_ERROR; - } - (void)SNPRINTF_S(l_seqFileName, sizeof(l_seqFileName) - 1U, - "qspy%s.seq", l_tstampStr); - PRINTF_S("-g %s (%s)\n", l_seqList, l_seqFileName); - break; - } - case 'c': { /* COM port */ - if ((l_link != NO_LINK) && (l_link != SERIAL_LINK)) { - FPRINTF_S(stderr, "%s\n", - "The -c option is incompatible with -t/-f"); - return QSPY_ERROR; - } - STRNCPY_S(l_comPort, sizeof(l_comPort), optarg); - PRINTF_S("-c %s\n", l_comPort); - l_link = SERIAL_LINK; - break; - } - case 'b': { /* baud rate */ - if ((l_link != NO_LINK) && (l_link != SERIAL_LINK)) { - FPRINTF_S(stderr, "%s\n", - "The -b option is incompatible with -t/-f"); - return QSPY_ERROR; - } - l_baudRate = (int)strtol(optarg, NULL, 10); - if (l_baudRate == 0) { - FPRINTF_S(stderr, "incorrect baud rate: %s\n", optarg); - return QSPY_ERROR; - } - PRINTF_S("-b %d\n", l_baudRate); - l_link = SERIAL_LINK; - break; - } - case 'f': { /* File input */ - if (l_link != NO_LINK) { - FPRINTF_S(stderr, "%s\n", - "The -f option is incompatible with -c/-b/-t"); - return QSPY_ERROR; - } - STRNCPY_S(l_inpFileName, sizeof(l_inpFileName), optarg); - PRINTF_S("-f %s\n", l_inpFileName); - l_link = FILE_LINK; - break; - } - case 'd': { /* Dictionary file */ - if (optarg != NULL) { /* is optional argument provided? */ - STRNCPY_S(l_dicFileName, sizeof(l_dicFileName), optarg); - PRINTF_S("-d %s\n", l_dicFileName); - } - else { /* apply the default */ - l_dicFileName[0] = '?'; - l_dicFileName[1] = '\0'; - PRINTF_S("%s\n", "-d"); - } - break; - } - case 't': { /* TCP/IP input */ - if ((l_link != NO_LINK) && (l_link != TCP_LINK)) { - FPRINTF_S(stderr, "%s\n", - "The -t option is incompatible with -c/-b/-f"); - return QSPY_ERROR; - } - if (optarg != NULL) { /* is optional argument provided? */ - l_tcpPort = (int)strtoul(optarg, NULL, 10); - } - PRINTF_S("-t %d\n", l_tcpPort); - l_link = TCP_LINK; - break; - } - case 'p': { /* TCP/IP port number */ - FPRINTF_S(stderr, "%s\n", - "The -p option is obsolete, use -t[port]"); - return QSPY_ERROR; - break; - } - case 'T': { /* timestamp size */ - config.tstampSize = (uint8_t)strtoul(optarg, 0, 10); - break; - } - case 'F': { /* function pointer size */ - config.funPtrSize = (uint8_t)strtoul(optarg, 0, 10); - break; - } - case 'O': { /* object pointer size */ - config.objPtrSize = (uint8_t)strtoul(optarg, 0, 10); - break; - } - case 'S': { /* signal size */ - config.sigSize = (uint8_t)strtoul(optarg, 0, 10); - break; - } - case 'E': { /* event size */ - config.evtSize = (uint8_t)strtoul(optarg, 0, 10); - break; - } - case 'Q': { /* Queue counter size */ - config.queueCtrSize = (uint8_t)strtoul(optarg, 0, 10); - break; - } - case 'P': { /* Memory-pool counter size */ - config.poolCtrSize = (uint8_t)strtoul(optarg, 0, 10); - break; - } - case 'B': { /* Memory-pool blocksize size */ - config.poolBlkSize = (uint8_t)strtoul(optarg, 0, 10); - break; - } - case 'C': { /* Time event counter size */ - config.tevtCtrSize = (uint8_t)strtoul(optarg, 0, 10); - break; - } - case 'h': { /* help */ - PRINTF_S("\n%s\n%s", l_helpStr, l_kbdHelpStr); - return QSPY_ERROR; - } - case '?': /* intentionally fall through */ - case '!': /* intentionally fall through */ - case '$': { - PRINTF_S("\n%s\n%s", l_helpStr, l_kbdHelpStr); - return QSPY_ERROR; - } - default: { - Q_ASSERT(0); - } - } - } - if (argc != optind) { - FPRINTF_S(stderr, - "%d command-line options were not processed\n", (argc - optind)); - PRINTF_S("\n%s\n%s", l_helpStr, l_kbdHelpStr); - return QSPY_ERROR; - } - - /* open the keyboard input... */ - if (PAL_openKbd(l_kbd_inp, (l_colorPalette != (char const * const*)0)) - != QSPY_SUCCESS) - { - return QSPY_ERROR; - } - - /* configure QSPY ......................................................*/ - /* open Back-End link. NOTE: must happen *before* opening Target link */ - if (l_bePort != 0) { - if (PAL_openBE(l_bePort) == QSPY_ERROR) { - return QSPY_ERROR; - } - } - - /* open Target link... */ - switch (l_link) { - case NO_LINK: /* fall through */ - case TCP_LINK: { /* connect to the Target via TCP socket */ - if (PAL_openTargetTcp(l_tcpPort) != QSPY_SUCCESS) { - return QSPY_ERROR; - } - break; - } - case SERIAL_LINK: { /* connect to the Target via serial port */ - if (PAL_openTargetSer(l_comPort, l_baudRate) != QSPY_SUCCESS) { - return QSPY_ERROR; - } - break; - } - case FILE_LINK: { /* input QS data from a file */ - if (PAL_openTargetFile(l_inpFileName) != QSPY_SUCCESS) { - return QSPY_ERROR; - } - break; - } - } - - /* open files specified on the command line... */ - if (l_outFileName[0] != 'O') { /* "OFF" ? */ - FOPEN_S(l_outFile, l_outFileName, "w"); - if (l_outFile != (FILE *)0) { - FPRINTF_S(l_outFile, l_introStr, QSPY_VER, l_tstampStr); - } - else { - PRINTF_S(" Cannot open File=%s\n", l_outFileName); - return QSPY_ERROR; - } - } - if (l_savFileName[0] != 'O') { /* "OFF" ? */ - FOPEN_S(l_savFile, l_savFileName, "wb"); /* open for writing binary */ - if (l_savFile == (FILE *)0) { - PRINTF_S(" Cannot open File=%s\n", l_savFileName); - return QSPY_ERROR; - } - } - if (l_matFileName[0] != 'O') { /* "OFF" ? */ - FOPEN_S(l_matFile, l_matFileName, "w"); - if (l_matFile == (FILE *)0) { - PRINTF_S(" Cannot open File=%s\n", l_matFileName); - return QSPY_ERROR; - } - } - if (l_seqFileName[0] != 'O') { /* "OFF" ? */ - FOPEN_S(l_seqFile, l_seqFileName, "w"); - if (l_seqFile == (FILE *)0) { - PRINTF_S(" Cannot open File=%s\n", l_seqFileName); - return QSPY_ERROR; - } - } - QSPY_config(&config, - (l_bePort != 0) - ? &BE_parseRecFromTarget - : (QSPY_CustParseFun)0); - QSPY_configMatFile(l_matFile); - QSEQ_config(l_seqFile, l_seqList); - QSPY_configTxReset(&QSPY_txReset); - - /* NOTE: dictionary file must be set and read AFTER configuring QSPY */ - if (l_dicFileName[0] != 'O') { /* not "OFF" ? */ - QSPY_setExternDict(l_dicFileName); - (void)QSPY_readDict(); - } - - return QSPY_SUCCESS; -} -/*..........................................................................*/ -bool QSPY_command(uint8_t cmdId, uint8_t opt) { - uint32_t nBytes; - bool isRunning = true; - QSpyStatus stat; - - switch (cmdId) { - default: - PRINTF_S(" Unrecognized keyboard Command=%c", - (char)cmdId); - /* intentionally fall-through... */ - - case 'h': /* keyboard help */ - PRINTF_S("\n%s\n", l_kbdHelpStr); - if (l_quiet < 0) { - PRINTF_S("Quiet Mode [q]: %s\n", "OFF"); - } - else { - PRINTF_S("Quiet Mode [q]: %d\n", l_quiet); - } - PRINTF_S("Screen Output [o]: %s\n", l_outFileName); - PRINTF_S("Binary Output [s]: %s\n", l_savFileName); - PRINTF_S("Matlab Output [m]: %s\n", l_matFileName); - PRINTF_S("Sequence Output [g]: %s\n", l_seqFileName); - break; - - case 'r': /* send RESET command to the Target */ - nBytes = QSPY_encodeResetCmd(l_buf, sizeof(l_buf)); - stat = (*PAL_vtbl.send2Target)(l_buf, nBytes); - PRINTF_S(" Sending RESET to the Target Stat=%s\n", - (stat == QSPY_ERROR) ? "ERROR" : "OK"); - break; - - case 't': /* send TICK[0] command to the Target */ - nBytes = QSPY_encodeTickCmd(l_buf, sizeof(l_buf), 0U); - stat = (*PAL_vtbl.send2Target)(l_buf, nBytes); - PRINTF_S(" Sending TICK-0 to the Target Stat=%s\n", - (stat == QSPY_ERROR) ? "ERROR" : "OK"); - break; - - case 'u': /* send TICK[1] command to the Target */ - nBytes = QSPY_encodeTickCmd(l_buf, sizeof(l_buf), 1U); - stat = (*PAL_vtbl.send2Target)(l_buf, nBytes); - PRINTF_S(" Sending TICK-1 to the Target Stat=%s\n", - (stat == QSPY_ERROR) ? "ERROR" : "OK"); - break; - - case 'i': /* send INFO request command to the Target */ - nBytes = QSPY_encodeInfoCmd(l_buf, sizeof(l_buf)); - stat = (*PAL_vtbl.send2Target)(l_buf, nBytes); - PRINTF_S(" Sending INFO to the Target Stat=%s\n", - (stat == QSPY_ERROR) ? "ERROR" : "OK"); - break; - - case 'd': /* save Dictionaries to a file */ - (void)QSPY_writeDict(); - break; - - case 'c': /* clear the screen */ - PAL_clearScreen(); - break; - - case 'q': /* quiet */ - if (l_quiet < 0) { - l_quiet = l_quiet_ctr; - PRINTF_S(" Quiet Mode [q] Mode=%d\n", l_quiet); - } - else { - l_quiet_ctr = l_quiet; - l_quiet = -1; - PRINTF_S(" Quiet Mode [q] Mode=%s\n", "OFF"); - } - break; - - case 'o': /* text output file open/close/toggle */ - if (l_outFile != (FILE *)0) { - (void)fclose(l_outFile); - l_outFile = (FILE *)0; - STRNCPY_S(l_outFileName, sizeof(l_outFileName), "OFF"); - if (opt == CMD_OPT_TOGGLE) { - opt = CMD_OPT_OFF; - } - } - if ((opt == CMD_OPT_ON) || (opt == CMD_OPT_TOGGLE)) { - STRNCPY_S(l_tstampStr, sizeof(l_tstampStr), QSPY_tstampStr()); - (void)SNPRINTF_S(l_outFileName, sizeof(l_outFileName), - "qspy%s.txt", l_tstampStr); - FOPEN_S(l_outFile, l_outFileName, "w"); - if (l_outFile != (FILE *)0) { - FPRINTF_S(l_outFile, l_introStr, QSPY_VER, - l_tstampStr); - } - else { - PRINTF_S(" Cannot open File=%s for writing\n", - l_outFileName); - STRNCPY_S(l_outFileName, sizeof(l_outFileName), "OFF"); - } - } - PRINTF_S(" Screen Output [o] File=%s\n", l_outFileName); - break; - - case 'b': - case 's': /* binary output file open/close/toggle */ - if (l_savFile != (FILE *)0) { - (void)fclose(l_savFile); - l_savFile = (FILE *)0; - STRNCPY_S(l_savFileName, sizeof(l_savFileName), "OFF"); - if (opt == CMD_OPT_TOGGLE) { - opt = CMD_OPT_OFF; - } - } - if ((opt == CMD_OPT_ON) || (opt == CMD_OPT_TOGGLE)) { - (void)SNPRINTF_S(l_savFileName, sizeof(l_savFileName), - "qspy%s.bin", QSPY_tstampStr()); - FOPEN_S(l_savFile, l_savFileName, "wb"); - if (l_savFile == (FILE *)0) { - PRINTF_S(" Cannot open File=%s for writing\n", - l_savFileName); - STRNCPY_S(l_savFileName, sizeof(l_savFileName), "OFF"); - } - } - PRINTF_S(" Binary Output [s] File=%s\n", - l_savFileName); - break; - - case 'm': /* Matlab output file open/close/toggle */ - if (l_matFile != (FILE *)0) { - QSPY_configMatFile((void *)0); /* close the Matlab file */ - l_matFile = (FILE *)0; - STRNCPY_S(l_matFileName, sizeof(l_matFileName), "OFF"); - if (opt == CMD_OPT_TOGGLE) { - opt = CMD_OPT_OFF; - } - } - if ((opt == CMD_OPT_ON) || (opt == CMD_OPT_TOGGLE)) { - (void)SNPRINTF_S(l_matFileName, sizeof(l_matFileName), - "qspy%s.mat", QSPY_tstampStr()); - FOPEN_S(l_matFile, l_matFileName, "w"); - if (l_matFile != (FILE *)0) { - QSPY_configMatFile(l_matFile); - } - else { - PRINTF_S(" Cannot open File=%s for writing\n", - l_matFileName); - STRNCPY_S(l_matFileName, sizeof(l_matFileName), "OFF"); - } - } - PRINTF_S(" Matlab Output [m] File=%s\n", - l_matFileName); - break; - - case 'g': /* Sequence output file open/close/toggle */ - if (l_seqList[0] == '\0') { - SNPRINTF_LINE(" Sequence list NOT provided %s ", - "(no -g option)"); - QSPY_printError(); - break; - } - if (l_seqFile != (FILE *)0) { - QSEQ_configFile((void *)0); /* close the Sequence file */ - l_seqFile = (FILE *)0; - STRNCPY_S(l_seqFileName, sizeof(l_seqFileName), "OFF"); - if (opt == CMD_OPT_TOGGLE) { - opt = CMD_OPT_OFF; - } - } - if ((opt == CMD_OPT_ON) || (opt == CMD_OPT_TOGGLE)) { - (void)SNPRINTF_S(l_seqFileName, sizeof(l_seqFileName), - "qspy%s.seq", QSPY_tstampStr()); - FOPEN_S(l_seqFile, l_seqFileName, "w"); - if (l_seqFile != (FILE *)0) { - QSEQ_configFile(l_seqFile); - } - else { - PRINTF_S(" Cannot open File=%s for writing\n", - l_seqFileName); - STRNCPY_S(l_seqFileName, sizeof(l_seqFileName), "OFF"); - } - } - PRINTF_S(" Sequence Output [g] File=%s\n", - l_seqFileName); - break; - - case 'x': - case 'X': - case '\x1b': /* Esc */ - isRunning = false; /* terminate the event loop */ - break; - } - - return isRunning; -} -/*..........................................................................*/ -char const* QSPY_tstampStr(void) { - time_t rawtime = time(NULL); - struct tm tstamp; - static char tstampStr[64]; - - (void)LOCALTIME_S(&tstamp, &rawtime); - - (void)SNPRINTF_S(tstampStr, sizeof(tstampStr), "%02d%02d%02d_%02d%02d%02d", - (tstamp.tm_year + 1900) % 100, - (tstamp.tm_mon + 1), - tstamp.tm_mday, - tstamp.tm_hour, - tstamp.tm_min, - tstamp.tm_sec); - - return &tstampStr[0]; -} - -/*--------------------------------------------------------------------------*/ -/* color output to the terminal */ - -/* terminal colors */ -#define B_DFLT_EOL "\x1b[K\x1b[0m" -#define B_DFLT "\x1b[0m" -#define B_BLACK "\x1b[40m" -#define B_RED "\x1b[41m" -#define B_GREEN "\x1b[42m" -#define B_YELLOW "\x1b[43m" -#define B_BLUE "\x1b[44m" -#define B_MAGENTA "\x1b[45m" -#define B_CYAN "\x1b[46m" -#define B_WHITE "\x1b[47m" - -#define F_BLACK "\x1b[30m" -#define F_RED "\x1b[31m" -#define F_GREEN "\x1b[32m" -#define F_YELLOW "\x1b[33m" -#define F_BLUE "\x1b[34m" -#define F_MAGENTA "\x1b[35m" -#define F_CYAN "\x1b[36m" -#define F_WHITE "\x1b[37m" - -#define F_GRAY "\x1b[30;1m" -#define F_BRED "\x1b[31;1m" -#define F_BGREEN "\x1b[32;1m" -#define F_BYELLOW "\x1b[33;1m" -#define F_BBLUE "\x1b[34;1m" -#define F_BMAGENTA "\x1b[35;1m" -#define F_BCYAN "\x1b[36;1m" -#define F_BWHITE "\x1b[37;1m" - -/* color palette entries */ -enum { - PALETTE_ERR_OUT, - PALETTE_INF_OUT, - PALETTE_TST_OUT, - PALETTE_USR_OUT, - PALETTE_TSTAMP, - PALETTE_DSC_SM, - PALETTE_DSC_QP, - PALETTE_DSC_INF, - PALETTE_DSC_TST, - PALETTE_SM_TXT, - PALETTE_QP_TXT, - PALETTE_INF_TXT, - PALETTE_DIC_TXT, - PALETTE_TST_TXT, - PALETTE_USR_TXT, -}; - -char const * const l_darkPalette[] = { -/* PALETTE_ERR_OUT */ B_RED F_BYELLOW, -/* PALETTE_INF_OUT */ B_DFLT B_GREEN F_BLACK, -/* PALETTE_TST_OUT */ B_BLACK F_BYELLOW, -/* PALETTE_USR_OUT */ B_BLACK F_WHITE, -/* PALETTE_TSTAMP */ B_BLACK F_CYAN, -/* PALETTE_DSC_SM */ B_BLUE F_WHITE, -/* PALETTE_DSC_QP */ B_DFLT B_MAGENTA F_WHITE, -/* PALETTE_DSC_INF */ B_DFLT B_BLUE F_BYELLOW, -/* PALETTE_DSC_TST */ B_DFLT B_CYAN F_BWHITE, -/* PALETTE_SM_TXT */ B_BLACK F_BWHITE, -/* PALETTE_QP_TXT */ B_BLACK F_WHITE, -/* PALETTE_INF_TXT */ B_DFLT B_BLACK F_BYELLOW, -/* PALETTE_DIC_TXT */ B_BLACK F_CYAN, -/* PALETTE_TST_TXT */ B_DFLT B_BLACK F_YELLOW, -/* PALETTE_USR_TXT */ B_DFLT B_WHITE F_BLACK, -}; - -char const * const l_lightPalette[] = { -/* PALETTE_ERR_OUT */ B_RED F_BYELLOW, -/* PALETTE_INF_OUT */ B_DFLT B_GREEN F_BLACK, -/* PALETTE_TST_OUT */ B_BLACK F_BYELLOW, -/* PALETTE_USR_OUT */ B_BLACK F_WHITE, -/* PALETTE_TSTAMP */ B_WHITE F_GRAY, -/* PALETTE_DSC_SM */ B_BLUE F_WHITE, -/* PALETTE_DSC_QP */ B_DFLT B_MAGENTA F_WHITE, -/* PALETTE_DSC_INF */ B_DFLT B_BLUE F_BYELLOW, -/* PALETTE_DSC_TST */ B_DFLT B_CYAN F_BWHITE, -/* PALETTE_SM_TXT */ B_WHITE F_BLUE, -/* PALETTE_QP_TXT */ B_WHITE F_MAGENTA, -/* PALETTE_INF_TXT */ B_DFLT B_WHITE F_RED, -/* PALETTE_DIC_TXT */ B_WHITE F_GRAY, -/* PALETTE_TST_TXT */ B_DFLT B_WHITE F_BLUE, -/* PALETTE_USR_TXT */ B_DFLT B_BLACK F_WHITE, -}; - -enum { - COL_TSTAMP = 11, - COL_DESC = 19, -}; - -static void colorPrintLn(void) { - if (QSPY_output.type == REG_OUT) { - /* timestamp */ - char ch = QSPY_output.buf[QS_LINE_OFFSET + COL_TSTAMP]; - QSPY_output.buf[QS_LINE_OFFSET + COL_TSTAMP] = '\0'; - (void)fputs(l_colorPalette[PALETTE_TSTAMP], stdout); - (void)fputs(&QSPY_output.buf[QS_LINE_OFFSET], stdout); - QSPY_output.buf[QS_LINE_OFFSET + COL_TSTAMP] = ch; - - switch (QSPY_getGroup(QSPY_output.rec)) { - case GRP_ERR: { - (void)fputs(l_colorPalette[PALETTE_ERR_OUT], stdout); - (void)fputs(&QSPY_output.buf[QS_LINE_OFFSET + COL_TSTAMP], stdout); - break; - } - case GRP_INF: { - /* description section */ - ch = QSPY_output.buf[QS_LINE_OFFSET + COL_DESC]; - QSPY_output.buf[QS_LINE_OFFSET + COL_DESC] = '\0'; - (void)fputs(l_colorPalette[PALETTE_DSC_INF], stdout); - (void)fputs(&QSPY_output.buf[QS_LINE_OFFSET + COL_TSTAMP], stdout); - QSPY_output.buf[QS_LINE_OFFSET + COL_DESC] = ch; - if (QSPY_output.len > COL_DESC) { - (void)fputs(l_colorPalette[PALETTE_INF_TXT], stdout); - (void)fputs(&QSPY_output.buf[QS_LINE_OFFSET + COL_DESC], stdout); - } - break; - } - case GRP_DIC: { - (void)fputs(l_colorPalette[PALETTE_DIC_TXT], stdout); - (void)fputs(&QSPY_output.buf[QS_LINE_OFFSET + COL_TSTAMP], stdout); - break; - } - case GRP_TST: { - /* description section */ - ch = QSPY_output.buf[QS_LINE_OFFSET + COL_DESC]; - QSPY_output.buf[QS_LINE_OFFSET + COL_DESC] = '\0'; - (void)fputs(l_colorPalette[PALETTE_DSC_TST], stdout); - (void)fputs(&QSPY_output.buf[QS_LINE_OFFSET + COL_TSTAMP], stdout); - QSPY_output.buf[QS_LINE_OFFSET + COL_DESC] = ch; - if (QSPY_output.len > COL_DESC) { - (void)fputs(l_colorPalette[PALETTE_TST_TXT], stdout); - (void)fputs(&QSPY_output.buf[QS_LINE_OFFSET + COL_DESC], stdout); - } - break; - } - case GRP_SM: { - /* description section */ - ch = QSPY_output.buf[QS_LINE_OFFSET + COL_DESC]; - QSPY_output.buf[QS_LINE_OFFSET + COL_DESC] = '\0'; - (void)fputs(l_colorPalette[PALETTE_DSC_SM], stdout); - (void)fputs(&QSPY_output.buf[QS_LINE_OFFSET + COL_TSTAMP], stdout); - QSPY_output.buf[QS_LINE_OFFSET + COL_DESC] = ch; - if (QSPY_output.len > COL_DESC) { - (void)fputs(l_colorPalette[PALETTE_SM_TXT], stdout); - (void)fputs(&QSPY_output.buf[QS_LINE_OFFSET + COL_DESC], stdout); - } - break; - } - case GRP_AO: - case GRP_EQ: - case GRP_MP: - case GRP_TE: - case GRP_QF: - case GRP_SC: - case GRP_SEM: - case GRP_MTX: { - /* description section */ - ch = QSPY_output.buf[QS_LINE_OFFSET + COL_DESC]; - QSPY_output.buf[QS_LINE_OFFSET + COL_DESC] = '\0'; - (void)fputs(l_colorPalette[PALETTE_DSC_QP], stdout); - (void)fputs(&QSPY_output.buf[QS_LINE_OFFSET + COL_TSTAMP], stdout); - QSPY_output.buf[QS_LINE_OFFSET + COL_DESC] = ch; - if (QSPY_output.len > COL_DESC) { - (void)fputs(l_colorPalette[PALETTE_QP_TXT], stdout); - (void)fputs(&QSPY_output.buf[QS_LINE_OFFSET + COL_DESC], stdout); - } - break; - } - case GRP_USR: /* intentionally fall through */ - default: { - (void)fputs(l_colorPalette[PALETTE_USR_TXT], stdout); - (void)fputs(&QSPY_output.buf[QS_LINE_OFFSET + COL_TSTAMP], stdout); - break; - } - } - (void)fputs(B_DFLT "\n", stdout); - } - else if (QSPY_output.type == INF_OUT) { - (void)fputs(l_colorPalette[PALETTE_INF_OUT], stdout); - (void)fputs(&QSPY_output.buf[QS_LINE_OFFSET], stdout); - (void)fputs(B_DFLT_EOL "\n", stdout); - } - else if (QSPY_output.type == ERR_OUT) { - (void)fputs(l_colorPalette[PALETTE_ERR_OUT], stdout); - (void)fputs(&QSPY_output.buf[QS_LINE_OFFSET], stdout); - (void)fputs(B_DFLT_EOL "\n", stdout); - } - else if (QSPY_output.type == TST_OUT) { - (void)fputs(l_colorPalette[PALETTE_TST_OUT], stdout); - (void)fputs(&QSPY_output.buf[QS_LINE_OFFSET], stdout); - (void)fputs(B_DFLT_EOL "\n", stdout); - } - else { /* USR_OUT */ - (void)fputs(l_colorPalette[PALETTE_USR_OUT], stdout); - (void)fputs(&QSPY_output.buf[QS_LINE_OFFSET], stdout); - (void)fputs(B_DFLT_EOL "\n", stdout); - } -} diff --git a/qspy/source/qspy_seq.c b/qspy/source/qspy_seq.c deleted file mode 100644 index d831d2a..0000000 --- a/qspy/source/qspy_seq.c +++ /dev/null @@ -1,611 +0,0 @@ -//============================================================================ -// QSPY software tracing host-side utility -// Copyright (C) 2005 Quantum Leaps, LLC. All rights reserved. -// -// SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-QL-commercial -// -// This software is dual-licensed under the terms of the open source GNU -// General Public License version 3 (or any later version), or alternatively, -// under the terms of one of the closed source Quantum Leaps commercial -// licenses. -// -// The terms of the open source GNU General Public License version 3 -// can be found at: -// -// The terms of the closed source Quantum Leaps commercial licenses -// can be found at: -// -// Redistributions in source code must retain this top-level comment block. -// Plagiarizing this software to sidestep the license obligations is illegal. -// -// Contact information: -// -// -//============================================================================ -//! @date Last updated on: 2024-06-21 -//! @version Last updated for version: 7.4.0 -//! -//! @file -//! @brief QSPY host utility: sequence diagram generation - -#include -#include - -#include "safe_std.h" /* "safe" and facilities */ -#include "qspy.h" /* QSPY data parser */ -#include "pal.h" /* QSPY PAL */ - -enum { - SEQ_ITEMS_MAX = 10, /* max number of items in the Sequence list */ -}; - -static FILE* l_seqFile; -static char l_seqList[QS_SEQ_LIST_LEN_MAX]; -static char l_seqNames[SEQ_ITEMS_MAX][QS_DNAME_LEN_MAX]; -static char l_seqTokens[QS_SEQ_LIST_LEN_MAX]; -static int l_seqNum; -static int l_seqLines; -static int l_seqSystem; -static DictEntry l_seqSto[SEQ_ITEMS_MAX]; -static Dictionary l_seqDict; - -/*..........................................................................*/ -char const *my_strtok(char *str, char delim) { - static char *next; - char const *token; - if (str != (char*)0) { - next = str; - } - token = next; - if (token != (char *)0) { - char *s = next; - for (;;) { - if (*s == delim) { - *s = '\0'; - next = s + 1; - break; - } - else if (*s == '\0') { - next = (char *)0; - break; - } - else { - ++s; - } - } - } - return token; -} -/*. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */ -void QSEQ_config(void* seqFile, char const * seqList) { - l_seqFile = (FILE *)seqFile; - l_seqNum = 0; - l_seqSystem = -1; - if ((seqList != (void*)0) && (*seqList != '\0')) { - STRNCPY_S(l_seqList, sizeof(l_seqList), seqList); - - /* split the comma-separated 'seqList' into string array l_seqNames[] */ - STRNCPY_S(l_seqTokens, sizeof(l_seqTokens), l_seqList); - char const *token; - for (token = my_strtok(l_seqTokens, ','); - (token != (char*)0) && (l_seqNum < SEQ_ITEMS_MAX); - token = my_strtok((char *)0, ','), ++l_seqNum) - { - if (strncmp(token, "?", 2) == 0) { /* system border? */ - l_seqSystem = l_seqNum; - } - STRNCPY_S(l_seqNames[l_seqNum], sizeof(l_seqNames[l_seqNum]), - token); - } - if (token != (char*)0) { - SNPRINTF_LINE(" Too many names in the Sequence list\n" - " %s\n", l_seqList); - QSPY_printInfo(); - } - else { - l_seqLines = 0; - QSEQ_genHeader(); - } - } - - Dictionary_ctor(&l_seqDict, l_seqSto, - sizeof(l_seqSto) / sizeof(l_seqSto[0])); - Dictionary_config(&l_seqDict, QSPY_conf.objPtrSize); -} - -enum { - SEQ_LANE_WIDTH = 20, - SEQ_LEFT_OFFSET = 19, /* offset to the middle of the first lane */ - SEQ_BOX_WIDTH = SEQ_LANE_WIDTH - 3, - SEQ_LABEL_MAX = SEQ_LANE_WIDTH - 5, - SEQ_HEADER_EVERY = 100, /* # lines between repeated headers */ -}; - -/*..........................................................................*/ -void QSEQ_configFile(void* seqFile) { - if (l_seqFile != (FILE*)0) { - (void)fclose(l_seqFile); - } - l_seqFile = (FILE*)seqFile; - l_seqLines = 0; - QSEQ_genHeader(); -} -/*..........................................................................*/ -bool QSEQ_isActive(void) { - return l_seqFile != (FILE*)0; -} -/*..........................................................................*/ -void QSEQ_dictionaryReset(void) { - Dictionary_reset(&l_seqDict); -} -/*..........................................................................*/ -void QSEQ_updateDictionary(char const* name, KeyType key) { - int n; - for (n = 0; n < l_seqNum; ++n) { /* brute-force search */ - if (strncmp(l_seqNames[n], name, QS_DNAME_LEN_MAX) == 0) { - char str[2]; - str[0] = (char)n; - str[1] = '\0'; - Dictionary_put(&l_seqDict, key, str); - break; - } - } -} -/*..........................................................................*/ -int QSEQ_find(KeyType key) { - int idx = Dictionary_find(&l_seqDict, key); - if (idx >= 0) { - char const *str = Dictionary_at(&l_seqDict, idx); - return (int)str[0]; - } - return -1; -} -/*..........................................................................*/ -void QSEQ_genHeader(void) { - if ((l_seqNum == 0) || (l_seqFile == (FILE*)0)) { - return; - } - static char seq_header[(SEQ_LEFT_OFFSET - + SEQ_LANE_WIDTH*SEQ_ITEMS_MAX + 4)*3 + 1]; - static uint32_t seq_header_len = 0; - if (seq_header_len == 0) { /* not initialized yet? */ - int n; - int i; - int left_box_edge; - char *seq_line = &seq_header[0]; - - /* clear the whole header */ - for (i = 0; i < (int)sizeof(seq_header); ++i) { - seq_header[i] = ' '; - } - - /* top box edges... */ - left_box_edge = SEQ_LEFT_OFFSET - SEQ_BOX_WIDTH/2; - for (n = 0; n < l_seqNum; ++n, left_box_edge += SEQ_LANE_WIDTH) { - i = left_box_edge; - seq_line[i] = '+'; - for (i += 1; i < left_box_edge - 1 + SEQ_BOX_WIDTH; ++i) { - seq_line[i] = '-'; - } - seq_line[i - SEQ_BOX_WIDTH / 2] = '+'; - seq_line[i] = '+'; i += 1; - } - seq_line[i] = '\n'; - seq_line = &seq_line[i + 1]; - - /* box content... */ - left_box_edge = SEQ_LEFT_OFFSET - SEQ_BOX_WIDTH/2; - for (n = 0; n < l_seqNum; ++n, left_box_edge += SEQ_LANE_WIDTH) { - seq_line[left_box_edge] = '|'; - - /* write the name */ - char const *name = l_seqNames[n]; - int len = (int)strlen(name); - i = left_box_edge + 1; - if (len < SEQ_BOX_WIDTH - 2) { - i += (SEQ_BOX_WIDTH - 2 - len)/2; /* center the name */ - } - for (; (*name != '\0') - && (i < left_box_edge + SEQ_BOX_WIDTH - 1); - ++name, ++i) - { - seq_line[i] = *name; - } - - i = left_box_edge - 1 + SEQ_BOX_WIDTH; - seq_line[i] = '|'; i += 1; - } - seq_line[i] = '\n'; - seq_line = &seq_line[i + 1]; - - /* bottom box edges... */ - left_box_edge = SEQ_LEFT_OFFSET - SEQ_BOX_WIDTH/2; - for (n = 0; n < l_seqNum; ++n, left_box_edge += SEQ_LANE_WIDTH) { - i = left_box_edge; - seq_line[i] = '+'; - for (i += 1; i < left_box_edge - 1 + SEQ_BOX_WIDTH; ++i) { - seq_line[i] = '-'; - } - seq_line[i - SEQ_BOX_WIDTH/2] = '+'; - seq_line[i] = '+'; i += 1; - } - seq_line[i] = '\n'; - seq_header_len = (uint32_t)(&seq_line[i + 1] - &seq_header[0]); - } - if (l_seqLines == 0) { - FPRINTF_S(l_seqFile, "-g %s\n\n", l_seqList); - } - (void)fwrite(seq_header, 1, seq_header_len, l_seqFile); - l_seqLines += 3; -} -/*..........................................................................*/ -void QSEQ_genPost(uint32_t tstamp, int src, int dst, char const* sig, - bool isAttempt) -{ - if ((l_seqNum == 0) || (l_seqFile == (FILE*)0)) { - return; - } - if (src < 0) { - src = l_seqSystem; - } - if (dst < 0) { - dst = l_seqSystem; - } - if ((src < 0) || (dst < 0)) { - return; - } - if ((src == l_seqSystem) && (dst == l_seqSystem)) { - return; - } - if ((l_seqLines % SEQ_HEADER_EVERY) == 0) { - QSEQ_genHeader(); - } - char seq_line[SEQ_LEFT_OFFSET+ SEQ_LABEL_MAX - + SEQ_LANE_WIDTH*SEQ_ITEMS_MAX]; - uint32_t seq_line_len; - int i = 0; - int j; - - (void)SNPRINTF_S(&seq_line[i], (int)sizeof(seq_line), "%010u", - (unsigned)tstamp); - i += 10; - for (; i < SEQ_LEFT_OFFSET + (l_seqNum - 1)*SEQ_LANE_WIDTH; ++i) { - seq_line[i] = ((i - SEQ_LEFT_OFFSET)%SEQ_LANE_WIDTH) == 0 - ? '|' - : ' '; - } - seq_line[i] = '|'; i += 1; - seq_line[i] = '\n'; - seq_line_len = i + 1; - char dash = isAttempt ? '~' : '-'; - if (src < dst) { - for (i = SEQ_LEFT_OFFSET + src*SEQ_LANE_WIDTH; - i < SEQ_LEFT_OFFSET + dst*SEQ_LANE_WIDTH; ++i) - { - seq_line[i] = ((i - SEQ_LEFT_OFFSET) % SEQ_LANE_WIDTH) == 0 - ? '+' - : dash; - } - seq_line[i - 1] = '>'; - /* write the signal */ - for (i = SEQ_LEFT_OFFSET + 3 + src*SEQ_LANE_WIDTH; - ((*sig != '\0') - && (i < SEQ_LEFT_OFFSET + SEQ_LABEL_MAX + 3 - + src*SEQ_LANE_WIDTH)); - ++i, ++sig) - { - seq_line[i] = *sig; - } - } - else if (src > dst) { - for (i = SEQ_LEFT_OFFSET + dst*SEQ_LANE_WIDTH; - i < SEQ_LEFT_OFFSET + src* SEQ_LANE_WIDTH; ++i) - { - seq_line[i] = ((i - SEQ_LEFT_OFFSET)% SEQ_LANE_WIDTH) == 0 - ? '+' - : dash; - } - seq_line[SEQ_LEFT_OFFSET + 1 + dst*SEQ_LANE_WIDTH] = '<'; - seq_line[SEQ_LEFT_OFFSET + dst*SEQ_LANE_WIDTH] = '|'; - - /* write the signal */ - int len = (int)strlen(sig); - if (len > SEQ_LABEL_MAX) { - len = SEQ_LABEL_MAX; - } - i = SEQ_LEFT_OFFSET - 2 + src*SEQ_LANE_WIDTH - len; - j = i + SEQ_LABEL_MAX; - for (; (*sig != '\0') && (i < j); ++i, ++sig) { - seq_line[i] = *sig; - } - } - else { /* self-posting */ - /* write the signal */ - i = SEQ_LEFT_OFFSET + 3 + src*SEQ_LANE_WIDTH; - j = i + SEQ_LABEL_MAX; - for (; (*sig != '\0') && (i < j); ++i, ++sig) { - seq_line[i] = *sig; - } - seq_line[i] = ']'; i += 1; - if (seq_line_len <= (uint32_t)i) { - seq_line[i] = '\n'; - seq_line_len = i + 1; - } - i = SEQ_LEFT_OFFSET + src*SEQ_LANE_WIDTH; - seq_line[i + 1] = '<'; - seq_line[i + 2] = '-'; - } - if (l_seqSystem >= 0) { - seq_line[SEQ_LEFT_OFFSET + l_seqSystem*SEQ_LANE_WIDTH] = '/'; - } - seq_line[SEQ_LEFT_OFFSET + src*SEQ_LANE_WIDTH] = isAttempt ? 'A' : '*'; - Q_ASSERT(seq_line_len <= sizeof(seq_line)); - (void)fwrite(seq_line, 1, seq_line_len, l_seqFile); - l_seqLines += 1; -} -/*..........................................................................*/ -void QSEQ_genPostLIFO(uint32_t tstamp, int src, char const* sig) { - if ((l_seqNum == 0) || (l_seqFile == (FILE*)0)) { - return; - } - if ((l_seqLines % SEQ_HEADER_EVERY) == 0) { - QSEQ_genHeader(); - } - char seq_line[SEQ_LEFT_OFFSET + SEQ_LABEL_MAX - + SEQ_LANE_WIDTH*SEQ_ITEMS_MAX]; - uint32_t seq_line_len; - int i = 0; - int j; - - (void)SNPRINTF_S(&seq_line[i], sizeof(seq_line), "%010u", - (unsigned)tstamp); - i += 10; - for (; i < SEQ_LEFT_OFFSET + (l_seqNum - 1)*SEQ_LANE_WIDTH; ++i) { - seq_line[i] = ((i - SEQ_LEFT_OFFSET) % SEQ_LANE_WIDTH) == 0 - ? '|' - : ' '; - } - seq_line[i] = '|'; i += 1; - seq_line[i] = '\n'; - seq_line_len = i + 1; - - /* write the signal */ - i = SEQ_LEFT_OFFSET + 3 + src * SEQ_LANE_WIDTH; - j = i + SEQ_LABEL_MAX; - for (; (*sig != '\0') && (i <= j); ++i, ++sig) { - seq_line[i] = *sig; - } - seq_line[i] = ']'; i += 1; - if (seq_line_len <= (uint32_t)i) { - seq_line[i] = '\n'; - seq_line_len = i + 1; - } - i = SEQ_LEFT_OFFSET + src * SEQ_LANE_WIDTH; - seq_line[i + 1] = '<'; - seq_line[i + 2] = '='; - - if (l_seqSystem >= 0) { - seq_line[SEQ_LEFT_OFFSET + l_seqSystem*SEQ_LANE_WIDTH] = '/'; - } - seq_line[SEQ_LEFT_OFFSET + src * SEQ_LANE_WIDTH] = '*'; - Q_ASSERT(seq_line_len <= sizeof(seq_line)); - (void)fwrite(seq_line, 1, seq_line_len, l_seqFile); - l_seqLines += 1; -} -/*..........................................................................*/ -void QSEQ_genPublish(uint32_t tstamp, int obj, char const* sig) { - if ((l_seqNum == 0) || (l_seqFile == (FILE*)0)) { - return; - } - if (obj < 0) { - obj = l_seqSystem; - } - if (obj < 0) { - return; - } - if ((l_seqLines % SEQ_HEADER_EVERY) == 0) { - QSEQ_genHeader(); - } - char seq_line[SEQ_LEFT_OFFSET + SEQ_LABEL_MAX - + SEQ_LANE_WIDTH * SEQ_ITEMS_MAX]; - uint32_t seq_line_len; - int i = 0; - int j; - - (void)SNPRINTF_S(&seq_line[i], sizeof(seq_line), "%010u", - (unsigned)tstamp); - i += 10; - for (; - i < SEQ_LEFT_OFFSET - SEQ_LANE_WIDTH + SEQ_BOX_WIDTH/2 - + l_seqNum*SEQ_LANE_WIDTH; ++i) - { - seq_line[i] = ((i - SEQ_LEFT_OFFSET)%SEQ_LANE_WIDTH) == 0 - ? '|' - : ((i % 2) ? '.' : ' '); - } - seq_line[i] = '\n'; - seq_line_len = i + 1; - i = SEQ_LEFT_OFFSET + obj * SEQ_LANE_WIDTH; - - /* write the signal */ - int len = (int)strlen(sig); - if (len > SEQ_LABEL_MAX) { - len = SEQ_LABEL_MAX; - } - if (obj < l_seqNum - 1) { /* signal to the right of '*' */ - i = SEQ_LEFT_OFFSET + 3 + obj*SEQ_LANE_WIDTH; - j = i + SEQ_LABEL_MAX; - for (; (*sig != '\0') && (i <= j); ++i, ++sig) { - seq_line[i] = *sig; - } - } - else { /* signal to the left of '*' */ - i = SEQ_LEFT_OFFSET - 2 + obj*SEQ_LANE_WIDTH - len; - j = i + SEQ_LABEL_MAX; - for (; (*sig != '\0') && (i <= j); ++i, ++sig) { - seq_line[i] = *sig; - } - } - if (l_seqSystem >= 0) { - seq_line[SEQ_LEFT_OFFSET + l_seqSystem*SEQ_LANE_WIDTH] = '/'; - } - seq_line[SEQ_LEFT_OFFSET + obj * SEQ_LANE_WIDTH] = '*'; - Q_ASSERT(seq_line_len <= sizeof(seq_line)); - (void)fwrite(seq_line, 1, seq_line_len, l_seqFile); - l_seqLines += 1; -} -/*..........................................................................*/ -void QSEQ_genTran(uint32_t tstamp, int obj, char const* state) { - if ((l_seqNum == 0) || (l_seqFile == (FILE*)0)) { - return; - } - if ((l_seqLines % SEQ_HEADER_EVERY) == 0) { - QSEQ_genHeader(); - } - char seq_line[SEQ_LEFT_OFFSET + SEQ_LABEL_MAX - + SEQ_LANE_WIDTH*SEQ_ITEMS_MAX]; - uint32_t seq_line_len; - int i = 0; - int j; - - (void)SNPRINTF_S(&seq_line[i], sizeof(seq_line), "%010u", - (unsigned)tstamp); - i += 10; - for (; i < SEQ_LEFT_OFFSET + (l_seqNum - 1)*SEQ_LANE_WIDTH; ++i) { - seq_line[i] = ((i - SEQ_LEFT_OFFSET) % SEQ_LANE_WIDTH) == 0 - ? '|' - : ' '; - } - seq_line[i] = '|'; i += 1; - seq_line[i] = '\n'; - seq_line_len = i + 1; - - /* write the state annotation... */ - /* 1. scan the "state" string for special char and find its length */ - i = 0; - j = 0; - for (char const *s = state; *s != '\0'; ++s, ++i) { - if (j == 0) { /* special sequence not found yet? */ - if (*s == '_') { /* first underscore? */ - j = i + 1; /* one beyond the first underscore */ - } - else if (*s == ':') { /* first colon? */ - if (*(s + 1) == ':') { /* second colon? */ - j = i + 2; /* two beyond the first colon */ - } - } - } - } - - /* 2. adjust "state" to one beyond special char, for example: - * from state == "MyStateMachine_active_123" -> s == "active_123" - * from state == "MyStateMachine::active_123" -> s == "active_123" - */ - state = &state[j]; /* adjusted beginning of the state-annotation */ - int len = i - j; /* length of the adjusted "state" annotation */ - if (len > SEQ_LABEL_MAX) { - len = SEQ_LABEL_MAX; - } - - /* 3. copy the adjusted state-annotation state to seq_line[] */ - i = SEQ_LEFT_OFFSET + obj* SEQ_LANE_WIDTH - (len + 1)/2; - j = i + SEQ_LABEL_MAX; - seq_line[i] = '<'; i += 1; - for (; (*state != '\0') && (i <= j); ++i, ++state) { - seq_line[i] = *state; - } - seq_line[i] = '>'; i += 1; - if (seq_line_len <= (uint32_t)i) { - seq_line[i] = '\n'; - seq_line_len = i + 1; - } - if (l_seqSystem >= 0) { - seq_line[SEQ_LEFT_OFFSET + l_seqSystem*SEQ_LANE_WIDTH] = '/'; - } - Q_ASSERT(seq_line_len <= sizeof(seq_line)); - (void)fwrite(seq_line, 1, seq_line_len, l_seqFile); - l_seqLines += 1; -} -/*..........................................................................*/ -void QSEQ_genAnnotation(uint32_t tstamp, int obj, char const* ann) { - if ((l_seqNum == 0) || (l_seqFile == (FILE*)0)) { - return; - } - if ((l_seqLines % SEQ_HEADER_EVERY) == 0) { - QSEQ_genHeader(); - } - char seq_line[SEQ_LEFT_OFFSET + SEQ_LABEL_MAX - + SEQ_LANE_WIDTH*SEQ_ITEMS_MAX]; - uint32_t seq_line_len; - int i = 0; - int j; - - (void)SNPRINTF_S(&seq_line[i], sizeof(seq_line), "%010u", - (unsigned)tstamp); - i += 10; - for (; i < SEQ_LEFT_OFFSET + (l_seqNum - 1)*SEQ_LANE_WIDTH; ++i) { - seq_line[i] = ((i - SEQ_LEFT_OFFSET)%SEQ_LANE_WIDTH) == 0 - ? '|' - : ' '; - } - seq_line[i] = '|'; i += 1; - seq_line[i] = '\n'; - seq_line_len = i + 1; - /* write the annotation */ - int len = (int)strlen(ann); - if (len > SEQ_LABEL_MAX) { - len = SEQ_LABEL_MAX; - } - i = SEQ_LEFT_OFFSET + obj*SEQ_LANE_WIDTH - (len + 1) / 2; - j = i + SEQ_LABEL_MAX; - seq_line[i] = '('; i += 1; - for (; (*ann != '\0') && (i <= j); ++i, ++ann) { - seq_line[i] = *ann; - } - seq_line[i] = ')'; i += 1; - if (seq_line_len <= (uint32_t)i) { - seq_line[i] = '\n'; - seq_line_len = i + 1; - } - if (l_seqSystem >= 0) { - seq_line[SEQ_LEFT_OFFSET + l_seqSystem*SEQ_LANE_WIDTH] = '/'; - } - Q_ASSERT(seq_line_len <= sizeof(seq_line)); - (void)fwrite(seq_line, 1, seq_line_len, l_seqFile); - l_seqLines += 1; -} -/*..........................................................................*/ -void QSEQ_genTick(uint32_t rate, uint32_t nTick) { - if ((l_seqNum == 0) || (l_seqFile == (FILE*)0)) { - return; - } - if ((l_seqLines % SEQ_HEADER_EVERY) == 0) { - QSEQ_genHeader(); - } - char seq_line[SEQ_LEFT_OFFSET + SEQ_LABEL_MAX - + SEQ_LANE_WIDTH*SEQ_ITEMS_MAX]; - uint32_t seq_line_len; - int i = 0; - - (void)SNPRINTF_S(&seq_line[i], sizeof(seq_line), - "########## Tick<%1u> Ctr=%010u", - (unsigned)rate, (unsigned)nTick); - i += 34; - for (; - i < SEQ_LEFT_OFFSET - SEQ_LANE_WIDTH + SEQ_BOX_WIDTH/2 - + l_seqNum*SEQ_LANE_WIDTH; ++i) - { - seq_line[i] = ((i - SEQ_LEFT_OFFSET) % SEQ_LANE_WIDTH) == 0 - ? '|' - : ((i % 2) ? ' ' : '\''); - } - if (l_seqSystem >= 0) { - seq_line[SEQ_LEFT_OFFSET + l_seqSystem*SEQ_LANE_WIDTH] = '/'; - } - seq_line[i] = '\n'; - seq_line_len = i + 1; - Q_ASSERT(seq_line_len <= sizeof(seq_line)); - (void)fwrite(seq_line, 1, seq_line_len, l_seqFile); - l_seqLines += 1; -} - diff --git a/qspy/source/qspy_tx.c b/qspy/source/qspy_tx.c deleted file mode 100644 index 2343e37..0000000 --- a/qspy/source/qspy_tx.c +++ /dev/null @@ -1,346 +0,0 @@ -//============================================================================ -// QSPY software tracing host-side utility -// Copyright (C) 2005 Quantum Leaps, LLC. All rights reserved. -// -// SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-QL-commercial -// -// This software is dual-licensed under the terms of the open source GNU -// General Public License version 3 (or any later version), or alternatively, -// under the terms of one of the closed source Quantum Leaps commercial -// licenses. -// -// The terms of the open source GNU General Public License version 3 -// can be found at: -// -// The terms of the closed source Quantum Leaps commercial licenses -// can be found at: -// -// Redistributions in source code must retain this top-level comment block. -// Plagiarizing this software to sidestep the license obligations is illegal. -// -// Contact information: -// -// -//============================================================================ -//! @date Last updated on: 2024-02-23 -//! @version Last updated for version: 7.3.3 -//! -//! @file -//! @brief QSPY transmit facilities - -#include -#include -#include -#include -#include - -#include "safe_std.h" /* "safe" and facilities */ -#include "qspy.h" /* QSPY data parser */ -#include "pal.h" /* Platform Abstraction Layer */ - -#define Q_SPY 1 // this is QP implementation -#define QP_IMPL 1 // this is QP implementation -typedef uint32_t QSObj; // dummy definition for including "qpc_qs.h" -typedef uint32_t QEvt; // dummy definition for including "qpc_qs.h" -#include "qpc_qs.h" // QS target-resident interface -#include "qpc_qs_pkg.h" // QS package-scope interface - -/*..........................................................................*/ -static uint8_t l_dstBuf[1024]; /* for encoding from FE to Target */ -static uint8_t l_txTargetSeq; /* transmit Target sequence number */ -static ObjType l_currSM; /* current State Machine Object from FE */ - -/****************************************************************************/ -/*! helper macro to insert an un-escaped byte into the QSPY buffer */ -#define QSPY_INSERT_BYTE(b_) \ - *dst++ = (b_); \ - if ((uint8_t)(dst - &dstBuf[0]) >= dstSize) { \ - return 0U; \ - } - -/*! helper macro to insert an escaped byte into the QS buffer */ -#define QSPY_INSERT_ESC_BYTE(b_) \ - chksum = (uint8_t)(chksum + (b_)); \ - if (((b_) != QS_FRAME) && ((b_) != QS_ESC)) { \ - QSPY_INSERT_BYTE(b_) \ - } \ - else { \ - QSPY_INSERT_BYTE(QS_ESC) \ - QSPY_INSERT_BYTE((uint8_t)((b_) ^ QS_ESC_XOR)) \ - } - -/*..........................................................................*/ -uint32_t QSPY_encode(uint8_t *dstBuf, uint32_t dstSize, - uint8_t const *srcBuf, uint32_t srcBytes) -{ - uint8_t chksum = 0U; - uint8_t *dst = &dstBuf[0]; - uint8_t const *src = &srcBuf[1]; /* skip the sequence from the source */ - - --srcBytes; /* account for skipping the sequence number in the source */ - - /* supply the sequence number */ - ++l_txTargetSeq; - uint8_t b = l_txTargetSeq; - QSPY_INSERT_ESC_BYTE(b); /* insert escaped sequence */ - - for (; srcBytes > 0U; ++src, --srcBytes) { - b = *src; - QSPY_INSERT_ESC_BYTE(b) /* insert all escaped bytes */ - } - - b = chksum; - b ^= 0xFFU; /* invert the bits of the checksum */ - QSPY_INSERT_ESC_BYTE(b) /* insert the escaped checksum */ - QSPY_INSERT_BYTE(QS_FRAME) /* insert un-escaped frame */ - - return (uint32_t)(dst - &dstBuf[0]); /* number of bytes in the destination */ -} -/*..........................................................................*/ -uint32_t QSPY_encodeResetCmd(uint8_t *dstBuf, uint32_t dstSize) { - static uint8_t const s_QS_RX_RESET[] = { 0x00U, QS_RX_RESET }; - return QSPY_encode(dstBuf, dstSize, - s_QS_RX_RESET, sizeof(s_QS_RX_RESET)); -} -/*..........................................................................*/ -uint32_t QSPY_encodeInfoCmd(uint8_t *dstBuf, uint32_t dstSize) { - static uint8_t const s_QS_RX_INFO[] = { 0x00U, QS_RX_INFO }; - return QSPY_encode(dstBuf, dstSize, - s_QS_RX_INFO, sizeof(s_QS_RX_INFO)); -} -/*..........................................................................*/ -uint32_t QSPY_encodeTickCmd (uint8_t *dstBuf, uint32_t dstSize, uint8_t rate){ - uint8_t a_QS_RX_TICK[] = { 0x00U, QS_RX_TICK, 0U }; - a_QS_RX_TICK[2] = rate; - return QSPY_encode(dstBuf, dstSize, - a_QS_RX_TICK, sizeof(a_QS_RX_TICK)); -} -/*..........................................................................*/ -void QSPY_sendEvt(QSpyRecord const * const qrec) { - unsigned sigSize = QSPY_conf.sigSize; - unsigned n = 3U + sigSize; - unsigned len = (qrec->start[n] | (qrec->start[n + 1U] << 8)); - - n += (2U + len); - if (n >= qrec->tot_len - 2U) { - SNPRINTF_LINE(" ERROR %s", - "command 'SEND_EVENT' incorrect"); - QSPY_printError(); - return; - } - else { - char const *name = (char const *)&qrec->start[n]; - SigType sig = QSPY_findSig(name, l_currSM); - if (sig == SIG_NOT_FOUND) { - SNPRINTF_LINE(" ERROR " - "Signal Dictionary not found for Sig=%s", name); - QSPY_printError(); - } - else { - uint32_t nBytes; - uint8_t *evtPkt = (uint8_t *)&qrec->start[0]; /*cast const away*/ - - evtPkt[0] = 0U; - evtPkt[1] = (uint8_t)QS_RX_EVENT; - - /* insert the found Signal 'sig' into the binary record */ - evtPkt[3] = (uint8_t)(sig & 0xFFU); - if (sigSize >= 2) { - sig >>= 8; - evtPkt[4] = (uint8_t)(sig & 0xFFU); - if (sigSize == 4) { - sig >>= 8; - evtPkt[5] = (uint8_t)(sig & 0xFFU); - sig >>= 8; - evtPkt[6] = (uint8_t)(sig & 0xFFU); - } - } - - /* encode the QS_RX_EVENT record to the Target */ - nBytes = QSPY_encode(l_dstBuf, sizeof(l_dstBuf), evtPkt, n); - if (nBytes == 0) { - SNPRINTF_LINE(" ERROR %s", - "Encoding QS_RX_EVENT"); - QSPY_printError(); - } - else { - (void)(*PAL_vtbl.send2Target)(l_dstBuf, nBytes); - /* send2Target() reports error by itself */ - } - } - } -} -/*..........................................................................*/ -void QSPY_sendObj(QSpyRecord const * const qrec) { - unsigned objPtrSize = QSPY_conf.objPtrSize; - unsigned n = 3U + objPtrSize; - char const *name = (char const *)&qrec->start[n]; - - KeyType key = QSPY_findObj(name); - - if (key == KEY_NOT_FOUND) { - SNPRINTF_LINE(" ERROR Object Dictionary not found for " - "Name=%s", name); - QSPY_printError(); - } - else { - uint32_t nBytes; - uint8_t *objPkt = (uint8_t *)&qrec->start[0]; /* cast const away */ - - objPkt[0] = 0U; - if (qrec->rec == QSPY_SEND_AO_FILTER) { - objPkt[1] = (uint8_t)QS_RX_AO_FILTER; - } - else if (qrec->rec == QSPY_SEND_CURR_OBJ) { - objPkt[1] = (uint8_t)QS_RX_CURR_OBJ; - - /* see enum QSpyObjKind in qs_copy.h */ - switch (qrec->start[2]) { /* object-kind */ - case SM_OBJ: - case AO_OBJ: - case SM_AO_OBJ: - l_currSM = (ObjType)key; /* store for QSPY_sendEvent() */ - break; - case MP_OBJ: - case EQ_OBJ: - case TE_OBJ: - case AP_OBJ: - break; - default: - SNPRINTF_LINE(" ERROR " - "Incorrect Object Kind=%d", qrec->start[2]); - QSPY_printError(); - break; - } - } - else { - Q_ASSERT(0); /* QSPY_sendObj() should not have been called */ - } - - if (objPtrSize >= 2) { - objPkt[3] = (uint8_t)(key & 0xFFU); key >>= 8; - objPkt[4] = (uint8_t)(key & 0xFFU); key >>= 8; - if (objPtrSize >= 4) { - objPkt[5] = (uint8_t)(key & 0xFFU); key >>= 8; - objPkt[6] = (uint8_t)(key & 0xFFU); key >>= 8; - if (objPtrSize == 8) { - objPkt[7] = (uint8_t)(key & 0xFFU); key >>= 8; - objPkt[8] = (uint8_t)(key & 0xFFU); key >>= 8; - objPkt[9] = (uint8_t)(key & 0xFFU); key >>= 8; - objPkt[10]= (uint8_t)(key & 0xFFU); key >>= 8; - } - } - } - - nBytes = QSPY_encode(l_dstBuf, sizeof(l_dstBuf), objPkt, n); - if (nBytes == 0) { - SNPRINTF_LINE(" ERROR %s", - "Encoding QS_RX_CURR_OBJ"); - QSPY_onPrintLn(); - } - else { - (void)(*PAL_vtbl.send2Target)(l_dstBuf, nBytes); - /* send2Target() reports error by itself */ - } - } -} -/*..........................................................................*/ -void QSPY_sendCmd(QSpyRecord const * const qrec) { - unsigned n = 2U + 1U + 3U*4U; - char const *name = (char const *)&qrec->start[n]; - - KeyType key; - if (QSPY_conf.version < 714U) { - key = QSPY_findUsr(name); - } - else { - key = QSPY_findEnum(name, QS_CMD); - } - - if (key == KEY_NOT_FOUND) { - SNPRINTF_LINE(" ERROR Command Dictionary not found for " - "Name=%s", name); - QSPY_printError(); - return; - } - - uint32_t nBytes; - uint8_t *cmdPkt = (uint8_t *)&qrec->start[0]; /* cast const away */ - - cmdPkt[0] = 0U; - cmdPkt[1] = (uint8_t)QS_RX_COMMAND; - cmdPkt[2] = (uint8_t)key; - - nBytes = QSPY_encode(l_dstBuf, sizeof(l_dstBuf), cmdPkt, n); - if (nBytes == 0) { - SNPRINTF_LINE(" ERROR %s", - "Encoding QS_RX_COMMAND"); - QSPY_onPrintLn(); - } - else { - (void)(*PAL_vtbl.send2Target)(l_dstBuf, nBytes); - /* send2Target() reports error by itself */ - } -} -/*..........................................................................*/ -void QSPY_sendTP(QSpyRecord const * const qrec) { - unsigned funPtrSize = QSPY_conf.funPtrSize; - unsigned n = 2U + 4U + funPtrSize; - char const *name = (char const *)&qrec->start[n]; - - KeyType key = QSPY_findFun(name); - - if (key == KEY_NOT_FOUND) { - SNPRINTF_LINE(" ERROR Function Dictionary not found for " - "Name=%s", name); - QSPY_printError(); - } - else { - uint32_t nBytes; - uint8_t *tpPkt = (uint8_t *)&qrec->start[0]; /* cast const away */ - - tpPkt[0] = 0U; - tpPkt[1] = (uint8_t)QS_RX_TEST_PROBE; - - if (funPtrSize >= 2) { - tpPkt[6] = (uint8_t)(key & 0xFFU); key >>= 8; - tpPkt[7] = (uint8_t)(key & 0xFFU); key >>= 8; - if (funPtrSize >= 4) { - tpPkt[8] = (uint8_t)(key & 0xFFU); key >>= 8; - tpPkt[9] = (uint8_t)(key & 0xFFU); key >>= 8; - if (funPtrSize == 8) { - tpPkt[10] = (uint8_t)(key & 0xFFU); key >>= 8; - tpPkt[11] = (uint8_t)(key & 0xFFU); key >>= 8; - tpPkt[12] = (uint8_t)(key & 0xFFU); key >>= 8; - tpPkt[13] = (uint8_t)(key & 0xFFU); key >>= 8; - } - } - } - - nBytes = QSPY_encode(l_dstBuf, sizeof(l_dstBuf), tpPkt, n); - if (nBytes == 0) { - SNPRINTF_LINE(" ERROR %s", - "Encoding QS_RX_PROBE_POINT"); - QSPY_onPrintLn(); - } - else { - (void)(*PAL_vtbl.send2Target)(l_dstBuf, nBytes); - /* send2Target() reports error by itself */ - } - } -} -/*..........................................................................*/ -void QSPY_showNote(QSpyRecord const * const qrec) { - char const *note = (char const *)&qrec->start[3]; - SNPRINTF_LINE("%s", note); - switch (qrec->start[2]) { - case 0xFFU: QSPY_output.type = TST_OUT; break; - default: QSPY_output.type = USR_OUT; break; - } - QSPY_onPrintLn(); -} -/*..........................................................................*/ -void QSPY_txReset(void) { - l_txTargetSeq = 0U; - l_currSM = (ObjType)(~0U); /* invalidate */ -} diff --git a/qspy/test/dict/dpp-qpc.bin b/qspy/test/dict/dpp-qpc.bin new file mode 100644 index 0000000..b592739 Binary files /dev/null and b/qspy/test/dict/dpp-qpc.bin differ diff --git a/qspy/test/dict/dpp-qpc.dic b/qspy/test/dict/dpp-qpc.dic new file mode 100644 index 0000000..7567e15 --- /dev/null +++ b/qspy/test/dict/dpp-qpc.dic @@ -0,0 +1,59 @@ +-d241031 +-v800 +-q1 +-T4 +-O4 +-F4 +-S2 +-E2 +-Q1 +-P2 +-B2 +-C4 +-t241008_210100 + +Obj-Dic: +4 +0x08004F1C l_EXTI0_1_IRQHandler +0x08004F20 l_SysTick_Handler +0x08005140 QS_RX +0x20000E04 Philo_inst[0] +0x20000E30 Philo_inst[0].timeEvt +0x20000E54 Philo_inst[1] +0x20000E80 Philo_inst[1].timeEvt +0x20000EA4 Philo_inst[2] +0x20000ED0 Philo_inst[2].timeEvt +0x20000EF4 Philo_inst[3] +0x20000F20 Philo_inst[3].timeEvt +0x20000F44 Philo_inst[4] +0x20000F70 Philo_inst[4].timeEvt +0x20000F94 Table_inst +0x20001050 EvtPool1 +*** +Fun-Dic: +4 +0x08000A99 Philo_eating +0x08000B39 Philo_thinking +0x08000BC5 Philo_hungry +0x08000D15 Table_active +0x08000D41 Table_paused +0x08000E41 Table_serving +0x08001359 QHsm_top +*** +Usr-Dic: +1 +0x00000064 PHILO_STAT +0x00000065 PAUSED_STAT +0x00000066 CONTEXT_SW +0x0000007C QUTEST_ON_POST +*** +Sig-Dic: +4 +00000004 0x00000000 EAT_SIG +00000005 0x00000000 DONE_SIG +00000006 0x00000000 PAUSE_SIG +00000007 0x00000000 SERVE_SIG +00000008 0x00000000 TEST_SIG +00000010 0x00000000 TIMEOUT_SIG +00000011 0x00000000 HUNGRY_SIG +*** diff --git a/qspy/test/dict/dpp-qpcpp.bin b/qspy/test/dict/dpp-qpcpp.bin new file mode 100644 index 0000000..4c5748b Binary files /dev/null and b/qspy/test/dict/dpp-qpcpp.bin differ diff --git a/qspy/test/dict/dpp-qpcpp.dic b/qspy/test/dict/dpp-qpcpp.dic new file mode 100644 index 0000000..ba4c5a0 --- /dev/null +++ b/qspy/test/dict/dpp-qpcpp.dic @@ -0,0 +1,58 @@ +-d241031 +-v800 +-q2 +-T4 +-O4 +-F4 +-S2 +-E2 +-Q1 +-P2 +-B2 +-C4 +-t241010_104644 + +Obj-Dic: +4 +0x0800503C l_SysTick_Handler +0x20001204 Philo::inst[0] +0x20001230 Philo::inst[0].m_timeEvt +0x20001254 Philo::inst[1] +0x20001280 Philo::inst[1].m_timeEvt +0x200012A4 Philo::inst[2] +0x200012D0 Philo::inst[2].m_timeEvt +0x200012F4 Philo::inst[3] +0x20001320 Philo::inst[3].m_timeEvt +0x20001344 Philo::inst[4] +0x20001370 Philo::inst[4].m_timeEvt +0x20001394 Table::inst +0x200013C8 EvtPool1 +0x20001518 QS_RX +*** +Fun-Dic: +4 +0x08000BD7 QP::QHsm::top +0x08000D6D Philo::thinking +0x08000DFD Philo::hungry +0x08000EA5 Philo::eating +0x08001029 Table::active +0x080012C5 Table::serving +0x080013CD Table::paused +*** +Usr-Dic: +1 +0x00000064 PHILO_STAT +0x00000065 PAUSED_STAT +0x00000066 CONTEXT_SW +0x0000007C QUTEST_ON_POST +*** +Sig-Dic: +4 +00000004 0x00000000 EAT_SIG +00000005 0x00000000 DONE_SIG +00000006 0x00000000 PAUSE_SIG +00000007 0x00000000 SERVE_SIG +00000008 0x00000000 TEST_SIG +00000010 0x00000000 TIMEOUT_SIG +00000011 0x00000000 HUNGRY_SIG +*** diff --git a/qspy/test/dict/test_dpp-qpc.bat b/qspy/test/dict/test_dpp-qpc.bat new file mode 100644 index 0000000..9db832e --- /dev/null +++ b/qspy/test/dict/test_dpp-qpc.bat @@ -0,0 +1,6 @@ +@cls +@echo without dictionaries... +qspy -f dpp-qpc.bin + +@echo with dictionaries... +qspy -f dpp-qpc.bin -d dpp-qpc.dic diff --git a/qspy/test/dict/test_dpp-qpcpp.bat b/qspy/test/dict/test_dpp-qpcpp.bat new file mode 100644 index 0000000..0b842ab --- /dev/null +++ b/qspy/test/dict/test_dpp-qpcpp.bat @@ -0,0 +1,6 @@ +@cls +@echo without dictionaries... +qspy -f dpp-qpcpp.bin + +@echo with dictionaries... +qspy -f dpp-qpcpp.bin -d dpp-qpcpp.dic diff --git a/qspy/seq/README.txt b/qspy/test/seq/README.txt similarity index 100% rename from qspy/seq/README.txt rename to qspy/test/seq/README.txt diff --git a/qspy/test/seq/dpp-qpc.bin b/qspy/test/seq/dpp-qpc.bin new file mode 100644 index 0000000..c1043a5 Binary files /dev/null and b/qspy/test/seq/dpp-qpc.bin differ diff --git a/qspy/test/seq/dpp-qpcpp.bin b/qspy/test/seq/dpp-qpcpp.bin new file mode 100644 index 0000000..6078220 Binary files /dev/null and b/qspy/test/seq/dpp-qpcpp.bin differ diff --git a/qspy/test/seq/qspy241010_115511.seq b/qspy/test/seq/qspy241010_115511.seq new file mode 100644 index 0000000..9b84ec3 --- /dev/null +++ b/qspy/test/seq/qspy241010_115511.seq @@ -0,0 +1,143 @@ +-g l_SysTick_Handler,Table_inst,Philo_inst[0],Philo_inst[1],Philo_inst[2],Philo_inst[3],Philo_inst[4] + + +-------+-------+ +-------+-------+ +-------+-------+ +-------+-------+ +-------+-------+ +-------+-------+ +-------+-------+ + |l_SysTick_Handl| | Table_inst | | Philo_inst[0] | | Philo_inst[1] | | Philo_inst[2] | | Philo_inst[3] | | Philo_inst[4] | + +-------+-------+ +-------+-------+ +-------+-------+ +-------+-------+ +-------+-------+ +-------+-------+ +-------+-------+ +0002626121 *--TIMEOUT_SIG------+-------------------+-------------------+-------------------+-------------------+------------------>| +0002631234 | |<------------------+-------------------+-------------------+-------------------+-------HUNGRY_SIG--* +0002635176 . . . . | . . . . . . . . . * .EAT_SIG. . . . . | . . . . . . . . . | . . . . . . . . . | . . . . . . . . . | . . . . . . . . . | . . . +0002636168 | *--EAT_SIG----------+-------------------+-------------------+-------------------+------------------>| +0002637049 | *--EAT_SIG----------+-------------------+-------------------+------------------>| | +0002637920 | *--EAT_SIG----------+-------------------+------------------>| | | +0002638791 | *--EAT_SIG----------+------------------>| | | | +0002639662 | *--EAT_SIG--------->| | | | | +0002644194 | | | | | | +0002648533 | | | | | | +0003946269 *--TIMEOUT_SIG------+------------------>| | | | | +0003951119 | |<------HUNGRY_SIG--* | | | | +0003956356 | | | | | | +0004666145 *--TIMEOUT_SIG------+-------------------+-------------------+------------------>| | | +0004671041 | |<------------------+-------------------+-------HUNGRY_SIG--* | | +0004674952 . . . . | . . . . . . . . . * .EAT_SIG. . . . . | . . . . . . . . . | . . . . . . . . . | . . . . . . . . . | . . . . . . . . . | . . . +0004675932 | *--EAT_SIG----------+-------------------+-------------------+-------------------+------------------>| +0004676809 | *--EAT_SIG----------+-------------------+-------------------+------------------>| | +0004677679 | *--EAT_SIG----------+-------------------+------------------>| | | +0004678549 | *--EAT_SIG----------+------------------>| | | | +0004679419 | *--EAT_SIG--------->| | | | | +0004683915 | | | | | | +0004693693 | | | | | | +0004866152 *--TIMEOUT_SIG------+-------------------+------------------>| | | | +0004871053 | |<------------------+-------HUNGRY_SIG--* | | | +0004876287 | | | | | | +0006506091 *--TIMEOUT_SIG------+-------------------+-------------------+-------------------+------------------>| | +0006510987 | |<------------------+-------------------+-------------------+-------HUNGRY_SIG--* | +0006516220 | | | | | | +0010146091 *--TIMEOUT_SIG------+-------------------+-------------------+-------------------+-------------------+------------------>| +0010150448 . . . . | . . . . . . . . . | . . . . . . . . . | . . . . . . . . . | . . . . . . . . . | . . . . . . . . . | . . . . DONE_SIG. * . . . +0010151420 | |<------------------+-------------------+-------------------+-------------------+---------DONE_SIG--* +0010155831 . . . . | . . . . . . . . . * .EAT_SIG. . . . . | . . . . . . . . . | . . . . . . . . . | . . . . . . . . . | . . . . . . . . . | . . . +0010156815 | *--EAT_SIG----------+-------------------+-------------------+-------------------+------------------>| +0010157694 | *--EAT_SIG----------+-------------------+-------------------+------------------>| | +0010158575 | *--EAT_SIG----------+-------------------+------------------>| | | +0010159445 | *--EAT_SIG----------+------------------>| | | | +0010160315 | *--EAT_SIG--------->| | | | | +0010167305 | | | | | | +0010182814 | | | | | | +0011906090 *--TIMEOUT_SIG------+-------------------+-------------------+------------------>| | | +0011910516 . . . . | . . . . . . . . . | . . . . . . . . . | . . . . . . . . . | . . . . . . . . . * .DONE_SIG . . . . | . . . . . . . . . | . . . +0011911488 | |<------------------+-------------------+---------DONE_SIG--* | | +0011915910 . . . . | . . . . . . . . . * .EAT_SIG. . . . . | . . . . . . . . . | . . . . . . . . . | . . . . . . . . . | . . . . . . . . . | . . . +0011916894 | *--EAT_SIG----------+-------------------+-------------------+-------------------+------------------>| +0011917773 | *--EAT_SIG----------+-------------------+-------------------+------------------>| | +0011918643 | *--EAT_SIG----------+-------------------+------------------>| | | +0011919513 | *--EAT_SIG----------+------------------>| | | | +0011920399 | *--EAT_SIG--------->| | | | | +0011927406 | | | | | | +0011934566 | | | | | | +0014666160 *--TIMEOUT_SIG------+-------------------+-------------------+-------------------+-------------------+------------------>| +0014671065 | |<------------------+-------------------+-------------------+-------------------+-------HUNGRY_SIG--* +0014676300 | | | | | | +0016986144 *--TIMEOUT_SIG------+-------------------+-------------------+-------------------+------------------>| | +0016990508 . . . . | . . . . . . . . . | . . . . . . . . . | . . . . . . . . . | . . . . . . . . . | . . . . . . . . . * .DONE_SIG . . . . | . . . +0016991480 | |<------------------+-------------------+-------------------+---------DONE_SIG--* | +0016999766 | | | | | | +0017146091 *--TIMEOUT_SIG------+------------------>| | | | | +0017150507 . . . . | . . . . . . . . . | . . . . . . . . . * .DONE_SIG . . . . | . . . . . . . . . | . . . . . . . . . | . . . . . . . . . | . . . +0017151479 | |<--------DONE_SIG--* | | | | +0017155890 . . . . | . . . . . . . . . * .EAT_SIG. . . . . | . . . . . . . . . | . . . . . . . . . | . . . . . . . . . | . . . . . . . . . | . . . +0017156874 | *--EAT_SIG----------+-------------------+-------------------+-------------------+------------------>| +0017157753 | *--EAT_SIG----------+-------------------+-------------------+------------------>| | +0017158623 | *--EAT_SIG----------+-------------------+------------------>| | | +0017159493 | *--EAT_SIG----------+------------------>| | | | +0017160363 | *--EAT_SIG--------->| | | | | +0017163535 . . . . | . . . . . . . . . * .EAT_SIG. . . . . | . . . . . . . . . | . . . . . . . . . | . . . . . . . . . | . . . . . . . . . | . . . +0017164515 | *--EAT_SIG----------+-------------------+-------------------+-------------------+------------------>| +0017165348 | *--EAT_SIG----------+-------------------+-------------------+------------------>| | +0017166177 | *--EAT_SIG----------+-------------------+------------------>| | | +0017167006 | *--EAT_SIG----------+------------------>| | | | +0017167835 | *--EAT_SIG--------->| | | | | +0017174785 | | | | | | +0017179422 | | | | | | +0017199706 | | | | | | +0017786090 *--TIMEOUT_SIG------+-------------------+-------------------+------------------>| | | +0017791101 | |<------------------+-------------------+-------HUNGRY_SIG--* | | +0017796363 | | | | | | +0019026102 *--TIMEOUT_SIG------+-------------------+-------------------+-------------------+------------------>| | +0019031051 | |<------------------+-------------------+-------------------+-------HUNGRY_SIG--* | +0019036284 | | | | | | +0021826160 *--TIMEOUT_SIG------+------------------>| | | | | +0021828001 *--TIMEOUT_SIG------+-------------------+------------------>| | | | +0021832305 . . . . | . . . . . . . . . | . . . . . . . . . | . . . . . . . . . * .DONE_SIG . . . . | . . . . . . . . . | . . . . . . . . . | . . . +0021833277 | |<------------------+---------DONE_SIG--* | | | +0021837687 . . . . | . . . . . . . . . * .EAT_SIG. . . . . | . . . . . . . . . | . . . . . . . . . | . . . . . . . . . | . . . . . . . . . | . . . +0021838671 | *--EAT_SIG----------+-------------------+-------------------+-------------------+------------------>| +0021839550 | *--EAT_SIG----------+-------------------+-------------------+------------------>| | +0021840420 | *--EAT_SIG----------+-------------------+------------------>| | | +0021841290 | *--EAT_SIG----------+------------------>| | | | +0021842160 | *--EAT_SIG--------->| | | | | +0021849105 | | | | | | +0021859327 | | | | | | +0021867276 | |<------HUNGRY_SIG--* | | | | +0021872540 | | | | | | +0023746090 *--TIMEOUT_SIG------+-------------------+-------------------+-------------------+-------------------+------------------>| + +-------+-------+ +-------+-------+ +-------+-------+ +-------+-------+ +-------+-------+ +-------+-------+ +-------+-------+ + |l_SysTick_Handl| | Table_inst | | Philo_inst[0] | | Philo_inst[1] | | Philo_inst[2] | | Philo_inst[3] | | Philo_inst[4] | + +-------+-------+ +-------+-------+ +-------+-------+ +-------+-------+ +-------+-------+ +-------+-------+ +-------+-------+ +0023750489 . . . . | . . . . . . . . . | . . . . . . . . . | . . . . . . . . . | . . . . . . . . . | . . . . . . . . . | . . . . DONE_SIG. * . . . +0023751461 | |<------------------+-------------------+-------------------+-------------------+---------DONE_SIG--* +0023755871 . . . . | . . . . . . . . . * .EAT_SIG. . . . . | . . . . . . . . . | . . . . . . . . . | . . . . . . . . . | . . . . . . . . . | . . . +0023756867 | *--EAT_SIG----------+-------------------+-------------------+-------------------+------------------>| +0023757746 | *--EAT_SIG----------+-------------------+-------------------+------------------>| | +0023758616 | *--EAT_SIG----------+-------------------+------------------>| | | +0023759486 | *--EAT_SIG----------+------------------>| | | | +0023760367 | *--EAT_SIG--------->| | | | | +0023767356 | | | | | | +0023782422 | | | | | | +0025986090 *--TIMEOUT_SIG------+-------------------+-------------------+------------------>| | | +0025990550 . . . . | . . . . . . . . . | . . . . . . . . . | . . . . . . . . . | . . . . . . . . . * .DONE_SIG . . . . | . . . . . . . . . | . . . +0025991522 | |<------------------+-------------------+---------DONE_SIG--* | | +0025995931 . . . . | . . . . . . . . . * .EAT_SIG. . . . . | . . . . . . . . . | . . . . . . . . . | . . . . . . . . . | . . . . . . . . . | . . . +0025996915 | *--EAT_SIG----------+-------------------+-------------------+-------------------+------------------>| +0025997794 | *--EAT_SIG----------+-------------------+-------------------+------------------>| | +0025998664 | *--EAT_SIG----------+-------------------+------------------>| | | +0025999534 | *--EAT_SIG----------+------------------>| | | | +0026000404 | *--EAT_SIG--------->| | | | | +0026007392 | | | | | | +0026014552 | | | | | | +0026586102 *--TIMEOUT_SIG------+-------------------+------------------>| | | | +0026591113 | |<------------------+-------HUNGRY_SIG--* | | | +0026596351 | | | | | | +0028826092 *--TIMEOUT_SIG------+------------------>| | | | | +0028830575 . . . . | . . . . . . . . . | . . . . . . . . . * .DONE_SIG . . . . | . . . . . . . . . | . . . . . . . . . | . . . . . . . . . | . . . +0028831547 | |<--------DONE_SIG--* | | | | +0028835957 . . . . | . . . . . . . . . * .EAT_SIG. . . . . | . . . . . . . . . | . . . . . . . . . | . . . . . . . . . | . . . . . . . . . | . . . +0028836941 | *--EAT_SIG----------+-------------------+-------------------+-------------------+------------------>| +0028837820 | *--EAT_SIG----------+-------------------+-------------------+------------------>| | +0028838690 | *--EAT_SIG----------+-------------------+------------------>| | | +0028839560 | *--EAT_SIG----------+------------------>| | | | +0028840430 | *--EAT_SIG--------->| | | | | +0028847419 | | | | | | +0028859749 | | | | | | +0029026090 *--TIMEOUT_SIG------+-------------------+-------------------+-------------------+-------------------+------------------>| +0029031099 | |<------------------+-------------------+-------------------+-------------------+-------HUNGRY_SIG--* +0029036337 | | | | | | diff --git a/qspy/test/seq/qspy241010_115543.seq b/qspy/test/seq/qspy241010_115543.seq new file mode 100644 index 0000000..a5e9889 --- /dev/null +++ b/qspy/test/seq/qspy241010_115543.seq @@ -0,0 +1,101 @@ +-g l_SysTick_Handler,Table::inst,Philo::inst[0],Philo::inst[1],Philo::inst[2],Philo::inst[3],Philo::inst[4] + + +-------+-------+ +-------+-------+ +-------+-------+ +-------+-------+ +-------+-------+ +-------+-------+ +-------+-------+ + |l_SysTick_Handl| | Table::inst | |Philo::inst[0] | |Philo::inst[1] | |Philo::inst[2] | |Philo::inst[3] | |Philo::inst[4] | + +-------+-------+ +-------+-------+ +-------+-------+ +-------+-------+ +-------+-------+ +-------+-------+ +-------+-------+ +0002630861 *--TIMEOUT_SIG------+-------------------+-------------------+-------------------+-------------------+------------------>| +0002635847 | |<------------------+-------------------+-------------------+-------------------+-------HUNGRY_SIG--* +0002639644 . . . . | . . . . . . . . . * .EAT_SIG. . . . . | . . . . . . . . . | . . . . . . . . . | . . . . . . . . . | . . . . . . . . . | . . . +0002640622 | *--EAT_SIG----------+-------------------+-------------------+-------------------+------------------>| +0002641471 | *--EAT_SIG----------+-------------------+-------------------+------------------>| | +0002642313 | *--EAT_SIG----------+-------------------+------------------>| | | +0002643155 | *--EAT_SIG----------+------------------>| | | | +0002643997 | *--EAT_SIG--------->| | | | | +0002648396 | | | | | | +0002652611 | | | | | | +0003951011 *--TIMEOUT_SIG------+------------------>| | | | | +0003955739 | |<------HUNGRY_SIG--* | | | | +0003960825 | | | | | | +0004670902 *--TIMEOUT_SIG------+-------------------+-------------------+------------------>| | | +0004675691 | |<------------------+-------------------+-------HUNGRY_SIG--* | | +0004679482 . . . . | . . . . . . . . . * .EAT_SIG. . . . . | . . . . . . . . . | . . . . . . . . . | . . . . . . . . . | . . . . . . . . . | . . . +0004680440 | *--EAT_SIG----------+-------------------+-------------------+-------------------+------------------>| +0004681285 | *--EAT_SIG----------+-------------------+-------------------+------------------>| | +0004682126 | *--EAT_SIG----------+-------------------+------------------>| | | +0004682967 | *--EAT_SIG----------+------------------>| | | | +0004683808 | *--EAT_SIG--------->| | | | | +0004688175 | | | | | | +0004697680 | | | | | | +0004870903 *--TIMEOUT_SIG------+-------------------+------------------>| | | | +0004875684 | |<------------------+-------HUNGRY_SIG--* | | | +0004880788 | | | | | | +0006510847 *--TIMEOUT_SIG------+-------------------+-------------------+-------------------+------------------>| | +0006515638 | |<------------------+-------------------+-------------------+-------HUNGRY_SIG--* | +0006520723 | | | | | | +0010150847 *--TIMEOUT_SIG------+-------------------+-------------------+-------------------+-------------------+------------------>| +0010155088 . . . . | . . . . . . . . . | . . . . . . . . . | . . . . . . . . . | . . . . . . . . . | . . . . . . . . . | . . . . DONE_SIG. * . . . +0010156036 | |<------------------+-------------------+-------------------+-------------------+---------DONE_SIG--* +0010160318 . . . . | . . . . . . . . . * .EAT_SIG. . . . . | . . . . . . . . . | . . . . . . . . . | . . . . . . . . . | . . . . . . . . . | . . . +0010161271 | *--EAT_SIG----------+-------------------+-------------------+-------------------+------------------>| +0010162114 | *--EAT_SIG----------+-------------------+-------------------+------------------>| | +0010162955 | *--EAT_SIG----------+-------------------+------------------>| | | +0010163796 | *--EAT_SIG----------+------------------>| | | | +0010164637 | *--EAT_SIG--------->| | | | | +0010171428 | | | | | | +0010186553 | | | | | | +0011910850 *--TIMEOUT_SIG------+-------------------+-------------------+------------------>| | | +0011915141 . . . . | . . . . . . . . . | . . . . . . . . . | . . . . . . . . . | . . . . . . . . . * .DONE_SIG . . . . | . . . . . . . . . | . . . +0011916089 | |<------------------+-------------------+---------DONE_SIG--* | | +0011920371 . . . . | . . . . . . . . . * .EAT_SIG. . . . . | . . . . . . . . . | . . . . . . . . . | . . . . . . . . . | . . . . . . . . . | . . . +0011921324 | *--EAT_SIG----------+-------------------+-------------------+-------------------+------------------>| +0011922167 | *--EAT_SIG----------+-------------------+-------------------+------------------>| | +0011923008 | *--EAT_SIG----------+-------------------+------------------>| | | +0011923849 | *--EAT_SIG----------+------------------>| | | | +0011924690 | *--EAT_SIG--------->| | | | | +0011931492 | | | | | | +0011938473 | | | | | | +0014670905 *--TIMEOUT_SIG------+-------------------+-------------------+-------------------+-------------------+------------------>| +0014675686 | |<------------------+-------------------+-------------------+-------------------+-------HUNGRY_SIG--* +0014680771 | | | | | | +0016990902 *--TIMEOUT_SIG------+-------------------+-------------------+-------------------+------------------>| | +0016995145 . . . . | . . . . . . . . . | . . . . . . . . . | . . . . . . . . . | . . . . . . . . . | . . . . . . . . . * .DONE_SIG . . . . | . . . +0016996093 | |<------------------+-------------------+-------------------+---------DONE_SIG--* | +0017004077 | | | | | | +0017150851 *--TIMEOUT_SIG------+------------------>| | | | | +0017155148 . . . . | . . . . . . . . . | . . . . . . . . . * .DONE_SIG . . . . | . . . . . . . . . | . . . . . . . . . | . . . . . . . . . | . . . +0017156096 | |<--------DONE_SIG--* | | | | +0017160358 . . . . | . . . . . . . . . * .EAT_SIG. . . . . | . . . . . . . . . | . . . . . . . . . | . . . . . . . . . | . . . . . . . . . | . . . +0017161311 | *--EAT_SIG----------+-------------------+-------------------+-------------------+------------------>| +0017162154 | *--EAT_SIG----------+-------------------+-------------------+------------------>| | +0017162995 | *--EAT_SIG----------+-------------------+------------------>| | | +0017163836 | *--EAT_SIG----------+------------------>| | | | +0017164677 | *--EAT_SIG--------->| | | | | +0017167760 . . . . | . . . . . . . . . * .EAT_SIG. . . . . | . . . . . . . . . | . . . . . . . . . | . . . . . . . . . | . . . . . . . . . | . . . +0017168713 | *--EAT_SIG----------+-------------------+-------------------+-------------------+------------------>| +0017169516 | *--EAT_SIG----------+-------------------+-------------------+------------------>| | +0017170318 | *--EAT_SIG----------+-------------------+------------------>| | | +0017171120 | *--EAT_SIG----------+------------------>| | | | +0017171922 | *--EAT_SIG--------->| | | | | +0017178651 | | | | | | +0017183176 | | | | | | +0017202992 | | | | | | +0017790850 *--TIMEOUT_SIG------+-------------------+-------------------+------------------>| | | +0017795753 | |<------------------+-------------------+-------HUNGRY_SIG--* | | +0017800841 | | | | | | +0019030847 *--TIMEOUT_SIG------+-------------------+-------------------+-------------------+------------------>| | +0019035691 | |<------------------+-------------------+-------------------+-------HUNGRY_SIG--* | +0019040776 | | | | | | +0021830914 *--TIMEOUT_SIG------+------------------>| | | | | +0021832675 *--TIMEOUT_SIG------+-------------------+------------------>| | | | +0021836891 . . . . | . . . . . . . . . | . . . . . . . . . | . . . . . . . . . * .DONE_SIG . . . . | . . . . . . . . . | . . . . . . . . . | . . . +0021837839 | |<------------------+---------DONE_SIG--* | | | +0021842119 . . . . | . . . . . . . . . * .EAT_SIG. . . . . | . . . . . . . . . | . . . . . . . . . | . . . . . . . . . | . . . . . . . . . | . . . +0021843072 | *--EAT_SIG----------+-------------------+-------------------+-------------------+------------------>| +0021843915 | *--EAT_SIG----------+-------------------+-------------------+------------------>| | +0021844756 | *--EAT_SIG----------+-------------------+------------------>| | | +0021845597 | *--EAT_SIG----------+------------------>| | | | +0021846438 | *--EAT_SIG--------->| | | | | +0021853170 | | | | | | +0021863103 | | | | | | +0021870875 | |<------HUNGRY_SIG--* | | | | +0021875968 | | | | | | diff --git a/qspy/seq/test_dpp-qpc.bat b/qspy/test/seq/test_dpp-qpc.bat similarity index 100% rename from qspy/seq/test_dpp-qpc.bat rename to qspy/test/seq/test_dpp-qpc.bat diff --git a/qspy/seq/test_dpp-qpcpp.bat b/qspy/test/seq/test_dpp-qpcpp.bat similarity index 100% rename from qspy/seq/test_dpp-qpcpp.bat rename to qspy/test/seq/test_dpp-qpcpp.bat diff --git a/qspy/win32/Makefile b/qspy/win32/Makefile deleted file mode 100644 index ed9d3e8..0000000 --- a/qspy/win32/Makefile +++ /dev/null @@ -1,204 +0,0 @@ -#============================================================================= -# Makefile for qspy console, Win32, MinGW -# Last updated for version 7.3.0 -# Last updated on 2023-09-26 -# -# Q u a n t u m L e a P s -# ------------------------ -# Modern Embedded Software -# -# Copyright (C) 2005 Quantum Leaps, LLC. All rights reserved. -# -# SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-QL-commercial -# -# This software is dual-licensed under the terms of the open source GNU -# General Public License version 3 (or any later version), or alternatively, -# under the terms of one of the closed source Quantum Leaps commercial -# licenses. -# -# The terms of the open source GNU General Public License version 3 -# can be found at: -# -# The terms of the closed source Quantum Leaps commercial licenses -# can be found at: -# -# Redistributions in source code must retain this top-level comment block. -# Plagiarizing this software to sidestep the license obligations is illegal. -# -# Contact information: -# -# -#============================================================================= -# examples of invoking this Makefile: -# building configurations: Debug (default), Release, and Spy -# make -# make CONF=dbg -# -# cleaning configurations: Debug (default), Release, and Spy -# make clean -# make CONF=dbg clean -# -# NOTE: -# To use this Makefile on Windows, you will need the GNU make utility, which -# is included in the Qtools collection for Windows, see: -# https://github.com/QuantumLeaps/qtools/releases -# - -#----------------------------------------------------------------------------- -# project name -# -PROJECT := qspy - -#----------------------------------------------------------------------------- -# project directories: -# - -# list of all source directories used by this project -VPATH := . \ - ../source - -# list of all include directories needed by this project -INCLUDES := -I. \ - -I../include - -#----------------------------------------------------------------------------- -# project files: -# - -# C source files... -C_SRCS := \ - getopt.c \ - qspy_pal.c \ - qspy_be.c \ - qspy_main.c \ - qspy_dict.c \ - qspy_seq.c \ - qspy_tx.c \ - qspy.c - -# C++ source files... -CPP_SRCS := - -DEFINES := -DQSPY_APP -LIB_DIRS := -LIBS := -lws2_32 - -#----------------------------------------------------------------------------- -# MinGW toolset (NOTE: assumed to be on your PATH) -# -# NOTE: -# MinGW toolset is included in the Qtools collection for Windows, see: -# https://github.com/QuantumLeaps/qtools/releases - -CC := gcc -CPP := g++ -LINK := gcc - - -############################################################################## -# Typically, you should not need to change anything below this line - -# basic utilities (included in QTools for Windows), see: -# https://github.com/QuantumLeaps/qtools/releases - -MKDIR := mkdir -RM := rm - -#----------------------------------------------------------------------------- -# build options for various configurations -# - -ifeq (dbg, $(CONF)) # Debug configuration .................................... - -BIN_DIR := dbg - -CFLAGS = -c -g -std=c11 \ - -O -Wall -Wextra -Wpedantic $(INCLUDES) $(DEFINES) - -CPPFLAGS = -c -g -std=c++11 -fno-rtti -fno-exceptions \ - -O -Wall -Wextra -Wpedantic $(INCLUDES) $(DEFINES) - -else # default Release configuration ........................................ - -BIN_DIR := rel - -CFLAGS = -c -std=c11 \ - -Ofast -Wall -Wextra -Wpedantic $(INCLUDES) $(DEFINES) -DNDEBUG - -CPPFLAGS = -c -std=c++11 -fno-rtti -fno-exceptions \ - -Ofast -Wall -Wextra -Wpedantic $(INCLUDES) $(DEFINES) -DNDEBUG - -endif # ..................................................................... - -LINKFLAGS := -Wl,-Map,$(BIN_DIR)/$(PROJECT).map,--cref,--gc-sections - -#----------------------------------------------------------------------------- - -C_OBJS := $(patsubst %.c, %.o, $(C_SRCS)) -CPP_OBJS := $(patsubst %.cpp, %.o, $(CPP_SRCS)) -RC_OBJS := $(patsubst %.rc, %.o, $(RC_SRCS)) - -TARGET_BIN := $(BIN_DIR)/$(PROJECT).bin -TARGET_EXE := $(BIN_DIR)/$(PROJECT).exe -C_OBJS_EXT := $(addprefix $(BIN_DIR)/, $(C_OBJS)) -C_DEPS_EXT := $(patsubst %.o, %.d, $(C_OBJS_EXT)) -CPP_OBJS_EXT := $(addprefix $(BIN_DIR)/, $(CPP_OBJS)) -CPP_DEPS_EXT := $(patsubst %.o, %.d, $(CPP_OBJS_EXT)) -RC_OBJS_EXT := $(addprefix $(BIN_DIR)/, $(RC_OBJS)) - -# create $(BIN_DIR) if it does not exist -ifeq ("$(wildcard $(BIN_DIR))","") -$(shell $(MKDIR) $(BIN_DIR)) -endif - -#----------------------------------------------------------------------------- -# rules -# - -all: $(TARGET_EXE) - -$(TARGET_EXE) : $(C_OBJS_EXT) $(CPP_OBJS_EXT) $(RC_OBJS_EXT) - $(LINK) $(LINKFLAGS) $(LIB_DIRS) -o $@ $^ $(LIBS) - -$(BIN_DIR)/%.d : %.cpp - $(CPP) -MM -MT $(@:.d=.o) $(CPPFLAGS) $< > $@ - -$(BIN_DIR)/%.d : %.c - $(CC) -MM -MT $(@:.d=.o) $(CFLAGS) $< > $@ - -$(BIN_DIR)/%.o : %.cpp - $(CPP) $(CPPFLAGS) $< -o $@ - -$(BIN_DIR)/%.o : %.c - $(CC) $(CFLAGS) $< -o $@ - -# include dependency files only if our goal depends on their existence -ifneq ($(MAKECMDGOALS),clean) - ifneq ($(MAKECMDGOALS),show) --include $(C_DEPS_EXT) $(CPP_DEPS_EXT) - endif -endif - -.PHONY : clean show - -clean: - -$(RM) $(BIN_DIR)/*.o \ - $(BIN_DIR)/*.d \ - $(BIN_DIR)/*.map \ - $(TARGET_EXE) - -show: - @echo PROJECT = $(PROJECT) - @echo TARGET_EXE = $(TARGET_EXE) - @echo VPATH = $(VPATH) - @echo C_SRCS = $(C_SRCS) - @echo CPP_SRCS = $(CPP_SRCS) - @echo C_DEPS_EXT = $(C_DEPS_EXT) - @echo C_OBJS_EXT = $(C_OBJS_EXT) - @echo C_DEPS_EXT = $(C_DEPS_EXT) - @echo CPP_DEPS_EXT = $(CPP_DEPS_EXT) - @echo CPP_OBJS_EXT = $(CPP_OBJS_EXT) - @echo LIB_DIRS = $(LIB_DIRS) - @echo LIBS = $(LIBS) - @echo DEFINES = $(DEFINES) - diff --git a/qspy/win32/qspy.sln b/qspy/win32/qspy.sln deleted file mode 100644 index 37bfde6..0000000 --- a/qspy/win32/qspy.sln +++ /dev/null @@ -1,31 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio Version 17 -VisualStudioVersion = 17.7.34031.279 -MinimumVisualStudioVersion = 10.0.40219.1 -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "qspy", "qspy.vcxproj", "{CBECC159-8744-4517-828D-D3C740E68AA5}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|x64 = Debug|x64 - Debug|x86 = Debug|x86 - Release|x64 = Release|x64 - Release|x86 = Release|x86 - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {CBECC159-8744-4517-828D-D3C740E68AA5}.Debug|x64.ActiveCfg = Debug|x64 - {CBECC159-8744-4517-828D-D3C740E68AA5}.Debug|x64.Build.0 = Debug|x64 - {CBECC159-8744-4517-828D-D3C740E68AA5}.Debug|x86.ActiveCfg = Debug|Win32 - {CBECC159-8744-4517-828D-D3C740E68AA5}.Debug|x86.Build.0 = Debug|Win32 - {CBECC159-8744-4517-828D-D3C740E68AA5}.Release|x64.ActiveCfg = Release|x64 - {CBECC159-8744-4517-828D-D3C740E68AA5}.Release|x64.Build.0 = Release|x64 - {CBECC159-8744-4517-828D-D3C740E68AA5}.Release|x86.ActiveCfg = Release|Win32 - {CBECC159-8744-4517-828D-D3C740E68AA5}.Release|x86.Build.0 = Release|Win32 - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection - GlobalSection(ExtensibilityGlobals) = postSolution - SolutionGuid = {72F1DD46-1083-46CF-9E35-E3CD17D5165D} - EndGlobalSection -EndGlobal diff --git a/qspy/win32/qspy.vcxproj b/qspy/win32/qspy.vcxproj deleted file mode 100644 index 6bc4884..0000000 --- a/qspy/win32/qspy.vcxproj +++ /dev/null @@ -1,163 +0,0 @@ - - - - - Debug - Win32 - - - Release - Win32 - - - Debug - x64 - - - Release - x64 - - - - 17.0 - Win32Proj - {cbecc159-8744-4517-828d-d3c740e68aa5} - qspy - 10.0 - - - - Application - true - v143 - NotSet - - - Application - false - v143 - true - NotSet - - - Application - true - v143 - NotSet - - - Application - false - v143 - true - NotSet - - - - - - - - - - - - - - - - - - - - - - Level3 - true - QSPY_APP;WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - ../include - stdc11 - - - Console - true - ws2_32.lib;$(CoreLibraryDependencies);%(AdditionalDependencies) - - - - - Level3 - true - true - true - QSPY_APP;WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - ../include - stdc11 - - - Console - true - true - true - ws2_32.lib;$(CoreLibraryDependencies);%(AdditionalDependencies) - - - - - Level3 - true - QSPY_APP;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - stdc11 - ../include - - - Console - true - ws2_32.lib;$(CoreLibraryDependencies);%(AdditionalDependencies) - - - - - Level3 - true - true - true - QSPY_APP;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - stdc11 - ../include - - - Console - true - true - true - ws2_32.lib;$(CoreLibraryDependencies);%(AdditionalDependencies) - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/qspy/win32/qspy.vcxproj.filters b/qspy/win32/qspy.vcxproj.filters deleted file mode 100644 index 1aa877c..0000000 --- a/qspy/win32/qspy.vcxproj.filters +++ /dev/null @@ -1,66 +0,0 @@ - - - - - {4FC737F1-C7A5-4376-A066-2A32D752A2FF} - cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx - - - {93995380-89BD-4b04-88EB-625FBE52EBFB} - h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd - - - {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} - rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms - - - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - \ No newline at end of file diff --git a/qspy/win32/qspy_pal.c b/qspy/win32/qspy_pal.c deleted file mode 100644 index d2b0395..0000000 --- a/qspy/win32/qspy_pal.c +++ /dev/null @@ -1,765 +0,0 @@ -//============================================================================ -// QSPY software tracing host-side utility -// Copyright (C) 2005 Quantum Leaps, LLC. All rights reserved. -// -// SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-QL-commercial -// -// This software is dual-licensed under the terms of the open source GNU -// General Public License version 3 (or any later version), or alternatively, -// under the terms of one of the closed source Quantum Leaps commercial -// licenses. -// -// The terms of the open source GNU General Public License version 3 -// can be found at: -// -// The terms of the closed source Quantum Leaps commercial licenses -// can be found at: -// -// Redistributions in source code must retain this top-level comment block. -// Plagiarizing this software to sidestep the license obligations is illegal. -// -// Contact information: -// -// -//============================================================================ -//! @date Last updated on: 2024-02-23 -//! @version Last updated for version: 7.3.3 -//! -//! @file -//! @brief QSPY PAL implementation for Win32 - -#include /* for system() */ -#include -#include -#include - -#ifdef _MSC_VER -#pragma warning(push) -#pragma warning(disable: 4255) -#endif - -#include /* for Windows socket facilities */ - -#ifdef _MSC_VER -#pragma warning(pop) -#endif - -#include "safe_std.h" /* "safe" and facilities */ -#include "qspy.h" /* QSPY data parser */ -#include "be.h" /* Back-End interface */ -#include "pal.h" /* Platform Abstraction Layer */ - -/*..........................................................................*/ -PAL_VtblType PAL_vtbl; /* global PAL virtual table */ - -/* specific implementations of the PAL "virutal functions" .................*/ -static QSPYEvtType ser_getEvt(unsigned char *buf, uint32_t *pBytes); -static QSpyStatus ser_send2Target(unsigned char *buf, uint32_t nBytes); -static void ser_cleanup(void); - -static QSPYEvtType tcp_getEvt(unsigned char *buf, uint32_t *pBytes); -static QSpyStatus tcp_send2Target(unsigned char *buf, uint32_t nBytes); -static void tcp_cleanup(void); - -static QSPYEvtType file_getEvt(unsigned char *buf, uint32_t *pBytes); -static QSpyStatus file_send2Target(unsigned char *buf, uint32_t nBytes); -static void file_cleanup(void); - -/*..........................................................................*/ -enum PAL_Constants { /* local constants... */ - FE_DETACHED = 0, /* Front-End detached */ - PAL_TOUT_MS = 10, /* determines how long to wait for an event [ms] */ -}; - -/* fron-end address */ -typedef union { - uint64_t data[2]; - struct sockaddr addr; -} fe_addr; - -static bool l_kbd_inp = false; -static bool l_color = false; - -static HANDLE l_serHNDL; -static COMMTIMEOUTS l_timeouts; - -static SOCKET l_beSock = INVALID_SOCKET; -static fe_addr l_feAddr; -static int l_feAddrSize = FE_DETACHED; - -static SOCKET l_serverSock = INVALID_SOCKET; -static SOCKET l_clientSock = INVALID_SOCKET; - -static FILE *l_file = (FILE *)0; - -/*==========================================================================*/ -/* Ctrl-C handler */ -static BOOL WINAPI CtrlHandler(_In_ DWORD dwCtrlType) { - (void)dwCtrlType; /* unused parameter */ - QSPY_cleanup(); - //exit(-1); - return true; // signal handled -} - -/* Keyboard input */ -QSpyStatus PAL_openKbd(bool kbd_inp, bool color) { - l_kbd_inp = kbd_inp; - l_color = color; - SetConsoleCtrlHandler(&CtrlHandler, TRUE); - if (l_color) { - system("color"); /* to support color output */ - fputs("\033[0m", stdout); /* switch default colors */ - } - return QSPY_SUCCESS; -} -/*..........................................................................*/ -void PAL_closeKbd(void) { - if (l_color) { - fputs("\033[0m", stdout); /* switch default colors */ - l_color = false; - } -} -/*..........................................................................*/ -void PAL_exit(void) { - QSPY_cleanup(); - exit(0); -} - -/*==========================================================================*/ -/* Win32 serial communication with the Target */ -QSpyStatus PAL_openTargetSer(char const *comName, int baudRate) { - DCB dcb; - char comPortName[40]; - char comSettings[120]; - - /* setup the PAL virtual table for the Serial communication... */ - PAL_vtbl.getEvt = &ser_getEvt; - PAL_vtbl.send2Target = &ser_send2Target; - PAL_vtbl.cleanup = &ser_cleanup; - - /* open serial port (use \\.\COM name to allow large )... */ - SNPRINTF_S(comPortName, sizeof(comPortName), "\\\\.\\%s", comName); - l_serHNDL = CreateFile((LPCSTR)comPortName, - GENERIC_READ | GENERIC_WRITE, - 0U, /* exclusive access */ - NULL, /* no security attrs */ - OPEN_EXISTING, - 0U, /* standard (not-overlapped) I/O */ - NULL); - - if (l_serHNDL == INVALID_HANDLE_VALUE) { - SNPRINTF_LINE(" ERROR Opening COM Port=%s,Baud=%d", - comName, baudRate); - QSPY_printError(); - return QSPY_ERROR; - } - - /* configure the serial port... */ - SNPRINTF_S(comSettings, sizeof(comSettings), - "baud=%d parity=N data=8 stop=1 odsr=off dtr=on octs=off rts=on", - baudRate); - dcb.DCBlength = sizeof(DCB); - if (!GetCommState(l_serHNDL, &dcb)) { - SNPRINTF_LINE(" ERROR %s", "Getting COM port settings"); - QSPY_printError(); - return QSPY_ERROR; - } - - /* drill in the DCB... */ - dcb.fAbortOnError = 0U; /* don't abort on error */ - if (!BuildCommDCB((LPCSTR)comSettings, &dcb)) { - SNPRINTF_LINE(" ERROR %s", "Parsing COM port settings"); - QSPY_printError(); - return QSPY_ERROR; - } - - if (!SetCommState(l_serHNDL, &dcb)) { - SNPRINTF_LINE(" ERROR %s", "Setting up the COM port"); - QSPY_printError(); - return QSPY_ERROR; - } - - QSPY_reset(); /* reset the QSPY parser to start over cleanly */ - QSPY_txReset(); /* reset the QSPY transmitter */ - - /* setup the serial port buffers... */ - SetupComm(l_serHNDL, - 4*1024, /* 4K input buffer */ - 4*1024); /* 4K output buffer */ - - /* purge any information in the buffers */ - PurgeComm(l_serHNDL, PURGE_TXABORT | PURGE_RXABORT - | PURGE_TXCLEAR | PURGE_RXCLEAR); - - /* the read timeouts for the serial communication are set accorging - * to the following remark from the Win32 help documentation: - * - * If an application sets ReadIntervalTimeout and - * ReadTotalTimeoutMultiplier to MAXDWORD and sets - * ReadTotalTimeoutConstant to a value greater than zero and less than - * MAXDWORD, one of the following occurs when the ReadFile function - * is called: - * 1. If there are any characters in the input buffer, ReadFile - * returns immediately with the characters in the buffer. - * 2. If there are no characters in the input buffer, ReadFile waits - * until a character arrives and then returns immediately. - * 3. If no character arrives within the time specified by - * ReadTotalTimeoutConstant, ReadFile times out. - */ - l_timeouts.ReadIntervalTimeout = MAXDWORD; - l_timeouts.ReadTotalTimeoutMultiplier = MAXDWORD; - l_timeouts.ReadTotalTimeoutConstant = PAL_TOUT_MS; - - /* the write timeouts for the serial communication are set accorging - * to the following remark from the Win32 help documentation: - * - * A value of zero for both the WriteTotalTimeoutMultiplier and - * WriteTotalTimeoutConstant members indicates that total time-outs - * are not used for write operations. - * - * This means that the WriteFile() returns immediately and the - * serial driver must cache any bytes that have not been sent yet. - * (see also the output buffer setting for SetupComm() earlier). - * - * Exceeding the write buffer capacity indicates that the Target - * cannot accept all the bytes at this rate. This error will produce - * an error message to the screen. - */ - l_timeouts.WriteTotalTimeoutMultiplier = 0; - l_timeouts.WriteTotalTimeoutConstant = 0; - - SetCommTimeouts(l_serHNDL, &l_timeouts); - - return QSPY_SUCCESS; -} -/*..........................................................................*/ -static QSPYEvtType ser_getEvt(unsigned char *buf, uint32_t *pBytes) { - QSPYEvtType evtType; - - /* try to receive data from keyboard... */ - evtType = PAL_receiveKbd(buf, pBytes); - if (evtType != QSPY_NO_EVT) { - return evtType; - } - - /* try to receive data from the Back-End socket... */ - evtType = PAL_receiveBe(buf, pBytes); - if (evtType != QSPY_NO_EVT) { - return evtType; - } - - /* try to receive data from the Target... */ - /* NOTE: If data is not available immediately, this call blocks - * for up to PAL_TOUT_MS milliseconds. - */ - if (ReadFile(l_serHNDL, buf, (DWORD)(*pBytes), (LPDWORD)pBytes, NULL)) { - if (*pBytes > 0) { - return QSPY_TARGET_INPUT_EVT; - } - } - else { - COMSTAT comstat; - DWORD errors; - - SNPRINTF_LINE(" ERROR Reading COM port failed Err=%d", - WSAGetLastError()); - QSPY_printError(); - ClearCommError(l_serHNDL, &errors, &comstat); - - *pBytes = 0; - return QSPY_ERROR_EVT; - } - - return QSPY_NO_EVT; -} -/*..........................................................................*/ -static QSpyStatus ser_send2Target(unsigned char *buf, uint32_t nBytes) { - DWORD nBytesWritten; - - if (WriteFile(l_serHNDL, buf, (DWORD)nBytes, &nBytesWritten, NULL)) { - if (nBytesWritten == (DWORD)nBytes) { - return QSPY_SUCCESS; - } - else { - return QSPY_ERROR; - } - } - else { - SNPRINTF_LINE(" ERROR Writing to COM port Err=%d", - WSAGetLastError()); - QSPY_printError(); - return QSPY_ERROR; - } -} -/*..........................................................................*/ -static void ser_cleanup(void) { - CloseHandle(l_serHNDL); -} - - -/*==========================================================================*/ -/* Win32 TCP/IP communication with the Target */ - -static struct sockaddr_in l_clientAddr; - -/*..........................................................................*/ -QSpyStatus PAL_openTargetTcp(int portNum) { - struct sockaddr_in local; - u_long sockmode; - WSADATA wsaData; - - /* setup the PAL virtual table for the TCP/IP Target connection... */ - PAL_vtbl.getEvt = &tcp_getEvt; - PAL_vtbl.send2Target = &tcp_send2Target; - PAL_vtbl.cleanup = &tcp_cleanup; - - /* itialize Windows sockets version 2.2)... */ - /* WSAStartup() might be already called from PAL_openBE(), but - * in case the Back-End socket is not used it must be called here. - * NOTE: It's OK to call WSAStartup() multiple times, as long as - * the cleanup is performed equal number of times. - */ - int wsaErr = WSAStartup(MAKEWORD(2, 2), &wsaData); - if (wsaErr == SOCKET_ERROR) { - SNPRINTF_LINE(" ERROR Init Windows Sockets Err=%d", - wsaErr); - QSPY_printError(); - return QSPY_ERROR; - } - - /* create TCP socket */ - l_serverSock = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP); - if (l_serverSock == INVALID_SOCKET) { - SNPRINTF_LINE(" ERROR Server socket create Err=%d", - WSAGetLastError()); - QSPY_printError(); - return QSPY_ERROR; - } - - memset(&local, 0, sizeof(local)); - local.sin_family = AF_INET; - local.sin_addr.s_addr = INADDR_ANY; - local.sin_port = htons((unsigned short)portNum); - - /* bind() associates a local address and port combination with the - * socket just created. This is most useful when the application is a - * server that has a well-known port that clients know about in advance. - */ - if (bind(l_serverSock, (struct sockaddr *)&local, sizeof(local)) - == SOCKET_ERROR) - { - SNPRINTF_LINE(" ERROR Binding server socket Err=%d", - WSAGetLastError()); - QSPY_printError(); - return QSPY_ERROR; - } - - if (listen(l_serverSock, 1) == SOCKET_ERROR) { - SNPRINTF_LINE(" ERROR Server socket listen Err=%d", - WSAGetLastError()); - QSPY_printError(); - return QSPY_ERROR; - } - - /* put the socket into NON-BLOCKING mode... */ - sockmode = 1UL; /* NON-BLOCKING socket */ - if (ioctlsocket(l_serverSock, FIONBIO, &sockmode) == SOCKET_ERROR) { - SNPRINTF_LINE(" ERROR Server socket non-blocking Err=%d", - WSAGetLastError()); - QSPY_printError(); - return QSPY_ERROR; - } - - return QSPY_SUCCESS; -} -/*..........................................................................*/ -static void tcp_cleanup(void) { - if (l_serverSock != INVALID_SOCKET) { - closesocket(l_serverSock); - l_serverSock = INVALID_SOCKET; - } - WSACleanup(); -} -/*..........................................................................*/ -static QSPYEvtType tcp_getEvt(unsigned char *buf, uint32_t *pBytes) { - QSPYEvtType evtType; - struct timeval timeout = {(long)0, (long)(PAL_TOUT_MS*1000)}; - fd_set readSet; - int status; - int nrec; - char client_hostname[128]; - - /* try to receive data from keyboard... */ - evtType = PAL_receiveKbd(buf, pBytes); - if (evtType != QSPY_NO_EVT) { - return evtType; - } - - /* try to receive data from the Back-End socket... */ - evtType = PAL_receiveBe(buf, pBytes); - if (evtType != QSPY_NO_EVT) { - return evtType; - } - - /* still waiting for the client? */ - if (l_clientSock == INVALID_SOCKET) { - - FD_ZERO(&readSet); - FD_SET(l_serverSock, &readSet); - - /* selective, timed blocking... */ - status = select(0, &readSet, (fd_set *)0, (fd_set *)0, &timeout); - - if (status == SOCKET_ERROR) { - SNPRINTF_LINE(" ERROR Server socket select Err=%d", - WSAGetLastError()); - QSPY_printError(); - return QSPY_ERROR_EVT; - } - else if (FD_ISSET(l_serverSock, &readSet)) { - int fromLen = (int)sizeof(l_clientAddr); - ULONG sockmode; - //BOOL sockopt_bool; - - l_clientSock = accept(l_serverSock, - (struct sockaddr *)&l_clientAddr, &fromLen); - if (l_clientSock == INVALID_SOCKET) { - SNPRINTF_LINE(" ERROR Socket accept Err=%d", - WSAGetLastError()); - QSPY_printError(); - return QSPY_ERROR_EVT; - } - - /* put the client socket into NON-BLOCKING mode... */ - sockmode = 1UL; /* NON-BLOCKING socket */ - if (ioctlsocket(l_clientSock, FIONBIO, &sockmode) - == SOCKET_ERROR) - { - SNPRINTF_LINE(" ERROR Client socket non-blocking" - " Err=%d", WSAGetLastError()); - QSPY_printError(); - return QSPY_ERROR_EVT; - } - - QSPY_reset(); /* reset the QSPY parser to start over cleanly */ - QSPY_txReset(); /* reset the QSPY transmitter */ - -#ifdef _MSC_VER - inet_ntop(l_clientAddr.sin_family, &l_clientAddr.sin_addr, - client_hostname, sizeof(client_hostname)); -#else - strncpy(client_hostname, inet_ntoa(l_clientAddr.sin_addr), - sizeof(client_hostname) - 1U); -#endif - SNPRINTF_LINE(" TCP-IP Connected to Host=%s,Port=%d", - client_hostname, (int)ntohs(l_clientAddr.sin_port)); - QSPY_printInfo(); - } - } - else { /* client is connected... */ - FD_ZERO(&readSet); - FD_SET(l_clientSock, &readSet); - - /* selective, timed blocking... */ - status = select(0, &readSet, (fd_set *)0, (fd_set *)0, &timeout); - - if (status == SOCKET_ERROR) { - SNPRINTF_LINE(" ERROR Client socket select Err=%d", - WSAGetLastError()); - QSPY_printError(); - return QSPY_ERROR_EVT; - } else if (FD_ISSET(l_clientSock, &readSet)) { - nrec = recv(l_clientSock, (char *)buf, (int)(*pBytes), 0); - if (nrec <= 0) { /* the client hang up */ -#ifdef _MSC_VER - inet_ntop(l_clientAddr.sin_family, &l_clientAddr.sin_addr, - client_hostname, sizeof(client_hostname)); -#else - strncpy(client_hostname, inet_ntoa(l_clientAddr.sin_addr), - sizeof(client_hostname) - 1U); -#endif - SNPRINTF_LINE(" TCP-IP Disconn from " - "Host=%s,Port=%d", - client_hostname, - (int)ntohs(l_clientAddr.sin_port)); - QSPY_printInfo(); - - /* go back to waiting for a client */ - closesocket(l_clientSock); - l_clientSock = INVALID_SOCKET; - } - else { - *pBytes = (uint32_t)nrec; - return QSPY_TARGET_INPUT_EVT; - } - } - } - - return QSPY_NO_EVT; -} -/*..........................................................................*/ -static QSpyStatus tcp_send2Target(unsigned char *buf, uint32_t nBytes) { - if (l_clientSock == INVALID_SOCKET) { - return QSPY_ERROR; - } - if (send(l_clientSock, (char *)buf, (int)nBytes, 0) == SOCKET_ERROR) { - SNPRINTF_LINE(" ERROR Writing to TCP socket Err=%d", - WSAGetLastError()); - QSPY_printError(); - return QSPY_ERROR; - } - return QSPY_SUCCESS; -} - -/*==========================================================================*/ -/* File communication with the "Target" */ -QSpyStatus PAL_openTargetFile(char const *fName) { - /* setup the PAL virtual table for the File connection... */ - PAL_vtbl.getEvt = &file_getEvt; - PAL_vtbl.send2Target = &file_send2Target; - PAL_vtbl.cleanup = &file_cleanup; - - FOPEN_S(l_file, fName, "rb"); /* open for reading binary */ - if (l_file != (FILE *)0) { - QSPY_reset(); /* reset the QSPY parser to start over cleanly */ - QSPY_txReset(); /* reset the QSPY transmitter */ - - SNPRINTF_LINE(" File Opened File=%s", fName); - QSPY_printInfo(); - return QSPY_SUCCESS; - } - else { - SNPRINTF_LINE(" ERROR Cannot find File=%s", fName); - QSPY_printError(); - return QSPY_ERROR; - } -} -/*..........................................................................*/ -static QSPYEvtType file_getEvt(unsigned char *buf, uint32_t *pBytes) { - QSPYEvtType evtType; - uint32_t nBytes; - - /* try to receive data from keyboard... */ - evtType = PAL_receiveKbd(buf, pBytes); - if (evtType != QSPY_NO_EVT) { - return evtType; - } - - /* try to receive data from the Back-End socket... */ - evtType = PAL_receiveBe(buf, pBytes); - if (evtType != QSPY_NO_EVT) { - return evtType; - } - - /* try to receive data from the File... */ - nBytes = (uint32_t)FREAD_S(buf, *pBytes, 1U, *pBytes, l_file); - if (nBytes > 0) { - *pBytes = nBytes; - return QSPY_TARGET_INPUT_EVT; - } - - /* no more input available from the file, QSPY is done */ - return QSPY_DONE_EVT; -} -/*..........................................................................*/ -static QSpyStatus file_send2Target(unsigned char *buf, uint32_t nBytes) { - (void)buf; - (void)nBytes; - return QSPY_ERROR; -} -/*..........................................................................*/ -static void file_cleanup(void) { - if (l_file != (FILE *)0) { - fclose(l_file); - l_file = (FILE *)0; - } -} - - -/*==========================================================================*/ -/* Front-End interface */ -QSpyStatus PAL_openBE(int portNum) { - struct sockaddr_in local; - u_long sockmode; - WSADATA wsaData; - int wsaErr; - - /* itialize Windows sockets version 2.2)... */ - /* NOTE: assuming that PAL_openBE() is always called before initialzing - * the target connection, including the TCP/IP connection, the - */ - wsaErr = WSAStartup(MAKEWORD(2, 2), &wsaData); - if (wsaErr == SOCKET_ERROR) { - SNPRINTF_LINE(" ERROR Windows Sockets Init Err=%d", - wsaErr); - QSPY_printError(); - return QSPY_ERROR; - } - - l_beSock = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP); /* UDP socket */ - if (l_beSock == INVALID_SOCKET){ - SNPRINTF_LINE(" ERROR UDP socket create Err=%d", - WSAGetLastError()); - QSPY_printError(); - return QSPY_ERROR; - } - - /* bind the socket... - * bind() associates a local address and port combination with the - * socket just created. This is most useful when the application is a - * server that has a well-known port that clients know about in advance. - */ - memset(&local, 0, sizeof(local)); - local.sin_family = AF_INET; - local.sin_addr.s_addr = INADDR_ANY; - local.sin_port = htons((unsigned short)portNum); - if (bind(l_beSock, (struct sockaddr *)&local, sizeof(local)) - == SOCKET_ERROR) - { - SNPRINTF_LINE(" ERROR UDP socket binding Err=%d", - WSAGetLastError()); - QSPY_printError(); - return QSPY_ERROR; - } - - /* put the socket into NON-BLOCKING mode... */ - sockmode = 1UL; /* NON-BLOCKING socket */ - if (ioctlsocket(l_beSock, FIONBIO, &sockmode) == SOCKET_ERROR) { - SNPRINTF_LINE(" ERROR UDP socket non-blocking Err=%d", - WSAGetLastError()); - QSPY_printError(); - return QSPY_ERROR; - } - - BE_onStartup(); /* Back-End startup callback */ - - return QSPY_SUCCESS; -} -/*..........................................................................*/ -void PAL_closeBE(void) { - if (l_beSock != INVALID_SOCKET) { - if (l_feAddrSize != FE_DETACHED) { /* front-end attached? */ - fd_set writeSet; - struct timeval delay; - - /* Back-End cleanup callback (send detach packet)... */ - BE_onCleanup(); - - /* block until the packet comes out... */ - FD_ZERO(&writeSet); - FD_SET(l_beSock, &writeSet); - delay.tv_sec = 2U; /* delay for up to 2 seconds */ - delay.tv_usec = 0U; - if (select(0, (fd_set *)0, &writeSet, (fd_set *)0, &delay) - == SOCKET_ERROR) - { - SNPRINTF_LINE(" ERROR UDP socket select Err=%d", - WSAGetLastError()); - QSPY_printError(); - } - } - - closesocket(l_beSock); - l_beSock = INVALID_SOCKET; - } - WSACleanup(); -} -/*..........................................................................*/ -void PAL_send2FE(unsigned char const *buf, uint32_t nBytes) { - if (l_feAddrSize != FE_DETACHED) { /* front-end attached? */ - if (sendto(l_beSock, (char *)buf, (int)nBytes, 0, - &l_feAddr.addr, l_feAddrSize) == SOCKET_ERROR) - { - PAL_detachFE(); /* detach the Front-End */ - - SNPRINTF_LINE(" ERROR UDP socket failed Err=%d", - WSAGetLastError()); - QSPY_printError(); - } - } -} -/*..........................................................................*/ -void PAL_detachFE(void) { - l_feAddrSize = FE_DETACHED; -} - -/*..........................................................................*/ -void PAL_clearScreen(void) { - system("cls"); -} - -/*--------------------------------------------------------------------------*/ -QSPYEvtType PAL_receiveBe(unsigned char *buf, uint32_t *pBytes) { - fe_addr feAddr; - int feAddrSize; - int status; - - if (l_beSock == INVALID_SOCKET) { /* Back-End socket not initialized? */ - return QSPY_NO_EVT; - } - - /* receive a packet from the Back-End socket */ - feAddrSize = sizeof(feAddr); - status = recvfrom(l_beSock, (char *)buf, (int)*pBytes, 0, - &feAddr.addr, &feAddrSize); - - if (status == SOCKET_ERROR) { /* socket error - most likely would block */ - status = WSAGetLastError(); - if (status != WSAEWOULDBLOCK) { - PAL_detachFE(); /* detach from the Front-End */ - - SNPRINTF_LINE(" ERROR UDP socket failed Err=%d", - status); - QSPY_printError(); - return QSPY_ERROR_EVT; - } - } - else if (l_feAddrSize == 0) { /* not attached yet? */ - if (feAddrSize > (int)sizeof(l_feAddr)) { - SNPRINTF_LINE(" ERROR UDP address error size=%d", - feAddrSize); - QSPY_printError(); - return QSPY_ERROR_EVT; - } - memcpy(&l_feAddr, &feAddr, feAddrSize); - l_feAddrSize = feAddrSize; /* attach connection */ - *pBytes = (uint32_t)status; - return QSPY_FE_INPUT_EVT; - } - else { /* already attached */ - /* is this from the attached front-end address? */ - if ((feAddrSize == l_feAddrSize) - && (feAddr.data[1] == l_feAddr.data[1]) - && (feAddr.data[0] == l_feAddr.data[0])) - { - *pBytes = (uint32_t)status; - return QSPY_FE_INPUT_EVT; - } - else { - SNPRINTF_LINE(" WARN %s", "UDP socket in use"); - QSPY_printError(); - /* this packet is from a DIFFERENT front-end -- ignore it */ - } - } - return QSPY_NO_EVT; -} - -/*..........................................................................*/ -QSPYEvtType PAL_receiveKbd(unsigned char *buf, uint32_t *pBytes) { - if (l_kbd_inp) { - wint_t ch = 0; - while (_kbhit()) { - ch = _getwch(); - if ((ch == 0x00) || (ch == 0xE0)) { - ch = _getwch(); - } - } - if (ch != 0) { - buf[0] = (unsigned char)ch; - *pBytes = 1; /* number of bytes in the buffer */ - return QSPY_KEYBOARD_EVT; - } - } - return QSPY_NO_EVT; -} - diff --git a/qutest/qutest.py b/qutest/qutest.py index 611883c..a77224f 100644 --- a/qutest/qutest.py +++ b/qutest/qutest.py @@ -2,6 +2,11 @@ #============================================================================= # QUTest Python scripting support +# +# Q u a n t u m L e a P s +# ------------------------ +# Modern Embedded Software +# # Copyright (C) 2005 Quantum Leaps, LLC. All rights reserved. # # SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-QL-commercial @@ -57,7 +62,7 @@ class QUTest: # public class constants - VERSION = 740 + VERSION = 800 TIMEOUT = 1.000 # timeout value [seconds] # private class variables @@ -78,6 +83,7 @@ class QUTest: _test_start = 0 # private command-line options + _opt_trace = False _opt_exit_on_fail = False _opt_interactive = False _opt_clear_qspy = False @@ -158,10 +164,18 @@ def __init__(self): "poke": self.poke, "fill": self.fill, "note": self.note, - "scenario": scenario, # for BDD - "given": given, # for BDD - "when": when, # for BDD - "then": then, # for BDD + + "SCENARIO": self.SCENARIO, # for BDD (alternative 1) + "GIVEN": self.GIVEN, # for BDD (alternative 1) + "WHEN": self.WHEN, # for BDD (alternative 1) + "THEN": self.THEN, # for BDD (alternative 1) + "AND": self.AND, # for BDD (alternative 1) + + "scenario": scenario, # for BDD (alternative 2) + "given": given, # for BDD (alternative 2) + "when": when, # for BDD (alternative 2) + "then": then, # for BDD (alternative 2) + "pack": struct.pack, "test_file": self._test_fname, "test_dir": self._test_dname, @@ -207,13 +221,17 @@ def __init__(self): } def __del__(self): - #print("~QUTest", self) - pass + QUTest.trace("~QUTest", self) def exec_dsl(self, code): # pylint: disable=exec-used exec(code, self._dsl_dict) + @staticmethod + def trace(*args, **kwargs): + if QUTest._opt_trace: + print(*args, **kwargs) + #------------------------------------------------------------------------- # QUTest Domain Specific Language (DSL) commands @@ -272,7 +290,7 @@ def test(self, title, opt=0): # SCENARIO DSL command ....................................................... def SCENARIO(self, title="", opt=0): - self.context = Context_() # reset the context + self._context = Context_() # reset the context self.test(f"SCENARIO: {title}", opt) # expect DSL command ..................................................... @@ -295,7 +313,7 @@ def expect(self, exp, ignore=False): # in fnmatchcase(). if exp.startswith("@timestamp"): self._timestamp += 1 - exp = f"{self._timestamp:010d}" + exp[10:] + exp = f"{self._timestamp:010d}{exp[10:]}" pattern = exp.replace("[", "\2") pattern = pattern.replace("]", "\3") elif exp[0:9].isdigit(): @@ -325,7 +343,7 @@ def expect(self, exp, ignore=False): elif self._state in (QUTest._FAIL, QUTest._SKIP): pass # ignore else: - assert 0, "invalid state in expect: " + exp + assert 0, "invalid state in expect: {exp}" return False # ensure DSL command ..................................................... @@ -363,7 +381,7 @@ def _apply(bits, mask, is_neg): try: arg = QSpy.QS_PRE.index(arg) except Exception: - assert 0, 'invalid global filter arg="' + arg + '"' + assert 0, f'invalid global filter arg="{arg}"' else: is_neg = (arg < 0) if is_neg: @@ -813,15 +831,15 @@ def AND(self, msg="", dest=0x3): # dummy callbacks -------------------------------------------------------- def _dummy_on_reset(self): - #print("_dummy_on_reset") + QUTest.trace("_dummy_on_reset") self.expect(" QF_RUN") def _dummy_on_setup(self): - #print("_dummy_on_setup") + QUTest.trace("_dummy_on_setup") pass def _dummy_on_teardown(self): - #print("_dummy_on_teardown") + QUTest.trace("_dummy_on_teardown") pass # helper methods --------------------------------------------------------- @@ -878,6 +896,12 @@ def _run_script(fname): QUTest._num_failed += 1 QUTest._str_failed += f" {QUTest._num_groups}" + except ExitOnDetachException: + QUTest.display("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "\ + "QSPY detached ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~", + QUTest._COL_ERR1, QUTest._COL_ERR2) + sys.exit(-1) + except Exception: QUTest.display(traceback.format_exc(), QUTest._COL_ERR1, QUTest._COL_ERR2) @@ -915,7 +939,7 @@ def _interact(self): break def _tran(self, state): - #print(f"tran({self._state}->{state})" + QUTest.trace(f"tran({self._state}->{state})") self._state = state def _test_end(self): @@ -968,7 +992,6 @@ def _test_end(self): def _reset_target(self): if QUTest._host_exe[0]: if not QUTest._have_assert: - #print("quitting exe") QUTest._quithost_exe() # lauch a new instance of the host executable @@ -1015,7 +1038,7 @@ def _on_setup(self): def _before_test(self, command): QUTest._num_failed += 1 self._tran(QUTest._FAIL) - msg = '"' + command + '" before any test' + msg = f'"{command}" before any test' raise SyntaxError(msg) def _fail(self, err = "", exp = ""): @@ -1060,6 +1083,7 @@ def _fail(self, err = "", exp = ""): @staticmethod def _quithost_exe(): if QUTest._host_exe[0] and QUTest._have_target: + QUTest.trace("quitting host exe...") QUTest._have_target = False QSpy.send_to(struct.pack(" 0: - QUTest_inst.note(f"\n Given: {self.msgs[0]}") + QUTest_inst.note(f"\n GIVEN: {self.msgs[0]}") for msg in self.msgs[1:]: - QUTest_inst.note(f" And: {msg}") + QUTest_inst.note(f" AND: {msg}") else: - QUTest_inst.note("\n Given:") + QUTest_inst.note("\n GIVEN:") QUTest_inst._context = action(QUTest_inst._context) return wrapper @@ -1136,11 +1160,11 @@ def wrapper(): return wrapper if len(self.msgs) > 0: - QUTest_inst.note(f" When: {self.msgs[0]}") + QUTest_inst.note(f" WHEN: {self.msgs[0]}") for msg in self.msgs[1:]: - QUTest_inst.note(f" And: {msg}") + QUTest_inst.note(f" AND: {msg}") else: - QUTest_inst.note(" When:") + QUTest_inst.note(" WHEN:") action(QUTest_inst._context) return wrapper @@ -1157,11 +1181,11 @@ def wrapper(): return wrapper if len(self.msgs) > 0: - QUTest_inst.note(f" Then: {self.msgs[0]}") + QUTest_inst.note(f" THEN: {self.msgs[0]}") for msg in self.msgs[1:]: - QUTest_inst.note(f" And: {msg}") + QUTest_inst.note(f" AND: {msg}") else: - QUTest_inst.note(" Then:") + QUTest_inst.note(" THEN:") action(QUTest_inst._context) return wrapper @@ -1170,6 +1194,10 @@ class ExitOnFailException(Exception): # test failed and exit-on-fail (-x) is set pass +class ExitOnDetachException(Exception): + # QSPY detached in the middle of the run + pass + #============================================================================= # Helper class for communication with the QSpy front-end # @@ -1183,6 +1211,7 @@ class QSpy: # formats of various packet elements from the Target trg_QPver = 0 + trg_QPdate = 0 trg_objPtr = "L" trg_funPtr = "L" trg_tsize = "L" @@ -1419,11 +1448,9 @@ def _init(): # Create socket QSpy._sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) QSpy._sock.settimeout(QUTest.TIMEOUT) # timeout for blocking socket - #bufsize = QSpy._sock.getsockopt(socket.SOL_UDP, socket.SO_RCVBUF) - #print("SO_RCVBUF ", bufsize) try: QSpy._sock.bind(("0.0.0.0", QSpy._local_port)) - #print("bind: ", ("0.0.0.0", QSpy._local_port)) + QUTest.trace(f'bind: ("0.0.0.0", {QSpy._local_port})') except Exception: print("UDP Socket Error"\ "Can't bind the UDP socket\nto the specified local_host") @@ -1436,7 +1463,11 @@ def _attach(channels = 0x2): print(f"Attaching to QSpy "\ f"({QSpy.host_udp[0]}:{QSpy.host_udp[1]})... ", end='') QSpy._is_attached = False - QSpy.send_to(struct.pack("> 4] QSpy.trg_tsize = fmt[trg_info[4] & 0x0F] @@ -1527,7 +1565,7 @@ def receive(): QSpy.trg_tstamp = \ f"{trg_info[12]:02d}{trg_info[11]:02d}{trg_info[10]:02d}_"\ f"{trg_info[9]:02d}{trg_info[8]:02d}{trg_info[7]:02d}" - #print("Target:", QSpy.trg_tstamp) + QUTest.trace("Target:", QSpy.trg_tstamp) QUTest._have_info = True elif rec_id == QSpy._PKT_ATTACH_CONF: @@ -1538,7 +1576,7 @@ def receive(): QUTest._quithost_exe() QUTest._last_record = "" QSpy._detach() - QSpy._is_attached = False + raise ExitOnDetachException() else: QUTest._last_record = "" @@ -1548,6 +1586,8 @@ def receive(): @staticmethod def send_to(packet, payload=None): + if not QSpy._is_attached: + return tx_packet = bytearray([QSpy._tx_seq]) tx_packet.extend(packet) if payload is not None: @@ -1555,7 +1595,7 @@ def send_to(packet, payload=None): tx_packet.extend(b"\0") # zero-terminate QSpy._sock.sendto(tx_packet, QSpy.host_udp) QSpy._tx_seq = (QSpy._tx_seq + 1) & 0xFF - #print("sendTo", QSpy._tx_seq) + QUTest.trace("sendTo", QSpy._tx_seq) @staticmethod def send_evt(ao_prio, signal, parameters = None): @@ -1613,12 +1653,12 @@ def main(): parser.add_argument('-l', '--log', nargs='?', default='', const='', help="Optional log directory (might not exist yet)") parser.add_argument('-o', '--opt', nargs='?', default='', const='', - help="xciob: x:exit-on-fail,i:inter," + help="txciob: t:trace,x:exit-on-fail,i:inter,\n" "c:qspy-clear,o:qspy-save-txt,b:qspy-save-bin") parser.add_argument('scripts', nargs='*', help="List (comma-separated) of test scripts to run") args = parser.parse_args() - #print(args) + QUTest.trace(args) # process command-line argumens... if args.exe != '': @@ -1640,7 +1680,7 @@ def main(): QSpy.host_udp[1] = int(qspy_conf[1]) if len(qspy_conf) > 2 and not qspy_conf[2] == '': if QUTest._host_exe[0]: - QUTest._host_exe[1] = (QSpy.host_udp[0] + ":" + qspy_conf[2]) + QUTest._host_exe[1] = f"{QSpy.host_udp[0]}:{qspy_conf[2]}" else: print("\nTCP port specified without host executable\n") return sys.exit(-1) @@ -1654,7 +1694,7 @@ def main(): except Exception: pass if os.path.isdir(log): # is arg.log a directory - log += "qutest" + run_id + ".txt" + log += f"qutest{run_id}.log" else: # not a directory log = '' print("\nWrong directory for log output\n") @@ -1665,6 +1705,7 @@ def main(): if QUTest._host_exe[0]: QUTest._host_exe = tuple(QUTest._host_exe) + QUTest._opt_trace = 't' in args.opt QUTest._opt_exit_on_fail = 'x' in args.opt QUTest._opt_interactive = 'i' in args.opt QUTest._opt_clear_qspy = 'c' in args.opt @@ -1672,7 +1713,7 @@ def main(): QUTest._opt_save_qspy_bin = 'b' in args.opt if not args.scripts: # scripts not provided? - #print("applying default *.py") + QUTest.trace("applying default *.py") args.scripts = ['*.py'] # apply the default "*.py" scripts = [] for script in args.scripts: @@ -1686,16 +1727,16 @@ def main(): print("\nFound no test scripts to run") return sys.exit(0) - #print("scripts:", scripts) - #print("host_exe:", QUTest._host_exe) - #print("debug:", QUTest._is_debug) - #print("_log_file:", log) - #print("host_udp:", QSpy.host_udp) - #print("opt: x", QUTest._opt_exit_on_fail) - #print("opt: i", QUTest._opt_interactive) - #print("opt: c", QUTest._opt_clear_qspy) - #print("opt: o", QUTest._opt_save_qspy_txt) - #print("opt: o", QUTest._opt_save_qspy_bin) + QUTest.trace("scripts:", scripts) + QUTest.trace("host_exe:", QUTest._host_exe) + QUTest.trace("debug:", QUTest._is_debug) + QUTest.trace("_log_file:", log) + QUTest.trace("host_udp:", QSpy.host_udp) + QUTest.trace("opt: x", QUTest._opt_exit_on_fail) + QUTest.trace("opt: i", QUTest._opt_interactive) + QUTest.trace("opt: c", QUTest._opt_clear_qspy) + QUTest.trace("opt: o", QUTest._opt_save_qspy_txt) + QUTest.trace("opt: o", QUTest._opt_save_qspy_bin) #return 0 # init QSpy socket diff --git a/qutest/setup.py b/qutest/setup.py index 0db49ae..37ffdc7 100644 --- a/qutest/setup.py +++ b/qutest/setup.py @@ -9,7 +9,7 @@ setup( name="qutest", - version="7.4.0", + version="8.0.0", author="Quantum Leaps", author_email="info@state-machine.com", description="QUTest Python scripting support", diff --git a/qview/qview.py b/qview/qview.py index a018aa8..b41977f 100644 --- a/qview/qview.py +++ b/qview/qview.py @@ -2,6 +2,11 @@ #============================================================================= # QView Monitoring for QP/Spy +# +# Q u a n t u m L e a P s +# ------------------------ +# Modern Embedded Software +# # Copyright (C) 2005 Quantum Leaps, LLC. All rights reserved. # # SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-QL-commercial @@ -28,7 +33,9 @@ # pylint: disable=missing-module-docstring, # pylint: disable=missing-class-docstring, # pylint: disable=missing-function-docstring -# pylint: disable=broad-except +# pylint: disable=protected-access +# pylint: disable=invalid-name +# pylint: disable=broad-exception-caught from tkinter import * from tkinter.ttk import * # override the basic Tk widgets with Ttk widgets @@ -39,7 +46,6 @@ import time import sys import struct -import os import traceback import webbrowser @@ -49,7 +55,7 @@ # class QView: ## current version of QView - VERSION = 741 + VERSION = 800 # public static variables... ## menu to be customized @@ -110,10 +116,8 @@ def main(cust): # create the QView GUI QView._gui = Tk() - QView._gui.title("QView " + \ - "%d.%d.%d"%(QView.VERSION//100, \ - (QView.VERSION//10) % 10, \ - QView.VERSION % 10)) + QView._gui.title(f"QView {QView.VERSION//100}."\ + f"{(QView.VERSION//10) % 10}.{QView.VERSION % 10}") QView._init_gui(QView._gui) err = QSpy._init() @@ -163,10 +167,10 @@ def main(cust): # local filter groups... IDS_ALL= 0xF0 - IDS_AO = (0x80 + 0) - IDS_EP = (0x80 + 64) - IDS_EQ = (0x80 + 80) - IDS_AP = (0x80 + 96) + IDS_AO = 0x80 + 0 + IDS_EP = 0x80 + 64 + IDS_EQ = 0x80 + 80 + IDS_AP = 0x80 + 96 # on_init() callback def on_init(self): @@ -182,7 +186,7 @@ def on_run(self): ## @brief Send the RESET packet to the Target @staticmethod - def reset_target(*args): + def reset_target(): if QView._have_info: QSpy._sendTo(pack(") instead") sys.exit(-1) @@ -748,7 +752,7 @@ def _quit(err=0): QView._gui.quit() @staticmethod - def _onExit(*args): + def _onExit(): QView._quit() @staticmethod @@ -756,7 +760,7 @@ def _onReset(): QView._glb_filter = 0 QView._loc_filter = QSpy._LOC_FLT_MASK_ALL QView._locAO_OBJ.set("") - for i in range(len(QView._currObj)): + for i, e in enumerate(QView._currObj): QView._currObj[i].set("") QView._updateMenus() @@ -765,7 +769,7 @@ def _updateMenus(): # internal helper function def _update_glb_filter_menu(label, mask): - x = (QView._glb_filter & mask) + x = QView._glb_filter & mask if x == 0: status = "[ - ]" elif x == mask: @@ -777,7 +781,7 @@ def _update_glb_filter_menu(label, mask): # internal helper function def _update_loc_filter_menu(label, mask): - x = (QView._loc_filter & mask) + x = QView._loc_filter & mask if x == 0: status = "[ - ]" elif x == mask: @@ -787,7 +791,7 @@ def _update_loc_filter_menu(label, mask): QView._menu_loc_filter.entryconfig(label, accelerator=status) - for i in range(len(QView._currObj)): + for i, e in enumerate(QView._currObj): QView._menu_curr_obj.entryconfig(i, accelerator=QView._currObj[i].get()) QView._menu_events.entryconfig(0, @@ -841,7 +845,7 @@ def _update_loc_filter_menu(label, mask): accelerator=QView._locAO_OBJ.get()) @staticmethod - def _trap_error(*args): + def _trap_error(): QView._showerror("Runtime Error", traceback.format_exc(3)) QView._quit(-3) @@ -854,27 +858,27 @@ def _assert(cond, message): QView._quit(-3) @staticmethod - def _onSaveDict(*args): + def _onSaveDict(): QSpy._sendTo(pack(" 0xFF: - QView._MessageDialog("Event Error: par%d"%(i), + QView._MessageDialog(f"Event Error: par{i}", "8-bit data out of range") return 0 if size == 2 and par > 0xFFFF: - QView._MessageDialog("Event Error: par%d"%(i), + QView._MessageDialog(f"Event Error: par{i}", "16-bit data out of range") return 0 if size == 4 and par > 0xFFFFFFFF: - QView._MessageDialog("Event Error: par%d"%(i), + QView._MessageDialog(f"Event Error: par{i}", "32-bit data out of range") return 0 @@ -1851,13 +1874,8 @@ def _poll0(): # only show the frame, if visible QView._onFrameView() - - return - elif recID == QSpy._PKT_DETACH: QView._quit() - return - # regullar poll of the UDP socket after it has attached. @staticmethod @@ -1894,16 +1912,22 @@ def _poll(): QView.print_text(packet[3:]) elif recID == QSpy._PKT_TARGET_INFO: - if dlen != 18: + if dlen == 18: + QView._showerror("QP Version Error,", + "QP 8.0.0 or newer required") + QView._quit(-2) + return + + if dlen != 20: QView._showerror("UDP Socket Data Error", "Corrupted Target-info") QView._quit(-2) return - if packet[4] & 0x80 != 0: # big endian? + if packet[2] & 0x80 != 0: # big endian? QSpy._fmt_endian = ">" - tstamp = packet[5:18] + tstamp = packet[7:20] QSpy._size_objPtr = tstamp[3] & 0x0F QSpy._size_funPtr = tstamp[3] >> 4 QSpy._size_tstamp = tstamp[4] & 0x0F @@ -1913,11 +1937,11 @@ def _poll(): QSpy._size_poolCtr = tstamp[2] >> 4 QSpy._size_poolBlk = tstamp[2] & 0x0F QSpy._size_tevtCtr = tstamp[1] >> 4 - QSpy._fmt_target = "%02d%02d%02d_%02d%02d%02d"\ - %(tstamp[12], tstamp[11], tstamp[10], - tstamp[9], tstamp[8], tstamp[7]) + QSpy._fmt_target = \ + f"{tstamp[12]:02d}{tstamp[11]:02d}{tstamp[10]:02d}"\ + f"{tstamp[9]:02d}{tstamp[8]:02d}{tstamp[7]:02d}" #print("******* Target:", QSpy._fmt_target) - QView._target.configure(text="Target: " + QSpy._fmt_target) + QView._target.configure(text=f"Target: {QSpy._fmt_target}") QView._have_info = True # is this also target reset? @@ -1927,7 +1951,7 @@ def _poll(): QView._inst.on_reset() except Exception: QView._showerror("Runtime Error", - traceback.format_exc(3)) + traceback.format_exc(3)) QView._quit(-3) return @@ -1941,6 +1965,8 @@ def _poll(): return elif recID == QSpy._PKT_DETACH: + QView._showerror("UDP Socket Data Error", + "QSPY detached") QView._quit() return @@ -1957,15 +1983,15 @@ def _poll(): QView._quit(-3) return QSpy._rx_seq += 1 - QView._rx.configure(text="%d"%(QSpy._rx_seq)) + QView._rx.configure(text=f"{QSpy._rx_seq}") @staticmethod - def _sendTo(packet, str=None): + def _sendTo(packet, sig_name=None): tx_packet = bytearray([QSpy._tx_seq & 0xFF]) tx_packet.extend(packet) - if str is not None: - tx_packet.extend(bytes(str, "utf-8")) + if sig_name is not None: + tx_packet.extend(bytes(sig_name, "utf-8")) tx_packet.extend(b"\0") # zero-terminate try: QSpy._sock.sendto(tx_packet, QSpy._host_addr) @@ -1975,12 +2001,12 @@ def _sendTo(packet, str=None): QView._quit(-1) QSpy._tx_seq += 1 if not QView._gui is None: - QView._tx.configure(text="%d"%(QSpy._tx_seq)) + QView._tx.configure(text=f"{QSpy._tx_seq}") @staticmethod def _sendEvt(ao_prio, signal, params = None): #print("evt:", signal, params) - fmt = "