dbg match spec

Ulf Wiger (AL/EAB) <>
Mon Oct 3 14:23:58 CEST 2005


Aargh! That's what the problem was!

This single statement from the ERTS match spec guide:

"In ETS the match head is a tuple() (or a single 
match variable) while it is a list (or a single 
match variable) when tracing."

Having used match specifications mostly for ets,
I forgot about this little detail. 
It's not exactly intuitively obvious...  (:

/Uffe

> -----Original Message-----
> From: 
> [mailto:]On Behalf Of Siri 
> Hansen (EAB)
> Sent: den 3 oktober 2005 13:20
> To: chandru; 
> Subject: Re: dbg match spec
> 
> 
> Hi Chandru - Hope you are well!!
> 
> I'm sending from an address which is not member of the erlang list, so
> this might not come out on the list - but anyway...
> 
> You could try
> 
> 
> dbg:tpl(dbg_test, test, 1, [{[{'A','_','_'}],[],[]}]).
> 
> or
> 
> dbg:tpl(dbg_test, test, 1, 
> [{['$1'],[{'==',{element,1,'$1'},'A'}],[]}]).
> 
> 
> (But what is the 'call' command you put in the match spec body?)
> 
> BR
> /siri
> 
> 
> 
> chandru wrote:
> > Hi,
> > 
> > If I had code like this:
> > 
> > -module(dbg_test).
> > -export([test/1]).
> > 
> > test(N) when integer(N) ->
> >     io:format("Integer -> ~p~n", [N]);
> > test({'A', X, Y}) ->
> >     io:format("A: X -> ~p, Y -> ~p~n", [X,Y]);
> > test(L) ->
> >     io:format("L -> ~p~n", [L]).
> > 
> > how would I write a dbg command to print out a trace when the second
> > clause is matched?
> > 
> > I've tried: 	
> > 
> > dbg:tpl(dbg_test, test, 1, 
> [{'$1',[{'==',{element,1,'$$'},'A'}],[call]}]).
> > 
> > but it doesn't work. whereas this does:
> > 
> > dbg:tpl(dbg_test, test, 1, [{'_',[],[call]}]).
> > 
> > but it is not quite what I want...I want to single out the 
> second clause.
> > 
> > cheers
> > Chandru
> 



More information about the erlang-questions mailing list