All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] sepolgen: optionally generate debugging information during parsing
@ 2007-02-22 22:23 Karl MacMillan
  2007-02-27 15:15 ` Stephen Smalley
  0 siblings, 1 reply; 2+ messages in thread
From: Karl MacMillan @ 2007-02-22 22:23 UTC (permalink / raw)
  To: SELinux Mail List

[-- Attachment #1: Type: text/plain, Size: 220 bytes --]

This patch allows a caller to request the output of debugging 
information from the parser. This is mainly useful for development / 
debugging of the parser.

Signed-off-by: Karl MacMillan <kmacmillan@mentalrootkit.com>

[-- Attachment #2: sepolgen-parser-debug.diff --]
[-- Type: text/x-patch, Size: 2335 bytes --]

diff -r af054201710a sepolgen/src/sepolgen/refparser.py
--- a/sepolgen/src/sepolgen/refparser.py	Thu Feb 22 15:42:47 2007 -0500
+++ b/sepolgen/src/sepolgen/refparser.py	Thu Feb 22 17:07:44 2007 -0500
@@ -611,11 +611,11 @@ def prep_spt(spt):
 
 parser = None
 lexer = None
-def create_globals(module, support):
+def create_globals(module, support, debug):
     global parser, lexer, m, spt
     if not parser:
         lexer = lex.lex()
-        parser = yacc.yacc(method="LALR", debug=0, write_tables=0)
+        parser = yacc.yacc(method="LALR", debug=debug, write_tables=0)
 
     if module is not None:
         m = module
@@ -627,13 +627,13 @@ def create_globals(module, support):
     else:
         spt = support
 
-def parse(text, module=None, support=None):
-    create_globals(module, support)
+def parse(text, module=None, support=None, debug=False):
+    create_globals(module, support, debug)
     lexer.lexdata = []
     lexer.lexpos = 0
 
     try:
-        parser.parse(text, debug=0)
+        parser.parse(text, debug=debug)
     except Exception, e:
         global error
         error = "internal parser error: %s" % str(e)
@@ -670,7 +670,7 @@ def list_headers(root):
     return (modules, support_macros)
 
 
-def parse_headers(root, output=None, expand=True):
+def parse_headers(root, output=None, expand=True, debug=False):
     import util
 
     headers = refpolicy.Headers()
@@ -696,11 +696,13 @@ def parse_headers(root, output=None, exp
             output.write(msg)
 
     def parse_file(f, module, spt=None):
+        if debug:
+            o("parsing file %s\n" % f)
         try:
             fd = open(f)
             txt = fd.read()
             fd.close()
-            parse(txt, module, spt)
+            parse(txt, module, spt, debug)
         except IOError, e:
             return
         except ValueError, e:
@@ -726,7 +728,7 @@ def parse_headers(root, output=None, exp
 
         o("done.\n")
 
-    if output:
+    if output and not debug:
         status = util.ConsoleProgressBar(sys.stdout, steps=len(modules))
         status.start("Parsing interface files")
 
@@ -744,7 +746,7 @@ def parse_headers(root, output=None, exp
             continue
 
         headers.children.append(m)
-        if output:
+        if output and not debug:
             status.step()
 
     if len(failures):

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] sepolgen: optionally generate debugging information during parsing
  2007-02-22 22:23 [PATCH] sepolgen: optionally generate debugging information during parsing Karl MacMillan
@ 2007-02-27 15:15 ` Stephen Smalley
  0 siblings, 0 replies; 2+ messages in thread
From: Stephen Smalley @ 2007-02-27 15:15 UTC (permalink / raw)
  To: Karl MacMillan; +Cc: SELinux Mail List

On Thu, 2007-02-22 at 17:23 -0500, Karl MacMillan wrote:
> This patch allows a caller to request the output of debugging 
> information from the parser. This is mainly useful for development / 
> debugging of the parser.
> 
> Signed-off-by: Karl MacMillan <kmacmillan@mentalrootkit.com>

Thanks, merged.

-- 
Stephen Smalley
National Security Agency


--
This message was distributed to subscribers of the selinux mailing list.
If you no longer wish to subscribe, send mail to majordomo@tycho.nsa.gov with
the words "unsubscribe selinux" without quotes as the message.

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2007-02-27 15:15 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-02-22 22:23 [PATCH] sepolgen: optionally generate debugging information during parsing Karl MacMillan
2007-02-27 15:15 ` Stephen Smalley

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.