[Lldb-commits] [PATCH] D96637: Make sure the interpreter module was loaded before making checks against it

Greg Clayton via Phabricator via lldb-commits lldb-commits at lists.llvm.org
Wed Feb 17 14:31:09 PST 2021


clayborg added a comment.

In D96637#2567269 <https://reviews.llvm.org/D96637#2567269>, @aadsm wrote:

>> We should have a test for this.
>
> how do you recommend doing this? I spent a couple of hours on this but got no where. From what I understood we should prefer lit tests, so I was thinking of creating a binary that dlopens a module. However, I wasn't able to create a binary that I can start and capture its pid address so that I can attach to. Here's what I've tried so far:
>
>   // RUN: cp %s %s.cpp
>   // RUN: %clang -g -O0 --target=x86_64-linux-gnu %s.cpp -o %s.out
>   // RUN: PID=$(%s.out)
>   // RUN: %lldb -p $PID -b -o 'target list' | FileCheck %s
>   // RUN: kill -9 $PID
>   // CHECK: foo
>   
>   #include <stdio.h>
>   #include <unistd.h>
>   
>   int main() {
>       pid_t pid = fork();
>       if (pid > 0) {
>           // parent process, print child pid
>           printf("%d", pid);
>           return 0;
>       } else if (pid < 0) {
>           printf("Unable to fork\n");
>           return -1;
>       }
>       // child process
>       pause();
>   }
>
> The lit test get stuck on `// RUN: PID=$(%s.out)`. Not sure why, the parent process shouldn't wait on its children..

I would do an end to end test for this. We have many attach tests that should be easy to modify and pause() and then try to load a local dylib that is dlopen'ed. Unless Pavel has a differing opinion?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D96637/new/

https://reviews.llvm.org/D96637



More information about the lldb-commits mailing list