Skip to content

PTRACE_O_TRACEEXIT, PTRACE_O_TRACEEXEC #555

Closed

Description

@kimjs29

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.

Activity

  1. kimjs29 commented on Jun 19, 2016

    @kimjs29
    Author

    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");
    }
  2. sunilmut commented on Jul 14, 2017

    @sunilmut
    Member

    Sven Groot (@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".

  3. therealkenc commented on Jul 14, 2017

    @therealkenc

    💯 Sven.

  4. therealkenc commented on Jul 14, 2017

    @therealkenc

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

  5. sunilmut commented on Jul 26, 2017

    @sunilmut
    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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions