All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jan Kiszka <jan.kiszka@siemens.com>
To: xenomai@xenomai.org
Subject: [PATCH v2 0/3] Add callback-like mechanism before/after ptrace stops
Date: Thu,  8 Jul 2021 22:47:42 +0200	[thread overview]
Message-ID: <cover.1625777265.git.jan.kiszka@siemens.com> (raw)

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

-- 
2.26.2



             reply	other threads:[~2021-07-08 20:47 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-07-08 20:47 Jan Kiszka [this message]
2021-07-08 20:47 ` [PATCH v2 1/3] cobalt/kernel: Introduce XNDBGCTRL to block SIGINT/SIGSTOP Jan Kiszka
2021-07-08 20:47 ` [PATCH v2 2/3] cobalt: Add ptrace debugging helper interface Jan Kiszka
2021-07-08 20:47 ` [PATCH v2 3/3] testsuite/smokey/gdb: Add test cases for ptrace-based debugging helper Jan Kiszka
2021-07-12  9:45 ` [PATCH v2 0/3] Add callback-like mechanism before/after ptrace stops Jan Kiszka
2021-07-19 10:08 ` Richard Weinberger
2021-07-19 14:42   ` Jan Kiszka
2021-07-20  7:57     ` Richard Weinberger
2021-07-20  9:27       ` Jan Kiszka
2021-07-20  9:33         ` Richard Weinberger
2021-07-20 10:53           ` Jan Kiszka
2021-07-20 11:17             ` Richard Weinberger
2021-07-20 13:56               ` Philippe Gerum
2021-07-20 14:08                 ` Philippe Gerum
2021-07-20 19:22                 ` Richard Weinberger

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=cover.1625777265.git.jan.kiszka@siemens.com \
    --to=jan.kiszka@siemens.com \
    --cc=xenomai@xenomai.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.