Skip to content

[dbg] make simple tracer() remsh-friendly - #9589

Merged
frazze-jobb merged 2 commits into
erlang:masterfrom
stolen:dbg-tracer-for-remsh
Jun 12, 2025
Merged

frazze-jobb merged 2 commits into
erlang:masterfrom
stolen:dbg-tracer-for-remsh

Conversation

@stolen

@stolen stolen commented Mar 13, 2025

Copy link
Copy Markdown
Contributor

The problem

Consider following dbg getting started guide https://www.erlang.org/doc/apps/runtime_tools/dbg.html

1> dbg:tracer().  % Start the default trace message receiver

If performed over remsh (e.g. when debugging a production node), default tracer prints all its messages to user process on the main node. This leads to no data printed to the shell which started the tracer, making dbg unusable for novice remsh users.

Solution

In this PR I make default tracer aware of remsh, and when remsh is detected, the output is sent to remote group_leader.
For local calls behaviour stays as before -- default output is user process.

@CLAassistant

CLAassistant commented Mar 13, 2025 •

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@github-actions

github-actions Bot commented Mar 13, 2025 •

Copy link
Copy Markdown
Contributor

CT Test Results

No tests were run for this PR. This is either because the build failed, or the PR is based on a branch without GH actions tests configured.

Results for commit ede0811

To speed up review, make sure that you have read Contributing to Erlang/OTP and that all checks pass.

See the TESTING and DEVELOPMENT HowTo guides for details about how to run test locally.

Artifacts

// Erlang/OTP Github Action Bot

@stolen
stolen force-pushed the dbg-tracer-for-remsh branch from 9e6e94a to 91cf595 Compare March 13, 2025 15:51
@jhogberg jhogberg added the team:VM Assigned to OTP team VM label Mar 17, 2025
@stolen
stolen force-pushed the dbg-tracer-for-remsh branch 2 times, most recently from 53b2012 to 7dd7d9d Compare March 17, 2025 09:18
Comment thread lib/runtime_tools/src/dbg.erl Outdated
%% When user (human) sets up dbg over remsh, group_leader is on other node.
%% In this case, pass printed info to the remote group_leader
%% so the user (human) can see what's happening
case node(group_leader()) == node() of

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you add a check here, that looks for if the current process is a shell.
{_Key, Ancestors} = process_info(self(),{dictionary, '$ancestors'})), shell:whereis() == hd(Ancestors).

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

@stolen
stolen force-pushed the dbg-tracer-for-remsh branch from 7dd7d9d to 7eda3af Compare April 22, 2025 12:17
stolen and others added 2 commits May 26, 2025 10:33
`dbg:tracer()` as shown in getting started was printing
everything via local `user` process. This made trace messages
invisible over remsh unless tracer was explicitly configured.

This commit makes default trace use group_leader, making
it less surprising for remsh users.
@frazze-jobb
frazze-jobb force-pushed the dbg-tracer-for-remsh branch from 7eda3af to ede0811 Compare May 26, 2025 08:34
@frazze-jobb frazze-jobb added the testing currently being tested, tag is used by OTP internal CI label Jun 2, 2025
@frazze-jobb
frazze-jobb merged commit 927327d into erlang:master Jun 12, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

team:VM Assigned to OTP team VM testing currently being tested, tag is used by OTP internal CI

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants