[Patch Darwin] head build fixes for i686-darwin9/x86_64-darwin10.

Iain Sandoe
2011-12-29T20:30:52Z

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;
}