[PATCH 20/30] bsd-user/signal.c: core_dump_signal

Warner Losh posted 30 patches 4 years ago
There is a newer version of this series
[PATCH 20/30] bsd-user/signal.c: core_dump_signal
Posted by Warner Losh 4 years ago
Returns 1 for signals that cause core files.

Signed-off-by: Stacey Son <sson@FreeBSD.org>
Signed-off-by: Kyle Evans <kevans@freebsd.org>
Signed-off-by: Warner Losh <imp@bsdimp.com>
---
 bsd-user/signal.c | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)

diff --git a/bsd-user/signal.c b/bsd-user/signal.c
index a6e07277fb2..824535be8b8 100644
--- a/bsd-user/signal.c
+++ b/bsd-user/signal.c
@@ -92,6 +92,23 @@ static inline void host_to_target_siginfo_noswap(target_siginfo_t *tinfo,
     }
 }
 
+/* Returns 1 if given signal should dump core if not handled. */
+static int core_dump_signal(int sig)
+{
+    switch (sig) {
+    case TARGET_SIGABRT:
+    case TARGET_SIGFPE:
+    case TARGET_SIGILL:
+    case TARGET_SIGQUIT:
+    case TARGET_SIGSEGV:
+    case TARGET_SIGTRAP:
+    case TARGET_SIGBUS:
+        return 1;
+    default:
+        return 0;
+    }
+}
+
 /*
  * Queue a signal so that it will be send to the virtual CPU as soon as
  * possible.
-- 
2.33.1


Re: [PATCH 20/30] bsd-user/signal.c: core_dump_signal
Posted by Peter Maydell 4 years ago
On Sun, 9 Jan 2022 at 16:48, Warner Losh <imp@bsdimp.com> wrote:
>
> Returns 1 for signals that cause core files.
>
> Signed-off-by: Stacey Son <sson@FreeBSD.org>
> Signed-off-by: Kyle Evans <kevans@freebsd.org>
> Signed-off-by: Warner Losh <imp@bsdimp.com>
> ---
>  bsd-user/signal.c | 17 +++++++++++++++++
>  1 file changed, 17 insertions(+)
>
> diff --git a/bsd-user/signal.c b/bsd-user/signal.c
> index a6e07277fb2..824535be8b8 100644
> --- a/bsd-user/signal.c
> +++ b/bsd-user/signal.c
> @@ -92,6 +92,23 @@ static inline void host_to_target_siginfo_noswap(target_siginfo_t *tinfo,
>      }
>  }
>
> +/* Returns 1 if given signal should dump core if not handled. */
> +static int core_dump_signal(int sig)
> +{
> +    switch (sig) {
> +    case TARGET_SIGABRT:
> +    case TARGET_SIGFPE:
> +    case TARGET_SIGILL:
> +    case TARGET_SIGQUIT:
> +    case TARGET_SIGSEGV:
> +    case TARGET_SIGTRAP:
> +    case TARGET_SIGBUS:
> +        return 1;
> +    default:
> +        return 0;
> +    }
> +}

Code is fine, but since this is a static function with no callers
the compiler is going to emit a warning about that. It's a small
function, so the easiest thing is just to squash this into the
following patch which is what adds the code that calls it.

thanks
-- PMM

Re: [PATCH 20/30] bsd-user/signal.c: core_dump_signal
Posted by Warner Losh 4 years ago
On Thu, Jan 13, 2022 at 1:22 PM Peter Maydell <peter.maydell@linaro.org>
wrote:

> On Sun, 9 Jan 2022 at 16:48, Warner Losh <imp@bsdimp.com> wrote:
> >
> > Returns 1 for signals that cause core files.
> >
> > Signed-off-by: Stacey Son <sson@FreeBSD.org>
> > Signed-off-by: Kyle Evans <kevans@freebsd.org>
> > Signed-off-by: Warner Losh <imp@bsdimp.com>
> > ---
> >  bsd-user/signal.c | 17 +++++++++++++++++
> >  1 file changed, 17 insertions(+)
> >
> > diff --git a/bsd-user/signal.c b/bsd-user/signal.c
> > index a6e07277fb2..824535be8b8 100644
> > --- a/bsd-user/signal.c
> > +++ b/bsd-user/signal.c
> > @@ -92,6 +92,23 @@ static inline void
> host_to_target_siginfo_noswap(target_siginfo_t *tinfo,
> >      }
> >  }
> >
> > +/* Returns 1 if given signal should dump core if not handled. */
> > +static int core_dump_signal(int sig)
> > +{
> > +    switch (sig) {
> > +    case TARGET_SIGABRT:
> > +    case TARGET_SIGFPE:
> > +    case TARGET_SIGILL:
> > +    case TARGET_SIGQUIT:
> > +    case TARGET_SIGSEGV:
> > +    case TARGET_SIGTRAP:
> > +    case TARGET_SIGBUS:
> > +        return 1;
> > +    default:
> > +        return 0;
> > +    }
> > +}
>
> Code is fine, but since this is a static function with no callers
> the compiler is going to emit a warning about that. It's a small
> function, so the easiest thing is just to squash this into the
> following patch which is what adds the code that calls it.
>

Sure thing. I'm still trying to get a feel for right-sizing the chunking...
Since the warning didn't fail the compile, I thought it would be OK,
but can easily fold this in with the first patch to use it.

Warner
Re: [PATCH 20/30] bsd-user/signal.c: core_dump_signal
Posted by Peter Maydell 4 years ago
On Thu, 13 Jan 2022 at 20:28, Warner Losh <imp@bsdimp.com> wrote:
> On Thu, Jan 13, 2022 at 1:22 PM Peter Maydell <peter.maydell@linaro.org> wrote:
>> Code is fine, but since this is a static function with no callers
>> the compiler is going to emit a warning about that. It's a small
>> function, so the easiest thing is just to squash this into the
>> following patch which is what adds the code that calls it.
>
>
> Sure thing. I'm still trying to get a feel for right-sizing the chunking...
> Since the warning didn't fail the compile, I thought it would be OK,
> but can easily fold this in with the first patch to use it.

Ah yes, we don't currently default-enable -Werror for BSD hosts
in configure (only for Linux and for mingw32). So in this particular
case it doesn't matter much, but we might as well do it the way we would
for code that's not BSD-specific.

thanks
-- PMM

Re: [PATCH 20/30] bsd-user/signal.c: core_dump_signal
Posted by Richard Henderson 4 years ago
On 1/10/22 3:19 AM, Warner Losh wrote:
> Returns 1 for signals that cause core files.
> 
> Signed-off-by: Stacey Son<sson@FreeBSD.org>
> Signed-off-by: Kyle Evans<kevans@freebsd.org>
> Signed-off-by: Warner Losh<imp@bsdimp.com>
> ---
>   bsd-user/signal.c | 17 +++++++++++++++++
>   1 file changed, 17 insertions(+)

Reviewed-by: Richard Henderson <richard.henderson@linaro.org>

r~