GDB (API)
/home/stan/gdb/src/gdb/solist.h
Go to the documentation of this file.
00001 /* Shared library declarations for GDB, the GNU Debugger.
00002    Copyright (C) 1990-2013 Free Software Foundation, Inc.
00003 
00004    This file is part of GDB.
00005 
00006    This program is free software; you can redistribute it and/or modify
00007    it under the terms of the GNU General Public License as published by
00008    the Free Software Foundation; either version 3 of the License, or
00009    (at your option) any later version.
00010 
00011    This program is distributed in the hope that it will be useful,
00012    but WITHOUT ANY WARRANTY; without even the implied warranty of
00013    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014    GNU General Public License for more details.
00015 
00016    You should have received a copy of the GNU General Public License
00017    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
00018 
00019 #ifndef SOLIST_H
00020 #define SOLIST_H
00021 
00022 #define SO_NAME_MAX_PATH_SIZE 512       /* FIXME: Should be dynamic */
00023 /* For domain_enum domain.  */
00024 #include "symtab.h"
00025 
00026 /* Forward declaration for target specific link map information.  This
00027    struct is opaque to all but the target specific file.  */
00028 struct lm_info;
00029 
00030 struct so_list
00031   {
00032     /* The following fields of the structure come directly from the
00033        dynamic linker's tables in the inferior, and are initialized by
00034        current_sos.  */
00035 
00036     struct so_list *next;       /* next structure in linked list */
00037 
00038     /* A pointer to target specific link map information.  Often this
00039        will be a copy of struct link_map from the user process, but
00040        it need not be; it can be any collection of data needed to
00041        traverse the dynamic linker's data structures.  */
00042     struct lm_info *lm_info;
00043 
00044     /* Shared object file name, exactly as it appears in the
00045        inferior's link map.  This may be a relative path, or something
00046        which needs to be looked up in LD_LIBRARY_PATH, etc.  We use it
00047        to tell which entries in the inferior's dynamic linker's link
00048        map we've already loaded.  */
00049     char so_original_name[SO_NAME_MAX_PATH_SIZE];
00050 
00051     /* Shared object file name, expanded to something GDB can open.  */
00052     char so_name[SO_NAME_MAX_PATH_SIZE];
00053 
00054     /* Program space this shared library belongs to.  */
00055     struct program_space *pspace;
00056 
00057     /* The following fields of the structure are built from
00058        information gathered from the shared object file itself, and
00059        are set when we actually add it to our symbol tables.
00060 
00061        current_sos must initialize these fields to 0.  */
00062 
00063     bfd *abfd;
00064     char symbols_loaded;        /* flag: symbols read in yet?  */
00065 
00066     /* objfile with symbols for a loaded library.  Target memory is read from
00067        ABFD.  OBJFILE may be NULL either before symbols have been loaded, if
00068        the file cannot be found or after the command "nosharedlibrary".  */
00069     struct objfile *objfile;
00070 
00071     struct target_section *sections;
00072     struct target_section *sections_end;
00073 
00074     /* Record the range of addresses belonging to this shared library.
00075        There may not be just one (e.g. if two segments are relocated
00076        differently); but this is only used for "info sharedlibrary".  */
00077     CORE_ADDR addr_low, addr_high;
00078   };
00079 
00080 struct target_so_ops
00081   {
00082     /* Adjust the section binding addresses by the base address at
00083        which the object was actually mapped.  */
00084     void (*relocate_section_addresses) (struct so_list *so,
00085                                         struct target_section *);
00086 
00087     /* Free the link map info and any other private data structures
00088        associated with a so_list entry.  */
00089     void (*free_so) (struct so_list *so);
00090 
00091     /* Reset private data structures associated with SO.
00092        This is called when SO is about to be reloaded.
00093        It is also called before free_so when SO is about to be freed.  */
00094     void (*clear_so) (struct so_list *so);
00095 
00096     /* Reset or free private data structures not associated with
00097        so_list entries.  */
00098     void (*clear_solib) (void);
00099 
00100     /* Target dependent code to run after child process fork.  */
00101     void (*solib_create_inferior_hook) (int from_tty);
00102 
00103     /* Do additional symbol handling, lookup, etc. after symbols for a
00104        shared object have been loaded in the usual way.  This is
00105        called to do any system specific symbol handling that might be
00106        needed.  */
00107     void (*special_symbol_handling) (void);
00108 
00109     /* Construct a list of the currently loaded shared objects.  This
00110        list does not include an entry for the main executable file.
00111 
00112        Note that we only gather information directly available from the
00113        inferior --- we don't examine any of the shared library files
00114        themselves.  The declaration of `struct so_list' says which fields
00115        we provide values for.  */
00116     struct so_list *(*current_sos) (void);
00117 
00118     /* Find, open, and read the symbols for the main executable.  If
00119        FROM_TTYP dereferences to a non-zero integer, allow messages to
00120        be printed.  This parameter is a pointer rather than an int
00121        because open_symbol_file_object is called via catch_errors and
00122        catch_errors requires a pointer argument.  */
00123     int (*open_symbol_file_object) (void *from_ttyp);
00124 
00125     /* Determine if PC lies in the dynamic symbol resolution code of
00126        the run time loader.  */
00127     int (*in_dynsym_resolve_code) (CORE_ADDR pc);
00128 
00129     /* Find and open shared library binary file.  */
00130     bfd *(*bfd_open) (char *pathname);
00131 
00132     /* Optional extra hook for finding and opening a solib.
00133        If TEMP_PATHNAME is non-NULL: If the file is successfully opened a
00134        pointer to a malloc'd and realpath'd copy of SONAME is stored there,
00135        otherwise NULL is stored there.  */
00136     int (*find_and_open_solib) (char *soname,
00137         unsigned o_flags, char **temp_pathname);
00138 
00139     /* Hook for looking up global symbols in a library-specific way.  */
00140     struct symbol * (*lookup_lib_global_symbol) (const struct objfile *objfile,
00141                                                  const char *name,
00142                                                  const domain_enum domain);
00143 
00144     /* Given two so_list objects, one from the GDB thread list
00145        and another from the list returned by current_sos, return 1
00146        if they represent the same library.
00147        Falls back to using strcmp on so_original_name field when set
00148        to NULL.  */
00149     int (*same) (struct so_list *gdb, struct so_list *inferior);
00150 
00151     /* Return whether a region of memory must be kept in a core file
00152        for shared libraries loaded before "gcore" is used to be
00153        handled correctly when the core file is loaded.  This only
00154        applies when the section would otherwise not be kept in the
00155        core file (in particular, for readonly sections).  */
00156     int (*keep_data_in_core) (CORE_ADDR vaddr,
00157                               unsigned long size);
00158 
00159     /* Enable or disable optional solib event breakpoints as
00160        appropriate.  This should be called whenever
00161        stop_on_solib_events is changed.  This pointer can be
00162        NULL, in which case no enabling or disabling is necessary
00163        for this target.  */
00164     void (*update_breakpoints) (void);
00165 
00166     /* Target-specific processing of solib events that will be
00167        performed before solib_add is called.  This pointer can be
00168        NULL, in which case no specific preprocessing is necessary
00169        for this target.  */
00170     void (*handle_event) (void);
00171   };
00172 
00173 /* Free the memory associated with a (so_list *).  */
00174 void free_so (struct so_list *so);
00175 
00176 /* Return address of first so_list entry in master shared object list.  */
00177 struct so_list *master_so_list (void);
00178 
00179 /* Find shared library binary file.  */
00180 extern char *solib_find (char *in_pathname, int *fd);
00181 
00182 /* Open BFD for shared library file.  */
00183 extern bfd *solib_bfd_fopen (char *pathname, int fd);
00184 
00185 /* Find solib binary file and open it.  */
00186 extern bfd *solib_bfd_open (char *in_pathname);
00187 
00188 /* FIXME: gdbarch needs to control this variable.  */
00189 extern struct target_so_ops *current_target_so_ops;
00190 
00191 /* Handler for library-specific global symbol lookup in solib.c.  */
00192 struct symbol *solib_global_lookup (const struct objfile *objfile,
00193                                     const char *name,
00194                                     const domain_enum domain);
00195 
00196 #endif
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Defines