- Copyright 1993, 1994, 1995, 1996, 1998 Free Software Foundation, Inc.
-
-This file is part of GDB.
+ Copyright 1993, 1994, 1995, 1996, 1998, 1999, 2000
+ Free Software Foundation, Inc.
-This program is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2 of the License, or
-(at your option) any later version.
+ This file is part of GDB.
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
-You should have received a copy of the GNU General Public License
-along with this program; if not, write to the Free Software
-Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA. */
- These are not documented, and they are not defined in the system
- header files. The definitions below were obtained by experimentation,
- but they seem stable enough.
+ These are not documented, and they are not defined in the system
+ header files. The definitions below were obtained by experimentation,
+ but they seem stable enough.
- equivalent ldr_* routines.
- This approach is somewhat cleaner, but it requires that the GDB
- executable is dynamically linked. In addition it requires a
- NAT_CLIBS= -lxproc -Wl,-expect_unresolved,ldr_process_context
- linker specification for GDB and all applications that are using
- libgdb.
+ equivalent ldr_* routines.
+ This approach is somewhat cleaner, but it requires that the GDB
+ executable is dynamically linked. In addition it requires a
+ NAT_CLIBS= -lxproc -Wl,-expect_unresolved,ldr_process_context
+ linker specification for GDB and all applications that are using
+ libgdb.
ldr_module_info_t module_info; /* corresponding module info */
};
#define LM_OFFSET(so) ((so) -> lm.l_offset)
#define LM_NAME(so) ((so) -> lm.l_name)
ldr_module_info_t module_info; /* corresponding module info */
};
#define LM_OFFSET(so) ((so) -> lm.l_offset)
#define LM_NAME(so) ((so) -> lm.l_name)
-struct so_list {
- struct so_list *next; /* next structure in linked list */
- struct link_map lm; /* copy of link map from inferior */
- struct link_map *lmaddr; /* addr in inferior lm was read from */
- CORE_ADDR lmend; /* upper addr bound of mapped object */
- char so_name[MAX_PATH_SIZE]; /* shared object lib name (FIXME) */
- char symbols_loaded; /* flag: symbols read in yet? */
- char from_tty; /* flag: print msgs? */
- struct objfile *objfile; /* objfile for loaded lib */
- struct section_table *sections;
- struct section_table *sections_end;
- struct section_table *textsection;
- bfd *abfd;
-};
+struct so_list
+ {
+ struct so_list *next; /* next structure in linked list */
+ struct link_map lm; /* copy of link map from inferior */
+ struct link_map *lmaddr; /* addr in inferior lm was read from */
+ CORE_ADDR lmend; /* upper addr bound of mapped object */
+ char so_name[MAX_PATH_SIZE]; /* shared object lib name (FIXME) */
+ char symbols_loaded; /* flag: symbols read in yet? */
+ char from_tty; /* flag: print msgs? */
+ struct objfile *objfile; /* objfile for loaded lib */
+ struct section_table *sections;
+ struct section_table *sections_end;
+ struct section_table *textsection;
+ bfd *abfd;
+ };
- Given a pointer to one of the shared objects in our list
- of mapped objects, use the recorded name to open a bfd
- descriptor for the object, build a section table, and then
- relocate all the section addresses by the base address at
- which the shared object was mapped.
+ Given a pointer to one of the shared objects in our list
+ of mapped objects, use the recorded name to open a bfd
+ descriptor for the object, build a section table, and then
+ relocate all the section addresses by the base address at
+ which the shared object was mapped.
- In most (all?) cases the shared object file name recorded in the
- dynamic linkage tables will be a fully qualified pathname. For
- cases where it isn't, do we really mimic the systems search
- mechanism correctly in the below code (particularly the tilde
- expansion stuff?).
+ In most (all?) cases the shared object file name recorded in the
+ dynamic linkage tables will be a fully qualified pathname. For
+ cases where it isn't, do we really mimic the systems search
+ mechanism correctly in the below code (particularly the tilde
+ expansion stuff?).
scratch_chan = openp (getenv ("PATH"), 1, filename, O_RDONLY, 0,
&scratch_pathname);
if (scratch_chan < 0)
scratch_chan = openp (getenv ("PATH"), 1, filename, O_RDONLY, 0,
&scratch_pathname);
if (scratch_chan < 0)
scratch_pathname, bfd_errmsg (bfd_get_error ()));
}
/* Leave bfd open, core_xfer_memory and "info files" need it. */
scratch_pathname, bfd_errmsg (bfd_get_error ()));
}
/* Leave bfd open, core_xfer_memory and "info files" need it. */
if (!bfd_check_format (abfd, bfd_object))
{
error ("\"%s\": not in executable format: %s.",
scratch_pathname, bfd_errmsg (bfd_get_error ()));
}
if (!bfd_check_format (abfd, bfd_object))
{
error ("\"%s\": not in executable format: %s.",
scratch_pathname, bfd_errmsg (bfd_get_error ()));
}
- object's file by the offset to get the address to which the
- object was actually mapped. */
- p -> addr += LM_OFFSET (so);
- p -> endaddr += LM_OFFSET (so);
- so -> lmend = (CORE_ADDR) max (p -> endaddr, so -> lmend);
- if (STREQ (p -> the_bfd_section -> name, ".text"))
+ object's file by the offset to get the address to which the
+ object was actually mapped. */
+ p->addr += LM_OFFSET (so);
+ p->endaddr += LM_OFFSET (so);
+ so->lmend = (CORE_ADDR) max (p->endaddr, so->lmend);
+ if (STREQ (p->the_bfd_section->name, ".text"))
- Read in a copy of the first member in the inferior's dynamic
- link map from the inferior's dynamic linker structures, and return
- a pointer to the copy in our address space.
-*/
+ Read in a copy of the first member in the inferior's dynamic
+ link map from the inferior's dynamic linker structures, and return
+ a pointer to the copy in our address space.
+ */
ldr_set_core_reader (ldr_read_memory);
ldr_xdetach (fake_ldr_process);
if (ldr_xattach (fake_ldr_process) != 0
ldr_set_core_reader (ldr_read_memory);
ldr_xdetach (fake_ldr_process);
if (ldr_xattach (fake_ldr_process) != 0
- || ldr_inq_module(fake_ldr_process, mod_id,
- &first_lm.module_info, sizeof(ldr_module_info_t),
- &retsize) != 0)
+ || ldr_inq_module (fake_ldr_process, mod_id,
+ &first_lm.module_info, sizeof (ldr_module_info_t),
+ &retsize) != 0)
- || ldr_inq_module(fake_ldr_process, mod_id,
- &next_lm.module_info, sizeof(ldr_module_info_t),
- &retsize) != 0)
+ || ldr_inq_module (fake_ldr_process, mod_id,
+ &next_lm.module_info, sizeof (ldr_module_info_t),
+ &retsize) != 0)
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);
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);
- This module contains the routine which finds the names of any
- loaded "images" in the current process. The argument in must be
- NULL on the first call, and then the returned value must be passed
- in on subsequent calls. This provides the capability to "step" down
- the list of loaded objects. On the last object, a NULL value is
- returned.
+ This module contains the routine which finds the names of any
+ loaded "images" in the current process. The argument in must be
+ NULL on the first call, and then the returned value must be passed
+ in on subsequent calls. This provides the capability to "step" down
+ the list of loaded objects. On the last object, a NULL value is
+ returned.
new = (struct so_list *) xmalloc (sizeof (struct so_list));
memset ((char *) new, 0, sizeof (struct so_list));
new = (struct so_list *) xmalloc (sizeof (struct so_list));
memset ((char *) new, 0, sizeof (struct so_list));
- if (so -> textsection)
- text_addr = so -> textsection -> addr;
- else if (so -> abfd != NULL)
+ memset (§ion_addrs, 0, sizeof (section_addrs));
+ if (so->textsection)
+ text_addr = so->textsection->addr;
+ else if (so->abfd != NULL)
-
- so -> objfile = symbol_file_add (so -> so_name, so -> from_tty,
- text_addr,
- 0, 0, 0);
+
+ section_addrs.other[0].addr = text_addr;
+ section_addrs.other[0].name = ".text";
+ so->objfile = symbol_file_add (so->so_name, so->from_tty,
+ §ion_addrs, 0, OBJF_SHARED);
- void solib_add (char *arg_string, int from_tty,
- struct target_ops *target)
+ void solib_add (char *arg_string, int from_tty,
+ struct target_ops *target)
-solib_add (arg_string, from_tty, target)
- char *arg_string;
- int from_tty;
- struct target_ops *target;
-{
- register struct so_list *so = NULL; /* link map state variable */
+solib_add (char *arg_string, int from_tty, struct target_ops *target)
+{
+ register struct so_list *so = NULL; /* link map state variable */
- 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;
- }
-
- printf_unfiltered("%-20s%-20s%-12s%s\n", "From", "To", "Syms Read",
- "Shared Object Library");
+ printf_unfiltered ("%-20s%-20s%-12s%s\n", "From", "To", "Syms Read",
+ "Shared Object Library");
}
printf_unfiltered ("%-20s", local_hex_string_custom (txt_start, "08l"));
printf_unfiltered ("%-20s", local_hex_string_custom (txt_end, "08l"));
}
printf_unfiltered ("%-20s", local_hex_string_custom (txt_start, "08l"));
printf_unfiltered ("%-20s", local_hex_string_custom (txt_end, "08l"));
- printf_unfiltered ("%-12s", so -> symbols_loaded ? "Yes" : "No");
- printf_unfiltered ("%s\n", so -> so_name);
+ printf_unfiltered ("%-12s", so->symbols_loaded ? "Yes" : "No");
+ printf_unfiltered ("%s\n", so->so_name);
- Provides a hook for other gdb routines to discover whether or
- not a particular address is within the mapped address space of
- a shared library. Any address between the base mapping address
- and the first address beyond the end of the last mapping, is
- considered to be within the shared library address space, for
- our purposes.
+ Provides a hook for other gdb routines to discover whether or
+ not a particular address is within the mapped address space of
+ a shared library. Any address between the base mapping address
+ and the first address beyond the end of the last mapping, is
+ considered to be within the shared library address space, for
+ our purposes.
warning ("cannot close \"%s\": %s",
bfd_filename, bfd_errmsg (bfd_get_error ()));
}
else
/* This happens for the executable on SVR4. */
bfd_filename = NULL;
warning ("cannot close \"%s\": %s",
bfd_filename, bfd_errmsg (bfd_get_error ()));
}
else
/* This happens for the executable on SVR4. */
bfd_filename = NULL;
-
-GLOBAL FUNCTION
-
- solib_create_inferior_hook -- shared library startup support
-
-SYNOPSIS
-
- void solib_create_inferior_hook()
-
-DESCRIPTION
-
- When gdb starts up the inferior, it nurses it along (through the
- shell) until it is ready to execute it's first instruction. At this
- point, this function gets called via expansion of the macro
- SOLIB_CREATE_INFERIOR_HOOK.
- For a statically bound executable, this first instruction is the
- one at "_start", or a similar text label. No further processing is
- needed in that case.
- For a dynamically bound executable, this first instruction is somewhere
- in the rld, and the actual user executable is not yet mapped in.
- We continue the inferior again, rld then maps in the actual user
- executable and any needed shared libraries and then sends
- itself a SIGTRAP.
- At that point we discover the names of all shared libraries and
- read their symbols in.
-
-FIXME
-
- This code does not properly handle hitting breakpoints which the
- user might have set in the rld itself. Proper handling would have
- to check if the SIGTRAP happened due to a kill call.
-
- Also, what if child has exit()ed? Must exit loop somehow.
- */
+
+ GLOBAL FUNCTION
+
+ solib_create_inferior_hook -- shared library startup support
+
+ SYNOPSIS
+
+ void solib_create_inferior_hook()
+
+ DESCRIPTION
+
+ When gdb starts up the inferior, it nurses it along (through the
+ shell) until it is ready to execute it's first instruction. At this
+ point, this function gets called via expansion of the macro
+ SOLIB_CREATE_INFERIOR_HOOK.
+ For a statically bound executable, this first instruction is the
+ one at "_start", or a similar text label. No further processing is
+ needed in that case.
+ For a dynamically bound executable, this first instruction is somewhere
+ in the rld, and the actual user executable is not yet mapped in.
+ We continue the inferior again, rld then maps in the actual user
+ executable and any needed shared libraries and then sends
+ itself a SIGTRAP.
+ At that point we discover the names of all shared libraries and
+ read their symbols in.
+
+ FIXME
+
+ This code does not properly handle hitting breakpoints which the
+ user might have set in the rld itself. Proper handling would have
+ to check if the SIGTRAP happened due to a kill call.
+
+ Also, what if child has exit()ed? Must exit loop somehow.
+ */
which point all of the libraries will have been mapped in and we
can go groveling around in the rld structures to find
out what we need to know about them. */
which point all of the libraries will have been mapped in and we
can go groveling around in the rld structures to find
out what we need to know about them. */
- But we are stopped in the runtime loader and we do not have symbols
- for the runtime loader. So heuristic_proc_start will be called
- and will put out an annoying warning.
- Delaying the resetting of stop_soon_quietly until after symbol loading
- suppresses the warning. */
+ But we are stopped in the runtime loader and we do not have symbols
+ for the runtime loader. So heuristic_proc_start will be called
+ and will put out an annoying warning.
+ Delaying the resetting of stop_soon_quietly until after symbol loading
+ suppresses the warning. */
{
add_com ("sharedlibrary", class_files, sharedlibrary_command,
"Load shared object library symbols for files matching REGEXP.");
{
add_com ("sharedlibrary", class_files, sharedlibrary_command,
"Load shared object library symbols for files matching REGEXP.");