diff options
Diffstat (limited to 'lldb/packages/Python/lldbsuite')
-rw-r--r-- | lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/attach/TestVSCode_attach.py | 19 | ||||
-rw-r--r-- | lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/attach/main.c | 21 |
2 files changed, 26 insertions, 14 deletions
diff --git a/lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/attach/TestVSCode_attach.py b/lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/attach/TestVSCode_attach.py index ed014392f59..cb2ac355df5 100644 --- a/lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/attach/TestVSCode_attach.py +++ b/lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/attach/TestVSCode_attach.py @@ -79,19 +79,22 @@ class TestVSCode_attach(lldbvscode_testcase.VSCodeTestCaseBase): shutil.copyfile(orig_program, program) shutil.copymode(orig_program, program) + # Use a file as a synchronization point between test and inferior. + pid_file_path = lldbutil.append_to_process_working_directory(self, + "pid_file_%d" % (int(time.time()))) + def cleanup(): if os.path.exists(program): os.unlink(program) + self.run_platform_command("rm %s" % (pid_file_path)) # Execute the cleanup function during test case tear down. self.addTearDownHook(cleanup) - self.process = subprocess.Popen([program], - stdin=subprocess.PIPE, - stdout=subprocess.PIPE, - stderr=subprocess.PIPE) - # Wait for a bit to ensure the process is launched, but not for so long - # that the process has already finished by the time we attach. - time.sleep(3) + popen = self.spawnSubprocess(program, [pid_file_path]) + self.addTearDownHook(self.cleanupSubprocesses) + + pid = lldbutil.wait_for_file_on_target(self, pid_file_path) + self.attach(program=program) self.set_and_hit_breakpoint(continueToExit=True) @@ -143,7 +146,7 @@ class TestVSCode_attach(lldbvscode_testcase.VSCodeTestCaseBase): # and use it for debugging attachCommands = [ 'target create -d "%s"' % (program), - 'process launch -- arg1' + 'process launch' ] initCommands = ['target list', 'platform list'] preRunCommands = ['image list a.out', 'image dump sections a.out'] diff --git a/lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/attach/main.c b/lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/attach/main.c index 4f50f754615..64d86583ada 100644 --- a/lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/attach/main.c +++ b/lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/attach/main.c @@ -1,11 +1,20 @@ #include <stdio.h> #include <unistd.h> -int main(int argc, char const *argv[]) -{ - lldb_enable_attach(); +int main(int argc, char const *argv[]) { + lldb_enable_attach(); - printf("pid = %i\n", getpid()); - sleep(10); - return 0; // breakpoint 1 + if (argc >= 2) { + // Create the synchronization token. + FILE *f = fopen(argv[1], "wx"); + if (!f) + return 1; + fputs("\n", f); + fflush(f); + fclose(f); + } + + printf("pid = %i\n", getpid()); + sleep(10); + return 0; // breakpoint 1 } |