perf_regs.c 570 B

12345678910111213141516171819202122232425262728293031323334
  1. #include <errno.h>
  2. #include "perf_regs.h"
  3. #include "event.h"
  4. const struct sample_reg __weak sample_reg_masks[] = {
  5. SMPL_REG_END
  6. };
  7. #ifdef HAVE_PERF_REGS_SUPPORT
  8. int perf_reg_value(u64 *valp, struct regs_dump *regs, int id)
  9. {
  10. int i, idx = 0;
  11. u64 mask = regs->mask;
  12. if (regs->cache_mask & (1ULL << id))
  13. goto out;
  14. if (!(mask & (1ULL << id)))
  15. return -EINVAL;
  16. for (i = 0; i < id; i++) {
  17. if (mask & (1ULL << i))
  18. idx++;
  19. }
  20. regs->cache_mask |= (1ULL << id);
  21. regs->cache_regs[id] = regs->regs[idx];
  22. out:
  23. *valp = regs->cache_regs[id];
  24. return 0;
  25. }
  26. #endif