[Erlang31]Erlang trace总结
.特定进程集内的函数调用输入输出,收发消息------trace 指定Processes{module,function,arity};
.特定端口集的输入输出,收发消息---------------trace 指定ports。
• sys comes standard with OTP and allows to set custom tracing functions, log all kinds of events, and so on. It’s generally complete and fine to use for development. It suffers a bit in production because it doesn’t redirect IO to remote shells, and doesn’t have rate-limiting capabilities for trace messages. It is still recommended to read the documentationfor the module.• dbg also comes standard with Erlang/OTP. Its interface is a bit clunky in terms of usability, but it’s entirely good enough to do what you need. The problem with it is that you have to know what you’re doing, because dbg can log absolutely everything on the node and kill one in under two seconds.• tracing BIFs are available as part of the erlang module. They’re mostly the raw blocks used by all the applications mentioned in this list, but their lower level of abstraction makes them rather difficult to use.• redbug is a production-safe tracing library, part of the eper 5 suite. It has an internal rate-limiter, and a nice usable interface. To use it, you must however be willing to add in all of eper’s dependencies. The toolkit is fairly comprehensive and can be a very interesting install.• recon_trace is recon’s take on tracing. The objective was to allow the same levels of safety as with redbug, but without the dependencies. The interface is different, and the rate-limiting options aren’t entirely identical. It can also only trace function calls, and not messages.
. 指定trace的进程集;
. 指定模块中指定的函数的指定入参。
%%% _,--------,_ _,--------,_
%%% ,-' `-,,-' `-,
%%% ,-' ,-' '-, `-,
%%% | Matching -' '- Matching |
%%% | Pids | Getting | Trace |
%%% | | Traced | Patterns |
%%% | -, ,- |
%%% '-, '-, ,-' ,-'
%%% '-,_ _,-''-,_ _,-'
%%% '--------' '--------'
%%%
1.先从指定模块,函数,和参数开始:
> dbg:start(). % start dbg
> dbg:tracer(). % start a simple tracer process
> dbg:tp(Module, Function, Arity, []). % specify MFA you are interested in
> dbg:p(all, c). % trace calls (c) of that MFA for all processes. ... trace here > dbg:stop_clear(). % stop tracer and clear effect of tp and p calls.
> dbg:tpl(Module, '_', []). % all calls in Module
> dbg:tpl(Module, Function, '_', []). % all calls to Module:Function with any arity.
> dbg:tpl(Module, Function, Arity, []). % all calls to Module:Function/Arity.
> dbg:tpl(M, F, A, [{'_', [], [{return_trace}]}]). % same as before, but also show return value.
1> dbg:fun2ms(fun([M,N]) when N > 3 -> return_trace() end).
[{['$1','$2'],[{'>','$2',3}],[{return_trace}]}]
> dbg:p(all, c). % trace calls to selected functions by all functions
> dbg:p(new, c). % trace calls by processes spawned from now on
> dbg:p(Pid, c). % trace calls by given process
> dbg:p(Pid, [c, m]). % trace calls and messages of a given process
>dbg:tracer(port,dbg:trace_port(file,{"/log/trace",wrap,atom_to_list(node())})).
1.接口太过复杂,使用步骤复杂:start----》自定义的trace-----》stop;
2.没有输出日志次数控制,在生产环境中使用不当时会导致异常:不安全!
1.接口使用简单,他只需要调用一个函数calls/2 calls/3就可以trace;
2. 有次数限制和速度限制;
3.输出的trace比的默认的trace易读性强。
参考资料

[Erlang31]Erlang trace总结的更多相关文章
- Erlang Trace机制
从FTP模块学习先进的诊断技术(Erlang Trace机制) http://blog.yufeng.info/archives/466
- erlang调试技术之etop
etop是erlang进程信息查看工具,类似于UNIX的top. 一.配置参数 node The measured node. Value: atom() Mandatory setcookie Co ...
- Erlang 不同版本内容
OTP 22.0 Erlang/OTP 22是一个新的主要版本,具有新的特性和改进,同时也具有不兼容性. 要更深入地了解OTP 22发行版的亮点,您可以阅读我们的博客: http://blog.erl ...
- [Erlang 0119] Erlang OTP 源码阅读指引
上周Erlang讨论群里面提到lists的++实现,争论大多基于猜测,其实打开代码看一下就都明了.贴出代码截图后有同学问这代码是哪里找的? "代码去哪里找?",关于Erla ...
- erlang 故障排查工具
系统级别perf top, dstat -tam, vtune 都能很好分析beam 瓶颈,本文主要erlang 级别排查: 1. 反编译 确认线上运行代码是否正确,reltools没掌握好,升级偶尔 ...
- erlang note
没有关于erlang interface ,继续寻找吧... --------------------------------------------------------------- erl - ...
- 为什么Erlang比C慢那么多倍?
Erlang 一直以慢“著称”,本文就来看看 Erlang 慢在什么地方,为什么比实现同样功能的 C 语言程序慢那么多倍.Erlang 作为一种虚拟机解释的语言,慢是当然的.不过本文从细节上分析为什么 ...
- Erlang generic standard behaviours -- gen_server module
在分析完gen module (http://www.cnblogs.com/--00/p/4271386.html)之后,就可以开始进入gen_server 的主体module 了.gen_serv ...
- Erlang generic standard behaviours -- gen
在分析 gen_server (或者是gen_fsm )之前,首先应该弄明白,gen 这个module . -module(gen). -compile({inline,[get_node/1]}). ...
随机推荐
- hive基本结构与数据存储
一.Hive简介 Hive是基于Hadoop的一个数据仓库工具,可以将结构化的数据文件映射为一张数据库表,并提供类SQL查询功能.还可以将 SQL 语句转换为 MapReduce 任务进行运行,通过自 ...
- 全虚拟化和半虚拟化的区别 cpu的ring0~ring3又是什么概念?
ring0是指CPU的运行级别,ring0是最高级别,ring1次之,ring2更次之-- 拿Linux+x86来说, 操作系统(内核)的代码运行在最高运行级别ring0上,可以使用特权指令,控制中断 ...
- #用openfiledialog文件和savefileDialog打开和保存文件
一.打开文件 Stream myStream = null; OpenFileDialog openFileDialog1 = new OpenFileDialog(); ...
- DBNavigator中把insert变为append
procedure TForm1.DBNavigator1Click(Sender: TObject; Button: TNavigateBtn);begin if Button = nbIns ...
- X264编码流程详解(转)
http://blog.csdn.net/xingyu19871124/article/details/7671634 对H.264编码标准一直停留在理解原理的基础上,对于一个实际投入使用的编码器是如 ...
- 从LinqPad入门Linq
为什么要学习Linq? 在我们日常开发中,经常需要从数据库中执行各式各样的查询来获取需要的数据.但是如果需要对查询获得的数据进行二次筛选呢?linq就提供了对于可枚举类型(实现IEnumerable接 ...
- Spring的属性文件properties使用注意
Spring的属性文件properties使用注意 Spring 中属性文件的配置 通常我们会使用properties文件来设置一些属性,如数据库连接信息,避免进行硬编码, <bean clas ...
- Redis 集群二
[Redis 集群二] 集群的客户端 Redis 集群现阶段的一个问题是客户端实现很少. 以下是一些我知道的实现: redis-rb-cluster 是我(@antirez)编写的 Ruby 实现, ...
- Grapher
[Grapher] You use Grapher to visualize and analyze implicit and explicit equations. You can graph eq ...
- linux 安装php7 Nginx
这里 记录下 本屌安装linux 下安装php7 即遇到的问题. wget http://cn2.php.NET/distributions/php-7.0.4.tar.gz tar zxvf ph ...