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
222222
223223 /* print the position in the source file of PC value 'pc' by reading
224224 the stabs debug information */
225−static uplong rt_printline(uplong wanted_pc)
225+static uplong rt_printline(uplong wanted_pc, const char *msg)
226226 {
227227 Stab_Sym *sym, *sym_end;
228228 char func_name[128], last_func_name[128];
@@ -231,8 +231,6 @@ static uplong rt_printline(uplong wanted_pc) · 2 unmodified lines
231231 int incl_index, len, last_line_num, i;
232232 const char *str, *p;
233233
234− fprintf(stderr, "0x%08lx:", (unsigned long)wanted_pc);
235−
236234 func_name[0] = '\0';
237235 func_addr = 0;
238236 incl_index = 0;
@@ -327,20 +325,28 @@ static uplong rt_printline(uplong wanted_pc) · 88 unmodified lines
327325 }
328326 }
329327 /* did not find any info: */
330− fprintf(stderr, " ???\n");
328+ fprintf(stderr, "%s %p ???\n", msg, (void*)wanted_pc);
329+ fflush(stderr);
331330 return 0;
332331 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')
334337 fprintf(stderr, " %s()", last_func_name);
335− }
336− if (incl_index > 0) {
337− fprintf(stderr, " (%s:%d",
338− incl_files[incl_index - 1], last_line_num);
339− for(i = incl_index - 2; i >= 0; i--)
340− fprintf(stderr, ", included from %s", incl_files[i]);
338+ if (--i >= 0) {
339+ fprintf(stderr, " (included from ");
340+ for (;;) {
341+ fprintf(stderr, "%s", incl_files[i]);
342+ if (--i < 0)
343+ break;
344+ fprintf(stderr, ", ");
345+ }
341346 fprintf(stderr, ")");
342347 }
343348 fprintf(stderr, "\n");
349+ fflush(stderr);
344350 return func_addr;
345351 }
346352
@@ -359,11 +365,7 @@ static void rt_error(ucontext_t *uc, const char *fmt, ...) · 12 unmodified lines
359365 for(i=0;i<num_callers;i++) {
360366 if (rt_get_caller_pc(&pc, uc, i) < 0)
361367 break;
362− if (i == 0)
363− fprintf(stderr, "at ");
364− else
365− fprintf(stderr, "by ");
366− pc = rt_printline(pc);
368+ pc = rt_printline(pc, i ? "by" : "at");
367369 if (pc == (uplong)rt_prog_main && pc)
368370 break;
369371 }

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