Skip to content

Instantly share code, notes, and snippets.

@posilva
Created December 26, 2019 16:11
Show Gist options
  • Save posilva/b18a0d27f5c737db34d1a547d65a5bff to your computer and use it in GitHub Desktop.
Save posilva/b18a0d27f5c737db34d1a547d65a5bff to your computer and use it in GitHub Desktop.
DBG Erlang DNS Resolution
%% Check the default lookup resolution option
inet_db:res_option(lookup).
%% Set the lookup resolution option giving priority to the ERVM dns client
inet_db:set_lookup([dns, native]).
%% Setup DBG (DO NOT USE IT IN PRODUCTION) good to run in the local erl console
dbg:stop_clear(). % Stop in any case
dbg:start(). % start application
dbg:tracer(). % create tracer
dbg:p(all, c). % allow for all process
%% Trace a MFA only one supported at the time run from the top again to trace a new MFA(starting at dbg:stop_clear())
dbg:tpl(inet_db, add_rr, '_', []). % trace inet_db:add_rr function in any arity
% stop the tracer
dbg:stop_clear().
% Example
dbg:tpl(M, F, A, [{'_', [], [{return_trace}]}]).
% Other DNS examples
dbg:tpl(inet_db, do_add_rr, '_', []).
dbg:tpl(inet_db, add_rr, '_', []).
dbg:tpl(inet_db, res_cache_answer, '_', []).
dbg:tpl(inet_res, res_getby_query, '_', []).
dbg:tpl(inet_res, res_query, '_', []).
dbg:tpl(inet_db, res_hostent_by_domain, '_', []).
dbg:tpl(inet_db, cache_rr, '_', []).
inet:getaddr("dynamodb.us-west-2.amazonaws.com",inet).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment