PageRenderTime 302ms CodeModel.GetById 22ms RepoModel.GetById 1ms app.codeStats 0ms

/erlang_otp/_sources/lib/inviso-0.6/doc/html/inviso.txt

https://bitbucket.org/docs/docs.bitbucket.org
Plain Text | 1034 lines | 738 code | 296 blank | 0 comment | 0 complexity | 6a8993d9db1e01c73bc919fa7d1b223d MD5 | raw file
  1. ======================================
  2. Lib - Inviso-0.6 - Doc - Html - Inviso
  3. ======================================
  4. ` <http://www.ericsson.com/technology/opensource/erlang>`__
  5. inviso
  6. ======
  7. MODULE
  8. ~~~~~~
  9. inviso
  10. MODULE SUMMARY
  11. ~~~~~~~~~~~~~~
  12. Main API Module to the Inviso Tracer
  13. DESCRIPTION
  14. ~~~~~~~~~~~
  15. With the inviso API runtime components can be started and tracing
  16. managed across a network of distributed Erlang nodes, using a control
  17. component also started with inviso API functions.
  18. Inviso can be used both in a distributed environment and in a non-
  19. distributed. API functions not taking a list of nodes as argument
  20. works on all started runtime components. If it is the non-distributed
  21. case, that is the local runtime component. The API functions taking a
  22. list of nodes as argument, or as part of one of the arguments, can not
  23. be used in a non-distributed environment. Return values named
  24. NodeResult refers to return values from a single Erlang node, and will
  25. therefore be the return in the non-distributed environment.
  26. EXPORTS
  27. ~~~~~~~
  28. start() -> {ok,pid()} | {error,Reason}
  29. start(Options) -> {ok,pid()} | {error,Reason}
  30. Types:
  31. Options = [Option]
  32. Options may contain both options which will be default options to a
  33. runtime component when started, and options to the control component.
  34. See add_nodes/3 for details on runtime component options. The control
  35. component recognizes the following options:
  36. :{subscribe,Pid}: Making the process Pid receive Inviso events from
  37. the control component. Starts a control component process on the local
  38. node. A control component must be started before runtime components
  39. can be started manually or otherwise accessed through the inviso API.
  40. stop() -> shutdown
  41. Stops the control component. Runtime components are left as is. They
  42. will behave according to their dependency values.
  43. add_node(RTtag) -> NodeResult | {error,Reason}
  44. add_node(RTtag,Options) -> NodeResult | {error,Reason}
  45. Types:
  46. RTtag = PreviousRTtag = term()
  47. Options = [Option]
  48. Option -- see below
  49. Option = {dependency,Dep}
  50. Dep = int() | infinity
  51. The timeout, in milliseconds, before the runtime component will
  52. terminate if abandoned by this control component. Option =
  53. {overload,Overload} | overload
  54. Controls how and how often overload checks shall be performed. Just
  55. overloadspecifies that no loadcheck shall be performed. Overload =
  56. Interval | {LoadMF,Interval,InitMFA,RemoveMFA}
  57. LoadMF = {Mod,Func} | function()/1
  58. Interval = int() | infinity
  59. Interval is the time in milliseconds between overload checks.
  60. InitMFA = RemoveMFA = {Mod,Func,ArgList} | void
  61. When starting up the runtime component or when changing options (see
  62. change_options/2) the overload mechanism is initialized with a call to
  63. the InitMFAfunction. It shall return LoadCheckData. Every time a load
  64. check is performed, LoadMFis called with LoadCheckDataas its only
  65. argument. LoadMFshall return okor {suspend,Reason}. When the runtime
  66. component is stopped or made to change options involving changing
  67. overload-check, the RemoveMFAfunction is called. Its return value is
  68. discarded. NodeResult = {ok,NAns} | {error,Reason}
  69. NAns = new | {adopted,State,Status,PreviousRTtag} | already_added
  70. State = new | tracing | idle
  71. Status = running | {suspended,SReason}
  72. Starts or tries to connect to an existing runtime component at the
  73. local node, regardless if the system is distributed or not. Options
  74. will override any default options specified at start-up of the control
  75. component.
  76. The PreviousRTtag can indicate if the incarnation of the runtime
  77. component at the node in question was started by "us" and then can be
  78. expected to do tracing according to "our" instructions or not.
  79. add_node_if_ref(RTtag) -> NodeResult |
  80. {error,{wrong_reference,OtherTag}} | {error,Reason}
  81. add_node_if_ref(RTtag,Options) -> NodeResult |
  82. {error,{wrong_reference,OtherRef}} | {error,Reason}
  83. Types:
  84. OtherRef = term()
  85. rttag of the running incarnation
  86. As add_node/1,2 but will only adopt the runtime component if its rttag
  87. is RTtag.
  88. add_nodes(Nodes,RTtag) -> {ok,NodeResults} | {error,Reason}
  89. add_nodes(Nodes,RTtag,Options) -> {ok,NodeResults} | {error,Reason}
  90. Types:
  91. Nodes = [Node]
  92. NodeResults = [{Node,NodeResult}]
  93. As add_node/1,2 but for a distributed environment.
  94. add_nodes_if_ref(Nodes,RTtag) -> NodeResult | {error,Reason}
  95. add_nodes_if_ref(Nodes,RTtag,Options) -> NodeResult | {error,Reason}
  96. Types:
  97. Nodes = [Node]
  98. NodeResults = [{Node,NodeResult}]
  99. As add_node_if_ref/1,2 but for a distributed environment.
  100. stop_nodes() -> {ok,NodeResults} | NodeResult
  101. stop_nodes(Nodes) -> {ok,NodeResults} | {error,Reason}
  102. Types:
  103. NodeResults = [{Node,NodeResult}]
  104. NodeResult = ok | {error,Reason}
  105. Stops runtime component on Nodes. stop_nodes/0 will if the control
  106. component is running on a distributed node stop all runtime
  107. components. And if running on a non distributed node, stop the local
  108. and only runtime component.
  109. stop_all() = {ok,NodeResults} | NodeResult
  110. Types:
  111. NodeResults = [{Node,NodeResult}]
  112. NodeResult = ok | {error,Reason}
  113. A combination of stop/0 and stop_nodes/0.
  114. change_options(Options) -> NodeResult | {ok,NodeResults} |
  115. {error,Reason}
  116. change_options(Nodes,Options) -> {ok,NodeResults} | {error,Reason}
  117. Types:
  118. Nodes = [Node]
  119. NodeResults = [{Node,NodeResult}]
  120. NodeResult = ok | {error,Reason}
  121. Changes the options for one or several runtime components. If for
  122. instance overload is redefined, the previous overload will be stopped
  123. and the new started. See add_node/1 for details on Options.
  124. init_tracing(TracerData) -> {ok,NodeResults} | NodeResult |
  125. {error,Reason}
  126. init_tracing(TracerList) -> {ok,NodeResults} | {error,Reason}
  127. init_tracing(Nodes,TracerData) -> {ok,NodeResults} | {error,Reason}
  128. Types:
  129. TracerData = [{trace,LogTD} [,{ti,TiTD}] }] | LogTD
  130. LogTD = {HandlerFun,Data1} | collector | {relayer,CollectingNode} |
  131. {ip,IPPortParameters} | {file,FilePortParameters}
  132. TiTD = {file,FileName} | {file,FileName,TiSpec} | {relay,Node}
  133. TiSpec = {InitMFA,RemoveMF,CleanMF}
  134. InitMFA = {Mi,Fi,Argsi}
  135. RemoveMF = {Mr,Fr} | void
  136. CleanMF = {Mc,Fc}
  137. Mi = Fi = Mr = Fr = Mc = Fd = atom()
  138. Argsi = [term()]
  139. TracerList = [{Node,TracerData}]
  140. IPPortParameters = Portno | {Portno,Qsize}
  141. Portno = tcp_portno()
  142. Qsize = int()
  143. FilePortParameters = {Filename,wrap,Tail,{time,WrapTime},WrapCnt} |
  144. {FileName,wrap,Tail,WrapSize,WrapCnt} | {FileName,wrap,Tail,WrapSize}
  145. | {FileName,wrap,Tail} | FileName
  146. FileName = string()
  147. Tail = string() =/= ""
  148. WrapTime = WrapCnt = WrapSize = int() >0
  149. TracerList = [{Node,TracerData}]
  150. Nodes = [Node]
  151. HandlerFun = function()/2;
  152. HandlerFun(TraceMsg,Data1) -> NewData
  153. CollectingNode = pid() | node()
  154. NodeResults = [{Node,NodeResult}]
  155. NodeResult = {ok,LogResults} | {error,NReason}
  156. LogResults = [LogResult]
  157. LogResult = {trace_log,LogRes} | {ti_log,LogRes}
  158. LogRes = ok | {error,Reason}
  159. Starts the tracing at the specified nodes, meaning that the runtime
  160. components transits from the state new or idle to tracing. For trace
  161. messages to be generated, there must of course also be trace pattern
  162. and/or trace flags set. Such can not be set before tracing has been
  163. initiated with init_tracing/1,2.
  164. TracerData controls how the runtime component will handle generated
  165. trace messages. The trace tag controls how regular trace messages are
  166. handled. The ti tag controls if and how trace information will be
  167. stored and the meta tracer will be activated. That is if ti is
  168. omitted, no meta tracer will be started as part of the runtime
  169. component. It is possible to have ti without trace, but most likely
  170. not useful.
  171. The ip and file trace tracerdata instructions results in using the
  172. built in trace ip-port and file-port respectively. relayer will result
  173. in that all regular trace messages are forwarded to a runtime
  174. component at the specified node. Using a HandlerFun will result in
  175. that every incoming regular trace message is applied to the
  176. HandlerFun. collector can be used to use this runtime component to
  177. receive relayed trace messages and print them to the shell.
  178. The trace information can be configured to either write trace
  179. information to a plain trace information file or to relay it to
  180. another inviso meta tracer on another node. The inviso meta tracer is
  181. capable of matching function calls with their function returns (only
  182. if return_trace is activated in the meta trace match specification for
  183. the function in question). This is necessary since it may not be
  184. possible to decide what to do, if anything shall be done at all, until
  185. the return value of the function call is examined.
  186. To be able to match calls with returns a state can be saved when
  187. detecting a function call in a public loop data structure kept by the
  188. inviso meta tracer. The public loop data structure is given as
  189. argument to a handler-function called whenever a meta trace message
  190. arrives to the inviso meta tracer (both function calls and function
  191. returns). The public loop data structure is first initiated by the
  192. Mi:Fi function which takes the items in Argsi as arguments. Fi shall
  193. return the initial public loop data structure. When meta tracing is
  194. stopped, either because tracing is stopped or because tracing is
  195. suspended, the Mr:Fr(PublicLoopData) is called to offer a possibility
  196. to clean-up. Note that for every function meta-tracing is activated, a
  197. public loop data modification function can be speficied. That function
  198. will prepare the current loop data structure for this particular
  199. function.
  200. Further there is a risk that function call states becomes abandoned
  201. inside the public loop data structure. This will happen if a function
  202. call is entered into the public loop data structure, but no function
  203. return occurs. To prevent the public loop data structure from growing
  204. infinitely the clean function Fc will periodically be called with the
  205. public loop data structure as argument. Elements entered into the
  206. public loop data structure as a result of a function call must contain
  207. a timestamp for the Fc to be able to conclude if it is abandoned or
  208. not. Fc shall return a new public loop data structure.
  209. When initiating tracing involving trace information without a TiSpec,
  210. a default public loop data structure will be initiated to handle
  211. locally registered process aliases. The default public loop data
  212. structure is a two-tuple where the first element is used by the meta
  213. tracing on the BIF register/2. The second element is left for user
  214. usage.
  215. The default public loop data structure may be extended with more
  216. element positions. The first position must be left to the
  217. implementation of registered-name translations. If the public loop
  218. data structure is changed no longer meeting this requirement, the
  219. tpm_localnames/0,1 and tpm_globalnames/0,1 can no longer be used.
  220. A wrap files specification is used to limit the disk space consumed by
  221. the trace. The trace is written to a limited number of files each with
  222. a limited size. The actual filenames are Filename ++ SeqCnt ++ Tail,
  223. where SeqCnt counts as a decimal string from 0 to WrapCnt and then
  224. around again from 0. When a trace message written to the current file
  225. makes it longer than WrapSize, that file is closed, if the number of
  226. files in this wrap trace is as many as WrapCnt the oldest file is
  227. deleted then a new file is opened to become the current. Thus, when a
  228. wrap trace has been stopped, there are at most WrapCnt trace files
  229. saved with a size of at least WrapSize (but not much bigger), except
  230. for the last file that might even be empty. The default values are
  231. WrapSize == 128*1024 and WrapCnt == 8.
  232. The SeqCnt values in the filenames are all in the range 0 through
  233. WrapCnt with a gap in the circular sequence. The gap is needed to find
  234. the end of the trace.
  235. If the WrapSize is specified as {time,WrapTime}, the current file is
  236. closed when it has been open more than WrapTime milliseconds,
  237. regardless of it being empty or not.
  238. The ip trace driver has a queue of QSize messages waiting to be
  239. delivered. If the driver cannot deliver messages as fast as they are
  240. produced by the runtime system, they are dropped. The number of
  241. dropped messages are indicated in the trace log as separate trace
  242. message.
  243. stop_tracing(Nodes) -> {ok,NodeResults} | {error,Reason}
  244. stop_tracing() -> {ok,NodeResults} | NodeResult
  245. Types:
  246. Nodes = [Node]
  247. NodeResults = [{Node,NodeResult}]
  248. NodeResult = {ok,State} | {error,Reason}
  249. State = new | idle
  250. Stops tracing on all or specified Nodes. Flushes the trace buffer if a
  251. trace-port is used, closes the trace-port and removes all trace flags
  252. and meta-patterns. The nodes are called in parallel.
  253. Stopping tracing means going to state idle<c>. If the runtime
  254. component was already in state <c>new, it will of course remain in
  255. state new (then there was no tracing to stop).
  256. clear() -> {ok,NodeResults} | NodeResult
  257. clear(Nodes,Options) -> {ok,NodeResults} | {error,Reason}
  258. clear(Options) -> {ok,NodeResults} | NodeResult | {error,Reason}
  259. Types:
  260. Nodes = [Node]
  261. Options = [Option]
  262. Option = keep_trace_patterns | keep_log_files
  263. NodeResults = [{Node,NodeResult}]
  264. NodeResult = {ok,{new,Status}} | {error,Reason}
  265. Status = running | {suspended,SReason}
  266. Stops all tracing including removing meta-trace patterns. Removes all
  267. trace patterns. If the node is tracing or idle, trace-logs belonging
  268. to the current tracerdata are removed. Hence the node is returned to
  269. state new. Note that the node can still be suspended.
  270. Various options can make the node keep set trace patterns and log-
  271. files. The node still enters the new state.
  272. tp(Nodes,Mod,Func,Arity,MatchSpec,Opts) ->
  273. tp(Nodes,Mod,Func,Arity,MatchSpec) -> {ok,NodeResults} |
  274. {error,Reason}
  275. tp(Mod,Func,Arity,MatchSpec,Opts) ->
  276. tp(Mod,Func,Arity,MatchSpec) -> {ok,NodeResults} | NodeResult |
  277. {error,Reason}
  278. tp(Nodes,PatternList) -> {ok,NodeResults} | {error,Reason}
  279. tp(PatternList) -> {ok,NodeResults} | NodeResult | {error,Reason}
  280. Types:
  281. Nodes = [Node]
  282. Mod = Func = atom() | '_'
  283. Arity = int() | '_'
  284. MatchSpec = true | false | [] | matchspec()
  285. PatternList = [Pattern],
  286. Pattern = {Mod,Func,Arity,MatchSpec,Opts}
  287. Opts = [Opt]
  288. Opt = only_loaded
  289. NodeResults = [NodeResult]
  290. NodeResult = {ok,[Ans]} | {error,Reason}
  291. Ans = int() | {error,Reason}
  292. Set trace pattern (global) on specified or all nodes. The integer
  293. replied if the call was successfully describes the number of matched
  294. functions. The functions without a Nodes argument means all nodes, in
  295. a non-distributed environment it means the local node. Using wildcards
  296. follows the rules for wildcards of erlang:trace_pattern/3. It is for
  297. instance illegal to specify M == '_' while F is not '_'.
  298. When calling several nodes, the nodes are called in parallel.
  299. The option only_loaded will prevent modules not loaded (yet) into the
  300. runtime system to become loaded just as a result of that a trace
  301. pattern is requested to be set on it. Otherwise modules are
  302. automatically loaded if not already loaded (since the module must be
  303. present for a trace pattern to be set on it). The latter does not
  304. apply if the wildcard '_' is used as module specification.
  305. tpl(Nodes,Mod,Func,Arity,MatchSpec) ->
  306. tpl(Nodes,Mod,Func,Arity,MatchSpec,Opts) -> {ok,NodeResults} |
  307. {error,Reason}
  308. tpl(Mod,Func,Arity,MatchSpec) ->
  309. tpl(Mod,Func,Arity,MatchSpec,Opts) -> {ok,NodeResults} | NodeResult|
  310. {error,Reason}
  311. tpl(Nodes,PatternList) -> {ok,NodeResults} | {error,Reason}
  312. tpl(PatternList) -> {ok,NodeResults} | NodeResult | {error,Reason}
  313. See tp/N function above for details on arguments and return values.
  314. Set local trace pattern on specified functions. When calling several
  315. nodes, the nodes are called in parallel.
  316. ctp(Nodes,Mod,Func,Arity) -> {ok,NodeResults} | {error,Reason}
  317. ctp(Mod,Func,Arity) -> {ok,NodeResults} | NodeResult | {error,Reason}
  318. See tp/N for argument descriptions.
  319. Clear global trace patterns. When calling several nodes, the nodes are
  320. called in parallel.
  321. ctpl(Nodes,Mod,Func,Arity) -> {ok,NodeResults} | {error,Reason}
  322. ctpl(Mod,Funct,Arity) -> {ok,NodeResults} | NodeResult |
  323. {error,Reason}
  324. See tp/N for argument description.
  325. Clear local trace patterns. When calling several nodes, the nodes are
  326. called in parallel.
  327. tf(Nodes,PidSpec,FlagList) -> {ok,NodeResults} | {error,Reason}
  328. tf(PidSpec,FlagList) -> {ok,NodeResults} | NodeResult | {error,Reason}
  329. tf(Nodes,TraceConfList) -> {ok,NodeResults} | {error,Reason}
  330. tf(NodeTraceConfList) -> {ok,NodeResults} | {error,Reason}
  331. tf(TraceConfList) -> {ok,NodeResults} | NodeResult | {error,Reason}
  332. Types:
  333. Nodes = [Node]
  334. NodeTraceConfList = [{Node,TraceConfList}]
  335. TraceConfList = [{PidSpec,FlagList}]
  336. FlagList = [Flag]
  337. PidSpec = all | new| existing | pid() | locally_registered_name()
  338. Flag -- see erlang:trace/3
  339. NodeResult = {ok,[Ans]} | {error,Reason}
  340. Ans = int() | {error,Reason}
  341. Set process trace flags on processes on all or specified nodes. The
  342. integer returned if the call was successful describes the matched
  343. number of processes. The functions without a Nodes argument means all
  344. nodes, in a non-distributed environment it means the local node.
  345. There are many combinations which does not make much sense. For
  346. instance specifying a certain process identifier at all nodes. Or an
  347. empty TraceConfList for all nodes.
  348. When calling several nodes, the nodes are called in parallel.
  349. ctf(Nodes,PidSpec,FlagList) -> {ok,NodeResults} | {error,Reason}
  350. ctf(PidSpec,FlagList) -> {ok,NodeResults} | NodeResult |
  351. {error,Reason}
  352. ctf(Nodes,TraceConfList) -> {ok,NodeResults} | {error,Reason}
  353. ctf(TraceConfList) -> {ok,NodeResults} | NodeResult | {error,Reason}
  354. See tf/N for arguments and return value description.
  355. Clear process trace flags on all or specified nodes. When calling
  356. several nodes, the nodes are called in parallel.
  357. ctf_all(Nodes) -> {ok,NodeResults} | {error,Reason}
  358. ctf_all() -> {ok,NodeResults} | NodeResult | {error,Reason}
  359. Types:
  360. Nodes = [Node]
  361. NodeResults = [{Node,NodeResult}]
  362. NodeResult = ok | {error,Reason}
  363. Clears all trace flags on all or specified nodes. Just for
  364. convenience.
  365. init_tpm(Mod,Func,Arity,CallFunc) -> {ok,NodeResults} | NodeResult |
  366. {error,Reason}
  367. init_tpm(Nodes,Mod,Func,Arity,CallFunc) -> {ok,NodeResults} |
  368. {error,Reason}
  369. init_tpm(Mod,Func,Arity,InitFunc,CallFunc,ReturnFunc,RemoveFunc) ->
  370. {ok,NodeResults} | NodeResult | {error,Reason}
  371. init_tpm(Nodes,Mod,Func,Arity,
  372. InitFunc,CallFunc,ReturnFunc,RemoveFunc) -> {ok,NodeResults} |
  373. {error,Reason}
  374. Types:
  375. Mod = Func = atom()
  376. Arity = int()
  377. NodeResults = [{Node,NodeResult}]
  378. NodeResult = ok | {error,Reason}
  379. InitFunc,RemoveFunc = {Module,Function} | function()/4 | void
  380. CallFunc = ReturnFunc = {Module,Function} | function()/3 | void
  381. Initializes Mod:Func/Arity for meta tracing without setting any meta
  382. trace patterns. This is necessary if the named match specs will be
  383. used (see tpm_ms/5,6). Otherwise initialization of public loop data
  384. can be done at the same time as setting meta trace patterns using
  385. tpm/8,9.
  386. Note that we can not use wildcards here (even if it is perfectly legal
  387. in Erlang). It also sets the CallFunc and ReturnFunc for the meta
  388. traced function. That is the functions which will be called when a
  389. function call and a return_trace meta trace message respectively
  390. arrives to the inviso meta tracer for Mod:Func/Arity.
  391. This function is also available without InitFunc and RemoveFunc. That
  392. means that no initialization of the public loop data structure will be
  393. done and that CallFunc and ReturnFunc must either use already existing
  394. parts of public loop data structure or not use it at all.
  395. The InitFunc initializes the already existing public loop data
  396. structure for use with Mod:Func/Arity. InitFunc(Mod,Func,Arity,PublLD)
  397. -> {ok,NewPublLD,Output} where OutPut can be a binary which will then
  398. be written to the trace information file. If it is not a binary, no
  399. output will be done. RemoveFunc will be called when the meta tracing
  400. is cleared with ctpm/3,4. RemoveFunc(Mod,Func,Arity,PublLD) ->
  401. {ok,NewPublLD}.
  402. See tpm/N for details on CallFunc and ReturnFunc.
  403. tpm(Mod,Func,Arity,MS) -> {ok,NodeResults} | NodeResult |
  404. {error,Reason}
  405. tpm(Nodes,Mod,Func,Arity,MS) -> {ok,NodeResults} | {error,Reason}
  406. tpm(Mod,Func,Arity,MS,CallFunc) -> {ok,NodeResults} | NodeResults |
  407. {error,Reason}
  408. tpm(Nodes,Mod,Func,Arity,MS,CallFunc) -> {ok,NodeResults} |
  409. {error,Reason}
  410. tpm(Mod,Func,Arity,MS,InitFunc,CallFunc,ReturnFunc,RemoveFunc) ->
  411. {ok,NodeResults} | NodeResults | {error,Reason}
  412. tpm(Nodes,Mod,Func,Arity,MS, InitFunc,CallFunc,ReturnFunc,RemoveFunc)
  413. -> {ok,NodeResults} | {error,Reason}
  414. Types:
  415. Mod = Func = atom()
  416. Arity = int()
  417. MS = [match_spec()]
  418. Nodes = [Node]
  419. InitFunc = RemoveFunc = {Module,Function} | function()/4 | void
  420. CallFunc = ReturnFunc = {Module,Function} | function()/3 | void
  421. NodeResults = [{Node,NodeResult}]
  422. NodeResult = {ok,1} | {ok,0} | {error,Reason}1
  423. Activates meta-tracing in the inviso_rt_meta tracer. Except when using
  424. tpm/6, tpm/8 and tpm/9 the Mod:Func/Arity must first have been
  425. initiated using init_tpm/N. When calling several nodes, the nodes are
  426. called in parallel.
  427. CallFunc will be called every time a meta trace message arrives to the
  428. inviso meta tracer because of a call to Func.
  429. CallFunc(CallingPid,ActualArgList,PublLD) -> {ok,NewPrivLD,Output}
  430. where Output can be a binary or void. If it is a binary it will be
  431. written to the trace information file.
  432. ReturnFunc will be called every time a meta return_trace message
  433. arrives to the inviso meta tracer because of a return_trace of a call
  434. to Func. ReturnFunc(CallingPid,ReturnValue,PublLD) ->
  435. {ok,NewPrivLD,Output}. Further the ReturnFunc must handle the fact
  436. that a return_trace message arrives for a call which was never
  437. noticed. This because the message queue of the meta tracer may have
  438. been emptied.
  439. tpm_tracer(Mod,Func,Arity,MS) -> {ok,NodeResults} | NodeResult |
  440. {error,Reason}
  441. tpm_tracer(Nodes,Mod,Func,Arity,MS) -> {ok,NodeResults} |
  442. {error,Reason}
  443. tpm_tracer(Mod,Func,Arity,MS,CallFunc) -> {ok,NodeResults} |
  444. NodeResults | {error,Reason}
  445. tpm_tracer(Nodes,Mod,Func,Arity,MS,CallFunc) -> {ok,NodeResults} |
  446. {error,Reason}
  447. tpm_tracer(Mod,Func,Arity,MS,InitFunc,CallFunc,ReturnFunc,RemoveFunc)
  448. -> {ok,NodeResults} | NodeResults | {error,Reason}
  449. tpm_tracer(Nodes,Mod,Func,Arity,MS,
  450. InitFunc,CallFunc,ReturnFunc,RemoveFunc) -> {ok,NodeResults} |
  451. {error,Reason}
  452. See tpm/X for details on arguments and return values.
  453. Same as tpm/X but all match specs in MS containing a trace action term
  454. will have a {tracer,Tracer} appended to its enable-list. Tracer will
  455. be the current output for regular trace messages as specified when
  456. tracing was initiated. This function is useful when setting a meta
  457. trace pattern on a function with the intent that its execution shall
  458. turn tracing on for the process executing the match-spec in the meta
  459. trace pattern. The reason the tracer process trace flag can not be
  460. explicitly written in the action term by the user is that it may be
  461. difficult to learn its exact value for a remote node. Further more
  462. inviso functions are made to work on several nodes at the same time,
  463. requiering different match specs to be set for different nodes.
  464. Simple example: We want any process executing the function
  465. mymod:init(1234) (with the argument, exactly the integer 1234) to
  466. begin function-call tracing. In the example, if the process is found
  467. to be one that shall start call tracing, we also first disable all
  468. process trace flags to ensure that we have full control over what the
  469. process traces. void in the example specifies that the meta-tracer
  470. (inviso_rt_meta) will not call any function when meta trace messages
  471. for mymod:init/1 arrives. There is no need for a CallFunc since the
  472. side-effect (start call-tracing) is achieved immediately with the
  473. match-spec.
  474. .. sourcecode:: erlang
  475. inviso:tpm_tracer(mymod,init,1,[{[1234],[],[{trace,[all],[call]}]}],void).
  476. This will internally, by the meta tracer on each Erlang node, be
  477. translated to:
  478. .. sourcecode:: erlang
  479. erlang:trace_pattern({mymod,init,1},[{[1234],[],[{trace,[all],[call,{{tracer,T}}]}]}],[{meta,P}]).
  480. Where T is the tracer for regular trace messages (most often a trace-
  481. port, but can be the runtime component inviso_rt process), and P is
  482. the meta tracer (the inviso_rt_meta process).
  483. tpm_ms(Mod,Func,Arity,MSname,MS) -> {ok,NodeResults} | NodeResult |
  484. {error,Reason}
  485. tpm_ms(Nodes,Mod,Func,Arity,MSname,MS) -> {ok,NodeResults} |
  486. {error,Reason}
  487. Types:
  488. Nodes = [Node]<v> <v>Mod = Func = atom()<v> <v>Arity = int()<v>
  489. <v>MSname = term()<v> <v>MS = [match_spec()]<v> <v>NodeResults =
  490. [{Node,NodeResult}]<v> <v>NodeResult = {ok,1} | {ok,0} |
  491. {error,Reason}<v>
  492. This function adds a list of match-specs to the already existing ones.
  493. It uses an internal database to keep track of existing match-specs.
  494. This set of match specs can hereafter be referred to with the name
  495. MSname. If the match-spec does not result in any meta traced functions
  496. (for whatever reason), the MS is not saved in the database. The
  497. previously known match-specs are not removed. If MSname is already in
  498. use as a name refering to a set of match-specs for this particular
  499. meta-traced function, the previous set of match-specs are replaced
  500. with MS.
  501. Mod:Func/Arity must previously have been initiated in order for this
  502. function to add a match-spec.
  503. When calling several nodes, the nodes are called in parallel. {ok,1}
  504. indicates success.
  505. tpm_ms_tracer(Mod,Func,Arity,MSname,MS) -> {ok,NodeResults} |
  506. NodeResult | {error,Reason}
  507. tpm_ms_tracer(Nodes,Mod,Func,Arity,MSname,MS) -> {ok,NodeResults} |
  508. {error,Reason}
  509. See tpm_ms/X for details on arguments and return values, and
  510. tpm_tracer/X for explanations about the appending of {tracer,Tracer}
  511. process trace flag.
  512. ctpm_ms(Mod,Func,Arity,MSname) -> {ok,NodeResults} | NodeResult |
  513. {error,Reason}
  514. ctpm_ms(Nodes,Mod,Func,Arity,MSname) -> {ok,NodeResults} |
  515. {error,Reason}
  516. Types:
  517. NodeResults = [{Node,NodeResult}]
  518. NodeResult = ok | {error,Reason}
  519. Removes a named match-spec from the meta traced function. Note that it
  520. never is a fault to remove a match spec. Not even from a function
  521. which is non existent.
  522. When calling several nodes, the nodes are called in parallel.
  523. ctpm(Mod,Func,Arity) -> {ok,NodeResults} | NodeResult | {error,Reason}
  524. ctpm(Nodes,Mod,Func,Arity) -> {ok,NodeResults} | {error,Reason}
  525. Types:
  526. NodeResults = [{Node,NodeResult}]
  527. NodeResult = ok | {error,Reason}
  528. Removes the meta trace pattern for the function, means stops
  529. generating output for this function. The public loop data structure
  530. may be cleared by the previously entered RemoveFunc.
  531. When calling several nodes, the nodes are called in parallel.
  532. tpm_localnames() -> {ok,NodeResults} | NodeResult | {error,Reason}
  533. tpm_localnames(Nodes) -> {ok,NodeResults} | {error,Reason}
  534. Types:
  535. NodeResults = [{Node,NodeResult}]
  536. NodeResult = {R1,R2}
  537. R1 = R2 = {ok,0} | {ok,1} | {error,Reason}
  538. Quick version for setting meta-trace patterns on erlang:register/2. It
  539. uses a default CallFunc and ReturnFunc in the meta-tracer server. The
  540. main purpose of this function is to create ti-log entries for
  541. associations between pids and registered name aliases. The
  542. implementation uses return_trace to see if the registration was
  543. successful or not, before actually making the ti-log alias entry.
  544. Further the implementation also meta traces the BIF unregister/1.
  545. If both N1 and N2 is 1, function call was successful. N1 and N2
  546. represent setting meta trace pattern on register/2 and unregister/1.
  547. ctpm_localnames() -> {ok,NodeResults} | NodeResult | {error,Reason}
  548. ctpm_localnames(Nodes) -> {ok,NodeResults} | {error,Reason}
  549. Types:
  550. NodeResults = [{Node,NodeResult}]
  551. NodeResult = {R1,R2}
  552. R1 = R2 = ok | {error,Reason}
  553. Function for removing previously set patters by tpm_localnames/0. The
  554. two results R1 and R2 represents that meta pattern is removed from
  555. both register/2 and unregister/1.
  556. tpm_globalnames() -> {ok,NodeResults} | NodeResult | {error,Reason}
  557. tpm_globalnames(Nodes) -> {ok,NodeResults} | {error,Reason}
  558. Types:
  559. NodeResults = [{Node,NodeResult}]
  560. NodeResult = {R1,R2}
  561. R1 = R2 = {ok,0} | {ok,1} | {error,Reason}
  562. Quick version for setting meta-trace patterns capable of learning the
  563. association of a pid with a globally registered name (registered using
  564. global:register_name). The implementation meta-traces on
  565. global:handle_call({register,'_','_','_'},'_','_') and
  566. global:delete_global_name/2. The N1 and N2 represents the success of
  567. the two sub-tmp calls.
  568. ctpm_globalnames() -> {ok,NodeResults} | NodeResult | {error,Reason}
  569. ctpm_globalnames(Nodes) -> {ok,NodeResults} | {error,Reason}
  570. Types:
  571. NodeResults = [{Node,NodeResult}]
  572. NodeResult = {R1,R2} | {error,Reason}
  573. R1 = R2 = ok | {error,Reason}
  574. Function for removing previously set meta patters by
  575. tpm_globalnames/0,1. The two results R1 and R2 represents that meta
  576. pattern are removed from both global:handle_call/3 and
  577. global:delete_global_name/1.
  578. ctp_all() -> {ok,NodeResults} | NodeResult | {error,Reason}
  579. ctp_all(Nodes) -> {ok,NodeResults} | {error,Reason}
  580. Types:
  581. NodeResults = [{Node,NodeResult}]
  582. NodeResult = ok | {error,Reason}
  583. Clears all, both global and local trace patterns. Does not clear meta
  584. trace patterns. Equivalent to a call to ctp/3,4 and to ctpl/3,4 with
  585. wildcards '_' for all modules, functions and arities.
  586. suspend(SReason) -> {ok,NodeResults} | NodeResult | {error,Reason}
  587. suspend(Nodes,SReason) -> {ok,NodeResults} | {error,Reason}
  588. Types:
  589. SReason = term()
  590. NodeResults = [{Node,NodeResult}]
  591. NodeResult = ok | {error,Reason}
  592. Suspends the runtime components. SReason will become the suspend-
  593. reason replied in for instance a get_status/0,1 call. A runtime
  594. component that becomes suspended removes all trace flags and all meta
  595. trace patterns. In that way trace output is no longer generated. The
  596. task of reactivating a suspended runtime component is outside the
  597. scoop of inviso. It can for instance be implemented by a higher layer
  598. trace-tool "remembering" all trace flags and meta patterns set.
  599. cancel_suspension() -> {ok,NodeResults} | NodeResult | {error,Reason}
  600. cancel_suspend(Nodes) -> {ok,NodeResults} | {error,Reason}
  601. Types:
  602. NodeResults = [{Node,NodeResult}]
  603. NodeResult = ok | {error,Reason}
  604. Makes the runtime components running again (as opposite to suspended).
  605. Since reactivating previous trace flags and meta trace patterns is
  606. outside the scoop of inviso, cancelling suspension is simply making it
  607. possible to set trace flags and meta trace patterns again.
  608. get_status() -> {ok,NodeResults} | NodeResult | {error,Reason}
  609. get_status(Nodes) -> {ok,NodeResults} | {error,Reason}
  610. Types:
  611. NodeResults = [{Node,NodeResult}]
  612. NodeResult = {ok,{State,Status}} | {error,Reason}
  613. State = new | idle | tracing
  614. Status = running | {suspended,SReason}
  615. SReason = term()
  616. Finds out the state and status of a runtime component. A runtime
  617. component is in state new before it has been initiated to do any
  618. tracing the first time. There are clear-functions which can make a
  619. runtime component become new again without having to restart. A
  620. runtime component becomes idle after tracing is stopped.
  621. get_tracerdata() -> {ok,NodeResults} | NodeResult | {error,Reason}
  622. get_tracerdata(Nodes) -> {ok,NodeResults} | {error,Reason}
  623. Types:
  624. NodeResults = [{Node,NodeResult}]
  625. NodeResult = {ok,NResult} | {error,Reason}
  626. NResult = TracerData | no_tracerdata
  627. Returns the current tracerdata of a runtime component. A runtime
  628. component in state new can not have tracerdata. An idle runtime
  629. component does have tracerdata, the last active tracerdata. TracerData
  630. will be a term as specified to init_tracing when tracing was initiated
  631. for the runtime component.
  632. list_logs() -> {ok,NodeResults} | NodeResult | {error,Reason}
  633. list_logs(Nodes) -> {ok,NodeResults} | {error,Reason}
  634. list_logs(NodeTracerData) -> {ok,NodeResults} | {error,Reason}
  635. list_logs(TracerData) -> {ok,NodeResults} | NodeResult |
  636. {error,Reason}
  637. Types:
  638. TracerData -- see init_tracing/1,2
  639. NodeResults = [{Node,NodeResult}]
  640. NodeResult = {ok,FileList} | {ok,no_log} | {error,Reason}
  641. FileList = [FileType]
  642. FileType = {trace_log,Dir,Files} | {ti_log,Dir,Files}
  643. Files = [FileNameWithOutPath]
  644. Returns the actually existing log files associated with TracerData. If
  645. a tracerdata is not specified, current tracerdata is used for that
  646. particular runtime component. Files will be a list of one or more
  647. files should it be a wrap-set. Otherwise the it is a list of only one
  648. filename.
  649. This function is useful to learn the name and path of all files
  650. belonging to a trace. This information can later be used to move those
  651. files for merging. Note that since it is possible to ask on other
  652. tracerdata than the current, it is possible to learn filenames of
  653. previously done traces, under the circumstances that they have not
  654. been removed.
  655. fetch_log(LogSpecList,DestDir,Prefix) -> {ok,NodeResults} |
  656. {error,not_distributed} | {error,Reason}
  657. fetch_log(DestDir,Prefix) -> {ok,NodeResults} |
  658. {error,not_distributed} | {error,Reason}
  659. Types:
  660. DestDir = string()
  661. Prefix = string()
  662. LogSpecList = [LogSpec]
  663. LogSpec = {Node,FileSpecList} | Node | {Node,TracerData}
  664. TracerData = see init_tracing/1,/2
  665. FileSpecList = [{trace_log,Dir,FileList},{ti_log,Dir,FileList}] |
  666. [{trace_log,Dir,FileList}]
  667. FileList = [RemoteFileName]
  668. NodeResult = {Conclusion,ResultFileSpec} | no_log | {error,NReason}
  669. NReason = own_node | Reason
  670. Conclusion = complete | incomplete
  671. ResultFileSpec = [{trace_log,FileResults},{ti_log,FileResults}]
  672. FileResults = [FileResult]
  673. FileResult = {ok,FileName} | {error,FReason}
  674. FReason = {file_open,{posix(),FileName}} |
  675. {file_open,{posix(),RemoteFileName}} |
  676. {file_open,{posix(),[DestDir,Prefix,RemoteFileName]}} |
  677. {file_write,{posix(),FileName}} | {truncated,FileName} |
  678. {truncated,{Reason,FileName}}
  679. posix() = atom()
  680. Copies log files over distributed erlang to the control component
  681. node. This function can only be used in a distributed system.
  682. The resulting transferred files will have the prefix Prefix and will
  683. be located in DestDir. The source files can either be pointed out
  684. using a FileListSpec or tracerdata. If no files are explicitly
  685. specified, current tracerdata for that node will be used. Note that if
  686. source files have the same name (on several nodes) they will overwrite
  687. each other at DestDir.
  688. delete_log(Nodes,TracerData) -> {ok,NodeResults} | {error,Reason}
  689. delete_log(NodeSpecList) -> {ok,NodeResults} | {error,Reason}
  690. delete_log(Spec) -> {ok,NodeResults} | NodeResult | {error,Reason}
  691. delete_log(TracerData) -> {ok,NodeResults} | NodeResult |
  692. {error,Reason}
  693. delete_log() -> {ok,NodeResults} | NodeResult | {error,Reason}
  694. Types:
  695. Nodes = [Node]
  696. NodeSpecList = [{Node,Spec}]
  697. Spec = [AbsPathFileName] | LogSpecs
  698. LogSpecs = [LogSpec]
  699. LogSpec = {trace_log,Dir,[FileNameWithoutPath]} |
  700. {ti_log,Dir,[FileNameWithoutPath]}
  701. TracerData -- see init_tracing/1,/2
  702. NodeResults = [{Node,NodeResult}]
  703. NodeResult = {ok,no_log} | {ok,LogInfos} | {ok,FileInfos}
  704. LogInfos = [LogInfo]
  705. LogInfo = {trace_log,FileInfos} | {ti_log,FileInfos}
  706. FileInfos = [FileInfo]
  707. FileInfo = {ok,FileName} | {error,Reason}
  708. Deletes listed files or files corresponding to tracerdata. If no
  709. tracerdata or list of files are specified in the call, current
  710. tracerdata at the runtime components will be used to identify files to
  711. delete. All filenames shall be strings.
  712. FileName can either be an absolute path or just a filename depending
  713. on if AbsPathFileName or a LogSpec was used to identify the file.
  714. subscribe() -> ok | {error,Reason}
  715. subscribe(Pid) -> ok | {error,Reason}
  716. Types:
  717. Pid = pid()
  718. Adds Pid or self() if using subscribe/0 to the inviso-event sending
  719. list. Note that it is possible to add a pid several times and that the
  720. Pid then will receive multiple copies of inviso-event messages.
  721. All events will be sent to all subscribers in the event sending list.
  722. .. sourcecode:: erlang
  723. Event = {inviso_event,ControllerPid,erlang:localtime(),Msg}
  724. Msg = {connected, Node, {RTtag, {State,Status}}}
  725. | {disconnected, Node, NA}
  726. | {state_change,Node,{State,Status}}
  727. | {port_down,Node,Reason}
  728. Node = node() | local_runtime
  729. Subscribing to inviso-event may be necessary for a higher layer trace-
  730. tool using inviso to follow the runtime components. local_runtime will
  731. be used for a runtime component running in a non-distributed
  732. environment.
  733. unsubscribe() -> ok
  734. unsubscribe(Pid) -> ok
  735. Removes Pid (once) from the subscription list.
  736. inviso 0.6
  737. Copyright 1991-2009 `Ericsson AB
  738. <http://www.ericsson.com/technology/opensource/erlang>`__