xref: /freebsd/lib/libsys/i386/i386_set_watch.3 (revision 6580f5c38dd5b01aeeaed16b370f1a12423437f0)
1.\" Copyright (c) 2000 Brian S. Dean
2.\" All rights reserved.
3.\"
4.\" This man-page is based on a similar man-page by Jonathan Lemon
5.\" which is copyrighted under the following conditions:
6.\"
7.\" Redistribution and use in source and binary forms, with or without
8.\" modification, are permitted provided that the following conditions
9.\" are met:
10.\" 1. Redistributions of source code must retain the above copyright
11.\"    notice, this list of conditions and the following disclaimer.
12.\" 2. Redistributions in binary form must reproduce the above copyright
13.\"    notice, this list of conditions and the following disclaimer in the
14.\"    documentation and/or other materials provided with the distribution.
15.\"
16.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
17.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
20.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
22.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
24.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26.\" SUCH DAMAGE.
27.\"
28.Dd August 24, 2000
29.Dt I386_SET_WATCH 3
30.Os
31.Sh NAME
32.Nm i386_clr_watch ,
33.Nm i386_set_watch
34.Nd manage i386 debug register values
35.Sh LIBRARY
36.Lb libc
37.Sh SYNOPSIS
38.In machine/reg.h
39.In machine/sysarch.h
40.Ft int
41.Fn i386_clr_watch "int watchnum" "struct dbreg *d"
42.Ft int
43.Fn i386_set_watch "int watchnum" "unsigned int watchaddr" "int size" "int access" "struct dbreg *d"
44.Sh DESCRIPTION
45The
46.Fn i386_clr_watch
47function
48will disable the indicated watch point within the specified debug
49register set.
50.Pp
51The
52.Fn i386_set_watch
53function
54will set up the specified debug registers as indicated by the
55arguments.
56The
57.Fa watchnum
58argument specifies which watch register is used, 0, 1, 2, 3, or \-1.
59If
60.Fa watchnum
61is \-1, a free watch register is found and used.
62If there are no free
63watch registers, an error code of \-1 is returned.
64The
65.Fa watchaddr
66argument
67specifies the watch address,
68.Fa size
69specifies the size in bytes of the area to be watched (1, 2, or 4 bytes),
70and
71.Fa access
72specifies the type of watch point:
73.Pp
74.Bd -literal -offset indent -compact
75DBREG_DR7_EXEC	  An execution breakpoint.
76DBREG_DR7_WRONLY  Break only when the watch area is written to.
77DBREG_DR7_RDWR	  Break when the watch area is read from or written
78                  to.
79.Ed
80.Pp
81Note that these functions do not actually set or clear breakpoints;
82they manipulate the indicated debug register set.
83You must use
84.Xr ptrace 2
85to retrieve and install the debug register values for a process.
86.Sh RETURN VALUES
87On success, the
88.Fn i386_clr_watch
89function returns 0.
90On error, \-1 returned which indicates that
91.Fa watchnum
92is invalid (not in the range of 0-3).
93If the specified watchnum was already disabled, no error is returned.
94.Pp
95On success, the
96.Fn i386_set_watch
97function returns the
98.Fa watchnum
99argument, or the watchnum actually used in the case where the specified
100.Fa watchnum
101was \-1.
102On error, the
103.Fn i386_set_watch
104function returns \-1 indicating that the watchpoint could not established
105because either no more watchpoints are available, or
106.Fa watchnum ,
107.Fa size ,
108or
109.Fa access
110is invalid.
111.Sh SEE ALSO
112.Xr ptrace 2 ,
113.Xr procfs 5
114.Sh AUTHORS
115This man page was written by
116.An Brian S. Dean .
117