MACH-CMD(3)
π MACH-CMD(3) π
okay so bestie, this is MACH-CMD(3) from the Library Functions Manual, and it's literally the page for the routines that give a debugger access to the stuff it needs: an executable binary, some number of shared libraries, a memory image (core dump or active process), and a register set. π«Ά it's giving debugger main character energy, no cap.
πΈ NAME πΈ
attachargs, attachcore, attachdynamic, attachproc, proctextfile β debugging processes and core files.
β¨ SYNOPSIS β¨
#include <u.h>
#include <libc.h>
#include <mach.h>
int attachcore(Fhdr *hdr)
int attachproc(int pid)
int attachdynamic(void)
char* proctextfile(int pid)
int attachargs(int argc, char **argv, int omode)
extern Fhdr* symhdr;
extern char* symfil;
extern Map* symmap;
extern Fhdr* fhdrlist;
extern Fhdr* corhdr;
extern char* corfil;
extern Map* cormap;
extern int corpid;
extern Regs* correg;
π¦ DESCRIPTION π¦
These routines provide access to the objects a typical debugger manipulates: an executable binary, some number of shared libraries, a memory image in the form of a core dump or active process, and a register set. π
The maintained state is:
symhdrβ the file header for the main binary.symfilβ the file name of the main binary.symmapβ the memory map of the main binary.fhdrlistβ a linked list (via theFhdr.nextfields) of all currently open headers (seesymopeninmach-symbol(3)). When dynamically linked objects have been attached, they are present in this linked list, and therefore included in searches byindexsym,lookupsym, andfindsym(seemach-symbol(3)).corhdrβ the file header for the core dump, if any.corfilβ the file name of the core dump, if any.cormapβ the memory map of the core dump or attached process.corpidβ the process id of the attached process, if any.corregβ the register set of the core dump or attached process. If these fields are not valid, they are zeroed. π
attachcore and attachproc attach to an opened core file or an executing process. They set corhdr, corfil, cormap, corpid, and correg. π«Ά
proctextfile returns the name of the main binary for the process with id pid.
attachdynamic requires that the memory image already be attached. It reads the dynamic linker's internal run-time data structures and then opens all the dynamic objects that are currently loaded. π₯
attachargs uses all of these functions while parsing an argument vector as would be passed to a debugger like db(1) or acid(1). It expects a list of executable files, core dump files, or process ids, given in any order. If extra arguments are given (for example, more than one executable, or both a core dump and a process id), they are ignored and diagnostics are printed to standard error. If arguments are missing (for example, the process id is given without an executable file), attachargs fills them in as best it can. π
π SOURCE π
/src/libmach
π SEE ALSO π
π BUGS π
β οΈ okay so the interface needs to be changed to support multiple threads, each with its own register set. that's the whole bug note, bestie. periodt.
mwah π β this page is MACH-CMD(3) from the Library Functions Manual. The footer just repeats the page name; no extra date/version line here fr, and the source lives at /src/libmach. bye bestie πβ¨
π¦ where this page comes from
- alpine 3.24: plan9port-doc 0_git20260208-r0 Β· LPL-1.02
- arch rolling: plan9port 20261021-2 Β· custom
- nixos 26.05: plan9port 0-unstable-2025-11-10
- nixos 26.05: plan9port-wayland 0-unstable-2025-11-26
- nixpkgs unstable: plan9port 0-unstable-2025-11-10
- nixpkgs unstable: plan9port-wayland 0-unstable-2025-11-26
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms