gdbstub.h 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. #ifndef GDBSTUB_H
  2. #define GDBSTUB_H
  3. #define DEFAULT_GDBSTUB_PORT "1234"
  4. /* GDB breakpoint/watchpoint types */
  5. #define GDB_BREAKPOINT_SW 0
  6. #define GDB_BREAKPOINT_HW 1
  7. #define GDB_WATCHPOINT_WRITE 2
  8. #define GDB_WATCHPOINT_READ 3
  9. #define GDB_WATCHPOINT_ACCESS 4
  10. typedef struct GDBFeature {
  11. const char *xmlname;
  12. const char *xml;
  13. const char *name;
  14. const char * const *regs;
  15. int num_regs;
  16. } GDBFeature;
  17. typedef struct GDBFeatureBuilder {
  18. GDBFeature *feature;
  19. GPtrArray *xml;
  20. GPtrArray *regs;
  21. int base_reg;
  22. } GDBFeatureBuilder;
  23. /* Get or set a register. Returns the size of the register. */
  24. typedef int (*gdb_get_reg_cb)(CPUState *cpu, GByteArray *buf, int reg);
  25. typedef int (*gdb_set_reg_cb)(CPUState *cpu, uint8_t *buf, int reg);
  26. /**
  27. * gdb_init_cpu(): Initialize the CPU for gdbstub.
  28. * @cpu: The CPU to be initialized.
  29. */
  30. void gdb_init_cpu(CPUState *cpu);
  31. /**
  32. * gdb_register_coprocessor() - register a supplemental set of registers
  33. * @cpu - the CPU associated with registers
  34. * @get_reg - get function (gdb reading)
  35. * @set_reg - set function (gdb modifying)
  36. * @num_regs - number of registers in set
  37. * @xml - xml name of set
  38. * @gpos - non-zero to append to "general" register set at @gpos
  39. */
  40. void gdb_register_coprocessor(CPUState *cpu,
  41. gdb_get_reg_cb get_reg, gdb_set_reg_cb set_reg,
  42. const GDBFeature *feature, int g_pos);
  43. /**
  44. * gdbserver_start: start the gdb server
  45. * @port_or_device: connection spec for gdb
  46. *
  47. * For CONFIG_USER this is either a tcp port or a path to a fifo. For
  48. * system emulation you can use a full chardev spec for your gdbserver
  49. * port.
  50. */
  51. int gdbserver_start(const char *port_or_device);
  52. /**
  53. * gdb_feature_builder_init() - Initialize GDBFeatureBuilder.
  54. * @builder: The builder to be initialized.
  55. * @feature: The feature to be filled.
  56. * @name: The name of the feature.
  57. * @xmlname: The name of the XML.
  58. * @base_reg: The base number of the register ID.
  59. */
  60. void gdb_feature_builder_init(GDBFeatureBuilder *builder, GDBFeature *feature,
  61. const char *name, const char *xmlname,
  62. int base_reg);
  63. /**
  64. * gdb_feature_builder_append_tag() - Append a tag.
  65. * @builder: The builder.
  66. * @format: The format of the tag.
  67. * @...: The values to be formatted.
  68. */
  69. void G_GNUC_PRINTF(2, 3)
  70. gdb_feature_builder_append_tag(const GDBFeatureBuilder *builder,
  71. const char *format, ...);
  72. /**
  73. * gdb_feature_builder_append_reg() - Append a register.
  74. * @builder: The builder.
  75. * @name: The register's name; it must be unique within a CPU.
  76. * @bitsize: The register's size, in bits.
  77. * @regnum: The offset of the register's number in the feature.
  78. * @type: The type of the register.
  79. * @group: The register group to which this register belongs; it can be NULL.
  80. */
  81. void gdb_feature_builder_append_reg(const GDBFeatureBuilder *builder,
  82. const char *name,
  83. int bitsize,
  84. int regnum,
  85. const char *type,
  86. const char *group);
  87. /**
  88. * gdb_feature_builder_end() - End building GDBFeature.
  89. * @builder: The builder.
  90. */
  91. void gdb_feature_builder_end(const GDBFeatureBuilder *builder);
  92. /**
  93. * gdb_find_static_feature() - Find a static feature.
  94. * @xmlname: The name of the XML.
  95. *
  96. * Return: The static feature.
  97. */
  98. const GDBFeature *gdb_find_static_feature(const char *xmlname);
  99. void gdb_set_stop_cpu(CPUState *cpu);
  100. /* in gdbstub-xml.c, generated by scripts/feature_to_c.py */
  101. extern const GDBFeature gdb_static_features[];
  102. #endif