Skip to content

Add callback-like mechanism before/after ptrace stops

Jan Kiszka xenomai 2 versions – In review

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v2 Latest3 patches 11 repliesIn review
  2. v13 patches 8 repliesSuperseded

Changes in v2 from the cover letter

- use 'bool' in patch 1
- reserve y2038 syscall range before adding new ones in patch 2
- ignore SIG32 (cancellation) in patch 3 to avoid failing tests

Patches in v2 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/3cobalt/kernel: Introduce XNDBGCTRL to block SIGINT/SIGSTOPinclude/cobalt/uapi/kernel/thread.h kernel/cobalt/posix/syscall.c+12 -10 replies
2/3cobalt: Add ptrace debugging helper interfaceinclude/cobalt/Makefile.am include/cobalt/ptrace.h include/cobalt/uapi/Makefile.am +7 more+281 -20 replies
3/3testsuite/smokey/gdb: Add test cases for ptrace-based debugging helpertestsuite/smokey/gdb/gdb.c+84 -20 replies

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v2 yet.

Read the v2 thread

Cover letter [PATCH v2 0/3] Add callback-like mechanism before/after ptrace stops

Changes in v2:
- use 'bool' in patch 1
- reserve y2038 syscall range before adding new ones in patch 2
- ignore SIG32 (cancellation) in patch 3 to avoid failing tests

This allows debugged real-time processes to execute crucial operations right before and after being stopped by a debugger. Such operations can include pausing physical devices and resuming them in an ordered manner so that no harm is caused to the outer world while debugging takes place and the real-time process can resume normally after the debugging session. It may also involve informing cooperating processes about the ongoing debug session.

The model chosen for this is dedicating a real-time thread to this task. This has the advantage of isolating the thread a bit from the debugged contexts and also avoids having to introduce any kind of asynchronous signaling mechanism. The helper thread will register itself with the core and then run a loop, waiting for the next stop or resume event. At the point the helper receives such an event, all other real-time threads in the process have been stopped or not yet resumed so that the helper cannot interact with them nor should wait for resources they may have locked. The helper thread may also migrate to secondary mode before releasing control, usually only after/before all time-sensitive operations are executed.

These patches have a very long (likely too long) internal history at Siemens, thus have shown to be useful at least for one of our use cases.

Jan

Jan Kiszka (3):
cobalt/kernel: Introduce XNDBGCTRL to block SIGINT/SIGSTOP
cobalt: Add ptrace debugging helper interface testsuite/smokey/gdb: Add test cases for ptrace-based debugging helper

 include/cobalt/Makefile.am          |  1 +
 include/cobalt/ptrace.h             | 37 +++++++++++
 include/cobalt/uapi/Makefile.am     |  1 +
 include/cobalt/uapi/kernel/thread.h |  1 +
 include/cobalt/uapi/ptrace.h        | 24 +++++++
 include/cobalt/uapi/syscall.h       |  3 +
 kernel/cobalt/posix/process.c       | 34 +++++++++-
 kernel/cobalt/posix/process.h       |  5 ++
 kernel/cobalt/posix/syscall.c       | 98 ++++++++++++++++++++++++++++-
 lib/cobalt/Makefile.am              |  1 +
 lib/cobalt/ptrace.c                 | 91 +++++++++++++++++++++++++++
 testsuite/smokey/gdb/gdb.c          | 86 ++++++++++++++++++++++++-
 12 files changed, 377 insertions(+), 5 deletions(-)
 create mode 100644 include/cobalt/ptrace.h
 create mode 100644 include/cobalt/uapi/ptrace.h
 create mode 100644 lib/cobalt/ptrace.c
Signature · 1 line
2.26.2