diff --git a/src/RecordCommand.cc b/src/RecordCommand.cc index 845cbbc1303..d7658168946 100644 --- a/src/RecordCommand.cc +++ b/src/RecordCommand.cc @@ -49,8 +49,11 @@ RecordCommand RecordCommand::singleton( " : Bitmask of bits to clear from EAX\n" " -h, --chaos randomize scheduling decisions to try to \n" " reproduce bugs\n" - " -n, --no-syscall-buffer disable the syscall buffer preload \n" - " library even if it would otherwise be used\n" + " -n, --no-syscall-buffer disable syscall buffering even if it would\n" + " otherwise be used\n" + " --no-preload disable the preload library; useful when\n" + " tracee uses a non-standard C ABI but may\n" + " cause replay issues. Implies -n.\n" " --no-file-cloning disable file cloning for mmapped files\n" " --no-read-cloning disable file-block cloning for syscallbuf\n" " reads\n" @@ -193,6 +196,9 @@ struct RecordFlags { /* True if we should check files being mapped outside of the recording. */ bool check_outside_mmaps; + /* True if we should not add the preload library to LD_PRELOAD. */ + bool no_preload = false; + RecordFlags() : max_ticks(Scheduler::DEFAULT_MAX_TICKS), ignore_sig(0), @@ -282,6 +288,7 @@ static bool parse_record_arg(vector& args, RecordFlags& flags) { { 18, "tsan", NO_PARAMETER }, { 19, "intel-pt", NO_PARAMETER }, { 20, "check-outside-mmaps", NO_PARAMETER }, + { 21, "no-preload", NO_PARAMETER }, { 'c', "num-cpu-ticks", HAS_PARAMETER }, { 'h', "chaos", NO_PARAMETER }, { 'i', "ignore-signal", HAS_PARAMETER }, @@ -507,6 +514,9 @@ static bool parse_record_arg(vector& args, RecordFlags& flags) { case 20: flags.check_outside_mmaps = true; break; + case 21: + flags.no_preload = true; + break; case 's': flags.always_switch = true; break; @@ -696,11 +706,10 @@ static WaitStatus record(const vector& args, const RecordFlags& flags) { auto session = RecordSession::create( args, flags.extra_env, flags.disable_cpuid_features, - flags.use_syscall_buffer, flags.syscallbuf_desched_sig, - flags.bind_cpu, flags.output_trace_dir, - flags.trace_id.get(), - flags.stap_sdt, flags.unmap_vdso, flags.asan, flags.tsan, - flags.intel_pt, flags.check_outside_mmaps); + flags.use_syscall_buffer, flags.syscallbuf_desched_sig, flags.bind_cpu, + flags.output_trace_dir, flags.trace_id.get(), flags.stap_sdt, + flags.unmap_vdso, flags.asan, flags.tsan, flags.intel_pt, + flags.check_outside_mmaps, flags.no_preload); setup_session_from_flags(*session, flags); static_session = session.get(); diff --git a/src/RecordSession.cc b/src/RecordSession.cc index 0c67b577b8e..65125bdb354 100644 --- a/src/RecordSession.cc +++ b/src/RecordSession.cc @@ -2402,7 +2402,8 @@ static string lookup_by_path(const string& name) { bool force_asan_active, bool force_tsan_active, bool intel_pt, - bool check_outside_mmaps) { + bool check_outside_mmaps, + bool no_preload) { TraceeAttentionSet::initialize(); // The syscallbuf library interposes some critical @@ -2450,7 +2451,7 @@ static string lookup_by_path(const string& name) { // LD_PRELOAD the syscall interception lib string syscall_buffer_lib_path = find_helper_library(SYSCALLBUF_LIB_FILENAME); - if (!syscall_buffer_lib_path.empty()) { + if (!no_preload && !syscall_buffer_lib_path.empty()) { string ld_preload = ""; if (!exe_info.sanitizer_path.empty()) { LOG(debug) << "Prepending " << exe_info.sanitizer_path << " to LD_PRELOAD"; diff --git a/src/RecordSession.h b/src/RecordSession.h index 86ee2056bab..a936eb6d926 100644 --- a/src/RecordSession.h +++ b/src/RecordSession.h @@ -73,7 +73,8 @@ class RecordSession final : public Session { bool force_asan_active = false, bool force_tsan_active = false, bool intel_pt = false, - bool check_outside_mmaps = false); + bool check_outside_mmaps = false, + bool no_preload = false); ~RecordSession() override;