Index: tools/rsym/log2lines.c =================================================================== --- tools/rsym/log2lines.c (revision 44285) +++ tools/rsym/log2lines.c (working copy) @@ -18,7 +18,7 @@ #include "rsym.h" -#define LOG2LINES_VERSION "1.1" +#define LOG2LINES_VERSION "1.2" #define INVALID_BASE 0xFFFFFFFFL @@ -53,6 +53,8 @@ #define CP_FMT CP_CMD "%s %s > " DEV_NULL #define CMD_7Z "7z" +//#define UNZIP_FMT_7Z "%s e -y %s -o%s > " DEV_NULL +#define UNZIP_FMT_7Z "%s e -y %s -o%s" #define UNZIP_FMT "%s x -y -r %s -o%s > " DEV_NULL #define UNZIP_FMT_CAB \ "%s x -y -r %s" PATH_STR "reactos" PATH_STR "reactos.cab -o%s" PATH_STR "reactos" PATH_STR "reactos > " DEV_NULL @@ -84,6 +86,7 @@ int redo; int skipped; int diff; + int majordiff; int offset_errors; int total; }; @@ -180,6 +183,7 @@ PSYMBOLFILE_HEADER RosSymHeader = (PSYMBOLFILE_HEADER) data; PROSSYM_ENTRY e = NULL; PROSSYM_ENTRY e2 = NULL; + int bLineOnly = 0; char *Strings = (char *)data + RosSymHeader->StringsOffset; @@ -188,9 +192,13 @@ { e2 = find_offset(data, offset-1, toString); + if ( e2 ) + { + bLineOnly = (e->FileOffset == e2->FileOffset) && (e->FunctionOffset == e2->FunctionOffset); + } + if ( e == e2 ) e2 = NULL; - if ( opt_Twice && e2 ) { e = e2; @@ -205,13 +213,25 @@ { // put in toString if provided if ( e2 ) { - snprintf(toString, LINESIZE, "%s:%u (%s) [%s:%u (%s)]", - &Strings[e->FileOffset], - (unsigned int)e->SourceLine, - &Strings[e->FunctionOffset], - &Strings[e2->FileOffset], - (unsigned int)e2->SourceLine, - &Strings[e2->FunctionOffset]); + if( bLineOnly ) + { + snprintf(toString, LINESIZE, "%s:%u[%u] (%s)", + &Strings[e->FileOffset], + (unsigned int)e->SourceLine, + (unsigned int)e2->SourceLine, + &Strings[e->FunctionOffset]); + } + else + { + snprintf(toString, LINESIZE, "%s:%u (%s) [%s:%u (%s)]", + &Strings[e->FileOffset], + (unsigned int)e->SourceLine, + &Strings[e->FunctionOffset], + &Strings[e2->FileOffset], + (unsigned int)e2->SourceLine, + &Strings[e2->FunctionOffset]); + summ.majordiff ++; + } summ.diff ++; } else @@ -227,13 +247,25 @@ { // to stdout if ( e2 ) { - printf("%s:%u (%s) [%s:%u (%s)]\n", - &Strings[e->FileOffset], - (unsigned int)e->SourceLine, - &Strings[e->FunctionOffset], - &Strings[e2->FileOffset], - (unsigned int)e2->SourceLine, - &Strings[e2->FunctionOffset]); + if( bLineOnly ) + { + printf("%s:%u[%u] (%s)", + &Strings[e->FileOffset], + (unsigned int)e->SourceLine, + (unsigned int)e2->SourceLine, + &Strings[e->FunctionOffset]); + } + else + { + printf("%s:%u (%s) [%s:%u (%s)]\n", + &Strings[e->FileOffset], + (unsigned int)e->SourceLine, + &Strings[e->FunctionOffset], + &Strings[e2->FileOffset], + (unsigned int)e2->SourceLine, + &Strings[e2->FunctionOffset]); + summ.majordiff ++; + } summ.diff ++; } else @@ -868,13 +900,14 @@ if (outFile) { fprintf(outFile, "\n*** LOG2LINES SUMMARY ***\n"); - fprintf(outFile, "Translated: %d\n", summ.translated); - fprintf(outFile, "Reverted: %d\n", summ.undo); - fprintf(outFile, "Retranslated: %d\n", summ.redo); - fprintf(outFile, "Skipped: %d\n", summ.skipped); - fprintf(outFile, "Differ: %d\n", summ.diff); - fprintf(outFile, "Offset error: %d\n", summ.offset_errors); - fprintf(outFile, "Total: %d\n", summ.total); + fprintf(outFile, "Translated: %d\n", summ.translated); + fprintf(outFile, "Reverted: %d\n", summ.undo); + fprintf(outFile, "Retranslated: %d\n", summ.redo); + fprintf(outFile, "Skipped: %d\n", summ.skipped); + fprintf(outFile, "Differ: %d\n", summ.diff); + fprintf(outFile, "Differ(function/source): %d\n", summ.majordiff); + fprintf(outFile, "Offset error: %d\n", summ.offset_errors); + fprintf(outFile, "Total: %d\n", summ.total); fprintf(outFile, "-------------------------------\n"); fprintf(outFile, "Log2lines version: " LOG2LINES_VERSION "\n"); fprintf(outFile, "Directory: %s\n",opt_dir); @@ -927,7 +960,6 @@ translate_line(outFile, Line, path, LineOut); translate_char(c, outFile); } - i = 0; } else { @@ -1008,7 +1040,9 @@ " -d |\n" " Directory to scan for images. (Do not append a '" PATH_STR "')\n" " This option also takes an ISO image as argument:\n" -" - The image is recognized by the '.iso' extension.\n" +" - The image is recognized by the '.iso' or '.7z' extension.\n" +" - NOTE: The '.7z' and extracted '.iso' basenames must be identical,\n" +" which is normally true for Reactos trunk builds.\n" " - The image will be unpacked to a directory with the same name.\n" " - The embedded reactos.cab file will also be unpacked.\n" " - Combined with -f the file will be re-unpacked.\n" @@ -1026,16 +1060,18 @@ " -r Raw output without translation.\n\n" " -s Statistics. A summary with the following info is printed after EOF:\n" " *** LOG2LINES SUMMARY ***\n" -" - Translated: Translated lines.\n" -" - Reverted: Lines translated back. See -u option\n" -" - Retranslated: Lines retranslated. See -U option\n" -" - Skipped: Lines not translated.\n" -" - Differ: Lines where (addr-1) info differs. See -tT options\n" -" - Offset error: Image exists, but error retrieving offset info.\n" -" - Total: Total number of lines attempted to translate.\n" +" - Translated: Translated lines.\n" +" - Reverted: Lines translated back. See -u option\n" +" - Retranslated: Lines retranslated. See -U option\n" +" - Skipped: Lines not translated.\n" +" - Differ: Lines where (addr-1) info differs. See -tT options\n" +" - Differ(func/src):Lines where also function and source info differ.\n" +" - Offset error: Image exists, but error retrieving offset info.\n" +" - Total: Total number of lines attempted to translate.\n" " Also some version info is displayed.\n\n" " -t Translate twice. The address itself and for (address - 1)\n" -" Display extra filename and linenumber between [..] if they differ\n\n" +" Show extra filename and linenumber between [..] if they differ\n" +" If only the linenumbers differ then only show the extra linenumber.\n\n" " -T As -t, but the original filename+linenumber gets replaced\n\n" " -u Undo translations.\n" " Lines are translated back (reverted) to the form \n" @@ -1061,7 +1097,12 @@ " Use kdbg debugger to send output to logfile:\n" " log2lines < \\\\.\\pipe\\kdbg > dbg.log\n\n" " Re-translate a debug log:\n" -" log2lines -d bootcd-38701-dbg.iso < bugxxxx.log\n\n" +" log2lines -U -d bootcd-38701-dbg.iso < bugxxxx.log\n\n" +" Re-translate a debug log. Specify a 7z file, which wil be decompressed.\n" +" Also check for (address) - (address - 1) differences.\n" +" This would generate loglines like\n" +" '' :\n" +" log2lines -U -t -d bootcd-38701-dbg.7z < bugxxxx.log\n\n" "\n"; static void @@ -1135,10 +1176,42 @@ static int check_directory(int force) { + char Line[LINESIZE]; char freeldr_path[MAX_PATH]; char iso_path[MAX_PATH]; + char compressed_7z_path[MAX_PATH]; + char *check_iso; + char *check_dir; - char *check_iso = strrchr(opt_dir, '.'); + check_iso = strrchr(opt_dir, '.'); + if (check_iso && PATHCMP(check_iso, ".7z") == 0) + { + if (opt_verbose) + fprintf(stderr, "Uncompressing 7z image: %s\n", opt_dir); + + //First attempt to decompress to a .iso image + strcpy(compressed_7z_path, opt_dir); + if ( (check_dir = strrchr(compressed_7z_path, PATH_CHAR)) ) + { + *check_dir = '\0'; + } + else + strcpy(compressed_7z_path, "."); //default to current dir + + sprintf(Line, UNZIP_FMT_7Z, opt_7z, opt_dir, compressed_7z_path); + if (system(Line) < 0) + { + fprintf(stderr, "\nCannot decompress %s to iso image\n", opt_dir); + if (opt_verbose) + fprintf(stderr, "Failed to execute: '%s'\n", Line); + return 2; + } + /* This of course only works if the .7z and .iso basenames are identical + * which is normally true for our trunk builds: + */ + strcpy(check_iso, ".iso"); + } + if (check_iso && PATHCMP(check_iso, ".iso") == 0) { if (opt_verbose)