call-path.h 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. /* SPDX-License-Identifier: GPL-2.0-only */
  2. /*
  3. * call-path.h: Manipulate a tree data structure containing function call paths
  4. * Copyright (c) 2014, Intel Corporation.
  5. */
  6. #ifndef __PERF_CALL_PATH_H
  7. #define __PERF_CALL_PATH_H
  8. #include <sys/types.h>
  9. #include <linux/types.h>
  10. #include <linux/rbtree.h>
  11. /**
  12. * struct call_path - node in list of calls leading to a function call.
  13. * @parent: call path to the parent function call
  14. * @sym: symbol of function called
  15. * @ip: only if sym is null, the ip of the function
  16. * @db_id: id used for db-export
  17. * @in_kernel: whether function is a in the kernel
  18. * @rb_node: node in parent's tree of called functions
  19. * @children: tree of call paths of functions called
  20. *
  21. * In combination with the call_return structure, the call_path structure
  22. * defines a context-sensitve call-graph.
  23. */
  24. struct call_path {
  25. struct call_path *parent;
  26. struct symbol *sym;
  27. u64 ip;
  28. u64 db_id;
  29. bool in_kernel;
  30. struct rb_node rb_node;
  31. struct rb_root children;
  32. };
  33. #define CALL_PATH_BLOCK_SHIFT 8
  34. #define CALL_PATH_BLOCK_SIZE (1 << CALL_PATH_BLOCK_SHIFT)
  35. #define CALL_PATH_BLOCK_MASK (CALL_PATH_BLOCK_SIZE - 1)
  36. struct call_path_block {
  37. struct call_path cp[CALL_PATH_BLOCK_SIZE];
  38. struct list_head node;
  39. };
  40. /**
  41. * struct call_path_root - root of all call paths.
  42. * @call_path: root call path
  43. * @blocks: list of blocks to store call paths
  44. * @next: next free space
  45. * @sz: number of spaces
  46. */
  47. struct call_path_root {
  48. struct call_path call_path;
  49. struct list_head blocks;
  50. size_t next;
  51. size_t sz;
  52. };
  53. struct call_path_root *call_path_root__new(void);
  54. void call_path_root__free(struct call_path_root *cpr);
  55. struct call_path *call_path__findnew(struct call_path_root *cpr,
  56. struct call_path *parent,
  57. struct symbol *sym, u64 ip, u64 ks);
  58. #endif