pc_sample.h 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. /*
  2. * Mach Operating System
  3. * Copyright (c) 1993 Carnegie Mellon University
  4. * All Rights Reserved.
  5. *
  6. * Permission to use, copy, modify and distribute this software and its
  7. * documentation is hereby granted, provided that both the copyright
  8. * notice and this permission notice appear in all copies of the
  9. * software, derivative works or modified versions, and any portions
  10. * thereof, and that both notices appear in supporting documentation.
  11. *
  12. * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
  13. * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
  14. * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
  15. *
  16. * Carnegie Mellon requests users of this software to return to
  17. *
  18. * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
  19. * School of Computer Science
  20. * Carnegie Mellon University
  21. * Pittsburgh PA 15213-3890
  22. *
  23. * any improvements or extensions that they make and grant Carnegie Mellon
  24. * the rights to redistribute these changes.
  25. */
  26. /*
  27. * HISTORY
  28. * Revision 1.1.1.1 1997/02/25 21:28:25 thomas
  29. * Initial source
  30. *
  31. * Revision 1.1.1.1 1996/10/30 01:38:13 thomas
  32. * Imported from UK22
  33. *
  34. * Revision 1.1 1994/11/02 02:24:15 law
  35. * Initial revision
  36. *
  37. * Revision 2.2 93/11/17 19:06:01 dbg
  38. * Moved kernel internal definitions here from mach/pc_sample.h.
  39. * [93/09/24 dbg]
  40. *
  41. */
  42. /*
  43. * Kernel definitions for PC sampling.
  44. */
  45. #ifndef _KERN_PC_SAMPLE_H_
  46. #define _KERN_PC_SAMPLE_H_
  47. #include <mach/pc_sample.h>
  48. #include <mach/machine/vm_types.h>
  49. #include <kern/kern_types.h>
  50. #include <kern/macros.h>
  51. /*
  52. * Control structure for sampling, included in
  53. * threads and tasks. If sampletypes is 0, no
  54. * sampling is done.
  55. */
  56. struct sample_control {
  57. vm_offset_t buffer;
  58. unsigned int seqno;
  59. sampled_pc_flavor_t sampletypes;
  60. };
  61. typedef struct sample_control sample_control_t;
  62. /*
  63. * Routines to take PC samples.
  64. */
  65. extern void take_pc_sample(
  66. thread_t thread,
  67. sample_control_t *cp,
  68. sampled_pc_flavor_t flavor,
  69. boolean_t usermode,
  70. vm_offset_t pc);
  71. /*
  72. * Macro to do quick flavor check for sampling,
  73. * on both threads and tasks.
  74. */
  75. #define take_pc_sample_macro(thread, flavor, usermode, pc) \
  76. MACRO_BEGIN \
  77. task_t task; \
  78. \
  79. if ((thread)->pc_sample.sampletypes & (flavor)) \
  80. take_pc_sample((thread), &(thread)->pc_sample, (flavor), usermode, pc); \
  81. \
  82. task = (thread)->task; \
  83. if (task->pc_sample.sampletypes & (flavor)) \
  84. take_pc_sample((thread), &task->pc_sample, (flavor), usermode, pc); \
  85. MACRO_END
  86. #endif /* _KERN_PC_SAMPLE_H_ */