Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
* [Patch Darwin] head build fixes for i686-darwin9/x86_64-darwin10.
@ 2011-12-29 20:32 Iain Sandoe
  2012-01-02 11:40 ` Pedro Alves
                   ` (2 more replies)
  0 siblings, 3 replies; 7+ messages in thread
From: Iain Sandoe @ 2011-12-29 20:32 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tristan Gingold

Hi,
At present trunk gdb does not build for me on either i686-darwin9 or  
x86_64-darwin10.

There are two problems on Darwin 10 and three on Darwin 9 (description  
with each patchlet, below).

OK?
Iain

gdb:

	* machoread.c (macho_symtab_read): Initialize nbr_syms.
	* i386-darwin-nat.c (DR_FIRSTADDR, DR_LASTADDR, DR_STATUS,
	DR_CONTROL): Ensure a default definition is available.
	* darwin-nat.c (darwin_read_dyld_info): Only build if
	TASK_DYLD_INFO_COUNT is available.
	(darwin_xfer_partial): Don not try to fetch dyld info
	unless TASK_DYLD_INFO_COUNT is available.

=====

1/ a "maybe used un-initialized" (in machoread.c)

which is fixed thus:

diff --git a/gdb/machoread.c b/gdb/machoread.c
index 46b8842..ba38ca6 100644
--- a/gdb/machoread.c
+++ b/gdb/machoread.c
@@ -180,7 +180,7 @@ macho_symtab_read (struct objfile *objfile,
    const asymbol *dir_so = NULL;
    const asymbol *file_so = NULL;
    asymbol **oso_file = NULL;
-  unsigned int nbr_syms;
+  unsigned int nbr_syms = 0;

    /* Current state while reading stabs.  */
    enum

=======

2/ DR_FIRSTADDR and cousins are undefined.
(the fragment below is copied verbatim from gdb-7.3.1 - is there some  
reason to expect that it should have been defined elsewhere?)

diff --git a/gdb/i386-darwin-nat.c b/gdb/i386-darwin-nat.c
index 23f6a6d..2a346c4 100644
--- a/gdb/i386-darwin-nat.c
+++ b/gdb/i386-darwin-nat.c
@@ -263,6 +263,22 @@ i386_darwin_store_inferior_registers (struct  
target_ops *ops,

  /* Support for debug registers, boosted mostly from i386-linux- 
nat.c.  */

+#ifndef DR_FIRSTADDR
+#define DR_FIRSTADDR 0
+#endif
+
+#ifndef DR_LASTADDR
+#define DR_LASTADDR 3
+#endif
+
+#ifndef DR_STATUS
+#define DR_STATUS 6
+#endif
+
+#ifndef DR_CONTROL
+#define DR_CONTROL 7
+#endif
+
  static void
  i386_darwin_dr_set (int regnum, uint32_t value)
  {

=====

3/ (Darwin 9 only)
TASK_DYLD_INFO_COUNT etc. are not defined.

Fixed thus:
diff --git a/gdb/darwin-nat.c b/gdb/darwin-nat.c
index 94f49d6..efc59e7 100644
--- a/gdb/darwin-nat.c
+++ b/gdb/darwin-nat.c
@@ -1823,6 +1823,7 @@ out:
    return length;
  }

+#ifdef TASK_DYLD_INFO_COUNT
  /* Read LENGTH bytes at offset ADDR of task_dyld_info for TASK, and  
copy them
     to RDADDR.
     Return 0 on failure; number of bytes read / writen otherwise.  */
@@ -1848,7 +1849,7 @@ darwin_read_dyld_info (task_t task, CORE_ADDR  
addr, char *rdaddr, int length)
    memcpy (rdaddr, (char *)&task_dyld_info + addr, length);
    return length;
  }
-
+#endif
  \f
  /* Return 0 on failure, number of bytes handled otherwise.  TARGET
     is ignored.  */
@@ -1890,6 +1891,7 @@ darwin_xfer_partial (struct target_ops *ops,
      case TARGET_OBJECT_MEMORY:
        return darwin_read_write_inferior (inf->private->task, offset,
                                           readbuf, writebuf, len);
+#ifdef TASK_DYLD_INFO_COUNT
      case TARGET_OBJECT_DARWIN_DYLD_INFO:
        if (writebuf != NULL || readbuf == NULL)
          {
@@ -1897,6 +1899,7 @@ darwin_xfer_partial (struct target_ops *ops,
            return -1;
          }
        return darwin_read_dyld_info (inf->private->task, offset,  
readbuf, len);
+#endif
      default:
        return -1;
      }






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

* Re: [Patch Darwin] head build fixes for i686-darwin9/x86_64-darwin10.
  2011-12-29 20:32 [Patch Darwin] head build fixes for i686-darwin9/x86_64-darwin10 Iain Sandoe
@ 2012-01-02 11:40 ` Pedro Alves
  2012-01-02 14:39 ` Tristan Gingold
  2012-12-24  3:56 ` Mike Frysinger
  2 siblings, 0 replies; 7+ messages in thread
From: Pedro Alves @ 2012-01-02 11:40 UTC (permalink / raw)
  To: Iain Sandoe; +Cc: gdb-patches, Tristan Gingold

On 12/29/2011 08:30 PM, Iain Sandoe wrote:

> =======
>
> 2/ DR_FIRSTADDR and cousins are undefined.
> (the fragment below is copied verbatim from gdb-7.3.1 - is there some 
> reason to expect that it should have been defined elsewhere?)

I've just recently removed these from this file, but I missed that the file
does not include i386-nat.h.  Include i386-nat.h instead please.

Darwin has the i386 watchpoint hooks in place, but it doesn't install
them --- there's a i386_use_watchpoints call missing (at least).


http://sourceware.org/ml/gdb-patches/2011-12/msg00143.html


>
> diff --git a/gdb/i386-darwin-nat.c b/gdb/i386-darwin-nat.c
> index 23f6a6d..2a346c4 100644
> --- a/gdb/i386-darwin-nat.c
> +++ b/gdb/i386-darwin-nat.c
> @@ -263,6 +263,22 @@ i386_darwin_store_inferior_registers (struct 
> target_ops *ops,
>
>  /* Support for debug registers, boosted mostly from 
> i386-linux-nat.c.  */
>
> +#ifndef DR_FIRSTADDR
> +#define DR_FIRSTADDR 0
> +#endif
> +
> +#ifndef DR_LASTADDR
> +#define DR_LASTADDR 3
> +#endif
> +
> +#ifndef DR_STATUS
> +#define DR_STATUS 6
> +#endif
> +
> +#ifndef DR_CONTROL
> +#define DR_CONTROL 7
> +#endif
> +


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

* Re: [Patch Darwin] head build fixes for i686-darwin9/x86_64-darwin10.
  2011-12-29 20:32 [Patch Darwin] head build fixes for i686-darwin9/x86_64-darwin10 Iain Sandoe
  2012-01-02 11:40 ` Pedro Alves
@ 2012-01-02 14:39 ` Tristan Gingold
  2012-12-24  3:57   ` Mike Frysinger
  2012-12-24  3:56 ` Mike Frysinger
  2 siblings, 1 reply; 7+ messages in thread
From: Tristan Gingold @ 2012-01-02 14:39 UTC (permalink / raw)
  To: Iain Sandoe; +Cc: gdb-patches


On Dec 29, 2011, at 9:30 PM, Iain Sandoe wrote:

> Hi,
> At present trunk gdb does not build for me on either i686-darwin9 or x86_64-darwin10.
> 
> There are two problems on Darwin 10 and three on Darwin 9 (description with each patchlet, below).
> 
> OK?

Chunk per chunk review.

Tristan.

> Iain
> 
> gdb:
> 
> 	* machoread.c (macho_symtab_read): Initialize nbr_syms.
> 	* i386-darwin-nat.c (DR_FIRSTADDR, DR_LASTADDR, DR_STATUS,
> 	DR_CONTROL): Ensure a default definition is available.
> 	* darwin-nat.c (darwin_read_dyld_info): Only build if
> 	TASK_DYLD_INFO_COUNT is available.
> 	(darwin_xfer_partial): Don not try to fetch dyld info
> 	unless TASK_DYLD_INFO_COUNT is available.
> 
> =====
> 
> 1/ a "maybe used un-initialized" (in machoread.c)
> 
> which is fixed thus:
> 
> diff --git a/gdb/machoread.c b/gdb/machoread.c
> index 46b8842..ba38ca6 100644
> --- a/gdb/machoread.c
> +++ b/gdb/machoread.c
> @@ -180,7 +180,7 @@ macho_symtab_read (struct objfile *objfile,
>   const asymbol *dir_so = NULL;
>   const asymbol *file_so = NULL;
>   asymbol **oso_file = NULL;
> -  unsigned int nbr_syms;
> +  unsigned int nbr_syms = 0;
> 
>   /* Current state while reading stabs.  */
>   enum
> 

Ok.

> =======
> 
> 2/ DR_FIRSTADDR and cousins are undefined.
> (the fragment below is copied verbatim from gdb-7.3.1 - is there some reason to expect that it should have been defined elsewhere?)
> 
> diff --git a/gdb/i386-darwin-nat.c b/gdb/i386-darwin-nat.c
> index 23f6a6d..2a346c4 100644
> --- a/gdb/i386-darwin-nat.c
> +++ b/gdb/i386-darwin-nat.c
> @@ -263,6 +263,22 @@ i386_darwin_store_inferior_registers (struct target_ops *ops,
> 
> /* Support for debug registers, boosted mostly from i386-linux-nat.c.  */
> 
> +#ifndef DR_FIRSTADDR
> +#define DR_FIRSTADDR 0
> +#endif
> +
> +#ifndef DR_LASTADDR
> +#define DR_LASTADDR 3
> +#endif
> +
> +#ifndef DR_STATUS
> +#define DR_STATUS 6
> +#endif
> +
> +#ifndef DR_CONTROL
> +#define DR_CONTROL 7
> +#endif
> +
> static void
> i386_darwin_dr_set (int regnum, uint32_t value)
> {
> 

See Pedro's message.


> =====
> 
> 3/ (Darwin 9 only)
> TASK_DYLD_INFO_COUNT etc. are not defined.
> 
> Fixed thus:
> diff --git a/gdb/darwin-nat.c b/gdb/darwin-nat.c
> index 94f49d6..efc59e7 100644
> --- a/gdb/darwin-nat.c
> +++ b/gdb/darwin-nat.c
> @@ -1823,6 +1823,7 @@ out:
>   return length;
> }
> 
> +#ifdef TASK_DYLD_INFO_COUNT
> /* Read LENGTH bytes at offset ADDR of task_dyld_info for TASK, and copy them
>    to RDADDR.
>    Return 0 on failure; number of bytes read / writen otherwise.  */
> @@ -1848,7 +1849,7 @@ darwin_read_dyld_info (task_t task, CORE_ADDR addr, char *rdaddr, int length)
>   memcpy (rdaddr, (char *)&task_dyld_info + addr, length);
>   return length;
> }
> -
> +#endif
> 
> /* Return 0 on failure, number of bytes handled otherwise.  TARGET
>    is ignored.  */
> @@ -1890,6 +1891,7 @@ darwin_xfer_partial (struct target_ops *ops,
>     case TARGET_OBJECT_MEMORY:
>       return darwin_read_write_inferior (inf->private->task, offset,
>                                          readbuf, writebuf, len);
> +#ifdef TASK_DYLD_INFO_COUNT
>     case TARGET_OBJECT_DARWIN_DYLD_INFO:
>       if (writebuf != NULL || readbuf == NULL)
>         {
> @@ -1897,6 +1899,7 @@ darwin_xfer_partial (struct target_ops *ops,
>           return -1;
>         }
>       return darwin_read_dyld_info (inf->private->task, offset, readbuf, len);
> +#endif
>     default:
>       return -1;
>     }

Ok (but a comment would be very welcome).

Thanks,
Tristan.


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

* Re: [Patch Darwin] head build fixes for i686-darwin9/x86_64-darwin10.
  2011-12-29 20:32 [Patch Darwin] head build fixes for i686-darwin9/x86_64-darwin10 Iain Sandoe
  2012-01-02 11:40 ` Pedro Alves
  2012-01-02 14:39 ` Tristan Gingold
@ 2012-12-24  3:56 ` Mike Frysinger
  2 siblings, 0 replies; 7+ messages in thread
From: Mike Frysinger @ 2012-12-24  3:56 UTC (permalink / raw)
  To: gdb-patches; +Cc: Iain Sandoe, Tristan Gingold

[-- Attachment #1: Type: Text/Plain, Size: 1068 bytes --]

On Thursday 29 December 2011 15:30:31 Iain Sandoe wrote:
> 1/ a "maybe used un-initialized" (in machoread.c)

looks like this has been fixed since:

commit 9ba6fb7f0b383d2f19536d8224fe4e692bd30e2d
Author: Tristan Gingold <gingold@adacore.com>
Date:   Thu Feb 16 14:57:01 2012 +0000

2012-02-16  Josh Matthews  <josh@joshmatthews.net>

* machoread.c: Initialize nbr_syms to avoid warnings-as-errors failure.

> 2/ DR_FIRSTADDR and cousins are undefined.
> (the fragment below is copied verbatim from gdb-7.3.1 - is there some
> reason to expect that it should have been defined elsewhere?)

looks like this has been fixed since:

commit 39e980b3953f98e66359aabc733c3d9dd4785b82
Author: Joel Brobecker <brobecker@gnat.com>
Date:   Wed Feb 1 10:54:06 2012 +0000

Fix build error in Darwin port.

gdb/ChangeLog:

From: Josh Matthews  <josh@joshmatthews.net>  (tiny change)
Fix build error in Darwin port.
* i386-darwin-nat.c: Include i386-nat.h.

> 3/ (Darwin 9 only)
> TASK_DYLD_INFO_COUNT etc. are not defined.

which leaves this one uncommitted.  i'll follow up.
-mike

[-- Attachment #2: This is a digitally signed message part. --]
[-- Type: application/pgp-signature, Size: 836 bytes --]

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

* Re: [Patch Darwin] head build fixes for i686-darwin9/x86_64-darwin10.
  2012-01-02 14:39 ` Tristan Gingold
@ 2012-12-24  3:57   ` Mike Frysinger
  2012-12-24  4:27     ` Joel Brobecker
  0 siblings, 1 reply; 7+ messages in thread
From: Mike Frysinger @ 2012-12-24  3:57 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tristan Gingold, Iain Sandoe

[-- Attachment #1: Type: Text/Plain, Size: 2514 bytes --]

On Monday 02 January 2012 09:38:57 Tristan Gingold wrote:
> On Dec 29, 2011, at 9:30 PM, Iain Sandoe wrote:
> > =====
> > 
> > 3/ (Darwin 9 only)
> > TASK_DYLD_INFO_COUNT etc. are not defined.
> > 
> > Fixed thus:
> > diff --git a/gdb/darwin-nat.c b/gdb/darwin-nat.c
> > index 94f49d6..efc59e7 100644
> > --- a/gdb/darwin-nat.c
> > +++ b/gdb/darwin-nat.c
> > @@ -1823,6 +1823,7 @@ out:
> >   return length;
> > }
> > 
> > +#ifdef TASK_DYLD_INFO_COUNT
> > /* Read LENGTH bytes at offset ADDR of task_dyld_info for TASK, and copy
> > them
> >    to RDADDR.
> >    Return 0 on failure; number of bytes read / writen otherwise.  */
> > @@ -1848,7 +1849,7 @@ darwin_read_dyld_info (task_t task, CORE_ADDR addr,
> > char *rdaddr, int length)
> >   memcpy (rdaddr, (char *)&task_dyld_info + addr, length);
> >   return length;
> > }
> > -
> > +#endif
> > 
> > /* Return 0 on failure, number of bytes handled otherwise.  TARGET
> >    is ignored.  */
> > @@ -1890,6 +1891,7 @@ darwin_xfer_partial (struct target_ops *ops,
> >     case TARGET_OBJECT_MEMORY:
> >       return darwin_read_write_inferior (inf->private->task, offset,
> >                                          readbuf, writebuf, len);
> > +#ifdef TASK_DYLD_INFO_COUNT
> >     case TARGET_OBJECT_DARWIN_DYLD_INFO:
> >       if (writebuf != NULL || readbuf == NULL)
> >         {
> > @@ -1897,6 +1899,7 @@ darwin_xfer_partial (struct target_ops *ops,
> >           return -1;
> >         }
> >       return darwin_read_dyld_info (inf->private->task, offset, readbuf,
> >       len);
> > +#endif
> >     default:
> >       return -1;
> >     }
> 
> Ok (but a comment would be very welcome).

how about this instead.  it localizes the #ifdef and has a comment.

diff --git a/gdb/darwin-nat.c b/gdb/darwin-nat.c
index 252fe3e..ac0aaac 100644
--- a/gdb/darwin-nat.c
+++ b/gdb/darwin-nat.c
@@ -1821,6 +1821,10 @@ out:
 static int
 darwin_read_dyld_info (task_t task, CORE_ADDR addr, char *rdaddr, int length)
 {
+#ifndef TASK_DYLD_INFO_COUNT
+  /* This is not available in Darwin 9.  */
+  return -1;
+#else
   struct task_dyld_info task_dyld_info;
   mach_msg_type_number_t count = TASK_DYLD_INFO_COUNT;
   int sz = TASK_DYLD_INFO_COUNT * sizeof (natural_t);
@@ -1838,6 +1842,7 @@ darwin_read_dyld_info (task_t task, CORE_ADDR addr, char 
*rdaddr, int length)
     length = sz - addr;
   memcpy (rdaddr, (char *)&task_dyld_info + addr, length);
   return length;
+#endif
 }
 
 \f
-mike

[-- Attachment #2: This is a digitally signed message part. --]
[-- Type: application/pgp-signature, Size: 836 bytes --]

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

* Re: [Patch Darwin] head build fixes for i686-darwin9/x86_64-darwin10.
  2012-12-24  3:57   ` Mike Frysinger
@ 2012-12-24  4:27     ` Joel Brobecker
  2012-12-24  5:09       ` Mike Frysinger
  0 siblings, 1 reply; 7+ messages in thread
From: Joel Brobecker @ 2012-12-24  4:27 UTC (permalink / raw)
  To: Mike Frysinger; +Cc: gdb-patches, Tristan Gingold, Iain Sandoe

> how about this instead.  it localizes the #ifdef and has a comment.

Tristan being on holiday, I will take over this week. This looks
OK to me with one tiny request: Update the function documentation
about also returning -1 to signify that the request is unsupported.
I assume you'll remember to provide a CL.

I wonder how we are expected to iterate over shared libraries
on Darwin 9 (we no longer have access to this version of Darwin).

Thanks!

> diff --git a/gdb/darwin-nat.c b/gdb/darwin-nat.c
> index 252fe3e..ac0aaac 100644
> --- a/gdb/darwin-nat.c
> +++ b/gdb/darwin-nat.c
> @@ -1821,6 +1821,10 @@ out:
>  static int
>  darwin_read_dyld_info (task_t task, CORE_ADDR addr, char *rdaddr, int length)
>  {
> +#ifndef TASK_DYLD_INFO_COUNT
> +  /* This is not available in Darwin 9.  */
> +  return -1;
> +#else
>    struct task_dyld_info task_dyld_info;
>    mach_msg_type_number_t count = TASK_DYLD_INFO_COUNT;
>    int sz = TASK_DYLD_INFO_COUNT * sizeof (natural_t);
> @@ -1838,6 +1842,7 @@ darwin_read_dyld_info (task_t task, CORE_ADDR addr, char 
> *rdaddr, int length)
>      length = sz - addr;
>    memcpy (rdaddr, (char *)&task_dyld_info + addr, length);
>    return length;
> +#endif
>  }
>  
>  \f
> -mike



-- 
Joel


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

* Re: [Patch Darwin] head build fixes for i686-darwin9/x86_64-darwin10.
  2012-12-24  4:27     ` Joel Brobecker
@ 2012-12-24  5:09       ` Mike Frysinger
  0 siblings, 0 replies; 7+ messages in thread
From: Mike Frysinger @ 2012-12-24  5:09 UTC (permalink / raw)
  To: Joel Brobecker; +Cc: gdb-patches, Tristan Gingold, Iain Sandoe

[-- Attachment #1: Type: Text/Plain, Size: 2020 bytes --]

On Sunday 23 December 2012 23:26:57 Joel Brobecker wrote:
> > how about this instead.  it localizes the #ifdef and has a comment.
> 
> Tristan being on holiday, I will take over this week. This looks
> OK to me with one tiny request: Update the function documentation
> about also returning -1 to signify that the request is unsupported.
> I assume you'll remember to provide a CL.

hmm, actually, that change won't work :/.  it doesn't handle 
TARGET_OBJECT_DARWIN_DYLD_INFO not being defined.

so back to the original patch:
--- a/gdb/darwin-nat.c
+++ b/gdb/darwin-nat.c
@@ -1823,6 +1823,7 @@ out:
    return length;
  }

+#ifdef TASK_DYLD_INFO_COUNT
  /* Read LENGTH bytes at offset ADDR of task_dyld_info for TASK, and  
copy them
     to RDADDR.
     Return 0 on failure; number of bytes read / writen otherwise.  */
@@ -1848,7 +1849,7 @@ darwin_read_dyld_info (task_t task, CORE_ADDR  
addr, char *rdaddr, int length)
    memcpy (rdaddr, (char *)&task_dyld_info + addr, length);
    return length;
  }
-
+#endif
  \f
  /* Return 0 on failure, number of bytes handled otherwise.  TARGET
     is ignored.  */
@@ -1890,6 +1891,7 @@ darwin_xfer_partial (struct target_ops *ops,
      case TARGET_OBJECT_MEMORY:
        return darwin_read_write_inferior (inf->private->task, offset,
                                           readbuf, writebuf, len);
+#ifdef TASK_DYLD_INFO_COUNT
      case TARGET_OBJECT_DARWIN_DYLD_INFO:
        if (writebuf != NULL || readbuf == NULL)
          {
@@ -1897,6 +1899,7 @@ darwin_xfer_partial (struct target_ops *ops,
            return -1;
          }
        return darwin_read_dyld_info (inf->private->task, offset, readbuf, 
len);
+#endif
      default:
        return -1;
      }

> I wonder how we are expected to iterate over shared libraries
> on Darwin 9 (we no longer have access to this version of Darwin).

i don't run any Darwin/OS X version, so i don't know.  i just implemented this 
for a fellow Gentoo dev.
-mike

[-- Attachment #2: This is a digitally signed message part. --]
[-- Type: application/pgp-signature, Size: 836 bytes --]

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

end of thread, other threads:[~2012-12-24  5:09 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-12-29 20:32 [Patch Darwin] head build fixes for i686-darwin9/x86_64-darwin10 Iain Sandoe
2012-01-02 11:40 ` Pedro Alves
2012-01-02 14:39 ` Tristan Gingold
2012-12-24  3:57   ` Mike Frysinger
2012-12-24  4:27     ` Joel Brobecker
2012-12-24  5:09       ` Mike Frysinger
2012-12-24  3:56 ` Mike Frysinger

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox