From 37b7496e0cfe8de6dab074ead95016dc62e7ab0e Mon Sep 17 00:00:00 2001 From: Clark Coleman <clc@zephyr-software.com> Date: Wed, 7 Nov 2018 10:33:23 -0500 Subject: [PATCH] Fix annotation parsing for memory range annotations. Former-commit-id: 41fa07d22ca3edef70568823572ee62eda413ef2 --- .../src/MEDS_AnnotationParser.cpp | 3 ++- .../src/MEDS_MemoryRangeAnnotation.cpp | 27 ++++++++++++++++--- 2 files changed, 25 insertions(+), 5 deletions(-) diff --git a/libMEDSannotation/src/MEDS_AnnotationParser.cpp b/libMEDSannotation/src/MEDS_AnnotationParser.cpp index c49e482b7..de2b10055 100644 --- a/libMEDSannotation/src/MEDS_AnnotationParser.cpp +++ b/libMEDSannotation/src/MEDS_AnnotationParser.cpp @@ -32,6 +32,7 @@ #include "MEDS_DeadRegAnnotation.hpp" #include "MEDS_IBAnnotation.hpp" #include "MEDS_IBTAnnotation.hpp" +#include "MEDS_MemoryRangeAnnotation.hpp" // @todo: multiple annotation per instruction @@ -104,7 +105,7 @@ void MEDS_AnnotationParser::parseFile(istream &p_inputStream) if(add_if_valid<MEDS_FuncExitAnnotation>(line)) continue; if(add_if_valid<MEDS_IBAnnotation>(line)) continue; if(add_if_valid<MEDS_IBTAnnotation>(line)) continue; - + if (add_if_valid<MEDS_MemoryRangeAnnotation>(line)) continue; } } diff --git a/libMEDSannotation/src/MEDS_MemoryRangeAnnotation.cpp b/libMEDSannotation/src/MEDS_MemoryRangeAnnotation.cpp index 9c15f8d8e..8548def68 100644 --- a/libMEDSannotation/src/MEDS_MemoryRangeAnnotation.cpp +++ b/libMEDSannotation/src/MEDS_MemoryRangeAnnotation.cpp @@ -23,7 +23,7 @@ #include <cstdio> #include <string> #include <string.h> -#include <cstdint> +#include <cinttypes> #include "MEDS_MemoryRangeAnnotation.hpp" @@ -87,11 +87,30 @@ void MEDS_MemoryRangeAnnotation::parse() // 417748 12 INSTR STATICMEMWRITE MIN 3c60320 LIMIT 4e53730 ZZ // 4992ea 4 INSTR STACKMEMRANGE MIN RSP - 568 LIMIT RSP - 48 INSTRSPDELTA - 592 ZZ - int ItemsFilled = sscanf(m_rawInputLine.c_str(), "%*x %d %*s %*s MIN %lx LIMIT %lx", &instrSize, &MinVal, &LimitVal); - if (3 != ItemsFilled) { + if (this->isStaticGlobalRange()) { + int ItemsFilled = sscanf(m_rawInputLine.c_str(), "%*x %d %*s %*s MIN %" SCNx64 " LIMIT %" SCNx64, &instrSize, &MinVal, &LimitVal); + if (3 != ItemsFilled) { + this->setInvalid(); + cerr << "Error on sscanf of annotation: ItemsFilled = " << ItemsFilled << " line: " << m_rawInputLine << endl; + return; + } + else { + cerr << "Parsed STATICMEMWRITE annotation: MIN = " << hex << MinVal << " LIMIT = " << LimitVal << endl; + } + } + else { +#if 0 + int ItemsFilled = sscanf(m_rawInputLine.c_str(), "%*x %d %*s %*s MIN %" SCNx64 " LIMIT %" SCNx64, &instrSize, &MinVal, &LimitVal); + if (3 != ItemsFilled) { + this->setInvalid(); + cerr << "Error on sscanf of annotation: ItemsFilled = " << ItemsFilled << " line: " << m_rawInputLine << endl; + return; + } +#else this->setInvalid(); - cerr << "Error on sscanf of annotation" << endl; + cerr << "Not yet parsing STACKMEMRANGE annotations " << endl; return; +#endif } this->setInstructionSize(instrSize); // in base class -- GitLab