[PATCH 18/22] covoar: Add option to create named objdumps
Alexander White
alexanderjwhite at gmail.com
Wed Mar 3 15:57:13 UTC 2021
On Tue, Mar 2, 2021 at 5:37 PM Chris Johns <chrisj at rtems.org> wrote:
> On 2/3/21 7:01 am, Alex White wrote:
> > This adds a new macro USE_TEMPLFILE 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.
>
> Is the USE_TEMPLFILE macro a debugging aid?
>
> If it is and it is useful could it be a command line argument to select a
> mode
> that allows debugging? It means the code is always seen by the compiler and
> built and anyone needing to chase down an issue has it available without
> needing
> the code and rebuilding it. Plus as an argument the command will have some
> help
> and that can be the documentation for this option.
>
Yes, it is both a debugging aid and a way to speed up execution.
I agree that it would be better as a command line argument. I will change
it and add it to the appropriate patch set.
>
> > ---
> > rtemstoolkit/rld-process.cpp | 12 ++++++++++++
> > rtemstoolkit/rld-process.h | 9 +++++++++
>
>
> > tester/covoar/ObjdumpProcessor.cc | 16 +++++++++++-----
> > tester/covoar/app_common.cc | 10 ++++++++++
> > tester/covoar/app_common.h | 1 +
> > tester/covoar/covoar.cc | 20 ++++++++++++++++++++
> > 6 files changed, 63 insertions(+), 5 deletions(-)
> >
> > diff --git a/rtemstoolkit/rld-process.cpp b/rtemstoolkit/rld-process.cpp
> > index 30e0605..d0352cb 100644
> > --- a/rtemstoolkit/rld-process.cpp
> > +++ b/rtemstoolkit/rld-process.cpp
> > @@ -169,6 +169,18 @@ namespace rld
> > _name = temporaries.get (suffix, _keep);
> > }
> >
> > + tempfile::tempfile (
> > + const std::string& name,
> > + const std::string& suffix,
> > + bool _keep
> > + ) : _name(name + suffix),
> > + suffix(suffix),
> > + overridden (false),
> > + fd (-1),
> > + level (0)
> > + {
> > + }
> > +
> > tempfile::~tempfile ()
> > {
> > try
> > diff --git a/rtemstoolkit/rld-process.h b/rtemstoolkit/rld-process.h
> > index fc9b7bc..16e0322 100644
> > --- a/rtemstoolkit/rld-process.h
> > +++ b/rtemstoolkit/rld-process.h
> > @@ -114,6 +114,15 @@ namespace rld
> > */
> > tempfile (const std::string& suffix = ".rldxx", bool keep =
> false);
> >
> > + /**
> > + * Get a temporary file name given a name and a suffix.
> > + */
> > + tempfile (
> > + const std::string& name,
> > + const std::string& suffix,
> > + bool _keep = false
> > + );
> > +
>
> The addition is fine but there is a minor nit, the coding format I used in
> this
> code from long ago is:
>
> tempfile (const std::string& name,
> const std::string& suffix,
> bool _keep = false);
>
> Would it be possible to keep it consistent with the other code, eg see
> `output`
> further down in this file?
>
> Should this also be a separate patch?
>
> Chris
>
I will fix this for my RLD patch set.
>
> > /**
> > * Clean up the temporary file.
> > */
> > diff --git a/tester/covoar/ObjdumpProcessor.cc
> b/tester/covoar/ObjdumpProcessor.cc
> > index 00824f1..f130819 100644
> > --- a/tester/covoar/ObjdumpProcessor.cc
> > +++ b/tester/covoar/ObjdumpProcessor.cc
> > @@ -245,12 +245,18 @@ 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" );
> > + #ifndef USE_TEMPFILE
> > + if (FileIsNewer( fileName.c_str(), objdumpFile.name().c_str() )) {
> > + #endif
> > + 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" );
> > + }
> > + #ifndef USE_TEMPFILE
> > }
> > + #endif
> > } catch( rld::error& err )
> > {
> > std::cout << "Error while running " << TargetInfo->getObjdump()
> > 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..bc1b7cf 100644
> > --- a/tester/covoar/covoar.cc
> > +++ b/tester/covoar/covoar.cc
> > @@ -162,7 +162,9 @@ int covoar(
> > FILE* gcnosFile = NULL;
> > Gcov::GcovData* gcovFile;
> > const char* singleExecutable = NULL;
> > + #ifdef USE_TEMPFILE
> > rld::process::tempfile objdumpFile( ".dmp" );
> > + #endif
> > rld::process::tempfile err( ".err" );
> > rld::process::tempfile syms( ".syms" );
> > bool debug = false;
> > @@ -373,6 +375,22 @@ int covoar(
> > exe->setLoadAddress( objdumpProcessor->determineLoadAddress( exe
> ) );
> > }
> >
> > + #ifndef USE_TEMPFILE
> > + std::string name;
> > +
> > + if ( !exe->hasDynamicLibrary() ) {
> > + name = exe->getFileName();
> > + } else {
> > + name = exe->getLibraryName();
> > + }
> > +
> > + name = GetFileNameFromPath( name );
> > + name = buildTarget + "-" + name;
> > + name.insert( 0, "/tmp/" );
> > +
> > + rld::process::tempfile objdumpFile( name, ".dmp", true );
> > + #endif
> > +
> > // Load the objdump for the symbols in this executable.
> > objdumpProcessor->load( exe, objdumpFile, err );
> > }
> > @@ -486,8 +504,10 @@ int covoar(
> >
> > //Leave tempfiles around if debug flag (-d) is enabled.
> > if ( debug ) {
> > + #ifdef USE_TEMPFILE
> > objdumpFile.override( "objdump_file" );
> > objdumpFile.keep();
> > + #endif
> > err.override( "objdump_exec_log" );
> > err.keep();
> > syms.override( "symbols_list" );
> >
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.rtems.org/pipermail/devel/attachments/20210303/ab52275a/attachment-0001.html>
More information about the devel
mailing list