[PATCH 1/2] covoar: Store only the file name in ExecutableInfo

Chris Johns chrisj at rtems.org
Tue May 25 23:35:08 UTC 2021



On 4/5/21 7:07 pm, Gedare Bloom wrote:
> On Fri, Apr 30, 2021 at 2:02 PM Alex White <alex.white at oarcorp.com> wrote:
>>
>> This changes the ExecutableInfo class to only store the executable
>> file's name rather than an entire instance of rld::files::object. This
>> allows the rld::files::object to be cleaned up in the ExecutableInfo
>> constructor.
>>
>> Updates #4383
>> ---
>>  tester/covoar/ExecutableInfo.cc | 12 +++++-------
>>  tester/covoar/ExecutableInfo.h  | 10 +++++-----
>>  2 files changed, 10 insertions(+), 12 deletions(-)
>>
>> diff --git a/tester/covoar/ExecutableInfo.cc b/tester/covoar/ExecutableInfo.cc
>> index fc368ce..861e60d 100644
>> --- a/tester/covoar/ExecutableInfo.cc
>> +++ b/tester/covoar/ExecutableInfo.cc
>> @@ -21,7 +21,7 @@ namespace Coverage {
>>      const char* const theExecutableName,
>>      const char* const theLibraryName,
>>      bool              verbose
>> -    ) : executable(theExecutableName),
>> +    ) : fileName(theExecutableName),
>>          loadAddress(0)
>>    {
>>      if (theLibraryName != nullptr)
>> @@ -34,6 +34,8 @@ namespace Coverage {
>>        std::cerr << std::endl;
>>      }
>>
>> +    rld::files::object executable(theExecutableName);
>> +
>>      executable.open();
>>      executable.begin();
>>      executable.load_symbols(symbols);
>> @@ -82,8 +84,6 @@ namespace Coverage {
>>        }
>>      } catch (...) {
>>        debug.end();
>> -      executable.end();
>> -      executable.close();
> 
> I may be missing something, but don't you still need to end() and close() it?
> 

The object is now local scope so the object destructs when control exits the
block and that should clean things up.

Chris

>>        throw;
>>      }
>>
>> @@ -95,8 +95,6 @@ namespace Coverage {
>>    ExecutableInfo::~ExecutableInfo()
>>    {
>>      debug.end();
>> -    executable.end();
>> -    executable.close();
>>    }
>>
>>    void ExecutableInfo::dumpCoverageMaps( void ) {
>> @@ -132,9 +130,9 @@ namespace Coverage {
>>      return aCoverageMap;
>>    }
>>
>> -  const std::string ExecutableInfo::getFileName ( void ) const
>> +  const std::string& ExecutableInfo::getFileName ( void ) const
>>    {
>> -    return executable.name().full();
>> +    return fileName;
>>    }
>>
>>    const std::string ExecutableInfo::getLibraryName( void ) const
>> diff --git a/tester/covoar/ExecutableInfo.h b/tester/covoar/ExecutableInfo.h
>> index d5ccb19..5d5a595 100644
>> --- a/tester/covoar/ExecutableInfo.h
>> +++ b/tester/covoar/ExecutableInfo.h
>> @@ -77,7 +77,7 @@ namespace Coverage {
>>       *
>>       *  @return Returns the executable's file name
>>       */
>> -    const std::string getFileName( void ) const;
>> +    const std::string& getFileName( void ) const;
>>
>>      /*!
>>       *  This method returns the library name associated with the executable.
>> @@ -158,14 +158,14 @@ namespace Coverage {
>>      );
>>
>>      /*!
>> -     *  The ELF executable.
>> +     *  The DWARF data to the ELF executable.
>>       */
>> -    rld::files::object executable;
>> +    rld::dwarf::file debug;
>>
>>      /*!
>> -     *  The DWARF data to the ELF executable.
>> +     *  The executable's file name.
>>       */
>> -    rld::dwarf::file debug;
>> +    std::string fileName;
>>
>>      /*!
>>       *  The executable's symbol table.
>> --
>> 2.27.0
>>
>> _______________________________________________
>> devel mailing list
>> devel at rtems.org
>> http://lists.rtems.org/mailman/listinfo/devel
> _______________________________________________
> devel mailing list
> devel at rtems.org
> http://lists.rtems.org/mailman/listinfo/devel
> 


More information about the devel mailing list