gdb/nat/mips-linux-watch.h - gdb

Data types defined

Macros defined

Source code

  1. /* Copyright (C) 2009-2015 Free Software Foundation, Inc.

  2.    This file is part of GDB.

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

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

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

  13. #ifndef MIPS_LINUX_WATCH_H
  14. #define MIPS_LINUX_WATCH_H 1

  15. #include <asm/ptrace.h>
  16. #include <stdint.h>

  17. #include "break-common.h"

  18. #define MAX_DEBUG_REGISTER 8

  19. /* If macro PTRACE_GET_WATCH_REGS is not defined, kernel header doesn't
  20.    have hardware watchpoint-related structures.  Define them below.  */

  21. #ifndef PTRACE_GET_WATCH_REGS
  22. #  define PTRACE_GET_WATCH_REGS        0xd0
  23. #  define PTRACE_SET_WATCH_REGS        0xd1

  24. enum pt_watch_style {
  25.   pt_watch_style_mips32,
  26.   pt_watch_style_mips64
  27. };

  28. /* A value of zero in a watchlo indicates that it is available.  */

  29. struct mips32_watch_regs
  30. {
  31.   uint32_t watchlo[MAX_DEBUG_REGISTER];
  32.   /* Lower 16 bits of watchhi.  */
  33.   uint16_t watchhi[MAX_DEBUG_REGISTER];
  34.   /* Valid mask and I R W bits.
  35.    * bit 0 -- 1 if W bit is usable.
  36.    * bit 1 -- 1 if R bit is usable.
  37.    * bit 2 -- 1 if I bit is usable.
  38.    * bits 3 - 11 -- Valid watchhi mask bits.
  39.    */
  40.   uint16_t watch_masks[MAX_DEBUG_REGISTER];
  41.   /* The number of valid watch register pairs.  */
  42.   uint32_t num_valid;
  43.   /* There is confusion across gcc versions about structure alignment,
  44.      so we force 8 byte alignment for these structures so they match
  45.      the kernel even if it was build with a different gcc version.  */
  46. } __attribute__ ((aligned (8)));

  47. struct mips64_watch_regs
  48. {
  49.   uint64_t watchlo[MAX_DEBUG_REGISTER];
  50.   uint16_t watchhi[MAX_DEBUG_REGISTER];
  51.   uint16_t watch_masks[MAX_DEBUG_REGISTER];
  52.   uint32_t num_valid;
  53. } __attribute__ ((aligned (8)));

  54. struct pt_watch_regs
  55. {
  56.   enum pt_watch_style style;
  57.   union
  58.   {
  59.     struct mips32_watch_regs mips32;
  60.     struct mips64_watch_regs mips64;
  61.   };
  62. };

  63. #endif /* !PTRACE_GET_WATCH_REGS */

  64. #define W_BIT 0
  65. #define R_BIT 1
  66. #define I_BIT 2

  67. #define W_MASK (1 << W_BIT)
  68. #define R_MASK (1 << R_BIT)
  69. #define I_MASK (1 << I_BIT)

  70. #define IRW_MASK (I_MASK | R_MASK | W_MASK)

  71. /* We keep list of all watchpoints we should install and calculate the
  72.    watch register values each time the list changes.  This allows for
  73.    easy sharing of watch registers for more than one watchpoint.  */

  74. struct mips_watchpoint
  75. {
  76.   CORE_ADDR addr;
  77.   int len;
  78.   int type;
  79.   struct mips_watchpoint *next;
  80. };

  81. uint32_t mips_linux_watch_get_num_valid (struct pt_watch_regs *regs);
  82. uint32_t mips_linux_watch_get_irw_mask (struct pt_watch_regs *regs, int n);
  83. CORE_ADDR mips_linux_watch_get_watchlo (struct pt_watch_regs *regs, int n);
  84. void mips_linux_watch_set_watchlo (struct pt_watch_regs *regs, int n,
  85.                                    CORE_ADDR value);
  86. uint32_t mips_linux_watch_get_watchhi (struct pt_watch_regs *regs, int n);
  87. void mips_linux_watch_set_watchhi (struct pt_watch_regs *regs, int n,
  88.                                    uint16_t value);
  89. int mips_linux_watch_try_one_watch (struct pt_watch_regs *regs,
  90.                                     CORE_ADDR addr, int len, uint32_t irw);
  91. void mips_linux_watch_populate_regs (struct mips_watchpoint *current_watches,
  92.                                      struct pt_watch_regs *regs);
  93. uint32_t mips_linux_watch_type_to_irw (int type);

  94. int mips_linux_read_watch_registers (long lwpid,
  95.                                      struct pt_watch_regs *watch_readback,
  96.                                      int *watch_readback_valid, int force);
  97. #endif