gdb/solist.h - gdb

Data types defined

Macros defined

Source code

  1. /* Shared library declarations for GDB, the GNU Debugger.
  2.    Copyright (C) 1990-2015 Free Software Foundation, Inc.

  3.    This file is part of GDB.

  4.    This program is free software; you can redistribute it and/or modify
  5.    it under the terms of the GNU General Public License as published by
  6.    the Free Software Foundation; either version 3 of the License, or
  7.    (at your option) any later version.

  8.    This program is distributed in the hope that it will be useful,
  9.    but WITHOUT ANY WARRANTY; without even the implied warranty of
  10.    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  11.    GNU General Public License for more details.

  12.    You should have received a copy of the GNU General Public License
  13.    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */

  14. #ifndef SOLIST_H
  15. #define SOLIST_H

  16. #define SO_NAME_MAX_PATH_SIZE 512        /* FIXME: Should be dynamic */
  17. /* For domain_enum domain.  */
  18. #include "symtab.h"

  19. /* Forward declaration for target specific link map information.  This
  20.    struct is opaque to all but the target specific file.  */
  21. struct lm_info;

  22. struct so_list
  23.   {
  24.     /* The following fields of the structure come directly from the
  25.        dynamic linker's tables in the inferior, and are initialized by
  26.        current_sos.  */

  27.     struct so_list *next;        /* next structure in linked list */

  28.     /* A pointer to target specific link map information.  Often this
  29.        will be a copy of struct link_map from the user process, but
  30.        it need not be; it can be any collection of data needed to
  31.        traverse the dynamic linker's data structures.  */
  32.     struct lm_info *lm_info;

  33.     /* Shared object file name, exactly as it appears in the
  34.        inferior's link map.  This may be a relative path, or something
  35.        which needs to be looked up in LD_LIBRARY_PATH, etc.  We use it
  36.        to tell which entries in the inferior's dynamic linker's link
  37.        map we've already loaded.  */
  38.     char so_original_name[SO_NAME_MAX_PATH_SIZE];

  39.     /* Shared object file name, expanded to something GDB can open.  */
  40.     char so_name[SO_NAME_MAX_PATH_SIZE];

  41.     /* Program space this shared library belongs to.  */
  42.     struct program_space *pspace;

  43.     /* The following fields of the structure are built from
  44.        information gathered from the shared object file itself, and
  45.        are set when we actually add it to our symbol tables.

  46.        current_sos must initialize these fields to 0.  */

  47.     bfd *abfd;
  48.     char symbols_loaded;        /* flag: symbols read in yet?  */

  49.     /* objfile with symbols for a loaded library.  Target memory is read from
  50.        ABFD.  OBJFILE may be NULL either before symbols have been loaded, if
  51.        the file cannot be found or after the command "nosharedlibrary".  */
  52.     struct objfile *objfile;

  53.     struct target_section *sections;
  54.     struct target_section *sections_end;

  55.     /* Record the range of addresses belonging to this shared library.
  56.        There may not be just one (e.g. if two segments are relocated
  57.        differently); but this is only used for "info sharedlibrary".  */
  58.     CORE_ADDR addr_low, addr_high;
  59.   };

  60. struct target_so_ops
  61.   {
  62.     /* Adjust the section binding addresses by the base address at
  63.        which the object was actually mapped.  */
  64.     void (*relocate_section_addresses) (struct so_list *so,
  65.                                         struct target_section *);

  66.     /* Free the link map info and any other private data structures
  67.        associated with a so_list entry.  */
  68.     void (*free_so) (struct so_list *so);

  69.     /* Reset private data structures associated with SO.
  70.        This is called when SO is about to be reloaded.
  71.        It is also called before free_so when SO is about to be freed.  */
  72.     void (*clear_so) (struct so_list *so);

  73.     /* Reset or free private data structures not associated with
  74.        so_list entries.  */
  75.     void (*clear_solib) (void);

  76.     /* Target dependent code to run after child process fork.  */
  77.     void (*solib_create_inferior_hook) (int from_tty);

  78.     /* Do additional symbol handling, lookup, etc. after symbols for a
  79.        shared object have been loaded in the usual way.  This is
  80.        called to do any system specific symbol handling that might be
  81.        needed.  */
  82.     void (*special_symbol_handling) (void);

  83.     /* Construct a list of the currently loaded shared objects.  This
  84.        list does not include an entry for the main executable file.

  85.        Note that we only gather information directly available from the
  86.        inferior --- we don't examine any of the shared library files
  87.        themselves.  The declaration of `struct so_list' says which fields
  88.        we provide values for.  */
  89.     struct so_list *(*current_sos) (void);

  90.     /* Find, open, and read the symbols for the main executable.  If
  91.        FROM_TTYP dereferences to a non-zero integer, allow messages to
  92.        be printed.  This parameter is a pointer rather than an int
  93.        because open_symbol_file_object is called via catch_errors and
  94.        catch_errors requires a pointer argument.  */
  95.     int (*open_symbol_file_object) (void *from_ttyp);

  96.     /* Determine if PC lies in the dynamic symbol resolution code of
  97.        the run time loader.  */
  98.     int (*in_dynsym_resolve_code) (CORE_ADDR pc);

  99.     /* Find and open shared library binary file.  */
  100.     bfd *(*bfd_open) (char *pathname);

  101.     /* Optional extra hook for finding and opening a solib.
  102.        If TEMP_PATHNAME is non-NULL: If the file is successfully opened a
  103.        pointer to a malloc'd and realpath'd copy of SONAME is stored there,
  104.        otherwise NULL is stored there.  */
  105.     int (*find_and_open_solib) (char *soname,
  106.         unsigned o_flags, char **temp_pathname);

  107.     /* Hook for looking up global symbols in a library-specific way.  */
  108.     struct symbol * (*lookup_lib_global_symbol) (struct objfile *objfile,
  109.                                                  const char *name,
  110.                                                  const domain_enum domain);

  111.     /* Given two so_list objects, one from the GDB thread list
  112.        and another from the list returned by current_sos, return 1
  113.        if they represent the same library.
  114.        Falls back to using strcmp on so_original_name field when set
  115.        to NULL.  */
  116.     int (*same) (struct so_list *gdb, struct so_list *inferior);

  117.     /* Return whether a region of memory must be kept in a core file
  118.        for shared libraries loaded before "gcore" is used to be
  119.        handled correctly when the core file is loaded.  This only
  120.        applies when the section would otherwise not be kept in the
  121.        core file (in particular, for readonly sections).  */
  122.     int (*keep_data_in_core) (CORE_ADDR vaddr,
  123.                               unsigned long size);

  124.     /* Enable or disable optional solib event breakpoints as
  125.        appropriate.  This should be called whenever
  126.        stop_on_solib_events is changed.  This pointer can be
  127.        NULL, in which case no enabling or disabling is necessary
  128.        for this target.  */
  129.     void (*update_breakpoints) (void);

  130.     /* Target-specific processing of solib events that will be
  131.        performed before solib_add is called.  This pointer can be
  132.        NULL, in which case no specific preprocessing is necessary
  133.        for this target.  */
  134.     void (*handle_event) (void);
  135.   };

  136. /* Free the memory associated with a (so_list *).  */
  137. void free_so (struct so_list *so);

  138. /* Return address of first so_list entry in master shared object list.  */
  139. struct so_list *master_so_list (void);

  140. /* Find shared library binary file.  */
  141. extern char *solib_find (char *in_pathname, int *fd);

  142. /* Open BFD for shared library file.  */
  143. extern bfd *solib_bfd_fopen (char *pathname, int fd);

  144. /* Find solib binary file and open it.  */
  145. extern bfd *solib_bfd_open (char *in_pathname);

  146. /* FIXME: gdbarch needs to control this variable.  */
  147. extern struct target_so_ops *current_target_so_ops;

  148. /* Handler for library-specific global symbol lookup in solib.c.  */
  149. struct symbol *solib_global_lookup (struct objfile *objfile,
  150.                                     const char *name,
  151.                                     const domain_enum domain);

  152. #endif