{"id":16701716,"url":"https://github.com/massemanet/redbug","last_synced_at":"2025-05-14T18:02:11.871Z","repository":{"id":11023916,"uuid":"68041216","full_name":"massemanet/redbug","owner":"massemanet","description":"erlang tracing debugger","archived":false,"fork":false,"pushed_at":"2025-02-26T11:20:29.000Z","size":1630,"stargazers_count":223,"open_issues_count":10,"forks_count":47,"subscribers_count":11,"default_branch":"master","last_synced_at":"2025-05-14T18:01:43.120Z","etag":null,"topics":["debugging","erlang","tracing"],"latest_commit_sha":null,"homepage":"","language":"Erlang","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/massemanet.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2016-09-12T19:35:52.000Z","updated_at":"2025-05-13T09:34:06.000Z","dependencies_parsed_at":"2023-11-27T11:28:56.101Z","dependency_job_id":"7ccdd8e5-9b66-4ad8-bc9c-a044005c80a5","html_url":"https://github.com/massemanet/redbug","commit_stats":{"total_commits":77,"total_committers":4,"mean_commits":19.25,"dds":"0.038961038961038974","last_synced_commit":"09ee7142f0fcab99151efb1fc405a067f1b15b56"},"previous_names":[],"tags_count":17,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/massemanet%2Fredbug","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/massemanet%2Fredbug/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/massemanet%2Fredbug/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/massemanet%2Fredbug/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/massemanet","download_url":"https://codeload.github.com/massemanet/redbug/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254198453,"owners_count":22030964,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["debugging","erlang","tracing"],"created_at":"2024-10-12T18:45:18.352Z","updated_at":"2025-05-14T18:02:11.793Z","avatar_url":"https://github.com/massemanet.png","language":"Erlang","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![Build Status](https://travis-ci.org/massemanet/redbug.svg?branch=master)](https://travis-ci.org/massemanet/redbug)\n\n\n# DESCRIPTION\n\nredbug is a tool to interact with the Erlang trace facility. It is\nintended to be run from the erlang shell, but it can also be run from\nan OS shell as an escript (see below). It will instruct the Erlang VM\nto generate so-called 'trace messages' when certain events (such as a\nparticular function being called) occur. It uses a safe subset of the\ntracing functionality, and exits if it feels overloaded, e.g. if it\ngets flooded by trace messages. It runs in the background, collecting\ntrace messages, until it reaches one of its termination criteria\n(number of messages/file size or elapsed time).\n\nThe trace messages are either printed (i.e. human readable) to a file\nor to the screen; or written to a trc file.  Using a trc file puts\nless stress on the system, but there is no way to count the messages\n(so the 'msgs' opt is ignored), and the files can only be read by\nspecial tools (such as 'bread'). Printing and trc files cannot be\ncombined.  By default (i.e. if the 'file' opt is not given), messages\nare printed.\n\n# DOCUMENTATION\n\nRun `erl -run redbug help -run erlang halt`, or `redbug:help().`.\n\n# EXAMPLES\n\nBasic call trace\n\n      1\u003e redbug:start(\"erlang:demonitor\").\n\n      % 18:27:21 \u003c0.188.0\u003e({erlang,apply,2})\n      % erlang:demonitor(#Ref\u003c0.2419348116.2832203778.12948\u003e)\n\n      % 18:27:21 \u003c0.188.0\u003e({erlang,apply,2})\n      % erlang:demonitor(#Ref\u003c0.2419348116.2832203777.10938\u003e, [flush])\n\n      % 18:27:21 \u003c0.188.0\u003e({erlang,apply,2})\n      % erlang:demonitor(#Ref\u003c0.2419348116.2832203777.10939\u003e, [flush])\n\n      % 18:27:21 \u003c0.188.0\u003e({erlang,apply,2})\n      % erlang:demonitor(#Ref\u003c0.2419348116.2832203777.10940\u003e, [flush])\n      redbug done, timeout - 4\n\n\nAs above, but also print return value. The return value is a separate message.\n\n      2\u003e redbug:start(\"erlang:demonitor-\u003ereturn\",[{msgs,2}]).\n      {75,2}\n\n      % 18:31:15 \u003c0.188.0\u003e({erlang,apply,2})\n      % erlang:demonitor(#Ref\u003c0.2419348116.2832203780.10535\u003e)\n\n      % 18:31:15 \u003c0.188.0\u003e({erlang,apply,2})\n      % erlang:demonitor/1 -\u003e true\n      redbug done, msg_count - 1\n\nAs above, also print the call stack. Note that not all functions in the\ncall chain are on the stack, only functions we will return to (this is a\nconsequence of tail call optimization.)\n\n      3\u003e redbug:start(\"erlang:demonitor-\u003ereturn,stack\",[{msgs,2}]).\n      {75,2}\n\n      % 18:32:54 \u003c0.188.0\u003e({erlang,apply,2})\n      % erlang:demonitor(#Ref\u003c0.2419348116.2832203778.13012\u003e)\n      %   redbug:block_a_little/0 \n      %   redbug:start/2 \n      %   erl_eval:do_apply/6 \n      %   shell:exprs/7 \n      %   shell:eval_exprs/7 \n      %   shell:eval_loop/3 \n\nAs above, but use the 'blocking' opt. redbug:start/2 blocks until end of\ntrace, and returns the stop reason and a list of trace messages.\n\n    10\u003e spawn(fun()-\u003ereceive after 2000-\u003eets:tab2list(inet_db) end end).\n    \u003c0.540.0\u003e\n    11\u003e redbug:start(\"ets:tab2list(inet_db)\",[blocking]).\n    {timeout,[{call,{{ets,tab2list,[inet_db]},\u003c\u003c\u003e\u003e},\n                    {\u003c0.540.0\u003e,{erlang,apply,2}},\n                    {15,50,43,776041}}]}\n\n\n# ESCRIPT\n\nRun from command line (portable escript archive)\n\n    ./_build/default/bin/redbug [-Opt Value [...]] TargetNode Trc [Trc...]\n\nExamples using the escript\n\nFirst start a node that we're going to trace:\n\n    erl -sname foo\n\nWe'll need to type some commands into the shell for some of the\nfollowing traces to trigger.\n\nStart tracing, giving the node name as the first argument. (If the\nnode name doesn't contain a host name, redbug will create a short\nnode name by adding the host name.)\n\n    $ redbug foo erlang:demonitor\n\n    % 14:19:29 \u003c5270.91.0\u003e(dead)\n    % erlang:demonitor(#Ref\u003c5270.0.4.122\u003e, [flush])\n\n    % 14:19:29 \u003c5270.40.0\u003e({erlang,apply,2})\n    % erlang:demonitor(#Ref\u003c5270.0.4.130\u003e, [flush])\n\n    % 14:19:29 \u003c5270.40.0\u003e({erlang,apply,2})\n    % erlang:demonitor(#Ref\u003c5270.0.4.131\u003e, [flush])\n\n    % 14:19:29 \u003c5270.40.0\u003e({erlang,apply,2})\n    % erlang:demonitor(#Ref\u003c5270.0.4.132\u003e, [flush])\n    redbug done, timeout - 4\n\n    %% Limit message count\n    $ redbug foo erlang:demonitor -msgs 1\n\n    % 14:22:09 \u003c5276.103.0\u003e(dead)\n    % erlang:demonitor(#Ref\u003c5276.0.4.144\u003e, [flush])\n    redbug done, msg_count - 1\n\n    %% Print return value. The return value is a separate message.\n    $ redbug foo 'erlang:demonitor -\u003e return' -msgs 2\n\n    % 14:23:47 \u003c5276.115.0\u003e(dead)\n    % erlang:demonitor(#Ref\u003c5276.0.4.166\u003e, [flush])\n\n    % 14:23:47 \u003c5276.115.0\u003e(dead)\n    % erlang:demonitor/2 -\u003e true\n    redbug done, msg_count - 1\n\n    %% Also print call stack.\n    $ redbug foo 'erlang:demonitor -\u003e return;stack' -msgs 2\n\n    % 14:24:43 \u003c5276.121.0\u003e(dead)\n    % erlang:demonitor(#Ref\u003c5276.0.4.177\u003e, [flush])\n      shell:'-get_command/5-fun-0-'/1\n\n    % 14:24:43 \u003c5276.121.0\u003e(dead)\n    % erlang:demonitor/2 -\u003e true\n    redbug done, msg_count - 1\n\n    %% Trace on messages that the 'user_drv' process receives.\n    $ redbug foo receive -procs user_drv -msgs 1\n\n    % 14:27:10 \u003c6071.31.0\u003e(user_drv)\n    % \u003c\u003c\u003c {#Port\u003c6071.375\u003e,{data,\"a\"}}\n    redbug done, msg_count - 1\n\n    %% As above, but also trace on sends. The two trace patterns\n    %% are given as separate arguments.\n    $ redbug foo receive send -procs user_drv -msgs 2\n\n    % 17:43:28 \u003c6071.31.0\u003e(user_drv)\n    % \u003c\u003c\u003c {#Port\u003c6071.375\u003e,{data,\"a\"}}\n\n    % 17:43:28 \u003c6071.31.0\u003e(user_drv)\n    % \u003c6071.33.0\u003e({group,server,3}) \u003c\u003c\u003c {\u003c6071.31.0\u003e,{data,\"a\"}}\n    redbug done, msg_count - 2\n\n    %% Call trace with a function head match.\n    $ redbug foo 'ets:tab2list(inet_db)' -msgs 2\n\n    % 17:45:48 \u003c5276.40.0\u003e({erlang,apply,2})\n    % ets:tab2list(inet_db)\n    redbug done, timeout - 1\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmassemanet%2Fredbug","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmassemanet%2Fredbug","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmassemanet%2Fredbug/lists"}