/* Handle Darwin shared libraries for GDB, the GNU Debugger.
- Copyright (C) 2009-2012 Free Software Foundation, Inc.
+ Copyright (C) 2009-2014 Free Software Foundation, Inc.
This file is part of GDB.
static void
darwin_pspace_data_cleanup (struct program_space *pspace, void *arg)
{
- struct darwin_info *info;
-
- info = program_space_data (pspace, solib_darwin_pspace_data);
- xfree (info);
+ xfree (arg);
}
/* Get the current darwin data. If none is found yet, add it now. This
if (info != NULL)
return info;
- info = XZALLOC (struct darwin_info);
+ info = XCNEW (struct darwin_info);
set_program_space_data (current_program_space,
solib_darwin_pspace_data, info);
return info;
/* Return program interpreter string. */
-static gdb_byte *
+static char *
find_program_interpreter (void)
{
- gdb_byte *buf = NULL;
+ char *buf = NULL;
/* If we have an exec_bfd, get the interpreter from the load commands. */
if (exec_bfd)
for (i = 0; i < info->all_image.count; i++)
{
CORE_ADDR iinfo = info->all_image.info + i * image_info_size;
- char buf[image_info_size];
+ gdb_byte buf[image_info_size];
CORE_ADDR load_addr;
CORE_ADDR path_addr;
struct mach_o_header_external hdr;
path_addr = extract_typed_address (buf + ptr_len, ptr_type);
/* Read Mach-O header from memory. */
- if (target_read_memory (load_addr, (char *) &hdr, sizeof (hdr) - 4))
+ if (target_read_memory (load_addr, (gdb_byte *) &hdr, sizeof (hdr) - 4))
break;
/* Discard wrong magic numbers. Shouldn't happen. */
hdr_val = extract_unsigned_integer
break;
/* Create and fill the new so_list element. */
- dnew = XZALLOC (struct darwin_so_list);
+ dnew = XCNEW (struct darwin_so_list);
new = &dnew->sl;
old_chain = make_cleanup (xfree, dnew);
for (i = 0; i < info->all_image.count; i++)
{
CORE_ADDR iinfo = info->all_image.info + i * image_info_size;
- char buf[image_info_size];
+ gdb_byte buf[image_info_size];
CORE_ADDR load_addr;
struct mach_o_header_external hdr;
unsigned long hdr_val;
load_addr = extract_typed_address (buf, ptr_type);
/* Read Mach-O header from memory. */
- if (target_read_memory (load_addr, (char *) &hdr, sizeof (hdr) - 4))
+ if (target_read_memory (load_addr, (gdb_byte *) &hdr, sizeof (hdr) - 4))
break;
/* Discard wrong magic numbers. Shouldn't happen. */
hdr_val = extract_unsigned_integer
static void
darwin_solib_get_all_image_info_addr_at_init (struct darwin_info *info)
{
- gdb_byte *interp_name;
+ char *interp_name;
CORE_ADDR load_addr = 0;
bfd *dyld_bfd = NULL;
struct cleanup *cleanup;
bfd_get_filename (abfd), bfd_errmsg (bfd_get_error ()));
}
+ /* The current filename for fat-binary BFDs is a name generated
+ by BFD, usually a string containing the name of the architecture.
+ Reset its value to the actual filename. */
+ xfree (bfd_get_filename (res));
+ res->filename = xstrdup (pathname);
+
gdb_bfd_unref (abfd);
return res;
}