Skip to content

Commit d966b22

Browse files
committed
docs: move and adapt the other chapters of Stan's docs suitable for public docs
also added `just serve-docs`
1 parent b7d2a3a commit d966b22

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

71 files changed

+217
-1298
lines changed

.gitignore

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ build-*/
1111
.direnv/
1212
result
1313

14-
docs/experimental-documentation/build/*
14+
docs/book/book
1515
src/index.js
1616
ui.js
1717
debugger.js

ci/deploy/docs.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
set -e
44

5-
pushd docs/experimental-documentation/mdbook-ct
5+
pushd docs/book/
66

77
# TODO: eventually: a more fine-grained nix shell/env?
88
# nix-shell --command "mdbook build"
File renamed without changes.
File renamed without changes.
File renamed without changes.

docs/book/src/SUMMARY.md

+36
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
## Summary
2+
3+
- [Introduction](./introduction.md)
4+
5+
## Usage guide
6+
7+
- [Intro to usage guide](./usage_guide/intro_to_usage.md)
8+
- [CLI](./usage_guide/CLI.md)
9+
- [Basic GUI](./usage_guide/basic_gui.md)
10+
- [Tracepoints](./usage_guide/tracepoints.md)
11+
- [CodeTracer Shell](./usage_guide/codetracer_shell.md)
12+
13+
## Backends
14+
15+
- [DB backend](./backends/db_backend.md)
16+
- [Noir](./backends/db-backend/noir.md)
17+
- [Ruby](./backends/db-backend/ruby.md)
18+
- [Python](./backends/db-backend/py.md)
19+
- [Lua](./backends/db-backend/lua.md)
20+
- [small](./backends/db-backend/small.md)
21+
22+
- [RR backend](./backends/rr_backend.md)
23+
- [C & C++](./backends/rr-backend/c_and_cpp.md)
24+
- [Rust](./backends/rr-backend/rust.md)
25+
- [Nim](./backends/rr-backend/nim.md)
26+
- [Go](./backends/rr-backend/go.md)
27+
28+
## Building & packaging
29+
30+
- [Build systems](./building_and_packaging/build_systems.md)
31+
32+
### Misc
33+
34+
- [Troubleshooting](./misc/troubleshooting.md)
35+
- [Environment variables](./misc/environment_variables.md)
36+
- [Building the documentation](./misc/building_docs.md)
+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
## Lua
2+
3+
We still don't have Lua support, however we've had a very minimal proof of concept experiment with supporting Lua (the interpreter, not LuaJIT) with our RR backend years ago.
4+
5+
We can change that patch to produce traces suitable for the DB backend, or at least publish some kind of basis for that(the RR approach remains possible, but with different tradeoffs)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
## Noir
2+
3+
The initial release of CodeTracer has MVP support for the Noir programming language. It has been developed in collaboration with the Blocksense team and currently requires the use of the [Blocksense Noir Compiler](https://github.com/blocksense-network/noir), which is included in the CodeTracer distribution.
4+
5+
We support many of Noir's features, but not all: e.g. we don't support mutable references currently, we don't serialize struct values and some other cases.
6+
7+
We are planning on adding support for the missing features.
+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
## python
2+
3+
We currently have started adding support for recording python programs for the DB backend, but the prototype isn't finished yet.
4+
5+
The recorder is currently hosted in the [codetracer-python-recorder](https://github.com/metacraft-labs/codetracer-python-recorder) repo.
6+
7+
You can read its README for more details. We are welcoming contributors!
8+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# Python
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
## Ruby
2+
3+
We currently have partial support for the Ruby programming language in the DB backend.
4+
We support many cases, you can use it like `ct record <path to rb file> [<args>]` and `ct replay <name of rb file>` (or directly `ct run <path to rb file> [<args>]`)
5+
6+
The recorder for Ruby is currently hosted in the [codetracer-ruby-recorder](https://github.com/metacraft-labs/codetracer-ruby-recorder) repo.
7+
8+
You can read its README for more details. We are welcoming contributors!
9+
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
1-
SmallLang is, as the name says, a small, lisp-like language, that's used for general testing of the DB backend.
1+
## small lang
2+
3+
small lang is, as the name says, a small, lisp-like language, that's used for general dogfooding of new tracing features and testing of the DB backend.
24
It's purely experimental.
35

46
You can find its source code under `src/small-lang`. There, you can also find multiple files with the `.small`
57
extension, which can be used as examples of the language.
8+

docs/book/src/backends/db_backend.md

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
## DB backend
2+
3+
The DB backend is currently used for interpreted languages, like scripting and blockchain/zero knowledge languages:
4+
5+
1. [Noir](./db-backend/noir.md)
6+
1. [Ruby](./db-backend/ruby.md)
7+
1. [Python(prototype not finished yet)](./db-backend/py.md)
8+
1. [Lua(not done: just a plan)](./db-backend/lua.md)
9+
1. [small(a toy interpreter for dogfooding)](./db-backend/small.md)
10+
11+
If you're interested in db-backend support for those languages or for now ones, you can discuss with us on our Github issue tracker,
12+
in the discussions or in our [chat server](https://discord.gg/aH5WTMnKHT). We welcome contributors!
13+
14+
However it might be used for emulators(and this way for native languages) in the future.
15+
16+
Also, languages can have both native(AOT) and interpreted implementations:
17+
so we can more easily support e.g. interpreters/VM-s of certain languages with this backend currently.
18+
19+
As the name suggests, this backend is implemented as a database. Due to its properties, this backend provides
20+
a more complete feature set - one of the reasons it was ready first.
21+
22+
For each language, we define a tracer, which instruments or hooks into the interpreter, VM or program and
23+
records all the data, that we need in a trace folder.
24+
25+
We postprocess and index that trace into a database-like structure. Currently this happens in the beginning of the replay.
26+
For now the data in the database is represented by a runtime-only Rust structure, however
27+
we plan on storing it as a file, which can be memory-mapped and on separating the postprocessing/indexing step as
28+
an optionally independent action.
29+
30+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# Noir
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
## C & C++
2+
3+
We have partial support for C and C++ in the RR backend. C generally has good support, though it is less advanced than
4+
the Rust implementation.
5+
6+
Support for C++ is still experimental, due to missing support for many C++ constructs.
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,4 @@
1+
# Go
2+
13
We have developed а basic integration that supports small parts of the Golang language in the Core backend.
2-
Development on a more complete revision is scheduled to start soon!
4+
Development on a more complete revision is scheduled to start soon!
+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# Nim
2+
3+
We have partial support for the Nim backend, with it being somewhat behind in features compared to C, but ahead,
4+
compared to C++.
5+
6+
The Nim backend only supports Nim 1 as of today, but there are plans to add support for Nim 2.
7+
8+
9+
Some additional future goals that have been announced in the Nim forum are:
10+
11+
* First-class support for macro-generated code - macro generated code should be indistinguishable from regular code. You can expand it layer by layer, set breakpoints and tracepoints anywhere within it, and step through it in all the familiar ways. (or at least part of those)
12+
* Precise debug info - you should be able to set breakpoints and tracepoints at the level of individual sub-expressions and you can switch between debugging Nim, C or assembly code at any time.
13+
* Compile-time debugging - with few clicks in your text editor, you should be able to trace the execution of the Nim VM itself.
14+
15+
> [!NOTE]
16+
> For now we're focused on the beta and initial releases of the RR backend though, and on initial releases for some of the language supports.
17+
> This means the initial support for Nim would be focused on the same features as the other languages: stepping, tracepoints, event log, calltrace, omniscience, state, history. We do hope we'll be able to continue with some of the more advanced goals afterwards.
18+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Rust
2+
3+
Our backend for Rust is the most developed out of all languages in the RR backend, with it being closest to MVP status(but still non trivial amount of work left).

docs/book/src/backends/rr_backend.md

+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
## RR backend
2+
3+
The RR backend is used for systems programming languages, like:
4+
5+
1. [C & C++](./rr-backend/c_and_cpp.md)
6+
1. [Rust](./rr-backend/rust.md)
7+
1. [Nim](./rr-backend/nim.md)
8+
1. [Go](./rr-backend/go.md)
9+
10+
Under the hood, it uses a patched version of the [RR debugger](https://rr-project.org/), as well as the standard
11+
GDB debugger.
12+
13+
We are still not distributing it, but we might need to rethink the GDB usage before that.
14+
15+
The Core backend is based on a dispatcher that maintains a pool of rr replay processes. These processes allow you to jump back and forward in time, while also
16+
preloading information, such as the information, needed for omniscience and calltrace, as well as managing other features, such as tracepoints. This logic is
17+
currently implemented using python code using the gdb API.
18+
(If required, this can be changed to use the lldb API or something more custom, like a dwarf lib-based solution. We are currently using the rust `gimli` DWARF lib for a tool, that helps with recording/metadata in the RR backend).
19+
20+
These are the main differences, when compared to the DB Backend: based on the way RR works:
21+
22+
1. Only non-deterministic events are recorded.
23+
1. The program's different states are navigated through re-execution.
24+
1. More practical for recording real-world software(RR was originally created by Mozilla to debug Firefox)
25+
1. Some features of CodeTracer are more challenging to implement, compared to the [DB Backend](./backends/db-backend.md)
26+
27+
> ![NOTE]
28+
> This backend is in active development, and is yet to be released to the wider public.
29+
>
30+
> It is currently proprietary and it might remain closed source.
31+
> Open sourcing it is also possible, if we find a suitable business model.
32+

docs/experimental-documentation/Introduction/BuildSystem.md docs/book/src/building_and_packaging/build_systems.md

+13-3
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,16 @@
1+
## Build systems
2+
13
Codetracer uses nix, just, tup and direnv as parts of its build system.
24

35
## Breakdown of the different components
46
### Nix
57
The Nix package manager/build system deals with managing all dependencies, required by CodeTracer, as well as packaging
6-
it for NixOS, and other operating systems through an AppImage generator utility.
8+
it for NixOS. It can package for other operating systems through an AppImage generator utility, however currently we are building our
9+
appimages with custom shell scripts in `appimage-scripts`.
710

811
### Just
9-
The Just build system is used to trigger build commands. It's semi-analogous to a Makefile. The following commands are
12+
13+
The `just` tool is used to trigger build commands and various other actions. It's semi-analogous to a Makefile. The following commands are
1014
the most widely-used:
1115

1216
1. `just build` - Builds the project with Tup and starts the automatic build process, which is used for active development
@@ -27,10 +31,13 @@ The Tup build system is used for local builds of CodeTracer and deals with calli
2731
The `direnv` utility sets up your local environment for using CodeTracer.
2832

2933
## Packaging
30-
### Detailed breakdown of the Nix package
34+
35+
### More detailed breakdown of the Nix package
36+
3137
Coming soon!
3238

3339
### Packaging for non-NixOS distributions
40+
3441
> [!TIP]
3542
> If you're a user that wants a package for your distribution contact us. We're currently in the process of creating
3643
> packages for popular distributions, such as Debian/Ubuntu, Fedora/RHEL, Arch Linux, Gentoo, Void, etc.
@@ -40,7 +47,10 @@ which you can install to `/usr/bin`. Along with it, you should also install our
4047
from `resources/` to the needed directories, such as `/usr/share/pixmaps` and `/usr/share/applications`.
4148

4249
### Packaging for Windows(DB-backend only)
50+
4351
Coming soon!
4452

4553
### Packaging for macOS(DB-backend only)
54+
4655
Coming soon!
56+

docs/experimental-documentation/mdbook-ct/src/chapter_1.md docs/book/src/introduction.md

+6-35
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,9 @@
33
Welcome to the codetracer-desktop wiki. Here you can find information on almost every topic
44
regarding codetracer development and usage.
55

6-
## What is codetracer
7-
Codetracer is a debugging environment, based on the concept of record and replay, developed as a powerful tool to easily
8-
debug complex applications.
9-
106
## Installation
117
> [!CAUTION]
12-
> Codetracer can only be installed on Linux and macOS.
8+
> Codetracer can only be installed on Linux and macOS currently.
139
1410
### Prerequisites
1511
On systems that are not NixOS, you need to install `direnv` and `nix`.
@@ -50,39 +46,14 @@ TODO:
5046
> 1. Run `direnv allow`
5147
5248
### Building and running the tests
53-
To start running tests do the following:
5449

55-
1. Run `tester build` - Builds tester
56-
1. Run `tester parallel` - Runs the tests
50+
Coming soon!
5751

5852
### Enabling `cachix`
59-
> [!NOTE]
60-
> This step is optional
61-
62-
<!-- TODO: Scrap or completely rewrite the cachix instructions for end users. Alternatively, make this an internal developer guide -->
63-
64-
Cachix is a cache for nix that allows you to save time on compiling codetracer and related projects. To enable `cachix` do the following:
65-
66-
1. Log into [cachix](https://www.cachix.org/) with your personal GitHub account
67-
1. Create an authentication token
68-
1. Run `cachix authtoken --stdin`
69-
1. Paste the token and click enter
70-
1. Press `CTRL + D` to save the token
71-
1. Run `cachix use metacraft-labs-codetracer`
72-
1. Run `direnv allow`, `nix develop`, or `just build-nix` to auto-download cached binaries if available
73-
74-
### Explicit `cachix` setup
75-
> [!NOTE]
76-
> You have to be an admin for the private cache. Ask an administrator to get added.
77-
78-
Our current `cachix` setup pushes binaries from CI, but if you want to manually push to `cachix` as well, or want to know how pushing works, you can do the following:
79-
80-
1. Go to [this page](https://app.cachix.org/organization/metacraft-labs/cache/metacraft-labs-codetracer/settings/authtokens)
81-
1. Create an auth token with `Read+Write` permissions
82-
1. Locally register it as described in the above heading
8353

84-
To push the dev shell to `cachix` use either one of the following commands:
54+
<!-- TODO(alexander): I removed the detailed cachix guide, as it's sensitive, and we don't have a public codetracer cache yet -->
55+
<!-- either include it in an internal docs in the rr-backend, or re-include here when this is discussed again -->
8556

86-
1. Automatically: `just cachix-push-devshell`
87-
1. Manually: `cachix push metacraft-labs-codetracer "$(nix build --print-out-paths .#devshells.x86_64-linux.default)"`
57+
Cachix is a cache for nix that allows you to save time on compiling codetracer and related projects. We'll discuss using a public codetracer cache
58+
for the open sourced parts, however this is available only internally for now.
8859

docs/book/src/misc/building_docs.md

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
## Building the documentation
2+
3+
The documenation for codetracer is written in Markdown using [mdbook](https://rust-lang.github.io/mdBook/).
4+
We use some extensions from [GitHub Flavoured Markdown](https://docs.github.com/en/get-started/writing-on-github/getting-started-with-writing-and-formatting-on-github/basic-writing-and-formatting-syntax) : specifically alert boxes with [mdbook-alerts](https://crates.io/crates/mdbook-alerts).
5+
6+
To build the documentation run `just build-docs`. If you want to iterate on the documentation for local development, run `just serve-docs [<hostname>] [<port>]` or by going in the docs directory and running `mdbook serve [--hostname <hostname>] [--port <port>]` and a web server will be started, by default on http://localhost:3000 .
7+
8+
The built doc files are stored under `docs/experimental-documentation/build`, while the markdown files are under `docs/experimental-documentation` and its child directories.

docs/experimental-documentation/Advanced/EnvironmentVariables.md docs/book/src/misc/environment_variables.md

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
## Environment variables
2+
13
CodeTracer exposes a number of environment variables that you can use to override some of its behaviours:
24

35
1. `CODETRACER_ELECTRON_ARGS` - adds arguments for launching Electron. Useful for debugging production builds
@@ -16,4 +18,4 @@ These are generally not functional right now, since they affect CodeTracer Shell
1618
1. `CODETRACER_SHELL_RECORDS_OUTPUT` - ?
1719
1. `CODETRACER_SHELL_EXPORT` - ?
1820
1. `CODETRACER_SHELL_CLEANUP_OUTPUT_FOLDER` - ?
19-
1. `CODETRACER_SHELL_SOCKET` and `CODETRACER_SHELL_ADDRESS` - they override the socket location and address respectively
21+
1. `CODETRACER_SHELL_SOCKET` and `CODETRACER_SHELL_ADDRESS` - they override the socket location and address respectively
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,26 @@
1+
## Troubleshooting
2+
13
CodeTracer is currently in an experimental state, so we expect that there are many bugs that have not been found as of now.
24
If you find any bug, please report it as an issue on GitHub.
35

46
In the meantime, you can use this page to fix some issues that are somewhat common.
57

6-
## Fixing outdated configuration/layout files
7-
You can find more information [here](https://dev-docs.codetracer.com/Introduction/Configuration#Layout).
8+
### Fixing outdated configuration/layout files
9+
10+
You can reset them by deleting your `~/.config/codetracer` folder currently.
11+
12+
You will be able to find more information in the configuration docs eventually: work in progress.
13+
14+
### Resetting the local trace database
815

9-
## Resetting the local trace database
1016
There are 2 commands that can be used to completely wipe all traces from your user's data:
1117

1218
1. `just reset-db` - Resets the local user's trace database
1319
1. `just clear-local-traces` - Clears the local user's traces
1420

15-
## Broken local build
21+
### Broken local build
22+
1623
Sometimes your local build might break. In most cases, a simple `direnv reload` and `just build` should be able to fix it.
17-
Otherwise, you can ask for help on our [issues tracker](github.com/metacraft-labs/codetracer), or in our [chat server](https://discord.gg/aH5WTMnKHT)
24+
Otherwise, you can ask for help on our [issues tracker](https://github.com/metacraft-labs/codetracer), or in our [chat server](https://discord.gg/aH5WTMnKHT)
1825

1926
<!-- TODO: Add more info here -->

docs/experimental-documentation/404.md

-4
This file was deleted.

docs/experimental-documentation/Advanced/CustomPatches.md

-1
This file was deleted.

docs/experimental-documentation/Advanced/Deprecated.md

-1
This file was deleted.

docs/experimental-documentation/Advanced/Dotfiles.md

-1
This file was deleted.

docs/experimental-documentation/Advanced/Packaging.md

Whitespace-only changes.

docs/experimental-documentation/Introduction/Backends.md

-4
This file was deleted.

0 commit comments

Comments
 (0)