call-path.h 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. /*
  2. * call-path.h: Manipulate a tree data structure containing function call paths
  3. * Copyright (c) 2014, Intel Corporation.
  4. *
  5. * This program is free software; you can redistribute it and/or modify it
  6. * under the terms and conditions of the GNU General Public License,
  7. * version 2, as published by the Free Software Foundation.
  8. *
  9. * This program is distributed in the hope it will be useful, but WITHOUT
  10. * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11. * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
  12. * more details.
  13. *
  14. */
  15. #ifndef __PERF_CALL_PATH_H
  16. #define __PERF_CALL_PATH_H
  17. #include <sys/types.h>
  18. #include <linux/types.h>
  19. #include <linux/rbtree.h>
  20. /**
  21. * struct call_path - node in list of calls leading to a function call.
  22. * @parent: call path to the parent function call
  23. * @sym: symbol of function called
  24. * @ip: only if sym is null, the ip of the function
  25. * @db_id: id used for db-export
  26. * @in_kernel: whether function is a in the kernel
  27. * @rb_node: node in parent's tree of called functions
  28. * @children: tree of call paths of functions called
  29. *
  30. * In combination with the call_return structure, the call_path structure
  31. * defines a context-sensitve call-graph.
  32. */
  33. struct call_path {
  34. struct call_path *parent;
  35. struct symbol *sym;
  36. u64 ip;
  37. u64 db_id;
  38. bool in_kernel;
  39. struct rb_node rb_node;
  40. struct rb_root children;
  41. };
  42. #define CALL_PATH_BLOCK_SHIFT 8
  43. #define CALL_PATH_BLOCK_SIZE (1 << CALL_PATH_BLOCK_SHIFT)
  44. #define CALL_PATH_BLOCK_MASK (CALL_PATH_BLOCK_SIZE - 1)
  45. struct call_path_block {
  46. struct call_path cp[CALL_PATH_BLOCK_SIZE];
  47. struct list_head node;
  48. };
  49. /**
  50. * struct call_path_root - root of all call paths.
  51. * @call_path: root call path
  52. * @blocks: list of blocks to store call paths
  53. * @next: next free space
  54. * @sz: number of spaces
  55. */
  56. struct call_path_root {
  57. struct call_path call_path;
  58. struct list_head blocks;
  59. size_t next;
  60. size_t sz;
  61. };
  62. struct call_path_root *call_path_root__new(void);
  63. void call_path_root__free(struct call_path_root *cpr);
  64. struct call_path *call_path__findnew(struct call_path_root *cpr,
  65. struct call_path *parent,
  66. struct symbol *sym, u64 ip, u64 ks);
  67. #endif