Commit 4b8232d4 authored by Kamil Rytarowski's avatar Kamil Rytarowski
Browse files

[compiler-rt] Adapt for ptrace(2) changes in NetBSD-9.99.30

Enable compat support for now legacy PT_LWPINFO.
Support PT_LWPSTATUS and PT_LWPNEXT.
parent fc356dcc
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -20,7 +20,7 @@
// DO NOT EDIT! THIS FILE HAS BEEN GENERATED!
//
// Generated with: generate_netbsd_syscalls.awk
// Generated date: 2019-11-01
// Generated date: 2019-12-24
// Generated from: syscalls.master,v 1.296 2019/09/22 22:59:39 christos Exp
//
//===----------------------------------------------------------------------===//
+14 −0
Original line number Diff line number Diff line
@@ -17,6 +17,7 @@

#define _KMEMUSER
#define RAY_DO_SIGLEV
#define __LEGACY_PT_LWPINFO

// clang-format off
#include <sys/param.h>
@@ -71,6 +72,15 @@
#include <sys/msg.h>
#include <sys/mtio.h>
#include <sys/ptrace.h>

// Compat for NetBSD < 9.99.30.
#ifndef PT_LWPSTATUS
#define PT_LWPSTATUS 24
#endif
#ifndef PT_LWPSTATUS
#define PT_LWPSTATUS 25
#endif

#include <sys/resource.h>
#include <sys/sem.h>
#include <sys/sha1.h>
@@ -292,6 +302,8 @@ int ptrace_pt_get_event_mask = PT_GET_EVENT_MASK;
int ptrace_pt_get_process_state = PT_GET_PROCESS_STATE;
int ptrace_pt_set_siginfo = PT_SET_SIGINFO;
int ptrace_pt_get_siginfo = PT_GET_SIGINFO;
int ptrace_pt_lwpstatus = PT_LWPSTATUS;
int ptrace_pt_lwpnext = PT_LWPNEXT;
int ptrace_piod_read_d = PIOD_READ_D;
int ptrace_piod_write_d = PIOD_WRITE_D;
int ptrace_piod_read_i = PIOD_READ_I;
@@ -324,6 +336,8 @@ int ptrace_pt_getdbregs = -1;

unsigned struct_ptrace_ptrace_io_desc_struct_sz = sizeof(struct ptrace_io_desc);
unsigned struct_ptrace_ptrace_lwpinfo_struct_sz = sizeof(struct ptrace_lwpinfo);
unsigned struct_ptrace_ptrace_lwpstatus_struct_sz =
    sizeof(struct __sanitizer_ptrace_lwpstatus);
unsigned struct_ptrace_ptrace_event_struct_sz = sizeof(ptrace_event_t);
unsigned struct_ptrace_ptrace_siginfo_struct_sz = sizeof(ptrace_siginfo_t);

+11 −0
Original line number Diff line number Diff line
@@ -412,6 +412,8 @@ extern int ptrace_pt_get_event_mask;
extern int ptrace_pt_get_process_state;
extern int ptrace_pt_set_siginfo;
extern int ptrace_pt_get_siginfo;
extern int ptrace_pt_lwpstatus;
extern int ptrace_pt_lwpnext;
extern int ptrace_piod_read_d;
extern int ptrace_piod_write_d;
extern int ptrace_piod_read_i;
@@ -436,8 +438,17 @@ struct __sanitizer_ptrace_lwpinfo {
  int pl_event;
};

struct __sanitizer_ptrace_lwpstatus {
  __sanitizer_lwpid_t pl_lwpid;
  __sanitizer_sigset_t pl_sigpend;
  __sanitizer_sigset_t pl_sigmask;
  char pl_name[20];
  void *pl_private;
};

extern unsigned struct_ptrace_ptrace_io_desc_struct_sz;
extern unsigned struct_ptrace_ptrace_lwpinfo_struct_sz;
extern unsigned struct_ptrace_ptrace_lwpstatus_struct_sz;
extern unsigned struct_ptrace_ptrace_event_struct_sz;
extern unsigned struct_ptrace_ptrace_siginfo_struct_sz;

+21 −1
Original line number Diff line number Diff line
@@ -42,7 +42,7 @@
// DO NOT EDIT! THIS FILE HAS BEEN GENERATED!
//
// Generated with: generate_netbsd_syscalls.awk
// Generated date: 2019-11-01
// Generated date: 2019-12-24
// Generated from: syscalls.master,v 1.296 2019/09/22 22:59:39 christos Exp
//
//===----------------------------------------------------------------------===//
@@ -323,6 +323,16 @@ PRE_SYSCALL(ptrace)
    PRE_READ(addr_, struct_ptrace_ptrace_siginfo_struct_sz);
  } else if (req_ == ptrace_pt_get_siginfo) {
    PRE_WRITE(addr_, struct_ptrace_ptrace_siginfo_struct_sz);
  } else if (req_ == ptrace_pt_lwpstatus) {
    struct __sanitizer_ptrace_lwpstatus *addr =
        (struct __sanitizer_ptrace_lwpstatus *)addr_;
    PRE_READ(&addr->pl_lwpid, sizeof(__sanitizer_lwpid_t));
    PRE_WRITE(addr, struct_ptrace_ptrace_lwpstatus_struct_sz);
  } else if (req_ == ptrace_pt_lwpnext) {
    struct __sanitizer_ptrace_lwpstatus *addr =
        (struct __sanitizer_ptrace_lwpstatus *)addr_;
    PRE_READ(&addr->pl_lwpid, sizeof(__sanitizer_lwpid_t));
    PRE_WRITE(addr, struct_ptrace_ptrace_lwpstatus_struct_sz);
  } else if (req_ == ptrace_pt_setregs) {
    PRE_READ(addr_, struct_ptrace_reg_struct_sz);
  } else if (req_ == ptrace_pt_getregs) {
@@ -366,6 +376,16 @@ POST_SYSCALL(ptrace)
      POST_READ(addr_, struct_ptrace_ptrace_siginfo_struct_sz);
    } else if (req_ == ptrace_pt_get_siginfo) {
      POST_WRITE(addr_, struct_ptrace_ptrace_siginfo_struct_sz);
    } else if (req_ == ptrace_pt_lwpstatus) {
      struct __sanitizer_ptrace_lwpstatus *addr =
          (struct __sanitizer_ptrace_lwpstatus *)addr_;
      POST_READ(&addr->pl_lwpid, sizeof(__sanitizer_lwpid_t));
      POST_WRITE(addr, struct_ptrace_ptrace_lwpstatus_struct_sz);
    } else if (req_ == ptrace_pt_lwpnext) {
      struct __sanitizer_ptrace_lwpstatus *addr =
          (struct __sanitizer_ptrace_lwpstatus *)addr_;
      POST_READ(&addr->pl_lwpid, sizeof(__sanitizer_lwpid_t));
      POST_WRITE(addr, struct_ptrace_ptrace_lwpstatus_struct_sz);
    } else if (req_ == ptrace_pt_setregs) {
      POST_READ(addr_, struct_ptrace_reg_struct_sz);
    } else if (req_ == ptrace_pt_getregs) {
+17 −1
Original line number Diff line number Diff line
@@ -19,7 +19,7 @@
# This script will emit compat code for the older releases.
#
# NetBSD minimal version supported 9.0.
# NetBSD current version supported 9.99.17.
# NetBSD current version supported 9.99.30.
#
#===------------------------------------------------------------------------===#

@@ -733,6 +733,14 @@ function syscall_body(syscall, mode)
      pcmd("  PRE_READ(addr_, struct_ptrace_ptrace_siginfo_struct_sz);")
      pcmd("} else if (req_ == ptrace_pt_get_siginfo) {")
      pcmd("  PRE_WRITE(addr_, struct_ptrace_ptrace_siginfo_struct_sz);")
      pcmd("} else if (req_ == ptrace_pt_lwpstatus) {")
      pcmd("  struct __sanitizer_ptrace_lwpstatus *addr = (struct __sanitizer_ptrace_lwpstatus *)addr_;")
      pcmd("  PRE_READ(&addr->pl_lwpid, sizeof(__sanitizer_lwpid_t));")
      pcmd("  PRE_WRITE(addr, struct_ptrace_ptrace_lwpstatus_struct_sz);")
      pcmd("} else if (req_ == ptrace_pt_lwpnext) {")
      pcmd("  struct __sanitizer_ptrace_lwpstatus *addr = (struct __sanitizer_ptrace_lwpstatus *)addr_;")
      pcmd("  PRE_READ(&addr->pl_lwpid, sizeof(__sanitizer_lwpid_t));")
      pcmd("  PRE_WRITE(addr, struct_ptrace_ptrace_lwpstatus_struct_sz);")
      pcmd("} else if (req_ == ptrace_pt_setregs) {")
      pcmd("  PRE_READ(addr_, struct_ptrace_reg_struct_sz);")
      pcmd("} else if (req_ == ptrace_pt_getregs) {")
@@ -769,6 +777,14 @@ function syscall_body(syscall, mode)
      pcmd("    POST_READ(addr_, struct_ptrace_ptrace_siginfo_struct_sz);")
      pcmd("  } else if (req_ == ptrace_pt_get_siginfo) {")
      pcmd("    POST_WRITE(addr_, struct_ptrace_ptrace_siginfo_struct_sz);")
      pcmd("  } else if (req_ == ptrace_pt_lwpstatus) {")
      pcmd("    struct __sanitizer_ptrace_lwpstatus *addr = (struct __sanitizer_ptrace_lwpstatus *)addr_;")
      pcmd("    POST_READ(&addr->pl_lwpid, sizeof(__sanitizer_lwpid_t));")
      pcmd("    POST_WRITE(addr, struct_ptrace_ptrace_lwpstatus_struct_sz);")
      pcmd("  } else if (req_ == ptrace_pt_lwpnext) {")
      pcmd("    struct __sanitizer_ptrace_lwpstatus *addr = (struct __sanitizer_ptrace_lwpstatus *)addr_;")
      pcmd("    POST_READ(&addr->pl_lwpid, sizeof(__sanitizer_lwpid_t));")
      pcmd("    POST_WRITE(addr, struct_ptrace_ptrace_lwpstatus_struct_sz);")
      pcmd("  } else if (req_ == ptrace_pt_setregs) {")
      pcmd("    POST_READ(addr_, struct_ptrace_reg_struct_sz);")
      pcmd("  } else if (req_ == ptrace_pt_getregs) {")