diff options
author | Eugene Tarassov | 2012-07-12 01:09:48 +0000 |
---|---|---|
committer | Eugene Tarassov | 2012-07-12 01:09:48 +0000 |
commit | b1da39c1e35992109421ece95e75d43412e6662d (patch) | |
tree | c5d228d7c2b72c3d9a0874d2b0549c8c0af76ef3 | |
parent | c0acc29f3d3897c6eb98a510cd3b5bd5451424e1 (diff) | |
download | org.eclipse.tcf-b1da39c1e35992109421ece95e75d43412e6662d.tar.gz org.eclipse.tcf-b1da39c1e35992109421ece95e75d43412e6662d.tar.xz org.eclipse.tcf-b1da39c1e35992109421ece95e75d43412e6662d.zip |
TCF Debugger: fixed Show Opcodes command in the Disassembly view
5 files changed, 140 insertions, 102 deletions
diff --git a/plugins/org.eclipse.tcf.cdt.ui/plugin.xml b/plugins/org.eclipse.tcf.cdt.ui/plugin.xml index ca29bfd15..181204ea3 100644 --- a/plugins/org.eclipse.tcf.cdt.ui/plugin.xml +++ b/plugins/org.eclipse.tcf.cdt.ui/plugin.xml @@ -490,6 +490,6 @@ type="string"> </attribute> </breakpointEditors> - </extension> + </extension> </plugin> diff --git a/plugins/org.eclipse.tcf.cdt.ui/src/org/eclipse/tcf/internal/cdt/ui/breakpoints/HardwareFieldEditor.java b/plugins/org.eclipse.tcf.cdt.ui/src/org/eclipse/tcf/internal/cdt/ui/breakpoints/HardwareFieldEditor.java index 40b8c05e8..e480b082b 100644 --- a/plugins/org.eclipse.tcf.cdt.ui/src/org/eclipse/tcf/internal/cdt/ui/breakpoints/HardwareFieldEditor.java +++ b/plugins/org.eclipse.tcf.cdt.ui/src/org/eclipse/tcf/internal/cdt/ui/breakpoints/HardwareFieldEditor.java @@ -40,7 +40,7 @@ import org.eclipse.ui.IWorkbenchPropertyPage; public class HardwareFieldEditor extends FieldEditor { private Composite fParent; - + /** * The previously selected, or "before", value. */ @@ -61,13 +61,13 @@ public class HardwareFieldEditor extends FieldEditor { super.setPage(dialogPage); updateEnablement(); } - + @Override public void dispose() { fParent = null; super.dispose(); } - + protected void updateEnablement() { // enable/disable this feature according to TCF agent capabilities. @@ -88,7 +88,7 @@ public class HardwareFieldEditor extends FieldEditor { /** * determine if the channel is able to manage "Physical Address" capability - * + * * @param channel * the channel to check * @return TRUE if "Physical Address" is supported by the channel, else @@ -118,7 +118,7 @@ public class HardwareFieldEditor extends FieldEditor { } return null; } - + protected Object getDebugContext() { IWorkbenchPropertyPage page = (IWorkbenchPropertyPage)getPage(); if (page != null) { @@ -131,11 +131,11 @@ public class HardwareFieldEditor extends FieldEditor { } return null; } - return DebugUITools.getDebugContext(); + return DebugUITools.getDebugContext(); } return null; } - + /* * (non-Javadoc) Method declared on FieldEditor. */ @@ -162,11 +162,11 @@ public class HardwareFieldEditor extends FieldEditor { * <code>getLabelControl(parent).setToolTipText(tooltipText)</code> does not * work for boolean field editors, as it can lead to duplicate text (see bug * 259952). - * + * * @param parent * the parent composite * @return the control responsible for displaying the label - * + * * @since 3.5 */ public Control getDescriptionControl(Composite parent) { @@ -215,7 +215,7 @@ public class HardwareFieldEditor extends FieldEditor { /** * Returns this field editor's current value. - * + * * @return the value */ public boolean getBooleanValue() { @@ -224,10 +224,10 @@ public class HardwareFieldEditor extends FieldEditor { /** * Returns the change button for this field editor. - * + * * @param parent * The Composite to create the receiver in. - * + * * @return the change button */ protected Button getChangeControl(Composite parent) { @@ -284,7 +284,7 @@ public class HardwareFieldEditor extends FieldEditor { * Informs this field editor's listener, if it has one, about a change to * the value (<code>VALUE</code> property) provided that the old and new * values are different. - * + * * @param oldValue * the old value * @param newValue diff --git a/plugins/org.eclipse.tcf.cdt.ui/src/org/eclipse/tcf/internal/cdt/ui/breakpoints/HardwareFieldEditorFactory.java b/plugins/org.eclipse.tcf.cdt.ui/src/org/eclipse/tcf/internal/cdt/ui/breakpoints/HardwareFieldEditorFactory.java index b5ef95a93..897474062 100644 --- a/plugins/org.eclipse.tcf.cdt.ui/src/org/eclipse/tcf/internal/cdt/ui/breakpoints/HardwareFieldEditorFactory.java +++ b/plugins/org.eclipse.tcf.cdt.ui/src/org/eclipse/tcf/internal/cdt/ui/breakpoints/HardwareFieldEditorFactory.java @@ -19,10 +19,10 @@ import org.eclipse.swt.widgets.Composite; * HardwareFieldEditorFactory - Create the field editor for hardware breakpoint support. */ public class HardwareFieldEditorFactory implements IFieldEditorFactory { - + public FieldEditor createFieldEditor(String name, String labelText, Composite parent) { return new HardwareFieldEditor (parent); } - - -}
\ No newline at end of file + + +} diff --git a/plugins/org.eclipse.tcf.cdt.ui/src/org/eclipse/tcf/internal/cdt/ui/disassembly/TCFDisassemblyBackend.java b/plugins/org.eclipse.tcf.cdt.ui/src/org/eclipse/tcf/internal/cdt/ui/disassembly/TCFDisassemblyBackend.java index 4e446c1da..90f52dc18 100644 --- a/plugins/org.eclipse.tcf.cdt.ui/src/org/eclipse/tcf/internal/cdt/ui/disassembly/TCFDisassemblyBackend.java +++ b/plugins/org.eclipse.tcf.cdt.ui/src/org/eclipse/tcf/internal/cdt/ui/disassembly/TCFDisassemblyBackend.java @@ -63,6 +63,7 @@ import org.eclipse.tcf.services.IExpressions.Value; import org.eclipse.tcf.services.ILineNumbers; import org.eclipse.tcf.services.ILineNumbers.CodeArea; import org.eclipse.tcf.services.ILineNumbers.DoneMapToSource; +import org.eclipse.tcf.services.IMemory.MemoryError; import org.eclipse.tcf.services.IMemory; import org.eclipse.tcf.services.IRunControl; import org.eclipse.tcf.services.IRunControl.RunControlContext; @@ -79,6 +80,7 @@ public class TCFDisassemblyBackend extends AbstractDisassemblyBackend { BigInteger start; BigInteger end; } + private static class FunctionOffset { static final FunctionOffset NONE = new FunctionOffset(null, null); String name; @@ -97,6 +99,7 @@ public class TCFDisassemblyBackend extends AbstractDisassemblyBackend { return offset == null || offset.compareTo(BigInteger.ZERO) == 0; } } + private class TCFLaunchListener implements ILaunchesListener { public void launchesRemoved(ILaunch[] launches) { @@ -106,9 +109,7 @@ public class TCFDisassemblyBackend extends AbstractDisassemblyBackend { } public void launchesChanged(ILaunch[] launches) { - if(fExecContext == null) { - return; - } + if (fExecContext == null) return; for (ILaunch launch : launches) { if (launch == fExecContext.getModel().getLaunch()) { if (launch.isTerminated()) { @@ -192,7 +193,6 @@ public class TCFDisassemblyBackend extends AbstractDisassemblyBackend { public void contextException(String context, String msg) { } - } private IDisassemblyPartCallback fCallback; @@ -315,7 +315,7 @@ public class TCFDisassemblyBackend extends AbstractDisassemblyBackend { } private void handleContextSuspended(BigInteger pc) { - ++fSuspendCount; + fSuspendCount++; fSuspendAddress = pc; fCallback.handleTargetSuspended(); } @@ -485,11 +485,23 @@ public class TCFDisassemblyBackend extends AbstractDisassemblyBackend { final int suspendCount = fSuspendCount; final long modCount = getModCount(); Protocol.invokeLater(new Runnable() { + + IMemory.MemoryContext mem; + boolean big_endian; + int addr_bits; + IDisassemblyLine[] disassembly; + AddressRange range; + boolean done_disassembly; + ISymbols.Symbol[] functionSymbols; + boolean done_symbols; + CodeArea[] code_areas; + boolean done_line_numbers; + byte[] code; + boolean done_code; + public void run() { - if (execContext != fExecContext) { - return; - } - if (suspendCount != fSuspendCount) { + if (execContext != fExecContext) return; + if (suspendCount != fSuspendCount || fMemoryContext == null) { fCallback.setUpdatePending(false); return; } @@ -499,52 +511,59 @@ public class TCFDisassemblyBackend extends AbstractDisassemblyBackend { fCallback.setUpdatePending(false); return; } - if (fMemoryContext == null) { - fCallback.setUpdatePending(false); - return; - } TCFDataCache<IMemory.MemoryContext> cache = fMemoryContext.getMemoryContext(); if (!cache.validate(this)) return; - final IMemory.MemoryContext mem = cache.getData(); + mem = cache.getData(); if (mem == null) { fCallback.setUpdatePending(false); return; } - final String contextId = mem.getID(); - Map<String, Object> params = new HashMap<String, Object>(); - disass.disassemble(contextId, startAddress, linesHint * 4, params, new DoneDisassemble() { - public void doneDisassemble(IToken token, final Throwable error, IDisassemblyLine[] disassembly) { - if (execContext != fExecContext) return; - if (error != null) { - fCallback.asyncExec(new Runnable() { - public void run() { - if (execContext != fExecContext) return; - if (modCount == getModCount()) { - fCallback.insertError(startAddress, TCFModel.getErrorMessage(error, false)); - fCallback.setUpdatePending(false); - int addr_bits = mem.getAddressSize() * 8; - if (fCallback.getAddressSize() < addr_bits) fCallback.addressSizeChanged(addr_bits); + big_endian = mem.isBigEndian(); + addr_bits = mem.getAddressSize() * 8; + if (!done_disassembly) { + Map<String, Object> params = new HashMap<String, Object>(); + disass.disassemble(mem.getID(), startAddress, linesHint * 4, params, new DoneDisassemble() { + @Override + public void doneDisassemble(IToken token, final Throwable error, IDisassemblyLine[] res) { + if (execContext != fExecContext) return; + if (error != null) { + fCallback.asyncExec(new Runnable() { + public void run() { + if (execContext != fExecContext) return; + if (modCount == getModCount()) { + fCallback.insertError(startAddress, TCFModel.getErrorMessage(error, false)); + fCallback.setUpdatePending(false); + if (fCallback.getAddressSize() < addr_bits) fCallback.addressSizeChanged(addr_bits); + } } - } - }); - return; + }); + return; + } + if (res != null && res.length > 0) { + disassembly = res; + range = new AddressRange(); + range.start = JSON.toBigInteger(res[0].getAddress()); + IDisassemblyLine last = res[res.length - 1]; + range.end = JSON.toBigInteger(last.getAddress()).add(BigInteger.valueOf(last.getSize())); + } + done_disassembly = true; + run(); } - doneGetDisassembly(disassembly); + }); + return; + } + if (!done_symbols && (range == null || !showSymbols)) { + done_symbols = true; + } + if (!done_symbols) { + final ISymbols symbols = channel.getRemoteService(ISymbols.class); + if (symbols == null) { + done_symbols = true; } - - private void doneGetDisassembly(final IDisassemblyLine[] disassembly) { - if (disassembly == null || disassembly.length == 0 || !showSymbols) { - doneGetSymbols(disassembly, null); - return; - } - final ISymbols symbols = channel.getRemoteService(ISymbols.class); - if (symbols == null) { - doneGetSymbols(disassembly, null); - return; - } + else { final ArrayList<ISymbols.Symbol> symbolList = new ArrayList<ISymbols.Symbol>(); IDisassemblyLine line = disassembly[0]; - symbols.findByAddr(contextId, line.getAddress(), new ISymbols.DoneFind() { + symbols.findByAddr(mem.getID(), line.getAddress(), new ISymbols.DoneFind() { int idx = 0; public void doneFind(IToken token, Exception error, String symbol_id) { if (error == null && symbol_id != null) { @@ -568,56 +587,60 @@ public class TCFDisassemblyBackend extends AbstractDisassemblyBackend { while (++idx < disassembly.length) { BigInteger instrAddress = JSON.toBigInteger(disassembly[idx].getAddress()); if (nextAddress != null && instrAddress.compareTo(nextAddress) < 0) continue; - symbols.findByAddr(contextId, instrAddress, this); + symbols.findByAddr(mem.getID(), instrAddress, this); return; } - ISymbols.Symbol[] functionSymbols = - symbolList.toArray(new ISymbols.Symbol[symbolList.size()]); - doneGetSymbols(disassembly, functionSymbols); + functionSymbols = symbolList.toArray(new ISymbols.Symbol[symbolList.size()]); + done_symbols = true; + run(); } }); + return; } - - private void doneGetSymbols(final IDisassemblyLine[] disassembly, final ISymbols.Symbol[] symbols) { - if (disassembly == null || disassembly.length == 0 || !mixed) { - doneGetLineNumbers(disassembly, symbols, null); - return; - } - ILineNumbers lineNumbers = channel.getRemoteService(ILineNumbers.class); - if (lineNumbers == null) { - doneGetLineNumbers(disassembly, symbols, null); - return; - } - AddressRange range = getAddressRange(disassembly); - lineNumbers.mapToSource(contextId, range.start, range.end, new DoneMapToSource() { + } + if (!done_line_numbers && (range == null || !mixed)) { + done_line_numbers = true; + } + if (!done_line_numbers) { + ILineNumbers lineNumbers = channel.getRemoteService(ILineNumbers.class); + if (lineNumbers == null) { + done_line_numbers = true; + } + else { + lineNumbers.mapToSource(mem.getID(), range.start, range.end, new DoneMapToSource() { public void doneMapToSource(IToken token, Exception error, final CodeArea[] areas) { if (error != null) { Activator.log(error); - doneGetLineNumbers(disassembly, symbols, null); } else { - doneGetLineNumbers(disassembly, symbols, areas); + code_areas = areas; } + done_line_numbers = true; + run(); } }); + return; } - - private void doneGetLineNumbers(final IDisassemblyLine[] disassembly, final ISymbols.Symbol[] symbols, final CodeArea[] areas) { - fCallback.asyncExec(new Runnable() { - public void run() { - insertDisassembly(modCount, startAddress, disassembly, symbols, areas); - int addr_bits = mem.getAddressSize() * 8; - if (fCallback.getAddressSize() < addr_bits) fCallback.addressSizeChanged(addr_bits); - } - }); - } - - private AddressRange getAddressRange(IDisassemblyLine[] lines) { - AddressRange range = new AddressRange(); - range.start = JSON.toBigInteger(lines[0].getAddress()); - IDisassemblyLine lastLine = lines[lines.length-1]; - range.end = JSON.toBigInteger(lastLine.getAddress()).add(BigInteger.valueOf(lastLine.getSize())); - return range; + } + if (!done_code && range == null) { + done_code = true; + } + if (!done_code) { + code = new byte[range.end.subtract(range.start).intValue()]; + mem.get(startAddress, 1, code, 0, code.length, 0, new IMemory.DoneMemory() { + @Override + public void doneMemory(IToken token, MemoryError error) { + done_code = true; + run(); + } + }); + return; + } + fCallback.asyncExec(new Runnable() { + public void run() { + insertDisassembly(modCount, startAddress, code, big_endian, + disassembly, functionSymbols, code_areas); + if (fCallback.getAddressSize() < addr_bits) fCallback.addressSizeChanged(addr_bits); } }); } @@ -628,7 +651,7 @@ public class TCFDisassemblyBackend extends AbstractDisassemblyBackend { return ((IDocumentExtension4) fCallback.getDocument()).getModificationStamp(); } - protected final void insertDisassembly(long modCount, BigInteger startAddress, + protected final void insertDisassembly(long modCount, BigInteger startAddress, byte[] code, boolean big_endian, IDisassemblyLine[] instructions, ISymbols.Symbol[] symbols, CodeArea[] codeAreas) { if (!fCallback.hasViewer() || fExecContext == null) return; if (modCount != getModCount()) return; @@ -709,7 +732,22 @@ public class TCFDisassemblyBackend extends AbstractDisassemblyBackend { Map<String,Object>[] instrAttrs = instruction.getInstruction(); String instr = formatInstruction(instrAttrs); - p = fCallback.getDocument().insertDisassemblyLine(p, address, instrLength, functionOffset.toString(), instr, sourceFile, firstLine); + if (code != null) { + int offs = address.subtract(startAddress).intValue(); + BigInteger opcode = BigInteger.ZERO; + for (int i = 0; i < instrLength; i++) { + int j = big_endian ? i : instrLength - i - 1; + opcode = opcode.shiftLeft(8).add(BigInteger.valueOf(code[offs + j] & 0xff)); + } + p = fCallback.getDocument().insertDisassemblyLine(p, + address, instrLength, functionOffset.toString(), + opcode, instr, sourceFile, firstLine); + } + else { + p = fCallback.getDocument().insertDisassemblyLine(p, + address, instrLength, functionOffset.toString(), + instr, sourceFile, firstLine); + } if (p == null) break; insertedAnyAddress = true; } diff --git a/plugins/org.eclipse.tcf.debug/src/org/eclipse/tcf/internal/debug/model/TCFBreakpointsModel.java b/plugins/org.eclipse.tcf.debug/src/org/eclipse/tcf/internal/debug/model/TCFBreakpointsModel.java index ff3668821..3b2aae979 100644 --- a/plugins/org.eclipse.tcf.debug/src/org/eclipse/tcf/internal/debug/model/TCFBreakpointsModel.java +++ b/plugins/org.eclipse.tcf.debug/src/org/eclipse/tcf/internal/debug/model/TCFBreakpointsModel.java @@ -80,7 +80,7 @@ public class TCFBreakpointsModel { ATTR_EVENT_TYPE = "org.eclipse.cdt.debug.core.eventbreakpoint_event_id", ATTR_EVENT_ARGS = "org.eclipse.cdt.debug.core.eventbreakpoint_event_arg", ATTR_TYPE = "org.eclipse.cdt.debug.core.breakpointType"; - + public static final int ATTR_TYPE_TEMPORARY = 0x1, ATTR_TYPE_REGULAR = 0x0 << 1, @@ -698,7 +698,7 @@ public class TCFBreakpointsModel { } if ((cdt_type.intValue() & ATTR_TYPE_HARDWARE) != 0) { m.put(IBreakpoints.PROP_TYPE, IBreakpoints.TYPE_HARDWARE); - } + } else if ((cdt_type.intValue() & ATTR_TYPE_SOFTWARE) != 0) { m.put(IBreakpoints.PROP_TYPE, IBreakpoints.TYPE_SOFTWARE); } |