# Debugger: Threads and Traces

In general, a thread refers to a unit of concurrent execution within a target. Typically, each thread carries its own execution context, so this window provides a means of navigating those contexts. Furthermore, this window provides a means of navigating and managing open traces, much like the static listing provides a means of navigating open programs. The window also plots a timeline showing thread lifespans, and displays a caret which can be used to navigate the current point in time. This window, the Stack window, and the Dynamic Listing window provide a complete trace navigation system.

## Trace Tabs

The trace tab bar is displayed when at least one trace is open. It displays the name of each open trace in a button, where the "current" or "focused" trace is selected. Clicking a tab will select its trace and focus the tool onto it. A trace associated with a live target has a red "recording" icon at its left. If that icon is not present, or has disappeared, the trace is dead or terminated. A "dead" trace can still be manipulated and marked up, but it will not record any new target information.

### Close Trace / All / Other / Dead Traces

In most cases, a trace is ephemeral, but occasionally, interesting behavior is observed that is difficult to store as static mark-up. When traces are no longer needed, they can be closed by right-clicking a tab and selecting one of the actions. See Trace Management for details of each action.

## Navigating Threads

Double-clicking a thread in the table will navigate to (or "activate" or "focus") that thread. Windows which are sensitive to the current thread will update. Notably, the Registers window will display the activated thread's register values. Listing windows with configured location tracking will re-compute that location with the thread's context and navigate to it. The thread timeline plots all recorded threads. Threads which are alive will appear to extend "to the end of time." The threads table displays more detailed information in the following columns:

- Name - the name of the thread given by the debugger. Often, this is just an index or unique id assigned to the thread. This field can be modified, but it has no effect on the target.
- Created - the snapshot when this thread was first observed. If the thread's creation was observed, then it is its creation time.
- Destroyed - if destroyed, the snapshot when this thread was last observed. If the thread's destruction was observed, then it is its destruction time.
- State - the thread's current state. For a dead trace, this is either ALIVE or TERMINATED, and depends solely on whether or not a destruction time was recorded. For a live trace, this may also take RUNNING, STOPPED, or UNKNOWN, depending on what is reported by the debugger. The state always reflects the present, or latest known, state.
- Comment - a user-modifiable comment about the thread.
- Plot - a graphical representation of the thread's lifespan. Unlike other column headers, clicking and dragging in this one will navigate trace snapshots. To rearrange this column, hold SHIFT while dragging.

## Actions

### Synchronize Trace and Target Activation

This toggle is always available and is enabled by default. While enabled, any changes in navigation coordinates are translated, to the extent possible, and sent to the connected debugger. This may, for example, issue `thread` and/or `frame` commands to GDB so that commands typed into its CLI will refer to the same thread and frame as is active in Ghidra. Conversely, any target events which indicate a change in activation are translated, to the extent possible, into navigation coordinates and activated in Ghidra. For example, if the user issues a `frame` command to the CLI of a GDB connection, then Ghidra will navigate to that same frame.