tttrace.sgm 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488
  1. <!-- $XConsortium: tttrace.sgm /main/11 1996/10/30 16:33:07 rws $ -->
  2. <!-- (c) Copyright 1995 Digital Equipment Corporation. -->
  3. <!-- (c) Copyright 1995 Hewlett-Packard Company. -->
  4. <!-- (c) Copyright 1995 International Business Machines Corp. -->
  5. <!-- (c) Copyright 1995 Sun Microsystems, Inc. -->
  6. <!-- (c) Copyright 1995 Novell, Inc. -->
  7. <!-- (c) Copyright 1995 FUJITSU LIMITED. -->
  8. <!-- (c) Copyright 1995 Hitachi. -->
  9. <RefEntry Id="CDEMX.MAN38.rsml.1" Remap="">
  10. <RefMeta>
  11. <RefEntryTitle>tttrace</RefEntryTitle>
  12. <ManVolNum>user cmd</ManVolNum>
  13. </RefMeta>
  14. <RefNameDiv>
  15. <RefName><Command>tttrace</Command></RefName>
  16. <RefPurpose>trace ToolTalk calls and messages
  17. </RefPurpose>
  18. </RefNameDiv>
  19. <!-- $XConsortium: tttrace.sgm /main/11 1996/10/30 16:33:07 rws $-->
  20. <!-- (c) Copyright 1993, 1994 Sun Microsystems, Inc.-->
  21. <!-- (c) Copyright 1993, 1994 Hewlett-Packard Company-->
  22. <!-- (c) Copyright 1993, 1994 International Business Machines Corp.-->
  23. <!-- (c) Copyright 1993, 1994 Novell, Inc.-->
  24. <RefSynopsisDiv>
  25. <CmdSynopsis>
  26. <Command>tttrace</Command>
  27. <Arg Choice="opt">-0FCa</Arg>
  28. <Arg Choice="opt">-o<Replaceable>outfile</Replaceable></Arg>
  29. <Group>
  30. <Arg>-S<Replaceable>session</Replaceable></Arg>
  31. <Arg><Replaceable>command</Replaceable></Arg>
  32. </Group>
  33. </CmdSynopsis>
  34. <CmdSynopsis>
  35. <Command>tttrace</Command>
  36. <Group>
  37. <Arg>-e<Replaceable>script</Replaceable></Arg>
  38. <Arg>-f<Replaceable>scriptfile</Replaceable></Arg>
  39. </Group>
  40. <Group>
  41. <Arg>-S<Replaceable>session</Replaceable></Arg>
  42. <Arg><Replaceable>command</Replaceable></Arg>
  43. </Group>
  44. </CmdSynopsis>
  45. </RefSynopsisDiv>
  46. <RefSect1>
  47. <Title>DESCRIPTION</Title>
  48. <Para><Command>tttrace</Command> traces message traffic through the server for the indicated ToolTalk
  49. <Emphasis>session</Emphasis>, or runs
  50. <Symbol Role="Variable">command</Symbol> with ToolTalk client tracing turned on. If neither
  51. <Emphasis>session</Emphasis> nor
  52. <Symbol Role="Variable">command</Symbol> is given, the default session is traced. By default, tracing
  53. terminates when
  54. <Command>tttrace</Command> exits.
  55. </Para>
  56. <Para>Tracing of ToolTalk functions looks like this:
  57. [<Emphasis>pid</Emphasis>] <Symbol Role="Variable">function_name</Symbol>(<Symbol Role="Variable">params</Symbol>) = <Emphasis>return_value</Emphasis> (<StructName Role="typedef">Tt_status</StructName>)
  58. </Para>
  59. <Para>With the
  60. <Literal>-a</Literal> option, message attributes are printed after a one-line summary
  61. of the message:
  62. <Emphasis>Tt_state Tt_paradigm Tt_class</Emphasis> (<StructName Role="typedef">Tt_disposition</StructName> in <StructName Role="typedef">Tt_scope</StructName>): <Symbol Role="Variable">status</Symbol> == <StructName Role="typedef">Tt_status</StructName>
  63. </Para>
  64. <Para>State changes are indicated by:
  65. <Emphasis>old_state</Emphasis> => <Emphasis>new_state</Emphasis>.
  66. </Para>
  67. <Para>Deliveries are indicated by:
  68. Tt_message => procid &lt;<Emphasis>recipient_procid</Emphasis>>
  69. </Para>
  70. <Para>When dispatching is being traced, the reason for each dispatch
  71. is one of:
  72. </Para>
  73. <Para><Symbol>tt_message_send</Symbol>()</Para>
  74. <Para><Symbol>tt_message_reject</Symbol>()</Para>
  75. <Para><Symbol>tt_message_fail</Symbol>()</Para>
  76. <Para><Symbol>tt_message_reply</Symbol>()</Para>
  77. <Para><Symbol>tt_session_join</Symbol>()</Para>
  78. <Para><Symbol>tt_file_join</Symbol>()</Para>
  79. <VariableList>
  80. <VarListEntry>
  81. <Term>tt_message_reply ()</Term>
  82. <ListItem>
  83. <!-- ex-TP-->
  84. <Para>A client called the indicated function.
  85. </Para>
  86. </ListItem>
  87. </VarListEntry>
  88. <VarListEntry>
  89. <Term>tt_message_send_on_exit ()</Term>
  90. <ListItem>
  91. <!-- ex-TP-->
  92. <Para><Command>ttsession</Command> is dispatching on_exit messages for a client that
  93. disconnected before calling
  94. <Symbol>tt_close</Symbol>().</Para>
  95. </ListItem>
  96. </VarListEntry>
  97. <VarListEntry>
  98. <Term>tt_message_accept ()</Term>
  99. <ListItem>
  100. <!-- ex-TP-->
  101. <Para><Command>ttsession</Command> is dispatching messages that had been blocked while
  102. a ptype was being started. The started client has now called
  103. either
  104. <Symbol>tt_message_accept</Symbol>() or
  105. <Symbol>tt_message_reply</Symbol>() to indicate that the ptype should be unblocked.
  106. </Para>
  107. </ListItem>
  108. </VarListEntry>
  109. <VarListEntry>
  110. <Term>TT_ERR_PTYPE_START</Term>
  111. <ListItem>
  112. <!-- ex-TP-->
  113. <Para>A ptype instance was started to receive the message, but the
  114. start command exited before it connected to
  115. <Command>ttsession</Command>.</Para>
  116. </ListItem>
  117. </VarListEntry>
  118. <VarListEntry>
  119. <Term>TT_ERR_PROCID</Term>
  120. <ListItem>
  121. <!-- ex-TP-->
  122. <Para><Command>ttsession</Command> lost its connection to the client that was working on this request.
  123. </Para>
  124. </ListItem>
  125. </VarListEntry>
  126. <VarListEntry>
  127. <Term>ttsession -> ttsession</Term>
  128. <ListItem>
  129. <!-- ex-TP-->
  130. <Para>Another session wants this session to find recipients for the message.
  131. </Para>
  132. </ListItem>
  133. </VarListEntry>
  134. <VarListEntry>
  135. <Term>ttsession &lt;- ttsession</Term>
  136. <ListItem>
  137. <!-- ex-TP-->
  138. <Para>Another session wants to update (e.g. fail) a message originating in this
  139. session.
  140. </Para>
  141. <Para>When dispatching is being traced, matching is indicated by one of
  142. Tt_message &amp; Tt_pattern {
  143. Tt_message &amp; ptype <Emphasis>ptid</Emphasis> {
  144. Tt_message &amp; otype <Emphasis>otid</Emphasis> {
  145. </Para>
  146. <Para>The pattern or signature is printed, followed by
  147. } == <Emphasis>match_score</Emphasis>; [/* <Emphasis>mismatch_reason</Emphasis> */]
  148. </Para>
  149. </ListItem>
  150. </VarListEntry>
  151. </VariableList>
  152. </RefSect1>
  153. <RefSect1>
  154. <Title>OPTIONS</Title>
  155. <VariableList>
  156. <VarListEntry>
  157. <Term>-0</Term>
  158. <ListItem>
  159. <!-- ex-TP-->
  160. <Para>Turn off message tracing in
  161. <Emphasis>session</Emphasis>, or run
  162. <Symbol Role="Variable">command</Symbol> without message tracing (i.e., with only call tracing).
  163. </Para>
  164. </ListItem>
  165. </VarListEntry>
  166. <VarListEntry>
  167. <Term>-F</Term>
  168. <ListItem>
  169. <!-- ex-TP-->
  170. <Para>Follow all children forked by
  171. <Symbol Role="Variable">command</Symbol> or subsequently started in
  172. <Emphasis>session</Emphasis> by
  173. <Command>ttsession</Command>. Normally, only the indicated
  174. <Symbol Role="Variable">command</Symbol> or
  175. <Command>ttsession</Command> instance is traced. When
  176. <Literal>-F</Literal> is specified, the process id is included with each line of trace
  177. output to indicate which process generated it.
  178. </Para>
  179. </ListItem>
  180. </VarListEntry>
  181. <VarListEntry>
  182. <Term>-C</Term>
  183. <ListItem>
  184. <!-- ex-TP-->
  185. <Para>Do not trace client calls into the ToolTalk API. Default is
  186. to trace them.
  187. </Para>
  188. </ListItem>
  189. </VarListEntry>
  190. <VarListEntry>
  191. <Term>-a</Term>
  192. <ListItem>
  193. <!-- ex-TP-->
  194. <Para>Print all attributes, arguments, and context slots of traced messages.
  195. The default is to use only a single line when printing a message on
  196. the trace output.
  197. </Para>
  198. </ListItem>
  199. </VarListEntry>
  200. <VarListEntry>
  201. <Term>-e script</Term>
  202. <ListItem>
  203. <!-- ex-TP-->
  204. <Para>Take
  205. <Emphasis>script</Emphasis> as a
  206. <Command>tttrace</Command> setting. See
  207. &cdeman.tttracefile;.</Para>
  208. </ListItem>
  209. </VarListEntry>
  210. <VarListEntry>
  211. <Term>-f scriptfile</Term>
  212. <ListItem>
  213. <!-- ex-TP-->
  214. <Para>File to read
  215. <Command>tttrace</Command> settings from. See
  216. &cdeman.tttracefile;. <Literal>-f</Literal> <Literal>-</Literal> causes
  217. <Command>tttrace</Command> to read standard input until EOF, which may prevent
  218. <Symbol Role="Variable">command</Symbol> from using standard input.
  219. </Para>
  220. </ListItem>
  221. </VarListEntry>
  222. <VarListEntry>
  223. <Term>-o outfile</Term>
  224. <ListItem>
  225. <!-- ex-TP-->
  226. <Para>File to be used for the trace output.
  227. </Para>
  228. <Para>For session tracing, output goes to standard output of
  229. <Command>tttrace</Command>.</Para>
  230. <Para>For client tracing, output goes by default to standard error of
  231. <Command>tttrace</Command>. For client tracing,
  232. <Literal>-o</Literal> <Literal>-</Literal> causes trace output to go to standard output of
  233. <Command>tttrace</Command>.</Para>
  234. <Para>If the
  235. server for
  236. <Emphasis>session</Emphasis> is running on a remote host and either
  237. </Para>
  238. <itemizedlist>
  239. <listitem>
  240. <Para><Emphasis>outfile</Emphasis> is not mounted on that host, or
  241. </Para>
  242. </listitem>
  243. <listitem>
  244. <Para>the <Literal>-o</Literal> option is omitted,
  245. </Para>
  246. </listitem>
  247. </itemizedlist>
  248. <Para>then
  249. <Command>tttrace</Command> will fail.
  250. </Para>
  251. </ListItem>
  252. </VarListEntry>
  253. <VarListEntry>
  254. <Term>-S session</Term>
  255. <ListItem>
  256. <!-- ex-TP-->
  257. <Para>Session to trace. Defaults to the
  258. <Symbol Role="Variable">default</Symbol> <Emphasis>session</Emphasis> -- the session that <ComputerOutput>tt_open()</ComputerOutput> would contact.
  259. </Para>
  260. </ListItem>
  261. </VarListEntry>
  262. <VarListEntry>
  263. <Term>command</Term>
  264. <ListItem>
  265. <!-- ex-TP-->
  266. <Para>The ToolTalk client command to invoke and trace.
  267. </Para>
  268. </ListItem>
  269. </VarListEntry>
  270. </VariableList>
  271. </RefSect1>
  272. <RefSect1>
  273. <Title>EXAMPLES</Title>
  274. <Para>Here we trace a client that registers a pattern and sends a notice
  275. that matches it:
  276. </Para>
  277. <Screen>% tttrace -a <Emphasis>myclientprogram</Emphasis>
  278. tt_open() = 0x51708=="7.jOHHM X 129.144.153.55 0" (TT_OK)
  279. tt_fd() = 11 (TT_OK)
  280. tt_pattern_create() = 0x50318 (TT_OK)
  281. tt_pattern_category_set(0x50318, TT_OBSERVE) = 0 (TT_OK)
  282. tt_pattern_scope_add(0x50318, TT_SESSION) = 0 (TT_OK)
  283. tt_pattern_op_add(0x50318, 0x2f308=="Hello World") = 0 (TT_OK)
  284. tt_default_session() = 0x519e0=="X 129.144.153.55 0" (TT_OK)
  285. tt_pattern_session_add(0x50318, 0x519e0=="X 129.144.153.55 0") = 0 (TT_OK)
  286. tt_pattern_register(0x50318) = 0 (TT_OK)
  287. tt_message_create() = 0x51af0 (TT_OK)
  288. tt_message_class_set(0x51af0, TT_NOTICE) = 0 (TT_OK)
  289. tt_message_address_set(0x51af0, TT_PROCEDURE) = 0 (TT_OK)
  290. tt_message_scope_set(0x51af0, TT_SESSION) = 0 (TT_OK)
  291. tt_message_op_set(0x51af0, 0x2f308=="Hello World") = 0 (TT_OK)
  292. tt_message_send(0x51af0) ...
  293. TT_CREATED => TT_SENT:
  294. TT_SENT TT_PROCEDURE TT_NOTICE (TT_DISCARD in TT_SESSION): 0 == TT_OK
  295. id: 0 7.jOHHM X 129.144.153.55 0
  296. op: Hello World
  297. session: X 129.144.153.55 0
  298. sender: 7.jOHHM X 129.144.153.55 0
  299. = 0 (TT_OK)
  300. tt_message_receive() ...
  301. Tt_message => procid &lt;7.jOHHM X 129.144.153.55 0>
  302. TT_SENT TT_PROCEDURE TT_NOTICE (TT_DISCARD in TT_SESSION): 0 == TT_OK
  303. id: 0 7.jOHHM X 129.144.153.55 0
  304. op: Hello World
  305. session: X 129.144.153.55 0
  306. sender: 7.jOHHM X 129.144.153.55 0
  307. pattern: 0:7.jOHHM X 129.144.153.55 0
  308. = 0x51af0 (TT_OK)
  309. </Screen>
  310. <Para><Command>ttsession</Command>'s view of this traffic can be seen as follows. Note that the first message
  311. traced will almost always be
  312. <Command>ttsession</Command>'s reply to the request sent it by
  313. <Command>tttrace</Command>.</Para>
  314. <Screen>% <Command>tttrace</Command> -a
  315. tt_message_reply:
  316. TT_SENT => TT_HANDLED:
  317. TT_HANDLED TT_PROCEDURE TT_REQUEST (TT_DISCARD in TT_SESSION): 0 == TT_OK
  318. id: 0 2.jOHHM X 129.144.153.55 0
  319. op: Session_Trace
  320. args:
  321. TT_IN string: "> /tmp/traceAAAa002oL; version 1; states"[...]
  322. session: X 129.144.153.55 0
  323. sender: 2.jOHHM X 129.144.153.55 0
  324. pattern: 0:X 129.144.153.55 0
  325. handler: 0.jOHHM X 129.144.153.55 0
  326. Tt_message => procid &lt;2.jOHHM X 129.144.153.55 0>
  327. tt_message_send:
  328. TT_CREATED TT_PROCEDURE TT_NOTICE (TT_DISCARD in TT_SESSION): 0 == TT_OK
  329. id: 0 7.jOHHM X 129.144.153.55 0
  330. op: Hello World
  331. session: X 129.144.153.55 0
  332. sender: 7.jOHHM X 129.144.153.55 0
  333. TT_CREATED => TT_SENT:
  334. TT_SENT TT_PROCEDURE TT_NOTICE (TT_DISCARD in TT_SESSION): 0 == TT_OK
  335. id: 0 7.jOHHM X 129.144.153.55 0
  336. op: Hello World
  337. session: X 129.144.153.55 0
  338. sender: 7.jOHHM X 129.144.153.55 0
  339. Tt_message &amp; Tt_pattern {
  340. id: 0:7.jOHHM X 129.144.153.55 0
  341. category: TT_OBSERVE
  342. scopes: TT_SESSION
  343. sessions: X 129.144.153.55 0
  344. ops: Hello World
  345. } == 3;
  346. Tt_message => procid &lt;7.jOHHM X 129.144.153.55 0>
  347. </Screen>
  348. <Para>To trace message flow in a specific, non-default session,
  349. </Para>
  350. <Screen>% tttrace -S "01 15303 1342177284 1 0 13691 129.144.153.55 2"
  351. </Screen>
  352. </RefSect1>
  353. <RefSect1>
  354. <Title>ENVIRONMENT</Title>
  355. <Para><Command>tttrace</Command> is implemented purely as a ToolTalk client, using the message
  356. interface to
  357. <Command>ttsession</Command> and the following environmental hook into libtt.
  358. </Para>
  359. <VariableList>
  360. <VarListEntry>
  361. <Term>TT_TRACE_SCRIPT</Term>
  362. <ListItem>
  363. <!-- ex-TP-->
  364. <Para>If set, tells libtt to turn on client-side tracing as specified in
  365. the trace script. If the first character of of the value is '.' or '/',
  366. the value is taken to be the pathname of file containing the trace script
  367. to use. Otherwise, the value is taken to be an inline trace script.
  368. </Para>
  369. </ListItem>
  370. </VarListEntry>
  371. </VariableList>
  372. </RefSect1>
  373. <RefSect1>
  374. <Title>FILES</Title>
  375. <VariableList>
  376. <VarListEntry>
  377. <Term>$TMPDIR/tttrace.nnn</Term>
  378. <ListItem>
  379. <!-- ex-TP-->
  380. <Para>A
  381. <Emphasis>named</Emphasis> <Emphasis>pipe</Emphasis> (see
  382. <Filename MoreInfo="RefEntry">mkfifo</Filename>(3C)) in <Symbol>$TMPDIR</Symbol> (see
  383. <Filename MoreInfo="RefEntry">tempnam</Filename>(3S)) from which trace output for
  384. <Emphasis>session</Emphasis> is read when the
  385. <Literal>-o</Literal> option is omitted.
  386. </Para>
  387. </ListItem>
  388. </VarListEntry>
  389. </VariableList>
  390. </RefSect1>
  391. <RefSect1>
  392. <Title>WARNINGS</Title>
  393. <Para>Since (with the
  394. <Literal>-F</Literal> option) tracing can follow clients to remote hosts if the environment
  395. is properly propagated, it is possible for different processes in
  396. the same trace output to be labeled with the same process id.
  397. </Para>
  398. </RefSect1>
  399. <RefSect1>
  400. <Title>SEE</Title>
  401. <Para>&cdeman.ttsession;, &cdeman.tttracefile;, the
  402. <Literal>Session_Trace</Literal>() ToolTalk request
  403. </Para>
  404. </RefSect1>
  405. <RefSect1>
  406. <Title>DIAGNOSTICS</Title>
  407. <Para>If
  408. <Symbol Role="Variable">command</Symbol> is run, then
  409. <Command>tttrace</Command> will exit with the exit status of
  410. <Symbol Role="Variable">command</Symbol>. Otherwise, exit codes are as follows:
  411. </Para>
  412. <VariableList>
  413. <VarListEntry>
  414. <Term>0</Term>
  415. <ListItem>
  416. <!-- ex-TP-->
  417. <Para>Normal termination. Any
  418. <Emphasis>session</Emphasis> tracing turned on by this invocation of
  419. <Command>tttrace</Command> has now been turned off.
  420. </Para>
  421. </ListItem>
  422. </VarListEntry>
  423. <VarListEntry>
  424. <Term>1</Term>
  425. <ListItem>
  426. <!-- ex-TP-->
  427. <Para>Usage.
  428. <Command>tttrace</Command> was given invalid command line options.
  429. </Para>
  430. </ListItem>
  431. </VarListEntry>
  432. <VarListEntry>
  433. <Term>2</Term>
  434. <ListItem>
  435. <!-- ex-TP-->
  436. <Para>Failure.
  437. <Command>tttrace</Command> encountered an error while trying to do its job. An error
  438. message has been emitted on standard error.
  439. </Para>
  440. </ListItem>
  441. </VarListEntry>
  442. <VarListEntry>
  443. <Term>3</Term>
  444. <ListItem>
  445. <!-- ex-TP-->
  446. <Para>Runaway
  447. <Emphasis>session</Emphasis> tracing.
  448. <Command>tttrace</Command> could not terminate tracing in
  449. <Emphasis>session</Emphasis> before exiting.
  450. </Para>
  451. </ListItem>
  452. </VarListEntry>
  453. <VarListEntry>
  454. <Term>4</Term>
  455. <ListItem>
  456. <!-- ex-TP-->
  457. <Para>Remote
  458. <Emphasis>session</Emphasis>. <Command>ttsession</Command> is remote, and
  459. <Emphasis>outfile</Emphasis> (if given) is not visible there. Choose a visible file,
  460. or run
  461. <Command>tttrace</Command> on that remote host.
  462. </Para>
  463. </ListItem>
  464. </VarListEntry>
  465. <VarListEntry>
  466. <Term>5</Term>
  467. <ListItem>
  468. <!-- ex-TP-->
  469. <Para>Old
  470. <Emphasis>session</Emphasis>. The
  471. <Command>ttsession</Command> for
  472. <Emphasis>session</Emphasis> does not support the <ComputerOutput>Session_Trace()</ComputerOutput> request. Run
  473. <Literal>kill</Literal> <Literal>-USR1</Literal> on it to turn on old-style tracing.
  474. </Para>
  475. </ListItem>
  476. </VarListEntry>
  477. </VariableList>
  478. </RefSect1>
  479. <RefSect1>
  480. <Title>NOTES</Title>
  481. <Para>For security purposes, client-side tracing is disabled inside a client
  482. when its effective uid or gid is different from its real uid or gid
  483. and the real uid is not the super-user.
  484. </Para>
  485. </RefSect1>
  486. </RefEntry>
  487. <!--fickle 1.12 mancsf-to-docbook 1.3 08/21/95 21:30:04-->