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.

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  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. // STUB: don't expect this to work!
  17. GDBMACH_EIP,
  18. GDBMACH_EFLAGS,
  19. GDBMACH_NREGS,
  20. GDBMACH_SIZEOF_REGS = GDBMACH_NREGS * sizeof ( gdbreg_t )
  21. };
  22. /* Breakpoint types */
  23. enum {
  24. GDBMACH_BPMEM,
  25. GDBMACH_BPHW,
  26. GDBMACH_WATCH,
  27. GDBMACH_RWATCH,
  28. GDBMACH_AWATCH,
  29. };
  30. static inline void gdbmach_set_pc ( gdbreg_t *regs, gdbreg_t pc ) {
  31. regs [ GDBMACH_EIP ] = pc;
  32. }
  33. static inline void gdbmach_set_single_step ( gdbreg_t *regs, int step ) {
  34. regs [ GDBMACH_EFLAGS ] &= ~( 1 << 8 ); /* Trace Flag (TF) */
  35. regs [ GDBMACH_EFLAGS ] |= ( step << 8 );
  36. }
  37. static inline void gdbmach_breakpoint ( void ) {
  38. __asm__ __volatile__ ( "int $3\n" );
  39. }
  40. extern int gdbmach_set_breakpoint ( int type, unsigned long addr, size_t len, int enable );
  41. #endif /* GDBMACH_H */