History

tccrun: improve rt_printline output format

Prefix line with "file:linenumber:" such that editors can easily jump to the source location

grischka committed 16 years ago

Commit af839931 parent df4c0891 file · +18 −16Browse files

Unified · Split

tccrun.c+18−16
@@ -222,7 +222,7 @@ static void set_pages_executable(void *ptr, unsigned long length) · 221 unmodified lines
222 222
223/* print the position in the source file of PC value 'pc' by reading223/* print the position in the source file of PC value 'pc' by reading
224 the stabs debug information */224 the stabs debug information */
225static uplong rt_printline(uplong wanted_pc)225static uplong rt_printline(uplong wanted_pc, const char *msg)
226{226{
227 Stab_Sym *sym, *sym_end;227 Stab_Sym *sym, *sym_end;
228 char func_name[128], last_func_name[128];228 char func_name[128], last_func_name[128];
@@ -231,8 +231,6 @@ static uplong rt_printline(uplong wanted_pc) · 2 unmodified lines
231 int incl_index, len, last_line_num, i;231 int incl_index, len, last_line_num, i;
232 const char *str, *p;232 const char *str, *p;
233 233
234 fprintf(stderr, "0x%08lx:", (unsigned long)wanted_pc);
235
236 func_name[0] = '\0';234 func_name[0] = '\0';
237 func_addr = 0;235 func_addr = 0;
238 incl_index = 0;236 incl_index = 0;
@@ -327,20 +325,28 @@ static uplong rt_printline(uplong wanted_pc) · 88 unmodified lines
327 }325 }
328 }326 }
329 /* did not find any info: */327 /* did not find any info: */
330 fprintf(stderr, " ???\n");328 fprintf(stderr, "%s %p ???\n", msg, (void*)wanted_pc);
329 fflush(stderr);
331 return 0;330 return 0;
332 found:331 found:
333 if (last_func_name[0] != '\0') {332 i = incl_index;
333 if (i > 0)
334 fprintf(stderr, "%s:%d: ", incl_files[--i], last_line_num);
335 fprintf(stderr, "%s %p", msg, (void*)wanted_pc);
336 if (last_func_name[0] != '\0')
334 fprintf(stderr, " %s()", last_func_name);337 fprintf(stderr, " %s()", last_func_name);
335 }338 if (--i >= 0) {
336 if (incl_index > 0) {339 fprintf(stderr, " (included from ");
337 fprintf(stderr, " (%s:%d",340 for (;;) {
338 incl_files[incl_index - 1], last_line_num);341 fprintf(stderr, "%s", incl_files[i]);
339 for(i = incl_index - 2; i >= 0; i--)342 if (--i < 0)
340 fprintf(stderr, ", included from %s", incl_files[i]);343 break;
344 fprintf(stderr, ", ");
345 }
341 fprintf(stderr, ")");346 fprintf(stderr, ")");
342 }347 }
343 fprintf(stderr, "\n");348 fprintf(stderr, "\n");
349 fflush(stderr);
344 return func_addr;350 return func_addr;
345}351}
346 352
@@ -359,11 +365,7 @@ static void rt_error(ucontext_t *uc, const char *fmt, ...) · 12 unmodified lines
359 for(i=0;i<num_callers;i++) {365 for(i=0;i<num_callers;i++) {
360 if (rt_get_caller_pc(&pc, uc, i) < 0)366 if (rt_get_caller_pc(&pc, uc, i) < 0)
361 break;367 break;
362 if (i == 0)368 pc = rt_printline(pc, i ? "by" : "at");
363 fprintf(stderr, "at ");
364 else
365 fprintf(stderr, "by ");
366 pc = rt_printline(pc);
367 if (pc == (uplong)rt_prog_main && pc)369 if (pc == (uplong)rt_prog_main && pc)
368 break;370 break;
369 }371 }

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