Skip to content

Instantly share code, notes, and snippets.

@raypereda
Created May 18, 2012 20:13
Show Gist options
  • Save raypereda/2727379 to your computer and use it in GitHub Desktop.
Save raypereda/2727379 to your computer and use it in GitHub Desktop.
header file for debugging erlang
% -compile([debug_info, export_all]).
% -define (VALUE (Call), io:format ("~p:~p ~s = ~p~n", [?MODULE, ?LINE, ??Call, Call])).
@raypereda
Copy link
Author

Example usage of the value macro.

-module (foo).

-compile([debug_info, export_all]).
-define (VALUE (Call), io:format ("~p:~p ~s = ~p~n", [?MODULE, ?LINE, ??Call, Call])). 

test1() ->
  ?VALUE(value), 
  ?VALUE(length([1,2,3])),
  X = dict:new(),
  ?VALUE(X),
  X1 = dict:store("A", 1, X),
  ?VALUE(X1).

Here's the output

1> foo:test1().
foo:5 value = value
foo:6 length ( [ 1 , 2 , 3 ] ) = 3
foo:8 X = {dict,0,16,16,8,80,48,
                {[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[]},
                {{[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[]}}}
foo:10 X1 = {dict,1,16,16,8,80,48,
                  {[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[]},
                  {{[],[],[],[],[],[],[],[],[],[],[],[],[["A"|1]],[],[],[]}}}
ok

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment