This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH] break gdb build on 32-bit host with ADI support


The problem of failing to build with arm-linux-gnueabihf-g++-4.8 was
that type CORE_ADDR is of "unsigned long" on a 64-bit machine but is
of type "unsigned long long" on a 32 bit system, which caused type
mismatch when passing arguments or printing errors.

Fixed the problem in three places - (1) change type of "blksize" and "nbits"
in struct adi_stat_t to "unsigned long long"; (2) explicitly cast argument 3
type when calling target_auxv_search(); (2) use %llx with explicit cast when
printing type CORE_ADDR in either printf_filtered() or error().
---
 gdb/sparc64-tdep.c |   21 ++++++++++++---------
 1 files changed, 12 insertions(+), 9 deletions(-)

diff --git a/gdb/sparc64-tdep.c b/gdb/sparc64-tdep.c
index 6f4fca7..0da2ae5 100644
--- a/gdb/sparc64-tdep.c
+++ b/gdb/sparc64-tdep.c
@@ -90,12 +90,12 @@ static struct cmd_list_element *sparc64adilist = NULL;
 typedef struct
 {
   /* The ADI block size.  */
-  unsigned long blksize;
+  unsigned long long blksize;
 
   /* Number of bits used for an ADI version tag which can be
    * used together with the shift value for an ADI version tag
    * to encode or extract the ADI version value in a pointer.  */
-  unsigned long nbits;
+  unsigned long long nbits;
 
   /* The maximum ADI version tag value supported.  */
   int max_version;
@@ -223,9 +223,10 @@ adi_available (void)
 
   proc->stat.checked_avail = true;
   if (target_auxv_search (&current_target, AT_ADI_BLKSZ, 
-                          &proc->stat.blksize) <= 0)
+                          (CORE_ADDR *)&proc->stat.blksize) <= 0)
     return false;
-  target_auxv_search (&current_target, AT_ADI_NBITS, &proc->stat.nbits);
+  target_auxv_search (&current_target, AT_ADI_NBITS, 
+                      (CORE_ADDR *)&proc->stat.nbits);
   proc->stat.max_version = (1 << proc->stat.nbits) - 2;
   proc->stat.is_avail = true;
 
@@ -346,7 +347,8 @@ adi_read_versions (CORE_ADDR vaddr, size_t size, unsigned char *tags)
   if (!adi_is_addr_mapped (vaddr, size))
     {
       adi_stat_t ast = get_adi_info (ptid_get_pid (inferior_ptid));
-      error(_("Address at 0x%lx is not in ADI maps"), vaddr*ast.blksize);
+      error(_("Address at 0x%llx is not in ADI maps"), 
+            (long long)(vaddr*ast.blksize));
     }
 
   int target_errno;
@@ -366,7 +368,8 @@ adi_write_versions (CORE_ADDR vaddr, size_t size, unsigned char *tags)
   if (!adi_is_addr_mapped (vaddr, size))
     {
       adi_stat_t ast = get_adi_info (ptid_get_pid (inferior_ptid));
-      error(_("Address at 0x%lx is not in ADI maps"), vaddr*ast.blksize);
+      error(_("Address at 0x%llx is not in ADI maps"), 
+            (long long)(vaddr*ast.blksize));
     }
 
   int target_errno;
@@ -387,7 +390,7 @@ adi_print_versions (CORE_ADDR vaddr, size_t cnt, unsigned char *tags)
   while (cnt > 0)
     {
       QUIT;
-      printf_filtered ("0x%016lx:\t", vaddr * adi_stat.blksize);
+      printf_filtered ("0x%016llx:\t", (long long)(vaddr*adi_stat.blksize));
       for (int i = maxelts; i > 0 && cnt > 0; i--, cnt--)
         {
           if (tags[v_idx] == 0xff)    /* no version tag */
@@ -418,7 +421,7 @@ do_examine (CORE_ADDR start, int bcnt)
   if (read_cnt == -1)
     error (_("No ADI information"));
   else if (read_cnt < cnt)
-    error(_("No ADI information at 0x%lx"), vaddr);
+    error(_("No ADI information at 0x%llx"), (long long)vaddr);
 
   adi_print_versions (vstart, cnt, buf);
 
@@ -438,7 +441,7 @@ do_assign (CORE_ADDR start, size_t bcnt, int version)
   if (set_cnt == -1)
     error (_("No ADI information"));
   else if (set_cnt < cnt)
-    error(_("No ADI information at 0x%lx"), vaddr);
+    error(_("No ADI information at 0x%llx"), (long long)vaddr);
 
 }
 
-- 
1.7.1


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]