gdb/gdbserver/mem-break.h - gdb

Data types defined

Macros defined

Source code

  1. /* Memory breakpoint interfaces for the remote server for GDB.
  2.    Copyright (C) 2002-2015 Free Software Foundation, Inc.

  3.    Contributed by MontaVista Software.

  4.    This file is part of GDB.

  5.    This program is free software; you can redistribute it and/or modify
  6.    it under the terms of the GNU General Public License as published by
  7.    the Free Software Foundation; either version 3 of the License, or
  8.    (at your option) any later version.

  9.    This program is distributed in the hope that it will be useful,
  10.    but WITHOUT ANY WARRANTY; without even the implied warranty of
  11.    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  12.    GNU General Public License for more details.

  13.    You should have received a copy of the GNU General Public License
  14.    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */

  15. #ifndef MEM_BREAK_H
  16. #define MEM_BREAK_H

  17. #include "break-common.h"

  18. /* Breakpoints are opaque.  */
  19. struct breakpoint;
  20. struct fast_tracepoint_jump;
  21. struct raw_breakpoint;
  22. struct process_info;

  23. #define Z_PACKET_SW_BP '0'
  24. #define Z_PACKET_HW_BP '1'
  25. #define Z_PACKET_WRITE_WP '2'
  26. #define Z_PACKET_READ_WP '3'
  27. #define Z_PACKET_ACCESS_WP '4'

  28. /* The low level breakpoint types.  */

  29. enum raw_bkpt_type
  30.   {
  31.     /* Software/memory breakpoint.  */
  32.     raw_bkpt_type_sw,

  33.     /* Hardware-assisted breakpoint.  */
  34.     raw_bkpt_type_hw,

  35.     /* Hardware-assisted write watchpoint.  */
  36.     raw_bkpt_type_write_wp,

  37.     /* Hardware-assisted read watchpoint.  */
  38.     raw_bkpt_type_read_wp,

  39.     /* Hardware-assisted access watchpoint.  */
  40.     raw_bkpt_type_access_wp
  41.   };

  42. /* Map the protocol breakpoint/watchpoint type Z_TYPE to the internal
  43.    raw breakpoint type.  */

  44. enum raw_bkpt_type Z_packet_to_raw_bkpt_type (char z_type);

  45. /* Map a raw breakpoint type to an enum target_hw_bp_type.  */

  46. enum target_hw_bp_type raw_bkpt_type_to_target_hw_bp_type
  47.   (enum raw_bkpt_type raw_type);

  48. /* Create a new GDB breakpoint of type Z_TYPE at ADDR with size SIZE.
  49.    Returns a pointer to the newly created breakpoint on success.  On
  50.    failure returns NULL and sets *ERR to either -1 for error, or 1 if
  51.    Z_TYPE breakpoints are not supported on this target.  */

  52. struct breakpoint *set_gdb_breakpoint (char z_type, CORE_ADDR addr, int size,
  53.                                        int *err);

  54. /* Delete a GDB breakpoint of type Z_TYPE and size SIZE previously
  55.    inserted at ADDR with set_gdb_breakpoint_at.  Returns 0 on success,
  56.    -1 on error, and 1 if Z_TYPE breakpoints are not supported on this
  57.    target.  */

  58. int delete_gdb_breakpoint (char z_type, CORE_ADDR addr, int size);

  59. /* Returns TRUE if there's a software or hardware (code) breakpoint at
  60.    ADDR in our tables, inserted, or not.  */

  61. int breakpoint_here (CORE_ADDR addr);

  62. /* Returns TRUE if there's any inserted software or hardware (code)
  63.    breakpoint set at ADDR.  */

  64. int breakpoint_inserted_here (CORE_ADDR addr);

  65. /* Returns TRUE if there's any inserted software breakpoint at
  66.    ADDR.  */

  67. int software_breakpoint_inserted_here (CORE_ADDR addr);

  68. /* Returns TRUE if there's any inserted hardware (code) breakpoint at
  69.    ADDR.  */

  70. int hardware_breakpoint_inserted_here (CORE_ADDR addr);

  71. /* Clear all breakpoint conditions and commands associated with a
  72.    breakpoint.  */

  73. void clear_breakpoint_conditions_and_commands (struct breakpoint *bp);

  74. /* Set target-side condition CONDITION to the breakpoint at ADDR.
  75.    Returns false on failure.  On success, advances CONDITION pointer
  76.    past the condition and returns true.  */

  77. int add_breakpoint_condition (struct breakpoint *bp, char **condition);

  78. /* Set target-side commands COMMANDS to the breakpoint at ADDR.
  79.    Returns false on failure.  On success, advances COMMANDS past the
  80.    commands and returns true.  If PERSIST, the commands should run
  81.    even while GDB is disconnected.  */

  82. int add_breakpoint_commands (struct breakpoint *bp, char **commands,
  83.                              int persist);

  84. int any_persistent_commands (void);

  85. /* Evaluation condition (if any) at breakpoint BP.  Return 1 if
  86.    true and 0 otherwise.  */

  87. int gdb_condition_true_at_breakpoint (CORE_ADDR where);

  88. int gdb_no_commands_at_breakpoint (CORE_ADDR where);

  89. void run_breakpoint_commands (CORE_ADDR where);

  90. /* Returns TRUE if there's a GDB breakpoint (Z0 or Z1) set at
  91.    WHERE.  */

  92. int gdb_breakpoint_here (CORE_ADDR where);

  93. /* Create a new breakpoint at WHERE, and call HANDLER when
  94.    it is hit.  HANDLER should return 1 if the breakpoint
  95.    should be deleted, 0 otherwise.  */

  96. struct breakpoint *set_breakpoint_at (CORE_ADDR where,
  97.                                       int (*handler) (CORE_ADDR));

  98. /* Delete a breakpoint.  */

  99. int delete_breakpoint (struct breakpoint *bkpt);

  100. /* Set a reinsert breakpoint at STOP_AT.  */

  101. void set_reinsert_breakpoint (CORE_ADDR stop_at);

  102. /* Delete all reinsert breakpoints.  */

  103. void delete_reinsert_breakpoints (void);

  104. /* Reinsert breakpoints at WHERE (and change their status to
  105.    inserted).  */

  106. void reinsert_breakpoints_at (CORE_ADDR where);

  107. /* Uninsert breakpoints at WHERE (and change their status to
  108.    uninserted).  This still leaves the breakpoints in the table.  */

  109. void uninsert_breakpoints_at (CORE_ADDR where);

  110. /* Reinsert all breakpoints of the current process (and change their
  111.    status to inserted).  */

  112. void reinsert_all_breakpoints (void);

  113. /* Uninsert all breakpoints of the current process (and change their
  114.    status to uninserted).  This still leaves the breakpoints in the
  115.    table.  */

  116. void uninsert_all_breakpoints (void);

  117. /* See if any breakpoint claims ownership of STOP_PC.  Call the handler for
  118.    the breakpoint, if found.  */

  119. void check_breakpoints (CORE_ADDR stop_pc);

  120. /* See if any breakpoints shadow the target memory area from MEM_ADDR
  121.    to MEM_ADDR + MEM_LEN.  Update the data already read from the target
  122.    (in BUF) if necessary.  */

  123. void check_mem_read (CORE_ADDR mem_addr, unsigned char *buf, int mem_len);

  124. /* See if any breakpoints shadow the target memory area from MEM_ADDR
  125.    to MEM_ADDR + MEM_LEN.  Update the data to be written to the target
  126.    (in BUF, a copy of MYADDR on entry) if necessary, as well as the
  127.    original data for any breakpoints.  */

  128. void check_mem_write (CORE_ADDR mem_addr,
  129.                       unsigned char *buf, const unsigned char *myaddr, int mem_len);

  130. /* Set the byte pattern to insert for memory breakpoints.  This function
  131.    must be called before any breakpoints are set.  */

  132. void set_breakpoint_data (const unsigned char *bp_data, int bp_len);

  133. /* Delete all breakpoints.  */

  134. void delete_all_breakpoints (void);

  135. /* Clear the "inserted" flag in all breakpoints of PROC.  */

  136. void mark_breakpoints_out (struct process_info *proc);

  137. /* Delete all breakpoints, but do not try to un-insert them from the
  138.    inferior.  */

  139. void free_all_breakpoints (struct process_info *proc);

  140. /* Check if breakpoints still seem to be inserted in the inferior.  */

  141. void validate_breakpoints (void);

  142. /* Insert a fast tracepoint jump at WHERE, using instruction INSN, of
  143.    LENGTH bytes.  */

  144. struct fast_tracepoint_jump *set_fast_tracepoint_jump (CORE_ADDR where,
  145.                                                        unsigned char *insn,
  146.                                                        ULONGEST length);

  147. /* Increment reference counter of JP.  */
  148. void inc_ref_fast_tracepoint_jump (struct fast_tracepoint_jump *jp);

  149. /* Delete fast tracepoint jump TODEL from our tables, and uninsert if
  150.    from memory.  */

  151. int delete_fast_tracepoint_jump (struct fast_tracepoint_jump *todel);

  152. /* Returns true if there's fast tracepoint jump set at WHERE.  */

  153. int fast_tracepoint_jump_here (CORE_ADDR);

  154. /* Uninsert fast tracepoint jumps at WHERE (and change their status to
  155.    uninserted).  This still leaves the tracepoints in the table.  */

  156. void uninsert_fast_tracepoint_jumps_at (CORE_ADDR pc);

  157. /* Reinsert fast tracepoint jumps at WHERE (and change their status to
  158.    inserted).  */

  159. void reinsert_fast_tracepoint_jumps_at (CORE_ADDR where);

  160. /* Insert a memory breakpoint.  */

  161. int insert_memory_breakpoint (struct raw_breakpoint *bp);

  162. /* Remove a previously inserted memory breakpoint.  */

  163. int remove_memory_breakpoint (struct raw_breakpoint *bp);

  164. #endif /* MEM_BREAK_H */