Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
home:Ledest:erlang:23
erlang
5011-dbg-Disarm-the-stop-0-footgun.patch
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File 5011-dbg-Disarm-the-stop-0-footgun.patch of Package erlang
From c211ae25e8a6719d2b10aac3a861cdbd6fe5881f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?John=20H=C3=B6gberg?= <john@erlang.org> Date: Wed, 2 Feb 2022 14:51:45 +0100 Subject: [PATCH] dbg: Disarm the stop/0 footgun `dbg:stop/0` explicitly leaves global function tracing untouched, which can lead to some very confusing situations: 1. As it clears the trace flags of all processes, it often *looks* like all global function trace patterns have been cleared, leaving a fun surprise for the next poor sod that tries to trace anything. 2. It makes it really annoying to clear global function traces afterwards, as we've discarded all information on what nodes we've been tracing on. The user more or less has to call `erlang:trace_pattern/3` themselves on all nodes they've traced on. Since clearing the trace flags of all processes means that `dbg` can't coexist with other trace tools to begin with, there is very little point in keeping global trace patterns around after stop/0. This commit makes stop/0 behave like stop_clear/0, ensuring that *ALL* tracing is turned off on *ALL* associated nodes before shutting down. --- lib/runtime_tools/doc/src/dbg.xml | 16 ++++------------ lib/runtime_tools/src/dbg.erl | 16 +++++++++++----- 2 files changed, 15 insertions(+), 17 deletions(-) diff --git a/lib/runtime_tools/doc/src/dbg.xml b/lib/runtime_tools/doc/src/dbg.xml index 7532ec692d..1f6bc713f4 100644 --- a/lib/runtime_tools/doc/src/dbg.xml +++ b/lib/runtime_tools/doc/src/dbg.xml @@ -1156,20 +1156,12 @@ hello</pre> </func> <func> <name since="">stop() -> ok</name> - <fsummary>Stop the <c>dbg</c>server and the tracing of all processes.</fsummary> - <desc> - <p>Stops the <c>dbg</c> server and clears all trace flags for - all processes and all local trace patterns for all functions. Also - shuts down all trace clients and closes all trace ports.</p> - <p>Note that no global trace patterns are affected by this - function.</p> - </desc> - </func> - <func> - <name since="">stop_clear() -> ok</name> <fsummary>Stop the <c>dbg</c>server and the tracing of all processes, and clears trace patterns.</fsummary> <desc> - <p>Same as stop/0, but also clears all trace patterns on global functions calls.</p> + <p>Stops the <c>dbg</c> server, clears all trace flags for + all processes, clears all trace patterns for all functions, + clears trace patterns for send/receive, shuts down all trace clients, + and closes all trace ports.</p> </desc> </func> </funcs> diff --git a/lib/runtime_tools/src/dbg.erl b/lib/runtime_tools/src/dbg.erl index 7dd3c452e5..ca0f6e689e 100644 --- a/lib/runtime_tools/src/dbg.erl +++ b/lib/runtime_tools/src/dbg.erl @@ -595,17 +595,23 @@ c(Parent, M, F, A, Flags) -> -spec stop() -> ok. stop() -> + {ok, _} = ctp(), + {ok, _} = ctpe('receive'), + {ok, _} = ctpe('send'), + Mref = erlang:monitor(process, dbg), catch dbg ! {self(),stop}, + receive - {'DOWN',Mref,_,_,_} -> - ok + {'DOWN',Mref,_,_,_} -> ok end. +%% This is a vestigial function that used to be documented as a variant of +%% `stop/0` that also clears global function traces. Since `stop/0` now clears +%% all tracing as the user would expect it to, we've removed this from the +%% documentation but keep it around for backwards compatibility, much like +%% `queue:lait`. stop_clear() -> - {ok, _} = ctp(), - {ok, _} = ctpe('receive'), - {ok, _} = ctpe('send'), stop(). %%% Calling the server. -- 2.34.1
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor