summaryrefslogtreecommitdiff
path: root/static/v10/man9/pi.9
blob: f67d38687a6028eee123980718adbc9e65006f0b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
.TH PI 9.1
.CT 1 debug_tune
.SH NAME
pi, 3pi \- process inspector
.SH SYNOPSIS
.B pi
[
.B -t
.I corefile objectfile
]
.PP
.B 3pi
[
.B -p
.I person
]
.SH DESCRIPTION
.I Pi
is a C debugger that
is bound dynamically to multiple subject processes or core dumps.
It works better for programs compiled
.I cc
.IR \-g .
.I Pi
uses the
.IR Pads (9.5)
multi-window user interface.
There are three types of windows:
debugger control windows,
which access the global state of the debugger;
process control windows (exactly one per process),
which start and stop processes and connect to process-specific functions;
and process inspection windows,
which include viewers for source text and memory, formatted various ways.
.PP
The most important debugger control window is the
.I pi
window itself.
Each line within the
.I pi
window refers to a specific process.
These lines may be introduced to the window by running
.IR ps (1)
from the button 3 menu;
by typing a file name, either a
.IR proc (4)
name, or the name of a core image followed by the name of the binary that created
the core;
or by typing a command, prefixed by an exclamation 
.LR ! ,
to be executed as a child of
.IR pi .
There are several ways to access a process (using the button 2 menu),
each of which generates a process control window:
.TF hang\ &\ take\ over
.TP
.B open process
Attach to a running process, often one started with
.IR hang (1).
.PD0
.TP
.B open core
Attach to a core image.
.TP
.B open child
Attach to a process forked by a process being debugged by the current
.IR pi.
.TP
.B take over
Rebind an existing process window hierarchy (pointed to with the mouse)
to the named process,
which must be an instance of the identical program.
.TP
.B hang & open proc 
Execute a command afresh, beginning it in the
stopped state, and redirecting IO to
.FR /dev/null .
.TP
.B hang & take over
Same, also binding to an existing process window.
.PD
.PP
The process window indicates the process's state,
shows the call stack traceback
and connects to windows that access source text,
local variables within a stack frame,
raw memory, and so on.
These windows are cross-connected, so, for example,
an instruction in a process's assembly language window can
be inspected in hexadecimal in the raw memory window.
Closing the process control window closes all the windows under it.
.PP
The following menu functions are provided by
the various window types in
.IR pi .
Initially there are these windows available:
.TP 0.5i
.B Help
Reminder of user interface mechanics.
.TP
.B Pi
Overall control of processes, core dumps and programs.
A process is identified by its pathname or command line.
Process symbols are found in the executable file from which the process was loaded,
but may be overridden.
Symbols for core dumps must be supplied explicitly, after the core filename.
\fBSynopsis\fP:
Identify and open process or core dump;
run a program as
.I Pi's
child;
take over a process with the debugging environment of a different one.
.TP
.B Pwd/cd
change the working directory of the debugger.
.SS Process Window
Selecting and opening a process from the Pi window creates a new
window with overall control of that process.
It shows the process state, and a traceback if the process is halted or dead.
States are:
.TF EVENT\ PENDING
.TP 
.SM
.B ACTIVE
running normally
.TP
.SM
.B HALTED
halted asynchronously by a debugger
.TP
.SM
.B BREAKPOINT
halted on reaching breakpoint
.TP
.SM
.B STMT STEPPED
halted after executing C source statement(s)
.TP
.SM
.B INSTR STEPPED
halted after executing machine instruction(s)
.TP
.SM
.B EVENT PENDING
halted about to receive a signal being traced
.TP
.SM
.B ERROR STATE
the process has probably exited
.PD
.LP
The menu operations on the process are:
.TF EVENT\ PENDING
.TP
.B go
let the process run
.PD 0
.TP
.B stop
stop the process
.TP
.B kill
send
.B SIGKILL
to the process; see
.IR signal (2)
.TP
.B src text
open source text window(s)
.TP
.B Signals
open window for sending and trapping signals
.TP
.B Globals
open window for evaluating expression in global scope
.TP
.B RawMemory
open window for editing uninterpreted memory
.TP
.B Assembler
open window for disassembler
.PD
.LP
Each line of the call stack traceback describes one function.
Each function in the traceback can open an expression evaluator window
or display its current source line.
.SS Globals and Stack Frame Windows
.PP
These windows evaluate expressions with respect to global scope,
and scope in a function, respectively.
A stack frame window is opened from a line in the call stack traceback or
from a line of source text.
A stack frame can find its active source line in a source window or the stack
frame window of its caller.
.LP
C expressions can be entered by the keyboard or mouse.
The unary operators
.I fabs
and
.I sizeof
are supported; the only assignment operator is 
.LR = .
Functions from the user program may be called.
New expressions can be derived from old ones by the keyboard or mouse.
In menus and the keyboard,
.B $
means the expression in the current line.
The VAX registers are called
.B $r0 
to
.BR $r15 ;
the address of a register is
the location at which it was saved.
The format in which values are displayed can be changed.
The raw memory editor may be entered using an expression's value as address.
.PP
An expression may be made a
.IR spy .
The value of a spy expression is evaluated and displayed
each time the debugger looks at the process.
If the value of a spy changes the process is halted
at the next instruction, statement or breakpoint.
.LP
The comma operator is useful in conditional breakpoints because the values
of its subexpressions are displayed.
E.g. x, y, x==y traces the values of x and y when the condition fails;
x, y, 0 just traces.
.LP
To cross scope boundaries, the environment (a function identifier)
in which an expression is to be evaluated may be specified as:
{ expr } function.
From the source directory window, file static variables can be promoted
to appear in the menu of global variables.
.SS Source Text Windows
The source file directory window lists all the source files, if there are
two or more.
A textual prefix, entered from the keyboard, points to a source directory,
without changing the working directory.
Each source file is in a separate window, opened when needed.
The source file's pathname as given to
.I cc
can be overridden from the keyboard.
If things go wrong, use
.B reopen
to open the file afresh.
\fBSynopsis\fP:
set/clear (conditional) breakpoint;
single-step source statements;
step into (rather than over) a function;
go the process;
show the statement for the current PC;
open a stack frame window for a source line's function;
evaluate expression;
disassemble first instruction of source statement;
context search for string.
.SS Breakpoints Window
Lists all the active source and assembler breakpoints and related errors.
\fBSynopsis\fP:
show source or assembler for a breakpoint;
clear breakpoint;
clear all breakpoints.
.SS Signals Window
Lists all signal types, showing which ones are traced.
\fBSynopsis\fP:
Change which signals are traced;
send a signal to the subject process;
clear pending signal;
stop process on
.I exec.
.SS Raw Memory Window
In this window
memory is a viewed as a sequence of 1-, 2-, 4- or 8-byte cells.
\fBSynopsis\fP:
set cell address;
change cell size;
change display format;
display cells above and below;
indirect to cell;
change cell value;
spy on memory cell;
disassemble instruction at cell.
.SS (Dis)assembler Window
In this window memory is viewed as a sequence of instructions.
\fBSynopsis\fP:
set instruction address;
display more instructions;
change display format;
display instruction as cell in raw memory window;
set/clear breakpoint on instruction;
open stack frame window for instruction's function;
display instruction at current PC;
single step instruction(s);
step over a function call instead of into the function.
.SS Exec and Fork
If a process controlled by
.I pi
does an
.IR exec ()
and an exec break is set in the Signals window,
the process is suspended as if started by
.IR hang (1).
To debug the process after the
.IR exec ,
close the original process window and re-open it.
When re-opened it will get the new symbol tables.
.PP
To debug a child process: (i) set a breakpoint in code that will be executed
in the child after the fork; (ii) execute the fork
.I at full speed
(the child inherits the parent's breakpoints, which aren't there if the
parent is stepped);
(iii)
.I before altering any breakpoints,
get a fresh
.I ps
in the Pi window and apply
.B open child
to the child.
The child should be stopped on the inherited breakpoint, but it and all other
breakpoints should have been cleared.
.SS Kernel
The state of kernel variables associated with a process may be examined
by giving their name or virtual address.
The
.B UNIX
environment variable specifies the file from which the system was
loaded; the default is
.IR /unix .
Kernel dumps may be examined by opening the
`kernel pi' window.
.SS Just A Traceback
With the
.B -t
option
.I pi
writes a traceback on its standard output and quits.
.SS 3pi
.I 3pi
is a variant of
.I pi
for debugging 5620 programs running under
.IR mux (9.1).
It creates two terminal processes: one for its access to terminal memory
and graphics and a second for its
.IR Pads (9.5)
interface.
.SS Remote Debugging
With the
.B -p
option
.I 3pi
loads its first process, but not
.IR Pads .
Instead, it mails a
.I 3pi
command to
.IR person ,
to be executed on any host in the local network.
That
.I 3pi
command loads
.I Pads
on
.IR person 's
terminal, and connects to the originator's terminal.
If separate hosts are involved and the versions of critical files differ,
be careful with pathnames.
.SS 3pi Graphics
Points, rectangles, textures and bitmaps can be displayed graphically.
.SS 3pi - pi
Most differences come from obvious differences in the hardware and
software architectures.
Also, in
.I 3pi
function calls are executed by a debugger process on its own call stack.
.SH SEE ALSO
T. A. Cargill,
`The Feel of Pi',
this manual, Volume 2
.br
.IR hang (1), 
.IR proc (4), 
.IR adb (1),
.IR cin (1),
.IR nm (1),
.IR pads (9.5)
.SH BUGS
In switch statements there is no boundary between the last case
and the branch code; the program
.I appears
to jump to the last case (but is really in the branch)
and then to the real case.
.br
A changed spy only stops the process at a breakpoint or while stepping.
An expression can be cast only by menu.
.br
Functions may only be called when the process is stopped and not in a system call.