# Using TTSnoop to Debug Messages and Patterns

TTSnoop is a tool provided to create and send custom‐constructed ToolTalk messages. You can also use TTSnoop as a tool to selectively monitor any or all ToolTalk messages.

## About TTSnoop

TTSnoop is a useful interactive tool that you can use to become familiar with TookTalk concepts and API calls as well as to perform demonstrations. In addition, TTSnoop is a valuable debugging tool when you are developing applications.

You can use TTSnoop to monitor for messages that match more than one pattern. When a matched message is displayed, the name of the pattern that matched the entry can also be displayed.

You can add, edit, or delete messages and patterns to scrollable lists. TTSnoop allows the definitions of multiple patterns and messages to be saved and loaded from files. You can also define, save, and reload patterns and messages particular to a category of applications (for example, DeskSet™ tools) as well as associate messages and patterns with a user-defined name.

## Where to Find TTSnoop

The TTSnoop program resides in the directory
`/usr/dt/bin`.

## Starting TTSnoop

To start the program, enter the following command on the command line:

    ttsnoop [ -t ]

The
`-t` option displays the ToolTalk API calls that are being used to construct a particular pattern or message. TTUG.ttsnp.mkr.2 describes the menu options that are displayed when TTSnoop starts.

## TTSnoop Menu Options

`Menu Option` | `Description`
Snoop | Turn on/off tracing; get version information
Message | Create, open, receive, and destroy messages
Pattern | Create, open, and destroy patterns
File | Numerous tasks, including joining a file
Session | Join a specific session; set the default session
Ptype | Declare and undeclare a `ptype`; determine whether a `ptype` exists
Types | Generate a list of declared types; generate a list of ToolTalk-based actions
Procid | Open, close, suspend, and resume a procid
libc | Call `system()`, `putenv()`, `chdir()`, `pause()`, and `exit()`; use `exit()` to exit `ttsnoop`

## Composing and Sending Messages

When you select `Message ‐> Create`, a dialog is posted that enables you to

- Create and send a message

- Create a template for a ptype

- Create a template for a ToolTalk type action

- Create a C language template for a message reply handler

To create a message, select the `Create ‐> Tt_message` option. The following may be specified for a message:

- The Scope (for example, File, Session, Both, or File in Session)

- The Session Id

- The Class (for example, Notice or Request)

- The Address (for example, Object, Handler, or Procedure)

- The Disposition (Discard, Queue, or Start)

- The Arguments

## To Begin Snooping

To turn on the displaying of messages and pattern traffic, select `Snoop ‐> On`.

## To Stop Snooping

To turn off the displaying of messages and pattern traffic, select `Snoop ‐> Off`.