diff mbox series

[RISU,v2,15/17] Compute reginfo_size based on the reginfo

Message ID 20200519025355.4420-16-richard.henderson@linaro.org
State New
Headers show
Series risu cleanups and improvements | expand

Commit Message

Richard Henderson May 19, 2020, 2:53 a.m. UTC
This will allow dumping of SVE frames without having
to know the SVE vector length beforehand.

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

---
 risu.h                 | 2 +-
 reginfo.c              | 6 +++---
 risu_reginfo_aarch64.c | 4 ++--
 risu_reginfo_arm.c     | 2 +-
 risu_reginfo_i386.c    | 2 +-
 risu_reginfo_m68k.c    | 2 +-
 risu_reginfo_ppc64.c   | 2 +-
 7 files changed, 10 insertions(+), 10 deletions(-)

-- 
2.20.1

Comments

Alex Bennée May 20, 2020, 5:30 p.m. UTC | #1
Richard Henderson <richard.henderson@linaro.org> writes:

> This will allow dumping of SVE frames without having

> to know the SVE vector length beforehand.

>

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

> ---

>  risu.h                 | 2 +-

>  reginfo.c              | 6 +++---

>  risu_reginfo_aarch64.c | 4 ++--

>  risu_reginfo_arm.c     | 2 +-

>  risu_reginfo_i386.c    | 2 +-

>  risu_reginfo_m68k.c    | 2 +-

>  risu_reginfo_ppc64.c   | 2 +-

>  7 files changed, 10 insertions(+), 10 deletions(-)

>

> diff --git a/risu.h b/risu.h

> index eeb6775..054cef7 100644

> --- a/risu.h

> +++ b/risu.h

> @@ -155,6 +155,6 @@ int reginfo_dump(struct reginfo *ri, FILE * f);

>  int reginfo_dump_mismatch(struct reginfo *m, struct reginfo *a, FILE *f);

>  

>  /* return size of reginfo */

> -const int reginfo_size(void);

> +int reginfo_size(struct reginfo *ri);

>  

>  #endif /* RISU_H */

> diff --git a/reginfo.c b/reginfo.c

> index f187d9c..411c2a6 100644

> --- a/reginfo.c

> +++ b/reginfo.c

> @@ -38,7 +38,7 @@ RisuResult send_register_info(void *uc)

>      case OP_TESTEND:

>      case OP_COMPARE:

>      case OP_SIGILL:

> -        header.size = reginfo_size();

> +        header.size = reginfo_size(&ri);

>          extra = &ri;

>          break;

>  

> @@ -109,7 +109,7 @@ RisuResult recv_and_compare_register_info(void *uc)

>      case OP_TESTEND:

>      case OP_COMPARE:

>      case OP_SIGILL:

> -        extra_size = reginfo_size();

> +        extra_size = reginfo_size(&master_ri);

>          break;

>      case OP_SETMEMBLOCK:

>      case OP_GETMEMBLOCK:

> @@ -217,7 +217,7 @@ void report_mismatch_header(void)

>          case OP_COMPARE:

>          case OP_SIGILL:

>              kind = "reginfo";

> -            a_sz = reginfo_size();

> +            a_sz = reginfo_size(&apprentice_ri);

>              break;

>          case OP_SETMEMBLOCK:

>          case OP_GETMEMBLOCK:

> diff --git a/risu_reginfo_aarch64.c b/risu_reginfo_aarch64.c

> index 028c690..7044648 100644

> --- a/risu_reginfo_aarch64.c

> +++ b/risu_reginfo_aarch64.c

> @@ -69,7 +69,7 @@ void process_arch_opt(int opt, const char *arg)

>  #endif

>  }

>  

> -const int reginfo_size(void)

> +int reginfo_size(struct reginfo *ri)

>  {

>      int size = offsetof(struct reginfo, simd.end);

>  #ifdef SVE_MAGIC

> @@ -194,7 +194,7 @@ void reginfo_init(struct reginfo *ri, ucontext_t *uc)

>  /* reginfo_is_eq: compare the reginfo structs, returns nonzero if equal */

>  int reginfo_is_eq(struct reginfo *r1, struct reginfo *r2)

>  {

> -    return memcmp(r1, r2, reginfo_size()) == 0;

> +    return memcmp(r1, r2, reginfo_size(r1)) == 0;

>  }

>  

>  #ifdef SVE_MAGIC

> diff --git a/risu_reginfo_arm.c b/risu_reginfo_arm.c

> index 3662f12..3832e27 100644

> --- a/risu_reginfo_arm.c

> +++ b/risu_reginfo_arm.c

> @@ -36,7 +36,7 @@ void process_arch_opt(int opt, const char *arg)

>      abort();

>  }

>  

> -const int reginfo_size(void)

> +int reginfo_size(struct reginfo *ri)

>  {

>      return sizeof(struct reginfo);


I wonder if the fixed size architectures should return (sizeof *ri) to
reinforce the point? Anyway:

Reviewed-by: Alex Bennée <alex.bennee@linaro.org>


-- 
Alex Bennée
diff mbox series

Patch

diff --git a/risu.h b/risu.h
index eeb6775..054cef7 100644
--- a/risu.h
+++ b/risu.h
@@ -155,6 +155,6 @@  int reginfo_dump(struct reginfo *ri, FILE * f);
 int reginfo_dump_mismatch(struct reginfo *m, struct reginfo *a, FILE *f);
 
 /* return size of reginfo */
-const int reginfo_size(void);
+int reginfo_size(struct reginfo *ri);
 
 #endif /* RISU_H */
diff --git a/reginfo.c b/reginfo.c
index f187d9c..411c2a6 100644
--- a/reginfo.c
+++ b/reginfo.c
@@ -38,7 +38,7 @@  RisuResult send_register_info(void *uc)
     case OP_TESTEND:
     case OP_COMPARE:
     case OP_SIGILL:
-        header.size = reginfo_size();
+        header.size = reginfo_size(&ri);
         extra = &ri;
         break;
 
@@ -109,7 +109,7 @@  RisuResult recv_and_compare_register_info(void *uc)
     case OP_TESTEND:
     case OP_COMPARE:
     case OP_SIGILL:
-        extra_size = reginfo_size();
+        extra_size = reginfo_size(&master_ri);
         break;
     case OP_SETMEMBLOCK:
     case OP_GETMEMBLOCK:
@@ -217,7 +217,7 @@  void report_mismatch_header(void)
         case OP_COMPARE:
         case OP_SIGILL:
             kind = "reginfo";
-            a_sz = reginfo_size();
+            a_sz = reginfo_size(&apprentice_ri);
             break;
         case OP_SETMEMBLOCK:
         case OP_GETMEMBLOCK:
diff --git a/risu_reginfo_aarch64.c b/risu_reginfo_aarch64.c
index 028c690..7044648 100644
--- a/risu_reginfo_aarch64.c
+++ b/risu_reginfo_aarch64.c
@@ -69,7 +69,7 @@  void process_arch_opt(int opt, const char *arg)
 #endif
 }
 
-const int reginfo_size(void)
+int reginfo_size(struct reginfo *ri)
 {
     int size = offsetof(struct reginfo, simd.end);
 #ifdef SVE_MAGIC
@@ -194,7 +194,7 @@  void reginfo_init(struct reginfo *ri, ucontext_t *uc)
 /* reginfo_is_eq: compare the reginfo structs, returns nonzero if equal */
 int reginfo_is_eq(struct reginfo *r1, struct reginfo *r2)
 {
-    return memcmp(r1, r2, reginfo_size()) == 0;
+    return memcmp(r1, r2, reginfo_size(r1)) == 0;
 }
 
 #ifdef SVE_MAGIC
diff --git a/risu_reginfo_arm.c b/risu_reginfo_arm.c
index 3662f12..3832e27 100644
--- a/risu_reginfo_arm.c
+++ b/risu_reginfo_arm.c
@@ -36,7 +36,7 @@  void process_arch_opt(int opt, const char *arg)
     abort();
 }
 
-const int reginfo_size(void)
+int reginfo_size(struct reginfo *ri)
 {
     return sizeof(struct reginfo);
 }
diff --git a/risu_reginfo_i386.c b/risu_reginfo_i386.c
index 60fc239..902d33e 100644
--- a/risu_reginfo_i386.c
+++ b/risu_reginfo_i386.c
@@ -74,7 +74,7 @@  void process_arch_opt(int opt, const char *arg)
     }
 }
 
-const int reginfo_size(void)
+int reginfo_size(struct reginfo *ri)
 {
     return sizeof(struct reginfo);
 }
diff --git a/risu_reginfo_m68k.c b/risu_reginfo_m68k.c
index 32b28c8..361f172 100644
--- a/risu_reginfo_m68k.c
+++ b/risu_reginfo_m68k.c
@@ -23,7 +23,7 @@  void process_arch_opt(int opt, const char *arg)
     abort();
 }
 
-const int reginfo_size(void)
+int reginfo_size(struct reginfo *ri)
 {
     return sizeof(struct reginfo);
 }
diff --git a/risu_reginfo_ppc64.c b/risu_reginfo_ppc64.c
index 071c951..c86313c 100644
--- a/risu_reginfo_ppc64.c
+++ b/risu_reginfo_ppc64.c
@@ -32,7 +32,7 @@  void process_arch_opt(int opt, const char *arg)
     abort();
 }
 
-const int reginfo_size(void)
+int reginfo_size(struct reginfo *ri)
 {
     return sizeof(struct reginfo);
 }