libunwind-ptrace.man 4.8 KB

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