about summary refs log blame commit diff stats
path: root/tools/browse_trace.readme.md
blob: 8c3f50f4688f8c92e91aad789eb264cb37f93c95 (plain) (tree)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
pre { line-height: 125%; }
td.linenos .normal { color: inherit; background-color: transparent; padding-left: 5px; padding-right: 5px; }
span.linenos { color: inherit; background-color: transparent; padding-left: 5px; padding-right: 5px; }
td.linenos .special { color: #000000; background-color: #ffffc0; padding-left: 5px; padding-right: 5px; }
span.linenos.special { color: #000000; background-color: #ffffc0; padding-left: 5px; padding-right: 5px; }
.highlight .hll { background-color: #ffffcc }
.highlight .c { color: #888888 } /* Comment */
.highlight .err { color: #a61717; background-color: #e3d2d2 } /* Error */
.highlight .k { color: #008800; font-weight: bold } /* Keyword */
.highlight .ch { color: #888888 } /* Comment.Hashbang */
.highlight .cm { color: #888888 } /* Comment.Multiline */
.highlight .cp { color: #cc0000; font-weight: bold } /* Comment.Preproc */
.highlight .cpf { color: #888888 } /* Comment.PreprocFile */
.highlight .c1 { color: #888888 } /* Comment.Single */
.highlight .cs { color: #cc0000; font-weight: bold; background-color: #fff0f0 } /* Comment.Special */
.highlight .gd { color: #000000; background-color: #ffdddd } /* Generic.Deleted */
.highlight .ge { font-style: italic } /* Generic.Emph */
.highlight .ges { font-weight: bold; font-style: italic } /* Generic.EmphStrong */
.highlight .gr { color: #aa0000 } /* Generic.Error */
.highlight .gh { color: #333333 } /* Generic.Heading */
.highlight .gi { color: #000000; background-color: #ddffdd } /* Generic.Inserted */
.highlight .go { color: #888888 } /* Generic.Output */
.highlight .gp { color: #555555 } /* Generic.Prompt */
.highlight .gs { font-weight: bold } /* Generic.Strong */
.highlight .gu { color: #666666 } /* Generic.Subheading */
.highlight .gt { color: #aa0000 } /* Generic.Traceback */
.highlight .kc { color: #008800; font-weight: bold } /* Keyword.Constant */
.highlight .kd { color: #008800; font-weight: bold } /* Keyword.Declaration */
.highlight .kn { color: #008800; font-weight: bold } /* Keyword.Namespace */
.highlight .kp { color: #008800 } /* Keyword.Pseudo */
.highlight .kr { color: #008800; font-weight: bold } /* Keyword.Reserved */
.highlight .kt { color: #888888; font-weight: bold } /* Keyword.Type */
.highlight .m { color: #0000DD; font-weight: bold } /* Literal.Number */
.highlight .s { color: #dd2200; background-color: #fff0f0 } /* Literal.String */
.highlight .na { color: #336699 } /* Name.Attribute */
.highlight .nb { color: #003388 } /* Name.Builtin */
.highlight .nc { color: #bb0066; font-weight: bold } /* Name.Class */
.highlight .no { color: #003366; font-weight: bold } /* Name.Constant */
.highlight .nd { color: #555555 } /* Name.Decorator */
.highlight .ne { color: #bb0066; font-weight: bold } /* Name.Exception */
.highlight .nf { color: #0066bb; font-weight: bold } /* Name.Function */
.highlight .nl { color: #336699; font-style: italic } /* Name.Label */
.highlight .nn { color: #bb0066; font-weight: bold } /* Name.Namespace */
.highlight .py { color: #336699; font-weight: bold } /* Name.Property */
.highlight .nt { color: #bb0066; font-weight: bold } /* Name.Tag */
.highlight .nv { color: #336699 } /* Name.Variable */
.highlight .ow { color: #008800 } /* Operator.Word */
.highlight .w { color: #bbbbbb } /* Text.Whitespace */
.highlight .mb { color: #0000DD; font-weight: bold } /* Literal.Number.Bin */
.highlight .mf { color: #0000DD; font-weight: bold } /* Literal.Number.Float */
.highlight .mh { color: #0000DD; font-weight: bold } /* Literal.Number.Hex */
.highlight .mi { color: #0000DD; font-weight: bold } /* Literal.Number.Integer */
.highlight .mo { color: #0000DD; font-weight: bold } /* Literal.Number.Oct */
.highlight .sa { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Affix
### A debugging helper that lets you zoom in/out on a trace.

To try it out, first create an example trace:

  ```shell
  $ cd linux
  $ bootstrap/bootstrap translate [01]*.subx factorial.subx -o factorial
  $ bootstrap/bootstrap --trace run factorial
  ```

This command will save a trace of its execution in a file called `last_run`.
The trace consists of a series of lines, each starting with an integer depth
and a single-word 'label', followed by a colon and whitespace.

Now browse this trace:

  ```shell
  $ cd ..
  $ tools/browse_trace linux/last_run
  ```

You should now find yourself in a UI showing a subsequence of lines from the
trace, each line starting with a numeric depth, and ending with a parenthetical
count of trace lines hidden after it with greater depths.

For example, this line:

  ```
  2 app: line1 (30)
  ```

indicates that it was logged with depth 2, and that 30 following lines have
been hidden at a depth greater than 2.

(As an experiment, hidden counts of 1000 or more are highlighted in red.)

The UI provides the following hotkeys:

* `q` or `ctrl-c`: Quit.

* `Enter`: 'Zoom into' this line. Expand lines hidden after it that were at
  the next higher level.

* `Backspace`: 'Zoom out' on a line after zooming in, collapsing lines below
  expanded by some series of `Enter` commands.

* `j` or `down-arrow`: Move cursor down one line.
* `k` or `up-arrow`: Move cursor up one line.
* `J` or `ctrl-f` or `page-down`: Scroll cursor down one page.
* `K` or `ctrl-b` or `page-up`: Scroll cursor up one page.
* `h` or `left-arrow`: Scroll cursor left one character.
* `l` or `right-arrow`: Scroll cursor right one character.
* `H`: Scroll cursor left one screen-width.
* `L`: Scroll cursor right one screen-width.

* `g` or `home`: Move cursor to start of trace.
* `G` or `end`: Move cursor to end of trace.

* `t`: Move cursor to top line on screen.
* `c`: Move cursor to center line on screen.
* `b`: Move cursor to bottom line on screen.
* `T`: Scroll line at cursor to top of screen.

* `/`: Search forward for a pattern.
* `?`: Search backward for a pattern.
* `n`: Repeat the previous `/` or `?`.
* `N`: Repeat the previous `/` or `?` in the opposite direction.

After hitting `/`, the mini-editor on the bottom-most line supports the
following hotkeys:
* ascii characters: add the key to the pattern.
* `Enter`: search for the pattern.
* `Esc` or `ctrl-c`: cancel the current search, setting the screen back
  to its state before the search.
* `left-arrow`: move cursor left.
* `right-arrow`: move cursor right.
* `ctrl-a` or `home`: move cursor to start of search pattern.
* `ctrl-e` or `end`: move cursor to end of search pattern.
* `ctrl-u`: clear search pattern before cursor
* `ctrl-k`: clear search pattern at and after cursor

## wish list

* Simple regular expression search: `.` and `*`.
* Expand into lower depths as necessary when searching.
* Zoom out everything.
* Zoom out lines around the cursor to the highest (or specified) depth.
  Maybe a number followed by `]`?