Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
77 commits
Select commit Hold shift + click to select a range
fca712e
i#7113: Add library to cache information about decoded instructions
abhinav92003 Dec 9, 2024
abebffc
Docx improvement, and handle regdeps branch_target case.
abhinav92003 Dec 9, 2024
18f7028
Use instr_noalloc_t where possible.
abhinav92003 Dec 10, 2024
4487168
Remove redundant test.
abhinav92003 Dec 10, 2024
41595eb
move impl to cpp
abhinav92003 Dec 10, 2024
d2e94c7
Move impl to cpp
abhinav92003 Dec 10, 2024
f0f8a74
Cleanup and aarch64 mov fix.
abhinav92003 Dec 10, 2024
a1b1d63
Fix windows bug
abhinav92003 Dec 10, 2024
db8a3ad
Reviewer suggested changes
abhinav92003 Dec 10, 2024
1e810b5
Cleanup
abhinav92003 Dec 10, 2024
1fc4c04
Merge branch 'master' into i7113-decode-cache-lib
abhinav92003 Dec 14, 2024
bf76f70
Merge branch 'master' into i7113-decode-cache-lib
abhinav92003 Dec 15, 2024
45e062f
Add instr_decode_cache_t support to opcode_mix; add module_mapper_t s…
abhinav92003 Dec 15, 2024
5e28112
Drop instr_ from instr_decode_cache
abhinav92003 Dec 15, 2024
0a33a51
Handle missing use_module_mapper case
abhinav92003 Dec 15, 2024
29d10a3
Fix clang-format
abhinav92003 Dec 15, 2024
0e2df67
Make add_decode_info simpler and fix build error
abhinav92003 Dec 15, 2024
716a0ea
Cleanup
abhinav92003 Dec 15, 2024
fefe38b
Proactive destruction of module mapper
abhinav92003 Dec 16, 2024
2f0a708
Remove stale file
abhinav92003 Dec 16, 2024
84a2039
Move impl to cpp
abhinav92003 Dec 16, 2024
141e3c5
Fix when we use module mapper in opcode mix
abhinav92003 Dec 16, 2024
1092a21
Revert view deps
abhinav92003 Dec 16, 2024
b2ba91c
Use filetype instead of encoding_is_new
abhinav92003 Dec 16, 2024
d70e227
Cleanup
abhinav92003 Dec 16, 2024
d51d823
Add tmate to windows test
abhinav92003 Dec 16, 2024
0000c5b
Remove test filter
abhinav92003 Dec 16, 2024
3737ec5
Add missing standalone_init
abhinav92003 Dec 16, 2024
652bab0
Add tmate again
abhinav92003 Dec 16, 2024
1177304
Remove drmemtrace_static from test deps
abhinav92003 Dec 16, 2024
96efb50
Keep obj count tracking for tests
abhinav92003 Dec 16, 2024
31e1eab
Keep only one bool for use_module_mapper
abhinav92003 Dec 16, 2024
3702f29
Convert to doc comment
abhinav92003 Dec 16, 2024
d7a4d10
Add tmate... again
abhinav92003 Dec 16, 2024
57f34ad
Disable module mapper tests on Windows due to i#5960
abhinav92003 Dec 17, 2024
3f9cc4e
Remove tmate
abhinav92003 Dec 17, 2024
44971f6
Add TODO for some future items
abhinav92003 Dec 17, 2024
3042d6b
More apt function visibility
abhinav92003 Dec 17, 2024
2b301b5
Merge branch 'master' into i7113-decode-cache-lib
abhinav92003 Dec 19, 2024
4157f23
Reviewer suggested changes
abhinav92003 Dec 19, 2024
0f50370
Add clear_cache API for parallel_shard_exit
abhinav92003 Dec 19, 2024
8dc950c
Add optimization to avoid repeated module map lookups
abhinav92003 Dec 19, 2024
160e052
Remove common-case opt. Need add_decode_info for new encodings
abhinav92003 Dec 19, 2024
74da310
Optimize lookups into the cache
abhinav92003 Dec 19, 2024
6bcc33b
Skip re-decoding on invalid cached decode info. It's redundant.
abhinav92003 Dec 19, 2024
b24d79a
Cleanup
abhinav92003 Dec 22, 2024
e175cd9
Avoid DecodeInfo object construction when not needed.
abhinav92003 Dec 22, 2024
139f5ad
Merge branch 'master' into i7113-decode-cache-lib
abhinav92003 Jan 3, 2025
84a9f1e
Reviewer suggested edits
abhinav92003 Jan 3, 2025
894c675
Avoid DecodeInfo object construction if key exists.
abhinav92003 Jan 6, 2025
23dca98
Reviewer suggested edit
abhinav92003 Jan 6, 2025
7ebe54f
Also include decode_pc in set_decode_info calls
abhinav92003 Jan 6, 2025
5dbc0fc
Cleanup and assert fix.
abhinav92003 Jan 7, 2025
268e5a7
Fix doc xref
abhinav92003 Jan 7, 2025
88d0482
Separate out make_decode_cache
abhinav92003 Jan 7, 2025
0833242
Move some logic out of make_module_mapper
abhinav92003 Jan 7, 2025
021e20c
Merge branch 'master' into i7113-decode-cache-lib
abhinav92003 Jan 7, 2025
c8a38b3
Changes to allow 3p import, and other misc
abhinav92003 Jan 22, 2025
b01854b
Throw error on different module_file_path
abhinav92003 Jan 22, 2025
1347aef
Update copyright year
abhinav92003 Jan 22, 2025
d171074
Merge branch 'master' into i7113-decode-cache-lib
abhinav92003 Jan 22, 2025
29684cb
Address reviewer comments.
abhinav92003 Jan 22, 2025
8a67f4f
Merge branch 'master' into i7113-decode-cache-lib
abhinav92003 Jan 23, 2025
12da01f
Pass verbosity to module_mapper
abhinav92003 Jan 23, 2025
cfd3519
Revert empty file
abhinav92003 Jan 23, 2025
31f4146
Mark init() as virtual for easier downstream use
abhinav92003 Jan 23, 2025
70339cd
Address reviewer-suggested edits.
abhinav92003 Jan 24, 2025
49345b9
Cast trace_pc before printing
abhinav92003 Jan 24, 2025
b9c0fef
Ensure internal memory of unordered_map is released on clear_cache
abhinav92003 Jan 24, 2025
a5214b2
Cleanup
abhinav92003 Jan 24, 2025
92a1bc1
Revert "Ensure internal memory of unordered_map is released on clear_…
abhinav92003 Jan 24, 2025
a10721b
Simpler fix for unalloc mem in unordered_map
abhinav92003 Jan 24, 2025
7a61b92
More cleanup: comment clarity etc
abhinav92003 Jan 24, 2025
e59ce2b
Fix build
abhinav92003 Jan 24, 2025
a178ebc
Maintain status quo on decoding error in invariant checker
abhinav92003 Jan 24, 2025
5d4b390
Merge branch 'master' into i7113-decode-cache-lib
abhinav92003 Jan 24, 2025
22ce46a
Make init_decode_cache virtual and remove make_decode_cache
abhinav92003 Jan 24, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions api/docs/release.dox
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,11 @@ changes:
Further non-compatibility-affecting changes include:
- Added support for reading a single drmemtrace trace file from stdin
via "-infile -".
- Added the #dynamorio::drmemtrace::decode_cache_t library to make it easier and more
efficient for drmemtrace analysis tools to obtain decoded information about
instructions in the trace. This works for traces that have embedded instruction
encodings in them, and also for legacy traces without embedded encodings where the
encodings are obtained from the application binaries instead.

**************************************************
<hr>
Expand Down
38 changes: 35 additions & 3 deletions clients/drcachesim/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -163,19 +163,27 @@ 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 tracer/raw2trace_shared.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)
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)

configure_DynamoRIO_standalone(drmemtrace_decode_cache)
configure_DynamoRIO_standalone(drmemtrace_opcode_mix)
configure_DynamoRIO_standalone(drmemtrace_view)
configure_DynamoRIO_standalone(drmemtrace_invariant_checker)
Expand Down Expand Up @@ -322,6 +330,7 @@ include_directories(${CMAKE_CURRENT_SOURCE_DIR}/reader)
# 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)
Expand Down Expand Up @@ -369,6 +378,7 @@ 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)
Expand Down Expand Up @@ -633,6 +643,7 @@ 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.
Expand Down Expand Up @@ -706,6 +717,7 @@ 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)
Expand Down Expand Up @@ -964,6 +976,26 @@ if (BUILD_TESTS)
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)
add_test(NAME tool.drcacheoff.opcode_mix_test
COMMAND tool.drcacheoff.opcode_mix_test)
set_tests_properties(tool.drcacheoff.opcode_mix_test PROPERTIES
TIMEOUT ${test_seconds})

# XXX i#1997: dynamorio_static is not supported on Mac yet
# FIXME i#2949: gcc 7.3 fails to link certain configs
# TODO i#3544: Port tests to RISC-V 64
Expand Down
9 changes: 8 additions & 1 deletion clients/drcachesim/docs/drcachesim.dox.in
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* **********************************************************
* Copyright (c) 2015-2024 Google, Inc. All rights reserved.
* Copyright (c) 2015-2025 Google, Inc. All rights reserved.
* **********************************************************/

/*
Expand Down Expand Up @@ -142,6 +142,13 @@ copies of the binaries and reading the raw bytes for each instruction
in order to obtain the opcode and full operand information.
See also \ref sec_drcachesim_core.

drmemtrace analysis tools may use the
#dynamorio::drmemtrace::decode_cache_t library, which handles the
heavy lifting of decoding the trace instructions using either the embedded
encodings in the trace or the encodings from the app binaries, and manages
caching their decode info (including invalidating stale decode info based on
the `encoding_is_new` field for embedded encodings).

Whether conditional branches are taken or untaken is indicated by the
instruction types #dynamorio::drmemtrace::TRACE_TYPE_INSTR_TAKEN_JUMP
and #dynamorio::drmemtrace::TRACE_TYPE_INSTR_UNTAKEN_JUMP. The target
Expand Down
Loading
Loading