Pgetareg
,
Pputareg
,
Lgetareg
,
Lputareg
—
set and get a register from a stopped process or
thread
Process Control Library (libproc, -lproc)
#include
<libproc.h>
int
Pgetareg
(
struct
ps_prochandle *P,
int regno,
prgreg_t *preg);
int
Pputareg
(
struct
ps_prochandle *P,
int regno,
prgreg_t preg);
int
Lgetareg
(
struct
ps_lwphandle *L,
int regno,
prgreg_t *preg);
int
Lputareg
(
struct
ps_lwphandle *L,
int regno,
prgreg_t preg);
The
Pgetareg
() and
Pputareg
() functions read and update the
registers of the process handle referred to by
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
proc(4).
To change the registers of a specific thread, use the
Lgetareg
() and
Lputareg
() functions.
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
Pstop(3PROC) function.
The register to get or set is indicated by the
regno argument. For a list of registers, see
<sys/regset.h>
.
The set of registers is specific to each architecture of the system. The
Pgetareg
() function will fill in the value
of
preg with the value of the register
regno, while the
Pputareg
() function will update the value
of the register
regno with the value in
preg. Updated registers will be set when the
process resumes execution.
The
Lgetareg
() and
Lputareg
() functions are equivalent to the
Pgetareg
() and
Psetareg
() functions, except rather than
operating on the process and its representative thread, they instead operate
on the thread handle
L.
Upon successful completion, the
Pgetareg
()
and
Pputareg
() function return
0. Otherwise,
-1 is
returned,
errno is set, and no registers will
have been gotten or updated.
The
Pgetareg
() and
Lgetareg
() functions will fail if:
-
-
EINVAL
- The value of regno is invalid. This means
it is less than 0 and greater than
NPRGREG. Note,
NPRGREG's value varies based on process
architecture.
-
-
EBUSY
- The handle P is neither stopped nor a
core file.
-
-
ENODATA
- The handle P refers to a file obtained
through Pgrab_file(3PROC).
The
Pputareg
() and
Lputareg
() functions will fail if:
-
-
EINVAL
- The value of regno is invalid. This means
it is less than 0 and greater than
NPRGREG. Note,
NPRGREG's value varies based on process
architecture.
-
-
EBUSY
- The handle P is not stopped or refers to
a non-active process.
Uncommitted
See
LOCKING in
libproc(3LIB).
errno(3C),
libproc(3LIB),
Lgrab(3PROC),
Pgrab_file(3PROC),
Pstop(3PROC),
proc(4)