Skip to content

Commit

Permalink
scripting, Bug 580576: Fix TmfScriptAnalysis reads
Browse files Browse the repository at this point in the history
Extract the reading of analysis state systems from executeAnalysis, to
read them also when getting all state systems for viewing purposes. Fix
the initialisation of the State System Explorer view this way, upon
opening it while already having state systems to readily get from disk.

Before this change, an EASE scripted analysis had to be run by the user,
so that State System Explorer could show this resulting data. With this
change, upon already having such data on disk, then that view now shows
it properly, right after opening up.

This assumes the possibility of state system data on disk maybe changing
outside of current user's flows. Hence this change always (re)reads that
data upon getting all state systems again the first time.

Again, this change covers the case of properly initializing the SSE view
upon its first opening, solely. There is still no re-read if the data is
deemed as cached enough, in which case reopening the trace is required
to force reading again.

Change-Id: I8484a8825fbff47e16228c8938c911bdd292c01f
Signed-off-by: Marco Miller <marco.miller@ericsson.com>
Reviewed-on: https://git.eclipse.org/r/c/tracecompass.incubator/org.eclipse.tracecompass.incubator/+/197318
Tested-by: Trace Compass Bot <tracecompass-bot@eclipse.org>
Tested-by: Bernd Hufmann <bernd.hufmann@ericsson.com>
Reviewed-by: Bernd Hufmann <bernd.hufmann@ericsson.com>
  • Loading branch information
marco-miller committed Dec 1, 2022
1 parent e3f7755 commit d15fd82
Showing 1 changed file with 19 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,12 @@ private Path getStateSystemFolder() {
@SuppressWarnings("null")
@Override
protected boolean executeAnalysis(IProgressMonitor monitor) throws TmfAnalysisException {
// Historically expect files to be ready for reading during this stage.
readStateSystemsIfReady(true);
return true;
}

// Read the state systems of this analysis
private void readStateSystemsIfReady(boolean expectAlwaysReadable) {
Path suppFolder = getStateSystemFolder();
if (Files.exists(suppFolder)) {
try {
Expand All @@ -101,8 +105,15 @@ public FileVisitResult visitFile(Path file, @Nullable BasicFileAttributes attrs)
* internal files.
*
* TODO: Support a version ID?
*
* Alternatively, this may happen upon an incomplete
* state-system file being read. Likely if it is
* still being created concurrently thus not ready
* for reading yet. Warn only if not expecting this.
*/
Activator.getInstance().logWarning("Error opening a file that should contain a state system: " + file.getFileName(), e); //$NON-NLS-1$
if (expectAlwaysReadable) {
Activator.getInstance().logWarning("Error opening a file that should contain a state system: " + file.getFileName(), e); //$NON-NLS-1$
}
}
return FileVisitResult.CONTINUE;
}
Expand All @@ -111,8 +122,6 @@ public FileVisitResult visitFile(Path file, @Nullable BasicFileAttributes attrs)
Activator.getInstance().logWarning("Uncaught error opening state system files", e); //$NON-NLS-1$
}
}

return true;
}

@Override
Expand All @@ -131,8 +140,8 @@ protected void canceling() {
* @param id
* The ID of the state system to get
* @param useExisting
* Whether to use a pre-existing state system with that name or
* create a new one
* Whether to use a pre-existing state system with that name, or
* create a new one despite analysis deemed as completed by now
* @return A new state system
*/
public @Nullable ITmfStateSystem getStateSystem(String id, boolean useExisting) {
Expand All @@ -159,6 +168,10 @@ protected void canceling() {

@Override
public Iterable<ITmfStateSystem> getStateSystems() {
// Try to always (re)read them from disk, in case they changed up there,
// off-line. Don't expect them to always be ready for reading yet
// though, as some files might still undergo building.
readStateSystemsIfReady(false);
return fStateSystems.values();
}

Expand Down

0 comments on commit d15fd82

Please sign in to comment.