You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

gdbmach.h 1.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. #ifndef GDBMACH_H
  2. #define GDBMACH_H
  3. /** @file
  4. *
  5. * GDB architecture specifics
  6. *
  7. * This file declares functions for manipulating the machine state and
  8. * debugging context.
  9. *
  10. */
  11. #include <stdint.h>
  12. typedef unsigned long gdbreg_t;
  13. /* The register snapshot, this must be in sync with interrupt handler and the
  14. * GDB protocol. */
  15. enum {
  16. GDBMACH_EAX,
  17. GDBMACH_ECX,
  18. GDBMACH_EDX,
  19. GDBMACH_EBX,
  20. GDBMACH_ESP,
  21. GDBMACH_EBP,
  22. GDBMACH_ESI,
  23. GDBMACH_EDI,
  24. GDBMACH_EIP,
  25. GDBMACH_EFLAGS,
  26. GDBMACH_CS,
  27. GDBMACH_SS,
  28. GDBMACH_DS,
  29. GDBMACH_ES,
  30. GDBMACH_FS,
  31. GDBMACH_GS,
  32. GDBMACH_NREGS,
  33. GDBMACH_SIZEOF_REGS = GDBMACH_NREGS * sizeof ( gdbreg_t )
  34. };
  35. /* Breakpoint types */
  36. enum {
  37. GDBMACH_BPMEM,
  38. GDBMACH_BPHW,
  39. GDBMACH_WATCH,
  40. GDBMACH_RWATCH,
  41. GDBMACH_AWATCH,
  42. };
  43. /* Interrupt vectors */
  44. extern void gdbmach_sigfpe ( void );
  45. extern void gdbmach_sigtrap ( void );
  46. extern void gdbmach_sigstkflt ( void );
  47. extern void gdbmach_sigill ( void );
  48. static inline void gdbmach_set_pc ( gdbreg_t *regs, gdbreg_t pc ) {
  49. regs [ GDBMACH_EIP ] = pc;
  50. }
  51. static inline void gdbmach_set_single_step ( gdbreg_t *regs, int step ) {
  52. regs [ GDBMACH_EFLAGS ] &= ~( 1 << 8 ); /* Trace Flag (TF) */
  53. regs [ GDBMACH_EFLAGS ] |= ( step << 8 );
  54. }
  55. static inline void gdbmach_breakpoint ( void ) {
  56. __asm__ __volatile__ ( "int $3\n" );
  57. }
  58. extern int gdbmach_set_breakpoint ( int type, unsigned long addr, size_t len, int enable );
  59. extern void gdbmach_init ( void );
  60. #endif /* GDBMACH_H */