build failure on IRIX when building with Python support.
authorJoel Brobecker <brobecker@gnat.com>
Tue, 14 Dec 2010 07:17:15 +0000 (07:17 +0000)
committerJoel Brobecker <brobecker@gnat.com>
Tue, 14 Dec 2010 07:17:15 +0000 (07:17 +0000)
This is a nasty interaction between Python and GDB. Basically,
Python causes some macros to be unilaterally defined in order
to turns some features on:

    /* Define to activate features from IEEE Stds 1003.1-2001 */
    #define _POSIX_C_SOURCE 200112L

    /* Define to the level of X/Open that your system supports */
    #define _XOPEN_SOURCE 600

But the problem is that they turn off defines provided by some
system headers on which we depend. Namely:

  * sys/siginfo.h:

        #if _SGIAPI
        #define siginfo __siginfo
        #endif

  * sys/ucontext.h:

        #if _SGIAPI && !defined(__SGI_NOUCONTEXT_COMPAT)
        [...]
        #define fp_r            __fp_r
        [...]
        #define fp_csr          __fp_csr
        [...]
        #endif

The important macro here is _SGIAPI, defined as follow in standards.h:

        #define _SGIAPI ((defined(_SGI_SOURCE) && \
                                _NO_POSIX && _NO_XOPEN4 && _NO_XOPEN5) || \
                        (_ANSIMODE && _NO_POSIX && _NO_XOPEN4 && _NO_XOPEN5))

If one builds GDB without Python, then _SGIAPI is true, and all is fine.
But building with Python causes both _POSIX_C_SOURCE and _XOPEN_SOURCE
to trip all the _NO_[...] tests (_NO_POSIX, _NO_XOPEN4, _NO_XOPEN5).
And so we get build failures because we try to use undefined types, or
non-existent component names inside the regset structure.

The latter problem is observed only within irix5-nat.c, which means
that it is specific to IRIX.  So it's easy to write the code in a way
that it does not require the macros (just use the real component names,
rather than relying on the macros to do the translation).

The former, on the other hand, is a little trickier, because the problem
occurs inside a generic unit (procfs.c). The solution I chose was to
adjust the configure script to add -Dsiginfo=__siginfo to the CPPFLAGS
if building with python using GCC on IRIX.

We hadn't seen this sort of issue up to now because the affect units
have not been dependent on the python includes up to now.  Recent changes
have made them indirectly dependent on Python, thus triggering the issues.

gdb/ChangeLog:

        * irix5-nat.c: Replace fp_r, fp_regs and fp_scr by __fp_r, __fp_regs
        and __fp_scr respectively throughout.
        * configure.ac: Compile with -Dsiginfo=__siginfo if building with
        Python using GCC on IRIX.
        * configure: Regenerate.

gdb/ChangeLog
gdb/configure
gdb/configure.ac
gdb/irix5-nat.c

index 620cccce6d80ef14427f299a4789ed41d440a0a8..379beb2928fbf72b50ac2df3686e5d67c7f4bd1f 100644 (file)
@@ -1,3 +1,11 @@
+2010-12-14  Joel Brobecker  <brobecker@adacore.com>
+
+       * irix5-nat.c: Replace fp_r, fp_regs and fp_scr by __fp_r, __fp_regs
+       and __fp_scr respectively throughout.
+       * configure.ac: Compile with -Dsiginfo=__siginfo if building with
+       Python using GCC on IRIX.
+       * configure: Regenerate.
+
 2010-12-13  Kevin Buettner  <kevinb@redhat.com>
 
        * solib-svr4.c (enable_break): Don't attempt to place breakpoints,
index 2bc49d6a6670a2cffb0ab9ae06d88cfcdf1dae1c..6ea3f58bbc0f71eae5d848b6cb6789ebd0033ee2 100755 (executable)
@@ -10964,6 +10964,21 @@ rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
     { $as_echo "$as_me:${as_lineno-$LINENO}: result: ${PYTHON_CFLAGS}" >&5
 $as_echo "${PYTHON_CFLAGS}" >&6; }
   fi
+
+  # On IRIX, type siginfo is not defined.  Instead, sys/siginfo.h provides:
+  #    #if _SGIAPI
+  #    #define siginfo __siginfo
+  #    #endif
+  # The problem is that including Python causes some XOPEN macros to be
+  # unilaterally defined, and that in turn causes _SGIAPI to evaluate
+  # to false.  So, we work around this issue by defining siginfo ourself
+  # though the command-line.
+  case "$gdb_host" in
+    irix*) if test "${GCC}" = yes; then
+             CPPFLAGS="$CPPFLAGS -Dsiginfo=__siginfo"
+           fi
+           ;;
+  esac
 else
   # Even if Python support is not compiled in, we need to have these files
   # included.
index cc750dcffe1496ed91e1f7e6edbdad7f024798ab..e2bf45a588d9abc6afc767c4d95ec3033834869c 100644 (file)
@@ -858,6 +858,21 @@ if test "${have_libpython}" != no; then
     done
     AC_MSG_RESULT(${PYTHON_CFLAGS})
   fi
+
+  # On IRIX, type siginfo is not defined.  Instead, sys/siginfo.h provides:
+  #    #if _SGIAPI
+  #    #define siginfo __siginfo
+  #    #endif
+  # The problem is that including Python causes some XOPEN macros to be
+  # unilaterally defined, and that in turn causes _SGIAPI to evaluate
+  # to false.  So, we work around this issue by defining siginfo ourself
+  # though the command-line.
+  case "$gdb_host" in
+    irix*) if test "${GCC}" = yes; then
+             CPPFLAGS="$CPPFLAGS -Dsiginfo=__siginfo"
+           fi
+           ;;
+  esac
 else
   # Even if Python support is not compiled in, we need to have these files
   # included.
index f7454dc4558006f19c497371f7f9597bb2355b7f..aff29d8a1fc571c0e81ce95897c444000a7a7977 100644 (file)
@@ -151,7 +151,7 @@ supply_fpregset (struct regcache *regcache, const fpregset_t *fpregsetp)
 
   for (regi = 0; regi < 32; regi++)
     regcache_raw_supply (regcache, gdbarch_fp0_regnum (gdbarch) + regi,
-                        (const char *) &fpregsetp->fp_r.fp_regs[regi]);
+                        (const char *) &fpregsetp->__fp_r.__fp_regs[regi]);
 
   /* We can't supply the FSR register directly to the regcache,
      because there is a size issue: On one hand, fpregsetp->fp_csr
@@ -159,7 +159,7 @@ supply_fpregset (struct regcache *regcache, const fpregset_t *fpregsetp)
      So we use a buffer of the correct size and copy into it the register
      value at the proper location.  */
   memset (fsrbuf, 0, 4);
-  memcpy (fsrbuf + 4, &fpregsetp->fp_csr, 4);
+  memcpy (fsrbuf + 4, &fpregsetp->__fp_csr, 4);
 
   regcache_raw_supply (regcache,
                       mips_regnum (gdbarch)->fp_control_status, fsrbuf);
@@ -184,8 +184,9 @@ fill_fpregset (const struct regcache *regcache, fpregset_t *fpregsetp, int regno
     {
       if ((regno == -1) || (regno == regi))
        {
-         to = (char *) &(fpregsetp->fp_r.fp_regs[regi - gdbarch_fp0_regnum
-                                                        (gdbarch)]);
+         const int fp0_regnum = gdbarch_fp0_regnum (gdbarch);
+
+         to = (char *) &(fpregsetp->__fp_r.__fp_regs[regi - fp0_regnum]);
           regcache_raw_collect (regcache, regi, to);
        }
     }
@@ -203,7 +204,7 @@ fill_fpregset (const struct regcache *regcache, fpregset_t *fpregsetp, int regno
       regcache_raw_collect (regcache,
                            mips_regnum (gdbarch)->fp_control_status, fsrbuf);
 
-      memcpy (&fpregsetp->fp_csr, fsrbuf + 4, 4);
+      memcpy (&fpregsetp->__fp_csr, fsrbuf + 4, 4);
     }
 }
 
This page took 0.04244 seconds and 4 git commands to generate.