Use uint64_t for SVE VQ

Message ID 20180601175331.53523-1-alan.hayward@arm.com
State New, archived
Headers

Commit Message

Alan Hayward June 1, 2018, 5:53 p.m. UTC
  Previously VQ was of type long. Using uint64_t ensures it always matches the
same type as the VG register.
Note that in the Linux kernel, VQ is 16bits. We cast it up to 64bits
immediately after reading to ensure we always use the same type throughout
the code.

This spatch was spun off Pedro's review here:
https://sourceware.org/ml/gdb-patches/2018-05/msg00862.html

Tested with other SVE patches under aarch64 SVE emulation.

2018-06-01  Alan Hayward  <alan.hayward@arm.com>

	* aarch64-tdep.c (aarch64_read_description): Use long for VQ.
	* aarch64-tdep.h (aarch64_read_description): Likewise.
	* arch/aarch64.c (aarch64_create_target_description): Likewise.
	* arch/aarch64.h (aarch64_create_target_description): Likewise.
	* features/aarch64-sve.c (create_feature_aarch64_sve): Likewise.
	* nat/aarch64-sve-linux-ptrace.c(aarch64_sve_get_vq): Likewise.
	* nat/aarch64-sve-linux-ptrace.h (aarch64_sve_get_vq): Likewise.
---
 gdb/aarch64-tdep.c                 | 2 +-
 gdb/aarch64-tdep.h                 | 2 +-
 gdb/arch/aarch64.c                 | 2 +-
 gdb/arch/aarch64.h                 | 2 +-
 gdb/features/aarch64-sve.c         | 2 +-
 gdb/nat/aarch64-sve-linux-ptrace.c | 2 +-
 gdb/nat/aarch64-sve-linux-ptrace.h | 2 +-
 7 files changed, 7 insertions(+), 7 deletions(-)
  

Comments

Pedro Alves June 2, 2018, 10:39 a.m. UTC | #1
On 06/01/2018 06:53 PM, Alan Hayward wrote:

> 2018-06-01  Alan Hayward  <alan.hayward@arm.com>
> 
> 	* aarch64-tdep.c (aarch64_read_description): Use long for VQ.

s/long/uint64_t/.

> --- a/gdb/aarch64-tdep.c
> +++ b/gdb/aarch64-tdep.c
> @@ -2856,7 +2856,7 @@ aarch64_displaced_step_hw_singlestep (struct gdbarch *gdbarch,
>     (It is not possible to set VQ to zero on an SVE system).  */
>  
>  const target_desc *
> -aarch64_read_description (long vq)
> +aarch64_read_description (uint64_t vq)
>  {
>    if (vq > AARCH64_MAX_SVE_VQ)
>      error (_("VQ is %ld, maximum supported value is %d"), vq,

This %ld needs to be updated to either use PRIu64 or pulongest.
There may be others, I haven't looked at the code, just the patch.

Otherwise OK.

Thanks,
Pedro Alves
  
Alan Hayward June 4, 2018, 10:02 a.m. UTC | #2
> On 2 Jun 2018, at 11:39, Pedro Alves <palves@redhat.com> wrote:

> 

> On 06/01/2018 06:53 PM, Alan Hayward wrote:

> 

>> 2018-06-01  Alan Hayward  <alan.hayward@arm.com>

>> 

>> 	* aarch64-tdep.c (aarch64_read_description): Use long for VQ.

> 

> s/long/uint64_t/.


Oops.

> 

>> --- a/gdb/aarch64-tdep.c

>> +++ b/gdb/aarch64-tdep.c

>> @@ -2856,7 +2856,7 @@ aarch64_displaced_step_hw_singlestep (struct gdbarch *gdbarch,

>>    (It is not possible to set VQ to zero on an SVE system).  */

>> 

>> const target_desc *

>> -aarch64_read_description (long vq)

>> +aarch64_read_description (uint64_t vq)

>> {

>>   if (vq > AARCH64_MAX_SVE_VQ)

>>     error (_("VQ is %ld, maximum supported value is %d"), vq,

> 

> This %ld needs to be updated to either use PRIu64 or pulongest.

> There may be others, I haven't looked at the code, just the patch.


I’m surprised this didn’t cause a warning build failure.
Fixed up with:
    error (_("VQ is %" PRIu64 ", maximum supported value is %d"), vq,

Double checked that there were no other prints of VQ/VG etc that
were added in my committed SVE patches.


> Otherwise OK.

> 


Pushed with the changes above.

Thanks!
Alan.
  

Patch

diff --git a/gdb/aarch64-tdep.c b/gdb/aarch64-tdep.c
index 1cd2015e08..218a7ea0cf 100644
--- a/gdb/aarch64-tdep.c
+++ b/gdb/aarch64-tdep.c
@@ -2856,7 +2856,7 @@  aarch64_displaced_step_hw_singlestep (struct gdbarch *gdbarch,
    (It is not possible to set VQ to zero on an SVE system).  */
 
 const target_desc *
-aarch64_read_description (long vq)
+aarch64_read_description (uint64_t vq)
 {
   if (vq > AARCH64_MAX_SVE_VQ)
     error (_("VQ is %ld, maximum supported value is %d"), vq,
diff --git a/gdb/aarch64-tdep.h b/gdb/aarch64-tdep.h
index c9fd7b3578..e41a5972d2 100644
--- a/gdb/aarch64-tdep.h
+++ b/gdb/aarch64-tdep.h
@@ -75,7 +75,7 @@  struct gdbarch_tdep
   int (*aarch64_syscall_record) (struct regcache *regcache, unsigned long svc_number);
 };
 
-const target_desc *aarch64_read_description (long vq);
+const target_desc *aarch64_read_description (uint64_t vq);
 
 extern int aarch64_process_record (struct gdbarch *gdbarch,
                                struct regcache *regcache, CORE_ADDR addr);
diff --git a/gdb/arch/aarch64.c b/gdb/arch/aarch64.c
index 495057488d..9b191315bc 100644
--- a/gdb/arch/aarch64.c
+++ b/gdb/arch/aarch64.c
@@ -26,7 +26,7 @@ 
 /* See arch/aarch64.h.  */
 
 target_desc *
-aarch64_create_target_description (long vq)
+aarch64_create_target_description (uint64_t vq)
 {
   target_desc *tdesc = allocate_target_description ();
 
diff --git a/gdb/arch/aarch64.h b/gdb/arch/aarch64.h
index 30f5360380..9040d8d4c8 100644
--- a/gdb/arch/aarch64.h
+++ b/gdb/arch/aarch64.h
@@ -26,7 +26,7 @@ 
    the presence of SVE and the Vector Quotient - the number of 128bit chunks in
    an SVE Z register.  */
 
-target_desc *aarch64_create_target_description (long vq);
+target_desc *aarch64_create_target_description (uint64_t vq);
 
 /* Register numbers of various important registers.
    Note that on SVE, the Z registers reuse the V register numbers and the V
diff --git a/gdb/features/aarch64-sve.c b/gdb/features/aarch64-sve.c
index a020e4d393..71be67c3fb 100644
--- a/gdb/features/aarch64-sve.c
+++ b/gdb/features/aarch64-sve.c
@@ -23,7 +23,7 @@ 
 
 static int
 create_feature_aarch64_sve (struct target_desc *result, long regnum,
-			    int scale)
+			    uint64_t scale)
 {
   struct tdesc_feature *feature;
   tdesc_type *element_type, *field_type;
diff --git a/gdb/nat/aarch64-sve-linux-ptrace.c b/gdb/nat/aarch64-sve-linux-ptrace.c
index 3a1dbae709..119656b886 100644
--- a/gdb/nat/aarch64-sve-linux-ptrace.c
+++ b/gdb/nat/aarch64-sve-linux-ptrace.c
@@ -27,7 +27,7 @@ 
 
 /* See nat/aarch64-sve-linux-ptrace.h.  */
 
-unsigned long
+uint64_t
 aarch64_sve_get_vq (int tid)
 {
   struct iovec iovec;
diff --git a/gdb/nat/aarch64-sve-linux-ptrace.h b/gdb/nat/aarch64-sve-linux-ptrace.h
index a32ddf1676..61f841466c 100644
--- a/gdb/nat/aarch64-sve-linux-ptrace.h
+++ b/gdb/nat/aarch64-sve-linux-ptrace.h
@@ -32,7 +32,7 @@ 
 /* Read VQ for the given tid using ptrace.  If SVE is not supported then zero
    is returned (on a system that supports SVE, then VQ cannot be zero).  */
 
-extern unsigned long aarch64_sve_get_vq (int tid);
+uint64_t aarch64_sve_get_vq (int tid);
 
 /* Structures and defines taken from sigcontext.h.  */