hists_common.h 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. #ifndef __PERF_TESTS__HISTS_COMMON_H__
  2. #define __PERF_TESTS__HISTS_COMMON_H__
  3. struct machine;
  4. struct machines;
  5. #define FAKE_PID_PERF1 100
  6. #define FAKE_PID_PERF2 200
  7. #define FAKE_PID_BASH 300
  8. #define FAKE_MAP_PERF 0x400000
  9. #define FAKE_MAP_BASH 0x400000
  10. #define FAKE_MAP_LIBC 0x500000
  11. #define FAKE_MAP_KERNEL 0xf00000
  12. #define FAKE_MAP_LENGTH 0x100000
  13. #define FAKE_SYM_OFFSET1 700
  14. #define FAKE_SYM_OFFSET2 800
  15. #define FAKE_SYM_OFFSET3 900
  16. #define FAKE_SYM_LENGTH 100
  17. #define FAKE_IP_PERF_MAIN FAKE_MAP_PERF + FAKE_SYM_OFFSET1
  18. #define FAKE_IP_PERF_RUN_COMMAND FAKE_MAP_PERF + FAKE_SYM_OFFSET2
  19. #define FAKE_IP_PERF_CMD_RECORD FAKE_MAP_PERF + FAKE_SYM_OFFSET3
  20. #define FAKE_IP_BASH_MAIN FAKE_MAP_BASH + FAKE_SYM_OFFSET1
  21. #define FAKE_IP_BASH_XMALLOC FAKE_MAP_BASH + FAKE_SYM_OFFSET2
  22. #define FAKE_IP_BASH_XFREE FAKE_MAP_BASH + FAKE_SYM_OFFSET3
  23. #define FAKE_IP_LIBC_MALLOC FAKE_MAP_LIBC + FAKE_SYM_OFFSET1
  24. #define FAKE_IP_LIBC_FREE FAKE_MAP_LIBC + FAKE_SYM_OFFSET2
  25. #define FAKE_IP_LIBC_REALLOC FAKE_MAP_LIBC + FAKE_SYM_OFFSET3
  26. #define FAKE_IP_KERNEL_SCHEDULE FAKE_MAP_KERNEL + FAKE_SYM_OFFSET1
  27. #define FAKE_IP_KERNEL_PAGE_FAULT FAKE_MAP_KERNEL + FAKE_SYM_OFFSET2
  28. #define FAKE_IP_KERNEL_SYS_PERF_EVENT_OPEN FAKE_MAP_KERNEL + FAKE_SYM_OFFSET3
  29. /*
  30. * The setup_fake_machine() provides a test environment which consists
  31. * of 3 processes that have 3 mappings and in turn, have 3 symbols
  32. * respectively. See below table:
  33. *
  34. * Command: Pid Shared Object Symbol
  35. * ............. ............. ...................
  36. * perf: 100 perf main
  37. * perf: 100 perf run_command
  38. * perf: 100 perf cmd_record
  39. * perf: 100 libc malloc
  40. * perf: 100 libc free
  41. * perf: 100 libc realloc
  42. * perf: 100 [kernel] schedule
  43. * perf: 100 [kernel] page_fault
  44. * perf: 100 [kernel] sys_perf_event_open
  45. * perf: 200 perf main
  46. * perf: 200 perf run_command
  47. * perf: 200 perf cmd_record
  48. * perf: 200 libc malloc
  49. * perf: 200 libc free
  50. * perf: 200 libc realloc
  51. * perf: 200 [kernel] schedule
  52. * perf: 200 [kernel] page_fault
  53. * perf: 200 [kernel] sys_perf_event_open
  54. * bash: 300 bash main
  55. * bash: 300 bash xmalloc
  56. * bash: 300 bash xfree
  57. * bash: 300 libc malloc
  58. * bash: 300 libc free
  59. * bash: 300 libc realloc
  60. * bash: 300 [kernel] schedule
  61. * bash: 300 [kernel] page_fault
  62. * bash: 300 [kernel] sys_perf_event_open
  63. */
  64. struct machine *setup_fake_machine(struct machines *machines);
  65. void print_hists_in(struct hists *hists);
  66. void print_hists_out(struct hists *hists);
  67. #endif /* __PERF_TESTS__HISTS_COMMON_H__ */