Skip to content

Commit

Permalink
i#6660 dr$sim aliases: Add "-t drmemtrace" (DynamoRIO#6811)
Browse files Browse the repository at this point in the history
Adds a tool file so "-t drmemtrace" can become the preferred way to
launch the drmemtrace tool framework, as "drcachesim" is just one tool
within the framework.

Updates the documentation and tests.

Renames the "drcachesim" executable to "drmemtrace_launcher".

Fixes DynamoRIO#6660
  • Loading branch information
derekbruening authored May 15, 2024
1 parent 336e2a2 commit a559edc
Show file tree
Hide file tree
Showing 9 changed files with 123 additions and 106 deletions.
4 changes: 2 additions & 2 deletions README
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,9 @@ To run the application with a DynamoRIO sample client:

To run the application with a DynamoRIO-based tool:
32-bit:
% bin32/drrun -t drcachesim -- ls
% bin32/drrun -t drmemtrace -- ls
64-bit
% bin64/drrun -t drcachesim -- ls
% bin64/drrun -t drmemtrace -- ls

To run the Dr. Memory tool which is included in release packages:
% bin32/drrun -t drmemory -- <my-32-bit-app> <args-to-app>
Expand Down
6 changes: 3 additions & 3 deletions api/docs/new_release.dox
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* ******************************************************************************
* Copyright (c) 2010-2023 Google, Inc. All rights reserved.
* Copyright (c) 2010-2024 Google, Inc. All rights reserved.
* ******************************************************************************/

/*
Expand Down Expand Up @@ -161,8 +161,8 @@ bin64/drrun -t drltrace -- /work/dr/test/hello64
bin32/drrun -t drmemory -- /work/dr/test/hello
bin32/drrun -t drmemory_light -- /work/dr/test/hello
bin64/drrun -t drmemory -- /work/dr/test/hello64
bin32/drrun -t drcachesim -- /work/dr/test/hello
bin64/drrun -t drcachesim -- /work/dr/test/hello64
bin32/drrun -t drmemtrace -- /work/dr/test/hello
bin64/drrun -t drmemtrace -- /work/dr/test/hello64
bin32/drrun -t drcpusim -cpu PentiumPro -- /work/dr/test/hello
bin64/drrun -t drcpusim -cpu Banias -- /work/dr/test/hello64

Expand Down
2 changes: 2 additions & 0 deletions api/docs/release.dox
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,8 @@ Further non-compatibility-affecting changes include:
#DR_ISA_REGDEPS traces.
- Added -tool as the preferred alias for -simulator_type for the drmemtrace/drcachesim
trace analysis tool framework.
- Added "-t drmemtrace" as the preferred launcher for the drmemtrace/drcachesim
trace analysis tool framework.

**************************************************
<hr>
Expand Down
64 changes: 38 additions & 26 deletions clients/drcachesim/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# **********************************************************
# Copyright (c) 2015-2023 Google, Inc. All rights reserved.
# Copyright (c) 2015-2024 Google, Inc. All rights reserved.
# **********************************************************

# Redistribution and use in source and binary forms, with or without
Expand Down Expand Up @@ -272,28 +272,28 @@ set(drcachesim_srcs
tracer/instru_online.cpp
${loader_srcs})

add_executable(drcachesim ${drcachesim_srcs})
add_executable(drmemtrace_launcher ${drcachesim_srcs})
# In order to embed raw2trace we need to be standalone:
configure_DynamoRIO_standalone(drcachesim)
configure_DynamoRIO_standalone(drmemtrace_launcher)
# Link in our tools:
target_link_libraries(drcachesim drmemtrace_simulator drmemtrace_reuse_distance
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)
if (UNIX)
target_link_libraries(drcachesim dl)
target_link_libraries(drmemtrace_launcher dl)
endif ()
if (libsnappy)
target_link_libraries(drcachesim snappy)
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(drcachesim drdecode drinjectlib drconfiglib drfrontendlib)
use_DynamoRIO_extension(drcachesim droption)
target_link_libraries(drmemtrace_launcher drdecode drinjectlib drconfiglib drfrontendlib)
use_DynamoRIO_extension(drmemtrace_launcher droption)
# These are also for raw2trace:
use_DynamoRIO_extension(drcachesim drcovlib_static)
use_DynamoRIO_extension(drcachesim drutil_static)
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.
Expand Down Expand Up @@ -444,7 +444,7 @@ if (NOT APPLE)
configure_DynamoRIO_static(opcode_mix_launcher)
endif ()

target_link_libraries(drcachesim ${zlib_libs})
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})
Expand Down Expand Up @@ -569,7 +569,7 @@ macro(restore_nonclient_flags target)
endif ()
endmacro()

restore_nonclient_flags(drcachesim)
restore_nonclient_flags(drmemtrace_launcher)
restore_nonclient_flags(drraw2trace)
restore_nonclient_flags(histogram_launcher)
restore_nonclient_flags(record_filter_launcher)
Expand Down Expand Up @@ -634,7 +634,7 @@ macro(add_win32_flags target)
endif ()
endmacro ()

add_win32_flags(drcachesim)
add_win32_flags(drmemtrace_launcher)
add_win32_flags(drraw2trace)
add_win32_flags(histogram_launcher)
add_win32_flags(record_filter_launcher)
Expand All @@ -660,7 +660,7 @@ add_win32_flags(drmemtrace_schedule_stats)
add_win32_flags(directory_iterator)
add_win32_flags(test_helpers)
if (WIN32 AND DEBUG)
get_target_property(sim_srcs drcachesim SOURCES)
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!
Expand All @@ -673,18 +673,18 @@ endif ()

place_shared_lib_in_lib_dir(drmemtrace)

add_dependencies(drcachesim api_headers)
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 drcachesim"
ARGS -E echo "Usage: pass to drconfig or drrun: -t drmemtrace"
VERBATIM)
endif ()

install_target(drcachesim ${INSTALL_CLIENTS_BIN})
install_target(drmemtrace_launcher ${INSTALL_CLIENTS_BIN})
install_target(drraw2trace ${INSTALL_CLIENTS_BIN})

set(INSTALL_DRCACHESIM_CONFIG ${INSTALL_CLIENTS_BASE})
Expand All @@ -707,8 +707,8 @@ function (write_config_file dst bindir libdir)
set(debugopt "")
endif ()
file(GENERATE OUTPUT ${dst} CONTENT
"# drcachesim tool config file\n\
FRONTEND_REL=${bindir}/$<TARGET_FILE_NAME:drcachesim>\n\
"# 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\
Expand All @@ -720,20 +720,32 @@ ${debugopt}\n")
endfunction ()

if (X64)
set(CONFIG_INSTALL ${PROJECT_BINARY_DIR}/drcachesim.drrun64)
set(CONFIG_BUILD ${PROJECT_BINARY_DIR}/tools/drcachesim.drrun64)
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}/drcachesim.drrun32)
set(CONFIG_BUILD ${PROJECT_BINARY_DIR}/tools/drcachesim.drrun32)
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)
Expand All @@ -744,14 +756,14 @@ if (WIN32)
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 drcachesim POST_BUILD
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 drcachesim POST_BUILD
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(drcachesim client_dr_copy)
add_dependencies(drmemtrace_launcher client_dr_copy)
endif ()

add_subdirectory(tools/external)
Expand Down
Loading

0 comments on commit a559edc

Please sign in to comment.