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
|
.\"
.\" 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 02, 2020
.Dt PLWP_GETREGS 3PROC
.Os
.Sh NAME
.Nm Plwp_getfpregs ,
.Nm Plwp_setfpregs ,
.Nm Plwp_getregs ,
.Nm Plwp_setregs
.Nd get and set thread registers
.Sh LIBRARY
.Lb libproc
.Sh SYNOPSIS
.In libproc.h
.Ft int
.Fo Plwp_getfpregs
.Fa "struct ps_prochandle *P"
.Fa "lwpid_t lwpid"
.Fa "prfpregset_t *fpregs"
.Fc
.Ft int
.Fo Plwp_setfpregs
.Fa "struct ps_prochandle *P"
.Fa "lwpid_t lwpid"
.Fa "const prfpregset_t fpregs"
.Fc
.Ft int
.Fo Plwp_getregs
.Fa "struct ps_prochandle *P"
.Fa "lwpid_t lwpid"
.Fa "prgregset_t gregs"
.Fc
.Ft int
.Fo Plwp_setregs
.Fa "struct ps_prochandle *P"
.Fa "lwpid_t lwpid"
.Fa "const prgregset_t gregs"
.Fc
.Sh DESCRIPTION
The
.Fn Plwp_getregs ,
.Fn Plwp_setregs ,
.Fn Plwp_getfpregs ,
and
.Fn Plwp_setfpregs
functions allow one to get and set the general purpose and floating
point registers from the thread
.Fa lwpid
in the process handle
.Fa P .
.Pp
The
.Fn Plwp_getfpregs
function updates the structure pointed to by
.Fa fpregs
with the state and values of the floating point registers of the thread
specified by
.Fa lwpid .
.Pp
The
.Fn Plwp_setfpregs
function updates the floating point registers of the thread specified by
.Fa lwpid
to the register state contained in
.Fa fpregs .
.Pp
The
.Fn Plwp_getregs
function updates the structure pointed to by
.Fa gregs
with the state and values of the general purpose registers of the thread
specified by
.Fa lwpid.
.Pp
The
.Fn Plwp_setregs
function updates the general purpose registers of the thread specified
by
.Fa lwpid
to the register state contained in
.Fa gregs .
.Pp
Processes must be stopped before obtaining the register state of
individual threads.
Processes may be stopped with
.Xr Pstop 3PROC .
The structures used for registers are described in
.Xr proc 4
and their definitions may be found in
.In procfs.h .
The definitions of these structures varies based on the architecture of
the system and the running process.
.Pp
One may not set the register values of a process that is not an active
process, e.g. a process handle that refers to a file or a core file.
.Sh RETURN VALUES
Upon successful completion, the
.Fn Plwp_getregs ,
.Fn Plwp_setregs ,
.Fn Plwp_getfpregs ,
and
.Fn Plwp_setfpregs
functions return
.Sy 0
and obtain or set the register state.
Otherwise,
.Sy -1
is returned,
.Sy errno
is set to indicate the error, and the register state is not updated nor
are the data pointers changed.
.Sh ERRORS
For a full list of possible errors also see the
.Sy DIAGNOSTICS
section in
.Xr proc 4 .
.Pp
The
.Fn Plwp_getregs ,
.Fn Plwp_setregs ,
.Fn Plwp_getfpregs ,
and
.Fn Plwp_setfpregs
will fail if:
.Bl -tag -width Er
.It Er EBUSY
The process handle
.Fa P
is not currently stopped.
.It Er ENOENT
There is no thread in
.Fa P
with id
.Fa lwpid .
.El
.Sh INTERFACE STABILITY
.Sy Uncommitted
.Sh MT-LEVEL
See
.Sy LOCKING
in
.Xr libproc 3LIB .
.Sh SEE ALSO
.Xr libproc 3LIB ,
.Xr proc 4
|