Ohm-Management - Projektarbeit B-ME
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

usdt_internal.h 3.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. /*
  2. * Copyright (c) 2012, Chris Andrews. All rights reserved.
  3. */
  4. #ifdef __linux__
  5. #include <endian.h>
  6. #if __BYTE_ORDER == __LITTLE_ENDIAN
  7. #ifndef _LITTLE_ENDIAN
  8. #define _LITTLE_ENDIAN
  9. #endif
  10. #endif
  11. #endif
  12. #include <sys/dtrace.h>
  13. #include <sys/types.h>
  14. #include <sys/mman.h>
  15. #include <stdlib.h>
  16. #include <errno.h>
  17. #include <string.h>
  18. #include <fcntl.h>
  19. #include <unistd.h>
  20. #include <stdint.h>
  21. #include <assert.h>
  22. #define FUNC_SIZE 32
  23. #include "usdt.h"
  24. extern void usdt_tracepoint_isenabled(void);
  25. extern void usdt_tracepoint_probe(void);
  26. extern void usdt_tracepoint_end(void);
  27. extern void usdt_probe_args(void *, int, void**);
  28. uint32_t usdt_probe_offset(usdt_probe_t *probe, char *dof, uint8_t argc);
  29. uint32_t usdt_is_enabled_offset(usdt_probe_t *probe, char *dof);
  30. int usdt_create_tracepoints(usdt_probe_t *probe);
  31. void usdt_free_tracepoints(usdt_probe_t *probe);
  32. typedef struct usdt_dof_section {
  33. dof_secidx_t index;
  34. uint32_t type;
  35. uint32_t flags;
  36. uint32_t align;
  37. uint64_t offset;
  38. uint64_t size;
  39. uint32_t entsize;
  40. size_t pad;
  41. struct usdt_dof_section *next;
  42. char *data;
  43. } usdt_dof_section_t;
  44. int usdt_dof_section_init(usdt_dof_section_t *section,
  45. uint32_t type, dof_secidx_t index);
  46. int usdt_dof_section_add_data(usdt_dof_section_t *section,
  47. void *data, size_t length);
  48. void usdt_dof_section_free(usdt_dof_section_t *section);
  49. typedef struct usdt_strtab {
  50. dof_secidx_t index;
  51. uint32_t type;
  52. uint32_t flags;
  53. uint32_t align;
  54. uint64_t offset;
  55. uint64_t size;
  56. uint32_t entsize;
  57. size_t pad;
  58. int strindex;
  59. char *data;
  60. } usdt_strtab_t;
  61. int usdt_strtab_init(usdt_strtab_t *strtab, dof_secidx_t index);
  62. dof_stridx_t usdt_strtab_add(usdt_strtab_t *strtab, const char *string);
  63. char *usdt_strtab_header(usdt_strtab_t *strtab);
  64. size_t usdt_strtab_size(usdt_strtab_t *strtab);
  65. size_t usdt_provider_dof_size(usdt_provider_t *provider, usdt_strtab_t *strtab);
  66. typedef struct usdt_dof_file {
  67. char *dof;
  68. int gen;
  69. size_t size;
  70. usdt_dof_section_t *sections;
  71. } usdt_dof_file_t;
  72. usdt_dof_file_t *usdt_dof_file_init(usdt_provider_t *provider, size_t size);
  73. void usdt_dof_file_append_section(usdt_dof_file_t *file, usdt_dof_section_t *section);
  74. void usdt_dof_file_generate(usdt_dof_file_t *file, usdt_strtab_t *strtab);
  75. int usdt_dof_file_load(usdt_dof_file_t *file, const char *module);
  76. int usdt_dof_file_unload(usdt_dof_file_t *file);
  77. void usdt_dof_file_free(usdt_dof_file_t *file);
  78. int usdt_dof_probes_sect(usdt_dof_section_t *probes,
  79. usdt_provider_t *provider, usdt_strtab_t *strtab);
  80. int usdt_dof_prargs_sect(usdt_dof_section_t *prargs,
  81. usdt_provider_t *provider);
  82. int usdt_dof_proffs_sect(usdt_dof_section_t *proffs,
  83. usdt_provider_t *provider, char *dof);
  84. int usdt_dof_prenoffs_sect(usdt_dof_section_t *prenoffs,
  85. usdt_provider_t *provider, char *dof);
  86. int usdt_dof_provider_sect(usdt_dof_section_t *provider_s,
  87. usdt_provider_t *provider);