10
10
*******************************************************************************/
11
11
package org .eclipse .cdt .debug .dap ;
12
12
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 ;
13
18
import org .eclipse .lsp4j .jsonrpc .validation .NonNull ;
14
19
import org .eclipse .xtext .xbase .lib .Pure ;
15
20
import org .eclipse .xtext .xbase .lib .util .ToStringBuilder ;
@@ -32,11 +37,8 @@ public MemoryContents getBody() {
32
37
return this .body ;
33
38
}
34
39
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$
40
42
}
41
43
42
44
@ Override
@@ -93,11 +95,8 @@ public String getData() {
93
95
return this .data ;
94
96
}
95
97
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$
101
100
}
102
101
103
102
@ Pure
@@ -107,10 +106,7 @@ public String getAddress() {
107
106
}
108
107
109
108
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$
114
110
}
115
111
116
112
@ Override
@@ -177,10 +173,7 @@ public String getAddress() {
177
173
}
178
174
179
175
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$
184
177
}
185
178
186
179
@ Pure
@@ -190,22 +183,16 @@ public Long getLength() {
190
183
}
191
184
192
185
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$
197
187
}
198
188
199
189
@ Pure
200
190
public Long getOffset () {
201
191
return this .offset ;
202
192
}
203
193
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 ;
209
196
}
210
197
211
198
@ Override
@@ -256,6 +243,60 @@ public boolean equals(Object obj) {
256
243
return false ;
257
244
return true ;
258
245
}
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
+ }
259
268
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
+ }
260
301
}
261
- }
302
+ }
0 commit comments