Skip to content

Commit

Permalink
gdbtrace.core: handle selection with heterogenous traces
Browse files Browse the repository at this point in the history
Check that a child trace is a GdbTrace before casting.

Change comparison from object.equals(other) to Objects.equals(a,b)
This avoids exceptions. This should not change the functioning, but
reduce the false positive errors (NPE) in the console. The exception
before was aborting the if statement on false.

Change-Id: I1636e9cb856e5fbf69a33d9e6a8e6cbaa539219e
Signed-off-by: Matthew Khouzam <matthew.khouzam@ericsson.com>
Reviewed-on: https://git.eclipse.org/r/c/tracecompass/org.eclipse.tracecompass/+/201860
Tested-by: Trace Compass Bot <tracecompass-bot@eclipse.org>
Tested-by: Patrick Tasse <patrick.tasse@gmail.com>
Reviewed-by: Patrick Tasse <patrick.tasse@gmail.com>
  • Loading branch information
MatthewKhouzam committed Jun 8, 2023
1 parent 1e09a7c commit 05f9784
Showing 1 changed file with 13 additions and 10 deletions.
Expand Up @@ -21,6 +21,7 @@
import java.util.Hashtable;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.RejectedExecutionException;
import java.util.concurrent.TimeUnit;
Expand Down Expand Up @@ -213,7 +214,7 @@ public void debugContextChanged(DebugContextEvent event) {
String sessionId;
synchronized (SESSION_LOCK) {
sessionId = context.getSessionId();
if (sessionId.equals(fCurrentSessionId)) {
if (Objects.equals(sessionId,fCurrentSessionId)) {
return;
}
fCurrentSessionId = sessionId;
Expand Down Expand Up @@ -837,7 +838,7 @@ private static void closeGdbTraceEditor(final String sessionId) {
if (editor instanceof ITmfTraceEditor) {
ITmfTrace trace = ((ITmfTraceEditor) editor).getTrace();
if (trace instanceof GdbTrace) {
if (((GdbTrace) trace).getDsfSessionId().equals(sessionId)) {
if (Objects.equals(((GdbTrace) trace).getDsfSessionId(), sessionId)) {
wbPage.closeEditor(editor, false);
}
}
Expand All @@ -857,7 +858,7 @@ private static void selectGdbTraceEditor(final String sessionId, final int recor
if (editor instanceof ITmfTraceEditor) {
ITmfTrace trace = ((ITmfTraceEditor) editor).getTrace();
if (trace instanceof GdbTrace) {
if (((GdbTrace) trace).getDsfSessionId().equals(sessionId)) {
if (Objects.equals(((GdbTrace) trace).getDsfSessionId(), sessionId)) {
wbPage.bringToTop(editor);
if (recordId != -1) {
gotoRank(editor, recordId);
Expand All @@ -869,14 +870,16 @@ private static void selectGdbTraceEditor(final String sessionId, final int recor
List<ITmfTrace> expTraces = experiment.getTraces();
int nbTraces = expTraces.size();
for (int i = 0; i < nbTraces; i++) {
GdbTrace gdbTrace = (GdbTrace) expTraces.get(i);
if (gdbTrace.getDsfSessionId().equals(sessionId)) {
wbPage.bringToTop(editor);
if (recordId != -1) {
int rank = recordId * nbTraces + i;
gotoRank(editor, rank);
if (trace instanceof GdbTrace) {
GdbTrace gdbTrace = (GdbTrace) expTraces.get(i);
if (Objects.equals(gdbTrace.getDsfSessionId(), sessionId)) {
wbPage.bringToTop(editor);
if (recordId != -1) {
int rank = recordId * nbTraces + i;
gotoRank(editor, rank);
}
return;
}
return;
}
}
}
Expand Down

0 comments on commit 05f9784

Please sign in to comment.