public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
* minor portability patches
@ 2010-09-21 19:59 Peter O'Gorman
  2010-09-21 20:06 ` Tom Tromey
  2010-09-23 22:03 ` Jan Kratochvil
  0 siblings, 2 replies; 8+ messages in thread
From: Peter O'Gorman @ 2010-09-21 19:59 UTC (permalink / raw)
  To: gdb-patches

[-- Attachment #1: Type: text/plain, Size: 789 bytes --]

Hi,

We just built gdb-7.2 and had a couple of minor issues.

Patches attached, some I am less sure about than others.

When we build --with-python, IRIX 6.5 needed -lpthread, I don't know if
this is the correct place to add that though.

__FUNCTION__ is a gccism.

AIX 6.1 does prototype getthrds in /usr/include/procinfo.h, though not
identically to gdb's prototype, it has these:
extern  int     getthrds( pid_t, void *, int, tid_t *, int );
extern  int     getthrds64( pid_t, void *, int, tid64_t *, int );

Also avoid some warnings on AIX about ptrace32's third argument.

-rdynamic was being added regardless, causing link failures on multiple
platforms.

At least solaris cc complained about returning from void functions.

Thanks,
Peter
-- 
Peter O'Gorman
pogma@thewrittenword.com

[-- Attachment #2: 0001-Do-not-use-__FUNCTION__.patch --]
[-- Type: text/plain, Size: 2576 bytes --]

From 1c413972833ee2547579c9d4a7acc1db612abb14 Mon Sep 17 00:00:00 2001
From: Peter O'Gorman <pogma@thewrittenword.com>
Date: Tue, 21 Sep 2010 11:32:22 -0500
Subject: [PATCH 1/6] Do not use __FUNCTION__

Helps gdb to build with non-gcc compilers.
---
 bfd/elf32-i386.c   |    4 ++--
 bfd/elf64-x86-64.c |    4 ++--
 bfd/elfxx-sparc.c  |    2 +-
 3 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/bfd/elf32-i386.c b/bfd/elf32-i386.c
index 7a426d5..ef1f849 100644
--- a/bfd/elf32-i386.c
+++ b/bfd/elf32-i386.c
@@ -1408,7 +1408,7 @@ elf_i386_check_relocs (bfd *abfd,
 		    (_("%B: relocation %s against STT_GNU_IFUNC "
 		       "symbol `%s' isn't handled by %s"), abfd,
 		     elf_howto_table[r_type].name,
-		     name, __FUNCTION__);
+		     name, "elf_i386_check_relocs");
 		  bfd_set_error (bfd_error_bad_value);
 		  return FALSE;
 
@@ -3056,7 +3056,7 @@ elf_i386_relocate_section (bfd *output_bfd,
 		(_("%B: relocation %s against STT_GNU_IFUNC "
 		   "symbol `%s' isn't handled by %s"), input_bfd,
 		 elf_howto_table[r_type].name,
-		 name, __FUNCTION__);
+		 name, "elf_i386_relocate_section");
 	      bfd_set_error (bfd_error_bad_value);
 	      return FALSE;
 
diff --git a/bfd/elf64-x86-64.c b/bfd/elf64-x86-64.c
index 9da73a1..76520a1 100644
--- a/bfd/elf64-x86-64.c
+++ b/bfd/elf64-x86-64.c
@@ -1194,7 +1194,7 @@ elf64_x86_64_check_relocs (bfd *abfd, struct bfd_link_info *info,
 		    (_("%B: relocation %s against STT_GNU_IFUNC "
 		       "symbol `%s' isn't handled by %s"), abfd,
 		     x86_64_elf_howto_table[r_type].name,
-		     name, __FUNCTION__);
+		     name, "elf_x86_64_check_relocs");
 		  bfd_set_error (bfd_error_bad_value);
 		  return FALSE;
 
@@ -2768,7 +2768,7 @@ elf64_x86_64_relocate_section (bfd *output_bfd, struct bfd_link_info *info,
 		(_("%B: relocation %s against STT_GNU_IFUNC "
 		   "symbol `%s' isn't handled by %s"), input_bfd,
 		 x86_64_elf_howto_table[r_type].name,
-		 name, __FUNCTION__);
+		 name, "elf_x86_64_relocate_section");
 	      bfd_set_error (bfd_error_bad_value);
 	      return FALSE;
 
diff --git a/bfd/elfxx-sparc.c b/bfd/elfxx-sparc.c
index 58b1890..db7f511 100644
--- a/bfd/elfxx-sparc.c
+++ b/bfd/elfxx-sparc.c
@@ -3079,7 +3079,7 @@ _bfd_sparc_elf_relocate_section (bfd *output_bfd,
 		(_("%B: relocation %s against STT_GNU_IFUNC "
 		   "symbol `%s' isn't handled by %s"), input_bfd,
 		 _bfd_sparc_elf_howto_table[r_type].name,
-		 name, __FUNCTION__);
+		 name, "_bfd_sparc_elf_relocate_section");
 	      bfd_set_error (bfd_error_bad_value);
 	      return FALSE;
 	    }
-- 
1.7.0.1


[-- Attachment #3: 0002-Allow-build-to-succeed-on-AIX-6.1.patch --]
[-- Type: text/plain, Size: 2052 bytes --]

From aa5b6559bd80cdf2c161c1341878876061bdf606 Mon Sep 17 00:00:00 2001
From: Peter O'Gorman <pogma@thewrittenword.com>
Date: Tue, 21 Sep 2010 11:24:35 -0500
Subject: [PATCH 2/6] Allow build to succeed on AIX 6.1

getthrds is prototyped on aix 6.1 (and probably later)
The third argument to ptrace32 is an int*
---
 gdb/aix-thread.c |   13 ++++++++-----
 1 files changed, 8 insertions(+), 5 deletions(-)

diff --git a/gdb/aix-thread.c b/gdb/aix-thread.c
index cbdb099..01a276c 100644
--- a/gdb/aix-thread.c
+++ b/gdb/aix-thread.c
@@ -349,7 +349,7 @@ pdc_read_regs (pthdb_user_t user,
 	}
       else
 	{
-	  if (!ptrace32 (PTT_READ_GPRS, tid, gprs32, 0, NULL))
+	  if (!ptrace32 (PTT_READ_GPRS, tid, (int*)gprs32, 0, NULL))
 	    memset (gprs32, 0, sizeof (gprs32));
 	  memcpy (context->gpr, gprs32, sizeof(gprs32));
 	}
@@ -647,9 +647,12 @@ get_signaled_thread (void)
   pthdb_tid_t ktid = 0;
   int result = 0;
 
-  /* getthrds(3) isn't prototyped in any AIX 4.3.3 #include file.  */
+  /* getthrds(3) isn't prototyped in any AIX 4.3.3 #include file.
+     but is in AIX 6.1 (and later?) */
+#ifndef _AIX61
   extern int getthrds (pid_t, struct thrdsinfo64 *, 
 		       int, pthdb_tid_t *, int);
+#endif
 
   while (1)
   {
@@ -1238,7 +1241,7 @@ fetch_regs_kernel_thread (struct regcache *regcache, int regno,
 	}
       else
 	{
-	  if (!ptrace32 (PTT_READ_GPRS, tid, gprs32, 0, NULL))
+	  if (!ptrace32 (PTT_READ_GPRS, tid, (int*)gprs32, 0, NULL))
 	    memset (gprs32, 0, sizeof (gprs32));
 	  for (i = 0; i < ppc_num_gprs; i++)
 	    supply_reg32 (regcache, tdep->ppc_gp0_regnum + i, gprs32[i]);
@@ -1557,9 +1560,9 @@ store_regs_kernel_thread (const struct regcache *regcache, int regno,
       else
 	{
 	  /* Pre-fetch: some regs may not be in the cache.  */
-	  ptrace32 (PTT_READ_GPRS, tid, gprs32, 0, NULL);
+	  ptrace32 (PTT_READ_GPRS, tid, (int*)gprs32, 0, NULL);
 	  fill_gprs32 (regcache, gprs32);
-	  ptrace32 (PTT_WRITE_GPRS, tid, gprs32, 0, NULL);
+	  ptrace32 (PTT_WRITE_GPRS, tid, (int*)gprs32, 0, NULL);
 	}
     }
 
-- 
1.7.0.1


[-- Attachment #4: 0003-Don-t-use-rdynamic-by-default-for-non-gcc.patch --]
[-- Type: text/plain, Size: 843 bytes --]

From 2ec438d72fe8e7f33b316055cd42219f43d530bd Mon Sep 17 00:00:00 2001
From: Peter O'Gorman <pogma@thewrittenword.com>
Date: Tue, 21 Sep 2010 11:26:47 -0500
Subject: [PATCH 3/6] Don't use -rdynamic by default for non-gcc

-rdynamic breaks non-gcc build.
---
 gdb/configure.ac |    9 +++++++--
 1 files changed, 7 insertions(+), 2 deletions(-)

diff --git a/gdb/configure.ac b/gdb/configure.ac
index 2f8090e..0e84c0f 100644
--- a/gdb/configure.ac
+++ b/gdb/configure.ac
@@ -1496,8 +1496,13 @@ if $dynamic_list; then
   found="-Wl,--dynamic-list"
   RDYNAMIC='-Wl,--dynamic-list=$(srcdir)/proc-service.list'
 else
-  found="-rdynamic"
-  RDYNAMIC="-rdynamic"
+  if test "$GCC" = "yes"; then
+    found="-rdynamic"
+    RDYNAMIC="-rdynamic"
+  else
+    found=none
+    RDYNAMIC=
+  fi
 fi
 AC_SUBST(RDYNAMIC)
 AC_MSG_RESULT($found)
-- 
1.7.0.1


[-- Attachment #5: 0004-Don-t-return-from-void-functions.patch --]
[-- Type: text/plain, Size: 1102 bytes --]

From b91aa4ae16fd861188ba3a57a135c4a3119544ff Mon Sep 17 00:00:00 2001
From: Peter O'Gorman <pogma@thewrittenword.com>
Date: Tue, 21 Sep 2010 11:34:17 -0500
Subject: [PATCH 4/6] Don't return from void functions.

Helps with solaris cc
---
 gdb/dwarf2loc.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/gdb/dwarf2loc.c b/gdb/dwarf2loc.c
index b2aecf2..47ab667 100644
--- a/gdb/dwarf2loc.c
+++ b/gdb/dwarf2loc.c
@@ -260,7 +260,7 @@ dwarf_expr_dwarf_call (struct dwarf_expr_context *ctx, size_t die_offset)
 {
   struct dwarf_expr_baton *debaton = ctx->baton;
 
-  return per_cu_dwarf_call (ctx, die_offset, debaton->per_cu);
+  per_cu_dwarf_call (ctx, die_offset, debaton->per_cu);
 }
 
 struct piece_closure
@@ -1070,7 +1070,7 @@ needs_frame_dwarf_call (struct dwarf_expr_context *ctx, size_t die_offset)
 {
   struct needs_frame_baton *nf_baton = ctx->baton;
 
-  return per_cu_dwarf_call (ctx, die_offset, nf_baton->per_cu);
+  per_cu_dwarf_call (ctx, die_offset, nf_baton->per_cu);
 }
 
 /* Return non-zero iff the location expression at DATA (length SIZE)
-- 
1.7.0.1


[-- Attachment #6: 0005-IRIX-6.5-needs-lpthread.patch --]
[-- Type: text/plain, Size: 684 bytes --]

From 204e9e17f0216156c29a3265755440e3b59a7e48 Mon Sep 17 00:00:00 2001
From: Peter O'Gorman <pogma@thewrittenword.com>
Date: Tue, 21 Sep 2010 11:28:15 -0500
Subject: [PATCH 5/6] IRIX 6.5 needs -lpthread

At least when building -with-python
---
 gdb/config/mips/irix6.mh |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)

diff --git a/gdb/config/mips/irix6.mh b/gdb/config/mips/irix6.mh
index de212b2..6f57035 100644
--- a/gdb/config/mips/irix6.mh
+++ b/gdb/config/mips/irix6.mh
@@ -1,3 +1,4 @@
 # Host: SGI Iris running irix 6.x
 NATDEPFILES= fork-child.o irix5-nat.o corelow.o procfs.o \
 	proc-api.o proc-events.o proc-flags.o proc-why.o
+NAT_CLIBS= -lpthread
-- 
1.7.0.1


[-- Attachment #7: 0006-Initialize-cplus_struct_default-portably.patch --]
[-- Type: text/plain, Size: 811 bytes --]

From cd219062f4383084a5054d8ac1ad3f18eed8773d Mon Sep 17 00:00:00 2001
From: Peter O'Gorman <pogma@thewrittenword.com>
Date: Tue, 21 Sep 2010 11:35:48 -0500
Subject: [PATCH 6/6] Initialize cplus_struct_default portably.

Helps with IRIX 6.5's MIPSpro compiler
---
 gdb/gdbtypes.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/gdb/gdbtypes.c b/gdb/gdbtypes.c
index c35adbb..a813f22 100644
--- a/gdb/gdbtypes.c
+++ b/gdb/gdbtypes.c
@@ -1732,7 +1732,7 @@ check_stub_method_group (struct type *type, int method_id)
 }
 
 /* Ensure it is in .rodata (if available) by workarounding GCC PR 44690.  */
-const struct cplus_struct_type cplus_struct_default = { };
+const struct cplus_struct_type cplus_struct_default = {0};
 
 void
 allocate_cplus_struct_type (struct type *type)
-- 
1.7.0.1


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: minor portability patches
  2010-09-21 19:59 minor portability patches Peter O'Gorman
@ 2010-09-21 20:06 ` Tom Tromey
  2010-09-21 20:40   ` Joel Brobecker
                     ` (2 more replies)
  2010-09-23 22:03 ` Jan Kratochvil
  1 sibling, 3 replies; 8+ messages in thread
From: Tom Tromey @ 2010-09-21 20:06 UTC (permalink / raw)
  To: Peter O'Gorman; +Cc: gdb-patches

>>>>> "Peter" == Peter O'Gorman <gdb-patches@mlists.thewrittenword.com> writes:

Peter> We just built gdb-7.2 and had a couple of minor issues.
Peter> Patches attached, some I am less sure about than others.

Thanks.

The patches need ChangeLog entries.

Peter> When we build --with-python, IRIX 6.5 needed -lpthread, I don't know if
Peter> this is the correct place to add that though.

Me neither.  I'm not sure how we handle static linking against python,
or whether we even support it.

Peter> __FUNCTION__ is a gccism.

BFD patches should go to the binutils list.

Peter> At least solaris cc complained about returning from void functions.

This one and the cplus_struct_default patch are obvious once you have a
ChangeLog entry.

GCC's -Wreturn-type is supposed to complain about this (the void
function thing), at least according to my reading of the docs, but it
doesn't.

Tom

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: minor portability patches
  2010-09-21 20:06 ` Tom Tromey
@ 2010-09-21 20:40   ` Joel Brobecker
  2010-09-21 20:50     ` Peter O'Gorman
  2010-09-21 21:09   ` Peter O'Gorman
  2010-09-22 16:15   ` Doug Evans
  2 siblings, 1 reply; 8+ messages in thread
From: Joel Brobecker @ 2010-09-21 20:40 UTC (permalink / raw)
  To: Tom Tromey; +Cc: Peter O'Gorman, gdb-patches

> Peter> When we build --with-python, IRIX 6.5 needed -lpthread, I don't know if
> Peter> this is the correct place to add that though.
> 
> Me neither.  I'm not sure how we handle static linking against python,
> or whether we even support it.

Unfortunately not.  This forces a dependency on lpthread even when
it is not necessary (either Python is not built in, or Python is built
without thread support).

This should be handled at the python-config.py level. Something's
wrong, because the script is querying the sys and sysconfig modules
to get the list of libraries that libpython depends on:

What does the following script print with the Python you are using
to link GDB against?

    | from distutils import sysconfig
    | getvar = sysconfig.get_config_var
    | getvar('LIBS')
    | getvar('SYSLIBS')

The output should contain -lpthread if indeed libpython depends
on it (we haven't attempted to build GDB with Python on mips-irix
yet, but we build Python without thread support anyways).

-- 
Joel

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: minor portability patches
  2010-09-21 20:40   ` Joel Brobecker
@ 2010-09-21 20:50     ` Peter O'Gorman
  2010-09-21 21:56       ` Joel Brobecker
  0 siblings, 1 reply; 8+ messages in thread
From: Peter O'Gorman @ 2010-09-21 20:50 UTC (permalink / raw)
  To: Joel Brobecker; +Cc: Tom Tromey, gdb-patches

On Tue, Sep 21, 2010 at 11:40:51AM -0700, Joel Brobecker wrote:
> 
> What does the following script print with the Python you are using
> to link GDB against?
> 
>     | from distutils import sysconfig
>     | getvar = sysconfig.get_config_var
>     | getvar('LIBS')
>     | getvar('SYSLIBS')

Oh sorry. I should have checked. We built python on this platform with
CC set to "gcc -pthread", so no -lpthread in LIBS etc. and we build gdb
with MIPSpro C.

Let's forget about this hunk, it's doubtful that it will affect anyone else.

Thanks,
Peter
-- 
Peter O'Gorman
pogma@thewrittenword.com

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: minor portability patches
  2010-09-21 20:06 ` Tom Tromey
  2010-09-21 20:40   ` Joel Brobecker
@ 2010-09-21 21:09   ` Peter O'Gorman
  2010-09-22 16:15   ` Doug Evans
  2 siblings, 0 replies; 8+ messages in thread
From: Peter O'Gorman @ 2010-09-21 21:09 UTC (permalink / raw)
  To: Tom Tromey; +Cc: gdb-patches

On Tue, Sep 21, 2010 at 12:24:20PM -0600, Tom Tromey wrote:
> Me neither.  I'm not sure how we handle static linking against python,
> or whether we even support it.
> 
> Peter> __FUNCTION__ is a gccism.
> 
> BFD patches should go to the binutils list.
> 

I should have know that, sorry.

> Peter> At least solaris cc complained about returning from void functions.
> 
> This one and the cplus_struct_default patch are obvious once you have a
> ChangeLog entry.

For those then (0004-* and 0006-* in my earlier mail):

2010-09-21  Peter O'Gorman  <pogma@thewrittenword.com>

	* dwarf2loc.c (dwarf_expr_dwarf_call, needs_frame_dwarf_call): Do
	not return from void functions.
	* gdbtypes.c (cplus_struct_default): Initialize portably.

0002-*

	* aix-thread.c: Build fixes for aix6.1.

0003-*:

	* configure.ac: Do not add -rdynamic for non GCC compilers.

Thanks,
Peter
-- 
Peter O'Gorman
pogma@thewrittenword.com

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: minor portability patches
  2010-09-21 20:50     ` Peter O'Gorman
@ 2010-09-21 21:56       ` Joel Brobecker
  0 siblings, 0 replies; 8+ messages in thread
From: Joel Brobecker @ 2010-09-21 21:56 UTC (permalink / raw)
  To: Peter O'Gorman; +Cc: Tom Tromey, gdb-patches

> Oh sorry. I should have checked. We built python on this platform with
> CC set to "gcc -pthread", so no -lpthread in LIBS etc. and we build gdb
> with MIPSpro C.

Perhaps you should just do the same when building GDB?

-- 
Joel

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: minor portability patches
  2010-09-21 20:06 ` Tom Tromey
  2010-09-21 20:40   ` Joel Brobecker
  2010-09-21 21:09   ` Peter O'Gorman
@ 2010-09-22 16:15   ` Doug Evans
  2 siblings, 0 replies; 8+ messages in thread
From: Doug Evans @ 2010-09-22 16:15 UTC (permalink / raw)
  To: Tom Tromey; +Cc: Peter O'Gorman, gdb-patches

On Tue, Sep 21, 2010 at 11:24 AM, Tom Tromey <tromey@redhat.com> wrote:
> Peter> When we build --with-python, IRIX 6.5 needed -lpthread, I don't know if
> Peter> this is the correct place to add that though.
>
> Me neither.  I'm not sure how we handle static linking against python,
> or whether we even support it.

For reference sake,
I've statically linked in python just fine.
There may be something special about the python installation I used,
but I just use gdb's python-config.py normally and it DTRT.

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: minor portability patches
  2010-09-21 19:59 minor portability patches Peter O'Gorman
  2010-09-21 20:06 ` Tom Tromey
@ 2010-09-23 22:03 ` Jan Kratochvil
  1 sibling, 0 replies; 8+ messages in thread
From: Jan Kratochvil @ 2010-09-23 22:03 UTC (permalink / raw)
  To: Peter O'Gorman; +Cc: gdb-patches

On Tue, 21 Sep 2010 18:48:16 +0200, Peter O'Gorman wrote:
> -rdynamic was being added regardless, causing link failures on multiple
> platforms.
> 0003-Don-t-use-rdynamic-by-default-for-non-gcc.patch
[...]
> -  found="-rdynamic"
> -  RDYNAMIC="-rdynamic"
> +  if test "$GCC" = "yes"; then
> +    found="-rdynamic"
> +    RDYNAMIC="-rdynamic"
> +  else
> +    found=none
> +    RDYNAMIC=
> +  fi

I would slightly prefer to bring it more on-par with gdbserver/configure.ac
using AC_TRY_LINK.  On local OpenSolaris there is gcc but Sun linker.  Still
it worked there, though - as gcc complains but works even with -dynamic.


Thanks,
Jan


2010-09-23  Jan Kratochvil  <jan.kratochvil@redhat.com>

	* configure.ac: Use -rdynamic optionally, based on AC_TRY_LINK.
	* configure: Regenerate.

--- a/gdb/configure.ac
+++ b/gdb/configure.ac
@@ -1496,8 +1496,13 @@ if $dynamic_list; then
   found="-Wl,--dynamic-list"
   RDYNAMIC='-Wl,--dynamic-list=$(srcdir)/proc-service.list'
 else
-  found="-rdynamic"
-  RDYNAMIC="-rdynamic"
+  old_LDFLAGS="$LDFLAGS"
+  LDFLAGS="$old_LDFLAGS -rdynamic"
+  AC_TRY_LINK([], [], [found="-rdynamic"
+		       RDYNAMIC="-rdynamic"],
+		      [found="no"
+		       RDYNAMIC=""])
+  LDFLAGS="$old_LDFLAGS"
 fi
 AC_SUBST(RDYNAMIC)
 AC_MSG_RESULT($found)

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2010-09-23 19:44 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-09-21 19:59 minor portability patches Peter O'Gorman
2010-09-21 20:06 ` Tom Tromey
2010-09-21 20:40   ` Joel Brobecker
2010-09-21 20:50     ` Peter O'Gorman
2010-09-21 21:56       ` Joel Brobecker
2010-09-21 21:09   ` Peter O'Gorman
2010-09-22 16:15   ` Doug Evans
2010-09-23 22:03 ` Jan Kratochvil

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).