gdbcore.h 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208
  1. /* Machine independent variables that describe the core file under GDB.
  2. Copyright (C) 1986-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. /* Interface routines for core, executable, etc. */
  15. #if !defined (GDBCORE_H)
  16. #define GDBCORE_H 1
  17. struct type;
  18. struct regcache;
  19. #include "bfd.h"
  20. #include "exec.h"
  21. #include "target.h"
  22. /* Nonzero if there is a core file. */
  23. extern int have_core_file_p (void);
  24. /* Report a memory error with error(). */
  25. extern void memory_error (enum target_xfer_status status, CORE_ADDR memaddr);
  26. /* The string 'memory_error' would use as exception message. */
  27. extern std::string memory_error_message (enum target_xfer_status err,
  28. struct gdbarch *gdbarch,
  29. CORE_ADDR memaddr);
  30. /* Like target_read_memory, but report an error if can't read. */
  31. extern void read_memory (CORE_ADDR memaddr, gdb_byte *myaddr, ssize_t len);
  32. /* Like target_read_stack, but report an error if can't read. */
  33. extern void read_stack (CORE_ADDR memaddr, gdb_byte *myaddr, ssize_t len);
  34. /* Like target_read_code, but report an error if can't read. */
  35. extern void read_code (CORE_ADDR memaddr, gdb_byte *myaddr, ssize_t len);
  36. /* Read an integer from debugged memory, given address and number of
  37. bytes. */
  38. extern LONGEST read_memory_integer (CORE_ADDR memaddr,
  39. int len, enum bfd_endian byte_order);
  40. extern int safe_read_memory_integer (CORE_ADDR memaddr, int len,
  41. enum bfd_endian byte_order,
  42. LONGEST *return_value);
  43. /* Read an unsigned integer from debugged memory, given address and
  44. number of bytes. */
  45. extern ULONGEST read_memory_unsigned_integer (CORE_ADDR memaddr,
  46. int len,
  47. enum bfd_endian byte_order);
  48. extern int safe_read_memory_unsigned_integer (CORE_ADDR memaddr, int len,
  49. enum bfd_endian byte_order,
  50. ULONGEST *return_value);
  51. /* Read an integer from debugged code memory, given address,
  52. number of bytes, and byte order for code. */
  53. extern LONGEST read_code_integer (CORE_ADDR memaddr, int len,
  54. enum bfd_endian byte_order);
  55. /* Read an unsigned integer from debugged code memory, given address,
  56. number of bytes, and byte order for code. */
  57. extern ULONGEST read_code_unsigned_integer (CORE_ADDR memaddr,
  58. int len,
  59. enum bfd_endian byte_order);
  60. /* Read the pointer of type TYPE at ADDR, and return the address it
  61. represents. */
  62. CORE_ADDR read_memory_typed_address (CORE_ADDR addr, struct type *type);
  63. /* Same as target_write_memory, but report an error if can't
  64. write. */
  65. extern void write_memory (CORE_ADDR memaddr, const gdb_byte *myaddr,
  66. ssize_t len);
  67. /* Same as write_memory, but notify 'memory_changed' observers. */
  68. extern void write_memory_with_notification (CORE_ADDR memaddr,
  69. const bfd_byte *myaddr,
  70. ssize_t len);
  71. /* Store VALUE at ADDR in the inferior as a LEN-byte unsigned integer. */
  72. extern void write_memory_unsigned_integer (CORE_ADDR addr, int len,
  73. enum bfd_endian byte_order,
  74. ULONGEST value);
  75. /* Store VALUE at ADDR in the inferior as a LEN-byte unsigned integer. */
  76. extern void write_memory_signed_integer (CORE_ADDR addr, int len,
  77. enum bfd_endian byte_order,
  78. LONGEST value);
  79. /* Hook for `exec_file_command' command to call. */
  80. extern void (*deprecated_exec_file_display_hook) (const char *filename);
  81. /* Hook for "file_command", which is more useful than above
  82. (because it is invoked AFTER symbols are read, not before). */
  83. extern void (*deprecated_file_changed_hook) (const char *filename);
  84. extern void specify_exec_file_hook (void (*hook) (const char *filename));
  85. /* Binary File Diddler for the core file. */
  86. #define core_bfd (current_program_space->cbfd.get ())
  87. /* Whether to open exec and core files read-only or read-write. */
  88. extern bool write_files;
  89. /* Open and set up the core file bfd. */
  90. extern void core_target_open (const char *arg, int from_tty);
  91. extern void core_file_command (const char *filename, int from_tty);
  92. extern void exec_file_attach (const char *filename, int from_tty);
  93. /* If the filename of the main executable is unknown, attempt to
  94. determine it. If a filename is determined, proceed as though
  95. it was just specified with the "file" command. Do nothing if
  96. the filename of the main executable is already known.
  97. DEFER_BP_RESET uses SYMFILE_DEFER_BP_RESET for the main symbol file. */
  98. extern void exec_file_locate_attach (int pid, int defer_bp_reset, int from_tty);
  99. extern void validate_files (void);
  100. /* Give the user a message if the current exec file does not match the exec
  101. file determined from the target. In case of mismatch, ask the user
  102. if the exec file determined from target must be loaded. */
  103. extern void validate_exec_file (int from_tty);
  104. /* The current default bfd target. */
  105. extern const char *gnutarget;
  106. extern void set_gnutarget (const char *);
  107. /* Build either a single-thread or multi-threaded section name for
  108. PTID.
  109. If ptid's lwp member is zero, we want to do the single-threaded
  110. thing: look for a section named NAME (as passed to the
  111. constructor). If ptid's lwp member is non-zero, we'll want do the
  112. multi-threaded thing: look for a section named "NAME/LWP", where
  113. LWP is the shortest ASCII decimal representation of ptid's lwp
  114. member. */
  115. class thread_section_name
  116. {
  117. public:
  118. /* NAME is the single-threaded section name. If PTID represents an
  119. LWP, then the build section name is "NAME/LWP", otherwise it's
  120. just "NAME" unmodified. */
  121. thread_section_name (const char *name, ptid_t ptid)
  122. {
  123. if (ptid.lwp_p ())
  124. {
  125. m_storage = string_printf ("%s/%ld", name, ptid.lwp ());
  126. m_section_name = m_storage.c_str ();
  127. }
  128. else
  129. m_section_name = name;
  130. }
  131. /* Return the computed section name. The result is valid as long as
  132. this thread_section_name object is live. */
  133. const char *c_str () const
  134. { return m_section_name; }
  135. DISABLE_COPY_AND_ASSIGN (thread_section_name);
  136. private:
  137. /* Either a pointer into M_STORAGE, or a pointer to the name passed
  138. as parameter to the constructor. */
  139. const char *m_section_name;
  140. /* If we need to build a new section name, this is where we store
  141. it. */
  142. std::string m_storage;
  143. };
  144. #endif /* !defined (GDBCORE_H) */