This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: [Patch Darwin] head build fixes for i686-darwin9/x86_64-darwin10.
- From: Tristan Gingold <gingold at adacore dot com>
- To: Iain Sandoe <developer at sandoe-acoustics dot co dot uk>
- Cc: gdb-patches at sourceware dot org
- Date: Mon, 2 Jan 2012 15:38:57 +0100
- Subject: Re: [Patch Darwin] head build fixes for i686-darwin9/x86_64-darwin10.
- References: <59ABFF71-CA26-452C-B9B2-9B0FC6AAE2BD@sandoe-acoustics.co.uk>
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.