modus
Menu
On this page

The entry debugger

The debugger service: the commands of a debugger, as exports.

A debugger stops a process where its author asks, shows its threads, its registers, its stack and its variables, and runs it one instruction at a time. This process is the one debugger of the system: the console, a window, and a developer on another machine through the service remote call the same exports, and each export gives a table of records, never text to parse.

What it is for. attach("clock") asks the root service for the handle of the process with the right Debug, on behalf of the caller. The root service decides: the caller must act for the principal whose session runs the process, and each grant of the process must be a grant that the caller holds itself. Then threads(), hold(1), stack(1), locals(1, 0), value(1, 0, "pair.next^.first"), break_at("fault::three"), step(1), continue_all() and detach() act on that process.

How it works. The service is the debugger of the process for the kernel: its main thread is the debug handler, so the breakpoints and the single steps of the process become fault records of this thread . It reads the threads and the module records of the process with Inspect, the registers and the memory with Thread_Control, and the names, the lines, the types and the variables in the debug object of each module, which it takes from the debug image by the hash of the module. The module of a disk process is not in the boot image: at the attach, the service reads its debug object from the store module_files, through a connection that reads only and that the root service gives with the debug access (disk_debug_object.odin). It writes no byte in the process: a breakpoint is a debug register of a thread.

A disk process that faulted. stop_report("visitor") needs no attach: the root service keeps the stop report of a disk process that stopped on a fault, and gives it with the same connection to the store. The export names each frame with the debug object of the module (stop_report.odin).

One process at a time. The service debugs one process, for one caller. A second attach while it does is refused with Full (Debugged_Processes). The debugging ends at detach(), when the caller disconnects or stops, when the grant debug of the caller is revoked, and when the process stops: the kernel then gives the process back each thread that the debugger held.

The record. record("clock") asks the root service to start a process held before its first instruction (Debug_Start), attaches to it, and asks the kernel to write each process input of it into an input history that this service makes and maps without Write; record_start() does the same for an attached process that did not run. replay_status(), replay_checkpoint(0), replay_step_back(1) and watch_back(4206608, 8) read the history, replay_start() runs the module again from it, and record_end() or the end of the debugging ends the record. The history stays for its caller after the debugging, until the next record (replay_wiring.odin).

Start: the root service starts it when a caller connects to debugger (connect("debugger") in the console, or the first command of the debugger there). It has no window.

Grants, as the root service gives them:

  • Serve: its exports.
  • Debugger: the commands Debug, Debug_Store and Debug_Start of the root ring, and no other.
  • Inspect: the thread report and the module report of a process.
  • Debug_Image: the debug objects.
  • Image: the name of each module, from its hash.

What a reader sees: the log has "debugger: serves its exports", then one line for each attach, each stop of a thread at a breakpoint or a watch, and each end of a debugging.

The design:.

See: Architecture: The debugger of a process, Developer tools: The debugger

debugger module with an entry

Hash
cc258ec9dbe9db0647c9f279e21b68d19f5c37e444c40f0fdd21076c05a92704
Size
253952 bytes
Exports
30
Imports
0
Imported by
0
License
MIT

The debugger service: the commands of a debugger, as exports

FactValue
KindModules with an entry
Sourcesrc/modules/system/debugger
Boot imageyes: in the boot image, 253952 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
attach(process: Text) -> Table(Attached)makes the service the debugger of the process with this name, for the caller, and gives one row: the process, its slot, its threads, its module records and how many of them have a debug object
detach() -> Table(Detached)ends the debugging of the process, and gives one row: the process, the breakpoints that the debugger had and the threads that it held
threads() -> Table(Thread_Row)gives one row for each thread of the process: its number, its state, and for a thread that the debugger holds or that stopped, its instruction with its module, its procedure, its file and its line
hold(thread: Integer) -> Table(Thread_Row)stops one thread of the process, and gives its row: the thread runs no instruction until release or continue_all
release(thread: Integer) -> Table(Thread_Row)lets one thread run again, and gives its row: a thread that hold stopped, or that a breakpoint, a watch or a step stopped
continue_all() -> Table(Thread_Row)lets each thread of the process run again, and gives one row for each thread
registers(thread: Integer) -> Table(Register_Row)gives one row for each register of a held thread: the 16 general registers, rip with its procedure and its line, and rflags with the flags that are set
stack(thread: Integer) -> Table(Frame_Row)gives one row for each frame of the stack of a held thread: the frame number, the module, the procedure and its offset, the file and the line, the frame pointer and the return address
locals(thread: Integer, frame: Integer) -> Table(Variable_Row)gives one row for each parameter and each local variable that is visible at the instruction of a frame: its name, its role, its type, its value by its type or "not readable", and its location
value(thread: Integer, frame: Integer, path: Text) -> Table(Value_Row)gives one variable or one global by a path, as one row for each of its parts: the fields of a record, the elements of an array or of a slice, or one row for a value with no part; each row has the name, the type, the value by its type and the address
source(thread: Integer, frame: Integer) -> Table(Source_Row)gives the source line of the instruction of a frame, as one row: the line number, the mark =>, the path of the file and the hash of its content at the build
break_at(place: Text) -> Table(Break_Row)sets an execute breakpoint at a procedure or at a source line, and gives one row for each breakpoint of the debugger
watch(place: Text, length: Integer) -> Table(Break_Row)sets a data breakpoint on the bytes that the process writes, and gives one row for each breakpoint of the debugger
breaks() -> Table(Break_Row)gives one row for each breakpoint of the debugger: its number, its kind (execute or write), its address, the bytes of a watch, and the text that named it
break_remove(number: Integer) -> Table(Break_Row)removes one breakpoint of the debugger from each thread of the process, and gives one row for each breakpoint that stays
step(thread: Integer) -> Table(Thread_Row)runs one instruction of a thread that is held or stopped, and gives its row at its new instruction
step_line(thread: Integer) -> Table(Thread_Row)runs a thread that is held or stopped until the source line of its instruction changes, and gives its row there
step_over(thread: Integer) -> Table(Thread_Row)runs a thread to the next line of its procedure, and gives its row there: a call of the line runs to its end
memory(place: Text, count: Integer) -> Table(Memory_Row)gives the bytes of the process from an address, sixteen in each row: the address, the bytes in hexadecimal, and their printable characters
events() -> Table(Event_Row)gives one row for each stop of a thread since the last call: the thread, the kind (breakpoint N, watch N, step, int3 or int1), and the instruction where the thread goes on, with its module, its procedure, its file and its line
wait_stop(milliseconds: Integer) -> Table(Event_Row)waits until a thread of the process stops, at most the given milliseconds and 3000, and gives the rows of events
record_start() -> Table(Record_Row)asks the kernel to record the process into an input history, and gives the row of the record
record_end() -> Table(Record_Row)ends the record of the process, and gives the row of the record with its end
record(process: Text) -> Table(Record_Row)starts a process held before its first instruction, makes the service its debugger, records it from that instruction, then lets it run, and gives the row of the record
replay_start() -> Table(Record_Row)runs the recorded module again from the input history of the caller, and gives the row of the record: the replay reaches the same instructions with the same values, or stops at the first difference
replay_status() -> Table(Record_Row)gives the row of the record: its state, its input points, its bytes, why it ended, and its checkpoints
replay_checkpoint(thread: Integer) -> Table(Checkpoint_Row)keeps a checkpoint of a held thread at the last input point of the history, and gives one row for each checkpoint
replay_step_back(points: Integer) -> Table(Step_Back_Row)gives the way back by some input points: the nearest checkpoint at or before the target point, and the input points that a replay runs from it
watch_back(address: Integer, size: Integer, before_point: Integer) -> Table(Watch_Back_Row)gives the last input of the history that wrote a byte of a range, and the checkpoint where a replay to that write starts
entry()The entry of the debugger service
stop_report(process: Text) -> Table(Stop_Frame_Row)gives one row for each frame of the stop report of a disk process that stopped on a fault: the module, the procedure and its offset, the file and the line

attach

attach(process: ) -> ()

attach makes the service the debugger of the process with this name, for the caller, and gives one row: the process, its slot, its threads, its module records and how many of them have a debug object.

The service asks the root service for the handle of the process with the right Debug, on behalf of the caller. The root service gives it when the caller acts for the principal whose session runs the process, and when each grant of the process is a grant that the caller holds itself; a service is refused for each caller.

For a disk process, the service also reads the debug object of its module from the store module_files, where it is beside the module file, through a connection that the root service gives with the debug access . A read that fails is one line of the log, and described does not count the module.

  • process: the name of a process that runs, at most 31 bytes.

Errors:

  • No_Grant, Acts_For_Principal (-1): the caller does not act for the principal.
  • Full, Debugged_Processes (-3): the service debugs a process already; detach() first.
  • (-4) the record of the root service: No_Grant, Debug_Access when a start grant of the process refuses, with 1 + its number in found (the sentence names it: "the grant Store of the process refuses it"); Absent, Processes when no process has the name; No_Answer when the root service did not answer; Refused with the status of the kernel.
  • Absent, Processes (-13): the process stopped during the attach.
  • Bad_Value, Processes (-14): two processes that run have this name and this module.
  • Too_Long, Bytes (-15): the name has no byte or more than 31.
connect("debugger")
debugger.attach("clock")

See: Developer tools: Who can debug which process, Module contract: The debug object of a disk process

Parameters
  • process:
Result
()
When it fails
a negative result, and the error record
Source
src/modules/system/debugger/exports.odin:275

detach

detach() -> ()

detach ends the debugging of the process, and gives one row: the process, the breakpoints that the debugger had and the threads that it held.

The kernel removes the breakpoints of each thread, clears the trap flag that the debugger wrote, takes back the stops that the debugger made, and resumes each thread that waited for its answer: the process runs again. The root service forgets the debug access.

Errors: No_Grant, Acts_For_Principal (-1); Absent, Debugged_Processes (-2), the caller attached to no process; Absent, Processes (-13), the process stopped: the debugging ended with it.

debugger.detach()
Parameters
none
Result
()
When it fails
a negative result, and the error record
Source
src/modules/system/debugger/exports.odin:381

threads

threads() -> ()

threads gives one row for each thread of the process: its number, its state, and for a thread that the debugger holds or that stopped, its instruction with its module, its procedure, its file and its line.

The state is ready or waiting for a thread that runs, held for a thread that hold stopped, and stopped for a thread that a breakpoint, a watch or a step stopped. The registers of a thread that runs cannot be read: its row has no instruction.

Errors: No_Grant, Acts_For_Principal (-1); Absent, Debugged_Processes (-2); Absent, Processes (-13).

debugger.threads()
Parameters
none
Result
()
When it fails
a negative result, and the error record
Source
src/modules/system/debugger/exports.odin:423

hold

hold(thread: ) -> ()

hold stops one thread of the process, and gives its row: the thread runs no instruction until release or continue_all.

  • thread: the number of a thread, as threads() gives it.

Errors: No_Grant, Acts_For_Principal (-1); Absent, Debugged_Processes (-2); Refused (-4), with the status of the kernel; Absent, Threads (-5), the process has no thread with this number; Absent, Processes (-13).

debugger.hold(0)
Parameters
  • thread:
Result
()
When it fails
a negative result, and the error record
Source
src/modules/system/debugger/exports.odin:443

release

release(thread: ) -> ()

release lets one thread run again, and gives its row: a thread that hold stopped, or that a breakpoint, a watch or a step stopped.

A thread that stopped at an execute breakpoint runs the instruction of the breakpoint once, and the breakpoint stays.

  • thread: the number of a thread that is held or stopped.

Errors: No_Grant, Acts_For_Principal (-1); Absent, Debugged_Processes (-2); Refused (-4); Absent, Threads (-5), no thread has this number; Absent, Held_Threads (-5), the thread runs; Absent, Processes (-13).

debugger.release(0)
Parameters
  • thread:
Result
()
When it fails
a negative result, and the error record
Source
src/modules/system/debugger/exports.odin:476

continue_all

continue_all() -> ()

continue_all lets each thread of the process run again, and gives one row for each thread.

It first writes the breakpoints of the debugger in each thread: a thread that the process made after the last breakpoint was set has none until then.

Errors: No_Grant, Acts_For_Principal (-1); Absent, Debugged_Processes (-2); Refused (-4); Absent, Processes (-13).

debugger.continue_all()
Parameters
none
Result
()
When it fails
a negative result, and the error record
Source
src/modules/system/debugger/exports.odin:503

registers

registers(thread: ) -> ()

registers gives one row for each register of a held thread: the 16 general registers, rip with its procedure and its line, and rflags with the flags that are set.

  • thread: the number of a thread that is held or stopped.

Errors: No_Grant, Acts_For_Principal (-1); Absent, Debugged_Processes (-2); Refused (-4); Absent, Threads or Held_Threads (-5); Absent, Processes (-13).

debugger.registers(0)
Parameters
  • thread:
Result
()
When it fails
a negative result, and the error record
Source
src/modules/system/debugger/exports.odin:535

stack

stack(thread: ) -> ()

stack gives one row for each frame of the stack of a held thread: the frame number, the module, the procedure and its offset, the file and the line, the frame pointer and the return address.

The frame 0 is the instruction of the thread. Each next frame is a caller: its line is the line of the call. The walk follows the frame pointers: the word at the frame pointer is the frame pointer of the caller, and the next word is the return address. It ends at a frame pointer that is 0, that is not a multiple of 8, that the process does not map, or that is not above the one before it, at a return address 0, and after 32 frames. At the first instruction of a procedure, the return address is read at the stack pointer: the procedure has no frame yet.

  • thread: the number of a thread that is held or stopped.

Errors: No_Grant, Acts_For_Principal (-1); Absent, Debugged_Processes (-2); Refused (-4); Absent, Threads or Held_Threads (-5); Absent, Processes (-13).

debugger.stack(0)
Parameters
  • thread:
Result
()
When it fails
a negative result, and the error record
Source
src/modules/system/debugger/exports.odin:602

locals

locals(thread: , frame: ) -> ()

locals gives one row for each parameter and each local variable that is visible at the instruction of a frame: its name, its role, its type, its value by its type or "not readable", and its location.

The variables are those of the procedure that holds the instruction of the frame, from the debug object of its module. A variable whose location the debug object does not give at this instruction is "not readable". In the frame of a caller only the frame pointer is known: a variable in another register is "not readable in this frame". The debugger computes no location that the debug object does not give.

  • thread: the number of a thread that is held or stopped.
  • frame: the number of a frame, as stack gives it.

Errors: No_Grant, Acts_For_Principal (-1); Absent, Debugged_Processes (-2); Refused (-4); Absent, Threads or Held_Threads (-5); Absent, Debug_Objects (-6), the module of the frame has no debug object; Absent, Stack_Frames (-7); Absent, Processes (-13).

debugger.locals(0, 0)
Parameters
  • thread:
  • frame:
Result
()
When it fails
a negative result, and the error record
Source
src/modules/system/debugger/exports.odin:730

value

value(thread: , frame: , path: ) -> ()

value gives one variable or one global by a path, as one row for each of its parts: the fields of a record, the elements of an array or of a slice, or one row for a value with no part; each row has the name, the type, the value by its type and the address.

The path is a name, then steps: .field, [number] and ^ (pair.next^.first, table[3], debug_target::rounds). The name is a variable that is visible at the instruction of the frame, else a global. A global is named with its package; a name with :: needs no held thread, and thread and frame are not read. The field of a pointer to a record is the field of the record; ^ follows a pointer.

A value by its type: an integer in decimal; a boolean; a float as its bits in hexadecimal, because the system has no code that writes a float in decimal; a pointer as an address, with the procedure or the global that holds it, and not followed; an enumeration by the name of its value; a record and an array in one line, bounded; a string by a second read of memory, at most 64 bytes; a slice as its count and its address. The table has at most 64 rows.

  • thread, frame: as for locals.
  • path: at most 160 bytes, and 8 steps.

Errors: No_Grant, Acts_For_Principal (-1); Absent, Debugged_Processes (-2); Refused (-4); Absent, Threads or Held_Threads (-5); Absent, Stack_Frames (-7); Absent, Readable_Variables (-8), no variable and no global has the name, or the variable is not readable at this instruction; Bad_Byte (-9), the text is not a path, with the offset of the byte; Bad_Value (-9), a step names nothing: value is the step from 1 and found says why (1 no such field, 2 not a record, 3 not an array, 4 an index past the end, 5 not a pointer, 6 a pointer of 0, 7 memory that the process does not map); Absent, Processes (-13); Too_Long, Bytes (-15).

debugger.value(0, 0, "pair.next^.first")
Parameters
  • thread:
  • frame:
  • path:
Result
()
When it fails
a negative result, and the error record
Source
src/modules/system/debugger/exports.odin:882

source

source(thread: , frame: ) -> ()

source gives the source line of the instruction of a frame, as one row: the line number, the mark =>, the path of the file and the hash of its content at the build.

The system holds no source text: the row says so in text. A reader that has the sources shows the line only from a file whose BLAKE3 hash is hash; the command modustool call does so on the host, from the repository.

  • thread, frame: as for locals.

Errors: No_Grant, Acts_For_Principal (-1); Absent, Debugged_Processes (-2); Refused (-4); Absent, Threads or Held_Threads (-5); Absent, Debug_Objects (-6); Absent, Stack_Frames (-7); Absent, Source_Places (-10), the instruction has no source line; Absent, Processes (-13).

debugger.source(0, 0)
Parameters
  • thread:
  • frame:
Result
()
When it fails
a negative result, and the error record
Source
src/modules/system/debugger/exports.odin:941

break_at

break_at(place: ) -> ()

break_at sets an execute breakpoint at a procedure or at a source line, and gives one row for each breakpoint of the debugger.

The place is the full name of a procedure (fault::three): the breakpoint is at its first instruction. Or it is a file and a line (src/modules/demonstrations/fault/main.odin:15): the breakpoint is at the lowest instruction of the first row of the line table with that file and that line. The debug objects of the modules of the process give both. A breakpoint is a debug register of each thread of the process, not a byte in the code: the debugger has four, for breakpoints and watches together.

  • place: at most 160 bytes.

Errors: No_Grant, Acts_For_Principal (-1); Absent, Debugged_Processes (-2); Refused (-4), the kernel refused the breakpoints; Absent, Debug_Objects (-6), no module of the process has a debug object; Absent, Source_Places (-10), no procedure and no line has this place; Full, Breakpoints (-11), the four breakpoints are in use; Absent, Processes (-13); Too_Long, Bytes (-15).

debugger.break_at("fault::three")
debugger.break_at("src/modules/demonstrations/fault/main.odin:15")
Parameters
  • place:
Result
()
When it fails
a negative result, and the error record
Source
src/modules/system/debugger/exports.odin:1037

watch

watch(place: , length: ) -> ()

watch sets a data breakpoint on the bytes that the process writes, and gives one row for each breakpoint of the debugger.

A thread that writes one of the bytes stops after the instruction of the write. An access that the kernel makes for the process is not seen.

  • place: an address in hexadecimal (0x403010) or in decimal, or the path of a global with its package (debug_target::rounds).
  • length: 1, 2, 4 or 8 bytes; the address is a multiple of it.

Errors: No_Grant, Acts_For_Principal (-1); Absent, Debugged_Processes (-2); Refused (-4); Absent, Readable_Variables (-8), no global has the name; Bad_Byte or Bad_Value (-9), the path; Full, Breakpoints (-11); Bad_Value (-12), a length that is not 1, 2, 4 or 8; Not_Multiple (-12), the address is not a multiple of the length; Absent, Processes (-13); Too_Long, Bytes (-15).

debugger.watch("debug_target::rounds", 8)
Parameters
  • place:
  • length:
Result
()
When it fails
a negative result, and the error record
Source
src/modules/system/debugger/exports.odin:1113

breaks

breaks() -> ()

breaks gives one row for each breakpoint of the debugger: its number, its kind (execute or write), its address, the bytes of a watch, and the text that named it.

Errors: No_Grant, Acts_For_Principal (-1); Absent, Debugged_Processes (-2); Absent, Processes (-13).

debugger.breaks()
Parameters
none
Result
()
When it fails
a negative result, and the error record
Source
src/modules/system/debugger/exports.odin:1144

break_remove

break_remove(number: ) -> ()

break_remove removes one breakpoint of the debugger from each thread of the process, and gives one row for each breakpoint that stays.

  • number: the number of a breakpoint, as breaks() gives it.

Errors: No_Grant, Acts_For_Principal (-1); Absent, Debugged_Processes (-2); Refused (-4); Absent, Breakpoints (-11), the number names no breakpoint; Absent, Processes (-13).

debugger.break_remove(0)
Parameters
  • number:
Result
()
When it fails
a negative result, and the error record
Source
src/modules/system/debugger/exports.odin:1163

step

step(thread: ) -> ()

step runs one instruction of a thread that is held or stopped, and gives its row at its new instruction.

The debugger writes the trap flag in the registers of the thread and lets it run: the processor stops it after one instruction. A thread that waits in the kernel runs its next instruction only when its wait ends: the export waits 1000 ms at most, then gives the row of a thread that runs, with pending 1, and the stop comes later as an event. The end of a step that the export waited for is its result, and no event.

  • thread: the number of a thread that is held or stopped.

Errors: No_Grant, Acts_For_Principal (-1); Absent, Debugged_Processes (-2); Refused (-4); Absent, Threads or Held_Threads (-5); Absent, Processes (-13).

debugger.step(0)
Parameters
  • thread:
Result
()
When it fails
a negative result, and the error record
Source
src/modules/system/debugger/exports.odin:1233

step_line

step_line(thread: ) -> ()

step_line runs a thread that is held or stopped until the source line of its instruction changes, and gives its row there.

It runs one instruction at a time, until the instruction has a source line that is not the line of the start, in the same file or in another: it enters a procedure that the line calls. A breakpoint or a watch that the thread reaches before the line changes ends the export there: the row is the row of the thread at the breakpoint, with pending 0, and the stop is also an event. The whole export has two bounds: 4096 instructions, and 2000 ms, because the debugged process chooses how long one of its instructions takes and the service serves each caller with one thread. At a bound the row has pending 1: the line did not change yet. When its state is stopped, call step_line again; when the thread runs (it waits in the kernel), its stop comes as an event.

  • thread: the number of a thread that is held or stopped.

Errors: as for step.

debugger.step_line(0)
Parameters
  • thread:
Result
()
When it fails
a negative result, and the error record
Source
src/modules/system/debugger/exports.odin:1271

step_over

step_over(thread: ) -> ()

step_over runs a thread to the next line of its procedure, and gives its row there: a call of the line runs to its end.

It is step_line, with one difference. When an instruction of the line calls a procedure, the debugger puts a breakpoint at the instruction after the call and lets the thread run to it: the thread does not stop inside the call. The breakpoint takes one of the four places of the breakpoints of the process, and leaves it when the thread is back. With no free place, the thread stops at the first line of the call, as with step_line.

A call that does not return within 2000 ms leaves the thread running, with pending 1 and the breakpoint in place: the stop at the return comes as an event, and the next step_over of the thread goes on from there. A breakpoint, a watch or a fault inside the call stops the thread there, as with no step, and the stop is an event.

  • thread: the number of a thread that is held or stopped.

Errors: as for step.

debugger.step_over(0)
Parameters
  • thread:
Result
()
When it fails
a negative result, and the error record
Source
src/modules/system/debugger/exports.odin:1452

memory

memory(place: , count: ) -> ()

memory gives the bytes of the process from an address, sixteen in each row: the address, the bytes in hexadecimal, and their printable characters.

The kernel reads only the pages that the process maps, can read and that have a frame: the table ends before the first page that is not so. The read changes nothing of the process.

  • place: an address in hexadecimal (0x403010) or in decimal, or the path of a global with its package.
  • count: 1 to 4096 bytes.

Errors: No_Grant, Acts_For_Principal (-1); Absent, Debugged_Processes (-2); Absent, Readable_Variables (-8); Bad_Byte or Bad_Value (-9), the path; Bad_Value (-12), a count that is not 1 to 4096; Bad_Address (-12), the process does not map the first byte; Absent, Processes (-13); Too_Long, Bytes (-15).

debugger.memory("debug_target::table", 64)
Parameters
  • place:
  • count:
Result
()
When it fails
a negative result, and the error record
Source
src/modules/system/debugger/exports.odin:1544

events

events() -> ()

events gives one row for each stop of a thread since the last call: the thread, the kind (breakpoint N, watch N, step, int3 or int1), and the instruction where the thread goes on, with its module, its procedure, its file and its line.

The end of a step that step or step_line waited for is the result of that export, and not an event; a step that ended after its export stopped waiting is an event of the kind step.

A thread that stopped waits for the debugger: release, step or continue_all lets it run. After an execute breakpoint the instruction is the one of the breakpoint, which did not run; after a watch and after a step it is the next one. The service keeps 32 stops.

Errors: No_Grant, Acts_For_Principal (-1); Absent, Debugged_Processes (-2); Absent, Processes (-13).

debugger.events()
Parameters
none
Result
()
When it fails
a negative result, and the error record
Source
src/modules/system/debugger/exports.odin:1634

wait_stop

wait_stop(milliseconds: ) -> ()

wait_stop waits until a thread of the process stops, at most the given milliseconds and 3000, and gives the rows of events.

A caller learns of a stop with this export, with no loop of events(): the call returns at once when a stop waits already, at the next stop, or with no row when the time ends. The service serves no other call while it waits, and the service remote ends a call and its connection after 5000 ms: so the wait is 3000 ms at most, whatever the caller gives. A caller that waits longer calls again, or reads events() after the line of the stop in the log.

  • milliseconds: the longest wait; 0 or less does not wait; more than 3000 is 3000.

Errors: as for events.

debugger.wait_stop(3000)
Parameters
  • milliseconds:
Result
()
When it fails
a negative result, and the error record
Source
src/modules/system/debugger/exports.odin:1660

record_start

record_start() -> ()

record_start asks the kernel to record the process into an input history, and gives the row of the record.

The service makes the history, 16 pages of its own memory, and the kernel writes into it each process input of the process: the completions of its kernel entries, the trapped reads of the cycle counter and of cpuid, and the changes of its point copies . The record needs the right Debug on the process, which the attach gave. The kernel records only a process that did not run yet, so an attach to a process that runs gets the refusal: record("clock") starts a process recorded from its first instruction. The kernel refuses a process that holds a device. An earlier history goes, with its checkpoints.

Errors: No_Grant, Acts_For_Principal (-1); Absent, Debugged_Processes (-2); (-4) the record of the kernel: State, Processes for a process that ran already, that the kernel cannot record, or that another recorder records; Refused with the status of the kernel for the history; Absent, Processes (-13); Full, Input_Histories (-16), a record of the process runs already.

debugger.record_start()

See: Record and replay of a process in the repository

Parameters
none
Result
()
When it fails
a negative result, and the error record
Source
src/modules/system/debugger/exports.odin:1698

record_end

record_end() -> ()

record_end ends the record of the process, and gives the row of the record with its end.

The kernel writes the end record into the input history and stops writing it. The history and its checkpoints stay until the next record, after the end of the debugging too, so replay_status, replay_step_back and replay_start still read it.

Errors: No_Grant, Acts_For_Principal (-1); Absent, Debugged_Processes (-2); (-4) the record of the kernel; Absent, Processes (-13); Absent, Input_Histories (-16), no record runs: none started, or the kernel ended it already.

debugger.record_end()
Parameters
none
Result
()
When it fails
a negative result, and the error record
Source
src/modules/system/debugger/exports.odin:1728

record

record(process: ) -> ()

record starts a process held before its first instruction, makes the service its debugger, records it from that instruction, then lets it run, and gives the row of the record.

It is attach, record_start and the start of the process in one step: the root service starts the module for the caller as start does, holds it before its first instruction, and gives the service the debug access under the rule of attach. So the kernel records each process input from the first instruction . Memory that the process and another process both write is recorded too: the other process writes only while the process is at an input point.

  • process: the name of a module of the boot image, at most 31 bytes.

Errors:

  • No_Grant, Acts_For_Principal (-1).
  • Full, Debugged_Processes (-3): the service debugs a process already; detach() first.
  • (-4) the record of the root service: those of attach and of start; Full, Debugged_Processes when the caller has a held process already. Or the record of the kernel: State, Processes for a process that the kernel cannot record; Refused with the status of the kernel.
  • Absent, Processes (-13): the process stopped before it ran.
  • Bad_Value, Processes (-14): two held processes have this name and this module.
  • Too_Long, Bytes (-15).
connect("debugger")
debugger.record("clock")

See: Record and replay of a process: The frequent tasks in the repository

Parameters
  • process:
Result
()
When it fails
a negative result, and the error record
Source
src/modules/system/debugger/exports.odin:1776

replay_start

replay_start() -> ()

replay_start runs the recorded module again from the input history of the caller, and gives the row of the record: the replay reaches the same instructions with the same values, or stops at the first difference.

The root service starts the module of the history again with no start grant, held before its first instruction; the kernel writes the context of the record into it, answers each kernel entry, each read of the cycle counter and each cpuid from the history, and stops it at the first difference. The row is replaying while it runs, then replayed, with why it ended and the input point of a divergence. A replay sends nothing to any process: a process that maps memory that it received from another process diverges at that map.

Errors: No_Grant, Acts_For_Principal (-1); (-4) the record of the root service or of the kernel; Absent, Processes (-13), the replay stopped before it ran; Absent, Input_Histories (-16), the caller has no history; Full, Input_Histories (-16), the record or a replay runs; Bad_Value, Input_Histories (-16), the module of the boot image is not the module of the history; Damaged, Input_Histories (-16).

debugger.replay_start()

See: Record and replay of a process: The replay in the repository

Parameters
none
Result
()
When it fails
a negative result, and the error record
Source
src/modules/system/debugger/exports.odin:1853

replay_status

replay_status() -> ()

replay_status gives the row of the record: its state, its input points, its bytes, why it ended, and its checkpoints.

A record that the kernel ended by itself shows ended, with its reason: the process stopped, the history is full, the bound of one stint, or a revocation. While the process runs, the row is the history at one moment. A replay shows replaying, then replayed with why it ended and the input point of a divergence. The history stays after the process and the debugging end, until the next record: no attach is needed to read it.

Errors: No_Grant, Acts_For_Principal (-1); Absent, Input_Histories (-16), the caller has no history; Damaged, Input_Histories (-16), the header of the history is not valid.

debugger.replay_status()
Parameters
none
Result
()
When it fails
a negative result, and the error record
Source
src/modules/system/debugger/exports.odin:1888

replay_checkpoint

replay_checkpoint(thread: ) -> ()

replay_checkpoint keeps a checkpoint of a held thread at the last input point of the history, and gives one row for each checkpoint.

The checkpoint keeps the input point, the bytes of the history before it, and the instruction and the stack pointer of the thread. It copies no memory yet: a replay from it runs the module again from its start to that point. The service keeps 32 checkpoints; a newer one takes the place of the oldest.

  • thread: the number of a thread that is held or stopped.

Errors: No_Grant, Acts_For_Principal (-1); Absent, Debugged_Processes (-2); Refused (-4), with the status of the kernel; Absent, Threads or Held_Threads (-5); Absent, Processes (-13); Absent, Input_Histories (-16), no record runs; Damaged, Input_Histories (-16); Exists, Checkpoints (-17), a checkpoint is at this input point already: the thread ran no kernel entry since.

debugger.replay_checkpoint(0)
Parameters
  • thread:
Result
()
When it fails
a negative result, and the error record
Source
src/modules/system/debugger/exports.odin:1917

replay_step_back

replay_step_back(points: ) -> ()

replay_step_back gives the way back by some input points: the nearest checkpoint at or before the target point, and the input points that a replay runs from it.

The replay is deterministic, so an earlier state is the state that a replay from the checkpoint reaches again after these points . The row is that plan; the debugger runs no replay yet.

  • points: the input points to go back, from 1 to the points of the history.

Errors: No_Grant, Acts_For_Principal (-1); Absent, Input_Histories (-16), the caller has no history; Damaged, Input_Histories (-16); Out_Of_Range, Input_Histories (-16), 0 points, or more than the history holds; Absent, Checkpoints (-17), no checkpoint is at or before the target point.

debugger.replay_step_back(1)

See: Record and replay of a process: The debugger: step back, and a watch back in the repository

Parameters
  • points:
Result
()
When it fails
a negative result, and the error record
Source
src/modules/system/debugger/exports.odin:1970

watch_back

watch_back(address: , size: , before_point: ) -> ()

watch_back gives the last input of the history that wrote a byte of a range, and the checkpoint where a replay to that write starts.

The history holds each byte that entered the process from outside: the changed ranges of its point copies and of its shared pages, and the bytes that a kernel entry copied into its memory. The service reads it and finds the last input point, before the given point, whose record wrote a byte of the range. A write by an instruction of the process is not an input and is not in the history: only a replay with a watch finds it, and the debugger runs no replay to a point yet.

  • address: the first byte of the range, in user memory.
  • size: 1 to 4096 bytes.
  • before_point: the input point before which the service looks; 0 for the whole history.

Errors: No_Grant, Acts_For_Principal (-1); Bad_Value, Bytes (-12), a size that is not 1 to 4096; Bad_Address, Bytes (-12), an address of 0, or a range past user memory; Absent, Input_Histories (-16), the caller has no history; Damaged, Input_Histories (-16), the header or a record of the history is not valid; Out_Of_Range, Input_Histories (-16), a point that is negative or past the history; Absent, Recorded_Writes (-18), no input before the point wrote a byte of the range.

debugger.watch_back(4206608, 8, 0)

See: Record and replay of a process: The debugger: step back, and a watch back in the repository

Parameters
  • address:
  • size:
  • before_point:
Result
()
When it fails
a negative result, and the error record
Source
src/modules/system/debugger/exports.odin:2034

entry

entry()

The entry of the debugger service. It takes the machine handle, maps the boot image, takes the debug image, and opens its ring to the root service and its service ring; with no service ring it writes "debugger: no service ring" and stops with Refused. Then it writes "debugger: serves its exports", and waits for calls and runs them for ever, in this thread, which is also the debug handler of the process that it debugs.

Form
The entry of the module: one parameter, an address, fixed by the contract.
Source
src/modules/system/debugger/main.odin:977

stop_report

stop_report(process: ) -> ()

stop_report gives one row for each frame of the stop report of a disk process that stopped on a fault: the module, the procedure and its offset, the file and the line. It needs no attach.

The root service keeps the stop report of each disk process that stops on a fault, 8 of them and 4 for one principal, until a run of the nickname ends with no fault: a process that stopped can be attached to by no debugger. This export asks the root service for the report, and reads the debug object of the module from the store module_files, as attach does. The report holds only the frames that a module record holds, as Inspect gives them: the root service hid each other value, which can be a word of the memory of the process.

  • process: the nickname of the disk process, at most 31 bytes.

Errors:

  • No_Grant, Acts_For_Principal (-1): the caller does not act for the principal.
  • (-4) the record of the root service: Absent, Stop_Reports when no disk process of the principal of the caller with this nickname stopped on a fault, or 8 newer reports took its place; No_Grant, Debug_Access when the grant debug of the caller was revoked; No_Answer when the root service did not answer in 1500 ms; Refused with the status of the kernel.
  • Too_Long, Bytes (-15): the name has no byte or more than 31.
connect("debugger")
debugger.stop_report("visitor")
Parameters
  • process:
Result
()
When it fails
a negative result, and the error record
Source
src/modules/system/debugger/stop_report.odin:63

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
Grants

The debugger service:

  • Serve: its exports are the commands of the debugger.
  • Debugger: it asks this service for the handle of a process with the right Debug, on behalf of one of its callers, and, for a disk process that it debugs, for a connection that reads only to the store of its debug object (Debug_Store).
  • Inspect: the threads and the module records of the process that it debugs.
  • Debug_Image: the debug objects, which name the procedures, the lines, the types and the variables.
  • Image: the name of each module, from its hash. It starts at the first connection to it.
See: Developer tools: The debugger
Other terms of its start grant seton_demand = true
Budget that it asks for
  • working memory pages 2128
  • pages of its threads 72
  • pages of the pictures of its window 0
  • pages of the module and its imports from the files of the build
  • processes 1
  • threads 1
The debug object of the module of a disk process, read from the store into memory of this service: at most DEBUG_OBJECT_BYTES_LIMIT, 2048 pages. The input history of a record, HISTORY_PAGES, 16 pages, and the point copies that the kernel takes from its budget, POINT_COPY_PAGES, 32 pages. The rest: the page tables of the mappings, and the call ring and the call region of the connection that reads the debug object.

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).

Attached record of a module

A record of the module debugger: 64 bytes, aligned on 8 bytes, 0 bytes of padding.

  • processText(32)032 bytes
  • sloti64328 bytes
  • threadsi64408 bytes
  • modulesi64488 bytes
  • describedi64568 bytes

Error_Record record of a module

A record of the module debugger: 56 bytes, aligned on 8 bytes, 0 bytes of padding.

  • kindi6408 bytes
  • uniti6488 bytes
  • operationi64168 bytes
  • argumenti64248 bytes
  • valuei64328 bytes
  • limiti64408 bytes
  • foundi64488 bytes

Detached record of a module

A record of the module debugger: 48 bytes, aligned on 8 bytes, 0 bytes of padding.

  • processText(32)032 bytes
  • breakpointsi64328 bytes
  • threadsi64408 bytes

Thread_Row record of a module

A record of the module debugger: 256 bytes, aligned on 8 bytes, 0 bytes of padding.

  • threadi6408 bytes
  • stateText(12)812 bytes
  • instructionText(20)2020 bytes
  • moduleText(32)4032 bytes
  • procedureText(80)7280 bytes
  • offseti641528 bytes
  • fileText(80)16080 bytes
  • linei642408 bytes

and 1 more

Integer wire form

A wire form of the module contract: one word of a call. A signed integer of 64 bits, in a register.

Register_Row record of a module

A record of the module debugger: 156 bytes, aligned on 1 bytes, 0 bytes of padding.

  • nameText(8)08 bytes
  • valueText(20)820 bytes
  • aboutText(128)28128 bytes

Frame_Row record of a module

A record of the module debugger: 256 bytes, aligned on 8 bytes, 0 bytes of padding.

  • framei6408 bytes
  • moduleText(32)832 bytes
  • procedureText(80)4080 bytes
  • offseti641208 bytes
  • fileText(80)12880 bytes
  • linei642088 bytes
  • frame_pointerText(20)21620 bytes
  • return_addressText(20)23620 bytes

Variable_Row record of a module

A record of the module debugger: 232 bytes, aligned on 1 bytes, 0 bytes of padding.

  • nameText(48)048 bytes
  • roleText(12)4812 bytes
  • typeText(48)6048 bytes
  • valueText(96)10896 bytes
  • locationText(28)20428 bytes

Value_Row record of a module

A record of the module debugger: 212 bytes, aligned on 1 bytes, 0 bytes of padding.

  • nameText(48)048 bytes
  • typeText(48)4848 bytes
  • valueText(96)9696 bytes
  • addressText(20)19220 bytes

Source_Row record of a module

A record of the module debugger: 240 bytes, aligned on 8 bytes, 0 bytes of padding.

  • linei6408 bytes
  • markText(4)84 bytes
  • textText(80)1280 bytes
  • pathText(80)9280 bytes
  • hashText(68)17268 bytes

Break_Row record of a module

A record of the module debugger: 208 bytes, aligned on 8 bytes, 0 bytes of padding.

  • numberi6408 bytes
  • kindText(12)812 bytes
  • addressText(20)2020 bytes
  • lengthi64408 bytes
  • placeText(160)48160 bytes

Memory_Row record of a module

A record of the module debugger: 88 bytes, aligned on 1 bytes, 0 bytes of padding.

  • addressText(20)020 bytes
  • bytesText(48)2048 bytes
  • textText(20)6820 bytes

Event_Row record of a module

A record of the module debugger: 256 bytes, aligned on 8 bytes, 0 bytes of padding.

  • threadi6408 bytes
  • kindText(20)820 bytes
  • instructionText(20)2820 bytes
  • moduleText(32)4832 bytes
  • procedureText(80)8080 bytes
  • offseti641608 bytes
  • fileText(80)16880 bytes
  • linei642488 bytes

Record_Row record of a module

A record of the module debugger: 152 bytes, aligned on 8 bytes, 8 bytes of padding.

  • stateText(12)012 bytes
  • padding124 bytes
  • pointsi64168 bytes
  • bytesi64248 bytes
  • capacityi64328 bytes
  • endText(20)4020 bytes
  • padding604 bytes
  • checkpointsi64648 bytes
  • divergencei64728 bytes
  • differedText(12)8012 bytes

and 3 more

Checkpoint_Row record of a module

A record of the module debugger: 64 bytes, aligned on 8 bytes, 0 bytes of padding.

  • checkpointi6408 bytes
  • pointi6488 bytes
  • offseti64168 bytes
  • instructionText(20)2420 bytes
  • stackText(20)4420 bytes

Step_Back_Row record of a module

A record of the module debugger: 80 bytes, aligned on 8 bytes, 0 bytes of padding.

  • checkpointi6408 bytes
  • starti6488 bytes
  • targeti64168 bytes
  • pointsi64248 bytes
  • offseti64328 bytes
  • instructionText(20)4020 bytes
  • stackText(20)6020 bytes

Watch_Back_Row record of a module

A record of the module debugger: 136 bytes, aligned on 8 bytes, 8 bytes of padding.

  • pointi6408 bytes
  • offseti6488 bytes
  • sourceText(16)1616 bytes
  • addressText(20)3220 bytes
  • padding524 bytes
  • writteni64568 bytes
  • bytesText(24)6424 bytes
  • instructionText(20)8820 bytes
  • padding1084 bytes
  • checkpointi641128 bytes

and 2 more

Stop_Frame_Row record of a module

A record of the module debugger: 256 bytes, aligned on 8 bytes, 0 bytes of padding.

  • framei6408 bytes
  • moduleText(32)832 bytes
  • procedureText(80)4080 bytes
  • offseti641208 bytes
  • fileText(80)12880 bytes
  • linei642088 bytes
  • stopText(40)21640 bytes

Error_Record struct

A struct of the package errors: 56 bytes, aligned on 8 bytes, 0 bytes of padding. The error record: what a call that failed says about why, as seven integers.

  • kindi6408 bytes
  • uniti6488 bytes
  • operationi64168 bytes
  • argumenti64248 bytes
  • valuei64328 bytes
  • limiti64408 bytes
  • foundi64488 bytes

Debug_Store type of the package root

Debug_Store :: struct {...}

The one connection of the debugger service to the store.

src/modules/system/root/debug_store.odin:35

continue_all procedure of the package debugger

continue_all :: proc "c" (result: ^[]Thread_Row, error: ^errors.) -> i64

continue_all lets each thread of the process run again, and gives one row for each thread.

src/modules/system/debugger/exports.odin:503

step_line procedure of the package debugger

step_line :: proc "c" (thread: i64, result: ^[]Thread_Row, error: ^errors.) -> i64

step_line runs a thread that is held or stopped until the source line of its instruction changes, and gives its row there.

src/modules/system/debugger/exports.odin:1271

step_over procedure of the package debugger

step_over :: proc "c" (thread: i64, result: ^[]Thread_Row, error: ^errors.) -> i64

step_over runs a thread to the next line of its procedure, and gives its row there: a call of the line runs to its end.

src/modules/system/debugger/exports.odin:1452

replay_status procedure of the package debugger

replay_status :: proc "c" (result: ^[]Record_Row, error: ^errors.) -> i64

replay_status gives the row of the record: its state, its input points, its bytes, why it ended, and its checkpoints.

src/modules/system/debugger/exports.odin:1888

replay_step_back procedure of the package debugger

replay_step_back :: proc "c" (points: i64, result: ^[]Step_Back_Row, error: ^errors.) -> i64

replay_step_back gives the way back by some input points: the nearest checkpoint at or before the target point, and the input points that a replay runs from it.

src/modules/system/debugger/exports.odin:1970

replay_start procedure of the package debugger

replay_start :: proc "c" (result: ^[]Record_Row, error: ^errors.) -> i64

replay_start runs the recorded module again from the input history of the caller, and gives the row of the record: the replay reaches the same instructions with the same values, or stops at the first difference.

src/modules/system/debugger/exports.odin:1853

record_start procedure of the package debugger

record_start :: proc "c" (result: ^[]Record_Row, error: ^errors.) -> i64

record_start asks the kernel to record the process into an input history, and gives the row of the record.

src/modules/system/debugger/exports.odin:1698