modus
Menu
On this page

The entry debugged

The debugger of a process, as the kernel gives it. The design: Architecture: The debugger of a process.

A process with a handle of another process that has the right Debug becomes its debugger. This process is the debugger of children that it starts itself (this module, with a role): the process that creates a process has the right Debug on the handle that the creation gave. Each case checks one part of the contract:

  • The attach, and the refusals: a write of breakpoints on a thread that is not held, a handle with no Debug, a breakpoint at an address of the kernel, a write of breakpoints by a process on its own thread.
  • An execute breakpoint at a procedure of the child, the registers at the stop, a single step, a data breakpoint, and the end of the child with its own code when the breakpoints are removed.
  • Read_Memory: a value of the child, an address of the kernel, a page that the child does not map, a thread handle with Inspect only.
  • The end of the debugging gives the process back: a detach while a thread is held; a second debugger that ends while the child waits at its breakpoint, that ends after a single step, that closes its handle, and whose handle is revoked.
  • A breakpoint belongs to one thread: another thread of the child runs through the same procedure.
  • A stop of the child on its own thread stays when the debugger, which stopped that thread too, detaches.
  • A data breakpoint on memory that the kernel copies, and one that a load of the stack selector holds until a syscall: the kernel does not fault.
  • A full ring of the debugger: the breakpoint is lost for the debugger, and the child goes on.

What it is for. It is the test of the four additions of the kernel for a debugger: the right Debug, the delivery of the debug exceptions to the debugger, the breakpoints of a thread, and the read of the memory of a process. The commands of the console come on top of the same contract.

Start: start("debugged") in the console. The parent starts each child from the boot image.

Grants, as the root service gives them:

  • Image: the boot image, read-only, to start the children from it.
  • The log with Give: one child writes a line of the log from a buffer that its debugger watches.

What a reader sees: the log has one line for each case, which ends with "as it must", then "debugged: ok, 24 cases: a debugger holds, reads and steps one process, and its end gives the process back", or "debugged: failed: N cases of 24". The process has no window.

The design:.

See: Developer tools: The debugger: the design

debugged module with an entry

Hash
677fe8ffdb0ccd73f5a63e4e455f8a73b4caad624d69e88f3785047797a91224
Size
147456 bytes
Exports
0
Imports
0
Imported by
0
License
MIT

The debugger of a process, as the kernel gives it

FactValue
KindModules with an entry
Sourcesrc/modules/demonstrations/debugged
Boot imageyes: in the boot image, 147456 bytes in this build
Build settingsnone: the defaults of the source
Importsnone
Imported bynone

Neighbours

It imports no module, and no module imports it. The module graph shows it with the other modules that have no edge.

Exports

ExportWhat it does
entry()The entry of debugged

entry

entry()

The entry of debugged. The context value VALUE_ROLE chooses the role:

  • Child: the process that is debugged (child_run).
  • Second_Debugger: a debugger whose debugging ends while its process waits at a breakpoint (second_debugger).
  • Parent (0, as the root service starts it): it takes its random generator and maps the boot image (no seed stops it with Refused, no image with Failed), runs the cases, writes the result on the log, and then waits for ever.

A role or a mode word that names no member stops it with Refused.

Form
The entry of the module: one parameter, an address, fixed by the contract.
Source
src/modules/demonstrations/debugged/main.odin:862

Read from the source of the module, as the build reads it to describe the exports (tools/modustool/build/describe.odin).

What the root service gives it

WhatValueAs the root service says
GrantsIt starts its children from the boot image, and is the debugger of each one: no grant of this service gives it that. A child writes one line from a buffer that its debugger watches.
Other terms of its start grant setlog_gives = true
Budget that it asks for
  • working memory pages 1860
  • pages of its threads 167
  • pages of the pictures of its window 0
  • pages of the module and its imports from the files of the build
  • processes 3
  • threads 6
Two children at a time, the process that is debugged and a second debugger, each with a budget of two threads; its main thread, and one thread of its own that only waits.

The start grant set is read from start_grant_sets in src/modules/system/root/start_grant_sets.odin. The stated budget is read from the constant MODULE_BUDGET of the source of the module (its line); the build adds the counted parts and writes the sum in the module (tools/modustool/build/budget_count.odin); the root service accepts it up to the largest budget of a process, and adds the limits of processor time and of log records (src/modules/system/root/budgets.odin).

second_debugger procedure of the package debugged

second_debugger :: proc "contextless" (ctx: ^system.Context) -> !

second_debugger attaches to the process of its context and stops its.

src/modules/demonstrations/debugged/main.odin:337