### start(RTPs, Opts) Source: https://hexdocs.pm/redbug/redbug.html Starts a trace with the given RTPs and options. ```APIDOC ## start(RTPs, Opts) ### Description Starts a trace with the given RTPs and options. ### Function Signature start(RTPs :: list(), Opts :: map()) -> {Procs :: integer(), Functions :: integer()} ``` -------------------------------- ### start(RTPs) Source: https://hexdocs.pm/redbug/redbug.html Starts a trace with the given RTPs, equivalent to start(RTPs, []). ```APIDOC ## start(RTPs) ### Description Starts a trace with the given RTPs, equivalent to start(RTPs, []). ### Function Signature start(RTPs) ``` -------------------------------- ### start(Node, Cnf) Source: https://hexdocs.pm/redbug/redbug_targ.html Starts the redbug system with a specified node and configuration. ```APIDOC ## start(Node, Cnf) ### Description Starts the redbug system with a specified node and configuration. ### Parameters * **Node** (type) - Description * **Cnf** (type) - Description ``` -------------------------------- ### Basic Tracing with Redbug Source: https://hexdocs.pm/redbug/readme.html Start tracing a node, specifying the node name and the trace pattern. This example traces the 'erlang:demonitor' function. ```bash $ redbug foo erlang:demonitor % 14:19:29 <5270.91.0>(dead) % erlang:demonitor(#Ref<5270.0.4.122>, [flush]) % 14:19:29 <5270.40.0>({erlang,apply,2}) % erlang:demonitor(#Ref<5270.0.4.130>, [flush]) % 14:19:29 <5270.40.0>({erlang,apply,2}) % erlang:demonitor(#Ref<5270.0.4.131>, [flush]) % 14:19:29 <5270.40.0>({erlang,apply,2}) % erlang:demonitor(#Ref<5270.0.4.132>, [flush]) redbug done, timeout - 4 ``` -------------------------------- ### Start Erlang Node for Tracing Source: https://hexdocs.pm/redbug/index.html Start an Erlang node that will be the target for Redbug tracing. ```bash erl -sname foo ``` -------------------------------- ### Start Redbug Trace Source: https://hexdocs.pm/redbug/redbug.html Starts a trace with specified RTPs and options. Returns the number of processes and functions traced. ```erlang -spec start(RTPs :: list(), Opts :: map()) -> {Procs :: integer(), Functions :: integer()}. ``` -------------------------------- ### Start Basic Call Trace Source: https://hexdocs.pm/redbug/readme.html Initiates a basic call trace for a specified function. The trace messages are printed to the console. ```erlang 1> redbug:start("erlang:demonitor"). % 18:27:21 <0.188.0>({erlang,apply,2}) % erlang:demonitor(#Ref<0.2419348116.2832203778.12948>) % 18:27:21 <0.188.0>({erlang,apply,2}) % erlang:demonitor(#Ref<0.2419348116.2832203777.10938>, [flush]) % 18:27:21 <0.188.0>({erlang,apply,2}) % erlang:demonitor(#Ref<0.2419348116.2832203777.10939>, [flush]) % 18:27:21 <0.188.0>({erlang,apply,2}) % erlang:demonitor(#Ref<0.2419348116.2832203777.10940>, [flush]) redbug done, timeout - 4 ``` -------------------------------- ### Basic Erlang Call Trace Source: https://hexdocs.pm/redbug/index.html Starts a basic trace for the 'erlang:demonitor' function. This snippet shows the function calls and their arguments as they occur. ```erlang 1> redbug:start("erlang:demonitor"). % 18:27:21 <0.188.0>({erlang,apply,2}) % erlang:demonitor(#Ref<0.2419348116.2832203778.12948>) % 18:27:21 <0.188.0>({erlang,apply,2}) % erlang:demonitor(#Ref<0.2419348116.2832203777.10938>, [flush]) % 18:27:21 <0.188.0>({erlang,apply,2}) % erlang:demonitor(#Ref<0.2419348116.2832203777.10939>, [flush]) % 18:27:21 <0.188.0>({erlang,apply,2}) % erlang:demonitor(#Ref<0.2419348116.2832203777.10940>, [flush]) redbug done, timeout - 4 ``` -------------------------------- ### Trace erlang:demonitor Calls Source: https://hexdocs.pm/redbug/index.html Start tracing calls to erlang:demonitor on the target node. Redbug will output trace information and indicate when it's done. ```bash $ redbug foo erlang:demonitor % 14:19:29 <5270.91.0>(dead) % erlang:demonitor(#Ref<5270.0.4.122>, [flush]) % 14:19:29 <5270.40.0>({erlang,apply,2}) % erlang:demonitor(#Ref<5270.0.4.130>, [flush]) % 14:19:29 <5270.40.0>({erlang,apply,2}) % erlang:demonitor(#Ref<5270.0.4.131>, [flush]) % 14:19:29 <5270.40.0>({erlang,apply,2}) % erlang:demonitor(#Ref<5270.0.4.132>, [flush]) redbug done, timeout - 4 ``` -------------------------------- ### Blocking Trace with Return Value Source: https://hexdocs.pm/redbug/readme.html Starts a trace in blocking mode, which pauses execution until the trace ends. It returns the stop reason and a list of collected trace messages. ```erlang 10> spawn(fun()->receive after 2000->ets:tab2list(inet_db) end end). <0.540.0> 11> redbug:start("ets:tab2list(inet_db)",[blocking]). {timeout,[{call,{{ets,tab2list,[inet_db]},<<>>}, {<0.540.0>,{erlang,apply,2}}, {15,50,43,776041}}]} ``` -------------------------------- ### help() Source: https://hexdocs.pm/redbug/redbug.html Prints the help information for the redbug tool. ```APIDOC ## help() ### Description Prints the help information for the redbug tool. ### Function Signature help() ``` -------------------------------- ### init() Source: https://hexdocs.pm/redbug/redbug_targ.html Initializes the redbug module. This function does not return any value. ```APIDOC ## init() ### Description Initializes the redbug module. This function does not return any value. ### Method (Implicitly a function call, not an HTTP method) ### Response #### Success Response - no_return() ``` -------------------------------- ### main(Args) Source: https://hexdocs.pm/redbug/redbug.html The main function to execute redbug with provided arguments. ```APIDOC ## main(Args) ### Description The main function to execute redbug with provided arguments. ### Function Signature main(Args) ``` -------------------------------- ### Initialize Redbug Source: https://hexdocs.pm/redbug/redbug_targ.html Initializes the redbug system. This function is non-returning. ```erlang -spec init() -> no_return(). ``` -------------------------------- ### dtop() Source: https://hexdocs.pm/redbug/redbug.html Equivalent to calling dtop with an empty configuration. ```APIDOC ## dtop() ### Description Equivalent to calling dtop with an empty configuration. ### Function Signature dtop() ``` -------------------------------- ### dtop(Cfg) Source: https://hexdocs.pm/redbug/redbug.html Calls dtop with a specified configuration. ```APIDOC ## dtop(Cfg) ### Description Calls dtop with a specified configuration. ### Function Signature dtop(Cfg) ``` -------------------------------- ### Erlang Call Trace with Return Value and Stack Source: https://hexdocs.pm/redbug/index.html Traces 'erlang:demonitor', logs its return value, and prints the call stack. Note that only functions that will be returned to are shown due to tail call optimization. ```erlang 3> redbug:start("erlang:demonitor->return,stack",[{msgs,2}]). {75,2} % 18:32:54 <0.188.0>({erlang,apply,2}) % erlang:demonitor(#Ref<0.2419348116.2832203778.13012]) % redbug:block_a_little/0 % redbug:start/2 % erl_eval:do_apply/6 % shell:exprs/7 % shell:eval_exprs/7 % shell:eval_loop/3 ``` -------------------------------- ### scan(Str) Source: https://hexdocs.pm/redbug/redbug_compiler.html Scans a string and returns a list of tokens. This is the initial step in the compilation process. ```APIDOC ## scan(Str) ### Description Scans a string and returns a list of tokens. ### Method Not applicable (function call) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Parameters - **Str** (string()) - Description: The input string to be scanned. ### Response #### Success Response - **tokens** (tokens()) - Description: A list of tokens generated from the input string. ### Response Example ```json { "tokens": [ {"atom": 1, "integer": 1, "term": "value"} ] } ``` ``` -------------------------------- ### Trace Calls, Return Values, and Call Stack Source: https://hexdocs.pm/redbug/readme.html Traces function calls, return values, and the call stack. The call stack shows functions that will be returned to, considering tail call optimization. ```erlang 3> redbug:start("erlang:demonitor->return,stack",[{msgs,2}]). {75,2} % 18:32:54 <0.188.0>({erlang,apply,2}) % erlang:demonitor(#Ref<0.2419348116.2832203778.13012>) % redbug:block_a_little/0 % redbug:start/2 % erl_eval:do_apply/6 % shell:exprs/7 % shell:eval_exprs/7 % shell:eval_loop/3 ``` -------------------------------- ### Trace Process Messages and Sends Source: https://hexdocs.pm/redbug/index.html Trace both incoming messages and outgoing sends for a specific process. This provides a comprehensive view of communication involving the process. ```bash $ redbug foo receive send -procs user_drv -msgs 2 % 17:43:28 <6071.31.0>(user_drv) % <<< {#Port<6071.375>,{data,"a"}} % 17:43:28 <6071.31.0>(user_drv) % <6071.33.0>({group,server,3}) <<< {<6071.31.0>,{data,"a"}} redbug done, msg_count - 2 ``` -------------------------------- ### compile(X) Source: https://hexdocs.pm/redbug/redbug_compiler.html Compiles the input into a tp() type. This function likely performs the core compilation logic. ```APIDOC ## compile(X) ### Description Compiles the input into a tp() type. ### Method Not applicable (function call) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Parameters - **X** (atom() | binary() | list()) - Description: The input to be compiled. ### Response #### Success Response - **tp** (tp()) - Description: The compiled output in tp() type format. ### Response Example ```json { "tp": { "m_f_a": ["module", "function", 1], "args": [[], [[]]], "flags": [] } } ``` ``` -------------------------------- ### Run Redbug Escript Source: https://hexdocs.pm/redbug/index.html Execute the Redbug escript from the command line. Specify options, the target node, and trace patterns. ```bash ./_build/default/bin/redbug [-Opt Value [...]] TargetNode Trc [Trc...] ``` -------------------------------- ### Trace and Print Return Value Source: https://hexdocs.pm/redbug/index.html Trace calls to erlang:demonitor and also print its return value. This requires setting a message count that accommodates both the call and the return. ```bash $ redbug foo 'erlang:demonitor -> return' -msgs 2 % 14:23:47 <5276.115.0>(dead) % erlang:demonitor(#Ref<5276.0.4.166>, [flush]) % 14:23:47 <5276.115.0>(dead) % erlang:demonitor/2 -> true redbug done, msg_count - 1 ``` -------------------------------- ### Erlang Call Trace with Return Value Source: https://hexdocs.pm/redbug/index.html Traces 'erlang:demonitor' and also prints its return value. The return value is logged as a separate message. Limited to 2 messages. ```erlang 2> redbug:start("erlang:demonitor->return",[{msgs,2}]). {75,2} % 18:31:15 <0.188.0>({erlang,apply,2}) % erlang:demonitor(#Ref<0.2419348116.2832203780.10535>) % 18:31:15 <0.188.0>({erlang,apply,2}) % erlang:demonitor/1 -> true redbug done, msg_count - 1 ``` -------------------------------- ### Trace Return Value and Call Stack Source: https://hexdocs.pm/redbug/index.html Trace calls to erlang:demonitor, print its return value, and also display the call stack. This provides more detailed debugging information. ```bash $ redbug foo 'erlang:demonitor -> return;stack' -msgs 2 % 14:24:43 <5276.121.0>(dead) % erlang:demonitor(#Ref<5276.0.4.177>, [flush]) shell:'-get_command/5-fun-0-'/1 % 14:24:43 <5276.121.0>(dead) % erlang:demonitor/2 -> true redbug done, msg_count - 1 ``` -------------------------------- ### Define args type Source: https://hexdocs.pm/redbug/redbug_compiler.html Defines the 'args' type as a list or an underscore. ```erlang -type args() :: list() | '_'. ``` -------------------------------- ### stop() Source: https://hexdocs.pm/redbug/redbug.html Stops the current trace. ```APIDOC ## stop() ### Description Stops the current trace. ### Function Signature stop() ``` -------------------------------- ### parse(Str) Source: https://hexdocs.pm/redbug/redbug_compiler.html Parses a string into an Abstract Syntax Tree (AST). This function takes the output of the scan function (or a raw string) and structures it. ```APIDOC ## parse(Str) ### Description Parses a string into an Abstract Syntax Tree (AST). ### Method Not applicable (function call) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Parameters - **Str** (string()) - Description: The input string to be parsed. ### Response #### Success Response - **AST** (ast()) - Description: The Abstract Syntax Tree representation of the input string. ### Response Example ```json { "AST": [ {"node": "expression", "children": []} ] } ``` ``` -------------------------------- ### Trace Function Head Match Source: https://hexdocs.pm/redbug/index.html Trace calls to a specific function, like ets:tab2list, using a function head match. This allows for precise targeting of function calls. ```bash $ redbug foo 'ets:tab2list(inet_db)' -msgs 2 % 17:45:48 <5276.40.0>({erlang,apply,2}) % ets:tab2list(inet_db) redbug done, timeout - 1 ``` -------------------------------- ### Trace Function Calls and Return Values Source: https://hexdocs.pm/redbug/readme.html Traces function calls and also prints the return value as a separate message. It limits the trace to a specified number of messages. ```erlang 2> redbug:start("erlang:demonitor->return",[{msgs,2}]). {75,2} % 18:31:15 <0.188.0>({erlang,apply,2}) % erlang:demonitor(#Ref<0.2419348116.2832203780.10535>) % 18:31:15 <0.188.0>({erlang,apply,2}) % erlang:demonitor/1 -> true redbug done, msg_count - 1 ``` -------------------------------- ### Trace Process Messages Source: https://hexdocs.pm/redbug/index.html Trace incoming messages for a specific process, such as 'user_drv'. This helps in understanding inter-process communication. ```bash $ redbug foo receive -procs user_drv -msgs 1 % 14:27:10 <6071.31.0>(user_drv) % <<< {#Port<6071.375>,{data,"a"}} redbug done, msg_count - 1 ``` -------------------------------- ### redbug_name(Opts) Source: https://hexdocs.pm/redbug/redbug.html Retrieves the name of the redbug instance with specified options. ```APIDOC ## redbug_name(Opts) ### Description Retrieves the name of the redbug instance with specified options. ### Function Signature redbug_name(Opts) ``` -------------------------------- ### netload_test_() Source: https://hexdocs.pm/redbug/redbug_targ.html Performs a network load test. The specific return value or side effects are not detailed in the source. ```APIDOC ## netload_test_() ### Description Performs a network load test. The specific return value or side effects are not detailed in the source. ### Method (Implicitly a function call, not an HTTP method) ``` -------------------------------- ### generate(AST) Source: https://hexdocs.pm/redbug/redbug_compiler.html Generates a tp() type from an Abstract Syntax Tree (AST). This function might be used for code generation or intermediate representation. ```APIDOC ## generate(AST) ### Description Generates a tp() type from an Abstract Syntax Tree (AST). ### Method Not applicable (function call) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Parameters - **AST** (ast()) - Description: The Abstract Syntax Tree to generate from. ### Response #### Success Response - **tp** (tp()) - Description: The generated output in tp() type format. ### Response Example ```json { "tp": { "m_f_a": ["module", "function", 1], "args": [[], [[]]], "flags": [] } } ``` ``` -------------------------------- ### Define actions type Source: https://hexdocs.pm/redbug/redbug_compiler.html Defines the 'actions' type as a list. ```erlang -type actions() :: list(). ``` -------------------------------- ### parse_and_scan(_) Source: https://hexdocs.pm/redbug/redbug_parser.html Parses and scans input, which can be a function, a tuple representing a function, or a more complex structure. It returns a result of type yecc_ret(). ```APIDOC ## parse_and_scan(_) ### Description Parses and scans input, which can be a function, a tuple representing a function, or a more complex structure. It returns a result of type yecc_ret(). ### Method N/A (Function Signature) ### Parameters #### Path Parameters N/A #### Query Parameters N/A #### Request Body N/A ### Request Example N/A ### Response #### Success Response - **return_value** (yecc_ret()) - The result of the parse and scan operation, which can be an error or an ok tuple. ``` -------------------------------- ### Limit Trace Messages Source: https://hexdocs.pm/redbug/index.html Trace calls to erlang:demonitor but limit the output to a specific number of messages. This is useful for reducing noise in the trace. ```bash $ redbug foo erlang:demonitor -msgs 1 % 14:22:09 <5276.103.0>(dead) % erlang:demonitor(#Ref<5276.0.4.144>, [flush]) redbug done, msg_count - 1 ``` -------------------------------- ### Blocking Erlang Trace with Result Source: https://hexdocs.pm/redbug/index.html Uses the 'blocking' option to make redbug:start/2 block until the trace ends. It returns the stop reason and a list of collected trace messages. ```erlang 10> spawn(fun()->receive after 2000->ets:tab2list(inet_db) end end). <0.540.0> 11> redbug:start("ets:tab2list(inet_db)",[blocking]). {timeout,[{call,{{ets,tab2list,[inet_db]},<<>>}, {<0.540.0>,{erlang,apply,2}}, {15,50,43,776041}]} ``` -------------------------------- ### get_rec_fields(Mod, Rec) Source: https://hexdocs.pm/redbug/redbug_targ.html Retrieves the fields associated with a specific record within a given module. ```APIDOC ## get_rec_fields(Mod, Rec) ### Description Retrieves the fields associated with a specific record within a given module. ### Parameters * **Mod** (type) - Description * **Rec** (type) - Description ``` -------------------------------- ### Generate function signature Source: https://hexdocs.pm/redbug/redbug_compiler.html Specifies the signature for the 'generate' function, which takes an 'ast' type and returns a 'tp' type. ```erlang -spec generate(ast()) -> tp(). ``` -------------------------------- ### stop(Target) Source: https://hexdocs.pm/redbug/redbug.html Stops a trace targeting a specific entity. ```APIDOC ## stop(Target) ### Description Stops a trace targeting a specific entity. ### Function Signature stop(Target) ``` -------------------------------- ### Define flags type Source: https://hexdocs.pm/redbug/redbug_compiler.html Defines the 'flags' type as a list. ```erlang -type flags() :: list(). ``` -------------------------------- ### Define ast type Source: https://hexdocs.pm/redbug/redbug_compiler.html Defines the 'ast' type as a tuple. ```erlang -type ast() :: tuple(). ``` -------------------------------- ### Compile function signature Source: https://hexdocs.pm/redbug/redbug_compiler.html Specifies the signature for the 'compile' function, which takes an atom, binary, or list and returns a 'tp' type. ```erlang -spec compile(atom() | binary() | list()) -> tp(). ``` -------------------------------- ### Define m_f_a type Source: https://hexdocs.pm/redbug/redbug_compiler.html Defines the 'm_f_a' type for module, function, and arguments. ```erlang -type m_f_a() :: {atom(), atom() | '_', integer() | '_'}. ``` -------------------------------- ### Scan function signature Source: https://hexdocs.pm/redbug/redbug_compiler.html Specifies the signature for the 'scan' function, which takes a string and returns 'tokens'. ```erlang -spec scan(string()) -> tokens(). ``` -------------------------------- ### Parse function signature Source: https://hexdocs.pm/redbug/redbug_compiler.html Specifies the signature for the 'parse' function, which takes a string and returns an 'ast' type. ```erlang -spec parse(string()) -> ast(). ``` -------------------------------- ### parse(Tokens) Source: https://hexdocs.pm/redbug/redbug_parser.html Parses a list of tokens and returns a result of type yecc_ret(). This function is used for parsing structured data. ```APIDOC ## parse(Tokens) ### Description Parses a list of tokens and returns a result of type yecc_ret(). This function is used for parsing structured data. ### Method N/A (Function Signature) ### Parameters #### Path Parameters N/A #### Query Parameters N/A #### Request Body N/A ### Request Example N/A ### Response #### Success Response - **return_value** (yecc_ret()) - The result of the parsing operation, which can be an error or an ok tuple. ``` -------------------------------- ### format_error(Message) Source: https://hexdocs.pm/redbug/redbug_parser.html Formats an error message for display. It takes any type of message and returns a list of characters or a list. ```APIDOC ## format_error(Message) ### Description Formats an error message for display. It takes any type of message and returns a list of characters or a list. ### Method N/A (Function Signature) ### Parameters #### Path Parameters N/A #### Query Parameters N/A #### Request Body N/A ### Request Example N/A ### Response #### Success Response - **return_value** (list() | [char()]) - The formatted error message. ``` -------------------------------- ### Define guard type Source: https://hexdocs.pm/redbug/redbug_compiler.html Defines the 'guard' type as a tuple or an underscore. ```erlang -type guard() :: tuple() | '_'. ``` -------------------------------- ### Define tp type Source: https://hexdocs.pm/redbug/redbug_compiler.html Defines the 'tp' type, likely representing a compiled code structure. ```erlang -type tp() :: {m_f_a(), [{args(), [guard()], actions()}], flags()}. ``` -------------------------------- ### Define tokens type Source: https://hexdocs.pm/redbug/redbug_compiler.html Defines the 'tokens' type for lexical analysis results. ```erlang -type tokens() :: [{atom(), integer(), term()} | {atom(), integer()}]. ``` -------------------------------- ### parse_and_scan Function Specification Source: https://hexdocs.pm/redbug/redbug_parser.html Specifies the type signature for the parse_and_scan function, which takes a specific tuple structure and returns a yecc_ret() type. ```erlang -spec parse_and_scan({function() | {atom(), atom()}, [_]} | {atom(), atom(), [_]}) -> yecc_ret(). ``` -------------------------------- ### parse Function Specification Source: https://hexdocs.pm/redbug/redbug_parser.html Specifies the type signature for the parse function, which accepts a list of tokens and returns a yecc_ret() type. ```erlang -spec parse(Tokens :: list()) -> yecc_ret(). ``` -------------------------------- ### yecc_ret Type Definition Source: https://hexdocs.pm/redbug/redbug_parser.html Defines the return type for parsing functions, indicating either an error or an OK result. ```erlang -type yecc_ret() :: {error, _} | {ok, _}. ``` -------------------------------- ### format_error Function Specification Source: https://hexdocs.pm/redbug/redbug_parser.html Specifies the type signature for the format_error function, which takes any type and returns a list of characters or a list. ```erlang -spec format_error(any()) -> [char() | list()]. ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.