Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
Simple wrapper around dbg?
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  6 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Attila Rajmund Nohl  
View profile  
 More options Nov 6 2012, 9:33 am
From: Attila Rajmund Nohl <attila.r.n...@gmail.com>
Date: Tue, 6 Nov 2012 15:33:20 +0100
Local: Tues, Nov 6 2012 9:33 am
Subject: [erlang-questions] Simple wrapper around dbg?
Hello!

I can trace a function call with specific arguments with a command like this:

dbg:tpl(foo, bar, dbg:fun2ms(fun([baz,_]) -> return_trace(),
exception_trace() end)).

However, it's a long to type, I'd like to have a wrapper around it.
The naive solution doesn't even compile:

-module(d).

-export([mfa/3]).

mfa(M, F, A) ->
    dbg:tpl(M, F, dbg:fun2ms(fun(Args) when Args==A -> return_trace(),
exception_trace() end)).

because there are no return_trace() and exception_trace() functions in
the module. Even if it'd compile, I couldn't call it like this:

d:mfa(foo, bar, [baz, _]).

because the _ variable is not bound. Is there a simple workaround or
shall I start to read up on parse_transforms?
_______________________________________________
erlang-questions mailing list
erlang-questi...@erlang.org
http://erlang.org/mailman/listinfo/erlang-questions


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Philip Clarke  
View profile  
 More options Nov 6 2012, 10:44 am
From: Philip Clarke <send2phi...@gmail.com>
Date: Tue, 6 Nov 2012 15:44:29 +0000
Local: Tues, Nov 6 2012 10:44 am
Subject: Re: [erlang-questions] Simple wrapper around dbg?

Hi Attila,

This might not be answering the exact question you are asking, but have you
tried using the built in trace patterns ?
They can save you a lot of typing.  The build in trace patterns are
documented in the dbg man page (under the tpl/0 function).

For example, you can use
dbg:tpl(foo, bar, x)

as an alias for
dbg:tpl(foo, bar, x, [{'_', [], [{exception_trace}]}]).

Best regards
Philip

On Tue, Nov 6, 2012 at 2:33 PM, Attila Rajmund Nohl <attila.r.n...@gmail.com

_______________________________________________
erlang-questions mailing list
erlang-questi...@erlang.org
http://erlang.org/mailman/listinfo/erlang-questions


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Kenneth Lundin  
View profile  
 More options Nov 6 2012, 12:27 pm
From: Kenneth Lundin <kenneth.lun...@gmail.com>
Date: Tue, 6 Nov 2012 18:27:22 +0100
Local: Tues, Nov 6 2012 12:27 pm
Subject: Re: [erlang-questions] Simple wrapper around dbg?

The parse transform is already written for you, see
http://www.erlang.org/documentation/doc-5.2/lib/stdlib-1.11.0/doc/htm...

/Kenneth , Erlang/OTP Ericsson
Den 6 nov 2012 15:33 skrev "Attila Rajmund Nohl" <attila.r.n...@gmail.com>:

_______________________________________________
erlang-questions mailing list
erlang-questi...@erlang.org
http://erlang.org/mailman/listinfo/erlang-questions


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Garrett Smith  
View profile  
 More options Nov 6 2012, 2:58 pm
From: Garrett Smith <g...@rre.tt>
Date: Tue, 6 Nov 2012 13:58:18 -0600
Local: Tues, Nov 6 2012 2:58 pm
Subject: Re: [erlang-questions] Simple wrapper around dbg?
On Tue, Nov 6, 2012 at 8:33 AM, Attila Rajmund Nohl

<attila.r.n...@gmail.com> wrote:
> Hello!

> I can trace a function call with specific arguments with a command like this:

> dbg:tpl(foo, bar, dbg:fun2ms(fun([baz,_]) -> return_trace(),
> exception_trace() end)).

> However, it's a long to type, I'd like to have a wrapper around it.

It's very limited, but for basic tracing (modules and functions with
sensible defaults) I use e2_debug:

https://github.com/gar1t/e2/blob/master/src/e2_debug.erl

Garrett
_______________________________________________
erlang-questions mailing list
erlang-questi...@erlang.org
http://erlang.org/mailman/listinfo/erlang-questions


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Dmitry Klionsky  
View profile  
 More options Nov 7 2012, 7:46 am
From: Dmitry Klionsky <dm.klion...@gmail.com>
Date: Wed, 07 Nov 2012 15:46:13 +0300
Local: Wed, Nov 7 2012 7:46 am
Subject: Re: [erlang-questions] Simple wrapper around dbg?
Hi!

have a look at there links:
http://www.snookles.com/erlang/user_default.erl
https://github.com/eproxus/erlang_user_utilities/blob/master/user_def...

On 11/06/2012 05:33 PM, Attila Rajmund Nohl wrote:

--
Best regards,
Dmitry Klionsky

_______________________________________________
erlang-questions mailing list
erlang-questi...@erlang.org
http://erlang.org/mailman/listinfo/erlang-questions


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Patrik Nyblom  
View profile  
 More options Nov 8 2012, 10:28 am
From: Patrik Nyblom <p...@erlang.org>
Date: Thu, 8 Nov 2012 16:28:24 +0100
Local: Thurs, Nov 8 2012 10:28 am
Subject: Re: [erlang-questions] Simple wrapper around dbg?

On 11/06/2012 03:33 PM, Attila Rajmund Nohl wrote:

As described in the docs (
http://www.erlang.org/doc/man/dbg.html#fun2ms-1), you'll need to include
ms_transform.hrl if calling dbg:fun2ms inside a module, so this:
---------------
-module(d).
-include_lib("stdlib/include/ms_transform.hrl").
-export([mfa/3]).

mfa(M, F, A) ->
     dbg:tpl(M, F, dbg:fun2ms(fun(Args) when Args==A -> return_trace(),
exception_trace() end)).
----------------
compiles and works to a certain extent.

> because there are no return_trace() and exception_trace() functions in
> the module. Even if it'd compile, I couldn't call it like this:

> d:mfa(foo, bar, [baz, _]).

This is more tricky, you cannot send unbound variables to a function -
it has little to do with dbg:fun2ms. Either you have to write your own
parse_transform, which cannot be used from the shell, or you could use
the match_spec syntax for the variables in the argument list and skip
fun2ms altogether...
Look at this in the shell:
1> dbg:fun2ms(fun([baz,A,_])  -> return__trace(),exception_trace() end).
[{[baz,'_'],[],[{return_trace},{exception_trace}]}]
The argument list is translated so that anonymous variables become the
atom '_' and named variables become '$n', where n is an integer > 0. You
can write your function as:

mfa(M, F, A) ->
     dbg:tpl(M, F, [{A,[],[{return_trace},{exception_trace}]}]).

and call it as:
d:mfa(foo,bar,[baz,'_']).

In that case you will not need the parse_transform.

BTW, you can remove return_trace, exception_trace includes return_trace.

Cheers,
/Patrik

_______________________________________________
erlang-questions mailing list
erlang-questi...@erlang.org
http://erlang.org/mailman/listinfo/erlang-questions


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »