00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038 #include <stdlib.h>
00039 #include <stdio.h>
00040 #include <strings.h>
00041 #include <sys/unwindP.h>
00042 #include "unwind_producer.h"
00043
00044
00045
00046
00047 __unw_error_t unwind_info_add_prologue_mem_stack_f_info(__unw_info_t *info,
00048 __uint64_t when, __uint64_t size) {
00049 __unw_error_t ret = __UNW_OK;
00050 __unw_format_p7_t *desc;
00051 __uint64_t rsize, esize1, esize2;
00052 char encoded[1+2*__UNW_ENCODING_SIZE];
00053
00054
00055 if (NULL == info) {
00056 return __UNW_NULL_ERROR;
00057 } else if (_unwind_info + _unwind_info_size != info) {
00058 return __UNW_INV_ARG_ERROR;
00059 }
00060
00061
00062 if (when >= _current_region_total_size) {
00063 return __UNW_INV_SIZE_ERROR;
00064 }
00065
00066
00067
00068
00069
00070 encoded[0] = 0xe0;
00071 if ((esize1 = __leb128_encode((char *)&encoded[1],
00072 (__uint64_t)__UNW_ENCODING_SIZE,
00073 when)) == 0) {
00074 return __UNW_INTERNAL_ERROR;
00075 }
00076 if ((esize2 = __leb128_encode((char *)&encoded[1+esize1],
00077 (__uint64_t)__UNW_ENCODING_SIZE,
00078 size)) == 0) {
00079 return __UNW_INTERNAL_ERROR;
00080 }
00081
00082 desc = (__unw_format_p7_t *)&encoded;
00083 rsize = 1 + esize1 + esize2;
00084
00085
00086 ret = unwind_info_add_desc(rsize, (char *)desc);
00087
00088 return ret;
00089 }
00090
00091
00092
00093
00094 __unw_error_t unwind_info_add_prologue_mem_stack_v_info(__unw_info_t *info,
00095 __uint64_t when) {
00096 __unw_error_t ret = __UNW_OK;
00097 __unw_format_p7_t *desc;
00098 __uint64_t rsize, esize;
00099 char encoded[1+__UNW_ENCODING_SIZE];
00100
00101
00102 if (NULL == info) {
00103 return __UNW_NULL_ERROR;
00104 } else if (_unwind_info + _unwind_info_size != info) {
00105 return __UNW_INV_ARG_ERROR;
00106 }
00107
00108
00109 if (when >= _current_region_total_size) {
00110 return __UNW_INV_SIZE_ERROR;
00111 }
00112
00113
00114
00115
00116
00117 encoded[0] = 0xe1;
00118 if ((esize = __leb128_encode((char *)&encoded[1],
00119 (__uint64_t)__UNW_ENCODING_SIZE,
00120 when)) == 0) {
00121 return __UNW_INTERNAL_ERROR;
00122 }
00123
00124 desc = (__unw_format_p7_t *)&encoded;
00125 rsize = 1 + esize;
00126
00127
00128 ret = unwind_info_add_desc(rsize, (char *)desc);
00129
00130 return ret;
00131 }
00132
00133
00134
00135
00136 __unw_error_t unwind_info_add_prologue_psp_gr_info(__unw_info_t *info, __uint32_t gr) {
00137 __unw_error_t ret = __UNW_OK;
00138 __unw_format_p3_t desc;
00139 __uint64_t rsize;
00140
00141
00142 if (NULL == info) {
00143 return __UNW_NULL_ERROR;
00144 } else if (_unwind_info + _unwind_info_size != info) {
00145 return __UNW_INV_ARG_ERROR;
00146 }
00147
00148
00149
00150
00151
00152 if (gr >= 128) {
00153 return __UNW_INV_ARG_ERROR;
00154 }
00155 desc._fix[0] = 0xb0;
00156 desc._fix[1] = 0x00;
00157 desc._fix[1] |= gr;
00158 rsize = 2;
00159
00160
00161 ret = unwind_info_add_desc(rsize, (char *)&desc);
00162
00163 return ret;
00164 }
00165
00166
00167
00168
00169 __unw_error_t unwind_info_add_prologue_psp_sprel_info(__unw_info_t *info,
00170 __uint64_t offset) {
00171 __unw_error_t ret = __UNW_OK;
00172 __unw_format_p7_t *desc;
00173 __uint64_t rsize, esize;
00174 char encoded[1+__UNW_ENCODING_SIZE];
00175
00176
00177 if (NULL == info) {
00178 return __UNW_NULL_ERROR;
00179 } else if (_unwind_info + _unwind_info_size != info) {
00180 return __UNW_INV_ARG_ERROR;
00181 }
00182
00183
00184
00185
00186
00187 encoded[0] = 0xe3;
00188 if ((esize = __leb128_encode((char *)&encoded[1],
00189 (__uint64_t)__UNW_ENCODING_SIZE,
00190 offset)) == 0) {
00191 return __UNW_INTERNAL_ERROR;
00192 }
00193
00194 desc = (__unw_format_p7_t *)&encoded;
00195 rsize = 1 + esize;
00196
00197
00198 ret = unwind_info_add_desc(rsize, (char *)desc);
00199
00200 return ret;
00201 }