[PATCH] rtems-examples: Add CoreMark Benchmark

2021-03-12 Thread Hesham Almatary
CoreMark's primary goals are simplicity and providing a method for
testing only a processor's core features. It is used primarily here as
a performance benchmark.

Built and tested for RISC-V rv64imafdc_medany on QEMU and HW
---
 .gitmodules  |  3 +++
 benchmarks/coremark/coremark |  1 +
 benchmarks/coremark/wscript  | 50 
 benchmarks/wscript   |  2 +-
 4 files changed, 55 insertions(+), 1 deletion(-)
 create mode 16 benchmarks/coremark/coremark
 create mode 100644 benchmarks/coremark/wscript

diff --git a/.gitmodules b/.gitmodules
index ae86e49..d7e52b9 100644
--- a/.gitmodules
+++ b/.gitmodules
@@ -1,3 +1,6 @@
 [submodule "rtems_waf"]
path = rtems_waf
url = git://git.rtems.org/rtems_waf.git
+[submodule "benchmarks/coremark/coremark"]
+   path = benchmarks/coremark/coremark
+   url = g...@github.com:eembc/coremark.git
diff --git a/benchmarks/coremark/coremark b/benchmarks/coremark/coremark
new file mode 16
index 000..1541482
--- /dev/null
+++ b/benchmarks/coremark/coremark
@@ -0,0 +1 @@
+Subproject commit 1541482bf3e6ef7f5c69f5be76b14537b60833d0
diff --git a/benchmarks/coremark/wscript b/benchmarks/coremark/wscript
new file mode 100644
index 000..2ec5f1e
--- /dev/null
+++ b/benchmarks/coremark/wscript
@@ -0,0 +1,50 @@
+#-
+# SPDX-License-Identifier: BSD-2-Clause
+#
+# Copyright (c) 2021 Hesham Almatary
+#
+# This software was developed by SRI International and the University of
+# Cambridge Computer Laboratory (Department of Computer Science and
+# Technology) under DARPA contract HR0011-18-C-0016 ("ECATS"), as part of the
+# DARPA SSITH research programme.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+# 1. Redistributions of source code must retain the above copyright
+#notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright
+#notice, this list of conditions and the following disclaimer in the
+#documentation and/or other materials provided with the distribution.
+#
+# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+# ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+# SUCH DAMAGE.
+#
+
+import rtems_waf.rtems as rtems
+
+def build(bld):
+rtems.build(bld)
+
+bld(features = 'c cprogram',
+target = 'coremark.bin',
+includes = ['coremark/', 'coremark/posix/'],
+source = ['coremark/rtems/init.c', 'coremark/posix/core_portme.c',
+  'coremark/core_list_join.c', 'coremark/core_main.c',
+  'coremark/core_matrix.c', 'coremark/core_state.c',
+  'coremark/core_util.c'],
+
+defines = [
+# FLAGS_STR is used within CoreMark to print the compiler flags used
+'FLAGS_STR="'+' '.join([str(flag) for flag in bld.env.CFLAGS])+'"'
+]
+)
diff --git a/benchmarks/wscript b/benchmarks/wscript
index 12741e7..0947060 100644
--- a/benchmarks/wscript
+++ b/benchmarks/wscript
@@ -7,4 +7,4 @@ import rtems_waf.rtems as rtems
 
 def build(bld):
 bld.recurse('nbench')
-
+bld.recurse('coremark')
-- 
2.25.1

___
devel mailing list
devel@rtems.org
http://lists.rtems.org/mailman/listinfo/devel


[PATCH] GSoC initial Work Proof

2021-03-12 Thread Daman Bir Singh
---
 testsuites/samples/hello/hello.scn | 3 ++-
 testsuites/samples/hello/init.c| 3 ++-
 2 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/testsuites/samples/hello/hello.scn 
b/testsuites/samples/hello/hello.scn
index d9e92d81d5..e9fc49520f 100644
--- a/testsuites/samples/hello/hello.scn
+++ b/testsuites/samples/hello/hello.scn
@@ -1,3 +1,4 @@
 *** HELLO WORLD TEST ***
-Hello World
+Hello from the Dark Side
+By Daman Bir Singh, GSoC 2021 applicant
 *** END OF HELLO WORLD TEST ***
diff --git a/testsuites/samples/hello/init.c b/testsuites/samples/hello/init.c
index 34ded37c55..dc79226f42 100644
--- a/testsuites/samples/hello/init.c
+++ b/testsuites/samples/hello/init.c
@@ -22,7 +22,8 @@ static rtems_task Init(
 {
   rtems_print_printer_fprintf_putc(_test_printer);
   TEST_BEGIN();
-  printf( "Hello World\n" );
+  printf( "Hello from the Dark Side\n" );
+  printf( "By Daman Bir Singh, GSoC 2021 applicant\n");
   TEST_END();
   rtems_test_exit( 0 );
 }
-- 
2.30.1

___
devel mailing list
devel@rtems.org
http://lists.rtems.org/mailman/listinfo/devel


Re: GSoC Introduction, completed getting started guide.

2021-03-12 Thread Eshan Dhawan
Hi daman,
You have to send the patch using git send-email. To any of the maintainers.

- Eshan 
> On 13-Mar-2021, at 11:20 AM, Daman Bir Singh  
> wrote:
> 
> 
> Hello everyone, 
> 
> I am Daman from Bits Pilani, K K Birla Campus Goa, India. I am very 
> interested in working with your organization for GSoC 2021. I have followed 
> the GSoC Getting Started Guide  and was successfully able to build and change 
> the 'hello' test case.(screenshots and patch attached). 
> It would be a great help if you could guide me how to proceed further.
> 
> Thanks & Regards, 
> Daman Bir Singh
> <0001-GSoC-initial-Work-Proof.patch>
> 
> 
> ___
> devel mailing list
> devel@rtems.org
> http://lists.rtems.org/mailman/listinfo/devel
___
devel mailing list
devel@rtems.org
http://lists.rtems.org/mailman/listinfo/devel

GSoC Introduction, completed getting started guide.

2021-03-12 Thread Daman Bir Singh
Hello everyone,

I am Daman from Bits Pilani, K K Birla Campus Goa, India. I am very
interested in working with your organization for GSoC 2021. I have followed
the GSoC Getting Started Guide
  and was
successfully able to build and change the 'hello' test case.(screenshots
and patch attached).
It would be a great help if you could guide me how to proceed further.

Thanks & Regards,
Daman Bir Singh
From 0b723c66ab3d86b16394d167f1facb1ece91d713 Mon Sep 17 00:00:00 2001
From: Daman Bir Singh 
Date: Sat, 13 Mar 2021 11:01:24 +0530
Subject: [PATCH] GSoC initial Work Proof

---
 testsuites/samples/hello/hello.scn | 3 ++-
 testsuites/samples/hello/init.c| 3 ++-
 2 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/testsuites/samples/hello/hello.scn b/testsuites/samples/hello/hello.scn
index d9e92d81d5..e9fc49520f 100644
--- a/testsuites/samples/hello/hello.scn
+++ b/testsuites/samples/hello/hello.scn
@@ -1,3 +1,4 @@
 *** HELLO WORLD TEST ***
-Hello World
+Hello from the Dark Side
+By Daman Bir Singh, GSoC 2021 applicant
 *** END OF HELLO WORLD TEST ***
diff --git a/testsuites/samples/hello/init.c b/testsuites/samples/hello/init.c
index 34ded37c55..dc79226f42 100644
--- a/testsuites/samples/hello/init.c
+++ b/testsuites/samples/hello/init.c
@@ -22,7 +22,8 @@ static rtems_task Init(
 {
   rtems_print_printer_fprintf_putc(_test_printer);
   TEST_BEGIN();
-  printf( "Hello World\n" );
+  printf( "Hello from the Dark Side\n" );
+  printf( "By Daman Bir Singh, GSoC 2021 applicant\n");
   TEST_END();
   rtems_test_exit( 0 );
 }
-- 
2.30.1

___
devel mailing list
devel@rtems.org
http://lists.rtems.org/mailman/listinfo/devel

Re: [PATCH 1/1] Hello World - Ida's proof to work on rtems

2021-03-12 Thread Ida Delphine
Here's a screenshot as requested on the guide.

Thanks,
Ida.

On Sat, Mar 13, 2021 at 5:13 AM Ida Delphine  wrote:

> From: Meh Mbeh Ida Delphine 
>
> Modified rtems/testsuites/samples/hello/init.c to prove I can work on the
> RTEMS project for GSoC.
> ---
>  testsuites/samples/hello/init.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/testsuites/samples/hello/init.c
> b/testsuites/samples/hello/init.c
> index 34ded37c55..fa581fd447 100644
> --- a/testsuites/samples/hello/init.c
> +++ b/testsuites/samples/hello/init.c
> @@ -22,7 +22,7 @@ static rtems_task Init(
>  {
>rtems_print_printer_fprintf_putc(_test_printer);
>TEST_BEGIN();
> -  printf( "Hello World\n" );
> +  printf( "Hello World, I'm Ida Deslphine and this is th main proof I can
> officially work on the RTEMS Project for GSoC. I'm so excited. Thank you
> all for the help you rendered when I ran into several errors!\n" );
>TEST_END();
>rtems_test_exit( 0 );
>  }
> --
> 2.25.1
>
>
___
devel mailing list
devel@rtems.org
http://lists.rtems.org/mailman/listinfo/devel

[PATCH 1/1] Hello World - Ida's proof to work on rtems

2021-03-12 Thread Ida Delphine
From: Meh Mbeh Ida Delphine 

Modified rtems/testsuites/samples/hello/init.c to prove I can work on the RTEMS 
project for GSoC.
---
 testsuites/samples/hello/init.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/testsuites/samples/hello/init.c b/testsuites/samples/hello/init.c
index 34ded37c55..fa581fd447 100644
--- a/testsuites/samples/hello/init.c
+++ b/testsuites/samples/hello/init.c
@@ -22,7 +22,7 @@ static rtems_task Init(
 {
   rtems_print_printer_fprintf_putc(_test_printer);
   TEST_BEGIN();
-  printf( "Hello World\n" );
+  printf( "Hello World, I'm Ida Deslphine and this is th main proof I can 
officially work on the RTEMS Project for GSoC. I'm so excited. Thank you all 
for the help you rendered when I ran into several errors!\n" );
   TEST_END();
   rtems_test_exit( 0 );
 }
-- 
2.25.1

___
devel mailing list
devel@rtems.org
http://lists.rtems.org/mailman/listinfo/devel


[PATCH 0/1] My First Contribution

2021-03-12 Thread Ida Delphine
I modified init.c and tested it successfully as proof I can work on the RTEMS 
Project for GSoC.

Meh Mbeh Ida Delphine (1):
  Hello World - Ida's proof to work on rtems

 testsuites/samples/hello/init.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

-- 
2.25.1

___
devel mailing list
devel@rtems.org
http://lists.rtems.org/mailman/listinfo/devel


Re: [PATCH] covoar: Fix DWARF reading

2021-03-12 Thread Chris Johns
These are design question and not review issues 

On 12/3/21 5:33 am, Alex White wrote:
> +  // Create data based on target.
> +  TargetInfo = Target::TargetFactory( buildTarget );

Any pointers in this object given there is a copy operator at work here?

> +  // Create the set of desired symbols.
> +  SymbolsToAnalyze = new Coverage::DesiredSymbols();

How hard would it be to convert these types of allocations in covoar to
std::shared_ptr<> or std::unique_ptr<> (if that is suitable or possible)?

Chris
___
devel mailing list
devel@rtems.org
http://lists.rtems.org/mailman/listinfo/devel


[PATCH] coverage/symbol-sets.ini : Add libtrace

2021-03-12 Thread Alex White
---
 tester/rtems/testing/coverage/symbol-sets.ini | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/tester/rtems/testing/coverage/symbol-sets.ini 
b/tester/rtems/testing/coverage/symbol-sets.ini
index 9617dd8..52e25ff 100644
--- a/tester/rtems/testing/coverage/symbol-sets.ini
+++ b/tester/rtems/testing/coverage/symbol-sets.ini
@@ -29,7 +29,7 @@
 #
 
 [symbol-sets]
-sets = 
score,rtems,sapi,posix,librfs,libpipe,libdosfs,libimfs,libjffs2,libcsupport,libbspcmdline,libcpuuse,libstackchk,libfsmount,libstringto,libdevnull,libdumpbuf,libuntar,libblock,libcrypt,libmd,libstdthreads
+sets = 
score,rtems,sapi,posix,librfs,libpipe,libdosfs,libimfs,libjffs2,libcsupport,libbspcmdline,libcpuuse,libstackchk,libfsmount,libstringto,libdevnull,libdumpbuf,libuntar,libblock,libcrypt,libmd,libstdthreads,libtrace
 
 [libraries]
 score = @BUILD-TARGET@/@BSP@/cpukit/score/src
@@ -76,4 +76,5 @@ libblock  = @BUILD-TARGET@/@BSP@/cpukit/libblock/src
 libcrypt  = @BUILD-TARGET@/@BSP@/cpukit/libcrypt
 libmd = @BUILD-TARGET@/@BSP@/cpukit/libmd
 libstdthreads = @BUILD-TARGET@/@BSP@/cpukit/libstdthreads
+libtrace  = @BUILD-TARGET@/@BSP@/cpukit/libtrace/record
 #zlib  = @BUILD-TARGET@/@BSP@/cpukit/zlib
-- 
2.27.0

___
devel mailing list
devel@rtems.org
http://lists.rtems.org/mailman/listinfo/devel


[PATCH 2/3] covoar: Improve findCoverageMap error message

2021-03-12 Thread Alex White
---
 tester/covoar/ExecutableInfo.cc | 8 ++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/tester/covoar/ExecutableInfo.cc b/tester/covoar/ExecutableInfo.cc
index 5a730fd..30828a6 100644
--- a/tester/covoar/ExecutableInfo.cc
+++ b/tester/covoar/ExecutableInfo.cc
@@ -177,7 +177,9 @@ namespace Coverage {
 
 if (periodIndex == std::string::npos) {
   // Symbol name has no '.', can't do another lookup.
-  throw rld::error (symbolName, "ExecutableInfo::findCoverageMap");
+  std::ostringstream what;
+  what << "Could not find " << symbolName;
+  throw rld::error (what, "ExecutableInfo::findCoverageMap");
 }
 
 cmi = coverageMaps.find(
@@ -185,7 +187,9 @@ namespace Coverage {
 );
 
 if ( cmi == coverageMaps.end() ) {
-  throw rld::error (symbolName, "ExecutableInfo::findCoverageMap");
+  std::ostringstream what;
+  what << "Could not find " << symbolName;
+  throw rld::error (what, "ExecutableInfo::findCoverageMap");
 }
 
 return *(cmi->second);
-- 
2.27.0

___
devel mailing list
devel@rtems.org
http://lists.rtems.org/mailman/listinfo/devel


[PATCH 3/3] covoar: Fix overflow of high PC address

2021-03-12 Thread Alex White
This fixes an integer overflow that would occur if a function's high PC
address were zero in the DWARF info.
---
 tester/covoar/ExecutableInfo.cc | 5 +
 1 file changed, 5 insertions(+)

diff --git a/tester/covoar/ExecutableInfo.cc b/tester/covoar/ExecutableInfo.cc
index 30828a6..7f33f20 100644
--- a/tester/covoar/ExecutableInfo.cc
+++ b/tester/covoar/ExecutableInfo.cc
@@ -71,6 +71,11 @@ namespace Coverage {
 }
   }
 
+  // We can't process a zero size function.
+  if (func.pc_high() == 0) {
+continue;
+  }
+
   createCoverageMap (cu.name(), func.name(),
   func.pc_low(), func.pc_high() - 1);
 }
-- 
2.27.0

___
devel mailing list
devel@rtems.org
http://lists.rtems.org/mailman/listinfo/devel


[PATCH 0/3] covoar: Improve error handling

2021-03-12 Thread Alex White
This patch set contains a few improvements to error handling in covoar
that result in more meaningful error messages.

Alex White (3):
  covoar: Catch exceptional case
  covoar: Improve findCoverageMap error message
  covoar: Fix overflow of high PC address

 tester/covoar/ExecutableInfo.cc | 23 +--
 1 file changed, 21 insertions(+), 2 deletions(-)

-- 
2.27.0

___
devel mailing list
devel@rtems.org
http://lists.rtems.org/mailman/listinfo/devel


[PATCH] covoar: Add option to create named objdumps

2021-03-12 Thread Alex White
This adds a new behavior to the -d option which allows the creation of
named objdump outputs in the /tmp directory. This allows the outputs to
be reused on subsequent runs of covoar rather than running objdump
again.
---
 tester/covoar/ObjdumpProcessor.cc | 22 +-
 tester/covoar/ObjdumpProcessor.h  |  6 --
 tester/covoar/app_common.cc   | 10 ++
 tester/covoar/app_common.h|  1 +
 tester/covoar/covoar.cc   | 23 +++
 5 files changed, 47 insertions(+), 15 deletions(-)

diff --git a/tester/covoar/ObjdumpProcessor.cc 
b/tester/covoar/ObjdumpProcessor.cc
index 9ef2390..fb23ca6 100644
--- a/tester/covoar/ObjdumpProcessor.cc
+++ b/tester/covoar/ObjdumpProcessor.cc
@@ -236,7 +236,8 @@ namespace Coverage {
   void ObjdumpProcessor::getFile(
 std::string fileName,
 rld::process::tempfile& objdumpFile,
-rld::process::tempfile& err
+rld::process::tempfile& err,
+bool debug
 )
   {
 rld::process::statusstatus;
@@ -245,11 +246,13 @@ namespace Coverage {
  fileName };
 try
 {
-  status = rld::process::execute( TargetInfo->getObjdump(),
-  args, objdumpFile.name(), err.name() );
-  if ( (status.type != rld::process::status::normal)
-   || (status.code != 0) ) {
-throw rld::error( "Objdump error", "generating objdump" );
+  if (!debug || FileIsNewer( fileName.c_str(), objdumpFile.name().c_str() 
)) {
+status = rld::process::execute( TargetInfo->getObjdump(),
+args, objdumpFile.name(), err.name() );
+if ( (status.type != rld::process::status::normal)
+ || (status.code != 0) ) {
+  throw rld::error( "Objdump error", "generating objdump" );
+}
   }
 } catch( rld::error& err )
   {
@@ -325,7 +328,8 @@ namespace Coverage {
   void ObjdumpProcessor::load(
 ExecutableInfo* constexecutableInformation,
 rld::process::tempfile&  objdumpFile,
-rld::process::tempfile&  err
+rld::process::tempfile&  err,
+bool debug
   )
   {
 std::string currentSymbol = "";
@@ -348,9 +352,9 @@ namespace Coverage {
 
 // Obtain the objdump file.
 if ( !executableInformation->hasDynamicLibrary() )
-  getFile( executableInformation->getFileName(), objdumpFile, err );
+  getFile( executableInformation->getFileName(), objdumpFile, err, debug );
 else
-  getFile( executableInformation->getLibraryName(), objdumpFile, err );
+  getFile( executableInformation->getLibraryName(), objdumpFile, err, 
debug );
 
 while ( true ) {
   // Get the line.
diff --git a/tester/covoar/ObjdumpProcessor.h b/tester/covoar/ObjdumpProcessor.h
index c75755d..4dab001 100644
--- a/tester/covoar/ObjdumpProcessor.h
+++ b/tester/covoar/ObjdumpProcessor.h
@@ -103,7 +103,8 @@ namespace Coverage {
  */
 void getFile( std::string fileName,
   rld::process::tempfile& dmp,
-  rld::process::tempfile& err );
+  rld::process::tempfile& err,
+  bool debug = false );
 
 /*!
  *  This method fills the objdumpList list with all the
@@ -122,7 +123,8 @@ namespace Coverage {
 void load(
   ExecutableInfo* const executableInformation,
   rld::process::tempfile& dmp,
-  rld::process::tempfile& err
+  rld::process::tempfile& err,
+  bool debug
 );
 
 /*!
diff --git a/tester/covoar/app_common.cc b/tester/covoar/app_common.cc
index 8b490ed..0f3c8e2 100644
--- a/tester/covoar/app_common.cc
+++ b/tester/covoar/app_common.cc
@@ -116,3 +116,13 @@ bool ReadUntilFound( FILE *file, const char *line )
   } while (1);
 }
 
+std::string GetFileNameFromPath( const std::string& path )
+{
+  size_t idx = path.rfind('/', path.length());
+  if (idx == std::string::npos) {
+return "";
+  }
+
+  return path.substr(idx + 1, path.length() - idx);
+}
+
diff --git a/tester/covoar/app_common.h b/tester/covoar/app_common.h
index ac32bbd..21e8cfa 100644
--- a/tester/covoar/app_common.h
+++ b/tester/covoar/app_common.h
@@ -30,5 +30,6 @@ extern char 
inputBuffer2[MAX_LINE_LENGTH];
 bool FileIsNewer( const char *f1, const char *f2 );
 bool FileIsReadable( const char *f1 );
 bool ReadUntilFound( FILE *file, const char *line );
+std::string GetFileNameFromPath( const std::string& path );
 
 #endif
diff --git a/tester/covoar/covoar.cc b/tester/covoar/covoar.cc
index bf95cb4..6b2082d 100644
--- a/tester/covoar/covoar.cc
+++ b/tester/covoar/covoar.cc
@@ -373,8 +373,25 @@ int covoar(
   exe->setLoadAddress( objdumpProcessor->determineLoadAddress( exe ) );
 }
 
-// Load the objdump for the symbols in this executable.
-objdumpProcessor->load( exe, objdumpFile, err );
+if (debug) {
+  std::string name;
+  
+  if ( !exe->hasDynamicLibrary() ) {
+name = 

[PATCH] covoar: Fix null pointer dereference

2021-03-12 Thread Alex White
A null pointer dereference happens later in the program execution if
the files are cleaned up at the end of the ExecutableInfo constructor.
This change fixes the null pointer dereference.
---
 tester/covoar/ExecutableInfo.cc | 9 ++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/tester/covoar/ExecutableInfo.cc b/tester/covoar/ExecutableInfo.cc
index 1396519..187bb77 100644
--- a/tester/covoar/ExecutableInfo.cc
+++ b/tester/covoar/ExecutableInfo.cc
@@ -82,13 +82,16 @@ namespace Coverage {
   throw;
 }
 
-debug.end();
-executable.end();
-executable.close();
+// Can't cleanup handles until the destructor because the information is
+// referenced elsewhere. NOTE: This could cause problems from too many open
+// file descriptors.
   }
 
   ExecutableInfo::~ExecutableInfo()
   {
+debug.end();
+executable.end();
+executable.close();
   }
 
   void ExecutableInfo::dumpCoverageMaps( void ) {
-- 
2.27.0

___
devel mailing list
devel@rtems.org
http://lists.rtems.org/mailman/listinfo/devel


[PATCH 3/4] coverage/reports: Share common JS and CSS in reports

2021-03-12 Thread Alex White
This moves all of the javascript and CSS files that are shared by the
symbol set HTML reports to the shared parent directory. It also includes
the javascript and CSS in the top-level index file.
---
 tester/covoar/ReportsHtml.cc |  4 ++--
 tester/rt/coverage.py| 11 ++-
 2 files changed, 8 insertions(+), 7 deletions(-)

diff --git a/tester/covoar/ReportsHtml.cc b/tester/covoar/ReportsHtml.cc
index cce0a4f..3d20aec 100644
--- a/tester/covoar/ReportsHtml.cc
+++ b/tester/covoar/ReportsHtml.cc
@@ -121,8 +121,8 @@ namespace Coverage {
   "\n"
   "\n"
   "\n"
-  "\n"
-  "\n"
+  "\n"
+  "\n"
 );
 
 return aFile;
diff --git a/tester/rt/coverage.py b/tester/rt/coverage.py
index d62c853..ec3957c 100644
--- a/tester/rt/coverage.py
+++ b/tester/rt/coverage.py
@@ -137,6 +137,8 @@ class report_gen_html:
 head_section += 'text-align:center;' + os.linesep
 head_section += '  }' + os.linesep
 head_section += ' ' + os.linesep
+head_section += ' ' + os.linesep
+head_section += ' ' + os.linesep
 head_section += '' + os.linesep
 return head_section
 
@@ -221,11 +223,10 @@ class report_gen_html:
 def add_covoar_css(self):
 table_js_path = path.join(self.covoar_src_path, 'table.js')
 covoar_css_path = path.join(self.covoar_src_path, 'covoar.css')
-for symbol_set in self.symbol_sets:
-symbol_set_dir = path.join(self.build_dir,
-   self.bsp + '-coverage', symbol_set)
-path.copy_tree(covoar_css_path, symbol_set_dir)
-path.copy_tree(table_js_path, symbol_set_dir)
+coverage_directory = path.join(self.build_dir,
+self.bsp + '-coverage')
+path.copy_tree(covoar_css_path, coverage_directory)
+path.copy_tree(table_js_path, coverage_directory)
 
 def add_dir_name(self):
 for symbol_set in self.symbol_sets:
-- 
2.27.0

___
devel mailing list
devel@rtems.org
http://lists.rtems.org/mailman/listinfo/devel


[PATCH 4/4] coverage: Give coverage bars red background

2021-03-12 Thread Alex White
---
 tester/rt/coverage.py | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/tester/rt/coverage.py b/tester/rt/coverage.py
index ec3957c..a561d26 100644
--- a/tester/rt/coverage.py
+++ b/tester/rt/coverage.py
@@ -129,6 +129,9 @@ class report_gen_html:
 head_section += 'width: 150px;' + os.linesep
 head_section += 'height: 15px;' + os.linesep
 head_section += '  }' + os.linesep
+head_section += '  progress::-webkit-progress-bar {' + os.linesep
+head_section += 'background: red;' + os.linesep
+head_section += '  }' + os.linesep
 head_section += '  table, th, td {' + os.linesep
 head_section += 'border: 1px solid black;' + os.linesep
 head_section += 'border-collapse: collapse;' + os.linesep
-- 
2.27.0

___
devel mailing list
devel@rtems.org
http://lists.rtems.org/mailman/listinfo/devel


[PATCH 0/4] coverage/reports: Improve coverage reports

2021-03-12 Thread Alex White
This patch set includes a few improvements to the coverage reports.

Alex White (4):
  covoar/reports: Add new statistics to summary
  coverage/reports: Improve formatting and clarity
  coverage/reports: Share common JS and CSS in reports
  coverage: Give coverage bars red background

 tester/covoar/DesiredSymbols.cc   |  10 ++
 tester/covoar/DesiredSymbols.h|  24 -
 tester/covoar/ObjdumpProcessor.cc |   5 +
 tester/covoar/ReportsBase.cc  |  68 +++--
 tester/covoar/ReportsHtml.cc  | 163 +-
 tester/covoar/ReportsText.cc  |  76 --
 tester/rt/coverage.py |  66 
 7 files changed, 276 insertions(+), 136 deletions(-)

-- 
2.27.0

___
devel mailing list
devel@rtems.org
http://lists.rtems.org/mailman/listinfo/devel


[PATCH] covoar: Handle periods in symbols from objdump

2021-03-12 Thread Alex White
Occasionally the compiler will generate symbols that look similar to
symbols defined in RTEMS code except that they contain some suffix.
This looks to be related to compiler optimizations. Such symbols were
being treated as unique. For our purposes, they should be mapped to
the equivalent symbols in the DWARF info. This has been fixed.
---
 tester/covoar/ExecutableInfo.cc   | 35 ++-
 tester/covoar/ObjdumpProcessor.cc |  6 ++
 tester/covoar/SymbolTable.cc  | 12 ---
 3 files changed, 49 insertions(+), 4 deletions(-)

diff --git a/tester/covoar/ExecutableInfo.cc b/tester/covoar/ExecutableInfo.cc
index c4257f0..1396519 100644
--- a/tester/covoar/ExecutableInfo.cc
+++ b/tester/covoar/ExecutableInfo.cc
@@ -119,6 +119,22 @@ namespace Coverage {
 itsSymbol = theSymbolTable.getSymbol( address );
 if (itsSymbol != "") {
   it = coverageMaps.find( itsSymbol );
+  if (it == coverageMaps.end()) {
+size_t periodIndex = itsSymbol.find(".");
+
+if (periodIndex == std::string::npos) {
+  // Symbol name has no '.', can't do another lookup.
+  throw rld::error (itsSymbol, "ExecutableInfo::getCoverageMap");
+}
+
+it = coverageMaps.find(
+  itsSymbol.substr(0, periodIndex)
+);
+
+if (it == coverageMaps.end()) {
+  throw rld::error (itsSymbol, "ExecutableInfo::getCoverageMap");
+}
+  }
   aCoverageMap = (*it).second;
 }
 
@@ -150,8 +166,25 @@ namespace Coverage {
   )
   {
 CoverageMaps::iterator cmi = coverageMaps.find( symbolName );
-if ( cmi == coverageMaps.end() )
+if ( cmi != coverageMaps.end() ) {
+  return *(cmi->second);
+}
+
+size_t periodIndex = symbolName.find(".");
+
+if (periodIndex == std::string::npos) {
+  // Symbol name has no '.', can't do another lookup.
   throw rld::error (symbolName, "ExecutableInfo::findCoverageMap");
+}
+
+cmi = coverageMaps.find(
+  symbolName.substr(0, periodIndex)
+);
+
+if ( cmi == coverageMaps.end() ) {
+  throw rld::error (symbolName, "ExecutableInfo::findCoverageMap");
+}
+
 return *(cmi->second);
   }
 
diff --git a/tester/covoar/ObjdumpProcessor.cc 
b/tester/covoar/ObjdumpProcessor.cc
index 9d10a40..a71b00d 100644
--- a/tester/covoar/ObjdumpProcessor.cc
+++ b/tester/covoar/ObjdumpProcessor.cc
@@ -420,6 +420,12 @@ namespace Coverage {
 processSymbol = false;
 theInstructions.clear();
 
+// Look for a '.' character and strip everything after it.
+char *periodIndex = strstr(symbol, ".");
+if (periodIndex != NULL) {
+  *periodIndex = 0;
+}
+
 // See if the new symbol is one that we care about.
 if (SymbolsToAnalyze->isDesired( symbol )) {
   currentSymbol = symbol;
diff --git a/tester/covoar/SymbolTable.cc b/tester/covoar/SymbolTable.cc
index 53bc8af..00062cc 100644
--- a/tester/covoar/SymbolTable.cc
+++ b/tester/covoar/SymbolTable.cc
@@ -46,12 +46,18 @@ namespace Coverage {
 symbolData.startingAddress = start;
 symbolData.length = length;
 
-if ( info[ symbol ].empty() == false ) {
-  if ( info[ symbol ].front().length != length ) {
+for (auto& symData : info[ symbol ]) {
+  // The starting address could differ since we strip any suffixes 
beginning
+  // with a '.'
+  if (symData.startingAddress != start) {
+continue;
+  }
+
+  if (symData.length != length) {
 std::ostringstream what;
 what << "Different lengths for the symbol "
  << symbol
- << " (" << info[ symbol ].front().length
+ << " (" << symData.length
  << " and " << length
  << ")";
 throw rld::error( what, "SymbolTable::addSymbol" );
-- 
2.27.0

___
devel mailing list
devel@rtems.org
http://lists.rtems.org/mailman/listinfo/devel


[PATCH] covoar: Account for build path change

2021-03-12 Thread Alex White
Covoar had not been updated to account for the paths used by the new
build system. This has been fixed.
---
 tester/covoar/covoar.cc | 5 -
 1 file changed, 5 deletions(-)

diff --git a/tester/covoar/covoar.cc b/tester/covoar/covoar.cc
index 84d883a..bf95cb4 100644
--- a/tester/covoar/covoar.cc
+++ b/tester/covoar/covoar.cc
@@ -69,11 +69,6 @@ static void createBuildPath(Executables& 
executablesToAnalyze,
   }
 }
 ++pri;
-if (pri == eparts.rend() || *pri != "c") {
-  fail = "invalid executable path, no 'c'";
-  break;
-}
-++pri;
 if (pri == eparts.rend()) {
   fail = "invalid executable path, no arch prefix";
   break;
-- 
2.27.0

___
devel mailing list
devel@rtems.org
http://lists.rtems.org/mailman/listinfo/devel


[PATCH v1 1/3] cpukit/aarch64: Add ESR register decoding

2021-03-12 Thread Kinsey Moore
From: Alex White 

---
 .../aarch64/aarch64-exception-frame-print.c   | 83 ++-
 1 file changed, 79 insertions(+), 4 deletions(-)

diff --git a/cpukit/score/cpu/aarch64/aarch64-exception-frame-print.c 
b/cpukit/score/cpu/aarch64/aarch64-exception-frame-print.c
index 59b5d06032..71d94b2f85 100644
--- a/cpukit/score/cpu/aarch64/aarch64-exception-frame-print.c
+++ b/cpukit/score/cpu/aarch64/aarch64-exception-frame-print.c
@@ -43,10 +43,70 @@
 #endif
 
 #include 
+#include 
 
 #include 
 #include 
 
+const char* _exception_class_to_string( uint16_t exception_class );
+
+void _binary_sprintf(
+  char *s,
+  size_t maxlen,
+  uint32_t num_bits,
+  uint32_t value
+);
+
+const char* _exception_class_to_string( uint16_t exception_class )
+{
+  switch (exception_class)
+  {
+  case 0b01: return "Trapped WFI or WFE instruction";
+  case 0b11: return "Trapped MCR or MRC access with (coproc==0b)";
+  case 0b000100: return "Trapped MCRR or MRRC access with (coproc==0b)";
+  case 0b000101: return "Trapped MCR or MRC access with (coproc==0b1110)";
+  case 0b000110: return "Trapped LDC or STC access";
+  case 0b001100: return "Trapped MRRC access with (coproc==0b1110)";
+  case 0b001110: return "Illegal Execution state";
+  case 0b011000: return "Trapped MSR, MRS, or System instruction";
+  case 0b10: return "Instruction Abort from a lower Exception level";
+  case 0b11: return "Instruction Abort taken without a change in Exception 
"
+"level";
+  case 0b100010: return "PC alignment fault";
+  case 0b100100: return "Data Abort from a lower Exception level";
+  case 0b100101: return "Data Abort taken without a change in Exception level";
+  case 0b100110: return "SP alignment fault";
+  case 0b11: return "Breakpoint exception from a lower Exception level";
+  case 0b110001: return "Breakpoint exception taken without a change in "
+"Exception level";
+  case 0b110010: return "Software Step exception from a lower Exception level";
+  case 0b110011: return "Software Step exception taken without a change in "
+"Exception level";
+  case 0b110100: return "Watchpoint exception from a lower Exception level";
+  case 0b110101: return "Watchpoint exception taken without a change in "
+"Exception level";
+  case 0b111000: return "BKPT instruction execution in AArch32 state";
+  case 0b00: return "BRK instruction execution in AArch64 state";
+  default: return "Unknown";
+  }
+}
+
+void _binary_sprintf(
+  char *s,
+  size_t maxlen,
+  uint32_t num_bits,
+  uint32_t value
+)
+{
+  uint32_t mask = 1<<(num_bits-1);
+  int cx = 0;
+
+  while ( mask != 0 ) {
+cx += snprintf(s + cx, maxlen - cx, "%d", (value ? 1 : 0));
+mask >>= 1;
+  }
+}
+
 void _CPU_Exception_frame_print( const CPU_Exception_frame *frame )
 {
   printk(
@@ -68,8 +128,7 @@ void _CPU_Exception_frame_print( const CPU_Exception_frame 
*frame )
 "X14  = 0x%016" PRIx64  " SP   = 0x%016" PRIxPTR "\n"
 "X15  = 0x%016" PRIx64  " PC   = 0x%016" PRIxPTR "\n"
 "X16  = 0x%016" PRIx64  " DAIF = 0x%016" PRIx64 "\n"
-"VEC  = 0x%016" PRIxPTR " CPSR = 0x%016" PRIx64 "\n"
-"ESR  = 0x%016" PRIx64  " FAR  = 0x%016" PRIx64 "\n",
+"VEC  = 0x%016" PRIxPTR " CPSR = 0x%016" PRIx64 "\n",
 frame->register_x0, frame->register_x17,
 frame->register_x1, frame->register_x18,
 frame->register_x2, frame->register_x19,
@@ -87,10 +146,26 @@ void _CPU_Exception_frame_print( const CPU_Exception_frame 
*frame )
 frame->register_x14, (intptr_t)frame->register_sp,
 frame->register_x15, (intptr_t)frame->register_pc,
 frame->register_x16, frame->register_daif,
-(intptr_t) frame->vector, frame->register_cpsr,
-frame->register_syndrome, frame->register_fault_address
+(intptr_t) frame->vector, frame->register_cpsr
+  );
+
+  uint32_t ec = (frame->register_syndrome >> 26) & 0x3f;
+  uint32_t il = (frame->register_syndrome >> 25) & 0x1;
+  uint32_t iss = frame->register_syndrome & 0x1ff;
+  char ec_str[7];
+  char iss_str[26];
+
+  _binary_sprintf(ec_str, 7, 6, ec);
+  _binary_sprintf(iss_str, 26, 25, iss);
+
+  printk(
+"ESR  = EC: 0b%s" " IL: 0b%d" " ISS: 0b%s" "\n"
+"   %s\n",
+ec_str, il, iss_str, _exception_class_to_string(ec)
   );
 
+  printk( "FAR  = 0x%016" PRIx64 "\n", frame->register_fault_address );
+
   const uint128_t *qx = >register_q0;
   int i;
 
-- 
2.20.1

___
devel mailing list
devel@rtems.org
http://lists.rtems.org/mailman/listinfo/devel


[PATCH v1 2/3] score/aarch64: Align context validation frame

2021-03-12 Thread Kinsey Moore
Ensure the stack remains aligned when validating the context frame to
avoid stack alignment exceptions.
---
 .../cpu/aarch64/aarch64-context-validate.S | 18 +-
 1 file changed, 9 insertions(+), 9 deletions(-)

diff --git a/cpukit/score/cpu/aarch64/aarch64-context-validate.S 
b/cpukit/score/cpu/aarch64/aarch64-context-validate.S
index 57f634934b..fb4fbd6379 100644
--- a/cpukit/score/cpu/aarch64/aarch64-context-validate.S
+++ b/cpukit/score/cpu/aarch64/aarch64-context-validate.S
@@ -54,18 +54,18 @@
 #define FRAME_OFFSET_LR  0x40
 
 #ifdef AARCH64_MULTILIB_VFP
-  #define FRAME_OFFSET_V8  0x48
-  #define FRAME_OFFSET_V9  0x58
-  #define FRAME_OFFSET_V10 0x68
-  #define FRAME_OFFSET_V11 0x78
-  #define FRAME_OFFSET_V12 0x88
-  #define FRAME_OFFSET_V13 0x98
-  #define FRAME_OFFSET_V14 0xA8
-  #define FRAME_OFFSET_V15 0xB8
+  #define FRAME_OFFSET_V8  0x50
+  #define FRAME_OFFSET_V9  0x60
+  #define FRAME_OFFSET_V10 0x70
+  #define FRAME_OFFSET_V11 0x80
+  #define FRAME_OFFSET_V12 0x90
+  #define FRAME_OFFSET_V13 0xA0
+  #define FRAME_OFFSET_V14 0xB0
+  #define FRAME_OFFSET_V15 0xC0
 
   #define FRAME_SIZE (FRAME_OFFSET_V15 + 0x10)
 #else
-  #define FRAME_SIZE (FRAME_OFFSET_LR + 0x08)
+  #define FRAME_SIZE (FRAME_OFFSET_LR + 0x10)
 #endif
 
.section.text
-- 
2.20.1

___
devel mailing list
devel@rtems.org
http://lists.rtems.org/mailman/listinfo/devel


[PATCH v1 3/3] bsps/xilinx-zynqmp: Avoid constant UART reinit

2021-03-12 Thread Kinsey Moore
Constantly reinitializing the Cadence UART on every character output
causes data corruption/loss. Only initialize the UART once for early
output.
---
 bsps/aarch64/xilinx-zynqmp/console/console.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/bsps/aarch64/xilinx-zynqmp/console/console.c 
b/bsps/aarch64/xilinx-zynqmp/console/console.c
index 84e158d3f6..d1948f1a0c 100644
--- a/bsps/aarch64/xilinx-zynqmp/console/console.c
+++ b/bsps/aarch64/xilinx-zynqmp/console/console.c
@@ -112,6 +112,7 @@ static void zynqmp_debug_console_early_init(char c)
 _uart_instances[BSP_CONSOLE_MINOR].base;
 
   zynq_uart_initialize(base);
+  BSP_output_char = zynqmp_debug_console_out;
   zynqmp_debug_console_out(c);
 }
 
-- 
2.20.1

___
devel mailing list
devel@rtems.org
http://lists.rtems.org/mailman/listinfo/devel


[PATCH v3 0/2] Fix NOP recognition

2021-03-12 Thread Alex White
v3:
- Fix double increment of rangeIndex in Coverage::finalizeSymbol()

v2:
- Fix leftover debugging code in Coverage::finalizeSymbol()

This patch set fixes a couple cases where NOP instructions were showing
up as unexecuted in coverage reports.

Alex White (2):
  covoar: Fix NOP execution marking
  covoar/Target_i386: Add NOP patterns

 tester/covoar/CoverageMapBase.cc  |  10 +++
 tester/covoar/CoverageMapBase.h   |   4 ++
 tester/covoar/DesiredSymbols.cc   |  38 --
 tester/covoar/DesiredSymbols.h|  11 ++-
 tester/covoar/ObjdumpProcessor.cc | 112 +++---
 tester/covoar/Target_i386.cc  |   9 +++
 6 files changed, 149 insertions(+), 35 deletions(-)

-- 
2.27.0

___
devel mailing list
devel@rtems.org
http://lists.rtems.org/mailman/listinfo/devel


[PATCH v3 1/2] covoar: Fix NOP execution marking

2021-03-12 Thread Alex White
Some NOP instructions were not being marked as executed because they
are located at the end of uncovered ranges. This has been fixed.
---
 tester/covoar/CoverageMapBase.cc  |  10 +++
 tester/covoar/CoverageMapBase.h   |   4 ++
 tester/covoar/DesiredSymbols.cc   |  38 --
 tester/covoar/DesiredSymbols.h|  11 ++-
 tester/covoar/ObjdumpProcessor.cc | 112 +++---
 5 files changed, 140 insertions(+), 35 deletions(-)

diff --git a/tester/covoar/CoverageMapBase.cc b/tester/covoar/CoverageMapBase.cc
index ad0080d..6ca5cf7 100644
--- a/tester/covoar/CoverageMapBase.cc
+++ b/tester/covoar/CoverageMapBase.cc
@@ -142,6 +142,11 @@ namespace Coverage {
 return size;
   }
 
+  uint32_t CoverageMapBase::getSizeOfRange( size_t index ) const
+  {
+return Ranges.at(index).size();
+  }
+
   bool CoverageMapBase::getBeginningOfInstruction(
 uint32_t  address,
 uint32_t* beginning
@@ -178,6 +183,11 @@ namespace Coverage {
 return Ranges.front().lowAddress;
   }
 
+  uint32_t CoverageMapBase::getLowAddressOfRange( size_t index ) const
+  {
+return Ranges.at(index).lowAddress;
+  }
+
   bool CoverageMapBase::getRange( uint32_t address, AddressRange& range ) const
   {
 for ( auto r : Ranges ) {
diff --git a/tester/covoar/CoverageMapBase.h b/tester/covoar/CoverageMapBase.h
index 6ad76d3..a58c696 100644
--- a/tester/covoar/CoverageMapBase.h
+++ b/tester/covoar/CoverageMapBase.h
@@ -156,6 +156,8 @@ namespace Coverage {
  */
 int32_t getFirstLowAddress() const;
 
+uint32_t getLowAddressOfRange( size_t index ) const;
+
 /*!
  *  This method returns true and sets the address range if
  *  the address falls with the bounds of an address range
@@ -177,6 +179,8 @@ namespace Coverage {
  */
 uint32_t getSize() const;
 
+uint32_t getSizeOfRange( size_t index ) const;
+
 /*!
  *  This method returns the address of the beginning of the
  *  instruction that contains the specified address.
diff --git a/tester/covoar/DesiredSymbols.cc b/tester/covoar/DesiredSymbols.cc
index b9a5bb7..c97b25c 100644
--- a/tester/covoar/DesiredSymbols.cc
+++ b/tester/covoar/DesiredSymbols.cc
@@ -142,7 +142,7 @@ namespace Coverage {
   CoverageMapBase* theCoverageMap = s.second.unifiedCoverageMap;
   if (theCoverageMap)
   {
-// Increment the total sizeInBytes byt the bytes in the symbol
+// Increment the total sizeInBytes by the bytes in the symbol
 stats.sizeInBytes += s.second.stats.sizeInBytes;
 
 // Now scan through the coverage map of this symbol.
@@ -202,6 +202,26 @@ namespace Coverage {
 uint32_t count;
 
 // Mark NOPs as executed
+a = s.second.stats.sizeInBytes - 1;
+count = 0;
+while (a > 0) {
+  if (theCoverageMap->isStartOfInstruction( a )) {
+break;
+  }
+
+  count++;
+
+  if (theCoverageMap->isNop( a )) {
+for (la = a; la < (a + count); la++) {
+  theCoverageMap->setWasExecuted( la );
+}
+
+count = 0;
+  }
+
+  a--;
+}
+
 endAddress = s.second.stats.sizeInBytes - 1;
 a = 0;
 while (a < endAddress) {
@@ -223,12 +243,13 @@ namespace Coverage {
   ha++;
   if ( ha >= endAddress )
 break;
-} while ( !theCoverageMap->isStartOfInstruction( ha ) );
+} while ( !theCoverageMap->isStartOfInstruction( ha ) ||
+  theCoverageMap->isNop( ha ) );
   a = ha;
 }
 
 // Now scan through the coverage map of this symbol.
-endAddress = s.second.stats.sizeInBytes - 1;
+endAddress = s.second.stats.sizeInBytesWithoutNops - 1;
 a = 0;
 while (a <= endAddress) {
   // If an address was NOT executed, find consecutive unexecuted
@@ -316,7 +337,8 @@ namespace Coverage {
   void DesiredSymbols::createCoverageMap(
 const std::string& exefileName,
 const std::string& symbolName,
-uint32_t   size
+uint32_t   size,
+uint32_t   sizeWithoutNops
   )
   {
 CoverageMapBase* aCoverageMap;
@@ -354,9 +376,10 @@ namespace Coverage {
   << '/' << size << ')'
   << std::endl;
 
-if ( itr->second.stats.sizeInBytes < size )
+if ( itr->second.stats.sizeInBytes < size ) {
   itr->second.stats.sizeInBytes = size;
-else
+  itr->second.stats.sizeInBytesWithoutNops = sizeWithoutNops;
+} else
   size = itr->second.stats.sizeInBytes;
   }
 }
@@ -376,6 +399,7 @@ namespace Coverage {
 );
   itr->second.unifiedCoverageMap = aCoverageMap;
   itr->second.stats.sizeInBytes = size;
+  itr->second.stats.sizeInBytesWithoutNops = sizeWithoutNops;
 }
   }
 
@@ -479,7 +503,7 @@ namespace Coverage {
 // are the same size.
 // Changed from ERROR msg to INFO, because size 

[PATCH v3 2/2] covoar/Target_i386: Add NOP patterns

2021-03-12 Thread Alex White
A couple of NOP patterns found with the pc686 BSP were not detected.
This has been fixed.
---
 tester/covoar/Target_i386.cc | 9 +
 1 file changed, 9 insertions(+)

diff --git a/tester/covoar/Target_i386.cc b/tester/covoar/Target_i386.cc
index e0c9c0f..4567c1e 100644
--- a/tester/covoar/Target_i386.cc
+++ b/tester/covoar/Target_i386.cc
@@ -87,6 +87,15 @@ namespace Target {
   size = 3;
   return true;
 }
+if (!strncmp( [strlen(line)-28], "lea0x0(%esi,%eiz,1),%esi", 28)) 
{
+  // Could be 4 or 7 bytes of padding.
+  if (!strncmp( [strlen(line)-32], "00", 2)) {
+size = 7;
+  } else {
+size = 4;
+  }
+  return true;
+}
 
 return false;
   }
-- 
2.27.0

___
devel mailing list
devel@rtems.org
http://lists.rtems.org/mailman/listinfo/devel


[PATCH 5/5] rtl-shell.c: Resource leak (CID #1444140)

2021-03-12 Thread Ryan Long
CID 1444140: Resource leak in rtems_rtl_shell_object().

Closes #4300
---
 cpukit/libdl/rtl-shell.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/cpukit/libdl/rtl-shell.c b/cpukit/libdl/rtl-shell.c
index 9f8a136..bcecdd4 100644
--- a/cpukit/libdl/rtl-shell.c
+++ b/cpukit/libdl/rtl-shell.c
@@ -733,14 +733,17 @@ rtems_rtl_shell_object (const rtems_printer* printer, int 
argc, char* argv[])
 if (dlinfo (RTLD_SELF, RTLD_DI_UNRESOLVED, ) < 0)
 {
   rtems_printf (printer, "error: %s: %s\n", argv[arg], dlerror ());
+  (void) dlclose (handle);
   return 1;
 }
 
 if (unresolved != 0)
 {
   rtems_printf (printer, "warning: unresolved symbols present\n");
+  (void) dlclose (handle);
   return 1;
 }
+  (void) dlclose (handle);
   }
   else if (strcmp (argv[arg], "unload") == 0)
   {
-- 
1.8.3.1

___
devel mailing list
devel@rtems.org
http://lists.rtems.org/mailman/listinfo/devel


[PATCH 4/5] flashdisk.c: Fix Resource leak (CID #1439298)

2021-03-12 Thread Ryan Long
CID 1439298: Resource leak in rtems_fdisk_initialize().

Closes #4299
---
 cpukit/libblock/src/flashdisk.c | 42 ++---
 1 file changed, 31 insertions(+), 11 deletions(-)

diff --git a/cpukit/libblock/src/flashdisk.c b/cpukit/libblock/src/flashdisk.c
index 91f99e0..c4bac82 100644
--- a/cpukit/libblock/src/flashdisk.c
+++ b/cpukit/libblock/src/flashdisk.c
@@ -2463,6 +2463,7 @@ rtems_fdisk_initialize (rtems_device_major_number major,
   {
 char name[] = RTEMS_FLASHDISK_DEVICE_BASE_NAME "a";
 uint32_t device;
+uint32_t device_to_free;
 uint32_t blocks = 0;
 int  ret;
 
@@ -2485,18 +2486,27 @@ rtems_fdisk_initialize (rtems_device_major_number major,
  * One copy buffer of a page size.
  */
 fd->copy_buffer = malloc (c->block_size);
-if (!fd->copy_buffer)
+if (!fd->copy_buffer) {
+  free(fd);
   return RTEMS_NO_MEMORY;
+}
 
 fd->blocks = calloc (blocks, sizeof (rtems_fdisk_block_ctl));
-if (!fd->blocks)
+if (!fd->blocks) {
+  free(fd->copy_buffer);
+  free(fd);
   return RTEMS_NO_MEMORY;
+}
 
 fd->block_count = blocks;
 
 fd->devices = calloc (c->device_count, sizeof (rtems_fdisk_device_ctl));
-if (!fd->devices)
+if (!fd->devices) {
+  free (fd->blocks);
+  free (fd->copy_buffer);
+  free (fd);
   return RTEMS_NO_MEMORY;
+}
 
 rtems_mutex_init (>lock, "Flash Disk");
 
@@ -2505,9 +2515,10 @@ rtems_fdisk_initialize (rtems_device_major_number major,
 if (sc != RTEMS_SUCCESSFUL)
 {
   rtems_mutex_destroy (>lock);
-  free (fd->copy_buffer);
-  free (fd->blocks);
   free (fd->devices);
+  free (fd->blocks);
+  free (fd->copy_buffer);
+  free (fd);
   rtems_fdisk_error ("disk create phy failed");
   return sc;
 }
@@ -2524,11 +2535,14 @@ rtems_fdisk_initialize (rtems_device_major_number major,
  sizeof (rtems_fdisk_segment_ctl));
   if (!fd->devices[device].segments)
   {
+for (device_to_free = device - 1; device_to_free >= 0; 
device_to_free--)
+ free(fd->devices[device_to_free].segments);
 unlink (name);
 rtems_mutex_destroy (>lock);
-free (fd->copy_buffer);
-free (fd->blocks);
 free (fd->devices);
+free (fd->blocks);
+free (fd->copy_buffer);
+free (fd);
 return RTEMS_NO_MEMORY;
   }
 
@@ -2559,11 +2573,14 @@ rtems_fdisk_initialize (rtems_device_major_number major,
 ret = rtems_fdisk_recover_block_mappings (fd);
 if (ret)
 {
+  for (device_to_free = device - 1; device_to_free >= 0; device_to_free--)
+free(fd->devices[device_to_free].segments);
   unlink (name);
   rtems_mutex_destroy (>lock);
-  free (fd->copy_buffer);
-  free (fd->blocks);
   free (fd->devices);
+  free (fd->blocks);
+  free (fd->copy_buffer);
+  free (fd);
   rtems_fdisk_error ("recovery of disk failed: %s (%d)",
  strerror (ret), ret);
   return ret;
@@ -2572,11 +2589,14 @@ rtems_fdisk_initialize (rtems_device_major_number major,
 ret = rtems_fdisk_compact (fd);
 if (ret)
 {
+  for (device_to_free = device - 1; device_to_free >= 0; device_to_free--)
+free(fd->devices[device_to_free].segments);
   unlink (name);
   rtems_mutex_destroy (>lock);
-  free (fd->copy_buffer);
-  free (fd->blocks);
   free (fd->devices);
+  free (fd->blocks);
+  free (fd->copy_buffer);
+  free (fd);
   rtems_fdisk_error ("compacting of disk failed: %s (%d)",
  strerror (ret), ret);
   return ret;
-- 
1.8.3.1

___
devel mailing list
devel@rtems.org
http://lists.rtems.org/mailman/listinfo/devel


[PATCH 1/5] hexdump-parse.c: Fix Resource leak (CID #26032)

2021-03-12 Thread Ryan Long
CID 26032: Resource leak in rtems_shell_hexdump_rewrite().

Closes #4296
---
 cpukit/libmisc/shell/hexdump-parse.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/cpukit/libmisc/shell/hexdump-parse.c 
b/cpukit/libmisc/shell/hexdump-parse.c
index 88b9d56..5b56bbf 100644
--- a/cpukit/libmisc/shell/hexdump-parse.c
+++ b/cpukit/libmisc/shell/hexdump-parse.c
@@ -462,6 +462,9 @@ isint2: 
switch(fu->bcnt) {
(void)printf("\n");
}
 #endif
+#ifdef __rtems__
+   free(nextpr);
+#endif
 }
 
 void
-- 
1.8.3.1

___
devel mailing list
devel@rtems.org
http://lists.rtems.org/mailman/listinfo/devel


[PATCH 3/5] nvdisk.c: Fix Resource leak (CID #1439297)

2021-03-12 Thread Ryan Long
CID 1439297: Resource leak in rtems_nvdisk_initialize().

Closes #4298
---
 cpukit/libblock/src/nvdisk.c | 8 +++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/cpukit/libblock/src/nvdisk.c b/cpukit/libblock/src/nvdisk.c
index a7f4167..d742baf 100644
--- a/cpukit/libblock/src/nvdisk.c
+++ b/cpukit/libblock/src/nvdisk.c
@@ -766,8 +766,10 @@ rtems_nvdisk_initialize (rtems_device_major_number major 
RTEMS_UNUSED,
 nvd->info_level   = c->info_level;
 
 nvd->devices = calloc (c->device_count, sizeof (rtems_nvdisk_device_ctl));
-if (!nvd->devices)
+if (!nvd->devices) {
+  free(nvd);
   return RTEMS_NO_MEMORY;
+}
 
 for (device = 0; device < c->device_count; device++)
 {
@@ -790,6 +792,8 @@ rtems_nvdisk_initialize (rtems_device_major_number major 
RTEMS_UNUSED,
  rtems_nvdisk_ioctl, nvd);
 if (sc != RTEMS_SUCCESSFUL)
 {
+  free(nvd->devices);
+  free(nvd);
   rtems_nvdisk_error ("disk create phy failed");
   return sc;
 }
@@ -797,5 +801,7 @@ rtems_nvdisk_initialize (rtems_device_major_number major 
RTEMS_UNUSED,
 rtems_mutex_init (>lock, "NV Disk");
   }
 
+  free(nvd->devices);
+  free(nvd);
   return RTEMS_SUCCESSFUL;
 }
-- 
1.8.3.1

___
devel mailing list
devel@rtems.org
http://lists.rtems.org/mailman/listinfo/devel


[PATCH 0/5] Fix Resource leak Coverity issues

2021-03-12 Thread Ryan Long
Hi,

For these issues I just needed to free dynamically allocated variables.
Most of these additions were in areas that were error-checking and
returning early. For flashdisk.c, this was the case as well, but it had
nested, dynamically allocated list of values that had to be freed using
a for loop.

Thanks,
Ryan 

Ryan Long (5):
  hexdump-parse.c: Fix Resource leak (CID #26032)
  rtems-fdt.c: Fix Resource leak (CID #1437645)
  nvdisk.c: Fix Resource leak (CID #1439297)
  flashdisk.c: Fix Resource leak (CID #1439298)
  rtl-shell.c: Resource leak (CID #1444140)

 cpukit/libblock/src/flashdisk.c  | 42 ++--
 cpukit/libblock/src/nvdisk.c |  8 ++-
 cpukit/libdl/rtl-shell.c |  3 +++
 cpukit/libmisc/rtems-fdt/rtems-fdt.c |  1 +
 cpukit/libmisc/shell/hexdump-parse.c |  3 +++
 5 files changed, 45 insertions(+), 12 deletions(-)

-- 
1.8.3.1

___
devel mailing list
devel@rtems.org
http://lists.rtems.org/mailman/listinfo/devel


[PATCH 2/5] rtems-fdt.c: Fix Resource leak (CID #1437645)

2021-03-12 Thread Ryan Long
CID 1437645: Resource leak in rtems_fdt_load().

Closes #4297
---
 cpukit/libmisc/rtems-fdt/rtems-fdt.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/cpukit/libmisc/rtems-fdt/rtems-fdt.c 
b/cpukit/libmisc/rtems-fdt/rtems-fdt.c
index 0ea3653..5bb7ce0 100644
--- a/cpukit/libmisc/rtems-fdt/rtems-fdt.c
+++ b/cpukit/libmisc/rtems-fdt/rtems-fdt.c
@@ -611,6 +611,7 @@ rtems_fdt_load (const char* filename, rtems_fdt_handle* 
handle)
 return fe;
   }
 
+  close (bf);
   return 0;
 }
 
-- 
1.8.3.1

___
devel mailing list
devel@rtems.org
http://lists.rtems.org/mailman/listinfo/devel


[PATCH 2/2] main_rtrace.c: Fix Dereference after null check (CID #1399709)

2021-03-12 Thread Ryan Long
CID 1399709: Dereference after null check in
rtems_trace_buffering_shell_save().

Closes #4329
---
 cpukit/libmisc/shell/main_rtrace.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/cpukit/libmisc/shell/main_rtrace.c 
b/cpukit/libmisc/shell/main_rtrace.c
index 753ab9d..e4f59c4 100644
--- a/cpukit/libmisc/shell/main_rtrace.c
+++ b/cpukit/libmisc/shell/main_rtrace.c
@@ -473,6 +473,7 @@ rtems_trace_buffering_shell_save (int argc, char *argv[])
   {
 close (out);
 printf ("error: no memory\n");
+return 1;
   }
 
   memset (buf, 0, SAVE_BUF_SIZE);
-- 
1.8.3.1

___
devel mailing list
devel@rtems.org
http://lists.rtems.org/mailman/listinfo/devel


[PATCH 1/2] objectextendinformation.c: Fix Dereference after null check (CID #26033)

2021-03-12 Thread Ryan Long
CID 26033: Dereference after null check in _Objects_Extend_information().

Closes #4326
---
 cpukit/score/src/objectextendinformation.c | 11 +++
 1 file changed, 11 insertions(+)

diff --git a/cpukit/score/src/objectextendinformation.c 
b/cpukit/score/src/objectextendinformation.c
index 9796eb9..c669301 100644
--- a/cpukit/score/src/objectextendinformation.c
+++ b/cpukit/score/src/objectextendinformation.c
@@ -171,6 +171,17 @@ Objects_Maximum _Objects_Extend_information(
 
 if ( old_maximum > extend_count ) {
   /*
+   * Coverity thinks there is a way for this to be NULL (CID #26033).
+   * After much time spent analyzing this, no one has identified the
+   * conditions where this can actually occur. Adding this _Assert ensures
+   * that it is never NULL. If this assert is triggered, condition
+   * generating this case will have been identified and it can be revisted.
+   * This is being done out of an abundance of caution since we could have
+   * easily flagged this as a false positive and ignored it completely.
+   */
+  _Assert(information->object_blocks != NULL);
+
+  /*
*  Copy each section of the table over. This has to be performed as
*  separate parts as size of each block has changed.
*/
-- 
1.8.3.1

___
devel mailing list
devel@rtems.org
http://lists.rtems.org/mailman/listinfo/devel


[PATCH 0/2] Fix Dereference after null check Coverity issues

2021-03-12 Thread Ryan Long
Hi,

For these issues, I needed to make sure that a value that could be NULL
would not be dereferenced. For objectextendinformation.c, an assert was
added, and in main_rtrace.c a return was added to the check.

Thanks,
Ryan

Ryan Long (2):
  objectextendinformation.c: Fix Dereference after null check (CID
#26033)
  main_rtrace.c: Fix Dereference after null check (CID #1399709)

 cpukit/libmisc/shell/main_rtrace.c |  1 +
 cpukit/score/src/objectextendinformation.c | 11 +++
 2 files changed, 12 insertions(+)

-- 
1.8.3.1

___
devel mailing list
devel@rtems.org
http://lists.rtems.org/mailman/listinfo/devel


Re: Fwd: New Defects reported by Coverity Scan for RTEMS

2021-03-12 Thread Joel Sherrill
Luckily I think it is an easy one. Checking if an unsigned value is less
than 0.

Look back in the history. Ryan may have fixed it once and you just
accidentally
reverted it. He fixed a handful like this.

I'm sorry you were the first to be caught by it but I am thrilled to have
Coverity
run automatically about midnight Central time every night if there were any
changes to the RSB or RTEMS repos. Then it sends an email to build@ if
any new issues turned up. Definitely progress has been made here.

--joel

On Fri, Mar 12, 2021 at 7:22 AM Daniel Hellstrom  wrote:

> yes, it must have, so I will look into that.
>
> /Daniel
>
>On 2021-03-12 14:07, Joel Sherrill wrote:
>
> Without looking, I would assume this was introduced by Daniel's recent
> patches.
>
> -- Forwarded message -
> From: 
> Date: Fri, Mar 12, 2021, 12:55 AM
> Subject: New Defects reported by Coverity Scan for RTEMS
> To: 
>
>
> Hi,
>
> Please find the latest report on new defect(s) introduced to RTEMS found
> with Coverity Scan.
>
> 1 new defect(s) introduced to RTEMS found with Coverity Scan.
>
>
> New defect(s) Reported-by: Coverity Scan
> Showing 1 of 1 defect(s)
>
>
> ** CID 1473629:  Control flow issues  (NO_EFFECT)
> /bsps/shared/grlib/can/grcanfd.c: 323 in grcan_hw_write_try_fd()
>
>
>
> 
> *** CID 1473629:  Control flow issues  (NO_EFFECT)
> /bsps/shared/grlib/can/grcanfd.c: 323 in grcan_hw_write_try_fd()
> 317 bds = 1;
> 318 if (space_left < bds)
> 319 break;
> 320
> 321 /* Convert and write CAN message to DMA buffer */
> 322 dlc = grcan_len2dlc(source->len);
> >>> CID 1473629:  Control flow issues  (NO_EFFECT)
> >>> This less-than-zero comparison of an unsigned value is never true.
> "dlc < 0".
> 323 if (dlc < 0) {
> 324 /* Bad user input. Report the number of
> written messages
> 325  * or an error when non sent.
> 326  */
> 327 if (ret <= 0)
> 328 return GRCAN_RET_INVARG;
>
>
>
> 
> To view the defects in Coverity Scan visit,
> https://u15810271.ct.sendgrid.net/ls/click?upn=HRESupC-2F2Czv4BOaCWWCy7my0P0qcxCbhZ31OYv50ypUUzi-2FdSNmuyRB7BEFT8xQ4-2B8hpujh0hTgQljRGId4Dg-3D-3DVX3j_EU3W9teASMK00lBXX9WT4lsogDrkCcNZLvg-2FVxwAXMppdCoTOdWUHKtQLrEQ1MfSyaNP2M1HWoDjjoKTjy-2FIq1HdvVcL1npIuQDJWa-2FDWEQ-2FAOQo8VzAxUCWwGfT9lbXVNqnU0jQl-2FWSYNQAJPY2Tylmw5hG5KcV6hC39VfLDFtSor5xgUxBh-2BcdibW34mNQFj7qSSTl6hW9DF4ywtf1oYStmZyjbwIV0D1AeB2dPto-3D
>
> ___
> build mailing list
> bu...@rtems.org
> http://lists.rtems.org/mailman/listinfo/build
>
>
___
devel mailing list
devel@rtems.org
http://lists.rtems.org/mailman/listinfo/devel

Re: Fwd: New Defects reported by Coverity Scan for RTEMS

2021-03-12 Thread Daniel Hellstrom

yes, it must have, so I will look into that.

/Daniel

  


On 2021-03-12 14:07, Joel Sherrill wrote:
Without looking, I would assume this was introduced by Daniel's recent 
patches.


-- Forwarded message -
From: mailto:scan-ad...@coverity.com>>
Date: Fri, Mar 12, 2021, 12:55 AM
Subject: New Defects reported by Coverity Scan for RTEMS
To: mailto:bu...@rtems.org>>


Hi,

Please find the latest report on new defect(s) introduced to RTEMS 
found with Coverity Scan.


1 new defect(s) introduced to RTEMS found with Coverity Scan.


New defect(s) Reported-by: Coverity Scan
Showing 1 of 1 defect(s)


** CID 1473629:  Control flow issues  (NO_EFFECT)
/bsps/shared/grlib/can/grcanfd.c: 323 in grcan_hw_write_try_fd()



*** CID 1473629:  Control flow issues  (NO_EFFECT)
/bsps/shared/grlib/can/grcanfd.c: 323 in grcan_hw_write_try_fd()
317                             bds = 1;
318                     if (space_left < bds)
319                             break;
320
321                     /* Convert and write CAN message to DMA buffer */
322                     dlc = grcan_len2dlc(source->len);
>>>     CID 1473629:  Control flow issues  (NO_EFFECT)
>>>     This less-than-zero comparison of an unsigned value is never 
true. "dlc < 0".

323                     if (dlc < 0) {
324                             /* Bad user input. Report the number 
of written messages

325                              * or an error when non sent.
326                              */
327                             if (ret <= 0)
328                                     return GRCAN_RET_INVARG;



To view the defects in Coverity Scan visit, 
https://u15810271.ct.sendgrid.net/ls/click?upn=HRESupC-2F2Czv4BOaCWWCy7my0P0qcxCbhZ31OYv50ypUUzi-2FdSNmuyRB7BEFT8xQ4-2B8hpujh0hTgQljRGId4Dg-3D-3DVX3j_EU3W9teASMK00lBXX9WT4lsogDrkCcNZLvg-2FVxwAXMppdCoTOdWUHKtQLrEQ1MfSyaNP2M1HWoDjjoKTjy-2FIq1HdvVcL1npIuQDJWa-2FDWEQ-2FAOQo8VzAxUCWwGfT9lbXVNqnU0jQl-2FWSYNQAJPY2Tylmw5hG5KcV6hC39VfLDFtSor5xgUxBh-2BcdibW34mNQFj7qSSTl6hW9DF4ywtf1oYStmZyjbwIV0D1AeB2dPto-3D 



___
build mailing list
bu...@rtems.org 
http://lists.rtems.org/mailman/listinfo/build 

___
devel mailing list
devel@rtems.org
http://lists.rtems.org/mailman/listinfo/devel

Fwd: New Defects reported by Coverity Scan for RTEMS

2021-03-12 Thread Joel Sherrill
Without looking, I would assume this was introduced by Daniel's recent
patches.

-- Forwarded message -
From: 
Date: Fri, Mar 12, 2021, 12:55 AM
Subject: New Defects reported by Coverity Scan for RTEMS
To: 


Hi,

Please find the latest report on new defect(s) introduced to RTEMS found
with Coverity Scan.

1 new defect(s) introduced to RTEMS found with Coverity Scan.


New defect(s) Reported-by: Coverity Scan
Showing 1 of 1 defect(s)


** CID 1473629:  Control flow issues  (NO_EFFECT)
/bsps/shared/grlib/can/grcanfd.c: 323 in grcan_hw_write_try_fd()



*** CID 1473629:  Control flow issues  (NO_EFFECT)
/bsps/shared/grlib/can/grcanfd.c: 323 in grcan_hw_write_try_fd()
317 bds = 1;
318 if (space_left < bds)
319 break;
320
321 /* Convert and write CAN message to DMA buffer */
322 dlc = grcan_len2dlc(source->len);
>>> CID 1473629:  Control flow issues  (NO_EFFECT)
>>> This less-than-zero comparison of an unsigned value is never true.
"dlc < 0".
323 if (dlc < 0) {
324 /* Bad user input. Report the number of
written messages
325  * or an error when non sent.
326  */
327 if (ret <= 0)
328 return GRCAN_RET_INVARG;



To view the defects in Coverity Scan visit,
https://u15810271.ct.sendgrid.net/ls/click?upn=HRESupC-2F2Czv4BOaCWWCy7my0P0qcxCbhZ31OYv50ypUUzi-2FdSNmuyRB7BEFT8xQ4-2B8hpujh0hTgQljRGId4Dg-3D-3DVX3j_EU3W9teASMK00lBXX9WT4lsogDrkCcNZLvg-2FVxwAXMppdCoTOdWUHKtQLrEQ1MfSyaNP2M1HWoDjjoKTjy-2FIq1HdvVcL1npIuQDJWa-2FDWEQ-2FAOQo8VzAxUCWwGfT9lbXVNqnU0jQl-2FWSYNQAJPY2Tylmw5hG5KcV6hC39VfLDFtSor5xgUxBh-2BcdibW34mNQFj7qSSTl6hW9DF4ywtf1oYStmZyjbwIV0D1AeB2dPto-3D

___
build mailing list
bu...@rtems.org
http://lists.rtems.org/mailman/listinfo/build
___
devel mailing list
devel@rtems.org
http://lists.rtems.org/mailman/listinfo/devel

qoriq_e500 U-Boot Support in RTEMS

2021-03-12 Thread junkes
to use qoriq_e500 with legacy stack, I tried to define HAS_UBOOT to get 
tcsec-interfaces to work with RTEMS-5.

There is no u-boot-config.h in the qoriq_e500 bsp files.
This file is required by bsp/u-boot.h
Danke, Heinz
___
devel mailing list
devel@rtems.org
http://lists.rtems.org/mailman/listinfo/devel