aboutsummaryrefslogtreecommitdiffstats
path: root/erts/emulator/beam/erl_nfunc_sched.c
diff options
context:
space:
mode:
authorRickard Green <[email protected]>2016-11-08 09:51:03 +0100
committerRickard Green <[email protected]>2017-01-12 15:22:26 +0100
commit04e119e22a68d686b9e8df17c0a4836c4a5b91ea (patch)
tree59c7519927a8d72a31ae2ff609bd2db5acd29d4a /erts/emulator/beam/erl_nfunc_sched.c
parent95ec5d385cfba23c770d946871c0197bf374ff3c (diff)
downloadotp-04e119e22a68d686b9e8df17c0a4836c4a5b91ea.tar.gz
otp-04e119e22a68d686b9e8df17c0a4836c4a5b91ea.tar.bz2
otp-04e119e22a68d686b9e8df17c0a4836c4a5b91ea.zip
Return and exception trace for nif-export scheduled BIFs
The support is somewhat primitive, since it is determined at call time if trace on return or exception should be sent.
Diffstat (limited to 'erts/emulator/beam/erl_nfunc_sched.c')
-rw-r--r--erts/emulator/beam/erl_nfunc_sched.c40
1 files changed, 39 insertions, 1 deletions
diff --git a/erts/emulator/beam/erl_nfunc_sched.c b/erts/emulator/beam/erl_nfunc_sched.c
index bc3fd83d7a..1bebc1eda4 100644
--- a/erts/emulator/beam/erl_nfunc_sched.c
+++ b/erts/emulator/beam/erl_nfunc_sched.c
@@ -28,6 +28,7 @@
#include "erl_process.h"
#include "bif.h"
#include "erl_nfunc_sched.h"
+#include "erl_trace.h"
NifExport *
erts_new_proc_nif_export(Process *c_p, int argc)
@@ -44,9 +45,12 @@ erts_new_proc_nif_export(Process *c_p, int argc)
nep->argc = -1; /* unused marker */
nep->argv_size = argc;
+ nep->trace = NULL;
old_nep = ERTS_PROC_SET_NIF_TRAP_EXPORT(c_p, nep);
- if (old_nep)
+ if (old_nep) {
+ ASSERT(!nep->trace);
erts_free(ERTS_ALC_T_NIF_TRAP_EXPORT, old_nep);
+ }
return nep;
}
@@ -61,6 +65,40 @@ erts_destroy_nif_export(Process *p)
}
}
+void
+erts_nif_export_save_trace(Process *c_p, NifExport *nep, int applying,
+ Export* ep, BeamInstr *cp, Uint32 flags,
+ Uint32 flags_meta, BeamInstr* I,
+ ErtsTracer meta_tracer)
+{
+ NifExportTrace *netp;
+ ASSERT(nep && nep->argc >= 0);
+ ASSERT(!nep->trace);
+ netp = erts_alloc(ERTS_ALC_T_NIF_EXP_TRACE,
+ sizeof(NifExportTrace));
+ netp->applying = applying;
+ netp->ep = ep;
+ netp->cp = cp;
+ netp->flags = flags;
+ netp->flags_meta = flags_meta;
+ netp->I = I;
+ netp->meta_tracer = NIL;
+ erts_tracer_update(&netp->meta_tracer, meta_tracer);
+ nep->trace = netp;
+}
+
+void
+erts_nif_export_restore_trace(Process *c_p, Eterm result, NifExport *nep)
+{
+ NifExportTrace *netp = nep->trace;
+ nep->trace = NULL;
+ erts_bif_trace_epilogue(c_p, result, netp->applying, netp->ep,
+ netp->cp, netp->flags, netp->flags_meta,
+ netp->I, netp->meta_tracer);
+ erts_tracer_update(&netp->meta_tracer, NIL);
+ erts_free(ERTS_ALC_T_NIF_EXP_TRACE, netp);
+}
+
NifExport *
erts_nif_export_schedule(Process *c_p, Process *dirty_shadow_proc,
ErtsCodeMFA *mfa, BeamInstr *pc,