Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .agents/codebase-insights.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
`get_message()`, so callers need to drain messages until `None` after feeding
new bytes.


- The db-backend DAP server now responds to the `configurationDone` request.

- Electron lifecycle: the backend-manager process is spawned in
Expand All @@ -20,3 +19,5 @@
and hook it to `app.on('before-quit')`, `app.on('window-all-closed')`, and
Node process signals (`SIGINT`, `SIGTERM`, `SIGHUP`) to ensure the process
is always terminated when the app exits.
- The CodeTracer frontend and tooling now invoke the legacy CLI via the
`ct-legacy` binary; avoid calling the `ct` binary because it is a different tool.
12 changes: 6 additions & 6 deletions appimage-scripts/build_appimage.sh
Original file line number Diff line number Diff line change
Expand Up @@ -104,14 +104,14 @@ bash "${ROOT_PATH}"/appimage-scripts/build_css.sh
# Build/setup nim-based files
bash "${ROOT_PATH}"/appimage-scripts/build_with_nim.sh

cat << 'EOF' > "${APP_DIR}/bin/ct"
cat << 'EOF' > "${APP_DIR}/bin/ct-legacy"
#!/usr/bin/env bash

HERE=${HERE:-$(dirname "$(readlink -f "${0}")")}

# TODO: This includes references to x86_64. What about aarch64?

exec "${HERE}"/bin/ct_unwrapped "$@"
exec "${HERE}"/bin/ct-legacy_unwrapped "$@"

EOF

Expand Down Expand Up @@ -204,7 +204,7 @@ export LINKS_PATH_DIR=$HERE
export PATH="${HERE}/bin:${PATH}"
export CODETRACER_RUBY_RECORDER_PATH="${HERE}/codetracer-ruby-recorder/gems/codetracer-pure-ruby-recorder/bin/codetracer-pure-ruby-recorder"

exec ${HERE}/bin/ct "$@"
exec ${HERE}/bin/ct-legacy "$@"
EOF

chmod +x "${APP_DIR}/AppRun"
Expand Down Expand Up @@ -252,7 +252,7 @@ else
fi

# Patchelf the executable's interpreter
patchelf --set-interpreter "${INTERPRETER_PATH}" "${APP_DIR}"/bin/ct_unwrapped
patchelf --set-interpreter "${INTERPRETER_PATH}" "${APP_DIR}"/bin/ct-legacy_unwrapped
patchelf --set-interpreter "${INTERPRETER_PATH}" "${APP_DIR}"/bin/db-backend
patchelf --set-interpreter "${INTERPRETER_PATH}" "${APP_DIR}"/bin/db-backend-record
patchelf --set-interpreter "${INTERPRETER_PATH}" "${APP_DIR}"/bin/backend-manager
Expand All @@ -265,7 +265,7 @@ patchelf --set-interpreter "${INTERPRETER_PATH}" "${APP_DIR}"/bin/node
patchelf --set-interpreter "${INTERPRETER_PATH}" "${APP_DIR}"/ruby/bin/ruby

# Clear up the executable's rpath
patchelf --remove-rpath "${APP_DIR}"/bin/ct_unwrapped
patchelf --remove-rpath "${APP_DIR}"/bin/ct-legacy_unwrapped
patchelf --remove-rpath "${APP_DIR}"/bin/db-backend
patchelf --remove-rpath "${APP_DIR}"/bin/db-backend-record
patchelf --remove-rpath "${APP_DIR}"/bin/backend-manager
Expand All @@ -277,7 +277,7 @@ patchelf --remove-rpath "${APP_DIR}"/bin/node
patchelf --remove-rpath "${APP_DIR}"/ruby/bin/ruby

patchelf --set-rpath "\$ORIGIN/../lib" "${APP_DIR}"/bin/node
patchelf --set-rpath "\$ORIGIN/../lib" "${APP_DIR}"/bin/ct_unwrapped
patchelf --set-rpath "\$ORIGIN/../lib" "${APP_DIR}"/bin/ct-legacy_unwrapped
patchelf --set-rpath "\$ORIGIN/../lib" "${APP_DIR}"/bin/db-backend
patchelf --set-rpath "\$ORIGIN/../lib" "${APP_DIR}"/bin/db-backend-record
patchelf --set-rpath "\$ORIGIN/../lib" "${APP_DIR}"/bin/backend-manager
Expand Down
6 changes: 3 additions & 3 deletions appimage-scripts/build_with_nim.sh
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ nim -d:release \
-d:libcPath=libc \
-d:pathToNodeModules=../node_modules \
--nimcache:nimcache \
--out:"${APP_DIR}/bin/ct_unwrapped" c ./src/ct/codetracer.nim
--out:"${APP_DIR}/bin/ct-legacy_unwrapped" c ./src/ct-legacy/codetracer.nim


nim \
Expand All @@ -70,7 +70,7 @@ nim \
--passL:"${APP_DIR}/lib/libpcre.so.1" \
--passL:"${APP_DIR}/lib/libzip.so.5" \
--nimcache:nimcache \
--out:"${APP_DIR}/bin/db-backend-record" c ./src/ct/db_backend_record.nim
--out:"${APP_DIR}/bin/db-backend-record" c ./src/ct-legacy/db_backend_record.nim

# --passL:"-lsqlite3" \
#--passL:"${APPDIR}/lib/libcrypto.so.3" \
Expand All @@ -81,7 +81,7 @@ nim \

# TODO conditional for nixos?--passL:$LIBSQLITE3_PATH
#
# patchelf --set-rpath ${APP_DIR}/lib ${APP_DIR}/bin/ct
# patchelf --set-rpath ${APP_DIR}/lib ${APP_DIR}/bin/ct-legacy


# index.js
Expand Down
4 changes: 2 additions & 2 deletions docs/book/src/installation.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ Direnv should be set up in your shell, as shown [here](https://direnv.net/docs/h
```
4. Run `nix develop`
5. Run `direnv allow`
6. To build codetracer simply run `just build`. The location of the resulting binary will be `./src/build-debug/bin/ct`
6. To build codetracer simply run `just build`. The location of the resulting binary will be `./src/build-debug/bin/ct-legacy`
7. Now every time you enter the `codetracer` directory your environment should be updated

> [!TIP]
Expand All @@ -78,7 +78,7 @@ The only dependencies for the macOS build are `git`, `bash` and `homebrew`.
1. Clone the repository with submodules: `git clone https://github.com/metacraft-labs/codetracer.git --recursive`
2. Enter the created directory
3. Run `./non-nix-build/build.sh` from the root of the cloned repository. This will install all prerequisites like Rust, Nim and others using homebrew
4. The resulting binary can be found at `./non-nix-build/CodeTracer.app/Contents/MacOS/bin/ct`, and a DMG installer is created at `./non-nix-build/CodeTracer.dmg`.
4. The resulting binary can be found at `./non-nix-build/CodeTracer.app/Contents/MacOS/bin/ct-legacy`, and a DMG installer is created at `./non-nix-build/CodeTracer.dmg`.


### Building and running the tests
Expand Down
8 changes: 4 additions & 4 deletions nix/packages/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -623,7 +623,7 @@
mkdir -p $out/frontend/styles


cp ./ct $out/bin/
cp ./ct-legacy $out/bin/

# Codetracer web
cp -L ${codetracer-electron}/views/server_index.ejs $out/views
Expand Down Expand Up @@ -660,18 +660,18 @@
cp -L ${codetracer-electron}/src/helpers.js $out/src/helpers.js
# ln -sf ${codetracer-electron}/src/public/ $out/public

cp ./ct $out/bin
cp ./ct-legacy $out/bin
cp ./db-backend-record $out/bin

cp -r src/frontend/index.html $out/
cp -r src/frontend/subwindow.html $out/

'';

meta.mainProgram = "ct";
meta.mainProgram = "ct-legacy";

postFixup = ''
wrapProgram $out/bin/ct \
wrapProgram $out/bin/ct-legacy \
--prefix PATH : ${pkgs.lib.makeBinPath [ cargo-stylus ]}
'';

Expand Down
8 changes: 4 additions & 4 deletions non-nix-build/build_in_simple_env.sh
Original file line number Diff line number Diff line change
Expand Up @@ -56,19 +56,19 @@ cp -r "$ROOT_DIR"/src/config "$DIST_DIR"/config
cp -r "$ROOT_DIR"/src/public "$DIST_DIR"/public
cp -r "$BIN_DIR"/* "$DIST_DIR"/bin/

mv "$DIST_DIR"/bin/ct "$DIST_DIR"/bin/ct_unwrapped
mv "$DIST_DIR"/bin/ct-legacy "$DIST_DIR"/bin/ct-legacy_unwrapped

cat << 'EOF' > "${DIST_DIR}"/bin/ct
cat << 'EOF' > "${DIST_DIR}"/bin/ct-legacy
#!/usr/bin/env bash

export HERE=$(dirname $(dirname "$0"))

export CODETRACER_RUBY_RECORDER_PATH="${HERE}/codetracer-ruby-recorder/gems/codetracer-pure-ruby-recorder/bin/codetracer-pure-ruby-recorder"

exec ${HERE}/bin/ct_unwrapped "$@"
exec ${HERE}/bin/ct-legacy_unwrapped "$@"
EOF

chmod +x "${DIST_DIR}"/bin/ct
chmod +x "${DIST_DIR}"/bin/ct-legacy

# Enable the installation prompt. Extra argument to be compatible with FreeBSD coreutils
sed -i "" "s/skipInstall.*/skipInstall: false/g" "$DIST_DIR/config/default_config.yaml"
4 changes: 2 additions & 2 deletions non-nix-build/build_mac_app.sh
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,6 @@ cp "$DIST_DIR"/../Resources/CodeTracer.icns "$(realpath MacOS/node_modules)"/ele
# macOS uses core utils from FreeBSD so the additional "" is needed to execute this sed call.
#
# This sed call is needed because even though we replaced the entire plist file, the CodeTracer icon will not be displayed correctly
# in the auto-generated about menu, if the correct executable isn't listed here. If it was left as "bin/ct" a big disabled icon would
# in the auto-generated about menu, if the correct executable isn't listed here. If it was left as "bin/ct-legacy" a big disabled icon would
# be overlayed on top of the app icon
sed -i "" "s/\<string\>bin\/ct/\<string\>Electron/g" "$(realpath MacOS/node_modules)"/electron/dist/Electron.app/Contents/Info.plist
sed -i "" "s/\<string\>bin\/ct-legacy/\<string\>Electron/g" "$(realpath MacOS/node_modules)"/electron/dist/Electron.app/Contents/Info.plist
10 changes: 5 additions & 5 deletions non-nix-build/build_with_nim.sh
Original file line number Diff line number Diff line change
Expand Up @@ -35,15 +35,15 @@ nim -d:release \
-d:ctEntrypoint \
--nimcache:nimcache \
-d:ctmacos \
--out:"$DIST_DIR/bin/ct" c ./src/ct/codetracer.nim
--out:"$DIST_DIR/bin/ct-legacy" c ./src/ct-legacy/codetracer.nim

install_name_tool \
-add_rpath "@executable_path/../../Frameworks" \
"${DIST_DIR}/bin/ct"
"${DIST_DIR}/bin/ct-legacy"

install_name_tool -add_rpath "@loader_path" "${DIST_DIR}/bin/ct"
install_name_tool -add_rpath "@loader_path" "${DIST_DIR}/bin/ct-legacy"

codesign -s - --force --deep "${DIST_DIR}/bin/ct"
codesign -s - --force --deep "${DIST_DIR}/bin/ct-legacy"

nim -d:release \
-d:asyncBackend=asyncdispatch \
Expand All @@ -60,7 +60,7 @@ nim -d:release \
-d:ctEntrypoint \
--nimcache:nimcache \
-d:ctmacos \
--out:"$DIST_DIR/bin/db-backend-record" c ./src/ct/db_backend_record.nim
--out:"$DIST_DIR/bin/db-backend-record" c ./src/ct-legacy/db_backend_record.nim

install_name_tool \
-add_rpath "@executable_path/../../Frameworks" \
Expand Down
3 changes: 1 addition & 2 deletions resources/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<string>CodeTracer</string>

<key>CFBundleExecutable</key>
<string>bin/ct</string>
<string>bin/ct-legacy</string>

<key>CFBundleIconFile</key>
<string>CodeTracer.icns</string>
Expand Down Expand Up @@ -83,4 +83,3 @@
<string>Copyright (c) 2025 Metacraft Labs Ltd.</string>
</dict>
</plist>

3 changes: 1 addition & 2 deletions resources/codetracer.desktop
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
[Desktop Entry]
Version=1.0
Type=Application
Exec=ct
Exec=ct-legacy
Name=CodeTracer
Name[ja]=コードトレーサ始める
Comment=A user-friendly time-travelling debugger designed to support a wide range of programming languages.
Icon=codetracer
Categories=Development
Keywords=codetracer;time-travelling;debugger;omniscient;noir;nargo;tracing
StartupWMClass=CodeTracer

4 changes: 4 additions & 0 deletions src/Tuprules.tup
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,10 @@ export RUSTUP_HOME
CARGO_TARGET_DIR=/tmp/codetracer/backend_manager_target \
cargo build --release && \
cp /tmp/codetracer/backend_manager_target/release/backend-manager %o |> %o
!rust_cargo_ct = |> \
CARGO_TARGET_DIR=/tmp/codetracer/ct_target \
cargo build --release && \
cp /tmp/codetracer/ct_target/release/ct %o |> %o
!debug_rust_cargo_db_backend = |> \
CARGO_TARGET_DIR=/tmp/codetracer/db_backend_target \
cargo build && \
Expand Down
20 changes: 10 additions & 10 deletions src/common/install_utils.nim
Original file line number Diff line number Diff line change
Expand Up @@ -103,16 +103,16 @@ proc installCodetracerOnPath*(codetracerExe: string): Result[void, string] {.rai
execPath = getEnv("APPIMAGE")

try:
if not fileExists(binDir / "ct"):
if not fileExists(binDir / "ct-legacy"):
echo fmt2"Creating symlink to {execPath} in {binDir}"
createSymlink(execPath, binDir / "ct")
createSymlink(execPath, binDir / "ct-legacy")

elif isSymlinkDangling(binDir / "ct"):
elif isSymlinkDangling(binDir / "ct-legacy"):
# Try and clean up the installation
removeFile(binDir / "ct")
createSymlink(execPath, binDir / "ct")
removeFile(binDir / "ct-legacy")
createSymlink(execPath, binDir / "ct-legacy")
else:
echo fmt2"{binDir}/ct already exists and is not dangling"
echo fmt2"{binDir}/ct-legacy already exists and is not dangling"
except OSError as e:
return err "Failed to put CodeTracer on the PATH: " & e.msg

Expand All @@ -126,13 +126,13 @@ proc installCodetracerOnPath*(codetracerExe: string): Result[void, string] {.rai

try:
createDir(shellLaunchersDir)
let ctLauncherPath = shellLaunchersDir / "ct"
writeFile(ctLauncherPath, slurpShellIntegrationFile "shell-launchers/ct")
let ctLauncherPath = shellLaunchersDir / "ct-legacy"
writeFile(ctLauncherPath, slurpShellIntegrationFile "shell-launchers/ct-legacy")
setFilePermissions(ctLauncherPath, {fpUserExec, fpGroupExec, fpOthersExec,
fpUserRead, fpGroupRead, fpOthersRead,
fpUserWrite})
except CatchableError as err:
return err "Failed to create the ct shell launcher: " & err.msg
return err "Failed to create the ct-legacy shell launcher: " & err.msg

let shellPath = getEnv("SHELL", "/bin/bash")

Expand Down Expand Up @@ -253,7 +253,7 @@ when defined(linux):
# ran the `install` command

echo fmt"Replacing exec field with {execPath}"
contents = contents.replace("Exec=ct", fmt"Exec={execPath}")
contents = contents.replace("Exec=ct-legacy", fmt"Exec={execPath}")

let desktopFile = desktopFileDir / "codetracer.desktop"

Expand Down
4 changes: 2 additions & 2 deletions src/common/paths.nim
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ let
cTraceSourcePath* = linksPath / "src" / "trace.c"
consoleExe* = linksPath / "bin" / "console"
# (additional note: it is a workaround for dev/some cases: TODO think more)
codetracerExe* = codetracerExeDir / "bin" / "ct"
codetracerExe* = codetracerExeDir / "bin" / "ct-legacy"
bashExe* = linksPath / "bin" / "bash"
taskProcessExe* = linksPath / "bin" / "task_process"
python3Path* = linksPath / "bin" / "python3"
Expand Down Expand Up @@ -139,7 +139,7 @@ let
nodeModulesPath* = linksPath / "node_modules"

codetracerTestDir* = codetracerInstallDir / "src" / "tests"
codetracerNixResultExe* = codetracerInstallDir / "result" / "bin" / "ct"
codetracerNixResultExe* = codetracerInstallDir / "result" / "bin" / "ct-legacy"
codetracerTestBuildDir* = codetracerExeDir / "tests"
programDir* = codetracerTestDir / "programs"
recordDir* = codetracerTestDir / "records"
Expand Down
File renamed without changes.
7 changes: 7 additions & 0 deletions src/ct-legacy/Tupfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
include_rules

: codetracer.nim |> !codetracer |> ../bin/codetracer_depending_on_env_vars_in_tup
: ct_wrapper.nim |> !nim_c |> ../bin/ct-legacy
# TODO think if we want explicitly both
# : ct_wrapper.nim |> !nim_c |> ../bin/codetracer
: db_backend_record.nim |> !codetracer |> ../bin/db-backend-record
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion src/ct/codetracer.nim → src/ct-legacy/codetracer.nim
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import
launch/[ launch ],
codetracerconf, confutils,
version
../common/version

try:
if not eventuallyWrapElectron():
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Loading
Loading