Unified · Split
| @@ -224,22 +224,34 @@ static void set_pages_executable(void *ptr, unsigned long length) · 223 unmodified lines | |||
| 224 | the stabs debug information */ | 224 | the stabs debug information */ |
| 225 | static uplong rt_printline(uplong wanted_pc, const char *msg) | 225 | static uplong rt_printline(uplong wanted_pc, const char *msg) |
| 226 | { | 226 | { |
| 227 | Stab_Sym *sym, *sym_end; | ||
| 228 | char func_name[128], last_func_name[128]; | 227 | char func_name[128], last_func_name[128]; |
| 229 | unsigned long func_addr, last_pc, pc; | 228 | uplong func_addr, last_pc, pc; |
| 230 | const char *incl_files[INCLUDE_STACK_SIZE]; | 229 | const char *incl_files[INCLUDE_STACK_SIZE]; |
| 231 | int incl_index, len, last_line_num, i; | 230 | int incl_index, len, last_line_num, i; |
| 232 | const char *str, *p; | 231 | const char *str, *p; |
| 233 | 232 | ||
| 233 | Stab_Sym *stab_sym = NULL, *stab_sym_end, *sym; | ||
| 234 | int stab_len = 0; | ||
| 235 | char *stab_str = NULL; | ||
| 236 | |||
| 237 | if (stab_section) { | ||
| 238 | stab_len = stab_section->data_offset; | ||
| 239 | stab_sym = (Stab_Sym *)stab_section->data; | ||
| 240 | stab_str = stabstr_section->data; | ||
| 241 | } | ||
| 242 | |||
| 234 | func_name[0] = '\0'; | 243 | func_name[0] = '\0'; |
| 235 | func_addr = 0; | 244 | func_addr = 0; |
| 236 | incl_index = 0; | 245 | incl_index = 0; |
| 237 | last_func_name[0] = '\0'; | 246 | last_func_name[0] = '\0'; |
| 238 | last_pc = 0xffffffff; | 247 | last_pc = (uplong)-1; |
| 239 | last_line_num = 1; | 248 | last_line_num = 1; |
| 240 | sym = (Stab_Sym *)stab_section->data + 1; | 249 | |
| 241 | sym_end = (Stab_Sym *)(stab_section->data + stab_section->data_offset); | 250 | if (!stab_sym) |
| 242 | while (sym < sym_end) { | 251 | goto no_stabs; |
| 252 | |||
| 253 | stab_sym_end = (Stab_Sym*)((char*)stab_sym + stab_len); | ||
| 254 | for (sym = stab_sym + 1; sym < stab_sym_end; ++sym) { | ||
| 243 | switch(sym->n_type) { | 255 | switch(sym->n_type) { |
| 244 | /* function start or end */ | 256 | /* function start or end */ |
| 245 | case N_FUN: | 257 | case N_FUN: |
| @@ -251,7 +263,7 @@ static uplong rt_printline(uplong wanted_pc, const char *msg) · 5 unmodified lines | |||
| 251 | func_name[0] = '\0'; | 263 | func_name[0] = '\0'; |
| 252 | func_addr = 0; | 264 | func_addr = 0; |
| 253 | } else { | 265 | } else { |
| 254 | str = stabstr_section->data + sym->n_strx; | 266 | str = stab_str + sym->n_strx; |
| 255 | p = strchr(str, ':'); | 267 | p = strchr(str, ':'); |
| 256 | if (!p) { | 268 | if (!p) { |
| 257 | pstrcpy(func_name, sizeof(func_name), str); | 269 | pstrcpy(func_name, sizeof(func_name), str); |
| @@ -277,7 +289,7 @@ static uplong rt_printline(uplong wanted_pc, const char *msg) · 19 unmodified lines | |||
| 277 | break; | 289 | break; |
| 278 | /* include files */ | 290 | /* include files */ |
| 279 | case N_BINCL: | 291 | case N_BINCL: |
| 280 | str = stabstr_section->data + sym->n_strx; | 292 | str = stab_str + sym->n_strx; |
| 281 | add_incl: | 293 | add_incl: |
| 282 | if (incl_index < INCLUDE_STACK_SIZE) { | 294 | if (incl_index < INCLUDE_STACK_SIZE) { |
| 283 | incl_files[incl_index++] = str; | 295 | incl_files[incl_index++] = str; |
| @@ -291,7 +303,7 @@ static uplong rt_printline(uplong wanted_pc, const char *msg) · 7 unmodified lines | |||
| 291 | if (sym->n_strx == 0) { | 303 | if (sym->n_strx == 0) { |
| 292 | incl_index = 0; /* end of translation unit */ | 304 | incl_index = 0; /* end of translation unit */ |
| 293 | } else { | 305 | } else { |
| 294 | str = stabstr_section->data + sym->n_strx; | 306 | str = stab_str + sym->n_strx; |
| 295 | /* do not add path */ | 307 | /* do not add path */ |
| 296 | len = strlen(str); | 308 | len = strlen(str); |
| 297 | if (len > 0 && str[len - 1] != '/') | 309 | if (len > 0 && str[len - 1] != '/') |
| @@ -299,11 +311,12 @@ static uplong rt_printline(uplong wanted_pc, const char *msg) · 1 unmodified line | |||
| 299 | } | 311 | } |
| 300 | break; | 312 | break; |
| 301 | } | 313 | } |
| 302 | sym++; | ||
| 303 | } | 314 | } |
| 304 | 315 | ||
| 316 | no_stabs: | ||
| 305 | /* second pass: we try symtab symbols (no line number info) */ | 317 | /* second pass: we try symtab symbols (no line number info) */ |
| 306 | incl_index = 0; | 318 | incl_index = 0; |
| 319 | if (symtab_section) | ||
| 307 | { | 320 | { |
| 308 | ElfW(Sym) *sym, *sym_end; | 321 | ElfW(Sym) *sym, *sym_end; |
| 309 | int type; | 322 | int type; |