mostang.com!davidm | f18f14e | 2003-12-10 07:14:38 +0000 | [diff] [blame^] | 1 | '\" t |
| 2 | .\" Manual page created with latex2man on Tue Dec 9 23:06:06 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\-DYNAMIC" "3" "09 December 2003" "Programming Library " "Programming Library " |
| 14 | .SH NAME |
| 15 | libunwind\-dynamic |
| 16 | \-\- libunwind\-support for runtime\-generated code |
| 17 | .PP |
| 18 | .SH INTRODUCTION |
| 19 | |
| 20 | .PP |
| 21 | For libunwind |
| 22 | to do its work, it needs to be able to |
| 23 | reconstruct the \fIframe state\fP |
| 24 | of each frame in a call\-chain. The |
| 25 | frame state consists of some frame registers (such as the |
| 26 | instruction\-pointer and the stack\-pointer) and the locations at which |
| 27 | the current values of every callee\-saved (``preserved\&'') resides. |
| 28 | .PP |
| 29 | The purpose of the dynamic unwind\-info is therefore to provide |
| 30 | libunwind |
| 31 | the minimal information it needs about each |
| 32 | dynamically generated procedure such that it can reconstruct the |
| 33 | procedure\&'s frame state. |
| 34 | .PP |
| 35 | For the purpose of the following discussion, a \fIprocedure\fP |
| 36 | is any |
| 37 | contiguous piece of code. Normally, each procedure directly |
| 38 | corresponds to a function in the source\-language but this is not |
| 39 | strictly required. For example, a runtime code\-generator could |
| 40 | translate a given function into two separate (discontiguous) |
| 41 | procedures: one for frequently\-executed (hot) code and one for |
| 42 | rarely\-executed (cold) code. Similarly, simple source\-language |
| 43 | functions (usually leaf functions) may get translated into code for |
| 44 | which the default unwind\-conventions apply and for such code, no |
| 45 | dynamic unwind info needs to be registered. |
| 46 | .PP |
| 47 | Within a procedure, the code can be thought of as being divided into a |
| 48 | sequence of \fIregions\fP\&. |
| 49 | Each region logically consists of an |
| 50 | optional \fIprologue\fP, |
| 51 | a \fIbody\fP, |
| 52 | and an optional |
| 53 | \fIepilogue\fP\&. |
| 54 | If present, the prologue sets up the frame state for |
| 55 | the body, which does the actual work of the procedure. For example, |
| 56 | the prologue may need to allocate a stack\-frame and save some |
| 57 | callee\-saved registers before the body can start executing. |
| 58 | Correspondingly, the epilogue, if present, restores the previous frame |
| 59 | state and thereby undoes the effect of the prologue. Regions are |
| 60 | nested in the sense that the frame state at the end of a region serves |
| 61 | as the entry\-state of the next region. At the end of several nested |
| 62 | regions, there may be a single epilogue which undoes the effect of all |
| 63 | the prologues in the nested regions. |
| 64 | .PP |
| 65 | Even though logically we think of the prologue, body, and epilogue as |
| 66 | separate entities, optimizing code\-generators will generally |
| 67 | interleave instructions from all three entities to achieve higher |
| 68 | performance. In fact, as far as the dynamic unwind\-info is concerned, |
| 69 | there is no distinction at all between prologue and body. Similarly, |
| 70 | the exact set of instructions that make up an epilogue is also |
| 71 | irrelevant. The only point in the epilogue that needs to be described |
| 72 | explicitly is the point at which the stack\-pointer gets restored. The |
| 73 | reason this point needs to be described is that once the stack\-pointer |
| 74 | is restored, all values saved in the deallocated portion of the stack |
| 75 | become invalid. All other locations that store the values of |
| 76 | callee\-saved register are assumed to remain valid throughout the end |
| 77 | of the region. |
| 78 | .PP |
| 79 | Within a region, each instruction that affects the frame state in some |
| 80 | fashion needs to be described with an operation descriptor. For this |
| 81 | purpose, each instruction in the region is assigned a unique index. |
| 82 | Exactly how this index is derived depends on the architecture. For |
| 83 | example, on RISC and EPIC\-style architecture, instructions have a |
| 84 | fixed size so it\&'s possible to simply number the instructions. In |
| 85 | contrast, most CISC use variable\-length instruction encodings, so it |
| 86 | is usually necessary to use a byte\-offset as the index. Given the |
| 87 | instruction index, the operation descriptor specifies the effect of |
| 88 | the instruction in an abstract manner. For example, it might express |
| 89 | that the instruction stores calle\-saved register r1 |
| 90 | at offset 16 |
| 91 | in the stack frame. |
| 92 | .PP |
| 93 | .SH PROCEDURES |
| 94 | |
| 95 | .PP |
| 96 | unw_dyn_info_t |
| 97 | unw_dyn_proc_info_t |
| 98 | unw_dyn_table_info_t |
| 99 | unw_dyn_remote_table_info_t |
| 100 | .PP |
| 101 | .SH REGIONS |
| 102 | |
| 103 | .PP |
| 104 | unw_dyn_region_info_t: |
| 105 | \- insn_count can be negative to indicate that the region is |
| 106 | at the end of the procedure; in such a case, the negated |
| 107 | insn_count value specifies the length of the final region |
| 108 | in number of instructions. There must be at most one region |
| 109 | with a negative insn_count and only the last region in a |
| 110 | procedure\&'s region list may be negative. Furthermore, both |
| 111 | di\->start_ip and di\->end_ip must be valid. |
| 112 | .PP |
| 113 | .SH OPERATIONS |
| 114 | |
| 115 | .PP |
| 116 | unw_dyn_operation_t |
| 117 | unw_dyn_op_t |
| 118 | _U_QP_TRUE |
| 119 | .PP |
| 120 | unw_dyn_info_format_t |
| 121 | .PP |
| 122 | \- instructions don\&'t have to be sorted in increasing order of ``when\&'' |
| 123 | values: In general, if you can generate the sorted order easily |
| 124 | (e.g., without an explicit sorting step), I\&'d recommend doing so |
| 125 | because in that case, should some version of libunwind ever require |
| 126 | sorted order, libunwind can verify in O(N) that the list is sorted |
| 127 | already. In the particular case of the ia64\-version of libunwind, a |
| 128 | sorted order won\&'t help, since it always scans the instructions up |
| 129 | to UNW_DYN_STOP. |
| 130 | .PP |
| 131 | _U_dyn_region_info_size(opcount); |
| 132 | _U_dyn_op_save_reg(); |
| 133 | _U_dyn_op_spill_fp_rel(); |
| 134 | _U_dyn_op_spill_sp_rel(); |
| 135 | _U_dyn_op_add(); |
| 136 | _U_dyn_op_pop_frames(); |
| 137 | _U_dyn_op_label_state(); |
| 138 | _U_dyn_op_copy_state(); |
| 139 | _U_dyn_op_alias(); |
| 140 | _U_dyn_op_stop(); |
| 141 | .PP |
| 142 | .SH SEE ALSO |
| 143 | |
| 144 | .PP |
| 145 | libunwind(3), |
| 146 | _U_dyn_register(3), |
| 147 | _U_dyn_cancel(3) |
| 148 | .PP |
| 149 | .SH AUTHOR |
| 150 | |
| 151 | .PP |
| 152 | David Mosberger\-Tang |
| 153 | .br |
| 154 | Hewlett\-Packard Labs |
| 155 | .br |
| 156 | Palo\-Alto, CA 94304 |
| 157 | .br |
| 158 | Email: \fBdavidm@hpl.hp.com\fP |
| 159 | .br |
| 160 | WWW: \fBhttp://www.hpl.hp.com/research/linux/libunwind/\fP\&. |
| 161 | .\" NOTE: This file is generated, DO NOT EDIT. |