-
Notifications
You must be signed in to change notification settings - Fork 575
/
Copy pathCMakeLists.txt
1351 lines (1247 loc) · 59.5 KB
/
CMakeLists.txt
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
# **********************************************************
# Copyright (c) 2015-2025 Google, Inc. All rights reserved.
# **********************************************************
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
#
# * Redistributions of source code must retain the above copyright notice,
# this list of conditions and the following disclaimer.
#
# * Redistributions in binary form must reproduce the above copyright notice,
# this list of conditions and the following disclaimer in the documentation
# and/or other materials provided with the distribution.
#
# * Neither the name of Google, Inc. nor the names of its contributors may be
# used to endorse or promote products derived from this software without
# specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
# ARE DISCLAIMED. IN NO EVENT SHALL VMWARE, INC. OR CONTRIBUTORS BE LIABLE
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
# DAMAGE.
# 3.7 is DR's min as well, for VS2017, GREATER_EQUAL, etc.
cmake_minimum_required(VERSION 3.7)
include(../../make/policies.cmake NO_POLICY_SCOPE)
# We set a time limit on our unit tests here which do not go through suite/.
set(test_seconds 90)
if (WIN32)
set(os_name "win")
# Our non-client files assume this is set, yet don't include headers that set it.
add_definitions(-DWINDOWS)
else ()
set(os_name "unix")
# Ditto.
add_definitions(-DUNIX)
if (LINUX)
add_definitions(-DLINUX)
elseif (APPLE)
add_definitions(-DMACOS)
endif ()
endif ()
# Ditto here, in particular for options.cpp.
if (X86)
if (X64)
add_definitions(-DX86_64)
else ()
add_definitions(-DX86_32)
endif ()
elseif (AARCHXX)
if (X64)
add_definitions(-DARM_64)
else ()
add_definitions(-DARM_32)
endif ()
elseif (RISCV64)
add_definitions(-DRISCV_64)
endif ()
# GCC 6+ has a warning for an ABI change due to a bug introduced in GCC 5:
# http://gcc.gnu.org/bugzilla/show_bug.cgi?id=77728. As we are building all of
# drcachesim and not linking to other C++ code, we can just ignore it.
if (ARM AND CMAKE_COMPILER_IS_GNUCC)
include(CheckCXXCompilerFlag)
CHECK_CXX_COMPILER_FLAG(-Wno-psabi GCC_HAS_NO_PSABI)
if (GCC_HAS_NO_PSABI)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-psabi")
endif (GCC_HAS_NO_PSABI)
endif ()
# i#2277: we use zlib if available to write and read compressed trace files,
# and now to write zipfiles for fast seeking.
if (ZLIB_FOUND)
add_definitions(-DHAS_ZLIB)
include_directories(${ZLIB_INCLUDE_DIRS})
set(zlib_reader reader/compressed_file_reader.cpp)
# We use minizip, supplied with zlib, to split offline traces into pieces
# inside zipfiles to support fast seeking.
set(minizip_dir "${PROJECT_SOURCE_DIR}/third_party/zlib/contrib/minizip")
if (NOT EXISTS "${minizip_dir}")
# XXX: Should we make this a fatal error, and build zlib on Windows,
# to eliminate having to support both .gz and .zip output?
# Maybe require zlib as well and stop supporting uncompressed output
# and remove HAS_ZLIB ifdefs from our code?
message(WARNING
"third_party/zlib submodule is not initialized: run 'git submodule init'; "
"until then, disabling zip output and fast seeking")
set(zip_reader "")
set(zlib_libs ${ZLIB_LIBRARIES})
set(zlib_static_libs ${ZLIB_STATIC_LIBRARIES})
set(ZIP_FOUND OFF)
else ()
file(GLOB minizip_srcs "${minizip_dir}/*.c")
if (NOT WIN32)
list(REMOVE_ITEM minizip_srcs "${minizip_dir}/iowin32.c")
endif ()
add_library(minizip STATIC ${minizip_srcs})
if (APPLE)
append_property_string(TARGET minizip
COMPILE_FLAGS "-mmacosx-version-min=${OLDEST_OSX_SUPPPORTED}")
endif ()
add_definitions(-DHAS_ZIP)
set(ZIP_FOUND ON)
# We add "minizip/" to avoid collisions with system "zip.h" on Mac.
include_directories(${minizip_dir}/..)
DR_export_target(minizip)
install_exported_target(minizip ${INSTALL_CLIENTS_LIB})
set(zip_reader reader/zipfile_file_reader.cpp)
set(zlib_libs ${ZLIB_LIBRARIES} minizip)
set(zlib_static_libs ${ZLIB_STATIC_LIBRARIES} minizip)
endif ()
else ()
# XXX: We could ship with a zlib for Windows, or build the third_party/zlib.
# Today we simply don't support compressed traces or fast seeking on Windows.
set(zlib_reader "")
set(zip_reader "")
set(zlib_libs "")
endif()
if (libsnappy)
add_definitions(-DHAS_SNAPPY)
set(snappy_reader
reader/snappy_file_reader.cpp
common/snappy_consts.cpp
common/crc32c.cpp
)
else ()
set(snappy_reader "")
endif()
if (liblz4)
add_definitions(-DHAS_LZ4)
set(lz4_reader reader/lz4_file_reader.cpp)
endif ()
set(client_and_sim_srcs
common/named_pipe_${os_name}.cpp
common/options.cpp
common/trace_entry.cpp)
# i#2006: we split our tools into libraries for combining as desired in separate
# launchers. Since they are exported in the same dir as other tools like drcov,
# we use a drmemtrace_ prefix.
macro (add_exported_library name type)
add_library(${name} ${type} ${ARGN})
DR_export_target(${name})
install_exported_target(${name} ${INSTALL_CLIENTS_LIB})
add_dependencies(${name} api_headers)
endmacro ()
add_exported_library(drmemtrace_reuse_distance STATIC tools/reuse_distance.cpp)
add_exported_library(drmemtrace_histogram STATIC tools/histogram.cpp)
add_exported_library(drmemtrace_reuse_time STATIC tools/reuse_time.cpp)
add_exported_library(drmemtrace_basic_counts STATIC tools/basic_counts.cpp)
add_exported_library(drmemtrace_opcode_mix STATIC tools/opcode_mix.cpp)
add_exported_library(drmemtrace_syscall_mix STATIC tools/syscall_mix.cpp)
add_exported_library(drmemtrace_view STATIC
tools/view.cpp tracer/raw2trace_shared.cpp)
add_exported_library(drmemtrace_func_view STATIC tools/func_view.cpp)
add_exported_library(drmemtrace_invariant_checker STATIC tools/invariant_checker.cpp)
add_exported_library(drmemtrace_schedule_stats STATIC tools/schedule_stats.cpp)
add_exported_library(drmemtrace_decode_cache STATIC
tools/common/decode_cache.cpp
# XXX: Possibly create a library for raw2trace_shared, to avoid
# multiple build overhead.
tracer/raw2trace_shared.cpp)
add_exported_library(drmemtrace_schedule_file STATIC common/schedule_file.cpp)
add_exported_library(drmemtrace_mutex_dbg_owned STATIC common/mutex_dbg_owned.cpp)
target_link_libraries(drmemtrace_invariant_checker drdecode drmemtrace_schedule_file
drmemtrace_decode_cache)
target_link_libraries(drmemtrace_decode_cache drcovlib_static)
target_link_libraries(drmemtrace_opcode_mix drmemtrace_decode_cache)
target_link_libraries(drmemtrace_view drmemtrace_decode_cache)
configure_DynamoRIO_standalone(drmemtrace_decode_cache)
configure_DynamoRIO_standalone(drmemtrace_opcode_mix)
configure_DynamoRIO_standalone(drmemtrace_view)
configure_DynamoRIO_standalone(drmemtrace_invariant_checker)
# We combine the cache and TLB simulators as they share code already.
add_exported_library(drmemtrace_simulator STATIC
simulator/simulator.cpp
simulator/cache.cpp
simulator/cache_miss_analyzer.cpp
simulator/caching_device.cpp
simulator/caching_device_stats.cpp
simulator/cache_stats.cpp
simulator/prefetcher.cpp
simulator/cache_simulator.cpp
simulator/snoop_filter.cpp
simulator/tlb.cpp
simulator/tlb_simulator.cpp
simulator/create_cache_replacement_policy.cpp
simulator/policy_bit_plru.cpp
simulator/policy_fifo.cpp
simulator/policy_lfu.cpp
simulator/policy_lru.cpp
)
add_exported_library(drmemtrace_record_filter STATIC
tools/filter/record_filter.h
tools/filter/record_filter.cpp
tools/filter/cache_filter.h
tools/filter/cache_filter.cpp
tools/filter/type_filter.h
tools/filter/encodings2regdeps_filter.h
tools/filter/func_id_filter.h
tools/filter/modify_marker_value_filter.h
tools/filter/null_filter.h)
target_link_libraries(drmemtrace_record_filter drmemtrace_simulator
drmemtrace_schedule_file)
configure_DynamoRIO_standalone(drmemtrace_record_filter)
add_exported_library(directory_iterator STATIC common/directory_iterator.cpp)
add_dependencies(directory_iterator api_headers)
target_link_libraries(directory_iterator drfrontendlib)
if (BUILD_PT_POST_PROCESSOR)
add_subdirectory(drpt2trace)
endif (BUILD_PT_POST_PROCESSOR)
set(raw2trace_srcs
tracer/raw2trace.cpp
tracer/raw2trace_shared.cpp
tracer/raw2trace_directory.cpp
tracer/instru.cpp
tracer/instru_online.cpp
tracer/instru_offline.cpp
reader/reader.cpp
common/trace_entry.cpp
reader/record_file_reader.cpp
${zlib_reader}
)
if (libsnappy)
set(raw2trace_srcs ${raw2trace_srcs}
${snappy_reader}
reader/file_reader.cpp
)
endif ()
add_exported_library(drmemtrace_raw2trace STATIC ${raw2trace_srcs})
configure_DynamoRIO_standalone(drmemtrace_raw2trace)
target_link_libraries(drmemtrace_raw2trace directory_iterator drfrontendlib
drmemtrace_schedule_file)
use_DynamoRIO_extension(drmemtrace_raw2trace drutil_static)
link_with_pthread(drmemtrace_raw2trace)
if (libsnappy)
target_link_libraries(drmemtrace_raw2trace snappy)
endif ()
if (liblz4)
target_link_libraries(drmemtrace_raw2trace lz4)
endif ()
if (BUILD_PT_POST_PROCESSOR)
add_definitions(-DBUILD_PT_POST_PROCESSOR)
target_link_libraries(drmemtrace_raw2trace drpt2ir drir2trace)
endif (BUILD_PT_POST_PROCESSOR)
set(loader_srcs
tools/loader/dynamic_lib.cpp
tools/loader/external_tool_creator.cpp
tools/loader/external_config_file.cpp)
# XXX: We should link in drmemtrace_analyzer instead of re-building its
# source files.
set(drcachesim_srcs
launcher.cpp
scheduler/scheduler.cpp
scheduler/scheduler_impl.cpp
scheduler/scheduler_dynamic.cpp
scheduler/scheduler_replay.cpp
scheduler/scheduler_fixed.cpp
scheduler/speculator.cpp
analyzer.cpp
analyzer_multi.cpp
${client_and_sim_srcs}
reader/reader.cpp
reader/config_reader.cpp
reader/v2p_reader.cpp
reader/file_reader.cpp
reader/record_file_reader.cpp
${zlib_reader}
${zip_reader}
${snappy_reader}
${lz4_reader}
reader/ipc_reader.cpp
tracer/instru.cpp
tracer/instru_online.cpp
${loader_srcs})
add_executable(drmemtrace_launcher ${drcachesim_srcs})
# In order to embed raw2trace we need to be standalone:
configure_DynamoRIO_standalone(drmemtrace_launcher)
# Link in our tools:
target_link_libraries(drmemtrace_launcher drmemtrace_simulator drmemtrace_reuse_distance
drmemtrace_histogram drmemtrace_reuse_time drmemtrace_basic_counts
drmemtrace_opcode_mix drmemtrace_syscall_mix drmemtrace_view drmemtrace_func_view
drmemtrace_raw2trace directory_iterator drmemtrace_invariant_checker
drmemtrace_schedule_stats drmemtrace_record_filter drmemtrace_mutex_dbg_owned)
if (UNIX)
target_link_libraries(drmemtrace_launcher dl)
endif ()
if (libsnappy)
target_link_libraries(drmemtrace_launcher snappy)
endif ()
# To avoid dup symbol errors between drinjectlib and drdecode on Windows we have
# to explicitly list drdecode up front:
target_link_libraries(drmemtrace_launcher drdecode drinjectlib drconfiglib drfrontendlib)
use_DynamoRIO_extension(drmemtrace_launcher droption)
# These are also for raw2trace:
use_DynamoRIO_extension(drmemtrace_launcher drcovlib_static)
use_DynamoRIO_extension(drmemtrace_launcher drutil_static)
# This is to avoid ../ and common/ in the #includes of headers that we
# export in a single dir for 3rd-party tool integration.
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/simulator)
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/common)
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/reader)
# TODO i#6412: raw2trace.h and related headers that are used only in raw2trace
# conversion are also a part of this directory. Ideally we'd like for tracer
# code to not be able to include those headers so that we can keep tracer
# separate from raw2trace. Create a separate directory for non-tracer headers
# so that we can more cleanly separate tracer and raw2trace code.
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/tracer)
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/scheduler)
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/tools/common)
include_directories(${CMAKE_CURRENT_SOURCE_DIR})
if (BUILD_PT_POST_PROCESSOR)
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/drpt2trace)
endif (BUILD_PT_POST_PROCESSOR)
add_exported_library(drmemtrace_analyzer STATIC
analyzer.cpp
scheduler/scheduler.cpp
scheduler/scheduler_impl.cpp
scheduler/scheduler_dynamic.cpp
scheduler/scheduler_replay.cpp
scheduler/scheduler_fixed.cpp
scheduler/speculator.cpp
common/trace_entry.cpp
reader/reader.cpp
reader/config_reader.cpp
reader/v2p_reader.cpp
reader/file_reader.cpp
reader/record_file_reader.cpp
${zlib_reader}
${zip_reader}
${snappy_reader}
${lz4_reader}
)
target_link_libraries(drmemtrace_analyzer directory_iterator drmemtrace_mutex_dbg_owned)
if (libsnappy)
target_link_libraries(drmemtrace_analyzer snappy)
endif ()
if (liblz4)
target_link_libraries(drmemtrace_analyzer lz4)
endif ()
link_with_pthread(drmemtrace_analyzer)
# We get away w/ exporting the generically-named "utils.h" by putting into a
# drmemtrace/ subdir.
install_client_nonDR_header(drmemtrace common/utils.h)
install_client_nonDR_header(drmemtrace common/trace_entry.h)
install_client_nonDR_header(drmemtrace common/memref.h)
install_client_nonDR_header(drmemtrace common/memtrace_stream.h)
install_client_nonDR_header(drmemtrace common/archive_istream.h)
install_client_nonDR_header(drmemtrace common/archive_ostream.h)
install_client_nonDR_header(drmemtrace common/mutex_dbg_owned.h)
install_client_nonDR_header(drmemtrace reader/reader.h)
install_client_nonDR_header(drmemtrace reader/record_file_reader.h)
install_client_nonDR_header(drmemtrace analysis_tool.h)
install_client_nonDR_header(drmemtrace analyzer.h)
install_client_nonDR_header(drmemtrace tools/common/decode_cache.h)
install_client_nonDR_header(drmemtrace tools/reuse_distance_create.h)
install_client_nonDR_header(drmemtrace tools/histogram_create.h)
install_client_nonDR_header(drmemtrace tools/reuse_time_create.h)
install_client_nonDR_header(drmemtrace tools/basic_counts_create.h)
install_client_nonDR_header(drmemtrace tools/opcode_mix_create.h)
install_client_nonDR_header(drmemtrace tools/schedule_stats_create.h)
install_client_nonDR_header(drmemtrace tools/syscall_mix_create.h)
install_client_nonDR_header(drmemtrace simulator/cache_simulator.h)
install_client_nonDR_header(drmemtrace simulator/cache_simulator_create.h)
install_client_nonDR_header(drmemtrace simulator/tlb_simulator_create.h)
install_client_nonDR_header(drmemtrace tools/view_create.h)
install_client_nonDR_header(drmemtrace tools/func_view_create.h)
install_client_nonDR_header(drmemtrace tools/filter/record_filter_create.h)
install_client_nonDR_header(drmemtrace tools/filter/record_filter.h)
# TODO i#6412: Create a separate directory for non-tracer headers so that
# we can more cleanly separate tracer and raw2trace code.
install_client_nonDR_header(drmemtrace tracer/raw2trace.h)
install_client_nonDR_header(drmemtrace tracer/raw2trace_shared.h)
install_client_nonDR_header(drmemtrace scheduler/scheduler.h)
install_client_nonDR_header(drmemtrace scheduler/flexible_queue.h)
install_client_nonDR_header(drmemtrace scheduler/speculator.h)
add_library(test_helpers STATIC tests/test_helpers.cpp)
# We show one example of how to create a standalone analyzer of trace
# files that does not need to link with DR.
add_executable(histogram_launcher
tools/histogram_launcher.cpp
)
configure_DynamoRIO_standalone(histogram_launcher)
target_link_libraries(histogram_launcher drmemtrace_analyzer drmemtrace_histogram
drfrontendlib drmemtrace_invariant_checker)
use_DynamoRIO_extension(histogram_launcher droption)
add_dependencies(histogram_launcher api_headers)
add_executable(prefetch_analyzer_launcher
tests/prefetch_analyzer_launcher.cpp
tests/prefetch_analyzer.cpp
tests/test_helpers.cpp
)
target_link_libraries(prefetch_analyzer_launcher drmemtrace_analyzer drfrontendlib)
append_property_list(TARGET prefetch_analyzer_launcher
COMPILE_DEFINITIONS "NO_HELPER_MAIN")
use_DynamoRIO_extension(prefetch_analyzer_launcher droption)
add_dependencies(prefetch_analyzer_launcher api_headers)
add_executable(record_filter_launcher
tools/record_filter_launcher.cpp
tests/test_helpers.cpp)
target_link_libraries(record_filter_launcher drmemtrace_analyzer drmemtrace_record_filter)
add_dependencies(record_filter_launcher api_headers)
append_property_list(TARGET record_filter_launcher COMPILE_DEFINITIONS "NO_HELPER_MAIN")
use_DynamoRIO_extension(record_filter_launcher droption)
if (NOT APPLE)
configure_DynamoRIO_static(record_filter_launcher)
endif()
# We want to use test_helper's disable_popups() but we have _tmain and so do not want
# the test_helper library's main symbol: so we compile ourselves and disable.
add_executable(scheduler_launcher tests/scheduler_launcher.cpp tests/test_helpers.cpp)
append_property_list(TARGET scheduler_launcher COMPILE_DEFINITIONS "NO_HELPER_MAIN")
target_link_libraries(scheduler_launcher drmemtrace_analyzer drfrontendlib)
use_DynamoRIO_extension(scheduler_launcher droption)
add_dependencies(scheduler_launcher api_headers)
# Simple test to ensure this launcher keeps working.
if (X86 AND X64 AND ZIP_FOUND)
set(trace_dir
"${PROJECT_SOURCE_DIR}/clients/drcachesim/tests/drmemtrace.threadsig.x64.tracedir")
add_test(NAME tool.scheduler_launcher
COMMAND scheduler_launcher -trace_dir ${trace_dir})
set_tests_properties(tool.scheduler_launcher PROPERTIES TIMEOUT ${test_seconds})
endif ()
# We have a companion test built using a separate --build-and-test CMake project in
# tests/analyzer_separate.cpp to better test 3rd-party usage.
set_property(GLOBAL PROPERTY DynamoRIO_drmemtrace_src_dir
"${CMAKE_CURRENT_SOURCE_DIR}/tests")
set_property(GLOBAL PROPERTY DynamoRIO_drmemtrace_build_dir
"${CMAKE_CURRENT_BINARY_DIR}/tests")
# We have one more example of a standalone launcher that uses raw2trace to catch
# link errors (xref i#1409). We just build it to test the linking; no test.
# XXX i#1997: static DR is not fully supported on Mac yet.
if (NOT APPLE)
add_executable(opcode_mix_launcher
tools/opcode_mix_launcher.cpp
)
# We hit dup symbol errors on Windows so we need libc earlier before DR:
_DR_get_static_libc_list(static_libc)
target_link_libraries(opcode_mix_launcher drmemtrace_analyzer drmemtrace_opcode_mix
drmemtrace_raw2trace drcovlib_static drfrontendlib ${static_libc})
use_DynamoRIO_extension(opcode_mix_launcher droption)
add_dependencies(opcode_mix_launcher api_headers)
configure_DynamoRIO_static(opcode_mix_launcher)
endif ()
target_link_libraries(drmemtrace_launcher ${zlib_libs})
target_link_libraries(histogram_launcher ${zlib_libs})
target_link_libraries(prefetch_analyzer_launcher ${zlib_libs})
target_link_libraries(drmemtrace_raw2trace ${zlib_libs})
target_link_libraries(drmemtrace_analyzer ${zlib_libs})
if (NOT AARCH64 AND NOT APPLE)
target_link_libraries(opcode_mix_launcher ${zlib_libs})
endif ()
target_link_libraries(scheduler_launcher ${zlib_libs})
macro(add_drmemtrace name type static_DR no_main)
if (${type} STREQUAL "STATIC")
if (${static_DR})
set(ext_sfx "_drstatic")
else ()
set(ext_sfx "_static")
endif ()
else ()
set(ext_sfx "")
endif ()
set(drmemtrace_srcs
tracer/tracer.cpp
tracer/instr_counter.cpp
tracer/output.cpp
tracer/instru.cpp
tracer/instru_offline.cpp
tracer/instru_online.cpp
tracer/physaddr.cpp
tracer/func_trace.cpp
tracer/raw2trace_shared.cpp
${client_and_sim_srcs}
)
if (BUILD_PT_TRACER)
set(drmemtrace_srcs ${drmemtrace_srcs}
tracer/syscall_pt_trace.cpp
tracer/kcore_copy.cpp
)
add_definitions(-DBUILD_PT_TRACER)
endif ()
if (libsnappy)
set(drmemtrace_srcs ${drmemtrace_srcs}
tracer/snappy_file_writer.cpp
common/snappy_consts.cpp
common/crc32c.cpp
)
endif ()
# i#6412: All implementation shared between the tracer and raw2trace should
# be in the separate raw2trace_shared files. This is so we can keep the
# tracer library smaller. The following is a non-exhaustive condition that
# flags when raw2trace implementation is accidentally added. Including
# raw2trace.cpp would necessitate inclusion of various other implementations
# (like for the trace reader_t), which should all be avoided here.
list (FIND drmemtrace_srcs "tracer/raw2trace.cpp" _raw2trace_index)
if (${_raw2trace_index} GREATER -1)
message(FATAL_ERROR
"drmemtrace should use raw2trace_shared for shared implementation.")
endif()
add_library(${name} ${type} ${drmemtrace_srcs})
if (${no_main})
append_property_list(TARGET ${name} COMPILE_DEFINITIONS "DRMEMTRACE_NO_MAIN")
endif ()
if (${static_DR})
configure_DynamoRIO_static_client(${name})
else ()
configure_DynamoRIO_client(${name})
endif()
use_DynamoRIO_extension(${name} drmgr${ext_sfx})
use_DynamoRIO_extension(${name} drsyms${ext_sfx})
use_DynamoRIO_extension(${name} drwrap${ext_sfx})
use_DynamoRIO_extension(${name} drreg${ext_sfx})
use_DynamoRIO_extension(${name} drutil${ext_sfx})
use_DynamoRIO_extension(${name} drstatecmp${ext_sfx})
use_DynamoRIO_extension(${name} drx${ext_sfx})
use_DynamoRIO_extension(${name} droption)
use_DynamoRIO_extension(${name} drcovlib${ext_sfx})
use_DynamoRIO_extension(${name} drbbdup${ext_sfx})
if (BUILD_PT_TRACER)
use_DynamoRIO_extension(${name} drpttracer${ext_sfx})
endif ()
if (libsnappy)
target_link_libraries(${name} snappy)
endif ()
if (${static_DR})
target_link_libraries(${name} ${zlib_static_libs})
else ()
target_link_libraries(${name} ${zlib_libs})
endif ()
if (liblz4)
target_link_libraries(${name} lz4)
endif ()
if (libxxhash)
target_link_libraries(${name} xxhash)
endif ()
if (RISCV64)
target_link_libraries(${name} atomic)
endif ()
add_dependencies(${name} api_headers)
install_target(${name} ${INSTALL_CLIENTS_LIB})
endmacro()
add_drmemtrace(drmemtrace SHARED OFF OFF)
# This static library links with the DR shared library and has dr_client_main:
add_drmemtrace(drmemtrace_static STATIC OFF OFF)
# This static library links with the DR shared library and has no dr_client_main:
add_drmemtrace(drmemtrace_nomain STATIC OFF ON)
# This static library links with the DR static library and has dr_client_main:
add_drmemtrace(drmemtrace_drstatic STATIC ON OFF)
append_property_list(TARGET drmemtrace_static COMPILE_DEFINITIONS "DRMEMTRACE_STATIC")
# We export drmemtrace.h to the same place as the analysis tool headers
# for simplicity, rather than sticking it into ext/include or sthg.
install_client_nonDR_header(drmemtrace tracer/drmemtrace.h)
add_executable(drraw2trace
tracer/raw2trace_launcher.cpp
tracer/instru.cpp
tracer/instru_online.cpp
)
target_link_libraries(drraw2trace drmemtrace_raw2trace)
# To avoid dup symbol errors on some VS builds we list drdecode before DR:
target_link_libraries(drraw2trace drdecode)
configure_DynamoRIO_standalone(drraw2trace)
target_link_libraries(drraw2trace drfrontendlib)
use_DynamoRIO_extension(drraw2trace droption)
use_DynamoRIO_extension(drraw2trace drcovlib_static)
# Because we're leveraging instru_online code we have to link with drutil:
use_DynamoRIO_extension(drraw2trace drutil_static)
# We add a useful warning that's not in Wall.
CHECK_C_COMPILER_FLAG("-Wimplicit-fallthrough" implicit_fallthrough_avail)
macro(restore_nonclient_flags target)
# Restore debug and other flags to our non-client executables
set_target_properties(${target} PROPERTIES
COMPILE_FLAGS "${ORIG_CMAKE_CXX_FLAGS}")
if (NOT DEBUG)
append_property_list(TARGET ${target} COMPILE_DEFINITIONS "NDEBUG")
endif ()
# However, we need the target os and arch defines (XXX: better way?) for
# the config, inject, and frontend headers:
DynamoRIO_extra_defines(extra_defs ON)
append_property_list(TARGET ${target} COMPILE_DEFINITIONS "${extra_defs}")
if (implicit_fallthrough_avail)
append_property_string(TARGET ${target} COMPILE_FLAGS "-Wimplicit-fallthrough")
endif ()
endmacro()
restore_nonclient_flags(drmemtrace_launcher)
restore_nonclient_flags(drraw2trace)
restore_nonclient_flags(histogram_launcher)
restore_nonclient_flags(record_filter_launcher)
restore_nonclient_flags(prefetch_analyzer_launcher)
if (NOT AARCH64 AND NOT APPLE)
restore_nonclient_flags(opcode_mix_launcher)
endif ()
restore_nonclient_flags(scheduler_launcher)
restore_nonclient_flags(drmemtrace_simulator)
restore_nonclient_flags(drmemtrace_reuse_distance)
restore_nonclient_flags(drmemtrace_histogram)
restore_nonclient_flags(drmemtrace_reuse_time)
restore_nonclient_flags(drmemtrace_basic_counts)
restore_nonclient_flags(drmemtrace_opcode_mix)
restore_nonclient_flags(drmemtrace_syscall_mix)
restore_nonclient_flags(drmemtrace_view)
restore_nonclient_flags(drmemtrace_func_view)
restore_nonclient_flags(drmemtrace_record_filter)
restore_nonclient_flags(drmemtrace_analyzer)
restore_nonclient_flags(drmemtrace_invariant_checker)
restore_nonclient_flags(drmemtrace_schedule_stats)
restore_nonclient_flags(drmemtrace_schedule_file)
restore_nonclient_flags(drmemtrace_decode_cache)
# We need to pass /EHsc and we pull in libcmtd into drcachesim from a dep lib.
# Thus we need to override the /MT with /MTd.
#
# TODO i#6040: We should add a new configure_original_flage(target) function
# which restores the ORIG_ flags at the source level for all other targets
# in this file which are neither clients nor use DR standalone. We can then
# get rid of add_win32_flags(target) since that just adds a couple of flags
# back, and using the ORIG_ values is preferable.
macro(add_win32_flags target)
if (DEBUG AND NOT DEFINED ${target}_uses_configure)
append_property_list(TARGET ${target} COMPILE_DEFINITIONS "DEBUG")
endif ()
if (NOT DEBUG)
get_property(cur TARGET ${target} PROPERTY COMPILE_DEFINITIONS)
if (NOT "${cur}" MATCHES "NDEBUG")
append_property_list(TARGET ${target} COMPILE_DEFINITIONS "NDEBUG")
endif ()
endif ()
if (WIN32)
if (DEBUG)
get_property(cur TARGET ${target} PROPERTY COMPILE_FLAGS)
string(REPLACE "/MT " "" cur "${cur}") # Avoid override warning.
set_target_properties(${target} PROPERTIES COMPILE_FLAGS "${cur} /EHsc /MTd /Zi")
append_property_string(TARGET ${target} LINK_FLAGS "/nodefaultlib:libcmt")
else ()
append_property_string(TARGET ${target} COMPILE_FLAGS "/EHsc /MT")
endif ()
else ()
# Work around configure_DynamoRIO_static() clobbering flags by re-adding
# the important ones for our tests, so they can include our headers
# with C++11-isms.
get_property(cur TARGET ${target} PROPERTY COMPILE_FLAGS)
if (NOT cur MATCHES "-std=")
append_property_string(TARGET ${target} COMPILE_FLAGS "-std=c++11")
endif ()
if (DEBUG AND NOT cur MATCHES "-g")
# We can't use restore_nonclient_flags() for clients, so we manually re-add debug
# here.
append_property_string(TARGET ${target} COMPILE_FLAGS "-g")
endif ()
if (APPLE)
# Match the core/ flags.
append_property_string(TARGET ${target}
COMPILE_FLAGS "-mmacosx-version-min=${OLDEST_OSX_SUPPPORTED}")
endif ()
endif ()
endmacro ()
add_win32_flags(drmemtrace_launcher)
add_win32_flags(drraw2trace)
add_win32_flags(histogram_launcher)
add_win32_flags(record_filter_launcher)
add_win32_flags(prefetch_analyzer_launcher)
add_win32_flags(drmemtrace_raw2trace)
if (NOT AARCH64 AND NOT APPLE)
add_win32_flags(opcode_mix_launcher)
endif ()
add_win32_flags(scheduler_launcher)
add_win32_flags(drmemtrace_simulator)
add_win32_flags(drmemtrace_reuse_distance)
add_win32_flags(drmemtrace_histogram)
add_win32_flags(drmemtrace_reuse_time)
add_win32_flags(drmemtrace_basic_counts)
add_win32_flags(drmemtrace_opcode_mix)
add_win32_flags(drmemtrace_syscall_mix)
add_win32_flags(drmemtrace_view)
add_win32_flags(drmemtrace_func_view)
add_win32_flags(drmemtrace_record_filter)
add_win32_flags(drmemtrace_analyzer)
add_win32_flags(drmemtrace_invariant_checker)
add_win32_flags(drmemtrace_schedule_stats)
add_win32_flags(drmemtrace_schedule_file)
add_win32_flags(drmemtrace_decode_cache)
add_win32_flags(directory_iterator)
add_win32_flags(test_helpers)
add_win32_flags(drmemtrace_mutex_dbg_owned)
if (WIN32 AND DEBUG)
get_target_property(sim_srcs drmemtrace_launcher SOURCES)
get_target_property(raw2trace_srcs drraw2trace SOURCES)
# The client, and our standalone DR users, had /MT added so we need to override.
# XXX: solve this by avoiding the /MT in the first place!
foreach (src ${client_and_sim_srcs} ${sim_srcs} ${raw2trace_srcs} tools/opcode_mix.cpp tools/view.cpp)
get_property(cur SOURCE ${src} PROPERTY COMPILE_FLAGS)
string(REPLACE "/MT " "" cur ${cur}) # Avoid override warning.
set_source_files_properties(${src} COMPILE_FLAGS "${cur} /MTd")
endforeach ()
endif ()
place_shared_lib_in_lib_dir(drmemtrace)
add_dependencies(drmemtrace_launcher api_headers)
# Provide a hint for how to use the client
if (NOT DynamoRIO_INTERNAL OR NOT "${CMAKE_GENERATOR}" MATCHES "Ninja")
add_custom_command(TARGET drmemtrace
POST_BUILD
COMMAND ${CMAKE_COMMAND}
ARGS -E echo "Usage: pass to drconfig or drrun: -t drmemtrace"
VERBATIM)
endif ()
install_target(drmemtrace_launcher ${INSTALL_CLIENTS_BIN})
install_target(drraw2trace ${INSTALL_CLIENTS_BIN})
set(INSTALL_DRCACHESIM_CONFIG ${INSTALL_CLIENTS_BASE})
function (write_config_file dst bindir libdir)
# We include the alternate-bitwidth path, though it won't be there for
# a single build dir and such a child will have a fatal error.
if (X64)
string(REPLACE "lib64" "lib32" alt_libdir ${libdir})
set(CUR_BIT "64")
set(ALT_BIT "32")
else ()
set(CUR_BIT "32")
set(ALT_BIT "64")
string(REPLACE "lib64" "lib32" alt_libdir ${libdir})
endif ()
if (DEBUG)
set(debugopt "TOOL_OP=-dr_debug")
else ()
set(debugopt "")
endif ()
file(GENERATE OUTPUT ${dst} CONTENT
"# drmemtrace tracing and analysis tool config file.\n\
FRONTEND_REL=${bindir}/$<TARGET_FILE_NAME:drmemtrace_launcher>\n\
TOOL_OP=-dr\n\
TOOL_OP_DR_PATH\n\
TOOL_OP_DR_BUNDLE=-dr_ops\n\
TOOL_OP=-tracer\n\
CLIENT${CUR_BIT}_REL=${libdir}/${LIB_PFX}drmemtrace${LIB_EXT}\n\
TOOL_OP=-tracer_alt\n\
CLIENT${ALT_BIT}_REL=${alt_libdir}/${LIB_PFX}drmemtrace${LIB_EXT}\n\
${debugopt}\n")
endfunction ()
if (X64)
set(CONFIG_INSTALL ${PROJECT_BINARY_DIR}/drmemtrace.drrun64)
set(CONFIG_BUILD ${PROJECT_BINARY_DIR}/tools/drmemtrace.drrun64)
# Support the older launcher name (i#6660 applied s/drcachesim/drmemtrace/ as
# "drcachesim" is just one tool and we use "drmemtrace" to refer to the framework).
set(CONFIG_OLD_INSTALL ${PROJECT_BINARY_DIR}/drcachesim.drrun64)
set(CONFIG_OLD_BUILD ${PROJECT_BINARY_DIR}/tools/drcachesim.drrun64)
else (X64)
set(CONFIG_INSTALL ${PROJECT_BINARY_DIR}/drmemtrace.drrun32)
set(CONFIG_BUILD ${PROJECT_BINARY_DIR}/tools/drmemtrace.drrun32)
set(CONFIG_OLD_INSTALL ${PROJECT_BINARY_DIR}/drcachesim.drrun32)
set(CONFIG_OLD_BUILD ${PROJECT_BINARY_DIR}/tools/drcachesim.drrun32)
endif (X64)
set(BUILD_CLIENTS_BIN clients/${INSTALL_BIN})
set(BUILD_CLIENTS_LIB clients/${INSTALL_LIB})
write_config_file(${CONFIG_INSTALL} ${INSTALL_CLIENTS_BIN} ${INSTALL_CLIENTS_LIB})
write_config_file(${CONFIG_BUILD} ${BUILD_CLIENTS_BIN} ${BUILD_CLIENTS_LIB})
# Support the older launcher name (i#6660 renamed it).
write_config_file(${CONFIG_OLD_INSTALL} ${INSTALL_CLIENTS_BIN} ${INSTALL_CLIENTS_LIB})
write_config_file(${CONFIG_OLD_BUILD} ${BUILD_CLIENTS_BIN} ${BUILD_CLIENTS_LIB})
DR_install(FILES "${CONFIG_INSTALL}" DESTINATION ${INSTALL_DRCACHESIM_CONFIG})
register_tool_file("drmemtrace")
# Support the older launcher name (i#6660 renamed it).
DR_install(FILES "${CONFIG_OLD_INSTALL}" DESTINATION ${INSTALL_DRCACHESIM_CONFIG})
register_tool_file("drcachesim")
if (WIN32)
# drcachesim needs these dlls (i#1737 would eliminate this)
DynamoRIO_get_full_path(injectlib_loc drinjectlib "${location_suffix}")
DR_install(FILES "${injectlib_loc}" DESTINATION "${INSTALL_CLIENTS_BIN}")
DynamoRIO_get_full_path(configlib_loc drconfiglib "${location_suffix}")
DR_install(FILES "${configlib_loc}" DESTINATION "${INSTALL_CLIENTS_BIN}")
DynamoRIO_get_full_path(drlib_loc dynamorio "${location_suffix}")
DR_install(FILES "${drlib_loc}" DESTINATION "${INSTALL_CLIENTS_BIN}")
add_custom_command(TARGET drmemtrace_launcher POST_BUILD
COMMAND ${CMAKE_COMMAND} ARGS -E copy ${DR_LIBRARY_BASE_DIRECTORY}/drinjectlib.dll
${PROJECT_BINARY_DIR}/${BUILD_CLIENTS_BIN}/drinjectlib.dll VERBATIM)
add_custom_command(TARGET drmemtrace_launcher POST_BUILD
COMMAND ${CMAKE_COMMAND} ARGS -E copy ${DR_LIBRARY_BASE_DIRECTORY}/drconfiglib.dll
${PROJECT_BINARY_DIR}/${BUILD_CLIENTS_BIN}/drconfiglib.dll VERBATIM)
# Avoid dueling racy copies (i#4668).
add_dependencies(drmemtrace_launcher client_dr_copy)
endif ()
add_subdirectory(tools/external)
##################################################
# Test executables
#
# We build larger executables here. All tests are added in suite/tests/ except unit tests.
# Be sure to give the targets qualified test names ("tool.drcache*...").
# XXX: Try to add a macro add_drcachesim_test() to share common pieces
# of these executables.
if (BUILD_TESTS)
add_executable(tool.reuse_distance.unit_tests tests/reuse_distance_test.cpp)
target_link_libraries(tool.reuse_distance.unit_tests drmemtrace_reuse_distance
drmemtrace_static test_helpers)
add_win32_flags(tool.reuse_distance.unit_tests)
add_test(NAME tool.reuse_distance.unit_tests
COMMAND tool.reuse_distance.unit_tests)
set_tests_properties(tool.reuse_distance.unit_tests PROPERTIES TIMEOUT ${test_seconds})
add_executable(tool.drcachesim.unit_tests tests/drcachesim_unit_tests.cpp
tests/cache_replacement_policy_unit_test.cpp tests/config_reader_unit_test.cpp
tests/v2p_reader_unit_test.cpp tests/tlb_simulator_unit_test.cpp)
target_link_libraries(tool.drcachesim.unit_tests drmemtrace_simulator
# Link test_helpers first, or else the zlib main takes over.
drmemtrace_static drmemtrace_analyzer test_helpers ${zlib_libs})
add_win32_flags(tool.drcachesim.unit_tests)
add_test(NAME tool.drcachesim.unit_tests
COMMAND tool.drcachesim.unit_tests
${PROJECT_SOURCE_DIR}/clients/drcachesim/tests)
set_tests_properties(tool.drcachesim.unit_tests PROPERTIES TIMEOUT ${test_seconds})
# FIXME i#3544 Make raw2trace_unit_tests compilable in RISCV64.
if (NOT RISCV64)
add_executable(tool.drcacheoff.raw2trace_unit_tests tests/raw2trace_unit_tests.cpp)
configure_DynamoRIO_standalone(tool.drcacheoff.raw2trace_unit_tests)
add_win32_flags(tool.drcacheoff.raw2trace_unit_tests)
target_link_libraries(tool.drcacheoff.raw2trace_unit_tests drmemtrace_raw2trace
test_helpers)
use_DynamoRIO_extension(tool.drcacheoff.raw2trace_unit_tests drdecode)
use_DynamoRIO_extension(tool.drcacheoff.raw2trace_unit_tests drcovlib_static)
add_test(NAME tool.drcacheoff.raw2trace_unit_tests
COMMAND tool.drcacheoff.raw2trace_unit_tests)
set_tests_properties(tool.drcacheoff.raw2trace_unit_tests PROPERTIES TIMEOUT
${test_seconds})
endif ()
add_executable(tool.scheduler.unit_tests tests/scheduler_unit_tests.cpp)
target_link_libraries(tool.scheduler.unit_tests drmemtrace_analyzer test_helpers)
if (WIN32)
# We have a dup symbol from linking in DR. Linking libc first doesn't help.
append_property_string(TARGET tool.scheduler.unit_tests LINK_FLAGS
"/force:multiple")
endif ()
configure_DynamoRIO_standalone(tool.scheduler.unit_tests)
add_win32_flags(tool.scheduler.unit_tests)
add_test(NAME tool.scheduler.unit_tests
COMMAND tool.scheduler.unit_tests
${PROJECT_SOURCE_DIR}/clients/drcachesim/tests)
set_tests_properties(tool.scheduler.unit_tests PROPERTIES TIMEOUT ${test_seconds})
add_executable(tool.drcacheoff.flexible_queue_tests tests/flexible_queue_tests.cpp)
add_win32_flags(tool.drcacheoff.flexible_queue_tests)
target_link_libraries(tool.drcacheoff.flexible_queue_tests test_helpers)
add_test(NAME tool.drcacheoff.flexible_queue_tests
COMMAND tool.drcacheoff.flexible_queue_tests)
set_tests_properties(tool.drcacheoff.flexible_queue_tests PROPERTIES TIMEOUT
${test_seconds})
add_executable(tool.drcachesim.core_sharded tests/core_sharded_test.cpp
# XXX: Better to put these into libraries but that requires a bigger cleanup:
analyzer_multi.cpp ${client_and_sim_srcs} reader/ipc_reader.cpp
${loader_srcs})
target_link_libraries(tool.drcachesim.core_sharded test_helpers
drmemtrace_raw2trace drmemtrace_simulator drmemtrace_reuse_distance
drmemtrace_histogram drmemtrace_reuse_time drmemtrace_basic_counts
drmemtrace_opcode_mix drmemtrace_syscall_mix drmemtrace_view drmemtrace_func_view
drmemtrace_raw2trace directory_iterator drmemtrace_invariant_checker
drmemtrace_schedule_stats drmemtrace_analyzer drmemtrace_record_filter)
if (UNIX)
target_link_libraries(tool.drcachesim.core_sharded dl)
endif ()
add_win32_flags(tool.drcachesim.core_sharded)
if (WIN32)
# We have a dup symbol from linking in DR. Linking libc first doesn't help.
append_property_string(TARGET tool.drcachesim.core_sharded LINK_FLAGS
"/force:multiple")
endif ()
configure_DynamoRIO_standalone(tool.drcachesim.core_sharded)
use_DynamoRIO_extension(tool.drcachesim.core_sharded droption)
use_DynamoRIO_extension(tool.drcachesim.core_sharded drreg_static)
use_DynamoRIO_extension(tool.drcachesim.core_sharded drcovlib_static)
use_DynamoRIO_extension(tool.drcachesim.core_sharded drutil_static)
add_test(NAME tool.drcachesim.core_sharded
COMMAND tool.drcachesim.core_sharded
${PROJECT_SOURCE_DIR}/clients/drcachesim/tests)
set_tests_properties(tool.drcachesim.core_sharded PROPERTIES TIMEOUT ${test_seconds})
# XXX i#5675: add tests for other environments. Currently, the repository does not have
# a checked-in post-processed trace for x86-32 or AArchXX. We are also limited to
# the old format due to missing zip support so we can't use the new threadsig.x64.
if (X86 AND X64 AND ZLIB_FOUND)
set(trace_dir
"${PROJECT_SOURCE_DIR}/clients/drcachesim/tests/drmemtrace.legacy-for-record-filter.x64.tracedir")
set(tmp_output_dir ${PROJECT_BINARY_DIR}/record_filter_tests_tmp_output)
file(MAKE_DIRECTORY ${tmp_output_dir})
add_executable(tool.drcacheoff.record_filter_unit_tests
tests/record_filter_unit_tests.cpp)
configure_DynamoRIO_standalone(tool.drcacheoff.record_filter_unit_tests)
add_win32_flags(tool.drcacheoff.record_filter_unit_tests)
target_link_libraries(tool.drcacheoff.record_filter_unit_tests drmemtrace_analyzer
drmemtrace_basic_counts drmemtrace_record_filter test_helpers)
add_test(NAME tool.drcacheoff.record_filter_unit_tests
COMMAND tool.drcacheoff.record_filter_unit_tests --trace_dir
${trace_dir} --tmp_output_dir ${tmp_output_dir})
set_tests_properties(tool.drcacheoff.record_filter_unit_tests PROPERTIES TIMEOUT
${test_seconds})
endif ()
add_executable(tool.drcacheoff.trace_interval_analysis_unit_tests
tests/trace_interval_analysis_unit_tests.cpp)
add_win32_flags(tool.drcacheoff.trace_interval_analysis_unit_tests)
target_link_libraries(tool.drcacheoff.trace_interval_analysis_unit_tests
drmemtrace_analyzer drdecode test_helpers)
add_test(NAME tool.drcacheoff.trace_interval_analysis_unit_tests
COMMAND tool.drcacheoff.trace_interval_analysis_unit_tests)
set_tests_properties(tool.drcacheoff.trace_interval_analysis_unit_tests PROPERTIES
TIMEOUT ${test_seconds})
add_executable(tool.drcacheoff.analysis_unit_tests tests/analysis_unit_tests.cpp)
add_win32_flags(tool.drcacheoff.analysis_unit_tests)
target_link_libraries(tool.drcacheoff.analysis_unit_tests
drmemtrace_analyzer test_helpers)
add_test(NAME tool.drcacheoff.analysis_unit_tests
COMMAND tool.drcacheoff.analysis_unit_tests)
set_tests_properties(tool.drcacheoff.analysis_unit_tests PROPERTIES
TIMEOUT ${test_seconds})
if (DR_HOST_AARCH64 AND NOT APPLE) # i#1997: static DR on Mac NYI.
add_executable(tool.drcacheoff.burst_aarch64_sys tests/burst_aarch64_sys.cpp)
configure_DynamoRIO_static(tool.drcacheoff.burst_aarch64_sys)
use_DynamoRIO_static_client(tool.drcacheoff.burst_aarch64_sys drmemtrace_static)
target_link_libraries(tool.drcacheoff.burst_aarch64_sys drmemtrace_raw2trace
drmemtrace_analyzer test_helpers)
use_DynamoRIO_drmemtrace_tracer(tool.drcacheoff.burst_aarch64_sys)
add_win32_flags(tool.drcacheoff.burst_aarch64_sys)
endif ()
add_executable(tool.drcachesim.decode_cache_test tests/decode_cache_test.cpp)
configure_DynamoRIO_standalone(tool.drcachesim.decode_cache_test)
add_win32_flags(tool.drcachesim.decode_cache_test)
target_link_libraries(tool.drcachesim.decode_cache_test
drmemtrace_decode_cache test_helpers)
add_test(NAME tool.drcachesim.decode_cache_test
COMMAND tool.drcachesim.decode_cache_test)
set_tests_properties(tool.drcachesim.decode_cache_test PROPERTIES
TIMEOUT ${test_seconds})
add_executable(tool.drcacheoff.opcode_mix_test tests/opcode_mix_test.cpp)
configure_DynamoRIO_standalone(tool.drcacheoff.opcode_mix_test)
add_win32_flags(tool.drcacheoff.opcode_mix_test)
target_link_libraries(tool.drcacheoff.opcode_mix_test
drmemtrace_opcode_mix drmemtrace_decode_cache test_helpers)