Skip to content

Commit

Permalink
Merge branch 'master' into drcachesim_external_simulators
Browse files Browse the repository at this point in the history
  • Loading branch information
yuriershov committed Oct 6, 2023
2 parents dca1a00 + 43db19b commit 1bb867a
Show file tree
Hide file tree
Showing 12 changed files with 313 additions and 46 deletions.
1 change: 1 addition & 0 deletions api/docs/release.dox
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,7 @@ Further non-compatibility-affecting changes include:
- Added several routines to the #dynamorio::drmemtrace::memtrace_stream_t interface
for drmemtrace analysis tools: get_output_cpuid(), get_workload_id(),
get_input_id(), get_input_interface().
- Added -record_syscall to drmemtrace for recording syscall parameters.
- Added opportunity to run multiple drcachesim analysis tools simultaneously.
- Added support of loading separately-built analysis tools to drcachesim dynamically.

Expand Down
18 changes: 18 additions & 0 deletions clients/drcachesim/common/options.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -748,6 +748,24 @@ droption_t<bool> op_record_replace_retaddr(
"replacement, which has lower overhead, but runs the risk of breaking an "
"application that examines or changes its own return addresses in the recorded "
"functions.");
droption_t<std::string> op_record_syscall(
DROPTION_SCOPE_CLIENT, "record_syscall", DROPTION_FLAG_ACCUMULATE,
OP_RECORD_FUNC_ITEM_SEP, "", "Record parameters for the specified syscall number(s).",
"Record the parameters and success of the specified system call number(s)."
" The option value should fit this format:"
" sycsall_number|parameter_number"
" E.g., -record_syscall \"2|2\" will record SYS_open's 2 parameters and whether"
" successful (1 for success or 0 for failure, in a function return value record)"
" for x86 Linux. SYS_futex is recorded by default on Linux and this option's value"
" adds to futex rather than replacing it (setting futex to 0 parameters disables)."
" The trace identifies which syscall owns each set of parameter and return value"
" records via a numeric ID equal to the syscall number + TRACE_FUNC_ID_SYSCALL_BASE."
" Recording multiple syscalls can be achieved by using the separator"
" \"" OP_RECORD_FUNC_ITEM_SEP
"\" (e.g., -record_syscall \"202|6" OP_RECORD_FUNC_ITEM_SEP "3|1\"), or"
" specifying multiple -record_syscall options."
" It is up to the user to ensure the values are correct; a too-large parameter"
" count may cause tracing to fail with an error mid-run.");
droption_t<unsigned int> op_miss_count_threshold(
DROPTION_SCOPE_FRONTEND, "miss_count_threshold", 50000,
"For cache miss analysis: minimum LLC miss count for a load to be eligible for "
Expand Down
5 changes: 5 additions & 0 deletions clients/drcachesim/common/options.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,10 @@
#define CACHE_TYPE_DATA "data"
#define CACHE_TYPE_UNIFIED "unified"
#define CACHE_PARENT_MEMORY "memory"
// The expected pattern for a single_op_value is:
// function_name|function_id|arguments_num
// where function_name can contain spaces (for instance, C++ namespace prefix)
#define PATTERN_SEPARATOR "|"

#ifdef HAS_ZIP
# define DEFAULT_TRACE_COMPRESSION_TYPE "zip"
Expand Down Expand Up @@ -169,6 +173,7 @@ extern dynamorio::droption::droption_t<bool> op_record_heap;
extern dynamorio::droption::droption_t<std::string> op_record_heap_value;
extern dynamorio::droption::droption_t<bool> op_record_dynsym_only;
extern dynamorio::droption::droption_t<bool> op_record_replace_retaddr;
extern dynamorio::droption::droption_t<std::string> op_record_syscall;
extern dynamorio::droption::droption_t<unsigned int> op_miss_count_threshold;
extern dynamorio::droption::droption_t<double> op_miss_frac_threshold;
extern dynamorio::droption::droption_t<double> op_confidence_threshold;
Expand Down
16 changes: 16 additions & 0 deletions clients/drcachesim/common/utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
#include <iomanip>
#include <sstream>
#include <string>
#include <vector>

namespace dynamorio {
namespace drmemtrace {
Expand Down Expand Up @@ -166,6 +167,21 @@ starts_with(const std::string &str, const std::string &with)
return pos == 0;
}

static inline std::vector<std::string>
split_by(std::string s, const std::string &sep)
{
size_t pos;
std::vector<std::string> vec;
if (s.empty())
return vec;
do {
pos = s.find(sep);
vec.push_back(s.substr(0, pos));
s.erase(0, pos + sep.length());
} while (pos != std::string::npos);
return vec;
}

} // namespace drmemtrace
} // namespace dynamorio

Expand Down
5 changes: 5 additions & 0 deletions clients/drcachesim/docs/drcachesim.dox.in
Original file line number Diff line number Diff line change
Expand Up @@ -1482,6 +1482,11 @@ The -record_heap parameter requests recording of a pre-determined set
of functions related to heap allocation. The -record_heap_value
paramter controls the contents of this set.

The tracer also supports recording system call argument and success
values via the option -record_syscall, which functions similarly to
-record_function with the system call number replacing the function
name.

****************************************************************************
\page sec_drcachesim_newtool Creating New Analysis Tools

Expand Down
24 changes: 24 additions & 0 deletions clients/drcachesim/tests/offline-allasm-record-syscall.templatex
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
Adios world!
Adios world!
Adios world!
Adios world!
Adios world!
Adios world!
Adios world!
Adios world!
Adios world!
Adios world!
.*
43 20: .* ifetch 2 byte\(s\) @ 0x.* 0f 05 syscall
44 20: .* <marker: timestamp .*>
45 20: .* <marker: tid .* on core .*>
46 20: .* <marker: system call 1>
47 20: .* <marker: maybe-blocking system call>
48 20: .* <marker: function==syscall #1>
49 20: .* <marker: function argument 0x2>
50 20: .* <marker: function argument 0x.*>
51 20: .* <marker: function argument 0xd>
52 20: .* <marker: function==syscall #1>
53 20: .* <marker: function return value 0x1>
54 20: .* <marker: timestamp .*>
.*
Loading

0 comments on commit 1bb867a

Please sign in to comment.