aboutsummaryrefslogtreecommitdiffstats
path: root/lib/dtrace
diff options
context:
space:
mode:
Diffstat (limited to 'lib/dtrace')
-rw-r--r--lib/dtrace/c_src/Makefile.in10
-rw-r--r--lib/dtrace/examples/efile_drv.d3
-rw-r--r--lib/dtrace/src/dtrace.erl41
3 files changed, 29 insertions, 25 deletions
diff --git a/lib/dtrace/c_src/Makefile.in b/lib/dtrace/c_src/Makefile.in
index 831ce5ce75..4d5f59a63d 100644
--- a/lib/dtrace/c_src/Makefile.in
+++ b/lib/dtrace/c_src/Makefile.in
@@ -76,7 +76,7 @@ before_DTrace_OBJS = $(OBJDIR)/dtrace$(TYPEMARKER).o
## NIF_MAKEFILE = $(PRIVDIR)/Makefile
# Higher-level makefiles says that we can only compile on UNIX flavors
-NIF_LIB = $(LIBDIR)/dtrace$(TYPEMARKER).so
+NIF_LIB = $(LIBDIR)/dtrace$(TYPEMARKER).@DED_EXT@
ifeq ($(HOST_OS),)
HOST_OS := $(shell $(ERL_TOP)/erts/autoconf/config.guess)
@@ -121,14 +121,14 @@ $(OBJDIR)/%$(TYPEMARKER).o: %.c $(DTRACE_USER_HEADER)
$(INSTALL_DIR) $(OBJDIR)
$(CC) -c -o $@ $(ALL_CFLAGS) $<
-$(LIBDIR)/dtrace$(TYPEMARKER).so: $(OBJS)
+$(NIF_LIB): $(OBJS)
$(INSTALL_DIR) $(LIBDIR)
$(LD) $(LDFLAGS) -o $@ $^ $(LDLIBS)
clean:
- rm -f $(LIBDIR)/dtrace.so
- rm -f $(LIBDIR)/dtrace.debug.so
- rm -f $(LIBDIR)/dtrace.valgrind.so
+ rm -f $(LIBDIR)/dtrace.@DED_EXT@
+ rm -f $(LIBDIR)/dtrace.debug.@DED_EXT@
+ rm -f $(LIBDIR)/dtrace.valgrind.@DED_EXT@
rm -f $(OBJDIR)/dtrace.o
rm -f $(OBJDIR)/dtrace.debug.o
rm -f $(OBJDIR)/dtrace.valgrind.o
diff --git a/lib/dtrace/examples/efile_drv.d b/lib/dtrace/examples/efile_drv.d
index c9c8080dba..085995ce58 100644
--- a/lib/dtrace/examples/efile_drv.d
+++ b/lib/dtrace/examples/efile_drv.d
@@ -71,7 +71,8 @@ erlang*:::efile_drv-entry
arg4 == NULL ? "" : copyinstr(arg4),
arg5 == NULL ? "" : copyinstr(arg5), arg6, arg7,
/* NOTE: port name in args[10] is experimental */
- copyinstr((user_addr_t) args[10]))
+ (args[10] == NULL) ?
+ "?" : copyinstr((user_addr_t) args[10]));
}
erlang*:::efile_drv-int*
diff --git a/lib/dtrace/src/dtrace.erl b/lib/dtrace/src/dtrace.erl
index 6951c03215..71a1a3480e 100644
--- a/lib/dtrace/src/dtrace.erl
+++ b/lib/dtrace/src/dtrace.erl
@@ -35,12 +35,10 @@
%%% then the driver will ignore the user's input and use a default
%%% value of 0 or NULL, respectively.
--define(DTRACE_UT_KEY, '_dtrace_utag_@_@'). % Match prim_file:get_dtrace_utag()!
-
-export([init/0, available/0,
user_trace_s1/1, % TODO: unify with pid & tag args like user_trace_i4s4
p/0, p/1, p/2, p/3, p/4, p/5, p/6, p/7, p/8]).
--export([put_utag/1, get_utag/0]).
+-export([put_utag/1, get_utag/0, get_utag_data/0, spread_utag/1, restore_utag/1]).
-export([scaff/0]). % Development only
-export([user_trace_i4s4/9]). % Know what you're doing!
@@ -188,24 +186,29 @@ user_trace_int(I1, I2, I3, I4, S1, S2, S3, S4) ->
false
end.
--spec put_utag(undefined | iolist()) -> ok.
-
-put_utag(undefined) ->
- put_utag(<<>>);
-put_utag(T) when is_binary(T) ->
- put(?DTRACE_UT_KEY, T),
- ok;
-put_utag(T) when is_list(T) ->
- put(?DTRACE_UT_KEY, list_to_binary(T)),
- ok.
+-spec put_utag(undefined | iodata()) -> binary() | undefined.
+put_utag(Data) ->
+ erlang:put_utag(unicode:characters_to_binary(Data)).
+-spec get_utag() -> binary() | undefined.
get_utag() ->
- case get(?DTRACE_UT_KEY) of
- undefined ->
- <<>>;
- X ->
- X
- end.
+ erlang:get_utag().
+
+-spec get_utag_data() -> binary() | undefined.
+%% Gets utag if set, otherwise the spread utag data from last incoming message
+get_utag_data() ->
+ erlang:get_utag_data().
+
+-spec spread_utag(boolean()) -> true | {non_neg_integer(), binary() | []}.
+%% Makes the utag behave as a sequential trace token, will spread with messages to be picked up by someone using
+%% get_utag_data or get_drv_utag_data.
+spread_utag(B) ->
+ erlang:spread_utag(B).
+
+-spec restore_utag(true | {non_neg_integer(), binary() | []}) -> true.
+restore_utag(T) ->
+ erlang:restore_utag(T).
+
%% Scaffolding to write tedious code: quick brute force and not 100% correct.