exec.h 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. /* Work with executable files, for GDB, the GNU debugger.
  2. Copyright (C) 2003-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 EXEC_H
  15. #define EXEC_H
  16. #include "target.h"
  17. #include "progspace.h"
  18. #include "memrange.h"
  19. #include "symfile-add-flags.h"
  20. struct target_section;
  21. struct target_ops;
  22. struct bfd;
  23. struct objfile;
  24. /* Builds a section table, given args BFD. */
  25. extern target_section_table build_section_table (struct bfd *);
  26. /* VFORK_CHILD is a child vforked and its program space is shared with its
  27. parent. This pushes the exec target on that inferior's target stack if
  28. there are sections in the program space's section table. */
  29. extern void exec_on_vfork (inferior *vfork_child);
  30. /* Read from mappable read-only sections of BFD executable files.
  31. Return TARGET_XFER_OK, if read is successful. Return
  32. TARGET_XFER_EOF if read is done. Return TARGET_XFER_E_IO
  33. otherwise. */
  34. extern enum target_xfer_status
  35. exec_read_partial_read_only (gdb_byte *readbuf, ULONGEST offset,
  36. ULONGEST len, ULONGEST *xfered_len);
  37. /* Read or write from mappable sections of BFD executable files.
  38. Request to transfer up to LEN 8-bit bytes of the target sections
  39. defined by SECTIONS and SECTIONS_END. The OFFSET specifies the
  40. starting address.
  41. The MATCH_CB predicate is optional; when provided it will be called
  42. for each section under consideration. When MATCH_CB evaluates as
  43. true, the section remains under consideration; a false result
  44. removes it from consideration for performing the memory transfers
  45. noted above. See memory_xfer_partial_1() in target.c for an
  46. example.
  47. Return the number of bytes actually transfered, or zero when no
  48. data is available for the requested range.
  49. This function is intended to be used from target_xfer_partial
  50. implementations. See target_read and target_write for more
  51. information.
  52. One, and only one, of readbuf or writebuf must be non-NULL. */
  53. extern enum target_xfer_status
  54. section_table_xfer_memory_partial (gdb_byte *,
  55. const gdb_byte *,
  56. ULONGEST, ULONGEST, ULONGEST *,
  57. const target_section_table &,
  58. gdb::function_view<bool
  59. (const struct target_section *)> match_cb
  60. = nullptr);
  61. /* Read from mappable read-only sections of BFD executable files.
  62. Similar to exec_read_partial_read_only, but return
  63. TARGET_XFER_UNAVAILABLE if data is unavailable. */
  64. extern enum target_xfer_status
  65. section_table_read_available_memory (gdb_byte *readbuf, ULONGEST offset,
  66. ULONGEST len, ULONGEST *xfered_len);
  67. /* Set the loaded address of a section. */
  68. extern void exec_set_section_address (const char *, int, CORE_ADDR);
  69. /* Prints info about all sections defined in the TABLE. ABFD is
  70. special cased --- it's filename is omitted; if it is the executable
  71. file, its entry point is printed. */
  72. extern void print_section_info (const target_section_table *table,
  73. bfd *abfd);
  74. /* Helper function that attempts to open the symbol file at EXEC_FILE_HOST.
  75. If successful, it proceeds to add the symbol file as the main symbol file.
  76. ADD_FLAGS is passed on to the function adding the symbol file. */
  77. extern void try_open_exec_file (const char *exec_file_host,
  78. struct inferior *inf,
  79. symfile_add_flags add_flags);
  80. #endif