Open vchuravy opened 5 years ago
I am actually not sure how these get triggered...
Below is a generated header file provided from @nhdaly
Here the probes are just defined as call to __dtrace_probe$julia$compile_end$v1$63686172202a
but that is marked as extern... because whos responsibility is to generate DTRACE_CALL0ARGS
.
It might be feasible that we don't have to do the shared-library trick on Mac since they don't seem to use ELF notes or something similar than requires the usage of the linker.
/*
* Generated by dtrace(1M).
*/
#ifndef _UPROBES_H_GEN
#define _UPROBES_H_GEN
#include <unistd.h>
#ifdef __cplusplus
extern "C" {
#endif
#define JULIA_STABILITY "___dtrace_stability$julia$v1$1_1_0_1_1_0_1_1_0_1_1_0_1_1_0"
#define JULIA_TYPEDEFS "___dtrace_typedefs$julia$v2"
#if !defined(DTRACE_PROBES_DISABLED) || !DTRACE_PROBES_DISABLED
#define JULIA_COMPILE_END(arg0) \
do { \
__asm__ volatile(".reference " JULIA_TYPEDEFS); \
__dtrace_probe$julia$compile__end$v1$63686172202a(arg0); \
__asm__ volatile(".reference " JULIA_STABILITY); \
} while (0)
#define JULIA_COMPILE_END_ENABLED() \
({ int _r = __dtrace_isenabled$julia$compile__end$v1(); \
__asm__ volatile(""); \
_r; })
#define JULIA_COMPILE_START() \
do { \
__asm__ volatile(".reference " JULIA_TYPEDEFS); \
__dtrace_probe$julia$compile__start$v1(); \
__asm__ volatile(".reference " JULIA_STABILITY); \
} while (0)
#define JULIA_COMPILE_START_ENABLED() \
({ int _r = __dtrace_isenabled$julia$compile__start$v1(); \
__asm__ volatile(""); \
_r; })
extern void __dtrace_probe$julia$compile__end$v1$63686172202a(const char *);
extern int __dtrace_isenabled$julia$compile__end$v1(void);
extern void __dtrace_probe$julia$compile__start$v1(void);
extern int __dtrace_isenabled$julia$compile__start$v1(void);
#else
#define JULIA_COMPILE_END(arg0) \
do { \
} while (0)
#define JULIA_COMPILE_END_ENABLED() (0)
#define JULIA_COMPILE_START() \
do { \
} while (0)
#define JULIA_COMPILE_START_ENABLED() (0)
#endif /* !defined(DTRACE_PROBES_DISABLED) || !DTRACE_PROBES_DISABLED */
#ifdef __cplusplus
}
#endif
#endif /* _UPROBES_H_GEN */
Ok they are implemented very differently on Mac than on Linux https://opensource.apple.com/source/xnu/xnu-2050.9.2/bsd/dev/dtrace/dtrace.c
libusdt
is a good blueprint: https://github.com/chrisa/libusdt
The implementation can be found hidden away in this header file https://opensource.apple.com/source/xnu/xnu-4570.41.2/osfmk/mach/i386/sdt_isa.h.auto.html