diff options
author | Billy Donahue <billy.donahue@mongodb.com> | 2020-01-10 21:47:39 +0000 |
---|---|---|
committer | evergreen <evergreen@mongodb.com> | 2020-01-10 21:47:39 +0000 |
commit | bd8267ebcee61a9c131a931dbb7031f85dc6cd67 (patch) | |
tree | 94f0764e7783f2b6b70d28802e4ef4276703c2f3 /src/third_party | |
parent | d1c186ae22b56a7a481cdeb02bf04a0ad4a6384e (diff) | |
download | mongo-bd8267ebcee61a9c131a931dbb7031f85dc6cd67.tar.gz |
SERVER-42470 update libunwind to get mongo-local __asm__ patch
import to new v1.4-stable-mongo tag
Diffstat (limited to 'src/third_party')
-rw-r--r-- | src/third_party/unwind/dist/doc/libunwind.man | 6 | ||||
-rw-r--r-- | src/third_party/unwind/dist/doc/unw_step.man | 6 | ||||
-rw-r--r-- | src/third_party/unwind/dist/include/dwarf-eh.h | 1 | ||||
-rw-r--r-- | src/third_party/unwind/dist/include/libunwind_i.h | 5 | ||||
-rw-r--r-- | src/third_party/unwind/dist/include/tdep-x86_64/libunwind_i.h | 4 | ||||
-rw-r--r-- | src/third_party/unwind/dist/src/aarch64/Gresume.c | 4 | ||||
-rw-r--r-- | src/third_party/unwind/dist/src/arm/Gresume.c | 4 | ||||
-rw-r--r-- | src/third_party/unwind/dist/src/mips/Gstep.c | 106 | ||||
-rw-r--r-- | src/third_party/unwind/dist/src/sh/Gresume.c | 4 | ||||
-rw-r--r-- | src/third_party/unwind/dist/src/x86_64/Gglobal.c | 21 | ||||
-rw-r--r-- | src/third_party/unwind/dist/src/x86_64/Ginit_local.c | 2 | ||||
-rw-r--r-- | src/third_party/unwind/dist/src/x86_64/Ginit_remote.c | 2 | ||||
-rw-r--r-- | src/third_party/unwind/dist/tests/crasher.c | 2 | ||||
-rwxr-xr-x | src/third_party/unwind/scripts/import.sh | 2 |
14 files changed, 95 insertions, 74 deletions
diff --git a/src/third_party/unwind/dist/doc/libunwind.man b/src/third_party/unwind/dist/doc/libunwind.man index 02ab6b89374..87edee27df0 100644 --- a/src/third_party/unwind/dist/doc/libunwind.man +++ b/src/third_party/unwind/dist/doc/libunwind.man @@ -1,5 +1,7 @@ +.\" *********************************** start of \input{common.tex} +.\" *********************************** end of \input{common.tex} '\" t -.\" Manual page created with latex2man on Thu Jan 12 06:50:29 PST 2017 +.\" Manual page created with latex2man on Fri Jan 10 15:56:07 EST 2020 .\" NOTE: This file is generated, DO NOT EDIT. .de Vb .ft CW @@ -10,7 +12,7 @@ .fi .. -.TH "LIBUNWIND" "3" "12 January 2017" "Programming Library " "Programming Library " +.TH "LIBUNWIND" "3" "10 January 2020" "Programming Library " "Programming Library " .SH NAME libunwind \-\- a (mostly) platform\-independent unwind API diff --git a/src/third_party/unwind/dist/doc/unw_step.man b/src/third_party/unwind/dist/doc/unw_step.man index 96835cf0dfa..54da1b2f3d6 100644 --- a/src/third_party/unwind/dist/doc/unw_step.man +++ b/src/third_party/unwind/dist/doc/unw_step.man @@ -1,7 +1,5 @@ -.\" *********************************** start of \input{common.tex} -.\" *********************************** end of \input{common.tex} '\" t -.\" Manual page created with latex2man on Sat Apr 20 19:14:02 EDT 2019 +.\" Manual page created with latex2man on Thu Aug 16 09:44:45 MDT 2007 .\" NOTE: This file is generated, DO NOT EDIT. .de Vb .ft CW @@ -12,7 +10,7 @@ .fi .. -.TH "UNW\\_STEP" "3" "20 April 2019" "Programming Library " "Programming Library " +.TH "UNW\\_STEP" "3" "16 August 2007" "Programming Library " "Programming Library " .SH NAME unw_step \-\- advance to next stack frame diff --git a/src/third_party/unwind/dist/include/dwarf-eh.h b/src/third_party/unwind/dist/include/dwarf-eh.h index 96002a1b9d2..e03750760c5 100644 --- a/src/third_party/unwind/dist/include/dwarf-eh.h +++ b/src/third_party/unwind/dist/include/dwarf-eh.h @@ -27,7 +27,6 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ #define dwarf_eh_h #include "dwarf.h" -#include "libunwind_i.h" /* This header file defines the format of a DWARF exception-header section (.eh_frame_hdr, pointed to by program-header diff --git a/src/third_party/unwind/dist/include/libunwind_i.h b/src/third_party/unwind/dist/include/libunwind_i.h index 36cf7a14de7..e0f45401442 100644 --- a/src/third_party/unwind/dist/include/libunwind_i.h +++ b/src/third_party/unwind/dist/include/libunwind_i.h @@ -140,6 +140,7 @@ cmpxchg_ptr (void *addr, void *old, void *new) } # define fetch_and_add1(_ptr) AO_fetch_and_add1(_ptr) # define fetch_and_add(_ptr, value) AO_fetch_and_add(_ptr, value) +# define atomic_read(ptr) (AO_load(ptr)) /* GCC 3.2.0 on HP-UX crashes on cmpxchg_ptr() */ # if !(defined(__hpux) && __GNUC__ == 3 && __GNUC_MINOR__ == 2) # define HAVE_CMPXCHG @@ -164,10 +165,14 @@ cmpxchg_ptr (void *addr, void *old, void *new) } # define fetch_and_add1(_ptr) __sync_fetch_and_add(_ptr, 1) # define fetch_and_add(_ptr, value) __sync_fetch_and_add(_ptr, value) +# define atomic_read(ptr) (__atomic_load_n(ptr,__ATOMIC_RELAXED)) # define HAVE_CMPXCHG # define HAVE_FETCH_AND_ADD #endif + +#ifndef atomic_read #define atomic_read(ptr) (*(ptr)) +#endif #define UNWI_OBJ(fn) UNW_PASTE(UNW_PREFIX,UNW_PASTE(I,fn)) #define UNWI_ARCH_OBJ(fn) UNW_PASTE(UNW_PASTE(UNW_PASTE(_UI,UNW_TARGET),_), fn) diff --git a/src/third_party/unwind/dist/include/tdep-x86_64/libunwind_i.h b/src/third_party/unwind/dist/include/tdep-x86_64/libunwind_i.h index 283525c16a3..93d925f2831 100644 --- a/src/third_party/unwind/dist/include/tdep-x86_64/libunwind_i.h +++ b/src/third_party/unwind/dist/include/tdep-x86_64/libunwind_i.h @@ -232,7 +232,11 @@ dwarf_put (struct dwarf_cursor *c, dwarf_loc_t loc, unw_word_t val) #define tdep_get_ip(c) ((c)->dwarf.ip) #define tdep_big_endian(as) 0 +#ifdef HAVE_ATOMIC_OPS_H +extern AO_t tdep_init_done; +#else extern int tdep_init_done; +#endif extern void tdep_init (void); extern void tdep_init_mem_validate (void); diff --git a/src/third_party/unwind/dist/src/aarch64/Gresume.c b/src/third_party/unwind/dist/src/aarch64/Gresume.c index 3d82739293e..2cc161360ef 100644 --- a/src/third_party/unwind/dist/src/aarch64/Gresume.c +++ b/src/third_party/unwind/dist/src/aarch64/Gresume.c @@ -71,7 +71,7 @@ aarch64_local_resume (unw_addr_space_t as, unw_cursor_t *cursor, void *arg) char x[sizeof(regs)]; }; - asm volatile ( + __asm__ __volatile__ ( "mov x4, %0\n" "mov x5, %1\n" "ldp x0, x1, [x4]\n" @@ -134,7 +134,7 @@ aarch64_local_resume (unw_addr_space_t as, unw_cursor_t *cursor, void *arg) sc->pc = uc->uc_mcontext.pc; sc->pstate = uc->uc_mcontext.pstate; - asm volatile ( + __asm__ __volatile__ ( "mov sp, %0\n" "ret %1\n" : : "r" (c->sigcontext_sp), "r" (c->sigcontext_pc) diff --git a/src/third_party/unwind/dist/src/arm/Gresume.c b/src/third_party/unwind/dist/src/arm/Gresume.c index a8288628a6c..3b9dfb33e60 100644 --- a/src/third_party/unwind/dist/src/arm/Gresume.c +++ b/src/third_party/unwind/dist/src/arm/Gresume.c @@ -56,7 +56,7 @@ arm_local_resume (unw_addr_space_t as, unw_cursor_t *cursor, void *arg) char x[sizeof(regs)]; }; - asm __volatile__ ( + __asm__ __volatile__ ( "ldmia %0, {r4-r12, lr}\n" "mov sp, r12\n" "bx lr\n" @@ -90,7 +90,7 @@ arm_local_resume (unw_addr_space_t as, unw_cursor_t *cursor, void *arg) /* Set the SP and the PC in order to continue execution at the modified trampoline which restores the signal mask and the registers. */ - asm __volatile__ ( + __asm__ __volatile__ ( "mov sp, %0\n" "bx %1\n" : : "r" (c->sigcontext_sp), "r" (c->sigcontext_pc) diff --git a/src/third_party/unwind/dist/src/mips/Gstep.c b/src/third_party/unwind/dist/src/mips/Gstep.c index f5a742e12e0..0235d523f03 100644 --- a/src/third_party/unwind/dist/src/mips/Gstep.c +++ b/src/third_party/unwind/dist/src/mips/Gstep.c @@ -111,85 +111,91 @@ mips_handle_signal_frame (unw_cursor_t *cursor) } -int _step_n64(struct cursor *c) + +static inline +int is_valid_fp_val(unw_word_t cfa_val, unw_word_t fp_val) +{ + return fp_val > 0 && cfa_val > 0 && fp_val >cfa_val && (fp_val - cfa_val < 0x4000); +} + +static int _step_n64(struct cursor *c) { + #define FP_REG UNW_MIPS_R30 + #define SP_REG UNW_MIPS_R29 + #define RA_REG UNW_MIPS_R31 + //TODO:handle plt entry - struct dwarf_loc fp_loc, pc_loc; int ret; - unw_word_t fp = 0; - unw_word_t ra = 0; + unw_word_t current_fp_val = 0; + unw_word_t current_ra_val = 0; + unw_word_t current_sp_val = 0; + struct dwarf_loc up_fp_loc = DWARF_NULL_LOC; + struct dwarf_loc up_ra_loc = DWARF_NULL_LOC; - ret = dwarf_get (&c->dwarf, c->dwarf.loc[UNW_MIPS_R30], &fp); + ret = dwarf_get (&c->dwarf, c->dwarf.loc[SP_REG], ¤t_sp_val); + if (ret < 0) + { + Debug (2, "returning %d [SP=0x%lx]\n", ret, + DWARF_GET_LOC (c->dwarf.loc[FP_REG])); + return ret; + } + ret = dwarf_get (&c->dwarf, c->dwarf.loc[FP_REG], ¤t_fp_val); if (ret < 0) { Debug (2, "returning %d [FP=0x%lx]\n", ret, - DWARF_GET_LOC (c->dwarf.loc[UNW_MIPS_R30])); + DWARF_GET_LOC (c->dwarf.loc[FP_REG])); return ret; } - ret = dwarf_get (&c->dwarf, c->dwarf.loc[UNW_MIPS_R31], &ra); + ret = dwarf_get (&c->dwarf, c->dwarf.loc[RA_REG], ¤t_ra_val); if (ret < 0) { Debug (2, "returning %d [RA=0x%lx]\n", ret, - DWARF_GET_LOC (c->dwarf.loc[UNW_MIPS_R31])); + DWARF_GET_LOC (c->dwarf.loc[RA_REG])); return ret; } - if (!fp) { - fp_loc = DWARF_NULL_LOC; - pc_loc = DWARF_NULL_LOC; - } else { - fp_loc = DWARF_LOC(fp+16, 0); - pc_loc = DWARF_LOC (fp+24, 0); -#if UNW_DEBUG - unw_word_t fp1 = 0; - ret = dwarf_get (&c->dwarf, fp_loc, &fp1); - Debug (1, "RET:%d [FP=0x%lx] = 0x%lx (cfa = 0x%lx) -> 0x%lx. SAVED PC:0x%lx\n", - ret, - (unsigned long) DWARF_GET_LOC (c->dwarf.loc[UNW_MIPS_R30]), - fp, c->dwarf.cfa, fp1, ra); -#endif + Debug(2, "BEGIN GUESSING WITH SP:%p FP:%p CFA:%p at %p, RA:%p\n", + current_sp_val, current_fp_val, c->dwarf.cfa, + c->dwarf.ip, current_ra_val + ); + + if (current_fp_val == current_sp_val) { + // Don't adjust FP + up_fp_loc = c->dwarf.loc[FP_REG]; + up_ra_loc = c->dwarf.loc[RA_REG]; + } else if (is_valid_fp_val(c->dwarf.cfa, current_fp_val)) { /* Heuristic to determine incorrect guess. For FP to be a valid frame it needs to be above current CFA, but don't let it go more than a little. Note that we can't deduce anything about new FP (fp1) since it may not be a frame pointer in the frame above. Just check we get the value. */ - if (ret < 0 - || fp < c->dwarf.cfa - || (fp - c->dwarf.cfa) > 0x4000) - { - pc_loc = DWARF_NULL_LOC; - fp_loc = DWARF_NULL_LOC; - } + up_fp_loc = DWARF_MEM_LOC (c, current_fp_val+16); + up_ra_loc = DWARF_MEM_LOC (c, current_fp_val+24); + unw_word_t up_fp_val = 0; + ret = dwarf_get (&c->dwarf, up_fp_loc, &up_fp_val); + if (ret > 0 && is_valid_fp_val(current_fp_val, up_fp_val)) { + c->dwarf.loc[FP_REG] = up_fp_loc; + } } - c->dwarf.loc[UNW_MIPS_R30] = fp_loc; - - c->dwarf.loc[UNW_MIPS_PC] = c->dwarf.loc[UNW_MIPS_R31]; - c->dwarf.loc[UNW_MIPS_R31] = pc_loc; - c->dwarf.use_prev_instr = 1; - - if (DWARF_IS_NULL_LOC (c->dwarf.loc[UNW_MIPS_R30])) + if (DWARF_IS_NULL_LOC (up_fp_loc)) { ret = 0; Debug (2, "NULL %%fp loc, returning %d\n", ret); return ret; } - if (!DWARF_IS_NULL_LOC (c->dwarf.loc[UNW_MIPS_PC])) - { - ret = dwarf_get (&c->dwarf, c->dwarf.loc[UNW_MIPS_PC], &c->dwarf.ip); - Debug (1, "Frame Chain [IP=0x%Lx] = 0x%Lx\n", - (unsigned long long) DWARF_GET_LOC (c->dwarf.loc[UNW_MIPS_PC]), - (unsigned long long) c->dwarf.ip); - if (ret < 0) - { - Debug (2, "returning %d\n", ret); - return ret; - } - ret = 1; - } - else { + c->dwarf.loc[UNW_MIPS_PC] = c->dwarf.loc[RA_REG]; + c->dwarf.loc[RA_REG] = up_ra_loc; + c->dwarf.loc[SP_REG] = up_fp_loc; + c->dwarf.loc[FP_REG] = up_fp_loc; + c->dwarf.use_prev_instr = 1; + + if (c->dwarf.ip == current_ra_val && current_fp_val == current_sp_val) { + // Backtrace stopped: frame did not save the PC c->dwarf.ip = 0; + } else { + c->dwarf.ip = current_ra_val; } return (c->dwarf.ip == 0) ? 0 : 1; } diff --git a/src/third_party/unwind/dist/src/sh/Gresume.c b/src/third_party/unwind/dist/src/sh/Gresume.c index a263c92718a..5590bafa612 100644 --- a/src/third_party/unwind/dist/src/sh/Gresume.c +++ b/src/third_party/unwind/dist/src/sh/Gresume.c @@ -55,7 +55,7 @@ sh_local_resume (unw_addr_space_t as, unw_cursor_t *cursor, void *arg) char x[sizeof(regs)]; }; - asm volatile ( + __asm__ __volatile__ ( "mov.l @%0+, r8\n" "mov.l @%0+, r9\n" "mov.l @%0+, r10\n" @@ -99,7 +99,7 @@ sh_local_resume (unw_addr_space_t as, unw_cursor_t *cursor, void *arg) /* Set the SP and the PC in order to continue execution at the modified trampoline which restores the signal mask and the registers. */ - asm __volatile__ ( + __asm__ __volatile__ ( "mov %0, r15\n" "lds %1, pr\n" "rts\n" diff --git a/src/third_party/unwind/dist/src/x86_64/Gglobal.c b/src/third_party/unwind/dist/src/x86_64/Gglobal.c index 8d1fbb4b0a9..9a7b1957eb8 100644 --- a/src/third_party/unwind/dist/src/x86_64/Gglobal.c +++ b/src/third_party/unwind/dist/src/x86_64/Gglobal.c @@ -30,7 +30,11 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ #include "dwarf_i.h" HIDDEN define_lock (x86_64_lock); -HIDDEN int tdep_init_done; +#ifdef HAVE_ATOMIC_OPS_H + HIDDEN AO_t tdep_init_done; +#else + HIDDEN int tdep_init_done; +#endif /* See comments for svr4_dbx_register_map[] in gcc/config/i386/i386.c. */ @@ -77,15 +81,17 @@ HIDDEN void tdep_init (void) { intrmask_t saved_mask; + intrmask_t full_mask; + sigfillset (&full_mask); - sigfillset (&unwi_full_mask); - - lock_acquire (&x86_64_lock, saved_mask); + SIGPROCMASK (SIG_SETMASK, &full_mask, &saved_mask); + mutex_lock (&x86_64_lock); { - if (tdep_init_done) + if (atomic_read(&tdep_init_done)) /* another thread else beat us to it... */ goto out; + sigfillset (&unwi_full_mask); mi_init (); dwarf_init (); @@ -95,8 +101,9 @@ tdep_init (void) #ifndef UNW_REMOTE_ONLY x86_64_local_addr_space_init (); #endif - tdep_init_done = 1; /* signal that we're initialized... */ + fetch_and_add1(&tdep_init_done); /* signal that we're initialized... */ } out: - lock_release (&x86_64_lock, saved_mask); + mutex_unlock(&x86_64_lock); + SIGPROCMASK (SIG_SETMASK, &saved_mask, NULL); } diff --git a/src/third_party/unwind/dist/src/x86_64/Ginit_local.c b/src/third_party/unwind/dist/src/x86_64/Ginit_local.c index 5eaead0f840..12a9e3e4c96 100644 --- a/src/third_party/unwind/dist/src/x86_64/Ginit_local.c +++ b/src/third_party/unwind/dist/src/x86_64/Ginit_local.c @@ -43,7 +43,7 @@ unw_init_local_common (unw_cursor_t *cursor, ucontext_t *uc, unsigned use_prev_i { struct cursor *c = (struct cursor *) cursor; - if (unlikely (!tdep_init_done)) + if (unlikely (!atomic_read(&tdep_init_done))) tdep_init (); Debug (1, "(cursor=%p)\n", c); diff --git a/src/third_party/unwind/dist/src/x86_64/Ginit_remote.c b/src/third_party/unwind/dist/src/x86_64/Ginit_remote.c index efd61d64d4b..f411b233317 100644 --- a/src/third_party/unwind/dist/src/x86_64/Ginit_remote.c +++ b/src/third_party/unwind/dist/src/x86_64/Ginit_remote.c @@ -36,7 +36,7 @@ unw_init_remote (unw_cursor_t *cursor, unw_addr_space_t as, void *as_arg) #else /* !UNW_LOCAL_ONLY */ struct cursor *c = (struct cursor *) cursor; - if (!tdep_init_done) + if (!atomic_read(&tdep_init_done)) tdep_init (); Debug (1, "(cursor=%p)\n", c); diff --git a/src/third_party/unwind/dist/tests/crasher.c b/src/third_party/unwind/dist/tests/crasher.c index 9df57095d85..bb99e339c26 100644 --- a/src/third_party/unwind/dist/tests/crasher.c +++ b/src/third_party/unwind/dist/tests/crasher.c @@ -93,7 +93,7 @@ write_maps(char *fname) #pragma GCC optimize "-O1" #endif int c(int x) NOINLINE ALIAS(b); -#define compiler_barrier() asm volatile(""); +#define compiler_barrier() __asm__ __volatile__ (""); #else int c(int x); #define compiler_barrier() diff --git a/src/third_party/unwind/scripts/import.sh b/src/third_party/unwind/scripts/import.sh index 22489b4e4ab..2843a95e3b9 100755 --- a/src/third_party/unwind/scripts/import.sh +++ b/src/third_party/unwind/scripts/import.sh @@ -7,7 +7,7 @@ IFS=$'\n\t' set -vx NAME=libunwind -REVISION=334047a04e59287463348a9e333947b5e59ddd91 # 2019-04-02 +REVISION="v1.4-stable-mongo" # 2020-01-10 VERSION="1.4-rc1" DEST_DIR=$(git rev-parse --show-toplevel)/src/third_party/unwind |