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.

dtrace_provider.h 2.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. #include <nan.h>
  2. #include <node_object_wrap.h>
  3. extern "C" {
  4. #include <usdt.h>
  5. }
  6. #include <sys/dtrace.h>
  7. #include <sys/types.h>
  8. #include <sys/mman.h>
  9. #include <errno.h>
  10. #include <string.h>
  11. #include <fcntl.h>
  12. #include <unistd.h>
  13. #ifndef __APPLE__
  14. #include <stdlib.h>
  15. #ifndef __FreeBSD__
  16. #include <malloc.h>
  17. #endif
  18. #endif
  19. namespace node {
  20. using namespace v8;
  21. class DTraceArgument {
  22. public:
  23. virtual const char *Type() = 0;
  24. virtual void *ArgumentValue(v8::Local<Value>) = 0;
  25. virtual void FreeArgument(void *) = 0;
  26. virtual ~DTraceArgument() { };
  27. };
  28. class DTraceIntegerArgument : public DTraceArgument {
  29. public:
  30. const char *Type();
  31. void *ArgumentValue(v8::Local<Value>);
  32. void FreeArgument(void *);
  33. };
  34. class DTraceStringArgument : public DTraceArgument {
  35. public:
  36. const char *Type();
  37. void *ArgumentValue(v8::Local<Value>);
  38. void FreeArgument(void *);
  39. };
  40. class DTraceJsonArgument : public DTraceArgument {
  41. public:
  42. const char *Type();
  43. void *ArgumentValue(v8::Local<Value>);
  44. void FreeArgument(void *);
  45. DTraceJsonArgument();
  46. ~DTraceJsonArgument();
  47. private:
  48. Nan::Persistent<Object> JSON;
  49. Nan::Persistent<Function> JSON_stringify;
  50. };
  51. class DTraceProbe : public Nan::ObjectWrap {
  52. public:
  53. static void Initialize(v8::Local<v8::Object> target);
  54. usdt_probedef_t *probedef;
  55. size_t argc;
  56. DTraceArgument *arguments[USDT_ARG_MAX];
  57. static NAN_METHOD(New);
  58. static NAN_METHOD(Fire);
  59. v8::Local<Value> _fire(Nan::NAN_METHOD_ARGS_TYPE, size_t);
  60. static Nan::Persistent<FunctionTemplate> constructor_template;
  61. DTraceProbe();
  62. ~DTraceProbe();
  63. private:
  64. };
  65. class DTraceProvider : public Nan::ObjectWrap {
  66. public:
  67. static void Initialize(v8::Local<v8::Object> target);
  68. usdt_provider_t *provider;
  69. static NAN_METHOD(New);
  70. static NAN_METHOD(AddProbe);
  71. static NAN_METHOD(RemoveProbe);
  72. static NAN_METHOD(Enable);
  73. static NAN_METHOD(Disable);
  74. static NAN_METHOD(Fire);
  75. DTraceProvider();
  76. ~DTraceProvider();
  77. private:
  78. static Nan::Persistent<FunctionTemplate> constructor_template;
  79. };
  80. void InitDTraceProvider(v8::Local<v8::Object> target);
  81. }