Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: 1bea23bc650efc2d8a1bc3c69a6de90926c89e9c (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
/*******************************************************************************
 * Copyright (c) 2009, 2015 Ericsson and others.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:
 *     Ericsson - Initial implementation of Test cases
 *******************************************************************************/
package org.eclipse.cdt.tests.dsf.gdb.tests;


import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;

import java.util.Arrays;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.TimeUnit;

import org.eclipse.cdt.debug.core.ICDTLaunchConfigurationConstants;
import org.eclipse.cdt.dsf.concurrent.DataRequestMonitor;
import org.eclipse.cdt.dsf.concurrent.Query;
import org.eclipse.cdt.dsf.datamodel.DMContexts;
import org.eclipse.cdt.dsf.debug.service.IBreakpoints;
import org.eclipse.cdt.dsf.debug.service.IBreakpoints.IBreakpointDMContext;
import org.eclipse.cdt.dsf.debug.service.IBreakpoints.IBreakpointDMData;
import org.eclipse.cdt.dsf.debug.service.IBreakpoints.IBreakpointsAddedEvent;
import org.eclipse.cdt.dsf.debug.service.IBreakpoints.IBreakpointsRemovedEvent;
import org.eclipse.cdt.dsf.debug.service.IBreakpoints.IBreakpointsTargetDMContext;
import org.eclipse.cdt.dsf.debug.service.IBreakpoints.IBreakpointsUpdatedEvent;
import org.eclipse.cdt.dsf.debug.service.IRunControl.IContainerDMContext;
import org.eclipse.cdt.dsf.gdb.IGDBLaunchConfigurationConstants;
import org.eclipse.cdt.dsf.gdb.internal.tracepointactions.CollectAction;
import org.eclipse.cdt.dsf.gdb.internal.tracepointactions.EvaluateAction;
import org.eclipse.cdt.dsf.gdb.internal.tracepointactions.TracepointActionManager;
import org.eclipse.cdt.dsf.gdb.launching.LaunchUtils;
import org.eclipse.cdt.dsf.gdb.service.command.IGDBControl;
import org.eclipse.cdt.dsf.mi.service.MIBreakpointDMData;
import org.eclipse.cdt.dsf.mi.service.MIBreakpoints;
import org.eclipse.cdt.dsf.mi.service.command.CommandFactory;
import org.eclipse.cdt.dsf.mi.service.command.output.MIInfo;
import org.eclipse.cdt.dsf.mi.service.command.output.MIOOBRecord;
import org.eclipse.cdt.dsf.mi.service.command.output.MIStreamRecord;
import org.eclipse.cdt.dsf.service.DsfServiceEventHandler;
import org.eclipse.cdt.dsf.service.DsfServicesTracker;
import org.eclipse.cdt.dsf.service.DsfSession;
import org.eclipse.cdt.tests.dsf.gdb.framework.BaseParametrizedTestCase;
import org.eclipse.cdt.tests.dsf.gdb.framework.SyncUtil;
import org.eclipse.cdt.tests.dsf.gdb.launching.TestsPlugin;
import org.eclipse.core.runtime.Platform;
import org.junit.BeforeClass;
import org.junit.Ignore;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;

@RunWith(Parameterized.class)
public class GDBRemoteTracepointsTest extends BaseParametrizedTestCase {
	protected DsfSession fSession;
	protected DsfServicesTracker fServicesTracker;
	protected IBreakpoints fBreakpointService;
	//	private ITraceControl fTraceService;
	protected IBreakpointsTargetDMContext fBreakpointsDmc;
	//	private ITraceTargetDMContext fTraceTargetDmc;
	protected IGDBControl fGdbControl;
	protected CommandFactory fCommandFactory;

	//	private int fTotalTracingBufferSize = 0;

	protected static final String EXEC_NAME       = "TracepointTestApp.exe";
	protected static final String SOURCE_NAME     = "TracepointTestApp.cc";

	// Breakpoint tags in TracepointTestApp.cc
	public static final String[] LINE_TAGS = new String[] {
			"1_BYTE",
			"2_BYTE",
			"3_BYTE",
			"4_BYTE",
			"5_BYTE"
	};

	protected static final String NO_CONDITION    = "";
	protected static final String NO_COMMANDS     = "";
	//    private static final int    LAST_LINE_NUMBER   = 94;
	//
	// private static final int TOTAL_FRAMES_TO_BE_COLLECTED = 1 + 1 + 10 + 1 + 10000;

	protected final static int[] PASS_COUNTS = {12, 2, 32, 6, 128, 0, 0, 0, 0, 0, 0, 0};
	protected final static String[] CONDITIONS = {"gIntVar == 543", "gBoolVar == false", "x == 3", "x > 4", "x > 2 && gIntVar == 12345"};

	protected static CollectAction[] COLLECT_ACTIONS = new CollectAction[10];
	protected static EvaluateAction[] EVAL_ACTIONS = new EvaluateAction[10];
	// private static WhileSteppingAction[] STEPPING_ACTION_1 = new WhileSteppingAction[3];

	@BeforeClass
    public static void initializeActions() {
		TracepointActionManager tracepointActionMgr = TracepointActionManager.getInstance();

		int index = 0;
		COLLECT_ACTIONS[index] = new CollectAction();
		COLLECT_ACTIONS[index].setCollectString("$locals");
		COLLECT_ACTIONS[index].setName("Collect locals");
		tracepointActionMgr.addAction(COLLECT_ACTIONS[index]);
		index++;

		COLLECT_ACTIONS[index] = new CollectAction();
		COLLECT_ACTIONS[index].setCollectString("gIntVar");
		COLLECT_ACTIONS[index].setName("Collect gIntVar");
		tracepointActionMgr.addAction(COLLECT_ACTIONS[index]);
		index++;

		COLLECT_ACTIONS[index] = new CollectAction();
		COLLECT_ACTIONS[index].setCollectString("$locals, x, $reg");
		COLLECT_ACTIONS[index].setName("Collect locals, x and reg");
		tracepointActionMgr.addAction(COLLECT_ACTIONS[index]);
		index++;

		COLLECT_ACTIONS[index] = new CollectAction();
		COLLECT_ACTIONS[index].setCollectString("$reg");
		COLLECT_ACTIONS[index].setName("Collect reg");
		tracepointActionMgr.addAction(COLLECT_ACTIONS[index]);
		index++;

		COLLECT_ACTIONS[index] = new CollectAction();
		COLLECT_ACTIONS[index].setCollectString("x, $locals");
		COLLECT_ACTIONS[index].setName("Collect x, locals");
		tracepointActionMgr.addAction(COLLECT_ACTIONS[index]);
		index++;

		COLLECT_ACTIONS[index] = new CollectAction();
		COLLECT_ACTIONS[index].setCollectString("$myTraceVariable");
		COLLECT_ACTIONS[index].setName("Collect myTraceVariable");
		tracepointActionMgr.addAction(COLLECT_ACTIONS[index]);
		index++;

		index=0;
		EVAL_ACTIONS[index] = new EvaluateAction();
		EVAL_ACTIONS[index].setEvalString("$count=$count+1");
		EVAL_ACTIONS[index].setName("Eval increment count");
		tracepointActionMgr.addAction(EVAL_ACTIONS[index]);
		index++;

		EVAL_ACTIONS[index] = new EvaluateAction();
		EVAL_ACTIONS[index].setEvalString("$count2=$count2+2");
		EVAL_ACTIONS[index].setName("Eval increment count2 by 2");
		tracepointActionMgr.addAction(EVAL_ACTIONS[index]);
		index++;

		EVAL_ACTIONS[index] = new EvaluateAction();
		EVAL_ACTIONS[index].setEvalString("$count3=$count3+3");
		EVAL_ACTIONS[index].setName("Eval increment count3 by 3");
		tracepointActionMgr.addAction(EVAL_ACTIONS[index]);
		index++;

		//TODO do while stepping actions
		index=0;

	}

	@Override
	public void doBeforeTest() throws Exception {
		// GDB tracepoints are only supported on a remote target (e.g., using gdbserver)
		assumeRemoteSession();
		super.doBeforeTest();
		resolveLineTagLocations(SOURCE_NAME, LINE_TAGS);

		fSession = getGDBLaunch().getSession();
		Runnable runnable = new Runnable() {
			@Override
			public void run() {
				fServicesTracker = new DsfServicesTracker(TestsPlugin.getBundleContext(), fSession.getId());


				fBreakpointService = fServicesTracker.getService(IBreakpoints.class);
				fGdbControl = fServicesTracker.getService(IGDBControl.class);
				fCommandFactory = fGdbControl.getCommandFactory();
				
				//        		fTraceService = fServicesTracker.getService(ITraceControl.class);
				fSession.addServiceEventListener(GDBRemoteTracepointsTest.this, null);

				// Create a large array to make sure we don't run out
				fTracepoints = new IBreakpointDMContext[100];

				// Run an initial test to check that everything is ok with GDB
				checkTraceInitialStatus();
			}
		};
		fSession.getExecutor().submit(runnable).get();

		IContainerDMContext containerDmc = SyncUtil.getContainerContext();
		fBreakpointsDmc = DMContexts.getAncestorOfType(containerDmc, IBreakpointsTargetDMContext.class);
		assert(fBreakpointsDmc != null);
		//                fTraceTargetDmc = DMContexts.getAncestorOfType(containerDmc, ITraceTargetDMContext.class);

	}

	@Override
	protected void setLaunchAttributes() {
		super.setLaunchAttributes();

		setLaunchAttribute(ICDTLaunchConfigurationConstants.ATTR_PROGRAM_NAME, EXEC_PATH + EXEC_NAME);

		// To test both fast and normal tracepoints, we use the FAST_THEN_NORMAL setting
		setLaunchAttribute(IGDBLaunchConfigurationConstants.ATTR_DEBUGGER_TRACEPOINT_MODE,
				IGDBLaunchConfigurationConstants.DEBUGGER_TRACEPOINT_FAST_THEN_NORMAL);
	}

	@Override
	public void doAfterTest() throws Exception {
		super.doAfterTest();
		if (fSession != null)
			fSession.getExecutor().submit(() -> fSession.removeServiceEventListener(GDBRemoteTracepointsTest.this))
					.get();
		fBreakpointService = null;
		if (fServicesTracker != null)
			fServicesTracker.dispose();
	}

	// *********************************************************************
	// Below are utility methods.
	// *********************************************************************
	private static Boolean lock = true;
	enum Events {BP_ADDED, BP_UPDATED, BP_REMOVED, BP_HIT}
	final int BP_ADDED   = Events.BP_ADDED.ordinal();
	final int BP_UPDATED = Events.BP_UPDATED.ordinal();
	final int BP_REMOVED = Events.BP_REMOVED.ordinal();
	final int BP_HIT     = Events.BP_HIT.ordinal();
	private int[]   fBreakpointEvents = new int[Events.values().length];
	private boolean fBreakpointEvent;
	private int     fBreakpointEventCount;

	@DsfServiceEventHandler
	public void eventDispatched(IBreakpointsAddedEvent e) {
		synchronized (lock) {
			fBreakpointEvents[BP_ADDED]++;
			fBreakpointEventCount++;
			fBreakpointEvent = true;
			lock.notifyAll();
		}
	}

	@DsfServiceEventHandler
	public void eventDispatched(IBreakpointsUpdatedEvent e) {
		synchronized (lock) {
			fBreakpointEvents[BP_UPDATED]++;
			fBreakpointEventCount++;
			fBreakpointEvent = true;
			lock.notifyAll();
		}
	}

	@DsfServiceEventHandler
	public void eventDispatched(IBreakpointsRemovedEvent e) {
		synchronized (lock) {
			fBreakpointEvents[BP_REMOVED]++;
			fBreakpointEventCount++;
			fBreakpointEvent = true;
			lock.notifyAll();
		}
	}

	// Clears the counters
	protected void clearEventCounters() {
		synchronized (lock) {
			for (int i = 0; i < fBreakpointEvents.length; i++) {
				fBreakpointEvents[i] = 0;
			}
			fBreakpointEvent = false;
			fBreakpointEventCount = 0;
		}
	}

	// Get the breakpoint hit count
	protected int getBreakpointEventCount(int event) {
		int count = 0;
		synchronized (lock) {
			count = fBreakpointEvents[event];
		}
		return count;
	}

	// Suspends the thread until an event is flagged
	// NOTE: too simple for real life but good enough for this test suite
	protected void waitForBreakpointEvent() {
		synchronized (lock) {
			while (!fBreakpointEvent) {
				try {
					lock.wait();
				} catch (InterruptedException ex) {
				}
			}
			fBreakpointEvent = false;
		}
	}

	// *********************************************************************
	// Breakpoint service methods (to use with tracepoints).
	// *********************************************************************

	protected IBreakpointDMContext insertBreakpoint(final IBreakpointsTargetDMContext context, final Map<String,Object> attributes)
			throws Throwable
	{
        Query<IBreakpointDMContext> query = new Query<IBreakpointDMContext>() {
			@Override
			protected void execute(final DataRequestMonitor<IBreakpointDMContext> rm) {
				fBreakpointService.insertBreakpoint(context, attributes, rm);
			}
        };

        fBreakpointService.getExecutor().execute(query);
        try {
        	return query.get(1, TimeUnit.SECONDS);
        } catch (ExecutionException e) {
        	assert false : e.getCause().getMessage();
        }
        return null;
	}

	protected void removeBreakpoint(final IBreakpointDMContext breakpoint)
			throws Throwable
	{
        Query<Object> query = new Query<Object>() {
			@Override
			protected void execute(final DataRequestMonitor<Object> rm) {
				fBreakpointService.removeBreakpoint(breakpoint, rm);
			}
        };

        fBreakpointService.getExecutor().execute(query);
        try {
        	query.get(1, TimeUnit.SECONDS);
        } catch (ExecutionException e) {
        	assert false : e.getCause().getMessage();
        }
	}

	protected void updateBreakpoint(final IBreakpointDMContext breakpoint, final Map<String, Object> delta)
			throws Throwable
	{
        Query<Object> query = new Query<Object>() {
			@Override
			protected void execute(DataRequestMonitor<Object> rm) {
				fBreakpointService.updateBreakpoint(breakpoint, delta, rm);
			}
        };

        fBreakpointService.getExecutor().execute(query);
        try {
        	query.get(1, TimeUnit.SECONDS);
        } catch (ExecutionException e) {
        	assert false : e.getCause().getMessage();
        }
	}

	protected IBreakpointDMData getBreakpoint(final IBreakpointDMContext breakpoint)
			throws Throwable
	{
        Query<IBreakpointDMData> query = new Query<IBreakpointDMData>() {
			@Override
			protected void execute(DataRequestMonitor<IBreakpointDMData> rm) {
				fBreakpointService.getBreakpointDMData(breakpoint, rm);
			}
        };

        fBreakpointService.getExecutor().execute(query);
        try {
        	return query.get(1, TimeUnit.SECONDS);
        } catch (ExecutionException e) {
        	assert false : e.getCause().getMessage();
        }
        return null;
	}

	protected IBreakpointDMContext[] getBreakpoints(final IBreakpointsTargetDMContext context)
			throws Throwable
	{
        Query<IBreakpointDMContext[]> query = new Query<IBreakpointDMContext[]>() {
			@Override
			protected void execute(DataRequestMonitor<IBreakpointDMContext[]> rm) {
				fBreakpointService.getBreakpoints(context, rm);
			}
        };

        fBreakpointService.getExecutor().execute(query);
        try {
        	return query.get(1, TimeUnit.SECONDS);
        } catch (ExecutionException e) {
        	assert false : e.getCause().getMessage();
        }
        return null;
	}

	// *********************************************************************
	// TraceControl service methods.
	// *********************************************************************

	//    private void startTracing() throws InterruptedException
	//    {
	//    	startTracing(null);
	//    }
	//
	//    private void startTracing(String errorMessage) throws InterruptedException
	//    {
	//    	final AsyncCompletionWaitor wait = new AsyncCompletionWaitor();
	//
	//    	fTraceService.getExecutor().submit(new Runnable() {
	//            public void run() {
	//                fTraceService.canStartTracing(fTraceTargetDmc,
	//                		new DataRequestMonitor<Boolean>(fTraceService.getExecutor(), null) {
	//                    @Override
	//                    protected void handleCompleted() {
	//                    	wait.setReturnInfo(getData());
	//                        wait.waitFinished(getStatus());
	//                    }
	//                });
	//            }
	//        });
	//
	//        wait.waitUntilDone(AsyncCompletionWaitor.WAIT_FOREVER);
	//		assertTrue(wait.getMessage(), wait.isOK());
	//		assertTrue("Not allowed to start tracing!", (Boolean)wait.getReturnInfo());
	//
	//		wait.waitReset();
	//
	//    	fTraceService.getExecutor().submit(new Runnable() {
	//            public void run() {
	//                fTraceService.startTracing(fTraceTargetDmc,
	//                		new RequestMonitor(fTraceService.getExecutor(), null) {
	//                    @Override
	//                    protected void handleCompleted() {
	//                        wait.waitFinished(getStatus());
	//                    }
	//                });
	//            }
	//        });
	//
	//        wait.waitUntilDone(AsyncCompletionWaitor.WAIT_FOREVER);
	//        if (errorMessage == null) {
	//        	assertTrue(wait.getMessage(), wait.isOK());
	//        } else {
	//        	assertTrue(wait.getMessage(), !wait.isOK());
	//        	assertTrue("Message " + wait.getMessage() + " does not contain \"" + errorMessage +"\"",
	//        			   wait.getMessage().indexOf(errorMessage) != -1);
	//        }
	//    }
	//
	//    private void stopTracing() throws InterruptedException
	//    {
	//       	final AsyncCompletionWaitor wait = new AsyncCompletionWaitor();
	//
	//    	fTraceService.getExecutor().submit(new Runnable() {
	//            public void run() {
	//                fTraceService.canStopTracing(fTraceTargetDmc,
	//                		new DataRequestMonitor<Boolean>(fTraceService.getExecutor(), null) {
	//                    @Override
	//                    protected void handleCompleted() {
	//                    	wait.setReturnInfo(getData());
	//                        wait.waitFinished(getStatus());
	//                    }
	//                });
	//            }
	//        });
	//
	//        wait.waitUntilDone(AsyncCompletionWaitor.WAIT_FOREVER);
	//		assertTrue(wait.getMessage(), wait.isOK());
	//		assertTrue("Not allowed to stop tracing!", (Boolean)wait.getReturnInfo());
	//
	//		wait.waitReset();
	//
	//    	fTraceService.getExecutor().submit(new Runnable() {
	//            public void run() {
	//                fTraceService.stopTracing(fTraceTargetDmc,
	//                		new RequestMonitor(fTraceService.getExecutor(), null) {
	//                    @Override
	//                    protected void handleCompleted() {
	//                        wait.waitFinished(getStatus());
	//                    }
	//                });
	//            }
	//        });
	//
	//        wait.waitUntilDone(AsyncCompletionWaitor.WAIT_FOREVER);
	//		assertTrue(wait.getMessage(), wait.isOK());
	//    }
	//
	//    private boolean isTracing() throws InterruptedException
	//    {
	//       	final AsyncCompletionWaitor wait = new AsyncCompletionWaitor();
	//
	//    	fTraceService.getExecutor().submit(new Runnable() {
	//            public void run() {
	//                fTraceService.isTracing(fTraceTargetDmc,
	//                		new DataRequestMonitor<Boolean>(fTraceService.getExecutor(), null) {
	//                    @Override
	//                    protected void handleCompleted() {
	//                    	wait.setReturnInfo(getData());
	//                        wait.waitFinished(getStatus());
	//                    }
	//                });
	//            }
	//        });
	//
	//        wait.waitUntilDone(AsyncCompletionWaitor.WAIT_FOREVER);
	//		assertTrue(wait.getMessage(), wait.isOK());
	//
	//		return (Boolean)wait.getReturnInfo();
	//    }
	//
	//    private ITraceStatusDMData getTraceStatus() throws InterruptedException
	//    {
	//       	final AsyncCompletionWaitor wait = new AsyncCompletionWaitor();
	//
	//    	fTraceService.getExecutor().submit(new Runnable() {
	//            public void run() {
	//                fTraceService.getTraceStatus(fTraceTargetDmc,
	//                		new DataRequestMonitor<ITraceStatusDMData>(fTraceService.getExecutor(), null) {
	//                    @Override
	//                    protected void handleCompleted() {
	//                        wait.setReturnInfo(getData());
	//                        wait.waitFinished(getStatus());
	//                    }
	//                });
	//            }
	//        });
	//
	//        wait.waitUntilDone(AsyncCompletionWaitor.WAIT_FOREVER);
	//		assertTrue(wait.getMessage(), wait.isOK());
	//
	//		return (ITraceStatusDMData)wait.getReturnInfo();
	//    }

	// *********************************************************************
	// Below are the tests for the control of tracepoints.
	// *********************************************************************

	protected IBreakpointDMContext[] fTracepoints = null;

	//	private void checkTraceStatus(boolean supported, boolean active, int frames,
	//			                      STOP_REASON_ENUM reason, Integer stoppingTracepoint) throws Throwable {
	//		ITraceStatusDMData status = getTraceStatus();
	//		assertTrue("Error tracing supported should be " + supported + " but was " + status.isTracingSupported(),
	//				   status.isTracingSupported() == supported);
	//		assertTrue("Error tracing active should be " + active + " but was " + status.isTracingActive(),
	//				   status.isTracingActive() == active);
	//		boolean isTracing = isTracing();
	//		assertTrue("Error, tracing active is " + status.isTracingActive() + " but the tracepoint service thinks it is " + isTracing,
	//				   status.isTracingActive() == isTracing);
	//
	//		assertTrue("Wrong number of collected frames.  Expected " + frames + " but got " +
	//				   status.getNumberOfCollectedFrame(),
	//				   status.getNumberOfCollectedFrame() == frames);
	//		assertTrue("Total buffer size should be positive but is " +
	//				   status.getTotalBufferSize(),
	//				   status.getTotalBufferSize() > 0);
	//
	//		if (fTotalTracingBufferSize == 0) {
	//			// Initialize buffer
	//			fTotalTracingBufferSize = status.getTotalBufferSize();
	//		} else {
	//			assertTrue("Total buffer size changed!  Should be " + fTotalTracingBufferSize +
	//					   " but got " + status.getTotalBufferSize(),
	//					   status.getTotalBufferSize() == fTotalTracingBufferSize);
	//		}
	//
	//		assertTrue("Expected stopping reason " + reason + " but got " + status.getStopReason(),
	//				   status.getStopReason() == reason);
	//		assertTrue("Expected stopping bp " + stoppingTracepoint + " but got " + status.getStoppingTracepoint(),
	//				   status.getStoppingTracepoint() == stoppingTracepoint);
	//	}
	//
	//	private void checkTraceStatus(boolean supported, boolean active, int frames) throws Throwable {
	//		checkTraceStatus(supported, active, frames, null, null);
	//	}

	protected class TracepointData {
		String sourceFile;
		int lineNumber;
		String condition;
		int passcount;
		boolean enabled;
		String commands;
		boolean isFastTp;

		public TracepointData(int line, String cond, int pass, boolean isEnabled, String cmds, boolean fast) {
			this(SOURCE_NAME, line, cond, pass, isEnabled, cmds, fast);
		}

		public TracepointData(String file, int line, String cond, int pass, boolean isEnabled, String cmds, boolean fast) {
			sourceFile = file;
			lineNumber = line;
			condition = cond;
			passcount = pass;
			enabled = isEnabled;
			commands = cmds;
			isFastTp = fast;
			assertTrue(!fast || fastTracepointsSupported());
		}
	}

	protected void checkTracepoints(TracepointData[] dataArray) throws Throwable {
		int numTracepoints = dataArray.length;

		// Fetch the tp list from the backend
		IBreakpointDMContext[] tracepoints = getBreakpoints(fBreakpointsDmc);
		assertEquals("expected " + numTracepoints + " breakpoint(s), received "
				+ tracepoints.length, numTracepoints, tracepoints.length);

		for (int i=0; i<numTracepoints; i++) {
			TracepointData data = dataArray[i];

			// Ensure that the tracepoints were correctly installed
			MIBreakpointDMData tp = (MIBreakpointDMData) getBreakpoint(fTracepoints[i]);
			assertEquals("tracepoint "+i+" is not a tracepoint but a " + tp.getBreakpointType(),
					MIBreakpoints.TRACEPOINT, tp.getBreakpointType());
			assertEquals("tracepoint "+i+" should be a " + (data.isFastTp?"fast":"normal")+" tracepoint but is not",
					data.isFastTp, tp.getType().equals("fast tracepoint"));
			assertEquals("tracepoint "+i+" mismatch (wrong file name) got " + tp.getFileName(),
					data.sourceFile, tp.getFileName());
			assertEquals("tracepoint "+i+" mismatch (wrong line number) got " + tp.getLineNumber(),
					data.lineNumber, tp.getLineNumber());
			assertEquals("tracepoint "+i+" mismatch (wrong condition) got " + tp.getCondition(),
					data.condition, tp.getCondition());
			assertEquals("tracepoint "+i+" mismatch (wrong pass count) got " + tp.getPassCount(),
					data.passcount, tp.getPassCount());
			assertEquals("tracepoint "+i+" mismatch (wrong enablement) got " + tp.isEnabled(),
					data.enabled, tp.isEnabled());
			assertEquals("tracepoint "+i+" mismatch (wrong actions) got " + tp.getCommands(),
					data.commands, tp.getCommands());

			assertEquals("tracepoint "+i+" mismatch",
					getBreakpoint(tracepoints[i]), tp);
		}
	}

	protected void checkTracepoints(boolean useCond, boolean useCount, boolean enabled, boolean useActions)
			throws Throwable {
		TracepointData[] dataArray = new TracepointData[] {
			new TracepointData(getLineForTag("1_BYTE"), useCond ? CONDITIONS[0] : NO_CONDITION, useCount ? PASS_COUNTS[0] : 0, enabled, useActions ? COLLECT_ACTIONS[0].toString() : NO_COMMANDS, false),
			new TracepointData(getLineForTag("2_BYTE"), useCond ? CONDITIONS[1] : NO_CONDITION, useCount ? PASS_COUNTS[1] : 0, enabled, useActions ? COLLECT_ACTIONS[1].toString() : NO_COMMANDS, false),
			new TracepointData(getLineForTag("3_BYTE"), useCond ? CONDITIONS[2] : NO_CONDITION, useCount ? PASS_COUNTS[2] : 0, enabled, useActions ? COLLECT_ACTIONS[2].toString() : NO_COMMANDS, false),
			new TracepointData(getLineForTag("4_BYTE"), useCond ? CONDITIONS[3] : NO_CONDITION, useCount ? PASS_COUNTS[3] : 0, enabled, useActions ? COLLECT_ACTIONS[3].toString() : NO_COMMANDS, acceptsFastTpOnFourBytes()),
			new TracepointData(getLineForTag("5_BYTE"), useCond ? CONDITIONS[4] : NO_CONDITION, useCount ? PASS_COUNTS[4] : 0, enabled, useActions ? COLLECT_ACTIONS[4].toString() : NO_COMMANDS, fastTracepointsSupported()),
		};

		checkTracepoints(dataArray);
	}

	protected void createTracepoints(boolean useCond, boolean useCount, boolean enabled, boolean useActions)
			throws Throwable
	{
		Map<String, Object> attributes = null;

		int[] lineNumbers = {
				getLineForTag("1_BYTE"),
				getLineForTag("2_BYTE"),
				getLineForTag("3_BYTE"),
				getLineForTag("4_BYTE"),
				getLineForTag("5_BYTE") };

		for (int i = 0; i < lineNumbers.length; i++) {
			attributes = new HashMap<String, Object>();
			attributes.put(MIBreakpoints.BREAKPOINT_TYPE, MIBreakpoints.TRACEPOINT);
			attributes.put(MIBreakpoints.FILE_NAME, SOURCE_NAME);
			attributes.put(MIBreakpoints.LINE_NUMBER, lineNumbers[i]);
			if (!enabled) attributes.put(MIBreakpoints.IS_ENABLED, enabled);
			if (useCount) attributes.put(MIBreakpoints.PASS_COUNT, PASS_COUNTS[i]);
			if (useCond) attributes.put(MIBreakpoints.CONDITION, CONDITIONS[i]);
			if (useActions) attributes.put(MIBreakpoints.COMMANDS, COLLECT_ACTIONS[i].getName());

			fTracepoints[i] = insertBreakpoint(fBreakpointsDmc, attributes);

			waitForBreakpointEvent();
			assertEquals("Incorrect number of breakpoint events", 1,  fBreakpointEventCount);
			assertEquals("Incorrect number of breakpoint added events", 1, getBreakpointEventCount(BP_ADDED));
			clearEventCounters();
		}

		checkTracepoints(useCond, useCount, enabled, useActions);
	}

	/**
	 * This test makes sure that the tracing status is correct when we start.
	 * It also stores the total buffer size to be used by other tests.
	 * This test is being run before every other test by being called
	 * by the @Before method; this allows to verify every launch of GDB.
	 */
	@Test
	@Ignore
	public void checkTraceInitialStatus() {
		//		checkTraceStatus(true, false, 0);
	}

	/**
	 * This test relies on knowing that instructions in the compiled
	 * code are of the expected number of bytes long. See the {@value #SOURCE_NAME}
	 * for details of how to resolve this test failing.
	 */
	@Test
	public void checkInstructionsAreExpectedLength() throws Throwable {
		// GDB helpfully returns an error if you try to insert a fast tracepoint
		// on an instruction < 4 bytes long. We can use that to verify how big
		// each instruction is.

		IContainerDMContext containerDmc = SyncUtil.getContainerContext();
		Query<MIInfo> query = new Query<MIInfo>() {
			@Override
			protected void execute(DataRequestMonitor<MIInfo> rm) {
				fGdbControl.queueCommand(
						fCommandFactory.createMIInterpreterExecConsole(containerDmc, "disassemble /rs foo"), rm);
			}
		};
		fGdbControl.getExecutor().execute(query);
		MIInfo miInfo = query.get(TestsPlugin.massageTimeout(500), TimeUnit.MILLISECONDS);
		try {
			MIOOBRecord[] mioobRecords = miInfo.getMIOutput().getMIOOBRecords();
			Set<Integer> passed = new HashSet<>();
			for (int i = 0; i < mioobRecords.length; i++) {
				String sourceLineWithComment = ((MIStreamRecord) mioobRecords[i]).getString();
				int index;
				if ((index = sourceLineWithComment.indexOf("_BYTE")) >= 0) {
					int byteCount = Integer.parseInt(sourceLineWithComment.substring(index - 1, index));
					String disassembledInstruction = ((MIStreamRecord) mioobRecords[i + 1]).getString();
					String[] split = disassembledInstruction.split("\\t", 3);
					@SuppressWarnings("unused")
					String addr = split[0];
					String bytes = split[1];
					@SuppressWarnings("unused")
					String mnemonic = split[2];
					String[] bytes2 = bytes.split(" ");
					assertEquals(byteCount, bytes2.length);
					passed.add(byteCount);
				}
			}
			assertEquals("Some byte length were not seen", new HashSet<Integer>(Arrays.asList(1, 2, 3, 4, 5)), passed);
		} catch (AssertionError | Exception e) {
			throw new AssertionError("Failed to verify instruction lengths. Output from GDB's disassemble:\n" + miInfo.toString(), e);
		}
	}

	/**
	 * This test sets different tracepoints in the program:
	 * - using a method address
	 * - using a method name
	 * - using a filename and line number
	 *
	 * It also set a fast tracepoint by
	 */
	@Test
	public void createTracepoints() throws Throwable {
		createTracepoints(false, false, true, false);
	}

	/**
	 * This test sets the different types of tracepoints and then deletes them
	 */
	@Test
	public void deleteTracepoints() throws Throwable {
		createTracepoints();
		// Delete all tracepoints
		for (IBreakpointDMContext tp : fTracepoints) {
			if (tp == null) break;
			removeBreakpoint(tp);
		}

		// Fetch the bp list from the backend
		IBreakpointDMContext[] breakpoints = getBreakpoints(fBreakpointsDmc);
		assertTrue("BreakpointService problem: expected " + 0 + " breakpoints, received "
				+ breakpoints.length, breakpoints.length == 0);
	}

	/**
	 * This test sets the different types of tracepoints and then disables them
	 */
	@Test
	public void disableTracepoints() throws Throwable {
		createTracepoints();

		Map<String, Object> delta = new HashMap<String, Object>();
		delta.put(MIBreakpoints.IS_ENABLED, false);
		// Disable all tracepoints
		for (IBreakpointDMContext tp : fTracepoints) {
			if (tp == null) break;
			updateBreakpoint(tp, delta);
		}

		checkTracepoints(false, false, false, false);
	}

	/**
	 * This test sets, disables the different types of tracepoints and then enables them
	 */
	@Test
	public void enableTracepoints() throws Throwable {
		disableTracepoints();

		Map<String, Object> delta = new HashMap<String, Object>();
		delta.put(MIBreakpoints.IS_ENABLED, true);
		// Enable all tracepoints
		for (IBreakpointDMContext tp : fTracepoints) {
			if (tp == null) break;
			updateBreakpoint(tp, delta);
		}

		checkTracepoints(false, false, true, false);
	}

	/**
	 * This test sets the different types of tracepoints and then sets their passcount
	 */
	@Test
	public void tracepointPasscount() throws Throwable {
		createTracepoints();

		Map<String, Object> delta = new HashMap<String, Object>();
		// Set passcount for all tracepoints
		for (int i=0; i<fTracepoints.length; i++) {
			if (fTracepoints[i] == null) break;
			if (PASS_COUNTS[i] == 0) continue;
			delta.put(MIBreakpoints.PASS_COUNT, PASS_COUNTS[i]);
			updateBreakpoint(fTracepoints[i], delta);
		}

		checkTracepoints(false, true, true, false);
	}

	/**
	 * This test sets the different types of tracepoints and then sets some conditions
	 */
	@Test
	public void tracepointCondition() throws Throwable {
		createTracepoints();

		Map<String, Object> delta = new HashMap<String, Object>();
		// Set conditions for all tracepoints
		for (int i=0; i<fTracepoints.length; i++) {
			if (fTracepoints[i] == null) break;
			if (CONDITIONS[i].equals(NO_CONDITION)) continue;
			delta.put(MIBreakpoints.CONDITION, CONDITIONS[i]);
			updateBreakpoint(fTracepoints[i], delta);
		}

		checkTracepoints(true, false, true, false);
	}

	/**
	 * This test sets the different types of tracepoints and then sets some actions
	 */
	@Test
	public void tracepointActions() throws Throwable {
		createTracepoints();

		Map<String, Object> delta = new HashMap<String, Object>();
		// Set conditions for all tracepoints
		for (int i=0; i<fTracepoints.length; i++) {
			if (fTracepoints[i] == null) break;
			if (COLLECT_ACTIONS[i].equals(NO_COMMANDS)) continue;
			delta.put(MIBreakpoints.COMMANDS, COLLECT_ACTIONS[i].getName());
			updateBreakpoint(fTracepoints[i], delta);
		}

		checkTracepoints(false, false, true, true);
	}

	/**
	 * This test creates a tracepoint that starts disabled
	 */
	@Test
	public void createTracepointDisabled() throws Throwable {
		createTracepoints(false, false, false, false);
	}

	/**
	 * This test creates a tracepoint that starts with a passcount
	 */
	@Test
	public void createTracepointWithPasscount() throws Throwable {
		createTracepoints(false, true, true, false);
	}

	/**
	 * This test creates a tracepoint that starts with a condition
	 */
	@Test
	public void createTracepointWithCondition() throws Throwable {
		createTracepoints(true, false, true, false);
	}

	/**
	 * This test creates tracepoints that start a command
	 */
	@Test
	public void createTracepointWithCommand() throws Throwable {
		createTracepoints(false, false, true, true);
	}

	/**
	 * This test creates tracepoints that start with more than one command
	 */
	@Test
	public void createTracepointWithMultipleCommands() throws Throwable {

		String commandsNames1 = COLLECT_ACTIONS[0].getName() + TracepointActionManager.TRACEPOINT_ACTION_DELIMITER +
				COLLECT_ACTIONS[1].getName() + TracepointActionManager.TRACEPOINT_ACTION_DELIMITER +
				COLLECT_ACTIONS[3].getName();
		String commandsResult1 = COLLECT_ACTIONS[0].toString() + TracepointActionManager.TRACEPOINT_ACTION_DELIMITER +
				COLLECT_ACTIONS[1].toString() + TracepointActionManager.TRACEPOINT_ACTION_DELIMITER +
				COLLECT_ACTIONS[3].toString();

		String commandsNames2 = COLLECT_ACTIONS[2].getName() + TracepointActionManager.TRACEPOINT_ACTION_DELIMITER +
				COLLECT_ACTIONS[2].getName() + TracepointActionManager.TRACEPOINT_ACTION_DELIMITER +
				COLLECT_ACTIONS[1].getName();
		String commandsResult2 = COLLECT_ACTIONS[2].toString() + TracepointActionManager.TRACEPOINT_ACTION_DELIMITER +
				COLLECT_ACTIONS[2].toString() + TracepointActionManager.TRACEPOINT_ACTION_DELIMITER +
				COLLECT_ACTIONS[1].toString();

		String commandsNames3 = COLLECT_ACTIONS[4].getName() + TracepointActionManager.TRACEPOINT_ACTION_DELIMITER +
				COLLECT_ACTIONS[0].getName() + TracepointActionManager.TRACEPOINT_ACTION_DELIMITER +
				COLLECT_ACTIONS[1].getName();
		String commandsResult3 = COLLECT_ACTIONS[4].toString() + TracepointActionManager.TRACEPOINT_ACTION_DELIMITER +
				COLLECT_ACTIONS[0].toString() + TracepointActionManager.TRACEPOINT_ACTION_DELIMITER +
				COLLECT_ACTIONS[1].toString();

		String cmdNames[] = new String[] { commandsNames1, COLLECT_ACTIONS[0].getName(), commandsNames2, COLLECT_ACTIONS[2].getName(), commandsNames3 };
		String cmdResults[] = new String[] { commandsResult1, COLLECT_ACTIONS[0].toString(), commandsResult2, COLLECT_ACTIONS[2].toString(), commandsResult3};

		Map<String, Object> attributes = null;

		int[] lineNumbers = {
				getLineForTag("1_BYTE"),
				getLineForTag("2_BYTE"),
				getLineForTag("3_BYTE"),
				getLineForTag("4_BYTE"),
				getLineForTag("5_BYTE") };

		for (int i = 0; i < lineNumbers.length; i++) {
			attributes = new HashMap<String, Object>();
			attributes.put(MIBreakpoints.BREAKPOINT_TYPE, MIBreakpoints.TRACEPOINT);
			attributes.put(MIBreakpoints.FILE_NAME, SOURCE_NAME);
			attributes.put(MIBreakpoints.LINE_NUMBER, lineNumbers[i]);
			attributes.put(MIBreakpoints.COMMANDS, cmdNames[i]);

			fTracepoints[i] = insertBreakpoint(fBreakpointsDmc, attributes);

			waitForBreakpointEvent();
			assertEquals("Incorrect number of breakpoint events", 1,  fBreakpointEventCount);
			assertEquals("Incorrect number of breakpoint added events", 1, getBreakpointEventCount(BP_ADDED));
			clearEventCounters();
		}

		TracepointData[] dataArray = new TracepointData[] {
				new TracepointData(getLineForTag("1_BYTE"), NO_CONDITION, 0, true, cmdResults[0], false),
				new TracepointData(getLineForTag("2_BYTE"), NO_CONDITION, 0, true, cmdResults[1], false),
				new TracepointData(getLineForTag("3_BYTE"), NO_CONDITION, 0, true, cmdResults[2], false),
				new TracepointData(getLineForTag("4_BYTE"), NO_CONDITION, 0, true, cmdResults[3], acceptsFastTpOnFourBytes()),
				new TracepointData(getLineForTag("5_BYTE"), NO_CONDITION, 0, true, cmdResults[4], fastTracepointsSupported()),
			};

			checkTracepoints(dataArray);
	}

	/**
	 * This test creates an enabled tracepoint that starts with commands, condition and passcount
	 */
	@Test
	public void createTracepointEnabledWithCommandsConditionPasscount() throws Throwable {
		createTracepoints(true, true, true, true);
	}

	/**
	 * This test creates a disabled tracepoint that starts with commands, condition and passcount
	 */
	@Test
	public void createTracepointDisabledWithCommandsConditionPasscount() throws Throwable {
		createTracepoints(true, true, false, true);
	}

	//	/**
	//	 * This test sets the different types of tracepoints and then sets some eval actions
	//	 */
	//	@Test
	//	public void testEvalActions() throws Throwable {
	//		final String ACTIONS1 = EVAL_ACTION_1.getName()+","+EVAL_ACTION_2.getName()+","+EVAL_ACTION_3.getName();
	//		final String ACTIONS2 = EVAL_ACTION_1.getName()+","+EVAL_ACTION_3.getName();
	//		final String ACTIONS3 = EVAL_ACTION_3.getName();
	//
	//		testCreateTracepoints();
	//		testActions(new String[] {ACTIONS1, ACTIONS2, ACTIONS3, ""});
	//	}
	//
	//	/**
	//	 * This test sets the different types of tracepoints and then sets some while-stepping actions
	//	 */
	//	//@Test
	//	public void testSteppingActions() throws Throwable {
	////		final String ACTIONS1 = STEPPING_ACTION_1.getName()+","+STEPPING_ACTION_2.getName()+","+STEPPING_ACTION_3.getName();
	////		final String ACTIONS2 = STEPPING_ACTION_1.getName()+","+STEPPING_ACTION_3.getName();
	////		final String ACTIONS3 = STEPPING_ACTION_3.getName();
	////
	////		testCreateTracepoints();
	////		testActions(new String[] {ACTIONS1, ACTIONS2, ACTIONS3, ""});
	//	}
	//
	//	/**
	//	 * This test sets the different types of tracepoints and then sets a mix of different
	//     * tracepoint actions
	//	 */
	//	//@Test
	//	public void testMixedActions() throws Throwable {
	////		final String ACTIONS1 = COLLECT_ACTION_1.getName() + "," +
	////		                        EVAL_ACTION_2.getName() + "," +
	////		                        STEPPING_ACTION_3.getName();
	////		final String ACTIONS2 = STEPPING_ACTION_1.getName() + "," +
	////								COLLECT_ACTION_2.getName() + "," +
	////		                        EVAL_ACTION_1.getName() + "," +
	////								COLLECT_ACTION_3.getName() + "," +
	////		                        EVAL_ACTION_2.getName() + "," +
	////		                        EVAL_ACTION_3.getName();
	////		final String ACTIONS3 = EVAL_ACTION_3.getName() + "," +
	////								COLLECT_ACTION_1.getName() + "," +
	////								EVAL_ACTION_2.getName() + "," +
	////								STEPPING_ACTION_3.getName();
	////
	////		testCreateTracepoints();
	////		testActions(new String[] {ACTIONS1, ACTIONS2, ACTIONS3, ""});
	//	}
	//
	//	/**
	//	 * This test sets the different types of tracepoints and then sets some default collect actions
	//	 */
	//	//@Test
	//	public void testDefaultCollectAction() throws Throwable {
	//		testCreateTracepoints();
	//	}
	//
	//	// *********************************************************************
	//	// Below are the tests for the control of tracing
	//	// *********************************************************************
	//
	//	/**
	//	 * This test sets different tracepoints in the program:
	//	 * - using a filename and line number
	//	 * - using a method name
	//	 * - using a method address
	//	 *
	//	 * and confirms they are installed when tracing starts
	//	 */
	//	@Test
	//	public void testCreateAndRunTracepoints() throws Throwable {
	//		testCreateTracepoints();
	//		startTracing();
	//		SyncUtil.SyncRunToLocation(Integer.toString(LAST_LINE_NUMBER));
	//		checkTraceStatus(true, true, TOTAL_FRAMES_TO_BE_COLLECTED);
	//		stopTracing();
	//		checkTraceStatus(true, false, TOTAL_FRAMES_TO_BE_COLLECTED);
	//	}
	//
	//	/**
	//	 * This test sets the different types of tracepoints and then deletes them
	// 	 * and confirms they are not installed when tracing starts
	//	 */
	//	@Test
	//	public void testDeleteAndRunTracepoints() throws Throwable {
	//		testDeleteTracepoints();
	//		startTracing("No tracepoints available to download");
	//		SyncUtil.SyncRunToLocation(Integer.toString(LAST_LINE_NUMBER));
	//		checkTraceStatus(true, false, 0);
	//	}
	//
	//	/**
	//	 * This test sets the different types of tracepoints and then disables them
	// 	 * and confirms they are not hit when tracing starts
	//	 */
	//	@Test
	//	public void testDisableAndRunTracepoints() throws Throwable {
	//		testDisableTracepoints();
	//		startTracing("None of the downloadable tracepoints enabled");
	//		SyncUtil.SyncRunToLocation(Integer.toString(LAST_LINE_NUMBER));
	//		checkTraceStatus(true, false, 0);
	//	}
	//
	//	/**
	//	 * This test sets, disables the different types of tracepoints and then enables them
	//	 * and confirms they are hit when tracing starts
	//	 */
	//	@Test
	//	public void testEnableAndRunTracepoints() throws Throwable {
	//		testEnableTracepoints();
	//		startTracing();
	//		SyncUtil.SyncRunToLocation(Integer.toString(LAST_LINE_NUMBER));
	//		checkTraceStatus(true, true, TOTAL_FRAMES_TO_BE_COLLECTED);
	//		stopTracing();
	//		checkTraceStatus(true, false, TOTAL_FRAMES_TO_BE_COLLECTED);
	//	}
	//
	//	/**
	//	 * This test sets the different types of tracepoints and then sets their passcount
	//	 * and confirms the passcount is respected
	//	 */
	//	@Test
	//	public void testTracepointPasscountAndRun1() throws Throwable {
	//		testTracepointPasscount();
	//		startTracing();
	//		SyncUtil.SyncRunToLocation(Integer.toString(LAST_LINE_NUMBER));
	//
	//		checkTraceStatus(true, false,
	//				         1 + 1 + 10 + 1 + PASS_COUNTS[4],
	//				         STOP_REASON_ENUM.PASSCOUNT, 6);
	//	}
	//
	//	/**
	//	 * This test sets the passcount of the a tracepoint that is hit before some
	//	 * other tracepoints are hit, to confirm tracing really stops.
	//	 */
	//	@Test
	//	public void testTracepointPasscountAndRun2() throws Throwable {
	//		testTracepointPasscount();
	//
	//		// Set the passcount of the forth tp to make it stop the tracing
	//		Map<String, Object> delta = new HashMap<String, Object>();
	//		delta.put(MIBreakpoints.IGNORE_COUNT, 1);
	//		updateBreakpoint(fTracepoints[3], delta);
	//
	//		startTracing();
	//		SyncUtil.SyncRunToLocation(Integer.toString(LAST_LINE_NUMBER));
	//
	//		checkTraceStatus(true, false,
	//						 1 + 1 + 10 + 1,
	//				         STOP_REASON_ENUM.PASSCOUNT, 5);
	//	}
	//
	//	/**
	//	 * This test sets a tracepoint and then gives it a condition
	// 	 * and confirms the condition is respected
	//	 */
	//	//@Test
	//	public void testTracepointConditionAndRun() throws Throwable {
	//		// Use trace state variables and stuff
	//	}
	//
	//	/**
	//	 * This test sets the different types of tracepoints and then sets some collect actions
	//	 * and confirms the proper information is collected
	//	 */
	//	//@Test
	//	public void testCollectActionsAndRun() throws Throwable {
	//		testCreateTracepoints();
	//	}
	//
	//	/**
	//	 * This test sets the different types of tracepoints and then sets some eval actions
	//	 * and confirms the trace variables are properly updated
	//	 */
	//	//@Test
	//	public void testEvalActionsAndRun() throws Throwable {
	//		testCreateTracepoints();
	//	}
	//
	//	/**
	//	 * This test sets the different types of tracepoints and then sets some while-stepping actions
	//	 * and confirms the proper information is collected
	//	 */
	//	//@Test
	//	public void testSteppingActionsAndRun() throws Throwable {
	//		testCreateTracepoints();
	//	}
	//
	//	/**
	//	 * This test sets the different types of tracepoints and then sets a mix of different
	//     * tracepoint actions and confirms the proper information is collected
	//	 */
	//	//@Test
	//	public void testMixedActionsAndRun() throws Throwable {
	//		testCreateTracepoints();
	//	}
	//
	//	/**
	//	 * This test sets the different types of tracepoints and then sets some default collect actions
	//	 * and confirms the proper information is collected
	//	 */
	//	//@Test
	//	public void testDefaultCollectActionAndRun() throws Throwable {
	//		testCreateTracepoints();
	//	}
	//

	protected boolean acceptsFastTpOnFourBytes() {
		String gdbVersion = getGdbVersion();
		boolean isLower = LaunchUtils.compareVersions(ITestConstants.SUFFIX_GDB_7_4, gdbVersion) > 0;
		if (isLower) return false;
		// With GDB 7.4, fast tracepoints only need an
		// instruction of 4 bytes or more when on a 32bit architecture, instead of 5.
	    if (Platform.getOS().equals(Platform.ARCH_X86)) {
	    	return true;
	    }
	    return false;
	}

	protected boolean fastTracepointsSupported() {
		return  LaunchUtils.compareVersions(getGdbVersion(), ITestConstants.SUFFIX_GDB_7_2) >= 0;
	}

	/**
	 * This test sets the different types of tracepoints and then sets some string collection actions
	 */
	@Test
	public void tracepointActionsWithCollectStrings() throws Throwable {
		assumeGdbVersionAtLeast(ITestConstants.SUFFIX_GDB_7_4);
		TracepointActionManager tracepointActionMgr = TracepointActionManager.getInstance();

		CollectAction action1 = new CollectAction();
		action1.setCollectString("/s $locals");
		action1.setName("Collect string locals");
		tracepointActionMgr.addAction(action1);

		CollectAction action2 = new CollectAction();
		action2.setCollectString("/s3 $locals, $reg");
		action2.setName("Collect string locals, reg");
		tracepointActionMgr.addAction(action2);

		createTracepoints();

		Map<String, Object> delta = new HashMap<String, Object>();
		// Set conditions for all tracepoints
		delta.put(MIBreakpoints.COMMANDS, action1.getName());
		updateBreakpoint(fTracepoints[0], delta);
		delta.put(MIBreakpoints.COMMANDS, action2.getName());
		updateBreakpoint(fTracepoints[1], delta);
		delta.put(MIBreakpoints.COMMANDS, action1.getName());
		updateBreakpoint(fTracepoints[2], delta);
		delta.put(MIBreakpoints.COMMANDS, action1.getName());
		updateBreakpoint(fTracepoints[3], delta);
		delta.put(MIBreakpoints.COMMANDS, action2.getName());
		updateBreakpoint(fTracepoints[4], delta);

		TracepointData[] dataArray = new TracepointData[] {
			new TracepointData(getLineForTag("1_BYTE"), NO_CONDITION, 0, true, action1.toString(), false),
			new TracepointData(getLineForTag("2_BYTE"), NO_CONDITION, 0, true, action2.toString(), false),
			new TracepointData(getLineForTag("3_BYTE"), NO_CONDITION, 0, true, action1.toString(), false),
			new TracepointData(getLineForTag("4_BYTE"), NO_CONDITION, 0, true, action1.toString(), acceptsFastTpOnFourBytes()),
			new TracepointData(getLineForTag("5_BYTE"), NO_CONDITION, 0, true, action2.toString(), fastTracepointsSupported()),
		};

		checkTracepoints(dataArray);
	}
}

Back to the top