xref: /llvm-project/lldb/test/API/functionalities/dyld-exec-linux/main.cpp (revision 879a47a55ffb94976cbac1d191ef53be135d86a7)
1 #include <unistd.h>
2 
main(int argc,const char * argv[],const char * envp[])3 int main(int argc, const char *argv[], const char *envp[]) {
4   if (argc == 2) {
5     // If we have two arguments the first is the path to this executable,
6     // the second is the path to the linux dynamic loader that we should
7     // exec with. We want to re-run this problem under the dynamic loader
8     // and make sure we can hit the breakpoint in the "else".
9     const char *interpreter = argv[1];
10     const char *this_program = argv[0];
11     const char *exec_argv[3] = {interpreter, this_program, nullptr};
12     execve(interpreter, (char *const *)exec_argv, (char *const *)envp);
13   }
14   // Break here
15   return 0;
16 }
17