inf-child.h 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. /* Base/prototype target for default child (native) targets.
  2. Copyright (C) 2004-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 INF_CHILD_H
  15. #define INF_CHILD_H
  16. #include "target.h"
  17. #include "process-stratum-target.h"
  18. /* A prototype child target. The client can override it with local
  19. methods. */
  20. class inf_child_target
  21. : public memory_breakpoint_target<process_stratum_target>
  22. {
  23. public:
  24. inf_child_target () = default;
  25. ~inf_child_target () override = 0;
  26. const target_info &info () const override;
  27. void close () override;
  28. void disconnect (const char *, int) override;
  29. void fetch_registers (struct regcache *, int) override = 0;
  30. void store_registers (struct regcache *, int) override = 0;
  31. void prepare_to_store (struct regcache *) override;
  32. bool supports_terminal_ours () override;
  33. void terminal_init () override;
  34. void terminal_inferior () override;
  35. void terminal_save_inferior () override;
  36. void terminal_ours_for_output () override;
  37. void terminal_ours () override;
  38. void terminal_info (const char *, int) override;
  39. void interrupt () override;
  40. void pass_ctrlc () override;
  41. void follow_exec (inferior *follow_inf, ptid_t ptid,
  42. const char *execd_pathname) override;
  43. void mourn_inferior () override;
  44. bool can_run () override;
  45. bool can_create_inferior () override;
  46. void create_inferior (const char *, const std::string &,
  47. char **, int) override = 0;
  48. bool can_attach () override;
  49. void attach (const char *, int) override = 0;
  50. void post_attach (int) override;
  51. char *pid_to_exec_file (int pid) override;
  52. int fileio_open (struct inferior *inf, const char *filename,
  53. int flags, int mode, int warn_if_slow,
  54. int *target_errno) override;
  55. int fileio_pwrite (int fd, const gdb_byte *write_buf, int len,
  56. ULONGEST offset, int *target_errno) override;
  57. int fileio_pread (int fd, gdb_byte *read_buf, int len,
  58. ULONGEST offset, int *target_errno) override;
  59. int fileio_fstat (int fd, struct stat *sb, int *target_errno) override;
  60. int fileio_close (int fd, int *target_errno) override;
  61. int fileio_unlink (struct inferior *inf,
  62. const char *filename,
  63. int *target_errno) override;
  64. gdb::optional<std::string> fileio_readlink (struct inferior *inf,
  65. const char *filename,
  66. int *target_errno) override;
  67. bool use_agent (bool use) override;
  68. bool can_use_agent () override;
  69. protected:
  70. /* Unpush the target if it wasn't explicitly open with "target native"
  71. and there are no live inferiors left. Note: if calling this as a
  72. result of a mourn or detach, the current inferior shall already
  73. have its PID cleared, so it isn't counted as live. That's usually
  74. done by calling either generic_mourn_inferior or
  75. detach_inferior. */
  76. void maybe_unpush_target ();
  77. };
  78. /* Convert the host wait(2) status to a target_waitstatus. */
  79. extern target_waitstatus host_status_to_waitstatus (int hoststatus);
  80. /* Register TARGET as native target and set it up to respond to the
  81. "target native" command. */
  82. extern void add_inf_child_target (inf_child_target *target);
  83. /* target_open_ftype callback for inf-child targets. Used by targets
  84. that want to register an alternative target_info object. Most
  85. targets use add_inf_child_target instead. */
  86. extern void inf_child_open_target (const char *arg, int from_tty);
  87. #endif