pkgsrc-WIP-changes archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

coreclr-git: Draft to handle BSD style struct reg in NetBSD



Module Name:	pkgsrc-wip
Committed By:	Kamil Rytarowski <n54%gmx.com@localhost>
Pushed By:	kamil
Date:		Sun Jan 31 22:54:00 2016 +0100
Changeset:	44c11774bb1fba7771567e4b4700e1f565c344a3

Modified Files:
	coreclr-git/distinfo
	coreclr-git/patches/patch-src_pal_src_config.h.in
	coreclr-git/patches/patch-src_pal_src_configure.cmake
	coreclr-git/patches/patch-src_pal_src_include_pal_context.h
Added Files:
	coreclr-git/patches/patch-src_pal_src_thread_context.cpp

Log Message:
coreclr-git: Draft to handle BSD style struct reg in NetBSD

To see a diff of this commit:
https://wip.pkgsrc.org/cgi-bin/gitweb.cgi?p=pkgsrc-wip.git;a=commitdiff;h=44c11774bb1fba7771567e4b4700e1f565c344a3

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

diffstat:
 coreclr-git/distinfo                               |  7 +-
 coreclr-git/patches/patch-src_pal_src_config.h.in  |  6 +-
 .../patches/patch-src_pal_src_configure.cmake      | 16 ++++
 .../patch-src_pal_src_include_pal_context.h        | 88 ++++++++++++++++++++++
 .../patches/patch-src_pal_src_thread_context.cpp   | 48 ++++++++++++
 5 files changed, 161 insertions(+), 4 deletions(-)

diffs:
diff --git a/coreclr-git/distinfo b/coreclr-git/distinfo
index 7aa0e2c..9943c1b 100644
--- a/coreclr-git/distinfo
+++ b/coreclr-git/distinfo
@@ -1,11 +1,12 @@
 $NetBSD$
 
 SHA1 (patch-src_pal_inc_pal__char16.h) = 205f6a8533838c192b36bbb00155da1b02e0f629
-SHA1 (patch-src_pal_src_config.h.in) = f6caa80de0d3d3f1022bcc77e2a0cd3899efc80b
-SHA1 (patch-src_pal_src_configure.cmake) = 8a91b634878ed52b2ec73bba47cc6af00411e22f
+SHA1 (patch-src_pal_src_config.h.in) = 05c67c2131ed0eec3ba6fb80de08e101c9ec98cb
+SHA1 (patch-src_pal_src_configure.cmake) = 0bcb4ff8c0def2f146d29e75e781aa414fb5db23
 SHA1 (patch-src_pal_src_cruntime_file.cpp) = 315ad5db53ef2b893a77aa131ce97999214e0e11
 SHA1 (patch-src_pal_src_exception_seh-unwind.cpp) = ffb395a23d66e33e5cf1b0f3f4ff5feff52a56fc
 SHA1 (patch-src_pal_src_exception_signal.cpp) = 1bcb47f927a0c8037876b47ca4d15afb24cbd410
-SHA1 (patch-src_pal_src_include_pal_context.h) = 962cf83ef0ba0a4e2e57e344809a566f12f2e01d
+SHA1 (patch-src_pal_src_include_pal_context.h) = 32e5535866b4c7046bb05cc152b2e6db9dc9cf9b
 SHA1 (patch-src_pal_src_safecrt_safecrt__output__s.c) = ed008b078417d790c989226f50f4fe90f0def1ef
 SHA1 (patch-src_pal_src_safecrt_safecrt__woutput__s.c) = 0d666b335e262ed84a385bd3537cdbd94efa46e4
+SHA1 (patch-src_pal_src_thread_context.cpp) = bd5fe3f1793f32e396ace0a9b0cc06b8424b529a
diff --git a/coreclr-git/patches/patch-src_pal_src_config.h.in b/coreclr-git/patches/patch-src_pal_src_config.h.in
index 815bda0..b3fafca 100644
--- a/coreclr-git/patches/patch-src_pal_src_config.h.in
+++ b/coreclr-git/patches/patch-src_pal_src_config.h.in
@@ -2,8 +2,12 @@ $NetBSD$
 
 --- src/pal/src/config.h.in.orig	2016-01-31 18:28:53.000000000 +0000
 +++ src/pal/src/config.h.in
-@@ -61,6 +61,7 @@
+@@ -59,8 +59,11 @@
+ #cmakedefine01 HAVE_TM_GMTOFF
+ 
  #cmakedefine01 HAVE_BSD_REGS_T
++#cmakedefine01 HAVE_REG_R_REGS
++#cmakedefine01 HAVE_REG__R_REGS
  #cmakedefine01 HAVE_PT_REGS
  #cmakedefine01 HAVE_GREGSET_T
 +#cmakedefine01 HAVE___GREGSET_T
diff --git a/coreclr-git/patches/patch-src_pal_src_configure.cmake b/coreclr-git/patches/patch-src_pal_src_configure.cmake
index 57d25a8..e515c0c 100644
--- a/coreclr-git/patches/patch-src_pal_src_configure.cmake
+++ b/coreclr-git/patches/patch-src_pal_src_configure.cmake
@@ -19,3 +19,19 @@ $NetBSD$
  check_type_size(ucontext_t UCONTEXT_T)
  set(CMAKE_EXTRA_INCLUDE_FILES)
  set(CMAKE_EXTRA_INCLUDE_FILES pthread.h)
+@@ -937,6 +938,7 @@ elseif(CMAKE_SYSTEM_NAME STREQUAL FreeBS
+   set(PAL_PT_READ_D PT_READ_D)
+   set(PAL_PT_WRITE_D PT_WRITE_D)
+   set(HAS_FTRUNCATE_LENGTH_ISSUE 0)
++  set(HAVE_REG_R_REGS 1)
+ 
+   if(EXISTS "/lib/libc.so.7")
+     set(FREEBSD_LIBC "/lib/libc.so.7")
+@@ -960,6 +962,7 @@ elseif(CMAKE_SYSTEM_NAME STREQUAL NetBSD
+   set(PAL_PT_READ_D PT_READ_D)
+   set(PAL_PT_WRITE_D PT_WRITE_D)
+   set(HAS_FTRUNCATE_LENGTH_ISSUE 0)
++  set(HAVE_REG__R_REGS 1)
+ 
+ elseif(CMAKE_SYSTEM_NAME STREQUAL SunOS)
+   if(NOT HAVE_LIBUNWIND_H)
diff --git a/coreclr-git/patches/patch-src_pal_src_include_pal_context.h b/coreclr-git/patches/patch-src_pal_src_include_pal_context.h
index d418088..6d4aaae 100644
--- a/coreclr-git/patches/patch-src_pal_src_include_pal_context.h
+++ b/coreclr-git/patches/patch-src_pal_src_include_pal_context.h
@@ -62,3 +62,91 @@ $NetBSD$
  
  #ifdef BIT64
  #define MCREG_Rbx(mc)       ((mc).gregs[REG_RBX])
+@@ -293,43 +344,55 @@ typedef ucontext_t native_context_t;
+ 
+ #if HAVE_BSD_REGS_T
+ 
++/*
++#ifndef HAVE_BSD_REGS_STYLE
++#error "struct reg" has unrecognized format
++#endif
++*/
++
++#if 0
++#define BSD_REGS_STYLE(reg,RR,rr) ((reg).r_##rr)
++#else
++#define BSD_REGS_STYLE(reg,RR,rr) ((reg).regs[_REG_##RR])
++#endif
++
+ #ifdef BIT64
+ 
+-#define BSDREG_Rbx(reg)     ((reg).r_rbx)
+-#define BSDREG_Rcx(reg)     ((reg).r_rcx)
+-#define BSDREG_Rdx(reg)     ((reg).r_rdx)
+-#define BSDREG_Rsi(reg)     ((reg).r_rsi)
+-#define BSDREG_Rdi(reg)     ((reg).r_rdi)
+-#define BSDREG_Rbp(reg)     ((reg).r_rbp)
+-#define BSDREG_Rax(reg)     ((reg).r_rax)
+-#define BSDREG_Rip(reg)     ((reg).r_rip)
+-#define BSDREG_SegCs(reg)   ((reg).r_cs)
+-#define BSDREG_SegSs(reg)   ((reg).r_ss)
+-#define BSDREG_Rsp(reg)     ((reg).r_rsp)
+-#define BSDREG_R8(reg)      ((reg).r_r8)
+-#define BSDREG_R9(reg)      ((reg).r_r9)
+-#define BSDREG_R10(reg)     ((reg).r_r10)
+-#define BSDREG_R11(reg)     ((reg).r_r11)
+-#define BSDREG_R12(reg)     ((reg).r_r12)
+-#define BSDREG_R13(reg)     ((reg).r_r13)
+-#define BSDREG_R14(reg)     ((reg).r_r14)
+-#define BSDREG_R15(reg)     ((reg).r_r15)
+-#define BSDREG_EFlags(reg)  ((reg).r_rflags)
++#define BSDREG_Rbx(reg)     BSD_REGS_STYLE((reg),RBX,rbx)
++#define BSDREG_Rcx(reg)     BSD_REGS_STYLE((reg),RCX,rcx)
++#define BSDREG_Rdx(reg)     BSD_REGS_STYLE((reg),RDX,rdx)
++#define BSDREG_Rsi(reg)     BSD_REGS_STYLE((reg),RSI,rsi)
++#define BSDREG_Rdi(reg)     BSD_REGS_STYLE((reg),RDI,rdi)
++#define BSDREG_Rbp(reg)     BSD_REGS_STYLE((reg),RBP,rbp)
++#define BSDREG_Rax(reg)     BSD_REGS_STYLE((reg),RAX,rax)
++#define BSDREG_Rip(reg)     BSD_REGS_STYLE((reg),RIP,rip)
++#define BSDREG_SegCs(reg)   BSD_REGS_STYLE((reg),CS,cs)
++#define BSDREG_SegSs(reg)   BSD_REGS_STYLE((reg),SS,ss)
++#define BSDREG_Rsp(reg)     BSD_REGS_STYLE((reg),RSP,rsp)
++#define BSDREG_R8(reg)      BSD_REGS_STYLE((reg),R8,r8)
++#define BSDREG_R9(reg)      BSD_REGS_STYLE((reg),R9,r9)
++#define BSDREG_R10(reg)     BSD_REGS_STYLE((reg),R10,r10)
++#define BSDREG_R11(reg)     BSD_REGS_STYLE((reg),R11,r11)
++#define BSDREG_R12(reg)     BSD_REGS_STYLE((reg),R12,r12)
++#define BSDREG_R13(reg)     BSD_REGS_STYLE((reg),R13,r13)
++#define BSDREG_R14(reg)     BSD_REGS_STYLE((reg),R14,r14)
++#define BSDREG_R15(reg)     BSD_REGS_STYLE((reg),R15,r15)
++#define BSDREG_EFlags(reg)  BSD_REGS_STYLE((reg),RFLAGS,rflags)
+ 
+ #else // BIT64
+ 
+-#define BSDREG_Ebx(reg)     ((reg).r_ebx)
+-#define BSDREG_Ecx(reg)     ((reg).r_ecx)
+-#define BSDREG_Edx(reg)     ((reg).r_edx)
+-#define BSDREG_Esi(reg)     ((reg).r_esi)
+-#define BSDREG_Edi(reg)     ((reg).r_edi)
+-#define BSDREG_Ebp(reg)     ((reg).r_ebp)
+-#define BSDREG_Eax(reg)     ((reg).r_eax)
+-#define BSDREG_Eip(reg)     ((reg).r_eip)
+-#define BSDREG_SegCs(reg)   ((reg).r_cs)
+-#define BSDREG_EFlags(reg)  ((reg).r_eflags)
+-#define BSDREG_Esp(reg)     ((reg).r_esp)
+-#define BSDREG_SegSs(reg)   ((reg).r_ss)
++#define BSDREG_Ebx(reg)     ((reg).BSDREG_REGS(ebx))
++#define BSDREG_Ecx(reg)     ((reg).BSDREG_REGS(ecx))
++#define BSDREG_Edx(reg)     ((reg).BSDREG_REGS(edx))
++#define BSDREG_Esi(reg)     ((reg).BSDREG_REGS(esi))
++#define BSDREG_Edi(reg)     ((reg).BSDREG_REGS(edi))
++#define BSDREG_Ebp(reg)     ((reg).BSDREG_REGS(ebp))
++#define BSDREG_Eax(reg)     ((reg).BSDREG_REGS(eax))
++#define BSDREG_Eip(reg)     ((reg).BSDREG_REGS(eip))
++#define BSDREG_SegCs(reg)   ((reg).BSDREG_REGS(cs))
++#define BSDREG_EFlags(reg)  ((reg).BSDREG_REGS(eflags))
++#define BSDREG_Esp(reg)     ((reg).BSDREG_REGS(esp))
++#define BSDREG_SegSs(reg)   ((reg).BSDREG_REGS(ss))
+ 
+ #endif // BIT64
+ 
diff --git a/coreclr-git/patches/patch-src_pal_src_thread_context.cpp b/coreclr-git/patches/patch-src_pal_src_thread_context.cpp
new file mode 100644
index 0000000..8c2f324
--- /dev/null
+++ b/coreclr-git/patches/patch-src_pal_src_thread_context.cpp
@@ -0,0 +1,48 @@
+$NetBSD$
+
+--- src/pal/src/thread/context.cpp.orig	2016-01-31 18:28:53.000000000 +0000
++++ src/pal/src/thread/context.cpp
+@@ -200,7 +200,7 @@ BOOL CONTEXT_GetRegisters(DWORD processI
+         if (ptrace((__ptrace_request)PT_GETREGS, processId, (caddr_t) &ptrace_registers, 0) == -1)
+ #elif HAVE_BSD_REGS_T
+         struct reg ptrace_registers;
+-        if (ptrace(PT_GETREGS, processId, (caddr_t) &ptrace_registers, 0) == -1)
++        if (PAL_PTRACE(PT_GETREGS, processId, &ptrace_registers, 0) == -1)
+ #endif
+         {
+             ASSERT("Failed ptrace(PT_GETREGS, processId:%d) errno:%d (%s)\n",
+@@ -349,7 +349,7 @@ CONTEXT_SetThreadContext(
+ #if HAVE_PT_REGS
+         if (ptrace((__ptrace_request)PT_GETREGS, dwProcessId, (caddr_t)&ptrace_registers, 0) == -1)
+ #elif HAVE_BSD_REGS_T
+-        if (ptrace(PT_GETREGS, dwProcessId, (caddr_t)&ptrace_registers, 0) == -1)
++        if (PAL_PTRACE(PT_GETREGS, dwProcessId, &ptrace_registers, 0) == -1)
+ #endif
+         {
+             ASSERT("Failed ptrace(PT_GETREGS, processId:%d) errno:%d (%s)\n",
+@@ -634,6 +634,7 @@ DWORD CONTEXTGetExceptionCodeForSignal(c
+                 case SEGV_MAPERR:   // Address not mapped to object
+                 case SEGV_ACCERR:   // Invalid permissions for mapped object
+                     return EXCEPTION_ACCESS_VIOLATION;
++#ifdef SI_KERNEL
+                 case SI_KERNEL:
+                 {
+                     // Identify privileged instructions that are not identified as such by the system
+@@ -647,6 +648,7 @@ DWORD CONTEXTGetExceptionCodeForSignal(c
+                     }
+                     // fall through
+                 }
++#endif
+                 default:
+                     break;
+             }
+@@ -665,7 +667,9 @@ DWORD CONTEXTGetExceptionCodeForSignal(c
+         case SIGTRAP:
+             switch (siginfo->si_code)
+             {
++#ifdef SI_KERNEL
+                 case SI_KERNEL:
++#endif
+                 case SI_USER:
+                 case TRAP_BRKPT:    // Process breakpoint
+                     return EXCEPTION_BREAKPOINT;


Home | Main Index | Thread Index | Old Index