From 918eb1278aa2f1d037582572bb29701dae69c8d0 Mon Sep 17 00:00:00 2001 From: Anton Leherbauer Date: Thu, 14 Oct 2010 09:37:05 +0000 Subject: [PATCH] Bug 327716 - [disassembly] NPE in BreakpointsAnnotationModel --- .../model/BreakpointsAnnotationModel.java | 32 ++++++++++--------- 1 file changed, 17 insertions(+), 15 deletions(-) diff --git a/dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/internal/ui/disassembly/model/BreakpointsAnnotationModel.java b/dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/internal/ui/disassembly/model/BreakpointsAnnotationModel.java index cce489456e5..b5ffe9b8f6f 100644 --- a/dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/internal/ui/disassembly/model/BreakpointsAnnotationModel.java +++ b/dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/internal/ui/disassembly/model/BreakpointsAnnotationModel.java @@ -9,7 +9,6 @@ * Anton Leherbauer (Wind River Systems) - initial API and implementation * Patrick Chuong (Texas Instruments) - bug 300053 *******************************************************************************/ - package org.eclipse.cdt.dsf.debug.internal.ui.disassembly.model; import java.math.BigInteger; @@ -152,7 +151,7 @@ public class BreakpointsAnnotationModel extends AnnotationModel implements IBrea IBreakpointLocationProvider locationProvider = (IBreakpointLocationProvider) breakpoint.getAdapter(IBreakpointLocationProvider.class); /* if there is a location provider, than use the provider to retrieve the location */ - if (locationProvider != null) { + if (locationProvider != null) { /* if there is source info, than create a source line position */ String sourceFile = locationProvider.getSourceFile(breakpoint); @@ -167,7 +166,7 @@ public class BreakpointsAnnotationModel extends AnnotationModel implements IBrea return createPositionFromLabel(labelAddress.getValue()); /* Otherwise, create an address position */ - } else { + } else { // Discussion with Anton - comment #5 (Bug 300053) // @@ -206,9 +205,7 @@ public class BreakpointsAnnotationModel extends AnnotationModel implements IBrea } } else { String fileName= marker.getAttribute(ICLineBreakpoint.SOURCE_HANDLE, null); - if (fileName != null) { - position= createPositionFromSourceLine(fileName, lineNumber); - } + position= createPositionFromSourceLine(fileName, lineNumber); } return position; } @@ -218,7 +215,10 @@ public class BreakpointsAnnotationModel extends AnnotationModel implements IBrea } private Position createPositionFromSourceLine(String fileName, int lineNumber) { - return getDisassemblyDocument().getSourcePosition(fileName, lineNumber); + if (fileName != null) { + return getDisassemblyDocument().getSourcePosition(fileName, lineNumber); + } + return null; } private Position createPositionFromSourceLine(IFile file, int lineNumber) { @@ -258,15 +258,17 @@ public class BreakpointsAnnotationModel extends AnnotationModel implements IBrea * @return address value as BigInteger or null in case of a NumberFormatException */ private static BigInteger decodeAddress(String string) { - try { - if (string.startsWith("0x")) { //$NON-NLS-1$ - return new BigInteger(string.substring(2), 16); + if (string != null) { + try { + if (string.startsWith("0x")) { //$NON-NLS-1$ + return new BigInteger(string.substring(2), 16); + } + if (string.length() > 0) { + return new BigInteger(string); + } + } catch (NumberFormatException nfe) { + // don't propagate } - if (string.length() > 0) { - return new BigInteger(string); - } - } catch (NumberFormatException nfe) { - // don't propagate } return null; }