Skip to content

Commit

Permalink
Change e.printStackTrace() to Activator.logError(e.getMessage(), e)
Browse files Browse the repository at this point in the history
This change is done in order to have all exceptions stored in the error
log of the workspace.

Change-Id: I15da68f25e55b80403b848a1bcfb9fa5a7a0236b
Signed-off-by: Estelle Foisy <estelle.foisy@ericsson.com>
Reviewed-on: https://git.eclipse.org/r/c/tracecompass.incubator/org.eclipse.tracecompass.incubator/+/199436
Reviewed-by: Patrick Tasse <patrick.tasse@gmail.com>
Reviewed-by: Matthew Khouzam <matthew.khouzam@ericsson.com>
Tested-by: Trace Compass Bot <tracecompass-bot@eclipse.org>
Tested-by: Matthew Khouzam <matthew.khouzam@ericsson.com>
  • Loading branch information
Estelle Foisy authored and MatthewKhouzam committed Feb 1, 2023
1 parent cb50c72 commit b73a546
Show file tree
Hide file tree
Showing 24 changed files with 95 additions and 61 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import org.eclipse.lsp4j.services.LanguageServer;
import org.eclipse.lsp4j.services.WorkspaceService;
import org.eclipse.tracecompass.incubator.filters.core.tests.environment.TestEnvironment;
import org.eclipse.tracecompass.incubator.internal.filters.core.Activator;
import org.eclipse.tracecompass.incubator.internal.filters.core.server.FilterWorkspaceService;

/**
Expand Down Expand Up @@ -85,7 +86,7 @@ public CompletableFuture<Object> shutdown() {
// Get the value from the real server
returnVal = fStub.getProxyServer().shutdown().get();
} catch (InterruptedException | ExecutionException e) {
e.printStackTrace();
Activator.getInstance().logError(e.getMessage(), e);
}
// Pass it back to the real client
return CompletableFuture.completedFuture(returnVal);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
import org.eclipse.tracecompass.common.core.log.TraceCompassLog;
import org.eclipse.tracecompass.common.core.log.TraceCompassLogUtils.FlowScopeLog;
import org.eclipse.tracecompass.common.core.log.TraceCompassLogUtils.FlowScopeLogBuilder;
import org.eclipse.tracecompass.incubator.internal.kernel.core.Activator;
import org.eclipse.tracecompass.internal.analysis.os.linux.core.inputoutput.IODataPalette;
import org.eclipse.tracecompass.statesystem.core.ITmfStateSystem;
import org.eclipse.tracecompass.statesystem.core.StateSystemUtils;
Expand Down Expand Up @@ -180,7 +181,7 @@ public TmfModelResponse<TimeGraphModel> fetchRowModel(Map<String, Object> fetchP
return new TmfModelResponse<>(models, complete ? Status.COMPLETED : Status.RUNNING,
complete ? CommonStatusMessage.COMPLETED : CommonStatusMessage.RUNNING);
} catch (StateSystemDisposedException | TimeRangeException | IndexOutOfBoundsException e) {
e.printStackTrace();
Activator.getInstance().logError(e.getMessage(), e);
return new TmfModelResponse<>(null, Status.FAILED, String.valueOf(e.getMessage()));
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ public Long getTimer(long tid, long ts, String timer) {
// can thus return 0 !
return 0L;
} catch (StateSystemDisposedException e) {
e.printStackTrace();
Activator.logError(e.getMessage(), e);
return null;
}

Expand All @@ -121,7 +121,7 @@ public Long getTimer(long tid, long ts, String timer) {
// we thus can return value
return value;
} catch (StateSystemDisposedException e) {
e.printStackTrace();
Activator.logError(e.getMessage(), e);
return null;
}
Long value2 = intvlend.getStateValue().unboxLong();
Expand Down Expand Up @@ -277,7 +277,7 @@ public ITmfStateInterval getStateInterval(long tid, long ts, String attribute) {
//e.printStackTrace();
return null;
} catch (RuntimeException e) { // For debugging purposes...
e.printStackTrace();
Activator.logError(e.getMessage(), e);
return null;
}
}
Expand Down Expand Up @@ -331,11 +331,11 @@ public List<ITmfStateInterval> getAllStateIntervalInPeriod(long start, long end,
return new LinkedList<>();
// return stateIntervalList;
} catch (StateSystemDisposedException e) {
e.printStackTrace();
Activator.logError(e.getMessage(), e);
return new LinkedList<>();
// return stateIntervalList;
} catch (RuntimeException e) { // For debugging purposes...
e.printStackTrace();
Activator.logError(e.getMessage(), e);
return new LinkedList<>();
// return stateIntervalList;
}
Expand Down Expand Up @@ -391,7 +391,7 @@ public List<ITmfStateInterval> getAllKernelStateIntervalInPeriods(Collection<Tim
stateIntervalList.addAll(StateSystemUtils.queryHistoryRange(ss, attributeQuark, ti.getStartTime().getValue(), ti.getEndTime().getValue()));
}
} catch (AttributeNotFoundException | StateSystemDisposedException | TimeRangeException e) {
e.printStackTrace();
Activator.logError(e.getMessage(), e);
}

stateIntervalList.sort(new Comparator<ITmfStateInterval>() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import org.eclipse.jdt.annotation.NonNull;
import org.eclipse.tracecompass.analysis.os.linux.core.trace.IKernelAnalysisEventLayout;
import org.eclipse.tracecompass.analysis.os.linux.core.trace.IKernelTrace;
import org.eclipse.tracecompass.incubator.internal.xaf.ui.Activator;
import org.eclipse.tracecompass.statesystem.core.ITmfStateSystemBuilder;
import org.eclipse.tracecompass.statesystem.core.exceptions.StateValueTypeException;
import org.eclipse.tracecompass.statesystem.core.exceptions.TimeRangeException;
Expand Down Expand Up @@ -146,7 +147,7 @@ protected void eventHandle(ITmfEvent event) {
ss.modifyAttribute(ts, value, quark);
nextThreadInfo.cpu_last = cpu;
} catch (StateValueTypeException | TimeRangeException | IndexOutOfBoundsException e) {
e.printStackTrace();
Activator.logError(e.getMessage(), e);
}
}

Expand All @@ -158,7 +159,7 @@ protected void eventHandle(ITmfEvent event) {
ss.modifyAttribute(ts, value, quark);
nextThreadInfo.prio_last = nextPrio;
} catch (StateValueTypeException | TimeRangeException | IndexOutOfBoundsException e) {
e.printStackTrace();
Activator.logError(e.getMessage(), e);
}
}

Expand All @@ -176,7 +177,7 @@ protected void eventHandle(ITmfEvent event) {
TmfStateValue value = TmfStateValue.newValueLong(s.getValue());
ss.modifyAttribute(ts, value, quark);
} catch (StateValueTypeException | TimeRangeException | IndexOutOfBoundsException e) {
e.printStackTrace();
Activator.logError(e.getMessage(), e);
}

// TIMER_WAIT_(BLOCKED|FOR_CPU)
Expand All @@ -198,7 +199,7 @@ protected void eventHandle(ITmfEvent event) {
TmfStateValue value = TmfStateValue.newValueLong(nextThreadInfo.cumul_wait_blocked);
ss.modifyAttribute(ts, value, quark);
} catch (StateValueTypeException | TimeRangeException | IndexOutOfBoundsException e) {
e.printStackTrace();
Activator.logError(e.getMessage(), e);
}
} else {
// TIMER_WAIT_FOR_CPU
Expand All @@ -215,7 +216,7 @@ protected void eventHandle(ITmfEvent event) {
TmfStateValue value = TmfStateValue.newValueLong(nextThreadInfo.cumul_wait_for_cpu);
ss.modifyAttribute(ts, value, quark);
} catch (StateValueTypeException | TimeRangeException | IndexOutOfBoundsException e) {
e.printStackTrace();
Activator.logError(e.getMessage(), e);
}
}
}
Expand All @@ -238,7 +239,7 @@ protected void eventHandle(ITmfEvent event) {
// Reset last wakeup time to null, so that it will be used only next time we receive a sched_waking
nextThreadInfo.last_wakeup = null;
} catch (StateValueTypeException | TimeRangeException | IndexOutOfBoundsException e) {
e.printStackTrace();
Activator.logError(e.getMessage(), e);
}
}

Expand All @@ -254,7 +255,7 @@ protected void eventHandle(ITmfEvent event) {
ss.modifyAttribute(ts, value, quark);
prevThreadInfo.prio_last = prevPrio;
} catch (StateValueTypeException | TimeRangeException | IndexOutOfBoundsException e) {
e.printStackTrace();
Activator.logError(e.getMessage(), e);
}
}

Expand All @@ -278,7 +279,7 @@ protected void eventHandle(ITmfEvent event) {
TmfStateValue value = TmfStateValue.newValueLong(prevThreadInfo.cumul_cpu_usage);
ss.modifyAttribute(ts, value, quark);
} catch (StateValueTypeException | TimeRangeException | IndexOutOfBoundsException e) {
e.printStackTrace();
Activator.logError(e.getMessage(), e);
}
//}
nextThreadInfo.last_ts = ts;
Expand All @@ -305,7 +306,7 @@ protected void eventHandle(ITmfEvent event) {
TmfStateValue value = TmfStateValue.newValueInt(prevThreadInfo.counter_preempt);
ss.modifyAttribute(ts, value, quark);
} catch (StateValueTypeException | TimeRangeException | IndexOutOfBoundsException e) {
e.printStackTrace();
Activator.logError(e.getMessage(), e);
}
} else {
// STATE: Change to BLOCKED
Expand All @@ -318,7 +319,7 @@ protected void eventHandle(ITmfEvent event) {
TmfStateValue value = TmfStateValue.newValueLong(s.getValue());
ss.modifyAttribute(ts, value, quark);
} catch (StateValueTypeException | TimeRangeException | IndexOutOfBoundsException e) {
e.printStackTrace();
Activator.logError(e.getMessage(), e);
}
} else if (eventName.equals(layout.eventSchedPiSetprio())) {
ITmfEventField content = event.getContent();
Expand All @@ -337,7 +338,7 @@ protected void eventHandle(ITmfEvent event) {
ss.modifyAttribute(ts, value, quark);
toThreadInfo.prio_last = newPrio;
} catch (StateValueTypeException | TimeRangeException | IndexOutOfBoundsException e) {
e.printStackTrace();
Activator.logError(e.getMessage(), e);
}
}

Expand Down Expand Up @@ -365,7 +366,7 @@ protected void eventHandle(ITmfEvent event) {
TmfStateValue value = TmfStateValue.newValueLong(fromThreadInfo.sched_pi_cumul);
ss.modifyAttribute(ts, value, quark);
} catch (StateValueTypeException | TimeRangeException | IndexOutOfBoundsException e) {
e.printStackTrace();
Activator.logError(e.getMessage(), e);
}
}
// Then clear the list of fromTids
Expand Down Expand Up @@ -402,7 +403,7 @@ protected void eventHandle(ITmfEvent event) {
ss.modifyAttribute(ts, value, quark);
threadInfo.prio_last = prio;
} catch (StateValueTypeException | TimeRangeException | IndexOutOfBoundsException e) {
e.printStackTrace();
Activator.logError(e.getMessage(), e);
}
}

Expand All @@ -419,7 +420,7 @@ protected void eventHandle(ITmfEvent event) {
TmfStateValue value = TmfStateValue.newValueLong(s.getValue());
ss.modifyAttribute(ts, value, quark);
} catch (StateValueTypeException | TimeRangeException | IndexOutOfBoundsException e) {
e.printStackTrace();
Activator.logError(e.getMessage(), e);
}
} else if (eventName.equals(EVENT_POWER_CPU_FREQUENCY)) {
ITmfEventField content = event.getContent();
Expand All @@ -431,7 +432,7 @@ protected void eventHandle(ITmfEvent event) {
TmfStateValue value = TmfStateValue.newValueLong(freq);
ss.modifyAttribute(ts, value, quark);
} catch (StateValueTypeException | TimeRangeException | IndexOutOfBoundsException e) {
e.printStackTrace();
Activator.logError(e.getMessage(), e);
}
} else if (eventName.equals(layout.eventSoftIrqEntry()) || eventName.equals(EVENT_IRQ_SOFTIRQ_ENTRY)) {
ITmfEventField content = event.getContent();
Expand All @@ -452,7 +453,7 @@ protected void eventHandle(ITmfEvent event) {
TmfStateValue value = TmfStateValue.newValueLong(s.getValue());
ss.modifyAttribute(ts, value, quark);
} catch (StateValueTypeException | TimeRangeException | IndexOutOfBoundsException e) {
e.printStackTrace();
Activator.logError(e.getMessage(), e);
}
} else if (eventName.equals(layout.eventHRTimerExpireEntry()) || eventName.equals("timer_hrtimer_expire_entry")) { //$NON-NLS-1$
ITmfEventField content = event.getContent();
Expand All @@ -472,7 +473,7 @@ protected void eventHandle(ITmfEvent event) {
TmfStateValue value = TmfStateValue.newValueLong(s.getValue());
ss.modifyAttribute(ts, value, quark);
} catch (StateValueTypeException | TimeRangeException | IndexOutOfBoundsException e) {
e.printStackTrace();
Activator.logError(e.getMessage(), e);
}
} else if (eventName.equals(layout.eventIrqHandlerEntry())) {
ITmfEventField content = event.getContent();
Expand All @@ -493,7 +494,7 @@ protected void eventHandle(ITmfEvent event) {
TmfStateValue value = TmfStateValue.newValueLong(s.getValue());
ss.modifyAttribute(ts, value, quark);
} catch (StateValueTypeException | TimeRangeException | IndexOutOfBoundsException e) {
e.printStackTrace();
Activator.logError(e.getMessage(), e);
}
// TODO: démarrer le timer de IRQ preemption, qui sera stoppé lors du irq handler exit
// TODO: augmenter le compteur de préemptions ? (probablement!)
Expand Down Expand Up @@ -534,15 +535,15 @@ protected void eventHandle(ITmfEvent event) {
TmfStateValue value = TmfStateValue.newValueInt(0);
ss.modifyAttribute(getTrace().getStartTime().toNanos(), value, quark);
} catch (StateValueTypeException | IndexOutOfBoundsException e) {
e.printStackTrace();
Activator.logError(e.getMessage(), e);
}
}

try {
TmfStateValue value = TmfStateValue.newValueInt(threadInfo.counter_syscalls);
ss.modifyAttribute(ts, value, quark);
} catch (StateValueTypeException | IndexOutOfBoundsException e) {
e.printStackTrace();
Activator.logError(e.getMessage(), e);
}

// STATE: Change to SYSCALL
Expand All @@ -553,7 +554,7 @@ protected void eventHandle(ITmfEvent event) {
TmfStateValue value = TmfStateValue.newValueLong(s.getValue());
ss.modifyAttribute(ts, value, quark);
} catch (StateValueTypeException | TimeRangeException | IndexOutOfBoundsException e) {
e.printStackTrace();
Activator.logError(e.getMessage(), e);
}
}
} else if (eventName.equals(layout.eventSoftIrqExit()) || eventName.equals("irq_softirq_exit") //$NON-NLS-1$
Expand Down Expand Up @@ -583,7 +584,7 @@ protected void eventHandle(ITmfEvent event) {
TmfStateValue value = TmfStateValue.newValueLong(s.getValue());
ss.modifyAttribute(ts, value, quark);
} catch (StateValueTypeException | TimeRangeException | IndexOutOfBoundsException e) {
e.printStackTrace();
Activator.logError(e.getMessage(), e);
}
//} else if (eventName.equals(layout.eventIrqHandlerExit())) {
// TODO: stopper le timer de IRQ preemption
Expand Down Expand Up @@ -627,7 +628,7 @@ public void done() {
// Reset last wakeup time to null, so that it will be used only next time we receive a sched_waking
threadInfo.last_wakeup = null;
} catch (StateValueTypeException | TimeRangeException | IndexOutOfBoundsException e) {
e.printStackTrace();
Activator.logError(e.getMessage(), e);
}
}

Expand All @@ -649,7 +650,7 @@ public void done() {
value = TmfStateValue.newValueLong(threadInfo.cumul_wait_blocked);
ss.modifyAttribute(traceEndTime, value, quark);
} catch (StateValueTypeException | TimeRangeException | IndexOutOfBoundsException e) {
e.printStackTrace();
Activator.logError(e.getMessage(), e);
}
} else if (stateValue == BackendStateValue.PREEMPTED) {
// TIMER_WAIT_FOR_CPU
Expand All @@ -666,7 +667,7 @@ public void done() {
value = TmfStateValue.newValueLong(threadInfo.cumul_wait_for_cpu);
ss.modifyAttribute(traceEndTime, value, quark);
} catch (StateValueTypeException | TimeRangeException | IndexOutOfBoundsException e) {
e.printStackTrace();
Activator.logError(e.getMessage(), e);
}
} else {
// TIMER_CPU_USAGE
Expand All @@ -686,7 +687,7 @@ public void done() {
value = TmfStateValue.newValueLong(threadInfo.cumul_cpu_usage);
ss.modifyAttribute(traceEndTime, value, quark);
} catch (StateValueTypeException | TimeRangeException | IndexOutOfBoundsException e) {
e.printStackTrace();
Activator.logError(e.getMessage(), e);
}
}
threadInfo.last_ts = traceEndTime;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
import org.eclipse.tracecompass.incubator.internal.xaf.core.statemachine.constraint.StateMachineConstraintAdaptive;
import org.eclipse.tracecompass.incubator.internal.xaf.core.statemachine.variable.StateMachineVariable;
import org.eclipse.tracecompass.incubator.internal.xaf.core.statemachine.variable.StateMachineVariableTimer;
import org.eclipse.tracecompass.incubator.internal.xaf.ui.Activator;
import org.eclipse.tracecompass.incubator.internal.xaf.ui.statemachine.StateMachineInstance;
import org.eclipse.tracecompass.incubator.internal.xaf.ui.statemachine.StateMachineInstanceGroup;
import org.eclipse.tracecompass.incubator.internal.xaf.ui.statemachine.StateMachineNode;
Expand Down Expand Up @@ -470,7 +471,7 @@ public List<StateMachineTransition> getBasicInitialTransitions() {
variables.add(newVariable);
newNode.addVariable(newVariable);
} catch (NoSuchMethodException | SecurityException | InstantiationException | IllegalAccessException | IllegalArgumentException | InvocationTargetException e) {
e.printStackTrace();
Activator.logError(e.getMessage(), e);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1131,7 +1131,7 @@ public InterruptionInterval execute(InterruptionInterval key1, InterruptionInter
try {
criticalPathSteps = getCriticalPathSteps(isi);
} catch (CriticalPathAlgorithmException | StateMachineTIDNotFoundException e) {
e.printStackTrace();
Activator.getInstance().logError(e.getMessage(), e);
continue;
}

Expand All @@ -1148,7 +1148,7 @@ public InterruptionInterval execute(InterruptionInterval key1, InterruptionInter
try {
criticalPathSteps = getCriticalPathSteps(isi);
} catch (CriticalPathAlgorithmException | StateMachineTIDNotFoundException e) {
e.printStackTrace();
Activator.getInstance().logError(e.getMessage(), e);
continue;
}

Expand Down
Loading

0 comments on commit b73a546

Please sign in to comment.