From: Luiz Augusto von Dentz <luiz.dentz@gmail.com>
To: linux-bluetooth@vger.kernel.org
Subject: [PATCH BlueZ v2 0/9] monitor: Search the frames with a pager
Date: Fri, 18 Sep 2026 12:13:59 -0400 [thread overview]
Message-ID: <20260918161408.2464981-1-luiz.dentz@gmail.com> (raw)
From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
A frame spans several lines, and what identifies one is spread between
its header and its contents: the header says which controller and when,
the body says what happened. Searching a trace a line at a time finds the
line reporting an error without any of that context.
This series makes the frames searchable as whole entries:
$ btmon # then press Ctrl-R
$ btmon -r hcidump.log
$ btmon -r hcidump.log --print0 | fzf --read0
Patches 1 to 3 are unrelated fixes noticed on the way: a channel leaks
its latency plots, the channel latency is the only one of the three not
reporting its deviation, and a count of control messages is printed with
a stray space at the end of the line.
Patch 4 sends the decoding output through one function so that a frame
can be observed as a whole. It is a pure redirection and the output is
unchanged.
Patch 5 separates the frames with a NUL when something is going to read
them as records, asked for by --print0 or by --read0 already being in
PAGER. Nothing is separated otherwise, so a pager reading lines and
redirected output are both untouched.
Patches 6 and 7 hand the frames seen so far to the pager on Ctrl-R while
capturing. The capture is never paused for this, as anything not read in
time is dropped by the kernel, and whatever arrives while the pager is up
is printed once it closes so the trace on the terminal has no gap.
Patches 8 and 9 use fzf when PAGER is not set and it is installed, since
it suits a trace far better than a plain pager, giving it --ansi, --read0
and --tac wherever it is used.
Recordings of both, which expire after a week:
reading a file https://asciinema.org/a/FEetnoeF5H6NNOmZ
a running capture https://asciinema.org/a/pGZpLhPlJFPyO4I3
The first one searches a 39 frame trace of two LE connections:
'ATT: every ATT frame 19 of 39
'SMP: the pairing exchange 4
'L2CAP: the signalling 2
'0x0025 every frame touching that GATT handle 5
'ATT: 'Write two terms, both must match 2
'ATT: !'Error everything ATT except the failures 15
'Handle\ 65 just the second connection 4
'#20 one frame, by its number 1
A leading quote is an exact match, a space separates terms that must all
match, and ! inverts one. Matching itself has no regex, but --delimiter
is one, and with a newline as the delimiter every line of a frame becomes
a field, so a search can be aimed at the header or at the contents:
whole frame header only body only
'Handle\ 64 21 21 0
'#20 1 1 0
'0x0025 5 0 5
'ATT: 19 0 19
A frame number or a connection only ever appears in the header, and a
GATT handle or a protocol only inside.
The second recording shows Ctrl-R during a capture: the frames seen so
far are handed over, the capture keeps running underneath, and what
arrived meanwhile is printed on return.
Changes in v2:
- Added the three unrelated fixes as patches 1 to 3. The trailing space
is its own patch so that patch 4 stays a pure redirection.
- Rewrapped the lines that went over 80 columns, which the rename to
display_printf() pushed past the limit.
- Dropped the NULL initialiser on the static output stream, removed the
trailing semicolon from the print_space() macro and used ARRAY_SIZE().
Luiz Augusto von Dentz (9):
monitor/analyze: Free the channel latency plots
monitor/l2cap: Report the channel latency deviation
monitor/analyze: Drop a trailing space before a newline
monitor: Route the decoding output through a single function
monitor: Separate the frames for a pager reading records
monitor: Hand the captured frames to the pager on Ctrl-R
doc/btmon: Document searching the frames
monitor: Prefer fzf as the pager when one is not set
doc/btmon: Document the pager choice
Makefile.tools | 1 +
doc/btmon.rst | 64 ++++++
monitor/analyze.c | 47 ++--
monitor/avctp.c | 68 +++---
monitor/control.c | 176 ++++++++-------
monitor/display.c | 139 +++++++++++-
monitor/display.h | 14 +-
monitor/find.c | 534 ++++++++++++++++++++++++++++++++++++++++++++++
monitor/find.h | 19 ++
monitor/l2cap.c | 41 ++--
monitor/lmp.c | 4 +-
monitor/main.c | 28 ++-
monitor/packet.c | 19 +-
monitor/rfcomm.c | 6 +-
tools/l2test.c | 10 +
15 files changed, 994 insertions(+), 176 deletions(-)
create mode 100644 monitor/find.c
create mode 100644 monitor/find.h
--
2.55.0
next reply other threads:[~2026-09-18 16:14 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-18 16:13 Luiz Augusto von Dentz [this message]
2026-09-18 16:14 ` [PATCH BlueZ v2 1/9] monitor/analyze: Free the channel latency plots Luiz Augusto von Dentz
2026-09-18 18:47 ` monitor: Search the frames with a pager bluez.test.bot
2026-09-18 16:14 ` [PATCH BlueZ v2 2/9] monitor/l2cap: Report the channel latency deviation Luiz Augusto von Dentz
2026-09-18 16:14 ` [PATCH BlueZ v2 3/9] monitor/analyze: Drop a trailing space before a newline Luiz Augusto von Dentz
2026-09-18 16:14 ` [PATCH BlueZ v2 4/9] monitor: Route the decoding output through a single function Luiz Augusto von Dentz
2026-09-18 16:14 ` [PATCH BlueZ v2 5/9] monitor: Separate the frames for a pager reading records Luiz Augusto von Dentz
2026-09-18 16:14 ` [PATCH BlueZ v2 6/9] monitor: Hand the captured frames to the pager on Ctrl-R Luiz Augusto von Dentz
2026-09-18 16:14 ` [PATCH BlueZ v2 7/9] doc/btmon: Document searching the frames Luiz Augusto von Dentz
2026-09-18 16:14 ` [PATCH BlueZ v2 8/9] monitor: Prefer fzf as the pager when one is not set Luiz Augusto von Dentz
2026-09-18 16:14 ` [PATCH BlueZ v2 9/9] doc/btmon: Document the pager choice Luiz Augusto von Dentz
2026-09-21 14:40 ` [PATCH BlueZ v2 0/9] monitor: Search the frames with a pager patchwork-bot+bluetooth
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260918161408.2464981-1-luiz.dentz@gmail.com \
--to=luiz.dentz@gmail.com \
--cc=linux-bluetooth@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox