aboutsummaryrefslogtreecommitdiffstats
path: root/erts/emulator/beam/erl_bif_trace.c
diff options
context:
space:
mode:
authorBjörn Gustavsson <[email protected]>2012-02-28 05:44:26 +0100
committerBjörn Gustavsson <[email protected]>2012-06-25 14:31:19 +0200
commitdf41b1ab56ad0186d1233b141861fbaa794d69aa (patch)
tree499f80906400d0c3476b2c7308c810ea73aa3eba /erts/emulator/beam/erl_bif_trace.c
parentaa340f8d8a13b86f2938a4ce0b3c7d5807dec716 (diff)
downloadotp-df41b1ab56ad0186d1233b141861fbaa794d69aa.tar.gz
otp-df41b1ab56ad0186d1233b141861fbaa794d69aa.tar.bz2
otp-df41b1ab56ad0186d1233b141861fbaa794d69aa.zip
Refactor the code for managing breakpoints
To allow us to manage breakpoints without going to single-scheduler mode, we will need to update the breakpoints in several stages with memory barriers in between each stage. Prepare for that by splitting up the breakpoint setting and clearing functions into several smaller functions.
Diffstat (limited to 'erts/emulator/beam/erl_bif_trace.c')
-rw-r--r--erts/emulator/beam/erl_bif_trace.c46
1 files changed, 23 insertions, 23 deletions
diff --git a/erts/emulator/beam/erl_bif_trace.c b/erts/emulator/beam/erl_bif_trace.c
index 23dbdf7d6d..971e5ed650 100644
--- a/erts/emulator/beam/erl_bif_trace.c
+++ b/erts/emulator/beam/erl_bif_trace.c
@@ -1333,6 +1333,7 @@ erts_set_trace_pattern(Eterm* mfa, int specified,
Eterm meta_tracer_pid)
{
const ErtsCodeIndex code_ix = erts_active_code_ix();
+ BpFunctions f;
int matches = 0;
int i;
@@ -1466,50 +1467,50 @@ erts_set_trace_pattern(Eterm* mfa, int specified,
/*
** So, now for breakpoint tracing
*/
+ erts_bp_match_functions(&f, mfa, specified);
if (on) {
if (! flags.breakpoint) {
- erts_clear_trace_break(mfa, specified);
- erts_clear_mtrace_break(mfa, specified);
- erts_clear_count_break(mfa, specified);
- erts_clear_time_break(mfa, specified);
+ erts_clear_all_breaks(&f);
+ erts_commit_staged_bp();
+ erts_uninstall_breakpoints(&f);
} else {
- int m = 0;
if (flags.local) {
- m = erts_set_trace_break(mfa, specified, match_prog_set);
+ erts_set_trace_break(&f, match_prog_set);
}
if (flags.meta) {
- m = erts_set_mtrace_break(mfa, specified, meta_match_prog_set,
- meta_tracer_pid);
+ erts_set_mtrace_break(&f, meta_match_prog_set,
+ meta_tracer_pid);
}
if (flags.call_count) {
- m = erts_set_count_break(mfa, specified, on);
+ erts_set_count_break(&f, on);
}
if (flags.call_time) {
- m = erts_set_time_break(mfa, specified, on);
+ erts_set_time_break(&f, on);
}
- /* All assignments to 'm' above should give the same value,
- * so just use the last */
- matches += m;
+ erts_install_breakpoints(&f);
+ erts_commit_staged_bp();
}
} else {
- int m = 0;
if (flags.local) {
- m = erts_clear_trace_break(mfa, specified);
+ erts_clear_trace_break(&f);
}
if (flags.meta) {
- m = erts_clear_mtrace_break(mfa, specified);
+ erts_clear_mtrace_break(&f);
}
if (flags.call_count) {
- m = erts_clear_count_break(mfa, specified);
+ erts_clear_count_break(&f);
}
if (flags.call_time) {
- m = erts_clear_time_break(mfa, specified);
+ erts_clear_time_break(&f);
}
- /* All assignments to 'm' above should give the same value,
- * so just use the last */
- matches += m;
+ erts_commit_staged_bp();
+ erts_uninstall_breakpoints(&f);
}
-
+ erts_consolidate_bp_data(&f);
+ if (flags.breakpoint) {
+ matches += f.matched;
+ }
+ erts_bp_free_matched_functions(&f);
return matches;
}
@@ -1631,7 +1632,6 @@ static void reset_bif_trace(int bif_index) {
ASSERT(ExportIsBuiltIn(ep));
ASSERT(ep->code[4]);
ASSERT(! ep->match_prog_set);
- ASSERT(! erts_is_mtrace_break((BeamInstr *)ep->code+3, NULL, NULL));
ep->code[4] = (BeamInstr) bif_table[bif_index].f;
}