blob: ac6b3bbdf6891e36c82b619b6c88d88f78e70d36 [file] [log] [blame]
rsc058b0112005-01-03 06:40:20 +00001.TH MACH-CMD 3
2.SH NAME
3attachargs, attachcore, attachdynamic, attachproc, proctextfile \- debugging processes and core files
4.SH SYNOPSIS
5.B #include <u.h>
6.br
7.B #include <libc.h>
8.br
9.B #include <mach.h>
10.PP
11.ta +\w'\fLextern 'u +\w'\fLchar *'u
12.B
13int attachcore(Fhdr *hdr)
14.PP
15.B
16int attachproc(int pid)
17.PP
18.B
19int attachdynamic(void)
20.PP
21.B
22char* proctextfile(int pid)
23.PP
24.B
25int attachargs(int argc, char **argv, int omode)
26.PP
27.B
28.nf
29extern Fhdr* symhdr;
30extern char* symfil;
31extern Map* symmap;
32extern Fhdr* fhdrlist;
33.ift .sp .5
34.ifn .sp
35extern Fhdr* corhdr;
36extern char* corfil;
37extern Map* cormap;
38.ift .sp .5
39.ifn .sp
40extern int corpid;
41extern Regs* correg;
42.SH DESCRIPTION
43These routines provide access to the objects
44a typical debugger manipulates: an executable binary,
45some number of shared libraries, a memory image
46in the form of a core dump or active process,
47and a register set.
48.PP
49The maintained state is:
50.TP
51.I symhdr
52The file header for the main binary.
53.TP
54.I symfil
55The file name of the main binary.
56.TP
57.I symmap
58The memory map of the main binary.
59.TP
60.I fhdrlist
61A linked list (via the
62.B Fhdr.next
63fields) of all currently open headers
64(see
65.I symopen
66in
67.IR mach-symbol (3)).
68When dynamically linked objects have been attached,
69they are present in this linked list,
70and therefore included in searches by
71.IR indexsym ,
72.IR lookupsym ,
73and
74.I findsym
75(see
76.IR mach-symbol (3)).
77.TP
78.I corhdr
79The file header for the core dump, if any.
80.TP
81.I corfil
82The file name of the core dump, if any.
83.TP
84.I cormap
85The memory map of the core dump or attached process.
86.TP
87.I corpid
88The process id of the attached process, if any.
89.TP
90.I correg
91The register set of the core dump or attached process.
92.PD
93If these fields are not valid, they are zeroed.
94.PP
95.I Attachcore
96and
97.I attachproc
98attach to an opened core file or an executing process.
99They set
100.IR corhdr ,
101.IR corfil ,
102.IR cormap ,
103.IR corpid ,
104and
105.IR correg .
106.PP
107.I Proctextfile
108returns the name of the main binary for the process with id
109.IR pid .
110.PP
111.I Attachdynamic
112requires that the memory image already be attached.
113It reads the dynamic linker's internal run-time data structures
114and then opens all the dynamic objects that are currently
115loaded.
116.PP
117.I Attachargs
118uses all of these functions while
119parsing an argument vector as would be passed to
120a debugger like
121.IR db (1)
122or
123.IR acid (1).
124It expects a list of executable files, core dump files, or process ids,
125given in any order.
126If extra arguments are given (for example, more than one executable, or both
127a core dump and a process id), they are ignored and diagnostics are printed to
128standard error.
129If arguments are missing (for example, the process id is given without an
130executable file),
131.I attachargs
132fills them in as best it can.
133.SH SOURCE
rscc3674de2005-01-11 17:37:33 +0000134.B \*9/src/libmach
rsc058b0112005-01-03 06:40:20 +0000135.SH "SEE ALSO
136.IR mach (3),
137.IR mach-file (3),
138.IR mach-map (3)
139.SH BUGS
140The interface needs to be changed to support
141multiple threads, each with its own register set.