Deleted Added
full compact
uwx_utable.c (160158) uwx_utable.c (160163)
1/*
2Copyright (c) 2003-2006 Hewlett-Packard Development Company, L.P.
3Permission is hereby granted, free of charge, to any person
4obtaining a copy of this software and associated documentation
5files (the "Software"), to deal in the Software without
6restriction, including without limitation the rights to use,
7copy, modify, merge, publish, distribute, sublicense, and/or sell
8copies of the Software, and to permit persons to whom the

--- 62 unchanged lines hidden (view full) ---

71 uint64_t unwind_end;
72 int keys;
73 int status;
74
75 /* Get unwind table information from the result vector. */
76 /* Make sure all three required values are given. */
77
78 keys = 0;
1/*
2Copyright (c) 2003-2006 Hewlett-Packard Development Company, L.P.
3Permission is hereby granted, free of charge, to any person
4obtaining a copy of this software and associated documentation
5files (the "Software"), to deal in the Software without
6restriction, including without limitation the rights to use,
7copy, modify, merge, publish, distribute, sublicense, and/or sell
8copies of the Software, and to permit persons to whom the

--- 62 unchanged lines hidden (view full) ---

71 uint64_t unwind_end;
72 int keys;
73 int status;
74
75 /* Get unwind table information from the result vector. */
76 /* Make sure all three required values are given. */
77
78 keys = 0;
79 text_base = 0;
79 unwind_flags = 0;
80 unwind_flags = 0;
81 unwind_start = 0;
82 unwind_end = 0;
80 while (*uvec != 0) {
81 switch ((int)*uvec++) {
82 case UWX_KEY_TBASE:
83 keys |= 1;
84 env->text_base = text_base = *uvec++;
85 break;
86 case UWX_KEY_UFLAGS:
87 unwind_flags = *uvec++;

--- 51 unchanged lines hidden (view full) ---

139int uwx_search_utable32(
140 struct uwx_env *env,
141 uint32_t ip,
142 uint32_t text_base,
143 uint32_t unwind_start,
144 uint32_t unwind_end,
145 struct uwx_utable_entry *uentry)
146{
83 while (*uvec != 0) {
84 switch ((int)*uvec++) {
85 case UWX_KEY_TBASE:
86 keys |= 1;
87 env->text_base = text_base = *uvec++;
88 break;
89 case UWX_KEY_UFLAGS:
90 unwind_flags = *uvec++;

--- 51 unchanged lines hidden (view full) ---

142int uwx_search_utable32(
143 struct uwx_env *env,
144 uint32_t ip,
145 uint32_t text_base,
146 uint32_t unwind_start,
147 uint32_t unwind_end,
148 struct uwx_utable_entry *uentry)
149{
147 int status;
148 int lb;
149 int ub;
150 int mid;
151 int len;
152 uint32_t code_start;
153 uint32_t code_end;
154 uint32_t unwind_info;
155

--- 4 unchanged lines hidden (view full) ---

160
161 TRACE_T_SEARCH32(ip)
162
163 /* Standard binary search. */
164 /* Might modify this to do interpolation in the future. */
165
166 lb = 0;
167 ub = (unwind_end - unwind_start) / (3 * WORDSZ);
150 int lb;
151 int ub;
152 int mid;
153 int len;
154 uint32_t code_start;
155 uint32_t code_end;
156 uint32_t unwind_info;
157

--- 4 unchanged lines hidden (view full) ---

162
163 TRACE_T_SEARCH32(ip)
164
165 /* Standard binary search. */
166 /* Might modify this to do interpolation in the future. */
167
168 lb = 0;
169 ub = (unwind_end - unwind_start) / (3 * WORDSZ);
170 mid = 0;
168 while (ub > lb) {
169 mid = (lb + ub) / 2;
171 while (ub > lb) {
172 mid = (lb + ub) / 2;
170 len = COPYIN_UINFO_4((char *)&code_start, unwind_start+mid*3*WORDSZ);
173 len = COPYIN_UINFO_4((char *)&code_start,
174 (uintptr_t)(unwind_start+mid*3*WORDSZ));
171 len += COPYIN_UINFO_4((char *)&code_end,
175 len += COPYIN_UINFO_4((char *)&code_end,
172 unwind_start+mid*3*WORDSZ+WORDSZ);
176 (uintptr_t)(unwind_start+mid*3*WORDSZ+WORDSZ));
173 if (len != 2 * WORDSZ)
174 return UWX_ERR_COPYIN_UTBL;
175 if (env->byte_swap) {
176 uwx_swap4(&code_start);
177 uwx_swap4(&code_end);
178 }
179 TRACE_T_BINSEARCH32(lb, ub, mid, code_start, code_end)
180 if (ip >= code_end)
181 lb = mid + 1;
182 else if (ip < code_start)
183 ub = mid;
184 else
185 break;
186 }
187 if (ub <= lb)
188 return UWX_ERR_NOUENTRY;
189 len = COPYIN_UINFO_4((char *)&unwind_info,
177 if (len != 2 * WORDSZ)
178 return UWX_ERR_COPYIN_UTBL;
179 if (env->byte_swap) {
180 uwx_swap4(&code_start);
181 uwx_swap4(&code_end);
182 }
183 TRACE_T_BINSEARCH32(lb, ub, mid, code_start, code_end)
184 if (ip >= code_end)
185 lb = mid + 1;
186 else if (ip < code_start)
187 ub = mid;
188 else
189 break;
190 }
191 if (ub <= lb)
192 return UWX_ERR_NOUENTRY;
193 len = COPYIN_UINFO_4((char *)&unwind_info,
190 unwind_start+mid*3*WORDSZ+2*WORDSZ);
194 (uintptr_t)(unwind_start+mid*3*WORDSZ+2*WORDSZ));
191 if (len != WORDSZ)
192 return UWX_ERR_COPYIN_UTBL;
193 if (env->byte_swap)
194 uwx_swap4(&unwind_info);
195 uentry->ptr_size = WORDSZ;
196 uentry->code_start = SWIZZLE(text_base + code_start);
197 uentry->code_end = SWIZZLE(text_base + code_end);
198 uentry->unwind_info = SWIZZLE(text_base + unwind_info);

--- 12 unchanged lines hidden (view full) ---

211int uwx_search_utable64(
212 struct uwx_env *env,
213 uint64_t ip,
214 uint64_t text_base,
215 uint64_t unwind_start,
216 uint64_t unwind_end,
217 struct uwx_utable_entry *uentry)
218{
195 if (len != WORDSZ)
196 return UWX_ERR_COPYIN_UTBL;
197 if (env->byte_swap)
198 uwx_swap4(&unwind_info);
199 uentry->ptr_size = WORDSZ;
200 uentry->code_start = SWIZZLE(text_base + code_start);
201 uentry->code_end = SWIZZLE(text_base + code_end);
202 uentry->unwind_info = SWIZZLE(text_base + unwind_info);

--- 12 unchanged lines hidden (view full) ---

215int uwx_search_utable64(
216 struct uwx_env *env,
217 uint64_t ip,
218 uint64_t text_base,
219 uint64_t unwind_start,
220 uint64_t unwind_end,
221 struct uwx_utable_entry *uentry)
222{
219 int status;
220 int lb;
221 int ub;
222 int mid;
223 int len;
224 uint64_t code_start;
225 uint64_t code_end;
226 uint64_t unwind_info;
227
228 /* Since the unwind table uses segment-relative offsets, convert */
229 /* the IP in the current context to a segment-relative offset. */
230
231 ip -= text_base;
232
233 /* Standard binary search. */
234 /* Might modify this to do interpolation in the future. */
235
236 lb = 0;
237 ub = (unwind_end - unwind_start) / (3 * DWORDSZ);
223 int lb;
224 int ub;
225 int mid;
226 int len;
227 uint64_t code_start;
228 uint64_t code_end;
229 uint64_t unwind_info;
230
231 /* Since the unwind table uses segment-relative offsets, convert */
232 /* the IP in the current context to a segment-relative offset. */
233
234 ip -= text_base;
235
236 /* Standard binary search. */
237 /* Might modify this to do interpolation in the future. */
238
239 lb = 0;
240 ub = (unwind_end - unwind_start) / (3 * DWORDSZ);
241 mid = 0;
238 while (ub > lb) {
239 mid = (lb + ub) / 2;
240 len = COPYIN_UINFO_8((char *)&code_start, unwind_start+mid*3*DWORDSZ);
241 len += COPYIN_UINFO_8((char *)&code_end,
242 unwind_start+mid*3*DWORDSZ+DWORDSZ);
243 if (len != 2 * DWORDSZ)
244 return UWX_ERR_COPYIN_UTBL;
245 if (env->byte_swap) {

--- 24 unchanged lines hidden ---
242 while (ub > lb) {
243 mid = (lb + ub) / 2;
244 len = COPYIN_UINFO_8((char *)&code_start, unwind_start+mid*3*DWORDSZ);
245 len += COPYIN_UINFO_8((char *)&code_end,
246 unwind_start+mid*3*DWORDSZ+DWORDSZ);
247 if (len != 2 * DWORDSZ)
248 return UWX_ERR_COPYIN_UTBL;
249 if (env->byte_swap) {

--- 24 unchanged lines hidden ---