The entry inspect
The source src/modules/system/inspect built with the setting DRAWING_THROUGH_MODULE=true. The text after this paragraph is the comment of that source.
A developer tool: the memory and the execution of one process, live .
What it is for. A reader who wants to see how one process runs: where its memory is, which modules it holds, what its threads do now, and where it stopped if it faulted. It shows that a developer tool needs no special access: it reads the reports of the kernel with a grant, the same reports that any holder of the machine with Inspect can ask for, and it changes nothing.
What a reader sees. Start it from the start menu, or with start("inspect") in the console. The window has a list of the processes at the left. The input chooses one: Up and Down, a click, or letters that filter the list. The window then shows, for that process:
- its address space, as one band scaled by address and as a table: each mapping, its kind (module code, module data, thread area, device, shared memory...), its pages and the pages that have a page frame;
- its modules: the name in the boot image, the hash, the base, the size;
- its threads, with the state of the scheduler: the processor, the weight, the virtual time, the lag, the word wait;
- the stop report of a process that stopped on a fault, each frame as its procedure and its source line when the debug image names it, else as
module + offset.
A sample of the reports comes each 250 ms; a value that changed is drawn in the color of the boot program for one sample. Space freezes the sample. Tab shows the bytes of the memory of this process itself (hex.odin). The log gets inspect: ok, <count> processes; ... at the start.
Its grants: Inspect (the machine handle that reads the reports), Image (the names of the modules and their exports), Debug_Image (the names of the procedures and the source lines), and Serve (its exports). Nothing more: it reads reports, it changes nothing, and it reads no byte of another process.
Its exports (exports.odin) give the same facts as tables, to a caller that acts for the principal: mappings, threads and modules, each for one process by its name.
connect("inspect")
inspect.threads("console")
What it does not show. The bytes of another process: no report gives them, and the system has no right that reads them. A process is chosen by its slot and its serial, not by its name, in the window; the exports take a name, and of two processes with one name they give the one in the lowest slot. The design is in Developer tools: The process inspect, and "What inspect does not read: the bytes of another process".
See: Developer tools
inspect module with an entry
- Hash
ecd6293c42a7e69eabd93471ead02c15e7d0b999fc4b72496d8df47e00a5787f- Size
263987 bytes- Exports
3- Imports
1- Imported by
0- License
- MIT
A developer tool: the memory and the execution of one process, live
| Fact | Value |
|---|---|
| Kind | Modules with an entry |
| Source | src/modules/system/inspect |
| Boot image | yes: in the boot image, 263987 bytes in this build |
| Build settings |
|
| Imports | |
| Imported by | none |
Neighbours
What it imports, at its left, and what imports it, at its right: the part of the module graph that touches it.
Exports
| Export | What it does |
|---|---|
mappings(process: Text) -> Table(Mapping) | gives one row for each mapping of the process with this name, in the order of the addresses: the address, the module and the offset when a module holds it, the pages, the pages with a page frame, the kind, the rights, the memory object and how many handles and mappings name it |
threads(process: Text) -> Table(Thread) | gives one row for each thread of the process with this name: its thread area, its state, the processor that runs it and its home queue, its weight and its request, its virtual time and its lag, its processor time, the words of its word wait and the end of its wait |
modules(process: Text) -> Table(Module) | gives one row for each module record of the process with this name: the name in the boot image, the hash, the base, the size and the writer |
entry() | opens the window of inspect and runs its loop: one sample of the reports each 250 ms, until the process is stopped |
mappings
mappings(process: ) -> ()
mappings gives one row for each mapping of the process with this name, in the order of the addresses: the address, the module and the offset when a module holds it, the pages, the pages with a page frame, the kind, the rights, the memory object and how many handles and mappings name it. The result is the count of rows, or a negative number with an error record. The error kinds: No_Grant (-1, the caller does not act for the principal); Absent (-2, no process has this name); Absent (-3, a new process took the slot during the call, three times).
What it is for. It shows where the memory of a process is and what holds it: the code and the data of each module, the thread areas, the device memory, the memory that two processes share. A caller compares two rows by object: one serial is one memory object.
Parameter: process, the name of a process that runs, as processes() lists it (at most 31 bytes). If two processes have that name, the one in the lowest slot answers.
Grant: the caller must act for the principal: the facts are of another process, and a process sees no other process.
A row (Mapping): address; module and offset when a module record holds the address; pages; present, the pages with a page frame; kind; rights, as r, w, x or -; object, the serial of the memory object; names, the handles and mappings that name it in all processes.
Errors:
No_Grant(-1): the caller does not act for the principal.Absent(-2): no process has this name, or the name has 32 bytes or more.Absent(-3): a new process took the slot between the two reports of the call, three times in a row.
connect("inspect")
where(inspect.mappings("console"), kind = "shared")
process:
()- When it fails
- a negative result, and the error record
src/modules/system/inspect/exports.odin:114
threads
threads(process: ) -> ()
threads gives one row for each thread of the process with this name: its thread area, its state, the processor that runs it and its home queue, its weight and its request, its virtual time and its lag, its processor time, the words of its word wait and the end of its wait. The result is the count of rows, or a negative number with an error record. The error kinds: No_Grant (-1, the caller does not act for the principal); Absent (-2, no process has this name).
Parameter: process, the name of a process that runs, as processes() lists it (at most 31 bytes). If two processes have that name, the one in the lowest slot answers.
Grant: the caller must act for the principal: the facts are of another process, and a process sees no other process.
A row (Thread): number, the thread area; state (ready, waiting, stopped, or created before its first run); processor, 1 + the processor that runs it, or 0; home, the processor of its run queue; weight and request; virtual and lag, the state of the fair strategies; time, milliseconds of processor time; words, the words of its word wait; deadline, the end of its wait in milliseconds since the start, or -1. The kernel reads these fields with no lock: each field is whole, two fields can come from two instants.
Errors: No_Grant (-1), the caller does not act for the principal; Absent (-2), no process has this name.
connect("inspect")
inspect.threads("console")
process:
()- When it fails
- a negative result, and the error record
src/modules/system/inspect/exports.odin:186
modules
modules(process: ) -> ()
modules gives one row for each module record of the process with this name: the name in the boot image, the hash, the base, the size and the writer. The result is the count of rows, or a negative number with an error record. The error kinds: No_Grant (-1, the caller does not act for the principal); Absent (-2, no process has this name).
A process holds one module, its own, until a loader puts more in it: the console after load, a process with imports. Each row is one module record of the kernel: the identity of the code that the process runs. A row with the writer starter is true: the process cannot change it, nor map other code at its addresses. A row with the writer process is what the process says of itself.
Parameter: process, the name of a process that runs, as processes() lists it (at most 31 bytes). If two processes have that name, the one in the lowest slot answers.
Grant: the caller must act for the principal: the facts are of another process, and a process sees no other process.
A row (Module): name, the name in the boot image, or empty when no module of the boot image has the hash; hash, the BLAKE3 hash in hex; base and size, its place in the address space; writer, starter or process.
Errors: No_Grant (-1), the caller does not act for the principal; Absent (-2), no process has this name.
connect("inspect")
inspect.modules("console")
process:
()- When it fails
- a negative result, and the error record
src/modules/system/inspect/exports.odin:245
entry
entry()
entry opens the window of inspect and runs its loop: one sample of the reports each 250 ms, until the process is stopped.
What it sets up: a window of WIDTH by HEIGHT pixels; the machine handle with Inspect; the boot image and the debug image, read-only; the service ring of its exports; the hex view of its own memory. The first process that it shows is inspect itself. It writes inspect: ok, <count> processes; up, down, letters: choose; ... on the log.
The loop. It draws the window, then waits for an event of the window or a call until the time of the next sample. A key or a click in the list changes the chosen process and draws again at once. A call runs between two samples. At the time of the sample it takes a new sample, or, when Space froze the sample, it only reads the list of the processes again.
The stop: with no window, it stops with Failed. Else it never returns: stop("inspect"), or the close button of its window, ends it.
- Form
- The entry of the module: one parameter, an address, fixed by the contract.
src/modules/system/inspect/main.odin:417
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
| What | Value | As the root service says |
|---|---|---|
| Grants | A developer tool: it reads the reports of the machine and the names of the modules, and serves the same facts. See: Developer tools | |
| Other terms of its start grant set | none | |
| Budget that it asks for |
| The least budget of 2048 pages, in which it ran before it stated its window, less that window at the scale 1 (1375 pages): its module, its stack, its tables and its glyph memory. The tool counts the window at the largest scale. See: Module contract: The budget that a module asks for |
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).
Text wire form
A wire form of the module contract: one word of a call. The address of a slice record {address, count} of UTF-8 bytes.
Table wire form
A wire form of the module contract: one word of a call. Records of one description that follow each other (a table).
Mapping record of a module
A record of the module inspect: 104 bytes, aligned on 8 bytes, 4 bytes of padding.
addressi6408 bytesmoduleText(32)832 bytesoffseti64408 bytespagesi64488 bytespresenti64568 byteskindText(16)6416 bytesrightsText(4)804 bytes- padding844 bytes
objecti64888 bytes
and 1 more
Error_Record record of a module
A record of the module inspect: 56 bytes, aligned on 8 bytes, 0 bytes of padding.
kindi6408 bytesuniti6488 bytesoperationi64168 bytesargumenti64248 bytesvaluei64328 byteslimiti64408 bytesfoundi64488 bytes
Thread record of a module
A record of the module inspect: 88 bytes, aligned on 8 bytes, 0 bytes of padding.
numberi6408 bytesstateText(8)88 bytesprocessori64168 byteshomei64248 bytesweighti64328 bytesrequesti64408 bytesvirtuali64488 byteslagi64568 bytes
and 3 more
Module record of a module
A record of the module inspect: 120 bytes, aligned on 8 bytes, 0 bytes of padding.
nameText(32)032 byteshashText(64)3264 bytesbasei64968 bytessizei641048 byteswriterText(8)1128 bytes
