#include "command.h"
#include "target.h"
#include "frame.h"
-#include "gnu-regex.h"
+#include "gdb_regex.h"
#include "inferior.h"
#include "language.h"
#include "gdbcmd.h"
/* Called by ldr_* routines to read memory from the current target. */
-static int ldr_read_memory PARAMS ((CORE_ADDR, char *, int, int));
+static int ldr_read_memory (CORE_ADDR, char *, int, int);
static int
-ldr_read_memory (memaddr, myaddr, len, readstring)
- CORE_ADDR memaddr;
- char *myaddr;
- int len;
- int readstring;
+ldr_read_memory (CORE_ADDR memaddr, char *myaddr, int len, int readstring)
{
int result;
char *buffer;
target_read_string (memaddr, &buffer, len, &result);
if (result == 0)
strcpy (myaddr, buffer);
- free (buffer);
+ xfree (buffer);
}
else
result = target_read_memory (memaddr, myaddr, len);
static struct so_list *so_list_head; /* List of known shared objects */
-extern int
-fdmatch PARAMS ((int, int)); /* In libiberty */
+extern int fdmatch (int, int); /* In libiberty */
/* Local function prototypes */
-static void
-sharedlibrary_command PARAMS ((char *, int));
+static void sharedlibrary_command (char *, int);
-static void
-info_sharedlibrary_command PARAMS ((char *, int));
+static void info_sharedlibrary_command (char *, int);
-static int
-symbol_add_stub PARAMS ((char *));
+static int symbol_add_stub (char *);
-static struct so_list *
- find_solib PARAMS ((struct so_list *));
+static struct so_list *find_solib (struct so_list *);
-static struct link_map *
- first_link_map_member PARAMS ((void));
+static struct link_map *first_link_map_member (void);
-static struct link_map *
- next_link_map_member PARAMS ((struct so_list *));
+static struct link_map *next_link_map_member (struct so_list *);
-static void
-xfer_link_map_member PARAMS ((struct so_list *, struct link_map *));
+static void xfer_link_map_member (struct so_list *, struct link_map *);
-static int
-solib_map_sections PARAMS ((char *));
+static int solib_map_sections (char *);
/*
*/
static int
-solib_map_sections (arg)
- char *arg;
+solib_map_sections (char *arg)
{
struct so_list *so = (struct so_list *) arg; /* catch_errors bogon */
char *filename;
bfd *abfd;
filename = tilde_expand (so->so_name);
- old_chain = make_cleanup (free, filename);
+ old_chain = make_cleanup (xfree, filename);
scratch_chan = openp (getenv ("PATH"), 1, filename, O_RDONLY, 0,
&scratch_pathname);
*/
static struct link_map *
-first_link_map_member ()
+first_link_map_member (void)
{
struct link_map *lm = NULL;
static struct link_map first_lm;
}
static struct link_map *
-next_link_map_member (so_list_ptr)
- struct so_list *so_list_ptr;
+next_link_map_member (struct so_list *so_list_ptr)
{
struct link_map *lm = NULL;
static struct link_map next_lm;
}
static void
-xfer_link_map_member (so_list_ptr, lm)
- struct so_list *so_list_ptr;
- struct link_map *lm;
+xfer_link_map_member (struct so_list *so_list_ptr, struct link_map *lm)
{
int i;
so_list_ptr->lm = *lm;
error ("xfer_link_map_member: Can't read pathname for load map: %s\n",
safe_strerror (errcode));
strncpy (so_list_ptr->so_name, buffer, MAX_PATH_SIZE - 1);
- free (buffer);
+ xfree (buffer);
so_list_ptr->so_name[MAX_PATH_SIZE - 1] = '\0';
for (i = 0; i < lm->module_info.region_count; i++)
region_name = "??";
warning ("cannot handle shared library relocation for %s (%s)",
so_list_ptr->so_name, region_name);
- free (buffer);
+ xfree (buffer);
}
}
#endif
*/
static struct so_list *
-find_solib (so_list_ptr)
- struct so_list *so_list_ptr; /* Last lm or NULL for first one */
+find_solib (struct so_list *so_list_ptr)
{
struct so_list *so_list_next = NULL;
struct link_map *lm = NULL;
/* A small stub to get us past the arg-passing pinhole of catch_errors. */
static int
-symbol_add_stub (arg)
- char *arg;
+symbol_add_stub (char *arg)
{
register struct so_list *so = (struct so_list *) arg; /* catch_errs bogon */
CORE_ADDR text_addr = 0;
+ struct section_addr_info section_addrs;
+ memset (§ion_addrs, 0, sizeof (section_addrs));
if (so->textsection)
text_addr = so->textsection->addr;
else if (so->abfd != NULL)
text_addr = bfd_section_vma (so->abfd, lowest_sect) + LM_OFFSET (so);
}
+ section_addrs.other[0].addr = text_addr;
+ section_addrs.other[0].name = ".text";
so->objfile = symbol_file_add (so->so_name, so->from_tty,
- text_addr,
- 0, 0, 0, 0, 1);
+ §ion_addrs, 0, OBJF_SHARED);
return (1);
}
*/
void
-solib_add (arg_string, from_tty, target)
- char *arg_string;
- int from_tty;
- struct target_ops *target;
+solib_add (char *arg_string, int from_tty, struct target_ops *target)
{
register struct so_list *so = NULL; /* link map state variable */
if (count)
{
- int update_coreops;
-
- /* We must update the to_sections field in the core_ops structure
- here, otherwise we dereference a potential dangling pointer
- for each call to target_read/write_memory within this routine. */
- update_coreops = core_ops.to_sections == target->to_sections;
-
- /* Reallocate the target's section table including the new size. */
- if (target->to_sections)
- {
- old = target->to_sections_end - target->to_sections;
- target->to_sections = (struct section_table *)
- xrealloc ((char *) target->to_sections,
- (sizeof (struct section_table)) * (count + old));
- }
- else
- {
- old = 0;
- target->to_sections = (struct section_table *)
- xmalloc ((sizeof (struct section_table)) * count);
- }
- target->to_sections_end = target->to_sections + (count + old);
-
- /* Update the to_sections field in the core_ops structure
- if needed. */
- if (update_coreops)
- {
- core_ops.to_sections = target->to_sections;
- core_ops.to_sections_end = target->to_sections_end;
- }
-
/* Add these section table entries to the target's table. */
+
+ old = target_resize_to_sections (target, count);
+
while ((so = find_solib (so)) != NULL)
{
if (so->so_name[0])
*/
static void
-info_sharedlibrary_command (ignore, from_tty)
- char *ignore;
- int from_tty;
+info_sharedlibrary_command (char *ignore, int from_tty)
{
register struct so_list *so = NULL; /* link map state variable */
int header_done = 0;
if (exec_bfd == NULL)
{
- printf_unfiltered ("No exec file.\n");
+ printf_unfiltered ("No executable file.\n");
return;
}
while ((so = find_solib (so)) != NULL)
*/
char *
-solib_address (address)
- CORE_ADDR address;
+solib_address (CORE_ADDR address)
{
register struct so_list *so = 0; /* link map state variable */
/* Called by free_all_symtabs */
void
-clear_solib ()
+clear_solib (void)
{
struct so_list *next;
char *bfd_filename;
{
if (so_list_head->sections)
{
- free ((PTR) so_list_head->sections);
+ xfree (so_list_head->sections);
}
if (so_list_head->abfd)
{
next = so_list_head->next;
if (bfd_filename)
- free ((PTR) bfd_filename);
- free ((PTR) so_list_head);
+ xfree (bfd_filename);
+ xfree (so_list_head);
so_list_head = next;
}
}
*/
void
-solib_create_inferior_hook ()
+solib_create_inferior_hook (void)
{
/* Nothing to do for statically bound executables. */
*/
static void
-sharedlibrary_command (args, from_tty)
- char *args;
- int from_tty;
+sharedlibrary_command (char *args, int from_tty)
{
dont_repeat ();
solib_add (args, from_tty, (struct target_ops *) 0);
}
void
-_initialize_solib ()
+_initialize_solib (void)
{
add_com ("sharedlibrary", class_files, sharedlibrary_command,
"Load shared object library symbols for files matching REGEXP.");