[swift-users] DTrace Static (USDT) Probes & Swift
Daniel Eggert
danieleggert at me.com
Mon Jan 11 04:08:30 CST 2016
What are the thoughts on dtrace & Swift?
Would a sane approach be to teach the dtrace tool to generate SIL?
Currently 'dtrace -h’ will generate a C header file containing macro definitions for USDT probes. Could this be replaced by a tool than converts such a ‘.d’ file into SIL?
/Daniel
For example: ‘dtrace -h' it will turn
provider foo {
probe bar(int, intptr_t);
probe baz(char *, int);
};
into
/*
* Generated by dtrace(1M).
*/
#ifndef _PROVIDER_H
#define _PROVIDER_H
#include <unistd.h>
#ifdef __cplusplus
extern "C" {
#endif
#define FOO_STABILITY "___dtrace_stability$foo$v1$1_1_0_1_1_0_1_1_0_1_1_0_1_1_0"
#define FOO_TYPEDEFS "___dtrace_typedefs$foo$v2"
#if !defined(DTRACE_PROBES_DISABLED) || !DTRACE_PROBES_DISABLED
#define FOO_BAR(arg0, arg1) \
do { \
__asm__ volatile(".reference " FOO_TYPEDEFS); \
__dtrace_probe$foo$bar$v1$696e74$696e747074725f74(arg0, arg1); \
__asm__ volatile(".reference " FOO_STABILITY); \
} while (0)
#define FOO_BAR_ENABLED() \
({ int _r = __dtrace_isenabled$foo$bar$v1(); \
__asm__ volatile(""); \
_r; })
#define FOO_BAZ(arg0, arg1) \
do { \
__asm__ volatile(".reference " FOO_TYPEDEFS); \
__dtrace_probe$foo$baz$v1$63686172202a$696e74(arg0, arg1); \
__asm__ volatile(".reference " FOO_STABILITY); \
} while (0)
#define FOO_BAZ_ENABLED() \
({ int _r = __dtrace_isenabled$foo$baz$v1(); \
__asm__ volatile(""); \
_r; })
extern void __dtrace_probe$foo$bar$v1$696e74$696e747074725f74(int, intptr_t);
extern int __dtrace_isenabled$foo$bar$v1(void);
extern void __dtrace_probe$foo$baz$v1$63686172202a$696e74(const char *, int);
extern int __dtrace_isenabled$foo$baz$v1(void);
#else
#define FOO_BAR(arg0, arg1) \
do { \
} while (0)
#define FOO_BAR_ENABLED() (0)
#define FOO_BAZ(arg0, arg1) \
do { \
} while (0)
#define FOO_BAZ_ENABLED() (0)
#endif /* !defined(DTRACE_PROBES_DISABLED) || !DTRACE_PROBES_DISABLED */
#ifdef __cplusplus
}
#endif
#endif /* _PROVIDER_H */
More information about the swift-users
mailing list