blob: d579a5933c33aff2ae89043d8c90ed3fab5860d3 [file] [log] [blame]
mostang.com!davidm64f2bf72003-01-28 07:32:15 +00001'\" t
mostang.com!davidmf928eec2004-01-21 01:05:07 +00002.\" Manual page created with latex2man on Tue Jan 20 16:47:43 PST 2004
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!davidmf928eec2004-01-21 01:05:07 +000013.TH "LIBUNWIND\-PTRACE" "3" "20 January 2004" "Programming Library " "Programming Library "
mostang.com!davidm64f2bf72003-01-28 07:32:15 +000014.SH NAME
mostang.com!davidm9eb9f312003-04-01 07:19:34 +000015libunwind\-ptrace
16\-\- ptrace() support in libunwind
mostang.com!davidm64f2bf72003-01-28 07:32:15 +000017.PP
18.SH SYNOPSIS
19
20.PP
mostang.com!davidmf928eec2004-01-21 01:05:07 +000021#include <libunwind\-ptrace.h>
mostang.com!davidm64f2bf72003-01-28 07:32:15 +000022.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!davidm7a7d6112003-03-06 06:14:36 +000080int
81_UPT_resume(unw_addr_space_t,
82unw_cursor_t *,
83void *);
84.br
mostang.com!davidm64f2bf72003-01-28 07:32:15 +000085.PP
86.SH DESCRIPTION
87
88.PP
89The ptrace(2)
90system\-call makes it possible for a process to
91gain access to the machine\-state and virtual memory of \fIanother\fP
92process. With the right set of call\-back routines, it is therefore
93possible to hook up libunwind
94to another process via
95ptrace(2).
96While it\&'s not very difficult to do so directly,
97libunwind
98further facilitates this task by providing
99ready\-to\-use callbacks for this purpose. The routines and variables
100implementing this facility use a name\-prefix of _UPT,
101which is
102stands for ``unwind\-via\-ptrace\&''\&.
103.PP
104An application that wants to use the _UPT\-facility
105first needs
106to create a new libunwind
107address\-space that represents the
108target process. This is done by calling
109unw_create_addr_space().
110In many cases, the application
111will simply want to pass the address of _UPT_accessors
112as the
113first argument to this routine. Doing so will ensure that
114libunwind
115will be able to properly unwind the target process.
116However, in special circumstances, an application may prefer to use
117only portions of the _UPT\-facility.
118For this reason, the
119individual callback routines (_UPT_find_proc_info(),
120_UPT_put_unwind_info(),
121etc.) are also available for direct
122use. Of course, the addresses of these routines could also be picked
123up from _UPT_accessors,
124but doing so would prevent static
125initialization. Also, when using _UPT_accessors,
126\fIall\fP
127the callback routines will be linked into the application, even if
128they are never actually called.
129.PP
130Next, the application can turn on ptrace\-mode on the target process,
131either by forking a new process, invoking PTRACE_TRACEME,
132and
133then starting the target program (via execve(2)),
134or by
135directly attaching to an already running process (via
136PTRACE_ATTACH).
137Either way, once the process\-ID (pid) of the
138target process is known, a _UPT\-info\-structure
139can be created
140by calling _UPT_create(),
141passing the pid of the target process
142as the only argument. The returned void\-pointer then needs to be
143passed as the ``argument\&'' pointer (third argument) to
144unw_init_remote().
145.PP
mostang.com!davidm7a7d6112003-03-06 06:14:36 +0000146The _UPT_resume()
147routine can be used to resume execution of
148the target process. It simply invokes ptrace(2)
149with a command
150value of PTRACE_CONT\&.
151.PP
mostang.com!davidm64f2bf72003-01-28 07:32:15 +0000152When the application is done using libunwind
153on the target
154process, _UPT_destroy()
155needs to be called, passing it the
156void\-pointer that was returned by the corresponding call to
157_UPT_create().
158This ensures that all memory and other
159resources are freed up.
160.PP
161.SH AVAILABILITY
162
163.PP
164Since ptrace(2)
165works within a single machine only, the
166_UPT\-facility
167by definition is not available in
168libunwind\-versions
169configured for cross\-unwinding.
170.PP
171.SH THREAD SAFETY
172
173.PP
174The _UPT\-facility
175assumes that a single _UPT\-info
176structure is never shared between threads. Because of this, no
177explicit locking is used. As long as only one thread uses
178a _UPT\-info
179structure at any given time, this facility
180is thread\-safe.
181.PP
182.SH RETURN VALUE
183
184.PP
185_UPT_create()
186may return a NULL
187pointer if it fails
188to create the _UPT\-info\-structure
189for any reason. For the
190current implementation, the only reason this call may fail is when the
191system is out of memory.
192.PP
mostang.com!davidmf928eec2004-01-21 01:05:07 +0000193.SH FILES
194
195.PP
196.TP
197libunwind\-ptrace.h
198 Headerfile to include when using the
199interface defined by this library.
200.TP
201\fB\-l\fPunwind\-ptrace \fB\-l\fPunwind\-generic
202 Linker\-switches to add when building a program that uses the
203functions defined by this library.
204.PP
mostang.com!davidm64f2bf72003-01-28 07:32:15 +0000205.SH SEE ALSO
206
207.PP
208execve(2),
209libunwind(3),
210ptrace(2)
211.PP
212.SH AUTHOR
213
214.PP
215David Mosberger\-Tang
216.br
217Hewlett\-Packard Labs
218.br
219Palo\-Alto, CA 94304
220.br
221Email: \fBdavidm@hpl.hp.com\fP
222.br
223WWW: \fBhttp://www.hpl.hp.com/research/linux/libunwind/\fP\&.
224.\" NOTE: This file is generated, DO NOT EDIT.