jit.h 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  1. /* JIT declarations for GDB, the GNU Debugger.
  2. Copyright (C) 2009-2022 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 JIT_H
  15. #define JIT_H
  16. struct inferior;
  17. struct objfile;
  18. struct minimal_symbol;
  19. /* When the JIT breakpoint fires, the inferior wants us to take one of
  20. these actions. These values are used by the inferior, so the
  21. values of these enums cannot be changed. */
  22. typedef enum
  23. {
  24. JIT_NOACTION = 0,
  25. JIT_REGISTER,
  26. JIT_UNREGISTER
  27. } jit_actions_t;
  28. /* This struct describes a single symbol file in a linked list of
  29. symbol files describing generated code. As the inferior generates
  30. code, it adds these entries to the list, and when we attach to the
  31. inferior, we read them all. For the first element prev_entry
  32. should be NULL, and for the last element next_entry should be
  33. NULL. */
  34. struct jit_code_entry
  35. {
  36. CORE_ADDR next_entry;
  37. CORE_ADDR prev_entry;
  38. CORE_ADDR symfile_addr;
  39. ULONGEST symfile_size;
  40. };
  41. /* This is the global descriptor that the inferior uses to communicate
  42. information to the debugger. To alert the debugger to take an
  43. action, the inferior sets the action_flag to the appropriate enum
  44. value, updates relevant_entry to point to the relevant code entry,
  45. and calls the function at the well-known symbol with our
  46. breakpoint. We then read this descriptor from another global
  47. well-known symbol. */
  48. struct jit_descriptor
  49. {
  50. uint32_t version;
  51. /* This should be jit_actions_t, but we want to be specific about the
  52. bit-width. */
  53. uint32_t action_flag;
  54. CORE_ADDR relevant_entry;
  55. CORE_ADDR first_entry;
  56. };
  57. /* An objfile that defines the required symbols of the JIT interface has an
  58. instance of this type attached to it. */
  59. struct jiter_objfile_data
  60. {
  61. ~jiter_objfile_data ();
  62. /* Symbol for __jit_debug_register_code. */
  63. minimal_symbol *register_code = nullptr;
  64. /* Symbol for __jit_debug_descriptor. */
  65. minimal_symbol *descriptor = nullptr;
  66. /* This is the relocated address of the __jit_debug_register_code function
  67. provided by this objfile. This is used to detect relocations changes
  68. requiring the breakpoint to be re-created. */
  69. CORE_ADDR cached_code_address = 0;
  70. /* This is the JIT event breakpoint, or nullptr if it has been deleted. */
  71. breakpoint *jit_breakpoint = nullptr;
  72. };
  73. /* An objfile that is the product of JIT compilation and was registered
  74. using the JIT interface has an instance of this type attached to it. */
  75. struct jited_objfile_data
  76. {
  77. jited_objfile_data (CORE_ADDR addr, CORE_ADDR symfile_addr,
  78. ULONGEST symfile_size)
  79. : addr (addr),
  80. symfile_addr (symfile_addr),
  81. symfile_size (symfile_size)
  82. {}
  83. /* Address of struct jit_code_entry for this objfile. */
  84. CORE_ADDR addr;
  85. /* Value of jit_code_entry->symfile_addr for this objfile. */
  86. CORE_ADDR symfile_addr;
  87. /* Value of jit_code_entry->symfile_size for this objfile. */
  88. ULONGEST symfile_size;
  89. };
  90. /* Re-establish the jit breakpoint(s). */
  91. extern void jit_breakpoint_re_set (void);
  92. /* This function is called by handle_inferior_event when it decides
  93. that the JIT event breakpoint has fired. JITER is the objfile
  94. whose JIT event breakpoint has been hit. */
  95. extern void jit_event_handler (gdbarch *gdbarch, objfile *jiter);
  96. #endif /* JIT_H */