ptrace.c 1012 B

123456789101112131415161718192021222324252627282930313233
  1. #include <linux/ptrace.h>
  2. /**
  3. * regs_query_register_offset() - query register offset from its name
  4. * @name: the name of a register
  5. *
  6. * regs_query_register_offset() returns the offset of a register in struct
  7. * pt_regs from its name. If the name is invalid, this returns -EINVAL;
  8. */
  9. int regs_query_register_offset(const char *name)
  10. {
  11. const struct pt_regs_offset *roff;
  12. for (roff = regoffset_table; roff->name != NULL; roff++)
  13. if (!strcmp(roff->name, name))
  14. return roff->offset;
  15. return -EINVAL;
  16. }
  17. /**
  18. * regs_query_register_name() - query register name from its offset
  19. * @offset: the offset of a register in struct pt_regs.
  20. *
  21. * regs_query_register_name() returns the name of a register from its
  22. * offset in struct pt_regs. If the @offset is invalid, this returns NULL;
  23. */
  24. const char *regs_query_register_name(unsigned int offset)
  25. {
  26. const struct pt_regs_offset *roff;
  27. for (roff = regoffset_table; roff->name != NULL; roff++)
  28. if (roff->offset == offset)
  29. return roff->name;
  30. return NULL;
  31. }