kgdb.h 2.7 KB

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