History

tccrun: rt_printline: fix no-stabs case

grischka committed 16 years ago

Commit d59bd8b1 parent af839931 file · +23 −10Browse files

Unified · Split

tccrun.c+23−10
@@ -224,22 +224,34 @@ static void set_pages_executable(void *ptr, unsigned long length) · 223 unmodified lines
224224 the stabs debug information */
225225 static uplong rt_printline(uplong wanted_pc, const char *msg)
226226 {
227− Stab_Sym *sym, *sym_end;
228227 char func_name[128], last_func_name[128];
229− unsigned long func_addr, last_pc, pc;
228+ uplong func_addr, last_pc, pc;
230229 const char *incl_files[INCLUDE_STACK_SIZE];
231230 int incl_index, len, last_line_num, i;
232231 const char *str, *p;
233232
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+
234243 func_name[0] = '\0';
235244 func_addr = 0;
236245 incl_index = 0;
237246 last_func_name[0] = '\0';
238− last_pc = 0xffffffff;
247+ last_pc = (uplong)-1;
239248 last_line_num = 1;
240− sym = (Stab_Sym *)stab_section->data + 1;
241− sym_end = (Stab_Sym *)(stab_section->data + stab_section->data_offset);
242− while (sym < sym_end) {
249+
250+ if (!stab_sym)
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) {
243255 switch(sym->n_type) {
244256 /* function start or end */
245257 case N_FUN:
@@ -251,7 +263,7 @@ static uplong rt_printline(uplong wanted_pc, const char *msg) · 5 unmodified lines
251263 func_name[0] = '\0';
252264 func_addr = 0;
253265 } else {
254− str = stabstr_section->data + sym->n_strx;
266+ str = stab_str + sym->n_strx;
255267 p = strchr(str, ':');
256268 if (!p) {
257269 pstrcpy(func_name, sizeof(func_name), str);
@@ -277,7 +289,7 @@ static uplong rt_printline(uplong wanted_pc, const char *msg) · 19 unmodified lines
277289 break;
278290 /* include files */
279291 case N_BINCL:
280− str = stabstr_section->data + sym->n_strx;
292+ str = stab_str + sym->n_strx;
281293 add_incl:
282294 if (incl_index < INCLUDE_STACK_SIZE) {
283295 incl_files[incl_index++] = str;
@@ -291,7 +303,7 @@ static uplong rt_printline(uplong wanted_pc, const char *msg) · 7 unmodified lines
291303 if (sym->n_strx == 0) {
292304 incl_index = 0; /* end of translation unit */
293305 } else {
294− str = stabstr_section->data + sym->n_strx;
306+ str = stab_str + sym->n_strx;
295307 /* do not add path */
296308 len = strlen(str);
297309 if (len > 0 && str[len - 1] != '/')
@@ -299,11 +311,12 @@ static uplong rt_printline(uplong wanted_pc, const char *msg) · 1 unmodified line
299311 }
300312 break;
301313 }
302− sym++;
303314 }
304315
316+no_stabs:
305317 /* second pass: we try symtab symbols (no line number info) */
306318 incl_index = 0;
319+ if (symtab_section)
307320 {
308321 ElfW(Sym) *sym, *sym_end;
309322 int type;

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t