Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0 */
0002 #ifndef __PERF_TESTS__HISTS_COMMON_H__
0003 #define __PERF_TESTS__HISTS_COMMON_H__
0004 
0005 struct machine;
0006 struct machines;
0007 
0008 #define FAKE_PID_PERF1  100
0009 #define FAKE_PID_PERF2  200
0010 #define FAKE_PID_BASH   300
0011 
0012 #define FAKE_MAP_PERF    0x400000
0013 #define FAKE_MAP_BASH    0x400000
0014 #define FAKE_MAP_LIBC    0x500000
0015 #define FAKE_MAP_KERNEL  0xf00000
0016 #define FAKE_MAP_LENGTH  0x100000
0017 
0018 #define FAKE_SYM_OFFSET1  700
0019 #define FAKE_SYM_OFFSET2  800
0020 #define FAKE_SYM_OFFSET3  900
0021 #define FAKE_SYM_LENGTH   100
0022 
0023 #define FAKE_IP_PERF_MAIN  FAKE_MAP_PERF + FAKE_SYM_OFFSET1
0024 #define FAKE_IP_PERF_RUN_COMMAND  FAKE_MAP_PERF + FAKE_SYM_OFFSET2
0025 #define FAKE_IP_PERF_CMD_RECORD  FAKE_MAP_PERF + FAKE_SYM_OFFSET3
0026 #define FAKE_IP_BASH_MAIN  FAKE_MAP_BASH + FAKE_SYM_OFFSET1
0027 #define FAKE_IP_BASH_XMALLOC  FAKE_MAP_BASH + FAKE_SYM_OFFSET2
0028 #define FAKE_IP_BASH_XFREE  FAKE_MAP_BASH + FAKE_SYM_OFFSET3
0029 #define FAKE_IP_LIBC_MALLOC  FAKE_MAP_LIBC + FAKE_SYM_OFFSET1
0030 #define FAKE_IP_LIBC_FREE  FAKE_MAP_LIBC + FAKE_SYM_OFFSET2
0031 #define FAKE_IP_LIBC_REALLOC  FAKE_MAP_LIBC + FAKE_SYM_OFFSET3
0032 #define FAKE_IP_KERNEL_SCHEDULE  FAKE_MAP_KERNEL + FAKE_SYM_OFFSET1
0033 #define FAKE_IP_KERNEL_PAGE_FAULT  FAKE_MAP_KERNEL + FAKE_SYM_OFFSET2
0034 #define FAKE_IP_KERNEL_SYS_PERF_EVENT_OPEN  FAKE_MAP_KERNEL + FAKE_SYM_OFFSET3
0035 
0036 /*
0037  * The setup_fake_machine() provides a test environment which consists
0038  * of 3 processes that have 3 mappings and in turn, have 3 symbols
0039  * respectively.  See below table:
0040  *
0041  * Command:  Pid  Shared Object               Symbol
0042  * .............  .............  ...................
0043  *    perf:  100           perf  main
0044  *    perf:  100           perf  run_command
0045  *    perf:  100           perf  cmd_record
0046  *    perf:  100           libc  malloc
0047  *    perf:  100           libc  free
0048  *    perf:  100           libc  realloc
0049  *    perf:  100       [kernel]  schedule
0050  *    perf:  100       [kernel]  page_fault
0051  *    perf:  100       [kernel]  sys_perf_event_open
0052  *    perf:  200           perf  main
0053  *    perf:  200           perf  run_command
0054  *    perf:  200           perf  cmd_record
0055  *    perf:  200           libc  malloc
0056  *    perf:  200           libc  free
0057  *    perf:  200           libc  realloc
0058  *    perf:  200       [kernel]  schedule
0059  *    perf:  200       [kernel]  page_fault
0060  *    perf:  200       [kernel]  sys_perf_event_open
0061  *    bash:  300           bash  main
0062  *    bash:  300           bash  xmalloc
0063  *    bash:  300           bash  xfree
0064  *    bash:  300           libc  malloc
0065  *    bash:  300           libc  free
0066  *    bash:  300           libc  realloc
0067  *    bash:  300       [kernel]  schedule
0068  *    bash:  300       [kernel]  page_fault
0069  *    bash:  300       [kernel]  sys_perf_event_open
0070  */
0071 struct machine *setup_fake_machine(struct machines *machines);
0072 
0073 void print_hists_in(struct hists *hists);
0074 void print_hists_out(struct hists *hists);
0075 
0076 #endif /* __PERF_TESTS__HISTS_COMMON_H__ */