Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PTRACE_O_TRACEEXIT, PTRACE_O_TRACEEXEC #555

Closed
kimjs29 opened this issue Jun 18, 2016 · 6 comments
Closed

PTRACE_O_TRACEEXIT, PTRACE_O_TRACEEXEC #555

kimjs29 opened this issue Jun 18, 2016 · 6 comments

Comments

@kimjs29
Copy link

kimjs29 commented Jun 18, 2016

I am testing Swift on WSL.

Swift REPL uses LLVM's LLDB which calls ptrace(PTRACE_SETOPTIONS,...).

ptrace on WSL accepts PTRACE_O_TRACECLONE, but not PTRACE_O_TRACEEXIT nor PTRACE_O_TRACEEXEC.

The test code is as follows:

#include <unistd.h>
#include <stdlib.h>
#include <sys/ptrace.h>

int main()
{
    long data = PTRACE_O_TRACECLONE|PTRACE_O_TRACEEXEC|PTRACE_O_TRACEEXIT;

    pid_t child = fork();
    if (child == 0) {
        ptrace(PTRACE_TRACEME, 0, NULL, NULL);
        execl("/bin/echo", "echo", NULL);
    }
    wait(NULL);
    if (ptrace(PTRACE_SETOPTIONS, child, NULL, (void*)data) == -1)
        perror("ptrace error");
}

On Ubuntu LTS 14.04, the test code does not generate errors.
On WSL Build 14367, the test code produces an "Invalid argument" error with PTRACE_O_TRACEEXEC or PTRACE_O_TRACEEXIT suboptions.

@kimjs29
Copy link
Author

kimjs29 commented Jun 19, 2016

I met another similar case with PTRACE_GETREGSET option.

#include <unistd.h>
#include <stdlib.h>
#include <sys/ptrace.h>
#include <linux/uio.h>

int main()
{
    long regs[27];
    struct iovec iov = { regs, sizeof(regs) };
    pid_t child = fork();
    if (child == 0) {
        ptrace(PTRACE_TRACEME, 0, NULL, NULL);
        execl("/bin/echo", "echo", NULL);
    }
    wait(NULL);
    if (ptrace(PTRACE_GETREGSET, child, 1, &iov) == -1)
        perror("ptrace error");
}

@cbuschardt
Copy link

I met yet another case with PTRACE_TRACEME reporting EPERM on Creator's Update. This blocks lldb from functioning.

@sunilmut
Copy link
Member

@SvenGroot recently added support for PTRACE_O_TRACEEXIT and PTRACE_GETREGSET. Support for PTRACE_O_TRACEEXEC exists in Creators Update (build 15063). So, I am going to mark this as "fixinbound".

@therealkenc
Copy link
Collaborator

💯 Sven.

@therealkenc
Copy link
Collaborator

PTRACE_SYSEMU for the win, BTW. It is being tracked in awkwardly titled #1692.

@sunilmut
Copy link
Member

Support for PTRACE_O_TRACEEXIT, TRACE_GETFPREGS and PTRACE_GETREGSET has come in the Insider build 16251

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants