perf_regs.c 558 B

123456789101112131415161718192021222324252627282930313233
  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 & (1 << id))
  13. goto out;
  14. if (!(mask & (1 << id)))
  15. return -EINVAL;
  16. for (i = 0; i < id; i++) {
  17. if (mask & (1 << i))
  18. idx++;
  19. }
  20. regs->cache_mask |= (1 << id);
  21. regs->cache_regs[id] = regs->regs[idx];
  22. out:
  23. *valp = regs->cache_regs[id];
  24. return 0;
  25. }
  26. #endif