unw_create_addr_space.man 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457
  1. '\" t
  2. .\" Manual page created with latex2man on Thu Aug 16 09:44:45 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 "UNW\\_CREATE\\_ADDR\\_SPACE" "3" "16 August 2007" "Programming Library " "Programming Library "
  13. .SH NAME
  14. unw_create_addr_space
  15. \-\- create address space for remote unwinding
  16. .PP
  17. .SH SYNOPSIS
  18. .PP
  19. #include <libunwind.h>
  20. .br
  21. .PP
  22. unw_addr_space_t
  23. unw_create_addr_space(unw_accessors_t *ap,
  24. int
  25. byteorder);
  26. .br
  27. .PP
  28. .SH DESCRIPTION
  29. .PP
  30. The unw_create_addr_space()
  31. routine creates a new unwind
  32. address\-space and initializes it based on the call\-back routines
  33. passed via the ap
  34. pointer and the specified byteorder\&.
  35. The call\-back routines are described in detail below. The
  36. byteorder
  37. can be set to 0 to request the default byte\-order of
  38. the unwind target. To request a particular byte\-order,
  39. byteorder
  40. can be set to any constant defined by
  41. <endian.h>\&.
  42. In particular, __LITTLE_ENDIAN
  43. would
  44. request little\-endian byte\-order and __BIG_ENDIAN
  45. would
  46. request big\-endian byte\-order. Whether or not a particular byte\-order
  47. is supported depends on the target platform.
  48. .PP
  49. .SH CALL\-BACK ROUTINES
  50. .PP
  51. Libunwind
  52. uses a set of call\-back routines to access the
  53. information it needs to unwind a chain of stack\-frames. These
  54. routines are specified via the ap
  55. argument, which points to a
  56. variable of type unw_accessors_t\&.
  57. The contents of this
  58. variable is copied into the newly\-created address space, so the
  59. variable must remain valid only for the duration of the call to
  60. unw_create_addr_space().
  61. .PP
  62. The first argument to every call\-back routine is an address\-space
  63. identifier (as)
  64. and the last argument is an arbitrary,
  65. application\-specified void\-pointer (arg).
  66. When invoking a
  67. call\-back routine, libunwind
  68. sets the as
  69. argument to the
  70. address\-space on whose behalf the invocation is made and the arg
  71. argument to the value that was specified when
  72. unw_init_remote(3)
  73. was called.
  74. .PP
  75. The synopsis and a detailed description of every call\-back routine
  76. follows below.
  77. .PP
  78. .SS CALL\-BACK ROUTINE SYNOPSIS
  79. .PP
  80. int
  81. find_proc_info(unw_addr_space_t
  82. as,
  83. .br
  84. \fB \fP\fB \fP\fB \fP\fB \fP\fB \fP\fB \fP\fB \fP\fB \fP\fB \fP\fB \fP\fB \fP\fB \fP\fB \fP\fB \fP\fB \fP\fB \fPunw_word_t
  85. ip,
  86. unw_proc_info_t *pip,
  87. .br
  88. \fB \fP\fB \fP\fB \fP\fB \fP\fB \fP\fB \fP\fB \fP\fB \fP\fB \fP\fB \fP\fB \fP\fB \fP\fB \fP\fB \fP\fB \fP\fB \fPint
  89. need_unwind_info,
  90. void *arg);
  91. .br
  92. void
  93. put_unwind_info(unw_addr_space_t
  94. as,
  95. .br
  96. \fB \fP\fB \fP\fB \fP\fB \fP\fB \fP\fB \fP\fB \fP\fB \fP\fB \fP\fB \fP\fB \fP\fB \fP\fB \fP\fB \fP\fB \fP\fB \fPunw_proc_info_t *pip,
  97. void *arg);
  98. .br
  99. int
  100. get_dyn_info_list_addr(unw_addr_space_t
  101. as,
  102. .br
  103. \fB \fP\fB \fP\fB \fP\fB \fP\fB \fP\fB \fP\fB \fP\fB \fP\fB \fP\fB \fP\fB \fP\fB \fP\fB \fP\fB \fP\fB \fP\fB \fPunw_word_t *dilap,
  104. void *arg);
  105. .br
  106. int
  107. access_mem(unw_addr_space_t
  108. as,
  109. .br
  110. \fB \fP\fB \fP\fB \fP\fB \fP\fB \fP\fB \fP\fB \fP\fB \fP\fB \fP\fB \fP\fB \fP\fB \fP\fB \fP\fB \fP\fB \fP\fB \fPunw_word_t
  111. addr,
  112. unw_word_t *valp,
  113. .br
  114. \fB \fP\fB \fP\fB \fP\fB \fP\fB \fP\fB \fP\fB \fP\fB \fP\fB \fP\fB \fP\fB \fP\fB \fP\fB \fP\fB \fP\fB \fP\fB \fPint
  115. write,
  116. void *arg);
  117. .br
  118. int
  119. access_reg(unw_addr_space_t
  120. as,
  121. .br
  122. \fB \fP\fB \fP\fB \fP\fB \fP\fB \fP\fB \fP\fB \fP\fB \fP\fB \fP\fB \fP\fB \fP\fB \fP\fB \fP\fB \fP\fB \fP\fB \fPunw_regnum_t
  123. regnum,
  124. unw_word_t *valp,
  125. .br
  126. \fB \fP\fB \fP\fB \fP\fB \fP\fB \fP\fB \fP\fB \fP\fB \fP\fB \fP\fB \fP\fB \fP\fB \fP\fB \fP\fB \fP\fB \fP\fB \fPint
  127. write,
  128. void *arg);
  129. .br
  130. int
  131. access_fpreg(unw_addr_space_t
  132. as,
  133. .br
  134. \fB \fP\fB \fP\fB \fP\fB \fP\fB \fP\fB \fP\fB \fP\fB \fP\fB \fP\fB \fP\fB \fP\fB \fP\fB \fP\fB \fP\fB \fP\fB \fPunw_regnum_t
  135. regnum,
  136. unw_fpreg_t *fpvalp,
  137. .br
  138. \fB \fP\fB \fP\fB \fP\fB \fP\fB \fP\fB \fP\fB \fP\fB \fP\fB \fP\fB \fP\fB \fP\fB \fP\fB \fP\fB \fP\fB \fP\fB \fPint
  139. write,
  140. void *arg);
  141. .br
  142. int
  143. resume(unw_addr_space_t
  144. as,
  145. .br
  146. \fB \fP\fB \fP\fB \fP\fB \fP\fB \fP\fB \fP\fB \fP\fB \fP\fB \fP\fB \fP\fB \fP\fB \fP\fB \fP\fB \fP\fB \fP\fB \fPunw_cursor_t *cp,
  147. void *arg);
  148. .br
  149. int
  150. get_proc_name(unw_addr_space_t
  151. as,
  152. .br
  153. \fB \fP\fB \fP\fB \fP\fB \fP\fB \fP\fB \fP\fB \fP\fB \fP\fB \fP\fB \fP\fB \fP\fB \fP\fB \fP\fB \fP\fB \fP\fB \fPunw_word_t
  154. addr,
  155. char *bufp,
  156. .br
  157. \fB \fP\fB \fP\fB \fP\fB \fP\fB \fP\fB \fP\fB \fP\fB \fP\fB \fP\fB \fP\fB \fP\fB \fP\fB \fP\fB \fP\fB \fP\fB \fPsize_t
  158. buf_len,
  159. unw_word_t *offp,
  160. .br
  161. \fB \fP\fB \fP\fB \fP\fB \fP\fB \fP\fB \fP\fB \fP\fB \fP\fB \fP\fB \fP\fB \fP\fB \fP\fB \fP\fB \fP\fB \fP\fB \fPvoid *arg);
  162. .br
  163. .PP
  164. .SS FIND_PROC_INFO
  165. .PP
  166. Libunwind
  167. invokes the find_proc_info()
  168. call\-back to
  169. locate the information need to unwind a particular procedure. The
  170. ip
  171. argument is an instruction\-address inside the procedure whose
  172. information is needed. The pip
  173. argument is a pointer to the
  174. variable used to return the desired information. The type of this
  175. variable is unw_proc_info_t\&.
  176. See
  177. unw_get_proc_info(3)
  178. for details. Argument
  179. need_unwind_info
  180. is zero if the call\-back does not need to
  181. provide values for the following members in the
  182. unw_proc_info_t
  183. structure: format,
  184. unwind_info_size,
  185. and unwind_info\&.
  186. If
  187. need_unwind_info
  188. is non\-zero, valid values need to be returned
  189. in these members. Furthermore, the contents of the memory addressed
  190. by the unwind_info
  191. member must remain valid until the info is
  192. released via the put_unwind_info
  193. call\-back (see below).
  194. .PP
  195. On successful completion, the find_proc_info()
  196. call\-back must
  197. return zero. Otherwise, the negative value of one of the
  198. unw_error_t
  199. error\-codes may be returned. In particular, this
  200. call\-back may return \-UNW_ESTOPUNWIND
  201. to signal the end of
  202. the frame\-chain.
  203. .PP
  204. .SS PUT_UNWIND_INFO
  205. .PP
  206. Libunwind
  207. invokes the put_unwind_info()
  208. call\-back to
  209. release the resources (such as memory) allocated by a previous call to
  210. find_proc_info()
  211. with the need_unwind_info
  212. argument
  213. set to a non\-zero value. The pip
  214. argument has the same value as
  215. the argument of the same name in the previous matching call to
  216. find_proc_info().
  217. Note that libunwind
  218. does \fInot\fP
  219. invoke put_unwind_info
  220. for calls to find_proc_info()
  221. with a zero need_unwind_info
  222. argument.
  223. .PP
  224. .SS GET_DYN_INFO_LIST_ADDR
  225. .PP
  226. Libunwind
  227. invokes the get_dyn_info_list_addr()
  228. call\-back to obtain the address of the head of the dynamic unwind\-info
  229. registration list. The variable stored at the returned address must
  230. have a type of unw_dyn_info_list_t
  231. (see
  232. _U_dyn_register(3)).
  233. The dliap
  234. argument is a pointer
  235. to a variable of type unw_word_t
  236. which is used to return the
  237. address of the dynamic unwind\-info registration list. If no dynamic
  238. unwind\-info registration list exist, the value pointed to by
  239. dliap
  240. must be cleared to zero. Libunwind
  241. will cache the
  242. value returned by get_dyn_info_list_addr()
  243. if caching is
  244. enabled for the given address\-space. The cache can be cleared with a
  245. call to unw_flush_cache().
  246. .PP
  247. On successful completion, the get_dyn_info_list_addr()
  248. call\-back must return zero. Otherwise, the negative value of one of
  249. the unw_error_t
  250. error\-codes may be returned.
  251. .PP
  252. .SS ACCESS_MEM
  253. .PP
  254. Libunwind
  255. invokes the access_mem()
  256. call\-back to read
  257. from or write to a word of memory in the target address\-space. The
  258. address of the word to be accessed is passed in argument addr\&.
  259. To read memory, libunwind
  260. sets argument write
  261. to zero and
  262. valp
  263. to point to the word that receives the read value. To
  264. write memory, libunwind
  265. sets argument write
  266. to a non\-zero
  267. value and valp
  268. to point to the word that contains the value to
  269. be written. The word that valp
  270. points to is always in the
  271. byte\-order of the host\-platform, regardless of the byte\-order of the
  272. target. In other words, it is the responsibility of the call\-back
  273. routine to convert between the target\&'s and the host\&'s byte\-order, if
  274. necessary.
  275. .PP
  276. On successful completion, the access_mem()
  277. call\-back must return zero. Otherwise, the negative value of one of
  278. the unw_error_t
  279. error\-codes may be returned.
  280. .PP
  281. .SS ACCESS_REG
  282. .PP
  283. Libunwind
  284. invokes the access_reg()
  285. call\-back to read
  286. from or write to a scalar (non\-floating\-point) CPU register. The
  287. index of the register to be accessed is passed in argument
  288. regnum\&.
  289. To read a register, libunwind
  290. sets argument
  291. write
  292. to zero and valp
  293. to point to the word that receives
  294. the read value. To write a register, libunwind
  295. sets argument
  296. write
  297. to a non\-zero value and valp
  298. to point to the word
  299. that contains the value to be written. The word that valp
  300. points to is always in the byte\-order of the host\-platform, regardless
  301. of the byte\-order of the target. In other words, it is the
  302. responsibility of the call\-back routine to convert between the
  303. target\&'s and the host\&'s byte\-order, if necessary.
  304. .PP
  305. On successful completion, the access_reg()
  306. call\-back must
  307. return zero. Otherwise, the negative value of one of the
  308. unw_error_t
  309. error\-codes may be returned.
  310. .PP
  311. .SS ACCESS_FPREG
  312. .PP
  313. Libunwind
  314. invokes the access_fpreg()
  315. call\-back to read
  316. from or write to a floating\-point CPU register. The index of the
  317. register to be accessed is passed in argument regnum\&.
  318. To read a
  319. register, libunwind
  320. sets argument write
  321. to zero and
  322. fpvalp
  323. to point to a variable of type unw_fpreg_t
  324. that
  325. receives the read value. To write a register, libunwind
  326. sets
  327. argument write
  328. to a non\-zero value and fpvalp
  329. to point to
  330. the variable of type unw_fpreg_t
  331. that contains the value to
  332. be written. The word that fpvalp
  333. points to is always in the
  334. byte\-order of the host\-platform, regardless of the byte\-order of the
  335. target. In other words, it is the responsibility of the call\-back
  336. routine to convert between the target\&'s and the host\&'s byte\-order, if
  337. necessary.
  338. .PP
  339. On successful completion, the access_fpreg()
  340. call\-back must
  341. return zero. Otherwise, the negative value of one of the
  342. unw_error_t
  343. error\-codes may be returned.
  344. .PP
  345. .SS RESUME
  346. .PP
  347. Libunwind
  348. invokes the resume()
  349. call\-back to resume
  350. execution in the target address space. Argument cp
  351. is the
  352. unwind\-cursor that identifies the stack\-frame in which execution
  353. should resume. By the time libunwind
  354. invokes the resume
  355. call\-back, it has already established the desired machine\- and
  356. memory\-state via calls to the access_reg(),
  357. access_fpreg,
  358. and access_mem()
  359. call\-backs. Thus, all
  360. the call\-back needs to do is perform whatever action is needed to
  361. actually resume execution.
  362. .PP
  363. The resume
  364. call\-back is invoked only in response to a call to
  365. unw_resume(3),
  366. so applications which never invoke
  367. unw_resume(3)
  368. need not define the resume
  369. callback.
  370. .PP
  371. On successful completion, the resume()
  372. call\-back must return
  373. zero. Otherwise, the negative value of one of the
  374. unw_error_t
  375. error\-codes may be returned. As a special case,
  376. when resuming execution in the local address space, the call\-back will
  377. not return on success.
  378. .PP
  379. .SS GET_PROC_NAME
  380. .PP
  381. Libunwind
  382. invokes the get_proc_name()
  383. call\-back to
  384. obtain the procedure\-name of a static (not dynamically generated)
  385. procedure. Argument addr
  386. is an instruction\-address within the
  387. procedure whose name is to be obtained. The bufp
  388. argument is a
  389. pointer to a character\-buffer used to return the procedure name. The
  390. size of this buffer is specified in argument buf_len\&.
  391. The
  392. returned name must be terminated by a NUL character. If the
  393. procedure\&'s name is longer than buf_len
  394. bytes, it must be
  395. truncated to buf_len\-1
  396. bytes, with the last byte in the
  397. buffer set to the NUL character and \-UNW_ENOMEM
  398. must be
  399. returned. Argument offp
  400. is a pointer to a word which is used to
  401. return the byte\-offset relative to the start of the procedure whose
  402. name is being returned. For example, if procedure foo()
  403. starts
  404. at address 0x40003000, then invoking get_proc_name()
  405. with
  406. addr
  407. set to 0x40003080 should return a value of 0x80 in the word
  408. pointed to by offp
  409. (assuming the procedure is at least 0x80
  410. bytes long).
  411. .PP
  412. On successful completion, the get_proc_name()
  413. call\-back must
  414. return zero. Otherwise, the negative value of one of the
  415. unw_error_t
  416. error\-codes may be returned.
  417. .PP
  418. .SH RETURN VALUE
  419. .PP
  420. On successful completion, unw_create_addr_space()
  421. returns a
  422. non\-NULL
  423. value that represents the newly created
  424. address\-space. Otherwise, NULL
  425. is returned.
  426. .PP
  427. .SH THREAD AND SIGNAL SAFETY
  428. .PP
  429. unw_create_addr_space()
  430. is thread\-safe but \fInot\fP
  431. safe to use from a signal handler.
  432. .PP
  433. .SH SEE ALSO
  434. .PP
  435. _U_dyn_register(3),
  436. libunwind(3),
  437. unw_destroy_addr_space(3),
  438. unw_get_proc_info(3),
  439. unw_init_remote(3),
  440. unw_resume(3)
  441. .PP
  442. .SH AUTHOR
  443. .PP
  444. David Mosberger\-Tang
  445. .br
  446. Email: \fBdmosberger@gmail.com\fP
  447. .br
  448. WWW: \fBhttp://www.nongnu.org/libunwind/\fP\&.
  449. .\" NOTE: This file is generated, DO NOT EDIT.