]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
gdb.base/coremaker2.c: Fix compilation problems for x86_64 -m32 multilib
authorKevin Buettner <kevinb@redhat.com>
Fri, 31 Jul 2020 03:51:40 +0000 (20:51 -0700)
committerKevin Buettner <kevinb@redhat.com>
Fri, 31 Jul 2020 16:34:58 +0000 (09:34 -0700)
There are compilation warnings / errors when compiling coremaker2.c
for the gdb.base/corefile2.exp tests.  Here's the command to use
on x86_64 linux:

make check RUNTESTFLAGS="--target_board unix/-m32" \
           TESTS="gdb.base/corefile2.exp"

These are the warnings / errors - I've shortened the paths somewhat:

gdb compile failed, gdb/testsuite/gdb.base/coremaker2.c: In function 'main':
gdb/testsuite/gdb.base/coremaker2.c:106:11: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]
  106 |   addr = ((unsigned long long) buf_ro + pagesize) & ~(pagesize - 1);
      |           ^
gdb/testsuite/gdb.base/coremaker2.c:108:15: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]
  108 |   if (addr <= (unsigned long long) buf_ro
      |               ^
gdb/testsuite/gdb.base/coremaker2.c:109:18: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]
  109 |       || addr >= (unsigned long long) buf_ro + sizeof (buf_ro))
      |                  ^
gdb/testsuite/gdb.base/coremaker2.c:115:19: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
  115 |   mbuf_ro = mmap ((void *) addr, pagesize, PROT_READ,
      |                   ^
gdb/testsuite/gdb.base/coremaker2.c:130:11: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]
  130 |   addr = ((unsigned long long) buf_rw + pagesize) & ~(pagesize - 1);
      |           ^
gdb/testsuite/gdb.base/coremaker2.c:132:15: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]
  132 |   if (addr <= (unsigned long long) buf_rw
      |               ^
gdb/testsuite/gdb.base/coremaker2.c:133:18: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]
  133 |       || addr >= (unsigned long long) buf_rw + sizeof (buf_rw))
      |                  ^
gdb/testsuite/gdb.base/coremaker2.c:139:19: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
  139 |   mbuf_rw = mmap ((void *) addr, pagesize, PROT_READ,
      |                   ^

These were fixed by changing unsigned long long to uintptr_t.

Tested on either rawhide or Fedora 32 with architectures: x86_64,
x86_64/-m32, aarch64, s390x, and ppc64le.

gdb/testsuite/ChangeLog:

* gdb.base/coremaker2.c: Change all uses of 'unsigned long long'
to 'uintptr_t'
(inttypes.h): Include.

gdb/testsuite/ChangeLog
gdb/testsuite/gdb.base/coremaker2.c

index 4e7bcbe6ac6d32a7a7adef5fa444220f7e0da166..29dc46aad79bd67cda612bf1448400ac4e1db2f7 100644 (file)
@@ -1,3 +1,9 @@
+2020-07-31  Kevin Buettner  <kevinb@redhat.com>
+
+       * gdb.base/coremaker2.c: Change all uses of 'unsigned long long'
+       to 'uintptr_t'
+       (inttypes.h): Include.
+
 2020-07-31  Kevin Buettner  <kevinb@redhat.com>
 
        * gdb.base/coremaker2.c (buf_rw): Increase size to 256 KiB.
index 3c89bd790bd6ad9aca0aa038b567012e4a9d788a..d50ed5c0c6eb1fc5ffe4c12ea2d70fac57a0b1c3 100644 (file)
 #include <unistd.h>
 #include <string.h>
 #include <errno.h>
+#include <inttypes.h>
 
 /* These are globals so that we can find them easily when debugging
    the core file.  */
 long pagesize;
-unsigned long long addr;
+uintptr_t addr;
 char *mbuf_ro;
 char *mbuf_rw;
 
@@ -106,10 +107,10 @@ main (int argc, char **argv)
     }
 
   /* Compute an address that should be within buf_ro.  Complain if not.  */
-  addr = ((unsigned long long) buf_ro + pagesize) & ~(pagesize - 1);
+  addr = ((uintptr_t) buf_ro + pagesize) & ~(pagesize - 1);
 
-  if (addr <= (unsigned long long) buf_ro
-      || addr >= (unsigned long long) buf_ro + sizeof (buf_ro))
+  if (addr <= (uintptr_t) buf_ro
+      || addr >= (uintptr_t) buf_ro + sizeof (buf_ro))
     {
       fprintf (stderr, "Unable to compute a suitable address within buf_ro.\n");
       exit (1);
@@ -130,10 +131,10 @@ main (int argc, char **argv)
 
   /* Compute an mmap address within buf_rw.  Complain if it's somewhere
      else.  */
-  addr = ((unsigned long long) buf_rw + pagesize) & ~(pagesize - 1);
+  addr = ((uintptr_t) buf_rw + pagesize) & ~(pagesize - 1);
 
-  if (addr <= (unsigned long long) buf_rw
-      || addr >= (unsigned long long) buf_rw + sizeof (buf_rw))
+  if (addr <= (uintptr_t) buf_rw
+      || addr >= (uintptr_t) buf_rw + sizeof (buf_rw))
     {
       fprintf (stderr, "Unable to compute a suitable address within buf_rw.\n");
       exit (1);