symtab.h 8.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228
  1. /* Symbol table definitions for GDB.
  2. Copyright (C) 1986 Free Software Foundation, Inc.
  3. GDB is distributed in the hope that it will be useful, but WITHOUT ANY
  4. WARRANTY. No author or distributor accepts responsibility to anyone
  5. for the consequences of using it or for whether it serves any
  6. particular purpose or works at all, unless he says so in writing.
  7. Refer to the GDB General Public License for full details.
  8. Everyone is granted permission to copy, modify and redistribute GDB,
  9. but only under the conditions described in the GDB General Public
  10. License. A copy of this license is supposed to have been given to you
  11. along with GDB so you can know your rights and responsibilities. It
  12. should be in a file named COPYING. Among other things, the copyright
  13. notice and this notice must be preserved on all copies.
  14. In other words, go ahead and share GDB, but don't try to stop
  15. anyone else from sharing it farther. Help stamp out software hoarding!
  16. */
  17. /* An obstack to hold objects that should be freed
  18. when we load a new symbol table.
  19. This includes the symbols made by dbxread
  20. and the types that are not permanent. */
  21. extern struct obstack *symbol_obstack;
  22. /* Some definitions and declarations to go with use of obstacks. */
  23. #define obstack_chunk_alloc xmalloc
  24. #define obstack_chunk_free free
  25. extern int xmalloc ();
  26. extern void free ();
  27. /* gdb can know one or several symbol tables at the same time;
  28. the ultimate intent is to have one for each separately-compiled module.
  29. Each such symbol table is recorded by a struct symtab, and they
  30. are all chained together. */
  31. /* In addition, gdb can record any number of miscellaneous undebuggable
  32. functions' addresses. In a system that appends _ to function names,
  33. the _'s are removed from the names stored in this table. */
  34. struct misc_function
  35. {
  36. char *name;
  37. CORE_ADDR address;
  38. };
  39. /* Address and length of the vector recording all misc function names/addresses. */
  40. struct misc_function *misc_function_vector;
  41. int misc_function_count;
  42. #include "symseg.h"
  43. /* Each source file is represented by a struct symtab.
  44. These objects are chained through the `next' field. */
  45. struct symtab
  46. {
  47. /* Chain of all existing symtabs. */
  48. struct symtab *next;
  49. /* List of all symbol scope blocks for this symtab. */
  50. struct blockvector *blockvector;
  51. /* Table mapping core addresses to line numbers for this file. */
  52. struct linetable *linetable;
  53. /* Vector containing all types defined for this symtab. */
  54. struct typevector *typevector;
  55. /* Name of this source file. */
  56. char *filename;
  57. /* This component says how to free the data we point to:
  58. free_contents => do a tree walk and free each object.
  59. free_explicit => free what free_ptr points at.
  60. free_nothing => do nothing; some other symtab will free
  61. the data this one uses.
  62. free_linetable => free just the linetable. */
  63. enum free_code {free_nothing, free_contents, free_explicit, free_linetable}
  64. free_code;
  65. /* Pointer to storage to be freed, in case of free_explicit. */
  66. char *free_ptr;
  67. /* Total number of lines found in source file. */
  68. int nlines;
  69. /* Array mapping line number to character position. */
  70. int *line_charpos;
  71. /* Language of this source file. */
  72. enum language language;
  73. /* String of version information. May be zero. */
  74. char *version;
  75. /* String of compilation information. May be zero. */
  76. char *compilation;
  77. /* Offset within loader symbol table
  78. of first local symbol for this file. */
  79. int ldsymoff;
  80. };
  81. /* This is the list of struct symtab's that gdb considers current. */
  82. struct symtab *symtab_list;
  83. /* This symtab variable specifies the current file for printing source lines */
  84. struct symtab *current_source_symtab;
  85. /* This is the next line to print for listing source lines. */
  86. int current_source_line;
  87. #define BLOCKLIST(symtab) (symtab)->blockvector
  88. #define BLOCKVECTOR(symtab) (symtab)->blockvector
  89. #define TYPEVECTOR(symtab) (symtab)->typevector
  90. #define LINELIST(symtab) (symtab)->linetable
  91. #define LINETABLE(symtab) (symtab)->linetable
  92. /* Recording the code addresses of source lines. */
  93. struct linetable
  94. {
  95. int nitems;
  96. int item[1];
  97. };
  98. /* Each item is either minus a line number, or a program counter.
  99. If it represents a line number, that is the line described by the next
  100. program counter value. If it is positive, it is the program
  101. counter at which the code for the next line starts.
  102. Consecutive lines can be recorded by program counter entries
  103. with no line number entries between them. Line number entries
  104. are used when there are lines to skip with no code on them.
  105. This is to make the table shorter. */
  106. /* Macros normally used to access components of symbol table structures. */
  107. #define BLOCKLIST_NBLOCKS(blocklist) (blocklist)->nblocks
  108. #define BLOCKLIST_BLOCK(blocklist,n) (blocklist)->block[n]
  109. #define BLOCKVECTOR_NBLOCKS(blocklist) (blocklist)->nblocks
  110. #define BLOCKVECTOR_BLOCK(blocklist,n) (blocklist)->block[n]
  111. #define TYPEVECTOR_NTYPES(typelist) (typelist)->length
  112. #define TYPEVECTOR_TYPE(typelist,n) (typelist)->type[n]
  113. #define BLOCK_START(bl) (bl)->startaddr
  114. #define BLOCK_END(bl) (bl)->endaddr
  115. #define BLOCK_NSYMS(bl) (bl)->nsyms
  116. #define BLOCK_SYM(bl, n) (bl)->sym[n]
  117. #define BLOCK_FUNCTION(bl) (bl)->function
  118. #define BLOCK_SUPERBLOCK(bl) (bl)->superblock
  119. #define SYMBOL_NAME(symbol) (symbol)->name
  120. #define SYMBOL_NAMESPACE(symbol) (symbol)->namespace
  121. #define SYMBOL_CLASS(symbol) (symbol)->class
  122. #define SYMBOL_VALUE(symbol) (symbol)->value.value
  123. #define SYMBOL_BLOCK_VALUE(symbol) (symbol)->value.block
  124. #define SYMBOL_TYPE(symbol) (symbol)->type
  125. /* This appears in a type's flags word
  126. if it is a (pointer to a|function returning a)* built in scalar type.
  127. These types are never freed. */
  128. #define TYPE_FLAG_PERM 4
  129. #define TYPE_NAME(thistype) (thistype)->name
  130. #define TYPE_TARGET_TYPE(thistype) (thistype)->target_type
  131. #define TYPE_POINTER_TYPE(thistype) (thistype)->pointer_type
  132. #define TYPE_FUNCTION_TYPE(thistype) (thistype)->function_type
  133. #define TYPE_LENGTH(thistype) (thistype)->length
  134. #define TYPE_FLAGS(thistype) (thistype)->flags
  135. #define TYPE_UNSIGNED(thistype) ((thistype)->flags & TYPE_FLAG_UNSIGNED)
  136. #define TYPE_CODE(thistype) (thistype)->code
  137. #define TYPE_NFIELDS(thistype) (thistype)->nfields
  138. #define TYPE_FIELDS(thistype) (thistype)->fields
  139. #define TYPE_FIELD(thistype, n) (thistype)->fields[n]
  140. #define TYPE_FIELD_TYPE(thistype, n) (thistype)->fields[n].type
  141. #define TYPE_FIELD_NAME(thistype, n) (thistype)->fields[n].name
  142. #define TYPE_FIELD_VALUE(thistype, n) (* (int*) &(thistype)->fields[n].type)
  143. #define TYPE_FIELD_BITPOS(thistype, n) (thistype)->fields[n].bitpos
  144. #define TYPE_FIELD_BITSIZE(thistype, n) (thistype)->fields[n].bitsize
  145. #define TYPE_FIELD_PACKED(thistype, n) (thistype)->fields[n].bitsize
  146. /* Functions that work on the objects described above */
  147. extern struct symtab *lookup_symtab ();
  148. extern struct symbol *lookup_symbol ();
  149. extern struct type *lookup_typename ();
  150. extern struct type *lookup_unsigned_typename ();
  151. extern struct type *lookup_struct ();
  152. extern struct type *lookup_union ();
  153. extern struct type *lookup_enum ();
  154. extern struct type *lookup_pointer_type ();
  155. extern struct type *lookup_function_type ();
  156. extern struct symbol *block_function ();
  157. extern struct symbol *find_pc_function ();
  158. extern int find_pc_misc_function ();
  159. extern struct type *builtin_type_void;
  160. extern struct type *builtin_type_char;
  161. extern struct type *builtin_type_short;
  162. extern struct type *builtin_type_int;
  163. extern struct type *builtin_type_long;
  164. extern struct type *builtin_type_unsigned_char;
  165. extern struct type *builtin_type_unsigned_short;
  166. extern struct type *builtin_type_unsigned_int;
  167. extern struct type *builtin_type_unsigned_long;
  168. extern struct type *builtin_type_float;
  169. extern struct type *builtin_type_double;
  170. struct symtab_and_line
  171. {
  172. struct symtab *symtab;
  173. int line;
  174. CORE_ADDR pc;
  175. CORE_ADDR end;
  176. };
  177. /* Given a pc value, return line number it is in.
  178. Second arg nonzero means if pc is on the boundary
  179. use the previous statement's line number. */
  180. struct symtab_and_line find_pc_line ();
  181. /* Given a string, return the line specified by it.
  182. For commands like "list" and "breakpoint". */
  183. struct symtab_and_line decode_line_spec ();
  184. struct symtab_and_line decode_line_1 ();