Skip to content

Commit 063338b

Browse files
authored
Pass PHP script as argument (#63)
* POC php process running * Show PHP process output * Drain * Switch channels * Failing test for lines * Lines * Fix line ending * Show stdout and stderr * Extract crappy code to own module * OK * Clippy * Refactor * Support restarting * Show error when process terminates abnormally * Clippy * Fix channel names * Refactor event loop to use tokio * Do NOT inherit stdin in sub-process * Add event stream deps * Scroll lines * "Safely" render ANSI output * Kill io_task * Fix clippys * Do not use Vec * Snapshot rewind * Update * Show process out on listen screen * Clipyp * Clippy * Handle error * Refactor error handling in process manager * Refactorings and bug fixes * Update test * FIx clippy * Blinken lights channels * Allow filtering the context with a global shortcut * Encapsulate notfication handling * show all notifications * Fix order of inline variables * Do not issue Xdebug commands when xdebug is locked * Improve notifications * Avoid out-of-bounds error when ntifications scroll of end of screen * Do not allow process to be restarted when waiting for xdebug avoid freeze * Avoid deadlock * Avoid deadlock with running execution continuation * Bind keys in listen mode * Clippy fixes * Update README * Fix div
1 parent 2d2dc9e commit 063338b

26 files changed

Lines changed: 3815 additions & 291 deletions

CHANGELOG.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,21 @@ CHANGELOG
44
main
55
----
66

7+
### Features
8+
9+
- Process control - launch, restart and monitor a process.
10+
711
### Improvements
812

913
- Show window "titles" at bottom of window
1014
- Ability to disconnect from the server (via. "d")
15+
- Channel pane replaces eval pane.
16+
- Show multiple notifications.
17+
18+
### Bug fixes
19+
20+
- Fix order of inline variables.
21+
- Fixed deadlocks.
1122

1223
0.2.0
1324
-----

Cargo.lock

Lines changed: 169 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,15 @@ edition = "2021"
66
[build-dependencies]
77
cc="*"
88
[dependencies]
9+
ansi-to-tui = "7.0.0"
910
anyhow = "1.0.97"
1011
base64 = "0.22.1"
1112
better-panic = "0.3.0"
1213
clap = { version = "4.5.35", features = ["derive"] }
13-
crossterm = "0.28.1"
14+
crossterm = { version = "0.28.1", features = ["event-stream"] }
15+
futures = "0.3.31"
1416
log = "0.4.27"
17+
ordered_hash_map = "0.5.0"
1518
pretty_assertions = "1.4.1"
1619
ratatui = "0.29.0"
1720
serde = { version = "1.0.219", features = ["derive"] }

README.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ Interactive [Xdebug](https://xdebug.org) step-debugging client for your terminal
1111
- **Jump the stack**: jump up and down the stack.
1212
- **Vim-like motions**: Typing `100n` will repeat "step into" 100 times.
1313
- **Inline values**: Show variable values inline with the source code.
14+
- **Process control**: Launch, monitor and restart the process being debugged.
1415

1516
## Installation
1617

@@ -22,11 +23,26 @@ Interactive [Xdebug](https://xdebug.org) step-debugging client for your terminal
2223
- `--log`: Debug log to file.
2324
- `--listen`: Listen on an alternative address (defaults to `0.0.0.0:9003`).
2425

26+
## Usage
27+
28+
To listen for an incoming Xdebug connection on the default port:
29+
30+
```bash
31+
$ debug-tui
32+
```
33+
34+
Launch and manage the process to be debugged:
35+
36+
```bash
37+
$ debug-tui -- php path/to/script.php
38+
```
39+
2540
## Key bindings
2641

2742
Prefix with number to repeat:
2843

2944
- `r` run
45+
- `R` restart process if one was provided
3046
- `n` next / step into
3147
- `N` step over
3248
- `p` previous (switches to history mode if in current mode)

debug.loh

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
[00:00:00.000] (7ffa3507f440) INFO Handling event Startup
2+
[00:00:00.000] (7ffa2edf66c0) TRACE registering event source with poller: token=Token(140711450119680), interests=READABLE | WRITABLE
3+
[00:00:00.648] (7ffa34dff6c0) TRACE registering event source with poller: token=Token(140712523862528), interests=READABLE | WRITABLE
4+
[00:00:00.648] (7ffa3507f440) INFO Handling event ClientConnected(PollEvented { io: Some(TcpStream { addr: 127.0.0.1:9003, peer: 127.0.0.1:47680, fd: 14 }) })
5+
[00:00:00.648] (7ffa3507f440) DEBUG [dbgp] << <?xml version="1.0" encoding="iso-8859-1"?>
6+
<init xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" fileuri="file:///home/daniel/www/dantleech/debug-tui/php/test.php" language="PHP" xdebug:language_version="8.4.3" protocol_version="1.0" appid="2532590" xdebug:ctrl_socket="xdebug-ctrl.2532590"><engine version="3.4.1"><![CDATA[Xdebug]]></engine><author><![CDATA[Derick Rethans]]></author><url><![CDATA[https://xdebug.org]]></url><copyright><![CDATA[Copyright (c) 2002-2025 by Derick Rethans]]></copyright></init>
7+
[00:00:00.648] (7ffa3507f440) INFO setting feature max_depth to "4"
8+
[00:00:00.648] (7ffa3507f440) DEBUG [dbgp] >> feature_set -i 0 -n max_depth -v 4
9+
[00:00:00.648] (7ffa3507f440) DEBUG [dbgp] << <?xml version="1.0" encoding="iso-8859-1"?>
10+
<response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" command="feature_set" transaction_id="0" feature="max_depth" success="1"></response>
11+
[00:00:00.648] (7ffa3507f440) INFO setting feature extended_properties to "1"
12+
[00:00:00.648] (7ffa3507f440) DEBUG [dbgp] >> feature_set -i 1 -n extended_properties -v 1
13+
[00:00:00.648] (7ffa3507f440) DEBUG [dbgp] << <?xml version="1.0" encoding="iso-8859-1"?>
14+
<response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" command="feature_set" transaction_id="1" feature="extended_properties" success="1"></response>
15+
[00:00:00.649] (7ffa3507f440) DEBUG [dbgp] >> source -i 2 -f file:///home/daniel/www/dantleech/debug-tui/php/test.php
16+
[00:00:00.652] (7ffa3507f440) DEBUG [dbgp] << <?xml version="1.0" encoding="iso-8859-1"?>
17+
<response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" command="source" transaction_id="2" encoding="base64"><![CDATA[PD9waHAKCiRhcnJheSA9IFs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JsaWMgZnVuY3Rpb24gbWV0aG9kMSgpIHsKICAgIH0KICAgIHB1YmxpYyBmdW5jdGlvbiBtZXRob2QyKCkgewogICAgfQogICAgcHVibGljIGZ1bmN0aW9uIG1ldGhvZDMoKSB7CiAgICB9Cn0KCg==]]></response>
18+
[00:00:06.466] (7ffa3507f440) INFO Handling event Input(KeyEvent { code: Char('r'), modifiers: KeyModifiers(0x0), kind: Press, state: KeyEventState(0x0) })
19+
[00:00:06.478] (7ffa3507f440) INFO Handling event Run
20+
[00:00:06.478] (7ffa34dff6c0) INFO Running iteration 0/1
21+
[00:00:06.478] (7ffa34dff6c0) DEBUG [dbgp] >> run -i 3
22+
[00:00:06.478] (7ffa2eff76c0) DEBUG [dbgp] << <?xml version="1.0" encoding="iso-8859-1"?>
23+
<response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" command="run" transaction_id="3" status="stopping" reason="ok"></response>
24+
[00:00:06.481] (7ffa3507f440) INFO Handling event UpdateStatus(Stopping)
25+
[00:00:06.484] (7ffa3507f440) INFO Handling event Disconnect
26+
[00:00:06.484] (7ffa3507f440) TRACE deregistering event source from poller
27+
[00:00:06.487] (7ffa3507f440) INFO Handling event ChangeSessionViewMode(History)
28+
[00:00:09.778] (7ffa3507f440) INFO Handling event Quit
29+
[00:00:09.779] (7ffa347fc6c0) TRACE deregistering event source from poller

0 commit comments

Comments
 (0)