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.5KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  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_nocode_sigfpe ( void );
  45. extern void gdbmach_nocode_sigtrap ( void );
  46. extern void gdbmach_nocode_sigstkflt ( void );
  47. extern void gdbmach_nocode_sigill ( void );
  48. extern void gdbmach_withcode_sigbus ( void );
  49. extern void gdbmach_withcode_sigsegv ( void );
  50. static inline void gdbmach_set_pc ( gdbreg_t *regs, gdbreg_t pc ) {
  51. regs [ GDBMACH_EIP ] = pc;
  52. }
  53. static inline void gdbmach_set_single_step ( gdbreg_t *regs, int step ) {
  54. regs [ GDBMACH_EFLAGS ] &= ~( 1 << 8 ); /* Trace Flag (TF) */
  55. regs [ GDBMACH_EFLAGS ] |= ( step << 8 );
  56. }
  57. static inline void gdbmach_breakpoint ( void ) {
  58. __asm__ __volatile__ ( "int $3\n" );
  59. }
  60. extern int gdbmach_set_breakpoint ( int type, unsigned long addr, size_t len, int enable );
  61. extern void gdbmach_init ( void );
  62. #endif /* GDBMACH_H */