added verbosity levels (-vv -vvv)

tcc-xref
grischka 2008-03-31 19:49:14 +00:00
parent 4d9aaacc85
commit a327c7a552
3 changed files with 27 additions and 14 deletions

View File

@ -153,7 +153,7 @@ General Options:
@c man begin OPTIONS @c man begin OPTIONS
@table @option @table @option
@item -v @item -v
Display current TCC version. Display current TCC version, increase verbosity.
@item -c @item -c
Generate an object file (@option{-o} option must also be given). Generate an object file (@option{-o} option must also be given).

37
tcc.c
View File

@ -1960,6 +1960,9 @@ BufferedFile *tcc_open(TCCState *s1, const char *filename)
fd = 0, filename = "stdin"; fd = 0, filename = "stdin";
else else
fd = open(filename, O_RDONLY | O_BINARY); fd = open(filename, O_RDONLY | O_BINARY);
if ((verbose == 2 && fd >= 0) || verbose == 3)
printf("%s %*s%s\n", fd < 0 ? "nf":"->",
(s1->include_stack_ptr - s1->include_stack), "", filename);
if (fd < 0) if (fd < 0)
return NULL; return NULL;
bf = tcc_malloc(sizeof(BufferedFile)); bf = tcc_malloc(sizeof(BufferedFile));
@ -3033,6 +3036,11 @@ static void preprocess(int is_bof)
printf("%s: skipping %s\n", file->filename, buf); printf("%s: skipping %s\n", file->filename, buf);
#endif #endif
} else { } else {
if (s1->include_stack_ptr >= s1->include_stack + INCLUDE_STACK_SIZE)
error("#include recursion too deep");
/* push current file in stack */
/* XXX: fix current line init */
*s1->include_stack_ptr++ = file;
if (c == '\"') { if (c == '\"') {
/* first search in current dir if "header.h" */ /* first search in current dir if "header.h" */
size = tcc_basename(file->filename) - file->filename; size = tcc_basename(file->filename) - file->filename;
@ -3049,8 +3057,6 @@ static void preprocess(int is_bof)
goto found; goto found;
} }
} }
if (s1->include_stack_ptr >= s1->include_stack + INCLUDE_STACK_SIZE)
error("#include recursion too deep");
/* now search in all the include paths */ /* now search in all the include paths */
n = s1->nb_include_paths + s1->nb_sysinclude_paths; n = s1->nb_include_paths + s1->nb_sysinclude_paths;
for(i = 0; i < n; i++) { for(i = 0; i < n; i++) {
@ -3070,17 +3076,15 @@ static void preprocess(int is_bof)
goto found; goto found;
} }
} }
--s1->include_stack_ptr;
error("include file '%s' not found", buf); error("include file '%s' not found", buf);
f = NULL; break;
found: found:
#ifdef INC_DEBUG #ifdef INC_DEBUG
printf("%s: including %s\n", file->filename, buf1); printf("%s: including %s\n", file->filename, buf1);
#endif #endif
f->inc_type = c; f->inc_type = c;
pstrcpy(f->inc_filename, sizeof(f->inc_filename), buf); pstrcpy(f->inc_filename, sizeof(f->inc_filename), buf);
/* push current file in stack */
/* XXX: fix current line init */
*s1->include_stack_ptr++ = file;
file = f; file = f;
/* add include file debug info */ /* add include file debug info */
if (do_debug) { if (do_debug) {
@ -10566,7 +10570,7 @@ void help(void)
" [-static] [infile1 infile2...] [-run infile args...]\n" " [-static] [infile1 infile2...] [-run infile args...]\n"
"\n" "\n"
"General options:\n" "General options:\n"
" -v display current version\n" " -v display current version, increase verbosity\n"
" -c compile only - generate an object file\n" " -c compile only - generate an object file\n"
" -o outfile set output filename\n" " -o outfile set output filename\n"
" -Bdir set tcc internal library path\n" " -Bdir set tcc internal library path\n"
@ -10671,7 +10675,7 @@ static const TCCOption tcc_options[] = {
{ "nostdinc", TCC_OPTION_nostdinc, 0 }, { "nostdinc", TCC_OPTION_nostdinc, 0 },
{ "nostdlib", TCC_OPTION_nostdlib, 0 }, { "nostdlib", TCC_OPTION_nostdlib, 0 },
{ "print-search-dirs", TCC_OPTION_print_search_dirs, 0 }, { "print-search-dirs", TCC_OPTION_print_search_dirs, 0 },
{ "v", TCC_OPTION_v, 0 }, { "v", TCC_OPTION_v, TCC_OPTION_HAS_ARG | TCC_OPTION_NOSEP },
{ "w", TCC_OPTION_w, 0 }, { "w", TCC_OPTION_w, 0 },
{ "pipe", TCC_OPTION_pipe, 0}, { "pipe", TCC_OPTION_pipe, 0},
{ "E", TCC_OPTION_E, 0}, { "E", TCC_OPTION_E, 0},
@ -10723,10 +10727,12 @@ int parse_args(TCCState *s, int argc, char **argv)
optind = 0; optind = 0;
while (1) { while (1) {
if (optind >= argc) { if (optind >= argc) {
if (nb_files == 0 && !print_search_dirs) if (nb_files == 0 && !print_search_dirs) {
if (verbose)
exit(0);
goto show_help; goto show_help;
else }
break; break;
} }
r = argv[optind++]; r = argv[optind++];
if (r[0] != '-' || r[1] == '\0') { if (r[0] != '-' || r[1] == '\0') {
@ -10864,8 +10870,11 @@ int parse_args(TCCState *s, int argc, char **argv)
} }
break; break;
case TCC_OPTION_v: case TCC_OPTION_v:
printf("tcc version %s\n", TCC_VERSION); do {
exit(0); if (0 == verbose++)
printf("tcc version %s\n", TCC_VERSION);
} while (*optarg++ == 'v');
break;
case TCC_OPTION_f: case TCC_OPTION_f:
if (tcc_set_flag(s, optarg, 1) < 0 && s->warn_unsupported) if (tcc_set_flag(s, optarg, 1) < 0 && s->warn_unsupported)
goto unsupported_option; goto unsupported_option;
@ -11020,6 +11029,8 @@ int main(int argc, char **argv)
if (tcc_add_library(s, filename + 2) < 0) if (tcc_add_library(s, filename + 2) < 0)
error("cannot find %s", filename); error("cannot find %s", filename);
} else { } else {
if (1 == verbose)
printf("-> %s\n", filename);
if (tcc_add_file(s, filename) < 0) if (tcc_add_file(s, filename) < 0)
ret = 1; ret = 1;
} }

View File

@ -1664,6 +1664,8 @@ int tcc_output_file(TCCState *s1, const char *filename)
goto fail; goto fail;
} }
f = fdopen(fd, "wb"); f = fdopen(fd, "wb");
if (verbose)
printf("<- %s\n", filename);
#ifdef TCC_TARGET_COFF #ifdef TCC_TARGET_COFF
if (s1->output_format == TCC_OUTPUT_FORMAT_COFF) { if (s1->output_format == TCC_OUTPUT_FORMAT_COFF) {