blob: 86524e08cdad38d898adfbf59cb2e2d6c4a336ac [file] [log] [blame]
mostang.com!davidm64f2bf72003-01-28 07:32:15 +00001'\" t
2.\" Manual page created with latex2man on Mon Jan 27 23:19:42 PST 2003
3.\" NOTE: This file is generated, DO NOT EDIT.
4.de Vb
5.ft CW
6.nf
7..
8.de Ve
9.ft R
10
11.fi
12..
13.TH "LIBUNWIND\-PTRACE" "3" "27 January 2003" "Programming Library " "Programming Library "
14.SH NAME
15
16libunwind\-ptrace \-\- ptrace() support in libunwind
17.PP
18.SH SYNOPSIS
19
20.PP
21#include <libunwind.h>
22.br
23.PP
24unw_accessors_t
25_UPT_accessors;
26.br
27.PP
28void *_UPT_create(pid_t);
29.br
30void
31_UPT_destroy(void *);
32.br
33.PP
34int
35_UPT_find_proc_info(unw_addr_space_t,
36unw_word_t,
37unw_proc_info_t *,
38int,
39void *);
40.br
41void
42_UPT_put_unwind_info(unw_addr_space_t,
43unw_proc_info_t *,
44void *);
45.br
46int
47_UPT_get_dyn_info_list_addr(unw_addr_space_t,
48unw_word_t *,
49void *);
50.br
51int
52_UPT_access_mem(unw_addr_space_t,
53unw_word_t,
54unw_word_t *,
55int,
56void *);
57.br
58int
59_UPT_access_reg(unw_addr_space_t,
60unw_regnum_t,
61unw_word_t *,
62int,
63void *);
64.br
65int
66_UPT_access_fpreg(unw_addr_space_t,
67unw_regnum_t,
68unw_fpreg_t *,
69int,
70void *);
71.br
72.PP
73.SH DESCRIPTION
74
75.PP
76The ptrace(2)
77system\-call makes it possible for a process to
78gain access to the machine\-state and virtual memory of \fIanother\fP
79process. With the right set of call\-back routines, it is therefore
80possible to hook up libunwind
81to another process via
82ptrace(2).
83While it\&'s not very difficult to do so directly,
84libunwind
85further facilitates this task by providing
86ready\-to\-use callbacks for this purpose. The routines and variables
87implementing this facility use a name\-prefix of _UPT,
88which is
89stands for ``unwind\-via\-ptrace\&''\&.
90.PP
91An application that wants to use the _UPT\-facility
92first needs
93to create a new libunwind
94address\-space that represents the
95target process. This is done by calling
96unw_create_addr_space().
97In many cases, the application
98will simply want to pass the address of _UPT_accessors
99as the
100first argument to this routine. Doing so will ensure that
101libunwind
102will be able to properly unwind the target process.
103However, in special circumstances, an application may prefer to use
104only portions of the _UPT\-facility.
105For this reason, the
106individual callback routines (_UPT_find_proc_info(),
107_UPT_put_unwind_info(),
108etc.) are also available for direct
109use. Of course, the addresses of these routines could also be picked
110up from _UPT_accessors,
111but doing so would prevent static
112initialization. Also, when using _UPT_accessors,
113\fIall\fP
114the callback routines will be linked into the application, even if
115they are never actually called.
116.PP
117Next, the application can turn on ptrace\-mode on the target process,
118either by forking a new process, invoking PTRACE_TRACEME,
119and
120then starting the target program (via execve(2)),
121or by
122directly attaching to an already running process (via
123PTRACE_ATTACH).
124Either way, once the process\-ID (pid) of the
125target process is known, a _UPT\-info\-structure
126can be created
127by calling _UPT_create(),
128passing the pid of the target process
129as the only argument. The returned void\-pointer then needs to be
130passed as the ``argument\&'' pointer (third argument) to
131unw_init_remote().
132.PP
133When the application is done using libunwind
134on the target
135process, _UPT_destroy()
136needs to be called, passing it the
137void\-pointer that was returned by the corresponding call to
138_UPT_create().
139This ensures that all memory and other
140resources are freed up.
141.PP
142.SH AVAILABILITY
143
144.PP
145Since ptrace(2)
146works within a single machine only, the
147_UPT\-facility
148by definition is not available in
149libunwind\-versions
150configured for cross\-unwinding.
151.PP
152.SH THREAD SAFETY
153
154.PP
155The _UPT\-facility
156assumes that a single _UPT\-info
157structure is never shared between threads. Because of this, no
158explicit locking is used. As long as only one thread uses
159a _UPT\-info
160structure at any given time, this facility
161is thread\-safe.
162.PP
163.SH RETURN VALUE
164
165.PP
166_UPT_create()
167may return a NULL
168pointer if it fails
169to create the _UPT\-info\-structure
170for any reason. For the
171current implementation, the only reason this call may fail is when the
172system is out of memory.
173.PP
174.SH SEE ALSO
175
176.PP
177execve(2),
178libunwind(3),
179ptrace(2)
180.PP
181.SH AUTHOR
182
183.PP
184David Mosberger\-Tang
185.br
186Hewlett\-Packard Labs
187.br
188Palo\-Alto, CA 94304
189.br
190Email: \fBdavidm@hpl.hp.com\fP
191.br
192WWW: \fBhttp://www.hpl.hp.com/research/linux/libunwind/\fP\&.
193.\" NOTE: This file is generated, DO NOT EDIT.