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
|
.\"
.\" This file and its contents are supplied under the terms of the
.\" Common Development and Distribution License ("CDDL"), version 1.0.
.\" You may only use this file in accordance with the terms of version
.\" 1.0 of the CDDL.
.\"
.\" A full copy of the text of the CDDL should have accompanied this
.\" source. A copy of the CDDL is also available via the Internet at
.\" http://www.illumos.org/license/CDDL.
.\"
.\"
.\" Copyright 2015 Joyent, Inc.
.\"
.Dd May 11, 2016
.Dt PGETAREG 3PROC
.Os
.Sh NAME
.Nm Pgetareg ,
.Nm Pputareg ,
.Nm Lgetareg ,
.Nm Lputareg
.Nd set and get a register from a stopped process or thread
.Sh LIBRARY
.Lb libproc
.Sh SYNOPSIS
.In libproc.h
.Ft int
.Fo Pgetareg
.Fa "struct ps_prochandle *P"
.Fa "int regno"
.Fa "prgreg_t *preg"
.Fc
.Ft int
.Fo Pputareg
.Fa "struct ps_prochandle *P"
.Fa "int regno"
.Fa "prgreg_t preg"
.Fc
.Ft int
.Fo Lgetareg
.Fa "struct ps_lwphandle *L"
.Fa "int regno"
.Fa "prgreg_t *preg"
.Fc
.Ft int
.Fo Lputareg
.Fa "struct ps_lwphandle *L"
.Fa "int regno"
.Fa "prgreg_t preg"
.Fc
.Sh DESCRIPTION
The
.Fn Pgetareg
and
.Fn Pputareg
functions read and update the registers of the process handle referred
to by
.Fa P .
The getting and setting of registers of the process operates on the
representative thread (LWP).
For more information on how the representative is chosen, see
.Xr proc 5 .
.Pp
To change the registers of a specific thread, use the
.Fn Lgetareg
and
.Fn Lputareg
functions.
.Pp
The getting and setting of registers only applies to stopped processes.
In addition, one may obtain registers from core files, but not set them.
To stop a process, see the
.Xr Pstop 3PROC
function.
.Pp
The register to get or set is indicated by the
.Fa regno
argument.
For a list of registers, see
.In sys/regset.h .
The set of registers is specific to each architecture of the system.
The
.Fn Pgetareg
function will fill in the value of
.Fa preg
with the value of the register
.Fa regno ,
while the
.Fn Pputareg
function will update the value of the register
.Fa regno
with the value in
.Fa preg .
Updated registers will be set when the process resumes execution.
.Pp
The
.Fn Lgetareg
and
.Fn Lputareg
functions are equivalent to the
.Fn Pgetareg
and
.Fn Psetareg
functions, except rather than operating on the process and its
representative thread, they instead operate on the thread handle
.Fa L .
.Sh RETURN VALUES
Upon successful completion, the
.Fn Pgetareg
and
.Fn Pputareg
function return
.Sy 0 .
Otherwise,
.Sy -1
is returned,
.Sy errno
is set, and no registers will have been gotten or updated.
.Sh ERRORS
The
.Fn Pgetareg
and
.Fn Lgetareg
functions will fail if:
.Bl -tag -width Er
.It Er EINVAL
The value of
.Fa regno
is invalid.
This means it is less than
.Sy 0
and greater than
.Sy NPRGREG .
Note,
.Sy NPRGREG Ns 's
value varies based on process architecture.
.It Er EBUSY
The handle
.Fa P
is neither stopped nor a core file.
.It Er ENODATA
The handle
.Fa P
refers to a file obtained through
.Xr Pgrab_file 3PROC .
.El
.Pp
The
.Fn Pputareg
and
.Fn Lputareg
functions will fail if:
.Bl -tag -width Er
.It Er EINVAL
The value of
.Fa regno
is invalid.
This means it is less than
.Sy 0
and greater than
.Sy NPRGREG .
Note,
.Sy NPRGREG Ns 's
value varies based on process architecture.
.It Er EBUSY
The handle
.Fa P
is not stopped or refers to a non-active process.
.El
.Sh INTERFACE STABILITY
.Sy Uncommitted
.Sh MT-LEVEL
See
.Sy LOCKING
in
.Xr libproc 3LIB .
.Sh SEE ALSO
.Xr errno 3C ,
.Xr libproc 3LIB ,
.Xr Lgrab 3PROC ,
.Xr Pgrab_file 3PROC ,
.Xr Pstop 3PROC ,
.Xr proc 5
|