Re: [PATCH] covoar: Handle periods in symbols from objdump

2021-03-15 Thread Chris Johns
On 16/3/21 8:26 am, Alex White wrote:
> The exceptions are being used as legitimate error cases. The "what" messages 
> that I use here are not helpful. I think that's why it looks like they're 
> being used as labels. 

Understood and thanks.

> As part of a revision of my "covoar: Fix NOP execution marking" patch that 
> I'll be sending out soon, this has been greatly simplified and a specific 
> exception class has been defined.
> 
> I'll get v2 of this patch out, and that should clear the exception handling 
> up.

Excellent.

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


RE: [PATCH] covoar: Handle periods in symbols from objdump

2021-03-15 Thread Alex White
The exceptions are being used as legitimate error cases. The "what" messages 
that I use here are not helpful. I think that's why it looks like they're being 
used as labels. 

As part of a revision of my "covoar: Fix NOP execution marking" patch that I'll 
be sending out soon, this has been greatly simplified and a specific exception 
class has been defined.

I'll get v2 of this patch out, and that should clear the exception handling up.

Alex

-Original Message-
From: Chris Johns  
Sent: Sunday, March 14, 2021 8:01 PM
To: Alex White ; devel@rtems.org
Subject: Re: [PATCH] covoar: Handle periods in symbols from objdump



On 13/3/21 3:37 am, Alex White wrote:
> 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");

The exception takes a what message and this looks like a label?

Is the exception being treated as signal to be caught in another place? I hope 
this is _not_ the case. Herb Sutter's write up is good place to start ...

https://www.drdobbs.com/when-and-how-to-use-exceptions/184401836

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


Re: [PATCH] covoar: Handle periods in symbols from objdump

2021-03-14 Thread Chris Johns



On 13/3/21 3:37 am, Alex White wrote:
> 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");

The exception takes a what message and this looks like a label?

Is the exception being treated as signal to be caught in another place? I hope
this is _not_ the case. Herb Sutter's write up is good place to start ...

https://www.drdobbs.com/when-and-how-to-use-exceptions/184401836

Chris
___
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