mirror of
https://github.com/Gericom/teak-llvm.git
synced 2025-06-21 04:25:45 -04:00

Summary: Due to a logic error, lldb-server ended up asserting/crashing every time the debugged process attempted an execve(). This fixes the error, and extends TestExec to work on other platforms too. The "extension" consists of avoiding non-standard posix_spawn extensions and using the classic execve() call, which should be available on any platform that actually supports re-execing. I change the test decorator from @skipUnlessDarwin to @skipIfWindows. Reviewers: clayborg, jasonmolenda Subscribers: lldb-commits Differential Revision: https://reviews.llvm.org/D65207 llvm-svn: 366985
17 lines
428 B
C++
17 lines
428 B
C++
#include <cstdio>
|
|
#include <cstdlib>
|
|
#include <cstring>
|
|
#include <libgen.h>
|
|
#include <string>
|
|
#include <unistd.h>
|
|
|
|
int main(int argc, char const **argv) {
|
|
char *buf = strdup(argv[0]); // Set breakpoint 1 here
|
|
std::string directory_name(::dirname(buf));
|
|
|
|
std::string other_program = directory_name + "/secondprog";
|
|
execve(other_program.c_str(), const_cast<char *const *>(argv), nullptr);
|
|
perror("execve");
|
|
abort();
|
|
}
|