Index: lldb/source/Target/Process.cpp =================================================================== --- lldb/source/Target/Process.cpp +++ lldb/source/Target/Process.cpp @@ -65,6 +65,7 @@ #include "lldb/Utility/Log.h" #include "lldb/Utility/NameMatches.h" #include "lldb/Utility/ProcessInfo.h" +#include "lldb/Utility/Reproducer.h" #include "lldb/Utility/SelectHelper.h" #include "lldb/Utility/State.h" @@ -2790,6 +2791,11 @@ } return error; } + } else if (repro::Reproducer::Instance().IsReplaying()) { + // The actual PID doesn't matter, we just need to set it to something + // that's not LLDB_INVALID_PROCESS_ID. The GDB remote replay + // infrastructure will intercept our attach later on. + attach_pid = 1; } else { ProcessInstanceInfoList process_infos; PlatformSP platform_sp(GetTarget().GetPlatform()); Index: lldb/test/Shell/Reproducer/Inputs/sleep.c =================================================================== --- /dev/null +++ lldb/test/Shell/Reproducer/Inputs/sleep.c @@ -0,0 +1,7 @@ +#include +#include + +int main(int argc, char const *argv[]) { + sleep(10); + return 0; +} Index: lldb/test/Shell/Reproducer/TestAttach.test =================================================================== --- /dev/null +++ lldb/test/Shell/Reproducer/TestAttach.test @@ -0,0 +1,11 @@ +# UNSUPPORTED: system-windows, system-freebsd + +# RUN: rm -rf %t.repro +# RUN: mkdir -p %t + +# RUN: %clang_host %S/Inputs/sleep.c -g -o %t/attach.out +# RUN: python -c 'import os; os.system("%t/attach.out &")' + +# RUN: %lldb --capture --capture-path %t.repro -o 'pro att -n attach.out' -o 'reproducer generate' | FileCheck %s +# RUN: %lldb --replay %t.repro | FileCheck %s +# CHECK: stop reason = signal SIGSTOP