From bd3fb89e113a84560808ee6c286a4f93c5ca879c Mon Sep 17 00:00:00 2001 From: Dave Watson Date: Wed, 16 Aug 2017 12:15:16 -0700 Subject: [PATCH] Change unw_init_local_signal to unw_init_local2(..., UNW_INIT_SIGNAL_FRAME) Add unw_init_local2 with a flag for better extensibility in the future --- doc/Makefile.am | 2 +- doc/unw_init_local.man | 16 +++++++++------- doc/unw_init_local.tex | 6 +++--- ...init_local_signal.man => unw_init_local2.man} | 0 src/aarch64/Ginit_local.c | 15 +++++++++++++-- src/arm/Ginit_local.c | 15 +++++++++++++-- src/hppa/Ginit_local.c | 15 +++++++++++++-- src/mips/Ginit_local.c | 15 +++++++++++++-- src/ppc/Ginit_local.c | 15 +++++++++++++-- src/sh/Ginit_local.c | 15 +++++++++++++-- src/tilegx/Ginit_local.c | 15 +++++++++++++-- src/x86/Ginit_local.c | 15 +++++++++++++-- tests/check-namespace.sh.in | 4 ++-- 13 files changed, 119 insertions(+), 29 deletions(-) rename doc/{unw_init_local_signal.man => unw_init_local2.man} (100%) diff --git a/doc/Makefile.am b/doc/Makefile.am index 9b75e6d8..bfe46691 100644 --- a/doc/Makefile.am +++ b/doc/Makefile.am @@ -12,7 +12,7 @@ man3_MANS = libunwind.man libunwind-dynamic.man libunwind-ia64.man \ unw_get_reg.man \ unw_getcontext.man \ unw_init_local.man unw_init_remote.man \ - unw_init_local_signal.man \ + unw_init_local2.man \ unw_is_fpreg.man \ unw_is_signal_frame.man \ unw_create_addr_space.man \ diff --git a/doc/unw_init_local.man b/doc/unw_init_local.man index bb598b22..301dd6f9 100644 --- a/doc/unw_init_local.man +++ b/doc/unw_init_local.man @@ -1,5 +1,5 @@ '\" t -.\" Manual page created with latex2man on Thu Mar 30 16:13:10 PDT 2017 +.\" Manual page created with latex2man on Wed Aug 16 12:11:05 PDT 2017 .\" NOTE: This file is generated, DO NOT EDIT. .de Vb .ft CW @@ -10,7 +10,7 @@ .fi .. -.TH "UNW\\_INIT\\_LOCAL" "3" "30 March 2017" "Programming Library " "Programming Library " +.TH "UNW\\_INIT\\_LOCAL" "3" "16 August 2017" "Programming Library " "Programming Library " .SH NAME unw_init_local \-\- initialize cursor for local unwinding @@ -26,8 +26,10 @@ unw_init_local(unw_cursor_t *c, unw_context_t *ctxt); .br int -unw_init_local_signal(unw_cursor_t *c, -unw_context_t *ctxt); +unw_init_local2(unw_cursor_t *c, +unw_context_t *ctxt, +int +flag); .br .PP .SH DESCRIPTION @@ -66,9 +68,9 @@ is not. .PP If the unw_context_t is known to be a signal frame (i.e., from the third argument in a sigaction handler on linux), -unw_init_local_signal() -should be used for correct -initialization on some platforms. +unw_init_local2() +should be used for correct initialization +on some platforms, passing the UNW_INIT_SIGNAL_FRAME flag. .PP .SH RETURN VALUE diff --git a/doc/unw_init_local.tex b/doc/unw_init_local.tex index da6d5c29..ff0d03bc 100644 --- a/doc/unw_init_local.tex +++ b/doc/unw_init_local.tex @@ -13,7 +13,7 @@ \File{\#include $<$libunwind.h$>$}\\ \Type{int} \Func{unw\_init\_local}(\Type{unw\_cursor\_t~*}\Var{c}, \Type{unw\_context\_t~*}\Var{ctxt});\\ -\Type{int} \Func{unw\_init\_local_signal}(\Type{unw\_cursor\_t~*}\Var{c}, \Type{unw\_context\_t~*}\Var{ctxt});\\ +\Type{int} \Func{unw\_init\_local2}(\Type{unw\_cursor\_t~*}\Var{c}, \Type{unw\_context\_t~*}\Var{ctxt}, \Type{int} \Var{flag});\\ \section{Description} @@ -39,8 +39,8 @@ is not. If the unw_context_t is known to be a signal frame (i.e., from the third argument in a sigaction handler on linux), -\Func{unw\_init\_local\_signal}() should be used for correct -initialization on some platforms. +\Func{unw\_init\_local2}() should be used for correct initialization +on some platforms, passing the UNW_INIT_SIGNAL_FRAME flag. \section{Return Value} diff --git a/doc/unw_init_local_signal.man b/doc/unw_init_local2.man similarity index 100% rename from doc/unw_init_local_signal.man rename to doc/unw_init_local2.man diff --git a/src/aarch64/Ginit_local.c b/src/aarch64/Ginit_local.c index 45b1b300..d284224a 100644 --- a/src/aarch64/Ginit_local.c +++ b/src/aarch64/Ginit_local.c @@ -59,9 +59,20 @@ unw_init_local (unw_cursor_t *cursor, unw_context_t *uc) } PROTECTED int -unw_init_local_signal (unw_cursor_t *cursor, unw_context_t *uc) +unw_init_local2 (unw_cursor_t *cursor, ucontext_t *uc, int flag) { - return unw_init_local_common(cursor, uc, 0); + if (!flag) + { + return unw_init_local_common(cursor, uc, 1); + } + else if (flag == UNW_INIT_SIGNAL_FRAME) + { + return unw_init_local_common(cursor, uc, 0); + } + else + { + return -UNW_EINVAL; + } } #endif /* !UNW_REMOTE_ONLY */ diff --git a/src/arm/Ginit_local.c b/src/arm/Ginit_local.c index f74d55e7..05bf96c2 100644 --- a/src/arm/Ginit_local.c +++ b/src/arm/Ginit_local.c @@ -59,9 +59,20 @@ unw_init_local (unw_cursor_t *cursor, unw_context_t *uc) } PROTECTED int -unw_init_local_signal (unw_cursor_t *cursor, unw_context_t *uc) +unw_init_local2 (unw_cursor_t *cursor, ucontext_t *uc, int flag) { - return unw_init_local_common(cursor, uc, 0); + if (!flag) + { + return unw_init_local_common(cursor, uc, 1); + } + else if (flag == UNW_INIT_SIGNAL_FRAME) + { + return unw_init_local_common(cursor, uc, 0); + } + else + { + return -UNW_EINVAL; + } } #endif /* !UNW_REMOTE_ONLY */ diff --git a/src/hppa/Ginit_local.c b/src/hppa/Ginit_local.c index 94583d9d..5c59f48f 100644 --- a/src/hppa/Ginit_local.c +++ b/src/hppa/Ginit_local.c @@ -58,9 +58,20 @@ unw_init_local (unw_cursor_t *cursor, ucontext_t *uc) } PROTECTED int -unw_init_local_signal (unw_cursor_t *cursor, ucontext_t *uc) +unw_init_local2 (unw_cursor_t *cursor, ucontext_t *uc, int flag) { - return unw_init_local_common(cursor, uc, 0); + if (!flag) + { + return unw_init_local_common(cursor, uc, 1); + } + else if (flag == UNW_INIT_SIGNAL_FRAME) + { + return unw_init_local_common(cursor, uc, 0); + } + else + { + return -UNW_EINVAL; + } } #endif /* !UNW_REMOTE_ONLY */ diff --git a/src/mips/Ginit_local.c b/src/mips/Ginit_local.c index d24e9ea5..a29b6d09 100644 --- a/src/mips/Ginit_local.c +++ b/src/mips/Ginit_local.c @@ -57,9 +57,20 @@ unw_init_local(unw_cursor_t *cursor, ucontext_t *uc) } PROTECTED int -unw_init_local_signal(unw_cursor_t *cursor, ucontext_t *uc) +unw_init_local2 (unw_cursor_t *cursor, ucontext_t *uc, int flag) { - return unw_init_local_common(cursor, uc, 0); + if (!flag) + { + return unw_init_local_common(cursor, uc, 1); + } + else if (flag == UNW_INIT_SIGNAL_FRAME) + { + return unw_init_local_common(cursor, uc, 0); + } + else + { + return -UNW_EINVAL; + } } #endif /* !UNW_REMOTE_ONLY */ diff --git a/src/ppc/Ginit_local.c b/src/ppc/Ginit_local.c index 6c83b3b7..a05d4c8a 100644 --- a/src/ppc/Ginit_local.c +++ b/src/ppc/Ginit_local.c @@ -69,9 +69,20 @@ unw_init_local(unw_cursor_t *cursor, ucontext_t *uc) } PROTECTED int -unw_init_local_signal(unw_cursor_t *cursor, ucontext_t *uc) +unw_init_local2 (unw_cursor_t *cursor, ucontext_t *uc, int flag) { - return unw_init_local_common(cursor, uc, 0); + if (!flag) + { + return unw_init_local_common(cursor, uc, 1); + } + else if (flag == UNW_INIT_SIGNAL_FRAME) + { + return unw_init_local_common(cursor, uc, 0); + } + else + { + return -UNW_EINVAL; + } } #endif /* !UNW_REMOTE_ONLY */ diff --git a/src/sh/Ginit_local.c b/src/sh/Ginit_local.c index 598f708a..36d1329b 100644 --- a/src/sh/Ginit_local.c +++ b/src/sh/Ginit_local.c @@ -59,9 +59,20 @@ unw_init_local (unw_cursor_t *cursor, unw_context_t *uc) } PROTECTED int -unw_init_local_signal (unw_cursor_t *cursor, unw_context_t *uc) +unw_init_local2 (unw_cursor_t *cursor, ucontext_t *uc, int flag) { - return unw_init_local_common(cursor, uc, 0); + if (!flag) + { + return unw_init_local_common(cursor, uc, 1); + } + else if (flag == UNW_INIT_SIGNAL_FRAME) + { + return unw_init_local_common(cursor, uc, 0); + } + else + { + return -UNW_EINVAL; + } } #endif /* !UNW_REMOTE_ONLY */ diff --git a/src/tilegx/Ginit_local.c b/src/tilegx/Ginit_local.c index 800dc00f..6aa679f0 100644 --- a/src/tilegx/Ginit_local.c +++ b/src/tilegx/Ginit_local.c @@ -61,9 +61,20 @@ unw_init_local (unw_cursor_t *cursor, ucontext_t *uc) } PROTECTED int -unw_init_local_signal (unw_cursor_t *cursor, ucontext_t *uc) +unw_init_local2 (unw_cursor_t *cursor, ucontext_t *uc, int flag) { - return unw_init_local_common(cursor, uc, 0); + if (!flag) + { + return unw_init_local_common(cursor, uc, 1); + } + else if (flag == UNW_INIT_SIGNAL_FRAME) + { + return unw_init_local_common(cursor, uc, 0); + } + else + { + return -UNW_EINVAL; + } } #endif /* !UNW_REMOTE_ONLY */ diff --git a/src/x86/Ginit_local.c b/src/x86/Ginit_local.c index 025c84cb..88c52de3 100644 --- a/src/x86/Ginit_local.c +++ b/src/x86/Ginit_local.c @@ -60,9 +60,20 @@ unw_init_local (unw_cursor_t *cursor, ucontext_t *uc) } PROTECTED int -unw_init_local_signal (unw_cursor_t *cursor, ucontext_t *uc) +unw_init_local2 (unw_cursor_t *cursor, ucontext_t *uc, int flag) { - return unw_init_local_common(cursor, uc, 0); + if (!flag) + { + return unw_init_local_common(cursor, uc, 1); + } + else if (flag == UNW_INIT_SIGNAL_FRAME) + { + return unw_init_local_common(cursor, uc, 0); + } + else + { + return -UNW_EINVAL; + } } #endif /* !UNW_REMOTE_ONLY */ diff --git a/tests/check-namespace.sh.in b/tests/check-namespace.sh.in index 5c7eb0f0..7268cda4 100644 --- a/tests/check-namespace.sh.in +++ b/tests/check-namespace.sh.in @@ -99,7 +99,7 @@ check_local_unw_abi () { match _UL${plat}_get_reg match _UL${plat}_get_save_loc match _UL${plat}_init_local - match _UL${plat}_init_local_signal + match _UL${plat}_init_local2 match _UL${plat}_init_remote match _UL${plat}_is_signal_frame match _UL${plat}_handle_signal_frame @@ -205,7 +205,7 @@ check_generic_unw_abi () { match _U${plat}_get_reg match _U${plat}_get_save_loc match _U${plat}_init_local - match _U${plat}_init_local_signal + match _U${plat}_init_local2 match _U${plat}_init_remote match _U${plat}_is_signal_frame match _U${plat}_handle_signal_frame