Author: dgorbachev
Date: Wed Feb 10 13:10:23 2010
New Revision: 45551
URL:
http://svn.reactos.org/svn/reactos?rev=45551&view=rev
Log:
Update log2lines to ver. 2.1. Jan Roeloffzen, bug #4342.
Added:
trunk/reactos/tools/log2lines/cmd.c (with props)
trunk/reactos/tools/log2lines/cmd.h (with props)
Modified:
trunk/reactos/tools/log2lines/cache.c
trunk/reactos/tools/log2lines/cache.h
trunk/reactos/tools/log2lines/compat.h
trunk/reactos/tools/log2lines/config.h
trunk/reactos/tools/log2lines/help.c
trunk/reactos/tools/log2lines/help.h
trunk/reactos/tools/log2lines/image.c
trunk/reactos/tools/log2lines/image.h
trunk/reactos/tools/log2lines/list.c
trunk/reactos/tools/log2lines/list.h
trunk/reactos/tools/log2lines/log2lines.c
trunk/reactos/tools/log2lines/log2lines.mak
trunk/reactos/tools/log2lines/options.c
trunk/reactos/tools/log2lines/options.h
trunk/reactos/tools/log2lines/revision.c
trunk/reactos/tools/log2lines/revision.h
trunk/reactos/tools/log2lines/stat.c
trunk/reactos/tools/log2lines/stat.h
trunk/reactos/tools/log2lines/util.c
trunk/reactos/tools/log2lines/util.h
trunk/reactos/tools/log2lines/version.h
Modified: trunk/reactos/tools/log2lines/cache.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/tools/log2lines/cache.c?re…
==============================================================================
--- trunk/reactos/tools/log2lines/cache.c [iso-8859-1] (original)
+++ trunk/reactos/tools/log2lines/cache.c [iso-8859-1] Wed Feb 10 13:10:23 2010
@@ -11,12 +11,10 @@
#include "util.h"
#include "version.h"
#include "compat.h"
-#include "config.h"
-#include "list.h"
#include "options.h"
#include "help.h"
#include "image.h"
-#include "revision.h"
+
#include "log2lines.h"
static char *cache_name;
@@ -77,11 +75,6 @@
char *check_iso;
char *check_dir;
- if (opt_Revision)
- {
- revinfo.rev = getRevision(NULL, 1);
- revinfo.range = DEF_RANGE;
- }
check_iso = strrchr(opt_dir, '.');
l2l_dbg(1, "Checking directory: %s\n", opt_dir);
if (check_iso && PATHCMP(check_iso, ".7z") == 0)
@@ -139,11 +132,6 @@
return 1;
}
}
- if (opt_Revision)
- {
- revinfo.buildrev = getTBRevision(opt_dir);
- l2l_dbg(1, "Trunk build revision: %d\n", revinfo.buildrev);
- }
cache_name = malloc(MAX_PATH);
tmp_name = malloc(MAX_PATH);
strcpy(cache_name, opt_dir);
@@ -238,10 +226,11 @@
l2l_dbg(0, "Scanning %s ...\n", opt_dir);
snprintf(Line, LINESIZE, DIR_FMT, opt_dir, tmp_name);
l2l_dbg(1, "Executing: %s\n", Line);
- if (system(Line) < 0)
+ if (system(Line) != 0)
{
l2l_dbg(0, "Cannot list directory %s\n", opt_dir);
l2l_dbg(1, "Failed to execute: '%s'\n", Line);
+ remove(tmp_name);
return 2;
}
l2l_dbg(0, "Creating cache ...");
Modified: trunk/reactos/tools/log2lines/cache.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/tools/log2lines/cache.h?re…
==============================================================================
--- trunk/reactos/tools/log2lines/cache.h [iso-8859-1] (original)
+++ trunk/reactos/tools/log2lines/cache.h [iso-8859-1] Wed Feb 10 13:10:23 2010
@@ -13,3 +13,5 @@
int create_cache(int force, int skipImageBase);
#endif /* __L2L_CACHE_H__ */
+
+/* EOF */
Added: trunk/reactos/tools/log2lines/cmd.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/tools/log2lines/cmd.c?rev=…
==============================================================================
--- trunk/reactos/tools/log2lines/cmd.c (added)
+++ trunk/reactos/tools/log2lines/cmd.c [iso-8859-1] Wed Feb 10 13:10:23 2010
@@ -1,0 +1,291 @@
+/*
+ * ReactOS log2lines
+ * Written by Jan Roeloffzen
+ *
+ * - Cli for escape commands
+ */
+#include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+
+#include "util.h"
+#include "cmd.h"
+#include "options.h"
+#include "log2lines.h"
+#include "help.h"
+
+/* When you edit the cmd line and/or use the history instead of just typing,
+ * a bunch of editing BS and space characters
+ * is inserted, so the string looks right on the console but still
+ * starts with the original string:
+ */
+static char
+*backSpaceEdit(char *s)
+{
+ char c;
+ char *edit = s;
+ char *text = s;
+
+ while (( c = *edit++ ))
+ {
+ switch (c)
+ {
+ case KDBG_BS_CHAR:
+ if (text > s)
+ text --;
+ break;
+ default:
+ *text++ = c;
+ }
+ }
+ *text = '\0';
+
+ return s;
+}
+
+static int
+handle_switch(FILE *outFile, int *sw, char *arg, char *desc)
+{
+ int changed =0;
+ int x = 0;
+
+ if (arg && (strcmp(arg,"") != 0))
+ {
+ x = atoi(arg);
+ if (x != *sw)
+ {
+ *sw = x;
+ changed = 1;
+ }
+ }
+ if (desc)
+ {
+ esclog(outFile, "%s is %d (%s)\n", desc, *sw, changed ?
"changed":"unchanged");
+ if (!arg)
+ esclog(outFile, "(readonly)\n");
+ }
+
+ return changed;
+}
+
+static int
+handle_switch_str(FILE *outFile, char *sw, char *arg, char *desc)
+{
+ int changed =0;
+
+ if (arg)
+ {
+ if (strcmp(arg,"") != 0)
+ {
+ if (strcmp(arg,KDBG_ESC_OFF) == 0)
+ {
+ if (*sw)
+ changed = 1;
+ *sw = '\0';
+ }
+ else if (strcmp(arg, sw) != 0)
+ {
+ strcpy(sw, arg);
+ changed = 1;
+ }
+ }
+ }
+ if (desc)
+ {
+ esclog(outFile, "%s is \"%s\" (%s)\n", desc, sw, changed ?
"changed":"unchanged");
+ if (!arg)
+ esclog(outFile, "(readonly)\n");
+ }
+
+ return changed;
+}
+
+static int
+handle_switch_pstr(FILE *outFile, char **psw, char *arg, char *desc)
+{
+ int changed =0;
+
+ if (arg)
+ {
+ if (strcmp(arg,"") != 0)
+ {
+ if (strcmp(arg,KDBG_ESC_OFF) == 0)
+ {
+ if (*psw)
+ changed = 1;
+ free(*psw);
+ *psw = NULL;
+ }
+ else
+ {
+ if (!*psw)
+ {
+ *psw = malloc(LINESIZE);
+ **psw = '\0';
+ }
+
+ if (strcmp(arg, *psw) != 0)
+ {
+ strcpy(*psw, arg);
+ changed = 1;
+ }
+ }
+ }
+ }
+ if (desc)
+ {
+ esclog(outFile, "%s is \"%s\" (%s)\n", desc, *psw, changed ?
"changed":"unchanged");
+ if (!arg)
+ esclog(outFile, "(readonly)\n");
+ }
+
+ return changed;
+}
+
+char
+handle_escape_cmd(FILE *outFile, char *Line, char *path, char *LineOut)
+{
+ char cmd;
+ char sep = '\n';
+ char *arg;
+ char *l = Line;
+ int res = 1;
+ int cnt = 0;
+ int changed = 0;
+
+ l = backSpaceEdit(l);
+ if (l[1] != KDBG_ESC_CHAR)
+ return l[1]; //for reprocessing as not escaped
+
+ log(outFile, "\n");
+
+ l += 2; //skip space+escape character
+ if ( (cnt=sscanf(l,"%c%c",&cmd,&sep)) < 1)
+ {
+ esclog(outFile, "Command expected\n");
+ res = 0;
+ }
+
+ if (res && cnt==2 && sep != ' ')
+ {
+ esclog(outFile, "' ' expected\n");
+ res = 0;
+ }
+ l++; //skip cmd
+ while ( *l == ' ')l++; //skip more spaces
+ arg = l;
+ opt_cli = 1;
+ switch (cmd)
+ {
+ case 'h':
+ usage(1);
+ break;
+ case 'b':
+ if (handle_switch(outFile, &opt_buffered, arg, "-b Logfile
buffering"))
+ set_LogFile(logFile); //re-open same logfile
+ break;
+ case 'c':
+ handle_switch(outFile, &opt_console, NULL, "-c Console option");
+ break;
+ case 'd':
+ handle_switch_str(outFile, opt_dir, NULL, "-d Directory option");
+ break;
+ case 'l':
+ if (handle_switch_str(outFile, opt_logFile, arg, "-l logfile"))
+ set_LogFile(logFile); //open new logfile
+ break;
+ case 'm':
+ handle_switch(outFile, &opt_Mark, arg, "-m mark (*)");
+ break;
+ case 'M':
+ handle_switch(outFile, &opt_Mark, arg, "-M Mark (?)");
+ break;
+ case 'P':
+ handle_switch_str(outFile, opt_Pipe, NULL, "-P Pipeline option");
+ break;
+ case 'q':
+ opt_quit = 1;
+ esclog(outFile, "Bye!\n");
+ break;
+ case 'r':
+ handle_switch(outFile, &opt_raw, arg, "-r Raw");
+ break;
+ case 'R':
+ changed = handle_switch_pstr(outFile, &opt_Revision, arg, NULL);
+ if (opt_Revision)
+ {
+ if (strstr(opt_Revision, "check") == opt_Revision)
+ {
+ esclog(outFile, "-R is \"%s\" (%s)\n", opt_Revision,
changed ? "changed":"unchanged");
+ }
+ else if (strstr(opt_Revision, "regscan") == opt_Revision)
+ {
+ char *s = strchr(opt_Revision, ',');
+
+ revinfo.range = DEF_RANGE;
+ if (s)
+ {
+ *s++ = '\0';
+ revinfo.range = atoi(s);
+ }
+ regscan(outFile);
+ }
+ else if (strstr(opt_Revision, "regclear") == opt_Revision)
+ {
+ list_clear(&sources);
+ summ.regfound = 0;
+ esclog(outFile, "cleared regression scan results\n");
+ }
+ }
+ break;
+ case 's':
+ if (strcmp(arg,"clear") == 0)
+ {
+ memset(&summ, 0, sizeof(SUMM));
+ esclog(outFile, "Statistics cleared\n");
+ }
+ else
+ stat_print(outFile, &summ);
+ break;
+ case 'S':
+ cnt = sscanf(arg, "%d+%d", &opt_Source, &opt_SrcPlus);
+ if (opt_Source)
+ {
+ handle_switch(outFile, &opt_undo, "1", "-u Undo");
+ handle_switch(outFile, &opt_redo, "1", "-U Undo and
reprocess");
+ }
+ esclog(outFile, "-S Sources option is %d+%d,\"%s\"\n",
opt_Source, opt_SrcPlus, opt_SourcesPath);
+ esclog(outFile, "(Setting source tree not implemented)\n");
+ break;
+ case 't':
+ handle_switch(outFile, &opt_twice, arg, "-t Translate twice");
+ break;
+ case 'T':
+ handle_switch(outFile, &opt_twice, arg, NULL);
+ handle_switch(outFile, &opt_Twice, arg, "-T Translate for
(address-1)");
+ break;
+ case 'u':
+ handle_switch(outFile, &opt_undo, arg, "-u undo");
+ break;
+ case 'U':
+ handle_switch(outFile, &opt_undo, arg, NULL);
+ handle_switch(outFile, &opt_redo, arg, "-U Undo and reprocess");
+ break;
+ case 'v':
+ handle_switch(outFile, &opt_verbose, arg, "-v Verbosity");
+ break;
+ case 'z':
+ handle_switch_str(outFile, opt_7z, NULL, "-z 7z path");
+ break;
+ default:
+ if (strchr(optchars, cmd))
+ esclog(outFile, "Command not implemented in cli: %c %s\n",cmd,
arg)
+ else
+ esclog(outFile, "Unknown command: %c %s\n",cmd, arg);
+ }
+ opt_cli = 0;
+
+ memset(Line, '\0', LINESIZE); // flushed
+
+ return KDBG_ESC_CHAR; //handled escaped command
+}
Propchange: trunk/reactos/tools/log2lines/cmd.c
------------------------------------------------------------------------------
svn:eol-style = native
Added: trunk/reactos/tools/log2lines/cmd.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/tools/log2lines/cmd.h?rev=…
==============================================================================
--- trunk/reactos/tools/log2lines/cmd.h (added)
+++ trunk/reactos/tools/log2lines/cmd.h [iso-8859-1] Wed Feb 10 13:10:23 2010
@@ -1,0 +1,26 @@
+/*
+ * ReactOS log2lines
+ * Written by Jan Roeloffzen
+ *
+ * - Cli for escape commands
+ */
+
+#ifndef __L2L_CMD_H__
+#define __L2L_CMD_H__
+
+#include <stdio.h>
+
+#define KDBG_BS_CHAR 0x08
+#define KDBG_ESC_CHAR '`'
+#define KDBG_ESC_STR "`"
+#define KDBG_ESC_RESP "| L2L- "
+#define KDBG_ESC_OFF "off"
+#define KDBG_PROMPT "kdb:>" //Start interactive (-c)
after this pattern
+#define KDBG_CONT "---" //Also after this pattern
(prompt with no line ending)
+#define KDBG_DISCARD "Command '" KDBG_ESC_STR //Discard responses at
l2l escape commands
+
+char handle_escape_cmd(FILE *outFile, char *Line, char *path, char *LineOut);
+
+#endif /* __L2L_CMD_H__ */
+
+/* EOF */
Propchange: trunk/reactos/tools/log2lines/cmd.h
------------------------------------------------------------------------------
svn:eol-style = native
Modified: trunk/reactos/tools/log2lines/compat.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/tools/log2lines/compat.h?r…
==============================================================================
--- trunk/reactos/tools/log2lines/compat.h [iso-8859-1] (original)
+++ trunk/reactos/tools/log2lines/compat.h [iso-8859-1] Wed Feb 10 13:10:23 2010
@@ -37,3 +37,5 @@
#endif /* __L2L_COMPAT_H__ */
+
+/* EOF */
Modified: trunk/reactos/tools/log2lines/config.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/tools/log2lines/config.h?r…
==============================================================================
--- trunk/reactos/tools/log2lines/config.h [iso-8859-1] (original)
+++ trunk/reactos/tools/log2lines/config.h [iso-8859-1] Wed Feb 10 13:10:23 2010
@@ -15,7 +15,6 @@
#define CACHEFILE "log2lines.cache"
#define TRKBUILDPREFIX "bootcd-"
#define SVN_PREFIX "/trunk/reactos/"
-#define KDBG_PROMPT "kdbg>"
#define PIPEREAD_CMD "piperead -c"
@@ -32,3 +31,5 @@
#define NAMESIZE 80
#endif /* __L2L_CONFIG_H__ */
+
+/* EOF */
Modified: trunk/reactos/tools/log2lines/help.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/tools/log2lines/help.c?rev…
==============================================================================
--- trunk/reactos/tools/log2lines/help.c [iso-8859-1] (original)
+++ trunk/reactos/tools/log2lines/help.c [iso-8859-1] Wed Feb 10 13:10:23 2010
@@ -10,6 +10,7 @@
#include "compat.h"
#include "config.h"
#include "options.h"
+#include "cmd.h"
#include "help.h"
char *verboseUsage =
@@ -76,7 +77,7 @@
" - regscan[,<range>]:\n"
" Scan for regression candidates. Essentially it tries to find\n"
" matches between the SVN log entries and the sources hit by\n"
-" the backtrace.\n"
+" a backtrace (bt) command.\n"
" <range> is the amount of revisions to look back from the
build\n"
" revision (default 500)\n"
" The output of '-R regscan' is printed after EOF. The 'Changed
path'\n"
@@ -130,7 +131,25 @@
" <path to 7z>: Specify path to 7z. See also option -d.\n"
" Default: '7z'\n"
"\n"
-"Examples:\n"
+"CLI escape commands:\n"
+" It is possible to change options and perform actions from the 'kdb:>'
prompt\n"
+" By prepending the `(backquote) character to the option.\n"
+" Example: 'kdb:> `l new.log' changes the current logfile to
'new.log'.\n"
+" Flag options like 'b' are given a numeric value of 0 (off) or 1
(on).\n"
+" Options accepting a string as argument can be cleared by the value '"
KDBG_ESC_OFF "'.\n"
+" Some ClI commands are read only or not (entirely) implemented.\n"
+" If no value is provided, the current one is printed.\n"
+" There are only a few extra ClI commands or with different behaviour:\n"
+" - `h : shows this helptext (without exiting)\n"
+" - `q : quits log2lines\n"
+" - `R regscan : the output is printed immediately (do a 'bt'
first)\n"
+" - `R regclear : clears previous regscan matches\n"
+" - `s : the output is printed immediately\n"
+" - `s clear : clears all statistics.\n"
+" - `S : only <context> and <add> can be set.\n"
+" - `v <level> : sets the current debug loglevel\n"
+"\n"
+"Option Examples:\n"
" Setup: A VMware machine with its serial port set to:
'\\\\.\\pipe\\kdbg'.\n\n"
" Just recreate cache after a svn update or a new module has been added:\n"
" log2lines -F\n\n"
@@ -179,7 +198,42 @@
" <msi.dll:5262 (dll/win32/msi/action.c:2665
(ACTION_ProcessComponents))>\n"
" | R--- Conflict : source(44191) > build(43850)\n"
" | 2664 else\n"
-" | 2665 rc =
MSIREG_OpenUserDataKey(comp->ComponentId,\n"
+" | 2665 rc =
MSIREG_OpenUserDataKey(comp->ComponentId,\n\n"
+"CLI Examples: (some are based on the option examples above)\n"
+" Use '`R check' to show that action.c has been changed after the
build:\n"
+" kdb:> `R check\n"
+" | L2L- -R is \"check\" (changed)\n"
+" kdb:> bt\n"
+" <msi.dll:35821 (dll/win32/msi/registry.c:781
(MSIREG_OpenUserDataKey))>\n"
+" | 0780 if (create)\n"
+" | 0781 rc = RegCreateKeyW(HKEY_LOCAL_MACHINE, keypath,
key);\n"
+" <msi.dll:5262 (dll/win32/msi/action.c:2665
(ACTION_ProcessComponents))>\n"
+" | R--- Conflict : source(44191) > build(43850)\n"
+" | 2664 else\n"
+" | 2665 rc =
MSIREG_OpenUserDataKey(comp->ComponentId,\n\n"
+" kdb:>\n\n"
+" Generate source lines. Show 2 lines of context plus 1 additional line.\n"
+" The -Uu options are dependent on -S:\n"
+" kdb:> `S 2+1\n"
+" | L2L- -u Undo is 1 (changed)\n"
+" | L2L- -U Undo and reprocess is 1 (changed)\n"
+" | L2L- -S Sources option is 2+1,\"C:\\ROS\\reactos\\\" \n"
+" | L2L- (Setting source tree not implemented)\n"
+" kdb:> bt\n"
+" <msi.dll:2e35d (dll/win32/msi/msiquery.c:189
(MSI_IterateRecords))>\n"
+" | 0188 {\n"
+" | 0189 r = MSI_ViewFetch( view, &rec );\n"
+" | ----\n"
+" | 0190 if( r != ERROR_SUCCESS )\n"
+" kdb:>\n\n"
+" Change logfile:\n"
+" kdb:> `l\n"
+" | L2L- -l logfile is "" (unchanged)\n"
+" kdb:> `l new.log\n"
+" | L2L- -l logfile is \"new.log\" (changed)\n"
+" kdb:> `l off\n"
+" | L2L- -l logfile is "" (changed)\n"
+" kdb:>\n"
"\n";
void
Modified: trunk/reactos/tools/log2lines/help.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/tools/log2lines/help.h?rev…
==============================================================================
--- trunk/reactos/tools/log2lines/help.h [iso-8859-1] (original)
+++ trunk/reactos/tools/log2lines/help.h [iso-8859-1] Wed Feb 10 13:10:23 2010
@@ -13,3 +13,5 @@
void usage(int verbose);
#endif /* __L2L_HELP_H__ */
+
+/* EOF */
Modified: trunk/reactos/tools/log2lines/image.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/tools/log2lines/image.c?re…
==============================================================================
--- trunk/reactos/tools/log2lines/image.c [iso-8859-1] (original)
+++ trunk/reactos/tools/log2lines/image.c [iso-8859-1] Wed Feb 10 13:10:23 2010
@@ -4,6 +4,7 @@
*
* - Image functions for symbol info
*/
+#include <sys/stat.h>
#include <errno.h>
#include <string.h>
#include <rsym.h>
Modified: trunk/reactos/tools/log2lines/image.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/tools/log2lines/image.h?re…
==============================================================================
--- trunk/reactos/tools/log2lines/image.h [iso-8859-1] (original)
+++ trunk/reactos/tools/log2lines/image.h [iso-8859-1] Wed Feb 10 13:10:23 2010
@@ -20,3 +20,5 @@
#endif /* __L2L_IMAGE_H__ */
+
+/* EOF */
Modified: trunk/reactos/tools/log2lines/list.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/tools/log2lines/list.c?rev…
==============================================================================
--- trunk/reactos/tools/log2lines/list.c [iso-8859-1] (original)
+++ trunk/reactos/tools/log2lines/list.c [iso-8859-1] Wed Feb 10 13:10:23 2010
@@ -66,6 +66,19 @@
return pentry;
}
+void list_clear(PLIST list)
+{
+ PLIST_MEMBER pentry = list->phead;
+ PLIST_MEMBER pnext;
+ while (pentry)
+ {
+ pnext = pentry->pnext;
+ entry_delete(pentry);
+ pentry = pnext;
+ }
+ list->phead = list->ptail = NULL;
+}
+
#if 0
LIST_MEMBER *
entry_remove(LIST *list, LIST_MEMBER *pentry)
Modified: trunk/reactos/tools/log2lines/list.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/tools/log2lines/list.h?rev…
==============================================================================
--- trunk/reactos/tools/log2lines/list.h [iso-8859-1] (original)
+++ trunk/reactos/tools/log2lines/list.h [iso-8859-1] Wed Feb 10 13:10:23 2010
@@ -12,7 +12,6 @@
typedef struct list_struct
{
- off_t st_size;
PLIST_MEMBER phead;
PLIST_MEMBER ptail;
} LIST,*PLIST;
@@ -22,5 +21,8 @@
PLIST_MEMBER entry_insert(PLIST list, PLIST_MEMBER pentry);
PLIST_MEMBER cache_entry_create(char *Line);
PLIST_MEMBER sources_entry_create(PLIST list, char *path, char *prefix);
+void list_clear(PLIST list);
#endif /* __L2L_LIST_H__ */
+
+/* EOF */
Modified: trunk/reactos/tools/log2lines/log2lines.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/tools/log2lines/log2lines.…
==============================================================================
--- trunk/reactos/tools/log2lines/log2lines.c [iso-8859-1] (original)
+++ trunk/reactos/tools/log2lines/log2lines.c [iso-8859-1] Wed Feb 10 13:10:23 2010
@@ -2,7 +2,7 @@
* ReactOS log2lines
* Written by Jan Roeloffzen
*
- * - Initialization and main loop
+ * - Initialization, translation and main loop
*/
#include <errno.h>
@@ -13,17 +13,18 @@
#include "util.h"
#include "version.h"
#include "compat.h"
-#include "config.h"
-#include "list.h"
#include "options.h"
#include "image.h"
#include "cache.h"
#include "log2lines.h"
#include "help.h"
+#include "cmd.h"
static FILE *stdIn = NULL;
static FILE *stdOut = NULL;
+static const char *kdbg_prompt = KDBG_PROMPT;
+static const char *kdbg_cont = KDBG_CONT;
LIST sources;
LINEINFO lastLine;
@@ -65,6 +66,8 @@
i++;
}
fclose(src);
+ if ( i < min )
+ log(outFile, "| S--- source has only %d lines! (check
source/revision)\n", i);
}
else
l2l_dbg(1, "Can't open: %s (check " SOURCES_ENV ")\n",
s);
@@ -332,7 +335,7 @@
/* Strip all lines added by this tool: */
char buf[NAMESIZE];
if (sscanf(s, "| %s", buf) == 1)
- if (buf[0] == '0' || strcmp(buf, "----") == 0 ||
strcmp(buf, "R---") == 0 || atoi(buf))
+ if (buf[0] == '0' || strcmp(buf, "----") == 0 ||
strcmp(buf, "L2L-") == 0 || strcmp(buf, "S---") == 0 || strcmp(buf,
"R---") == 0 || atoi(buf))
res = 0;
}
@@ -410,6 +413,9 @@
int c;
unsigned char ch;
int i = 0;
+ const char *pc = kdbg_cont;
+ const char *p = kdbg_prompt;
+ const char *p_eos = p + sizeof(KDBG_PROMPT) - 1; //end of string pos
if (Line && path && LineOut)
{
@@ -418,23 +424,53 @@
{
while ((c = fgetc(inFile)) != EOF)
{
+ if (opt_quit)break;
+
ch = (unsigned char)c;
if (!opt_raw)
{
switch (ch)
{
case '\n':
- translate_line(outFile, Line, path, LineOut);
+ if ( strncmp(Line, KDBG_DISCARD, sizeof(KDBG_DISCARD)-1) == 0 )
+ {
+ memset(Line, '\0', LINESIZE); // flushed
+ }
+ else
+ {
+ Line[1] = handle_escape_cmd(outFile, Line, path, LineOut);
+ if (Line[1] != KDBG_ESC_CHAR)
+ {
+ if (p == p_eos)
+ {
+ //kdbg prompt, so already echoed char by char
+ memset(Line, '\0', LINESIZE);
+ translate_char(c, outFile);
+ }
+ else
+ {
+ translate_line(outFile, Line, path, LineOut);
+ translate_char(c, outFile);
+ report(outFile);
+ }
+ }
+ }
i = 0;
- translate_char(c, outFile);
- report(outFile);
+ p = kdbg_prompt;
+ pc = kdbg_cont;
break;
case '<':
i = 0;
Line[i++] = ch;
break;
case '>':
- if (i)
+ if (ch == *p)
+ {
+ p = p_eos;
+ translate_line(outFile, Line, path, LineOut);
+ }
+
+ if (p != p_eos)
{
if (i < LINESIZE)
{
@@ -452,21 +488,27 @@
i = 0;
break;
default:
- if (i)
+ if (ch == *p)p++;
+ if (ch == *pc)pc++;
+ if (i < LINESIZE)
{
- if (i < LINESIZE)
+ Line[i++] = ch;
+ if (p == p_eos)
{
- Line[i++] = ch;
+ translate_char(c, outFile);
}
- else
+ else if (!*pc)
{
translate_line(outFile, Line, path, LineOut);
- translate_char(c, outFile);
i = 0;
}
}
else
+ {
+ translate_line(outFile, Line, path, LineOut);
translate_char(c, outFile);
+ i = 0;
+ }
}
}
else
@@ -477,6 +519,8 @@
{ // Line by line, slightly faster but less interactive
while (fgets(Line, LINESIZE, inFile) != NULL)
{
+ if (opt_quit)break;
+
if (!opt_raw)
{
translate_line(outFile, Line, path, LineOut);
@@ -552,26 +596,8 @@
read_cache();
l2l_dbg(4, "Cache read complete\n");
- if (*opt_logFile)
- {
- logFile = fopen(opt_logFile, "a");
- if (logFile)
- {
- // disable buffering so fflush is not needed
- if (!opt_buffered)
- {
- l2l_dbg(1, "Disabling log buffering on %s\n", opt_logFile);
- setbuf(logFile, NULL);
- }
- else
- l2l_dbg(1, "Enabling log buffering on %s\n", opt_logFile);
- }
- else
- {
- l2l_dbg(0, "Could not open logfile %s (%s)\n", opt_logFile,
strerror(errno));
- return 2;
- }
- }
+ if (set_LogFile(logFile))
+ return 2;
l2l_dbg(4, "opt_logFile processed\n");
if (opt_Pipe)
@@ -584,8 +610,6 @@
l2l_dbg(0, "Could not popen '%s' (%s)\n", opt_Pipe,
strerror(errno));
free(opt_Pipe); opt_Pipe = NULL;
}
-
- free(opt_Pipe); opt_Pipe = NULL;
}
l2l_dbg(4, "opt_Pipe processed\n");
Modified: trunk/reactos/tools/log2lines/log2lines.mak
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/tools/log2lines/log2lines.…
==============================================================================
--- trunk/reactos/tools/log2lines/log2lines.mak [iso-8859-1] (original)
+++ trunk/reactos/tools/log2lines/log2lines.mak [iso-8859-1] Wed Feb 10 13:10:23 2010
@@ -30,6 +30,7 @@
$(LOG2LINES_BASE_)image.c \
$(LOG2LINES_BASE_)stat.c \
$(LOG2LINES_BASE_)revision.c \
+ $(LOG2LINES_BASE_)cmd.c \
$(LOG2LINES_BASE_)log2lines.c \
$(RSYM_BASE_)rsym_common.c
@@ -83,6 +84,10 @@
$(ECHO_HOSTCC)
${host_gcc} $(LOG2LINES_HOST_CFLAGS) -c $< -o $@
+$(LOG2LINES_INT_)cmd.o: $(LOG2LINES_BASE_)cmd.c | $(LOG2LINES_INT)
+ $(ECHO_HOSTCC)
+ ${host_gcc} $(LOG2LINES_HOST_CFLAGS) -c $< -o $@
+
.PHONY: log2lines_clean
log2lines_clean:
-@$(rm) $(LOG2LINES_TARGET) $(LOG2LINES_OBJECTS) 2>$(NUL)
Modified: trunk/reactos/tools/log2lines/options.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/tools/log2lines/options.c?…
==============================================================================
--- trunk/reactos/tools/log2lines/options.c [iso-8859-1] (original)
+++ trunk/reactos/tools/log2lines/options.c [iso-8859-1] Wed Feb 10 13:10:23 2010
@@ -13,6 +13,7 @@
#include "compat.h"
#include "config.h"
#include "help.h"
+#include "log2lines.h"
#include "options.h"
char *optchars = "bcd:fFhl:mMP:rR:sS:tTuUvz:";
@@ -25,6 +26,8 @@
int opt_mark = 0; // -m
int opt_Mark = 0; // -M
char *opt_Pipe = NULL; // -P
+int opt_quit = 0; // -q (cli only)
+int opt_cli = 0; // (cli internal)
int opt_raw = 0; // -r
int opt_stats = 0; // -s
int opt_Source = 0; // -S
<opt_Source>[+<opt_SrcPlus>][,<sources_path>]
@@ -46,29 +49,45 @@
char *s;
strcpy(opt_dir, "");
+ strcpy(opt_logFile, "");
+ strcpy(opt_7z, CMD_7Z);
strcpy(opt_SourcesPath, "");
if ((s = getenv(SOURCES_ENV)))
strcpy(opt_SourcesPath, s);
+ revinfo.rev = getRevision(NULL, 1);
+ revinfo.range = DEF_RANGE;
+ revinfo.buildrev = getTBRevision(opt_dir);
+ l2l_dbg(1, "Trunk build revision: %d\n", revinfo.buildrev);
strcpy(opt_scanned, "");
for (i = 1; i < argc; i++)
{
- if (strcmp(argv[i],"-P")==0)
+ if ((argv[i][0] == '-') && (i+1 < argc))
{
- //Because its argument can contain spaces we cant use getopt(), a known bug:
- if (i+1 < argc)
+ //Because these arguments can contain spaces we cant use getopt(), a known
bug:
+ switch (argv[i][1])
{
+ case 'd':
+ strcpy(opt_dir, argv[i+1]);
+ break;
+ case 'l':
+ strcpy(opt_logFile, argv[i+1]);
+ break;
+ case 'P':
free(opt_Pipe);
opt_Pipe = malloc(LINESIZE);
strcpy(opt_Pipe, argv[i+1]);
+ break;
+ case 'z':
+ strcpy(opt_7z, argv[i+1]);
+ break;
}
}
strcat(opt_scanned, argv[i]);
strcat(opt_scanned, " ");
}
+
l2l_dbg(4,"opt_scanned=[%s]\n",opt_scanned);
- strcpy(opt_logFile, "");
- strcpy(opt_7z, CMD_7Z);
return 0;
}
@@ -91,7 +110,7 @@
break;
case 'd':
optCount++;
- strcpy(opt_dir, optarg);
+ //just count, see optionInit()
break;
case 'f':
opt_force++;
@@ -107,7 +126,7 @@
break;
case 'l':
optCount++;
- strcpy(opt_logFile, optarg);
+ //just count, see optionInit()
break;
case 'm':
opt_mark++;
@@ -120,7 +139,7 @@
break;
case 'P':
optCount++;
- //just count, see above
+ //just count, see optionInit()
break;
case 'R':
optCount++;
@@ -137,6 +156,12 @@
if (i == 1)
sscanf(optarg, "%*d,%s", opt_SourcesPath);
l2l_dbg(3, "Sources option parse result: %d+%d,\"%s\"\n",
opt_Source, opt_SrcPlus, opt_SourcesPath);
+ if (opt_Source)
+ {
+ /* need to retranslate for source info: */
+ opt_undo++;
+ opt_redo++;
+ }
break;
case 't':
opt_twice++;
@@ -166,15 +191,14 @@
}
optCount++;
}
+ if(opt_console)
+ {
+ l2l_dbg(2, "Note: use 's' command in console mode. Statistics option
disabled\n");
+ opt_stats = 0;
+ }
if (opt_SourcesPath[0])
{
strcat(opt_SourcesPath, PATH_STR);
- }
- if (opt_Source)
- {
- /* need to retranslate for source info: */
- opt_undo++;
- opt_redo++;
}
if (!opt_dir[0])
{
Modified: trunk/reactos/tools/log2lines/options.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/tools/log2lines/options.h?…
==============================================================================
--- trunk/reactos/tools/log2lines/options.h [iso-8859-1] (original)
+++ trunk/reactos/tools/log2lines/options.h [iso-8859-1] Wed Feb 10 13:10:23 2010
@@ -18,6 +18,8 @@
extern int opt_mark; // -m
extern int opt_Mark; // -M
extern char *opt_Pipe; // -P
+extern int opt_quit; // -q (cli only)
+extern int opt_cli; // (cli internal)
extern int opt_raw; // -r
extern int opt_stats; // -s
extern int opt_Source; // -S
<opt_Source>[+<opt_SrcPlus>][,<sources_path>]
@@ -38,3 +40,5 @@
int optionParse(int argc, const char **argv);
#endif /* __L2L_OPTIONS_H__ */
+
+/* EOF */
Modified: trunk/reactos/tools/log2lines/revision.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/tools/log2lines/revision.c…
==============================================================================
--- trunk/reactos/tools/log2lines/revision.c [iso-8859-1] (original)
+++ trunk/reactos/tools/log2lines/revision.c [iso-8859-1] Wed Feb 10 13:10:23 2010
@@ -13,7 +13,6 @@
#include "compat.h"
#include "util.h"
#include "options.h"
-#include "revision.h"
#include "log2lines.h"
static void
@@ -195,7 +194,7 @@
char path[MAX_PATH];
char path2[MAX_PATH];
int wflag = 0;
- log(outFile, "\nRegression candidates:\n");
+ clilog(outFile, "Regression candidates:\n");
while (( pos = findRev(finx, &r) ))
{
if (r < (revinfo.buildrev - revinfo.range))
@@ -216,11 +215,11 @@
{
if (wflag == 1)
{
- log(outFile, "%sChanged paths:\n", line);
+ clilog(outFile, "%sChanged paths:\n", line);
summ.regfound++;
wflag = 2;
}
- log(outFile, "%s", line2);
+ clilog(outFile, "%s", line2);
}
}
else
@@ -229,11 +228,11 @@
if (wflag == 2)
{
int i = 0;
- log(outFile, "\n");
+ clilog(outFile, "\n");
while (fgets(line2, LINESIZE, flog))
{
i++;
- log(outFile, "%s", line2);
+ clilog(outFile, "%s", line2);
if (strncmp(LOGBOTTOM, line2, sizeof(LOGBOTTOM) - 1) == 0)
break;
}
Modified: trunk/reactos/tools/log2lines/revision.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/tools/log2lines/revision.h…
==============================================================================
--- trunk/reactos/tools/log2lines/revision.h [iso-8859-1] (original)
+++ trunk/reactos/tools/log2lines/revision.h [iso-8859-1] Wed Feb 10 13:10:23 2010
@@ -26,3 +26,5 @@
int updateSvnlog(void);
#endif /* __L2L_REVISION_H__ */
+
+/* EOF */
Modified: trunk/reactos/tools/log2lines/stat.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/tools/log2lines/stat.c?rev…
==============================================================================
--- trunk/reactos/tools/log2lines/stat.c [iso-8859-1] (original)
+++ trunk/reactos/tools/log2lines/stat.c [iso-8859-1] Wed Feb 10 13:10:23 2010
@@ -10,7 +10,7 @@
#include "version.h"
#include "options.h"
-#include "stat.h"
+#include "util.h"
#include "log2lines.h"
void
@@ -18,22 +18,22 @@
{
if (outFile)
{
- fprintf(outFile, "\n*** LOG2LINES SUMMARY ***\n");
- fprintf(outFile, "Translated: %d\n",
psumm->translated);
- fprintf(outFile, "Reverted: %d\n", psumm->undo);
- fprintf(outFile, "Retranslated: %d\n", psumm->redo);
- fprintf(outFile, "Skipped: %d\n", psumm->skipped);
- fprintf(outFile, "Differ: %d\n", psumm->diff);
- fprintf(outFile, "Differ (function/source): %d\n",
psumm->majordiff);
- fprintf(outFile, "Revision conflicts: %d\n",
psumm->revconflicts);
- fprintf(outFile, "Regression candidates: %d\n",
psumm->regfound);
- fprintf(outFile, "Offset error: %d\n",
psumm->offset_errors);
- fprintf(outFile, "Total: %d\n", psumm->total);
- fprintf(outFile, "-------------------------------\n");
- fprintf(outFile, "Log2lines version: " LOG2LINES_VERSION
"\n");
- fprintf(outFile, "Directory: %s\n", opt_dir);
- fprintf(outFile, "Passed options: %s\n", opt_scanned);
- fprintf(outFile, "-------------------------------\n");
+ clilog(outFile, "*** LOG2LINES SUMMARY ***\n");
+ clilog(outFile, "Translated: %d\n",
psumm->translated);
+ clilog(outFile, "Reverted: %d\n", psumm->undo);
+ clilog(outFile, "Retranslated: %d\n", psumm->redo);
+ clilog(outFile, "Skipped: %d\n", psumm->skipped);
+ clilog(outFile, "Differ: %d\n", psumm->diff);
+ clilog(outFile, "Differ (function/source): %d\n",
psumm->majordiff);
+ clilog(outFile, "Revision conflicts: %d\n",
psumm->revconflicts);
+ clilog(outFile, "Regression candidates: %d\n", psumm->regfound);
+ clilog(outFile, "Offset error: %d\n",
psumm->offset_errors);
+ clilog(outFile, "Total: %d\n", psumm->total);
+ clilog(outFile, "-------------------------------\n");
+ clilog(outFile, "Log2lines version: " LOG2LINES_VERSION
"\n");
+ clilog(outFile, "Directory: %s\n", opt_dir);
+ clilog(outFile, "Passed options: %s\n", opt_scanned);
+ clilog(outFile, "-------------------------------\n");
}
}
Modified: trunk/reactos/tools/log2lines/stat.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/tools/log2lines/stat.h?rev…
==============================================================================
--- trunk/reactos/tools/log2lines/stat.h [iso-8859-1] (original)
+++ trunk/reactos/tools/log2lines/stat.h [iso-8859-1] Wed Feb 10 13:10:23 2010
@@ -28,3 +28,5 @@
void stat_clear(PSUMM psumm);
#endif /* __L2L_STAT_H__ */
+
+/* EOF */
Modified: trunk/reactos/tools/log2lines/util.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/tools/log2lines/util.c?rev…
==============================================================================
--- trunk/reactos/tools/log2lines/util.c [iso-8859-1] (original)
+++ trunk/reactos/tools/log2lines/util.c [iso-8859-1] Wed Feb 10 13:10:23 2010
@@ -14,6 +14,39 @@
#include "compat.h"
#include "util.h"
#include "options.h"
+
+int
+set_LogFile(FILE *logFile)
+{
+ if (*opt_logFile)
+ {
+ if (logFile)
+ fclose(logFile);
+ logFile = NULL;
+
+ if (strcmp(opt_logFile,"none") == 0)
+ return 0; //just close
+
+ logFile = fopen(opt_logFile, "a");
+ if (logFile)
+ {
+ // disable buffering so fflush is not needed
+ if (!opt_buffered)
+ {
+ l2l_dbg(1, "Disabling log buffering on %s\n", opt_logFile);
+ setbuf(logFile, NULL);
+ }
+ else
+ l2l_dbg(1, "Enabling log buffering on %s\n", opt_logFile);
+ }
+ else
+ {
+ l2l_dbg(0, "Could not open logfile %s (%s)\n", opt_logFile,
strerror(errno));
+ return 2;
+ }
+ }
+ return 0;
+}
int
file_exists(char *name)
Modified: trunk/reactos/tools/log2lines/util.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/tools/log2lines/util.h?rev…
==============================================================================
--- trunk/reactos/tools/log2lines/util.h [iso-8859-1] (original)
+++ trunk/reactos/tools/log2lines/util.h [iso-8859-1] Wed Feb 10 13:10:23 2010
@@ -8,12 +8,28 @@
#ifndef __L2L_UTIL_H__
#define __L2L_UTIL_H__
+#include <stdio.h>
+
+#include "cmd.h"
#define log(outFile, fmt, ...) \
{ \
fprintf(outFile, fmt, ##__VA_ARGS__); \
if (logFile) \
fprintf(logFile, fmt, ##__VA_ARGS__); \
+ }
+
+#define esclog(outFile, fmt, ...) \
+ { \
+ log(outFile, KDBG_ESC_RESP fmt, ##__VA_ARGS__); \
+ }
+
+#define clilog(outFile, fmt, ...) \
+ { \
+ if (opt_cli) \
+ esclog(outFile, fmt, ##__VA_ARGS__) \
+ else \
+ log(outFile, fmt, ##__VA_ARGS__); \
}
#define l2l_dbg(level, ...) \
@@ -29,5 +45,8 @@
long my_atoi(const char *a);
int isOffset(const char *a);
int copy_file(char *src, char *dst);
+int set_LogFile(FILE *logFile);
#endif /* __L2L_UTIL_H__ */
+
+/* EOF */
Modified: trunk/reactos/tools/log2lines/version.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/tools/log2lines/version.h?…
==============================================================================
--- trunk/reactos/tools/log2lines/version.h [iso-8859-1] (original)
+++ trunk/reactos/tools/log2lines/version.h [iso-8859-1] Wed Feb 10 13:10:23 2010
@@ -8,6 +8,8 @@
#ifndef __L2L_VERSION_H__
#define __L2L_VERSION_H__
-#define LOG2LINES_VERSION "1.12b"
+#define LOG2LINES_VERSION "2.1"
#endif /* __L2L_VERSION_H__ */
+
+/* EOF */