gdb/buildsym.h - gdb

Global variables defined

Data types defined

Macros defined

Source code

  1. /* Build symbol tables in GDB's internal format.
  2.    Copyright (C) 1986-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. #if !defined (BUILDSYM_H)
  15. #define BUILDSYM_H 1

  16. struct objfile;
  17. struct symbol;
  18. struct addrmap;
  19. struct compunit_symtab;

  20. /* This module provides definitions used for creating and adding to
  21.    the symbol table.  These routines are called from various symbol-
  22.    file-reading routines.

  23.    They originated in dbxread.c of gdb-4.2, and were split out to
  24.    make xcoffread.c more maintainable by sharing code.

  25.    Variables declared in this file can be defined by #define-ing the
  26.    name EXTERN to null.  It is used to declare variables that are
  27.    normally extern, but which get defined in a single module using
  28.    this technique.  */

  29. struct block;
  30. struct pending_block;

  31. #ifndef EXTERN
  32. #define        EXTERN extern
  33. #endif

  34. #define HASHSIZE 127                /* Size of things hashed via
  35.                                    hashname().  */

  36. /* Core address of start of text of current source file.  This too
  37.    comes from the N_SO symbol.  For Dwarf it typically comes from the
  38.    DW_AT_low_pc attribute of a DW_TAG_compile_unit DIE.  */

  39. EXTERN CORE_ADDR last_source_start_addr;

  40. /* The list of sub-source-files within the current individual
  41.    compilation.  Each file gets its own symtab with its own linetable
  42.    and associated info, but they all share one blockvector.  */

  43. struct subfile
  44. {
  45.   struct subfile *next;
  46.   /* Space for this is malloc'd.  */
  47.   char *name;
  48.   /* Space for this is malloc'd.  */
  49.   struct linetable *line_vector;
  50.   int line_vector_length;
  51.   /* The "containing" compunit.  */
  52.   struct buildsym_compunit *buildsym_compunit;
  53.   enum language language;
  54.   struct symtab *symtab;
  55. };

  56. EXTERN struct subfile *current_subfile;

  57. /* Global variable which, when set, indicates that we are processing a
  58.    .o file compiled with gcc */

  59. EXTERN unsigned char processing_gcc_compilation;

  60. /* When set, we are processing a .o file compiled by sun acc.  This is
  61.    misnamed; it refers to all stabs-in-elf implementations which use
  62.    N_UNDF the way Sun does, including Solaris gcc.  Hopefully all
  63.    stabs-in-elf implementations ever invented will choose to be
  64.    compatible.  */

  65. EXTERN unsigned char processing_acc_compilation;

  66. /* Count symbols as they are processed, for error messages.  */

  67. EXTERN unsigned int symnum;

  68. /* Record the symbols defined for each context in a list.  We don't
  69.    create a struct block for the context until we know how long to
  70.    make it.  */

  71. #define PENDINGSIZE 100

  72. struct pending
  73.   {
  74.     struct pending *next;
  75.     int nsyms;
  76.     struct symbol *symbol[PENDINGSIZE];
  77.   };

  78. /* Here are the three lists that symbols are put on.  */

  79. /* static at top level, and types */

  80. EXTERN struct pending *file_symbols;

  81. /* global functions and variables */

  82. EXTERN struct pending *global_symbols;

  83. /* everything local to lexical context */

  84. EXTERN struct pending *local_symbols;

  85. /* "using" directives local to lexical context.  */

  86. EXTERN struct using_direct *using_directives;

  87. /* Stack representing unclosed lexical contexts (that will become
  88.    blocks, eventually).  */

  89. struct context_stack
  90.   {
  91.     /* Outer locals at the time we entered */

  92.     struct pending *locals;

  93.     /* Pending using directives at the time we entered.  */

  94.     struct using_direct *using_directives;

  95.     /* Pointer into blocklist as of entry */

  96.     struct pending_block *old_blocks;

  97.     /* Name of function, if any, defining context */

  98.     struct symbol *name;

  99.     /* PC where this context starts */

  100.     CORE_ADDR start_addr;

  101.     /* Temp slot for exception handling.  */

  102.     CORE_ADDR end_addr;

  103.     /* For error-checking matching push/pop */

  104.     int depth;

  105.   };

  106. EXTERN struct context_stack *context_stack;

  107. /* Index of first unused entry in context stack.  */

  108. EXTERN int context_stack_depth;

  109. /* Currently allocated size of context stack.  */

  110. EXTERN int context_stack_size;

  111. /* Non-zero if the context stack is empty.  */
  112. #define outermost_context_p() (context_stack_depth == 0)

  113. /* Nonzero if within a function (so symbols should be local, if
  114.    nothing says specifically).  */

  115. EXTERN int within_function;

  116. /* The type of the record_line function.  */
  117. typedef void (record_line_ftype) (struct subfile *subfile, int line,
  118.                                   CORE_ADDR pc);



  119. #define next_symbol_text(objfile) (*next_symbol_text_func)(objfile)

  120. /* Function to invoke get the next symbol.  Return the symbol name.  */

  121. EXTERN char *(*next_symbol_text_func) (struct objfile *);

  122. extern void add_symbol_to_list (struct symbol *symbol,
  123.                                 struct pending **listhead);

  124. extern struct symbol *find_symbol_in_list (struct pending *list,
  125.                                            char *name, int length);

  126. extern struct block *finish_block (struct symbol *symbol,
  127.                                    struct pending **listhead,
  128.                                    struct pending_block *old_blocks,
  129.                                    CORE_ADDR start, CORE_ADDR end);

  130. extern void record_block_range (struct block *,
  131.                                 CORE_ADDR start, CORE_ADDR end_inclusive);

  132. extern void really_free_pendings (void *dummy);

  133. extern void start_subfile (const char *name);

  134. extern void patch_subfile_names (struct subfile *subfile, char *name);

  135. extern void push_subfile (void);

  136. extern char *pop_subfile (void);

  137. extern struct block *end_symtab_get_static_block (CORE_ADDR end_addr,
  138.                                                   int expandable,
  139.                                                   int required);

  140. extern struct compunit_symtab *
  141.   end_symtab_from_static_block (struct block *static_block,
  142.                                 int section, int expandable);

  143. extern struct compunit_symtab *end_symtab (CORE_ADDR end_addr, int section);

  144. extern struct compunit_symtab *end_expandable_symtab (CORE_ADDR end_addr,
  145.                                                       int section);

  146. extern void augment_type_symtab (void);

  147. /* Defined in stabsread.c.  */

  148. extern void scan_file_globals (struct objfile *objfile);

  149. extern void buildsym_new_init (void);

  150. extern void buildsym_init (void);

  151. extern struct context_stack *push_context (int desc, CORE_ADDR valu);

  152. extern struct context_stack *pop_context (void);

  153. extern record_line_ftype record_line;

  154. extern struct compunit_symtab *start_symtab (struct objfile *objfile,
  155.                                              const char *name,
  156.                                              const char *comp_dir,
  157.                                              CORE_ADDR start_addr);

  158. extern void restart_symtab (struct compunit_symtab *cust,
  159.                             const char *name, CORE_ADDR start_addr);

  160. extern int hashname (const char *name);

  161. extern void free_pending_blocks (void);

  162. /* Record the name of the debug format in the current pending symbol
  163.    table.  FORMAT must be a string with a lifetime at least as long as
  164.    the symtab's objfile.  */

  165. extern void record_debugformat (const char *format);

  166. /* Record the name of the debuginfo producer (usually the compiler) in
  167.    the current pending symbol table.  PRODUCER must be a string with a
  168.    lifetime at least as long as the symtab's objfile.  */

  169. extern void record_producer (const char *producer);

  170. extern void merge_symbol_lists (struct pending **srclist,
  171.                                 struct pending **targetlist);

  172. /* Set the name of the last source file.  NAME is copied by this
  173.    function.  */

  174. extern void set_last_source_file (const char *name);

  175. /* Fetch the name of the last source file.  */

  176. extern const char *get_last_source_file (void);

  177. /* Return the compunit symtab object.
  178.    It is only valid to call this between calls to start_symtab and the
  179.    end_symtab* functions.  */

  180. extern struct compunit_symtab *buildsym_compunit_symtab (void);

  181. /* Return the macro table.
  182.    Initialize it if this is the first use.
  183.    It is only valid to call this between calls to start_symtab and the
  184.    end_symtab* functions.  */

  185. extern struct macro_table *get_macro_table (void);

  186. #undef EXTERN

  187. #endif /* defined (BUILDSYM_H) */