symtab.h 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  1. /* symtab.h
  2. Copyright (C) 2000-2022 Free Software Foundation, Inc.
  3. This file is part of GNU Binutils.
  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, write to the Free Software
  14. Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
  15. MA 02110-1301, USA. */
  16. #ifndef symtab_h
  17. #define symtab_h
  18. /* For a profile to be intelligible to a human user, it is necessary
  19. to map code-addresses into source-code information. Source-code
  20. information can be any combination of: (i) function-name, (ii)
  21. source file-name, and (iii) source line number.
  22. The symbol table is used to map addresses into source-code
  23. information. */
  24. #define NBBS 10
  25. /* Symbol-entry. For each external in the specified file we gather
  26. its address, the number of calls and compute its share of cpu time. */
  27. typedef struct sym
  28. {
  29. /* Common information:
  30. In the symbol-table, fields ADDR and FUNC_NAME are guaranteed
  31. to contain valid information. FILE may be 0, if unknown and
  32. LINE_NUM maybe 0 if unknown. */
  33. bfd_vma addr; /* Address of entry point. */
  34. bfd_vma end_addr; /* End-address. */
  35. const char *name; /* Name of function this sym is from. */
  36. Source_File *file; /* Source file symbol comes from. */
  37. int line_num; /* Source line number. */
  38. unsigned int /* Boolean fields: */
  39. is_func:1, /* Is this a function entry point? */
  40. is_static:1, /* Is this a local (static) symbol? */
  41. is_bb_head:1, /* Is this the head of a basic-blk? */
  42. mapped:1, /* This symbol was mapped to another name. */
  43. has_been_placed:1; /* Have we placed this symbol? */
  44. unsigned long ncalls; /* How many times executed */
  45. int nuses; /* How many times this symbol appears in
  46. a particular context. */
  47. bfd_vma bb_addr[NBBS]; /* Address of basic-block start. */
  48. unsigned long bb_calls[NBBS];/* How many times basic-block was called. */
  49. struct sym *next; /* For building chains of syms. */
  50. struct sym *prev; /* For building chains of syms. */
  51. /* Profile specific information: */
  52. /* Histogram specific information: */
  53. struct
  54. {
  55. double time; /* (Weighted) ticks in this routine. */
  56. bfd_vma scaled_addr; /* Scaled entry point. */
  57. }
  58. hist;
  59. /* Call-graph specific information: */
  60. struct
  61. {
  62. unsigned long self_calls; /* How many calls to self. */
  63. double child_time; /* Cumulative ticks in children. */
  64. int index; /* Index in the graph list. */
  65. int top_order; /* Graph call chain top-sort order. */
  66. bool print_flag; /* Should this be printed? */
  67. struct
  68. {
  69. double fract; /* What % of time propagates. */
  70. double self; /* How much self time propagates. */
  71. double child; /* How much child time propagates. */
  72. }
  73. prop;
  74. struct
  75. {
  76. int num; /* Internal number of cycle on. */
  77. struct sym *head; /* Head of cycle. */
  78. struct sym *next; /* Next member of cycle. */
  79. }
  80. cyc;
  81. struct arc *parents; /* List of caller arcs. */
  82. struct arc *children; /* List of callee arcs. */
  83. }
  84. cg;
  85. }
  86. Sym;
  87. /* Symbol-tables are always assumed to be sorted
  88. in increasing order of addresses. */
  89. typedef struct
  90. {
  91. unsigned int len; /* # of symbols in this table. */
  92. Sym *base; /* First element in symbol table. */
  93. Sym *limit; /* Limit = base + len. */
  94. }
  95. Sym_Table;
  96. extern Sym_Table symtab; /* The symbol table. */
  97. extern void sym_init (Sym *);
  98. extern void symtab_finalize (Sym_Table *);
  99. #ifdef DEBUG
  100. extern Sym *dbg_sym_lookup (Sym_Table *, bfd_vma);
  101. #endif
  102. extern Sym *sym_lookup (Sym_Table *, bfd_vma);
  103. extern void find_call (Sym *, bfd_vma, bfd_vma);
  104. #endif /* symtab_h */