kgdb.h 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. /*
  2. * ARM KGDB support
  3. *
  4. * Author: Deepak Saxena <dsaxena@mvista.com>
  5. *
  6. * Copyright (C) 2002 MontaVista Software Inc.
  7. *
  8. */
  9. #ifndef __ARM_KGDB_H__
  10. #define __ARM_KGDB_H__
  11. #include <linux/ptrace.h>
  12. /*
  13. * GDB assumes that we're a user process being debugged, so
  14. * it will send us an SWI command to write into memory as the
  15. * debug trap. When an SWI occurs, the next instruction addr is
  16. * placed into R14_svc before jumping to the vector trap.
  17. * This doesn't work for kernel debugging as we are already in SVC
  18. * we would loose the kernel's LR, which is a bad thing. This
  19. * is bad thing.
  20. *
  21. * By doing this as an undefined instruction trap, we force a mode
  22. * switch from SVC to UND mode, allowing us to save full kernel state.
  23. *
  24. * We also define a KGDB_COMPILED_BREAK which can be used to compile
  25. * in breakpoints. This is important for things like sysrq-G and for
  26. * the initial breakpoint from trap_init().
  27. *
  28. * Note to ARM HW designers: Add real trap support like SH && PPC to
  29. * make our lives much much simpler. :)
  30. */
  31. #define BREAK_INSTR_SIZE 4
  32. #define GDB_BREAKINST 0xef9f0001
  33. #define KGDB_BREAKINST 0xe7ffdefe
  34. #define KGDB_COMPILED_BREAK 0xe7ffdeff
  35. #define CACHE_FLUSH_IS_SAFE 1
  36. #ifndef __ASSEMBLY__
  37. static inline void arch_kgdb_breakpoint(void)
  38. {
  39. asm(".word 0xe7ffdeff");
  40. }
  41. extern void kgdb_handle_bus_error(void);
  42. extern int kgdb_fault_expected;
  43. #endif /* !__ASSEMBLY__ */
  44. /*
  45. * From Kevin Hilman:
  46. *
  47. * gdb is expecting the following registers layout.
  48. *
  49. * r0-r15: 1 long word each
  50. * f0-f7: unused, 3 long words each !!
  51. * fps: unused, 1 long word
  52. * cpsr: 1 long word
  53. *
  54. * Even though f0-f7 and fps are not used, they need to be
  55. * present in the registers sent for correct processing in
  56. * the host-side gdb.
  57. *
  58. * In particular, it is crucial that CPSR is in the right place,
  59. * otherwise gdb will not be able to correctly interpret stepping over
  60. * conditional branches.
  61. */
  62. #define _GP_REGS 16
  63. #define _FP_REGS 8
  64. #define _EXTRA_REGS 2
  65. #define GDB_MAX_REGS (_GP_REGS + (_FP_REGS * 3) + _EXTRA_REGS)
  66. #define DBG_MAX_REG_NUM (_GP_REGS + _FP_REGS + _EXTRA_REGS)
  67. #define KGDB_MAX_NO_CPUS 1
  68. #define BUFMAX 400
  69. #define NUMREGBYTES (DBG_MAX_REG_NUM << 2)
  70. #define NUMCRITREGBYTES (32 << 2)
  71. #define _R0 0
  72. #define _R1 1
  73. #define _R2 2
  74. #define _R3 3
  75. #define _R4 4
  76. #define _R5 5
  77. #define _R6 6
  78. #define _R7 7
  79. #define _R8 8
  80. #define _R9 9
  81. #define _R10 10
  82. #define _FP 11
  83. #define _IP 12
  84. #define _SPT 13
  85. #define _LR 14
  86. #define _PC 15
  87. #define _CPSR (GDB_MAX_REGS - 1)
  88. /*
  89. * So that we can denote the end of a frame for tracing,
  90. * in the simple case:
  91. */
  92. #define CFI_END_FRAME(func) __CFI_END_FRAME(_PC, _SPT, func)
  93. #endif /* __ASM_KGDB_H__ */