JDevlieghere created this revision. JDevlieghere added reviewers: labath, jasonmolenda. Herald added a subscriber: teemperor. Herald added a project: LLDB.
Support replaying debug sessions that attach to an existing process instead of lldb launching the inferior. Bypass the logic that looks for a process with the given name and use an arbitrary PID. The value of the PID doesn't matter as the gdb remote replay infrastructure intercepts the attach and pretends that we're connected to the original process. Repository: rLLDB LLDB https://reviews.llvm.org/D75877 Files: lldb/source/Target/Process.cpp lldb/test/Shell/Reproducer/Inputs/sleep.c lldb/test/Shell/Reproducer/TestAttach.test 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 Index: lldb/test/Shell/Reproducer/Inputs/sleep.c =================================================================== --- /dev/null +++ lldb/test/Shell/Reproducer/Inputs/sleep.c @@ -0,0 +1,7 @@ +#include <stdio.h> +#include <unistd.h> + +int main(int argc, char const *argv[]) { + sleep(10); + return 0; +} 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/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 Index: lldb/test/Shell/Reproducer/Inputs/sleep.c =================================================================== --- /dev/null +++ lldb/test/Shell/Reproducer/Inputs/sleep.c @@ -0,0 +1,7 @@ +#include <stdio.h> +#include <unistd.h> + +int main(int argc, char const *argv[]) { + sleep(10); + return 0; +} 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());
_______________________________________________ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits