blob: f53cca30b710f858dad8fa598a1883d3fa745b7b [file] [log] [blame]
mostang.com!davidm64f2bf72003-01-28 07:32:15 +00001'\" t
mostang.com!davidm26f95912003-02-27 09:58:57 +00002.\" Manual page created with latex2man on Wed Feb 26 20:56:57 PST 2003
mostang.com!davidm64f2bf72003-01-28 07:32:15 +00003.\" 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..
mostang.com!davidm26f95912003-02-27 09:58:57 +000013.TH "LIBUNWIND\-PTRACE" "3" "26 February 2003" "Programming Library " "Programming Library "
mostang.com!davidm64f2bf72003-01-28 07:32:15 +000014.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
mostang.com!davidm26f95912003-02-27 09:58:57 +000072int
73_UPT_get_proc_name(unw_addr_space_t,
74unw_word_t,
75char *,
76size_t,
77unw_word_t *,
78void *);
79.br
mostang.com!davidm64f2bf72003-01-28 07:32:15 +000080.PP
81.SH DESCRIPTION
82
83.PP
84The ptrace(2)
85system\-call makes it possible for a process to
86gain access to the machine\-state and virtual memory of \fIanother\fP
87process. With the right set of call\-back routines, it is therefore
88possible to hook up libunwind
89to another process via
90ptrace(2).
91While it\&'s not very difficult to do so directly,
92libunwind
93further facilitates this task by providing
94ready\-to\-use callbacks for this purpose. The routines and variables
95implementing this facility use a name\-prefix of _UPT,
96which is
97stands for ``unwind\-via\-ptrace\&''\&.
98.PP
99An application that wants to use the _UPT\-facility
100first needs
101to create a new libunwind
102address\-space that represents the
103target process. This is done by calling
104unw_create_addr_space().
105In many cases, the application
106will simply want to pass the address of _UPT_accessors
107as the
108first argument to this routine. Doing so will ensure that
109libunwind
110will be able to properly unwind the target process.
111However, in special circumstances, an application may prefer to use
112only portions of the _UPT\-facility.
113For this reason, the
114individual callback routines (_UPT_find_proc_info(),
115_UPT_put_unwind_info(),
116etc.) are also available for direct
117use. Of course, the addresses of these routines could also be picked
118up from _UPT_accessors,
119but doing so would prevent static
120initialization. Also, when using _UPT_accessors,
121\fIall\fP
122the callback routines will be linked into the application, even if
123they are never actually called.
124.PP
125Next, the application can turn on ptrace\-mode on the target process,
126either by forking a new process, invoking PTRACE_TRACEME,
127and
128then starting the target program (via execve(2)),
129or by
130directly attaching to an already running process (via
131PTRACE_ATTACH).
132Either way, once the process\-ID (pid) of the
133target process is known, a _UPT\-info\-structure
134can be created
135by calling _UPT_create(),
136passing the pid of the target process
137as the only argument. The returned void\-pointer then needs to be
138passed as the ``argument\&'' pointer (third argument) to
139unw_init_remote().
140.PP
141When the application is done using libunwind
142on the target
143process, _UPT_destroy()
144needs to be called, passing it the
145void\-pointer that was returned by the corresponding call to
146_UPT_create().
147This ensures that all memory and other
148resources are freed up.
149.PP
150.SH AVAILABILITY
151
152.PP
153Since ptrace(2)
154works within a single machine only, the
155_UPT\-facility
156by definition is not available in
157libunwind\-versions
158configured for cross\-unwinding.
159.PP
160.SH THREAD SAFETY
161
162.PP
163The _UPT\-facility
164assumes that a single _UPT\-info
165structure is never shared between threads. Because of this, no
166explicit locking is used. As long as only one thread uses
167a _UPT\-info
168structure at any given time, this facility
169is thread\-safe.
170.PP
171.SH RETURN VALUE
172
173.PP
174_UPT_create()
175may return a NULL
176pointer if it fails
177to create the _UPT\-info\-structure
178for any reason. For the
179current implementation, the only reason this call may fail is when the
180system is out of memory.
181.PP
182.SH SEE ALSO
183
184.PP
185execve(2),
186libunwind(3),
187ptrace(2)
188.PP
189.SH AUTHOR
190
191.PP
192David Mosberger\-Tang
193.br
194Hewlett\-Packard Labs
195.br
196Palo\-Alto, CA 94304
197.br
198Email: \fBdavidm@hpl.hp.com\fP
199.br
200WWW: \fBhttp://www.hpl.hp.com/research/linux/libunwind/\fP\&.
201.\" NOTE: This file is generated, DO NOT EDIT.