Skip to content

Commit fe13a03

Browse files
committed
Bug 542488: Disassembly support
Change-Id: I8a280fba5147ed3ebd8ecace8b943d3e5350dacf
1 parent 6fa96ca commit fe13a03

File tree

11 files changed

+504
-36
lines changed

11 files changed

+504
-36
lines changed

debug/org.eclipse.cdt.debug.dap/META-INF/MANIFEST.MF

+4-3
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ Manifest-Version: 1.0
22
Bundle-ManifestVersion: 2
33
Bundle-Name: %Bundle-Name
44
Bundle-SymbolicName: org.eclipse.cdt.debug.dap;singleton:=true
5-
Bundle-Version: 1.0.100.qualifier
5+
Bundle-Version: 1.1.0.qualifier
66
Bundle-RequiredExecutionEnvironment: JavaSE-1.8
77
Require-Bundle: org.apache.commons.io,
88
org.eclipse.core.runtime,
@@ -20,15 +20,16 @@ Require-Bundle: org.apache.commons.io,
2020
com.google.gson;bundle-version="2.8.2",
2121
org.eclipse.lsp4j.jsonrpc,
2222
org.eclipse.cdt.launch,
23-
org.eclipse.lsp4e.debug,
23+
org.eclipse.lsp4e.debug;bundle-version="0.11.0",
2424
org.eclipse.debug.core,
2525
org.eclipse.debug.ui,
2626
org.eclipse.cdt.debug.core,
2727
org.eclipse.lsp4j.debug,
2828
org.eclipse.lsp4j.jsonrpc.debug,
2929
com.google.guava,
3030
org.eclipse.xtext.xbase.lib,
31-
org.eclipse.cdt.dsf.gdb;bundle-version="5.7.200"
31+
org.eclipse.cdt.dsf.gdb;bundle-version="5.7.200",
32+
org.eclipse.cdt.debug.ui
3233
Bundle-Vendor: %Bundle-Vendor
3334
Export-Package: org.eclipse.cdt.debug.dap
3435
Bundle-Activator: org.eclipse.cdt.debug.dap.Activator

debug/org.eclipse.cdt.debug.dap/pom.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
<relativePath>../../pom.xml</relativePath>
1313
</parent>
1414

15-
<version>1.0.100-SNAPSHOT</version>
15+
<version>1.1.0-SNAPSHOT</version>
1616
<artifactId>org.eclipse.cdt.debug.dap</artifactId>
1717
<packaging>eclipse-plugin</packaging>
1818

debug/org.eclipse.cdt.debug.dap/src/org/eclipse/cdt/debug/dap/Activator.java

+4
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,9 @@
1212
package org.eclipse.cdt.debug.dap;
1313

1414
import org.eclipse.core.runtime.IStatus;
15+
import org.eclipse.core.runtime.Platform;
1516
import org.eclipse.core.runtime.Status;
17+
import org.eclipse.lsp4e.debug.debugmodel.DSPDebugElement;
1618
import org.eclipse.ui.plugin.AbstractUIPlugin;
1719
import org.osgi.framework.BundleContext;
1820

@@ -29,6 +31,8 @@ public Activator() {
2931
public void start(BundleContext context) throws Exception {
3032
super.start(context);
3133
plugin = this;
34+
35+
Platform.getAdapterManager().registerAdapters(new DapDisassemblyBackendFactory(), DSPDebugElement.class);
3236
}
3337

3438
@Override

debug/org.eclipse.cdt.debug.dap/src/org/eclipse/cdt/debug/dap/CDTDebugProtocol.java

+69-28
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,11 @@
1010
*******************************************************************************/
1111
package org.eclipse.cdt.debug.dap;
1212

13+
import java.util.Objects;
14+
15+
import org.eclipse.lsp4j.debug.DisassembleArguments;
16+
import org.eclipse.lsp4j.debug.services.IDebugProtocolServer;
17+
import org.eclipse.lsp4j.debug.util.Preconditions;
1318
import org.eclipse.lsp4j.jsonrpc.validation.NonNull;
1419
import org.eclipse.xtext.xbase.lib.Pure;
1520
import org.eclipse.xtext.xbase.lib.util.ToStringBuilder;
@@ -32,11 +37,8 @@ public MemoryContents getBody() {
3237
return this.body;
3338
}
3439

35-
public void setBody(@NonNull final MemoryContents address) {
36-
if (address == null) {
37-
throw new IllegalArgumentException("Property must not be null: body"); //$NON-NLS-1$
38-
}
39-
this.body = address;
40+
public void setBody(@NonNull final MemoryContents body) {
41+
this.body = Preconditions.checkNotNull(body, "body"); //$NON-NLS-1$
4042
}
4143

4244
@Override
@@ -93,11 +95,8 @@ public String getData() {
9395
return this.data;
9496
}
9597

96-
public void setData(@NonNull final String address) {
97-
if (address == null) {
98-
throw new IllegalArgumentException("Property must not be null: data"); //$NON-NLS-1$
99-
}
100-
this.data = address;
98+
public void setData(@NonNull final String data) {
99+
this.data = Preconditions.checkNotNull(data, "data"); //$NON-NLS-1$
101100
}
102101

103102
@Pure
@@ -107,10 +106,7 @@ public String getAddress() {
107106
}
108107

109108
public void setAddress(@NonNull final String address) {
110-
if (address == null) {
111-
throw new IllegalArgumentException("Property must not be null: address"); //$NON-NLS-1$
112-
}
113-
this.address = address;
109+
this.address = Preconditions.checkNotNull(address, "address"); //$NON-NLS-1$
114110
}
115111

116112
@Override
@@ -177,10 +173,7 @@ public String getAddress() {
177173
}
178174

179175
public void setAddress(@NonNull final String address) {
180-
if (address == null) {
181-
throw new IllegalArgumentException("Property must not be null: address"); //$NON-NLS-1$
182-
}
183-
this.address = address;
176+
this.address = Preconditions.checkNotNull(address, "address"); //$NON-NLS-1$
184177
}
185178

186179
@Pure
@@ -190,22 +183,16 @@ public Long getLength() {
190183
}
191184

192185
public void setLength(@NonNull final Long length) {
193-
if (length == null) {
194-
throw new IllegalArgumentException("Property must not be null: length"); //$NON-NLS-1$
195-
}
196-
this.length = length;
186+
this.length = Preconditions.checkNotNull(length, "length"); //$NON-NLS-1$
197187
}
198188

199189
@Pure
200190
public Long getOffset() {
201191
return this.offset;
202192
}
203193

204-
public void setOffset(@NonNull final Long length) {
205-
if (length == null) {
206-
throw new IllegalArgumentException("Property must not be null: offset"); //$NON-NLS-1$
207-
}
208-
this.offset = length;
194+
public void setOffset(final Long offset) {
195+
this.offset = offset;
209196
}
210197

211198
@Override
@@ -256,6 +243,60 @@ public boolean equals(Object obj) {
256243
return false;
257244
return true;
258245
}
246+
}
247+
248+
/**
249+
* An extension to standard {@link DisassembleArguments} that can
250+
* be passed to {@link IDebugProtocolServer#disassemble(DisassembleArguments)}
251+
*
252+
* When endMemoryReference is provided, the disassemble command will return
253+
* the minimum number of instructions to get to the end address or number
254+
* of lines (instructionCount), whichever is smaller.
255+
*/
256+
public static class CDTDisassembleArguments extends DisassembleArguments {
257+
258+
private String endMemoryReference;
259+
260+
@Pure
261+
public String getEndMemoryReference() {
262+
return this.endMemoryReference;
263+
}
264+
265+
public void setEndMemoryReference(final String endMemoryReference) {
266+
this.endMemoryReference = endMemoryReference;
267+
}
259268

269+
@Override
270+
@Pure
271+
public String toString() {
272+
ToStringBuilder b = new ToStringBuilder(this);
273+
b.add("memoryReference", this.getMemoryReference()); //$NON-NLS-1$
274+
b.add("offset", this.getOffset()); //$NON-NLS-1$
275+
b.add("instructionOffset", this.getInstructionOffset()); //$NON-NLS-1$
276+
b.add("instructionCount", this.getInstructionCount()); //$NON-NLS-1$
277+
b.add("resolveSymbols", this.getResolveSymbols()); //$NON-NLS-1$
278+
b.add("endMemoryReference", this.endMemoryReference); //$NON-NLS-1$
279+
return b.toString();
280+
}
281+
282+
@Override
283+
public int hashCode() {
284+
final int prime = 31;
285+
int result = super.hashCode();
286+
result = prime * result + Objects.hash(endMemoryReference);
287+
return result;
288+
}
289+
290+
@Override
291+
public boolean equals(Object obj) {
292+
if (this == obj)
293+
return true;
294+
if (!super.equals(obj))
295+
return false;
296+
if (getClass() != obj.getClass())
297+
return false;
298+
CDTDisassembleArguments other = (CDTDisassembleArguments) obj;
299+
return Objects.equals(endMemoryReference, other.endMemoryReference);
300+
}
260301
}
261-
}
302+
}

debug/org.eclipse.cdt.debug.dap/src/org/eclipse/cdt/debug/dap/DapDebugTarget.java

-1
Original file line numberDiff line numberDiff line change
@@ -94,5 +94,4 @@ public IMemoryBlockExtension getExtendedMemoryBlock(String expression, Object co
9494
}
9595
return new MemoryBlock(this, expression, bigBaseAddress, context);
9696
}
97-
9897
}

0 commit comments

Comments
 (0)