summaryrefslogtreecommitdiffstats
path: root/lldb/packages/Python/lldbsuite
diff options
context:
space:
mode:
authorPavel Labath <pavel@labath.sk>2019-12-16 14:09:09 +0100
committerPavel Labath <pavel@labath.sk>2019-12-16 14:10:42 +0100
commit755a66ebdeda38669f5498565cbc6af331b47bad (patch)
tree670349580abaa4dc0dd14b594c6b73634bdf2065 /lldb/packages/Python/lldbsuite
parentc72bff682193118c054eb3d3c59eb718042787da (diff)
downloadbcm5719-llvm-755a66ebdeda38669f5498565cbc6af331b47bad.tar.gz
bcm5719-llvm-755a66ebdeda38669f5498565cbc6af331b47bad.zip
[lldb] Use file-based synchronization in TestVSCode_attach
The is the best method we have at the moment for attach-style tests.
Diffstat (limited to 'lldb/packages/Python/lldbsuite')
-rw-r--r--lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/attach/TestVSCode_attach.py19
-rw-r--r--lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/attach/main.c21
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
}
OpenPOWER on IntegriCloud