poke-devel
[Top][All Lists]
Advanced

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

Re: [PATCH] pvm: Improve PVM assertions by reporting more info


From: Jose E. Marchesi
Subject: Re: [PATCH] pvm: Improve PVM assertions by reporting more info
Date: Sun, 10 Apr 2022 01:36:42 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux)

Hi Mohammad.

This looks good, but I have two suggestions:

1) To s/pvm_assert/PVM_ASSERT and use upper-case macro names as is our
   convention.

2) To s/pvm_assert_full/pvm_assert/

wdyt?

> 2022-04-09  Mohammad-Reza Nabipoor  <mnabipoor@gnu.org>
>
>       * libpoke/pvm.h (pvm_assert_full): New function.
>       (pvm_assert): Changed to a macro that calls `pvm_assert_full`.
>       * libpoke/pvm.c (pvm_assert): Removed.
>       (pvm_assert_full): New function.
>       * libpoke/pvm.jitter (wrapped-functions):
>       s/pvm_assert/pvm_assert_full/.
> ---
>  ChangeLog          |  9 +++++++++
>  libpoke/pvm.c      | 15 +++++++++++++--
>  libpoke/pvm.h      | 12 ++++++++++--
>  libpoke/pvm.jitter |  2 +-
>  4 files changed, 33 insertions(+), 5 deletions(-)
>
> diff --git a/ChangeLog b/ChangeLog
> index 028753ab..f4f5278f 100644
> --- a/ChangeLog
> +++ b/ChangeLog
> @@ -1,3 +1,12 @@
> +2022-04-09  Mohammad-Reza Nabipoor  <mnabipoor@gnu.org>
> +
> +     * libpoke/pvm.h (pvm_assert_full): New function.
> +     (pvm_assert): Changed to a macro that calls `pvm_assert_full`.
> +     * libpoke/pvm.c (pvm_assert): Removed.
> +     (pvm_assert_full): New function.
> +     * libpoke/pvm.jitter (wrapped-functions):
> +     s/pvm_assert/pvm_assert_full/.
> +
>  2022-04-09  Jose E. Marchesi  <jemarch@gnu.org>
>  
>       * pickles/openpgp.pk: New file.
> diff --git a/libpoke/pvm.c b/libpoke/pvm.c
> index 5aa3f5bf..5c543b56 100644
> --- a/libpoke/pvm.c
> +++ b/libpoke/pvm.c
> @@ -373,7 +373,18 @@ pvm_set_compiler (pvm apvm, pkl_compiler compiler)
>  }
>  
>  void
> -pvm_assert (int expression)
> +pvm_assert_full (int expression, const char *expression_str,
> +                 const char *filename, int line)
>  {
> -  assert (expression);
> +#ifndef NDEBUG
> +
> +  if (!expression)
> +    {
> +      fprintf (stderr, "PVM assertion failed: %s (%s:%d)\n", expression_str,
> +               filename, line);
> +      fflush (NULL);
> +      abort ();
> +    }
> +
> +#endif
>  }
> diff --git a/libpoke/pvm.h b/libpoke/pvm.h
> index 1ca3d241..6bf27851 100644
> --- a/libpoke/pvm.h
> +++ b/libpoke/pvm.h
> @@ -728,9 +728,17 @@ void pvm_set_compiler (pvm vm, pkl_compiler compiler);
>  
>  /* The following function is to be used in pvm.jitter, because the
>     system `assert' may expand to a macro and is therefore
> -   non-wrappeable.  */
> +   non-wrappeable.
>  
> -void pvm_assert (int expression);
> +   EXPRESSION is the predicate that is expected to be non-zero.
> +   EXPRESSION_STR is the string representation of the EXPRESSION.
> +   FILENAME and LINE are the location information of invocation
> +   of this function.  */
> +
> +void pvm_assert_full (int expression, const char *expression_str,
> +                      const char *filename, int line);
> +
> +#define pvm_assert(expr) pvm_assert_full ((expr), #expr, __FILE__, __LINE__)
>  
>  /* This is defined in the late-c block in pvm.jitter.  */
>  
> diff --git a/libpoke/pvm.jitter b/libpoke/pvm.jitter
> index 2a40de39..8e56ad40 100644
> --- a/libpoke/pvm.jitter
> +++ b/libpoke/pvm.jitter
> @@ -69,7 +69,7 @@ wrapped-functions
>    snprintf
>    pvm_array_insert
>    pvm_array_set
> -  pvm_assert
> +  pvm_assert_full
>    pvm_env_lookup
>    pvm_env_register
>    pvm_env_pop_frame



reply via email to

[Prev in Thread] Current Thread [Next in Thread]