代码不必用特殊的标记(比如debug_info)来编译,也可以trace.
erlang:trace是最底层的BIF实现的trace功能。格式如下
erlang:trace(PidSpec,How,FlagList)
它要通过erlang:trace_pattern(MFA,MatchSpec,FlagList)来辅助输出.
MatchSpec这东西很难写,在dbg模块中可以用dbg:fun2ms,它可以把函数转成MatchSpec.
比如:
dbg:fun2ms(fun(_) -> return_trace() end).
相当于
[{'_',[],[{return_trace}]}]
dbg:fun2ms(fun([M,N]) when N > 3 -> return_trace() end).
相当于
[{['$1','$2'],[{'>','$2',3}],[{return_trace}]}]
代码
- dbg:p(Item, Flags) -> {ok, MatchDesc} | {error, term()}
类型说明:
MatchDesc = [MatchNum]
MatchNum = {matched, node(), integer()} | {matched, node(), 0, RPCError}
RPCError = term()
Item
- 如果
Item
是一个 pid(), 对应的进程会被跟踪.此进程可能是一个远程进程(在另外的一个Erlang节点上). 这个节点必须在被跟踪节点列表中.
(见 n/1
and tracer/0/2/3
).
- 如果
Item
是一个all
原子, 系统的所有进程和以后建的进程都会被跟踪.它同样对通过n/1
or tracer/0/2/3
函数加入的节点有效.
- 如果
Item是一个
new
原子,则现存的进程不受影响, 而后建立的进程则会被跟踪. 它同样对通过n/1
or tracer/0/2/3
函数加入的节点有效.
- 如果
Item是一个
existing
原子,对现存的进程有效,对后来建立的进程无效.它同样对通过n/1
or tracer/0/2/3
函数加入的节点有效.
- 如果
Item
既不是all
, new
,也不是existing原子
, 则注册了此名称的进程会被跟踪.此进程可能是一个远程进程(在另外的一个Erlang节点上). 这个节点必须在被跟踪节点列表中.
(见 n/1
and tracer/0/2/3
).
- 如果
Item
是一整数,则进程 <item.1></item.1>
被跟踪
- 如果
Item
是一个元组{X, Y, Z}
, 则进程 <x.y.z></x.y.z>
被跟踪
Flags
可以是一个原子,也可以是flags列表.
s (send)
跟踪进程发送的消息
r (receive)
跟踪进程接收的消息 m (messages)
跟踪进程接收和发送的消息 c (call)
依照系统定义的跟踪模式,来跟踪此进程关于全局函数的调用情况(见 tp/2). p (procs)
跟踪与此进程相关的事件
sos (set on spawn)
让所有由当前被跟踪进程所创建的子进程,都继承其flags.
sol (set on link)
每当被跟踪进程链至P2
时, 让P2继承其flags
sofs (set on first spawn)
和sos
相同,但只有第一个子进程会继承. sofl (set on first link)
和sol
相同,但只会在第一次调用link/1
时跟踪
all
所有flags都设上
clear
清除所有flags
erts 的Match Specification in Erlang这章详细说明了MatchSpec
to be continued...
分享到:
相关推荐
Chrome Tracing 打开 about:tracing 页面,Chrome 提供的底层的追踪工具允许我们深度了解 V8 的解析以及其他时间消耗情况。V8 也提供了 详细的指南 来介绍如何使用这个功能。
opentracing-api
赠送jar包:opentracing-api-0.33.0.jar 赠送原API文档:opentracing-api-0.33.0-javadoc.jar 赠送源代码:opentracing-api-0.33.0-...人性化翻译,文档中的代码和结构保持不变,注释和说明精准翻译,请放心使用。
赠送jar包:opentracing-util-0.33.0.jar; 赠送原API文档:opentracing-util-0.33.0-javadoc.jar;...人性化翻译,文档中的代码和结构保持不变,注释和说明精准翻译,请放心使用。 双语对照,边学技术、边学英语。
Peter Shirley Ray Tracing合集(包含Ray Tracing in One Weekend, Ray Tracing the Next Week, Ray Tracing The Rest of Your Life, Realistic Ray Tracing)
赠送jar包:opentracing-util-0.33.0.jar 赠送原API文档:opentracing-util-0.33.0-javadoc.jar 赠送源代码:opentracing-util-0.33.0-...人性化翻译,文档中的代码和结构保持不变,注释和说明精准翻译,请放心使用。
介绍了光线追踪(ray tracing)算法的基本原理及一些使用方法
Distribution ray tracing uses Monte Carlo integration to solve the rendering equation. This technique was introduced by Cook et. al, and was notable because of its simplicity and its ability to ...
赠送jar包:opentracing-api-0.33.0.jar; 赠送原API文档:opentracing-api-0.33.0-javadoc.jar;...人性化翻译,文档中的代码和结构保持不变,注释和说明精准翻译,请放心使用。 双语对照,边学技术、边学英语。
Ray Tracing in One Weekend, Ray Tracing The Next Week, Ray Tracing The Rest of Your Life 三本关于射线追踪的资料,简单易懂,容易上手。并附有源程序
An Introduction to Ray Tracing
English Tracing Book
DTrace is a comprehensive dynamic tracing framework for the illumos™ Operating System. DTrace provides a powerful infrastructure to permit administrators, developers, and service personnel to ...
Ray Tracing from the Ground Up 光跟踪算法技术 (英文版) Kevin Suffern 好书一枚,非常详实的讲解了一个ray tracer怎么写,从原理到实践,对应网站上面还提供了完整的立即可编译运行的代码。 part1: ...
An-Introduction-to-Ray-Tracing-The-Morgan-Kaufmann-Series-in-Computer-Graphics-.pdf
Mastering Distributed Tracing
Ray Tracing_ the Rest of Your Life 是继作者写完了 Ray Tracing in a weekend 之后的第三部作品
CG 入门 ray tracing in a week 和 ray tracing it the next week 完整英文版
Ray Tracing_ The Next Week.pdf