Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
base fork: eevee/gcc-python-plugin
base: ea3d94de25
...
head fork: eevee/gcc-python-plugin
compare: 7fe78d8f86
  • 2 commits
  • 4 files changed
  • 0 commit comments
  • 1 contributor
View
6 Makefile
@@ -123,7 +123,7 @@ autogenerated-tree-types.txt: tree-types.txt.in
cpp $(CFLAGS) $^ -o $@
autogenerated-callgraph.c: $(GENERATOR_DEPS) generate-callgraph-c.py
- python generate-callgraph-c.py > $@
+ $(PYTHON) generate-callgraph-c.py > $@
autogenerated-cfg.c: $(GENERATOR_DEPS) generate-cfg-c.py
$(PYTHON) generate-cfg-c.py > $@
@@ -153,7 +153,7 @@ autogenerated-tree.c: $(GENERATOR_DEPS) generate-tree-c.py autogenerated-tree-ty
$(PYTHON) generate-tree-c.py > $@
autogenerated-rtl.c: $(GENERATOR_DEPS) generate-rtl-c.py autogenerated-rtl-types.txt maketreetypes.py
- python generate-rtl-c.py > $@
+ $(PYTHON) generate-rtl-c.py > $@
autogenerated-variable.c: $(GENERATOR_DEPS) generate-variable-c.py autogenerated-gimple-types.txt maketreetypes.py
$(PYTHON) generate-variable-c.py > $@
@@ -186,7 +186,7 @@ debug: plugin
# A simple demo, to make it easy to demonstrate the cpychecker:
demo: plugin
- ./gcc-with-cpychecker $(shell python-config --cflags) demo.c
+ ./gcc-with-cpychecker $(shell $(PYTHON_CONFIG) --cflags) demo.c
json-examples: plugin
./gcc-with-cpychecker -I/usr/include/python2.7 libcpychecker/html/test/example1/bug.c
View
214 libcpychecker/html/make_html.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python2
"""Make our data into HTML!"""
import capi
@@ -11,6 +11,7 @@
from pygments.lexers.compiled import CLexer
from pygments.formatters.html import HtmlFormatter
+import itertools
from json import load
class HtmlPage(object):
@@ -41,10 +42,15 @@ def head(self):
)
head.extend(
E.SCRIPT(src=js + '.js')
- for js in ('extlib/prefixfree-1.0.4.min', 'extlib/jquery-1.7.1.min')
+ for js in ('extlib/prefixfree-1.0.4.min', 'extlib/jquery-1.7.1.min', 'script')
)
return head
+ def raw_code(self):
+ first, last = self.data['function']['lines']
+ # Line numbers are ONE-based
+ return ''.join(itertools.islice(self.codefile, first - 1, last))
+
def code(self):
"""generate the contents of the #code section"""
# Get ready to use Pygments:
@@ -58,7 +64,7 @@ def code(self):
open('pygments_c.css', 'w').write(formatter.get_style_defs())
# Use pygments to convert it all to HTML:
- code = parse(highlight(self.codefile.read(), CLexer(), formatter))
+ code = parse(highlight(self.raw_code(), CLexer(), formatter))
# linkify the python C-API functions
for name in code.xpath('//span[@class="n"]'):
@@ -71,73 +77,54 @@ def code(self):
return code
-
def header(self):
"""Make the header bar of the webpage"""
- return E.DIV(
- E.ATTR(id='header-wrap'),
+ return E.E.header(
+ E.ATTR(id='header'),
E.DIV(
- E.ATTR(id='header-container'),
- E.DIV(
- E.ATTR(id='header'),
- E.H1(
- 'GCC Python Plugin',
- ),
- E.DIV(
- E.ATTR(id='header-filename'),
- E.SPAN(
- E.CLASS('label'),
- 'Filename: ',
- ),
- self.data['filename'],
- ),
+ E.ATTR(id='title'),
+ E.H1(
+ 'GCC Python Plugin',
),
- ),
- E.DIV(
- E.ATTR(id='nav-container'),
E.DIV(
- E.ATTR(id='nav'),
+ E.ATTR(id='filename'),
E.SPAN(
E.CLASS('label'),
- 'Function Name: ',
+ 'Filename: ',
),
- E.SPAN(
- E.CLASS('fnc-report'),
- E.ATTR(id='fnc-name'),
- '[Function name goes here]',
- ),
- u'\xa0|\xa0',
- E.SPAN(
- E.CLASS('label'),
- 'Report: ',
- ),
- E.SPAN(
- E.CLASS('fnc-report'),
- E.ATTR(id='report-pagination'),
- '[Report Pagination]',
- ),
- E.DIV(
- E.ATTR(id='white-box'),
- E.IMG(
- src='images/arrow.png',
- ),
+ self.data['filename'],
+ ),
+ ),
+ E.E.nav(
+ E.ATTR(id='nav'),
+ E.DIV(
+ E.ATTR(id='function'),
+ E.H3('Function'),
+ self.data['function']['name'],
+ ),
+ E.DIV(
+ E.ATTR(id='report-pagination'),
+ E.H3('Report'),
+ '[Report Pagination]',
+ ),
+ E.DIV(
+ E.ATTR(id='bug-toggle'),
+ E.IMG(
+ src='images/bug.png',
),
- E.DIV(
- E.ATTR(id='white-box'),
- E.IMG(
- src='images/arrow-180.png',
- ),
+ E.H3('Bug'),
+ ' [count]',
+ ),
+ E.DIV(
+ E.ATTR(id='prev'),
+ E.IMG(
+ src='images/arrow.png',
),
- E.DIV(
- E.ATTR(id='bug-toggle'),
- E.IMG(
- src='images/bug.png',
- ),
- E.SPAN(
- E.CLASS('label'),
- 'Bug: ',
- ),
- ' [count]',
+ ),
+ E.DIV(
+ E.ATTR(id='next'),
+ E.IMG(
+ src='images/arrow-180.png',
),
),
),
@@ -146,32 +133,57 @@ def header(self):
@staticmethod
def footer():
"""make the footer"""
- return E.DIV(
- E.ATTR(id='footer-wrap'),
- E.DIV(
- E.ATTR(id='footer-container'),
- E.DIV(
- E.ATTR(id='footer'),
- E.DIV(
- E.ATTR(id='footer-text'),
- u'Hackathon 7.0 \xa0|\xa0 '
- u'Buck G, Alex M, Jason M \xa0|\xa0 '
- u'Yelp HQ 2012',
- ),
- ),
- ),
+ return E.E.footer(
+ E.ATTR(id='footer'),
+ E.P(
+ u'Hackathon 7.0 | '
+ u'Buck G, Alex M, Jason M | '
+ u'Yelp HQ 2012',
+ ),
+ )
+
+ def states(self):
+ report = self.data['reports'][0]
+
+ lis = []
+ last_line = None
+ for state in report['states']:
+ if not state['location'] or not state['message']:
+ continue
+
+ line = state['location'][0]['line']
+ p = E.P(state['message'])
+ p.append(
+ E.IMG(
+ src='images/bug--arrow.png', align='center',
+ ),
+ )
+
+ if lis and line == last_line:
+ # Merge adjacent messages for the same line together
+ lis[-1].append(p)
+ else:
+ lis.append(E.LI(
+ {'data-line': str(line)},
+ p,
+ ))
+
+ last_line = line
+
+ return E.OL(
+ {'class': 'states'},
+ *lis
)
def body(self):
"""The BODY of the html document"""
return E.BODY(
self.header(),
- E.DIV(
- E.ATTR(id='ie6-container-wrap'),
- E.DIV(
- E.ATTR(id='container'),
+ E.OL(
+ E.ATTR(id='reports'),
+ E.LI(
E.DIV(
- E.ATTR(id='content'),
+ E.CLASS('source'),
E.DIV(
E.ATTR(id='error-box'),
E.SPAN(
@@ -194,43 +206,7 @@ def body(self):
E.HR(),
),
),
- E.DIV(
- E.ATTR(id='sidebar'),
- E.DIV(
- E.CLASS('annotation-box'),
- E.IMG(
- src='images/bug--arrow.png', align='center',
- ),
- ' : ',
- E.SPAN(
- E.CLASS('bug-count'),
- '[bug count]',
- ),
- E.DIV(
- E.CLASS('annotation-comment'),
- 'when PyArg_ParseTuple() succeeds ',
- E.BR(),
- ' taking False path',
- ),
- ),
- E.DIV(
- E.CLASS('annotation-box selected'),
- E.IMG(
- src='images/bug--arrow.png', align='center',
- ),
- ' : ',
- E.SPAN(
- E.CLASS('bug-count'),
- '[bug count]',
- ),
- E.DIV(
- E.CLASS('annotation-comment'),
- 'when PyArg_ParseTuple() succeeds ',
- E.BR(),
- ' taking False path',
- ),
- ),
- ),
+ self.states(),
),
),
self.footer(),
@@ -240,13 +216,13 @@ class CodeHtmlFormatter(HtmlFormatter):
"""Format our HTML!"""
def wrap(self, source, outfile):
- yield 0, '<table class="%s" data-first-line="%s">' % (
- self.cssclass, self.linenostart,
+ yield 0, '<table data-first-line="%s">' % (
+ self.linenostart,
)
for i, line in source:
if i == 1:
# it's a line of formatted code
- yield 0, '<tr><td>'
+ yield 0, '<tr><td class="code">'
yield i, line
yield 0, '</td></tr>'
else:
View
111 libcpychecker/html/script.js
@@ -0,0 +1,111 @@
+$(function() {
+ "use strict";
+
+ var $reports = $('#reports > li');
+ $reports.each(function() {
+ var $report = $(this);
+
+ // Add line numbers to the source code, and create a mapping of line
+ // numbers to table rows
+ var $source = $report.find('.source table');
+ var first_line = parseInt($source.data('first-line'), 10);
+ var $lines = $source.find('tr');
+ var $line_index = {};
+ $lines.each(function(idx) {
+ var $line = $(this);
+ var lineno = first_line + idx;
+ $line.prepend($('<td>', { 'class': 'lineno' }).append(lineno));
+
+ $line_index[lineno] = $line;
+ });
+
+ // Figure out the state flow based on the state list: this is a list of
+ // lists of line numbers that strictly increase. If the flow moves
+ // backwards, that starts a new subflow
+ var $states = $report.find('.states li');
+ var source_flow = [];
+ var last_line = null;
+ $states.each(function() {
+ var $state = $(this);
+ var lineno = parseInt($state.data('line'), 10);
+ var $assoc_line = $line_index[lineno];
+ $state.data('line-element', $assoc_line);
+ $state.prepend($('<h2>').text(String(lineno)));
+
+ var flow;
+ if (! last_line || last_line >= lineno) {
+ // Mark commentary that starts a new subflow (but not the
+ // first)
+ if (source_flow.length) {
+ $state.addClass('new-subflow');
+ }
+
+ flow = [];
+ source_flow.push(flow);
+ }
+ else {
+ flow = source_flow[source_flow.length - 1];
+ }
+ flow.push({ 'lineno': lineno, '$state': $state });
+
+ last_line = lineno;
+ });
+
+ // Add the flows to the source code table. Each subflow becomes its
+ // own column. A line actually executed within this subflow gets a
+ // td.flow-line; otherwise it gets td.flow-empty. If there's
+ // commentary for a particular line, the cell gets a .flow-dot child as
+ // well.
+ var started = [];
+ $.each($line_index, function(lineno, $row) {
+ var $paths = $();
+ var $selectables = $();
+ $.each(source_flow, function(idx, flow) {
+ // Lines mentioned in the flow get dots...
+ if (flow.length && flow[0].lineno == lineno) {
+ var $new_cell = $('<td>', { "class": "flow-line" });
+ $new_cell.append($('<span>', { "class": "flow-dot" }));
+ $paths = $paths.add($new_cell);
+ $selectables = $selectables.add($new_cell).add(flow[0].$state);
+ started[idx] = true;
+
+ // When hovering either the dotted cell or the associated
+ // state commentary, highlight the dot and the comment and
+ // the row itself
+ var $group = $row.add(flow[0].$state).add($new_cell);
+ $new_cell.add(flow[0].$state).hover(
+ function() { $group.addClass('selected'); },
+ function() { $group.removeClass('selected'); }
+ );
+
+ flow.shift();
+ }
+ // Lines between the start and end of a subflow, or before the
+ // start of the first subflow, or after the end of the last
+ // subflow, get undotted lines
+ else if (
+ (idx == 0 && flow.length) ||
+ (idx == source_flow.length - 1 && ! flow.length) ||
+ (started[idx] && flow.length)
+ ) {
+ $paths = $paths.add($('<td>', { "class": "flow-line" }));
+ }
+ // Anywhere else gets nothing
+ else {
+ $paths = $paths.add($('<td>', { "class": "flow-empty" }));
+ }
+ });
+ $row.prepend($paths);
+
+ // When hovering the row, highlight *all* commentary associated
+ // with that line
+ if ($selectables.length) {
+ $selectables = $selectables.add($row);
+ $row.find('td:last-child').hover(
+ function() { $selectables.addClass('selected') },
+ function() { $selectables.removeClass('selected') }
+ );
+ }
+ });
+ });
+});
View
441 libcpychecker/html/style.css
@@ -1,165 +1,222 @@
-* {
- margin: 0;
- padding: 0;
+html, body {
+ width: 100%;
+ background: black;
}
-
-body {
- font: 62.5% Arial, Helvetica, sans-serif;
- color: #000;
- margin: 0;
- padding: 0;
- background: #EBEBEB;
+html {
+ height: 100%;
}
+body {
+ font: 12px "DejaVu Sans", "Bitstream Vera Sans", "Ubuntu Sans", Helvetica, Arial, sans-serif;
+ color: black;
+ background: #EBEBEB;
+ height: 100%;
+ display: box;
+ box-orient: vertical;
+}
h1, h2 {
- color: #000;
- font-family: Tahoma, Arial, Geneva, sans-serif;
- font-size:12px;
- font-weight:bolder;
+ font-weight: bolder;
}
-
hr {
- border-bottom: 1px solid #CCC; width: 640px;
+ border-bottom: 1px solid #CCC; width: 640px;
}
-
-p {
- margin: 10px 0;
- padding: 0;
+img {
+ vertical-align: middle;
}
-blockquote {
- font-style: italic;
-}
-#header-wrap {
- position: fixed;
- top: 0;
- left: 0;
- width: 100%;
+/* Main page layout */
+#header {
+ background-color: #0099ff;
}
-
-#header-container {
- height: 38px;
- background-color:#0099FF;
- border-bottom:1px solid #7A7A7A;
+#nav {
+ padding: 1em;
+ background: hsl(0, 0%, 83%);
+ color: black;
}
-
-#header {
- width: 1000px;
- margin: 0 auto;
- position: relative;
+#reports {
+ box-flex: 1;
+ overflow-y: auto;
+}
+#footer {
+ background: hsl(0, 0%, 30%);
+ box-shadow: inset 0 3px 3px -3px black;
+ color: white;
+ padding: 1em;
+ text-shadow: 0px 1px 0px black;
+ min-height: 30px;
+ background-color: #09f;
}
-#header h1 {
- color: #fff;
- text-align: left;
- margin: 0;
- float:left;
- left: 0;
- margin-top: 10px;
- font-size:14px;
- text-shadow: 0px 1px 1px #000;
+
+/* Header */
+#title {
+ display: box;
+ box-orient: horizontal;
+ width: 100%;
+ color: white;
+}
+#title h1,
+#title #filename {
+ box-flex: 1;
+ padding: 1em;
+ vertical-align: middle;
+}
+#title h1 {
+ font-size: 1.2em;
+ text-shadow: 0 1px 1px black;
+}
+#title #filename {
+ box-flex: 1;
+ text-align: right;
+ text-shadow: 0 1px 0 black;
}
-#header h1 em{
- color: #90b874;
- font-size: small;
- display: block;
+/* Navigation */
+#nav {
+ display: box;
+ box-orient: horizontal;
+ box-align: center;
+ width: 100%;
+ box-sizing: border-box;
+ background-color: #E4E4E4;
+ border-bottom: 1px solid #7A7A7A;
+ box-shadow: 0px 0px 2px #000;
+}
+#nav h3 {
+ display: inline-block;
+ font-weight: bold;
+ margin-right: 0.33em;
+}
+#nav h3:after {
+ content: ':';
+}
+#nav #function {
+ margin-right: 2em;
+}
+#nav #report-pagination {
+}
+#nav #bug-toggle {
+ box-flex: 1;
+ text-align: right;
}
+#nav #prev,
+#nav #next {
+ width: 2em;
+ height: 18px;
+ text-align: center;
+ background-color:#fff;
+ border: 1px solid #CCCCCC;
+ margin: 0 1em;
+}
+
-#header-filename {
- color:#fff;
- font-size:12px;
- float:right;
- margin-top:13px;
- text-shadow: 0px 1px 0px #000;
+
+#header-container {
+ border-bottom:1px solid #7A7A7A;
}
#header ul {
- margin: 0;
- padding: 0;
- list-style: none;
- position: absolute;
- top: 35px;
- right: 0;
+ margin: 0;
+ padding: 0;
+ list-style: none;
+ position: absolute;
+ top: 35px;
+ right: 0;
}
#header ul li {
- float: left;
- margin-right: 5px;
+ float: left;
+ margin-right: 5px;
}
#header ul li a{
- color: #90b874;
- font-weight: bold;
- font-size: 1.4em;
- margin-right: 5px;
- text-decoration: none;
+ color: #90b874;
+ font-weight: bold;
+ font-size: 1.4em;
+ margin-right: 5px;
+ text-decoration: none;
}
#header ul li a:hover {
- color: #beffbf;
+ color: #beffbf;
}
-#nav-container {
- height: 30px;
- background-color:#E4E4E4;
- border-bottom:1px solid #7A7A7A;
- box-shadow: 0px 0px 2px #000;
-}
-#nav {
- width: 1000px;
- margin: 0 auto;
- position: relative;
- padding-top:8px;
+
+
+
+#reports > li {
+ display: box;
+ box-orient: horizontal;
+ width: 100%;
}
+
+
+
+
+
.label {
- font-color:000;
- font-size: 12px;
- font-weight:bolder;
+ font-color:000;
+ font-size: 12px;
+ font-weight:bolder;
+}
+
+#main {
+ background: red;
+ display: box;
+}
+
+.source {
+ height: 100%;
+ font-family: monospace;
+ font-size: 12px;
+ padding: 1em;
+ background: white;
+ box-flex: 1;
+ line-height: 1.33;
+}
+.source table {
+ width: 100%;
}
#bug-toggle {
- color:#000;
- font-size:12px;
- float:right;
- vertical-align:middle;
+ color:#000;
+ font-size:12px;
+ float:right;
+ vertical-align:middle;
}
-#bug-toggle img{
- padding-right:5px;
- vertical-align:middle;
+#code {
+ background: blue;
+ min-width: 300px;
+ box-flex: 2;
+}
+.source tr:nth-child(2n) {
+ background: hsl(0, 0%, 93%);
}
-#white-box {
- width:27px;
- height:18px;
- background-color:#fff;
- border: 1px solid #CCCCCC;
- float:right;
- margin-left:10px;
- padding-left:10px;
- padding-top:3px;
- margin-top:-4px;
+#bug-toggle img{
+ padding-right:5px;
+ vertical-align:middle;
}
#container {
- width: 1000px;
- margin: 0 auto;
- font-size:12px;
- overflow: auto;
- padding: 70px 0 0px;
- background-color:#f8f8f8;
+ width: 1000px;
+ margin: 0 auto;
+ font-size:12px;
+ overflow: auto;
+ padding: 70px 0 0px;
+ background-color:#f8f8f8;
}
#content {
- float: left;
- width: 660px;
- padding-top:20px;
- padding-left:20px;
- padding-right:10px;
+ float: left;
+ width: 660px;
+ padding-top:20px;
+ padding-left:20px;
+ padding-right:10px;
}
@@ -177,75 +234,135 @@ blockquote {
.fnc-report {
- font-size:12px;
+ font-size:12px;
}
#error-box {
- font-size:12px;
- font-color:000;
- float:left;
+ font-size:12px;
+ font-color:000;
+ float:left;
}
#report-count{
- font-size:12px;
- font-color:000;
- float:right;
+ font-size:12px;
+ float:right;
}
-#sidebar {
- float: right;
- width: 300px;
- background-color:#EBEBEB;
- min-height:700px;
- padding-top:60px;
+/* Left column: source code */
+.source tr:hover {
+ background: hsl(210, 30%, 87%);
+}
+.source .lineno {
+ padding-right: 0.5em;
+ text-align: right;
+ user-select: none;
+ color: hsl(0, 0%, 60%);
+}
+.source .code {
+ white-space: pre-wrap;
}
-.annotation-box {
- background-color:#fff;
- border: 1px solid #CCC;
- width:278px;
- min-height:55px;
- margin-left:10px;
- margin-bottom:10px;
- padding:5px;
- line-height:20px;
+
+/* Right column: list of states */
+.states {
+ font-size: 12px;
+ top: 0.5em;
+ height: 100%;
+ width: 24em;
+ border-left: 1px solid hsl(0, 0%, 70%);
+}
+.states li {
+ position: relative;
+ padding: 0.5em;
+ margin: 1em;
+ background: white;
+ border: 1px solid hsl(0, 0%, 80%);
+}
+.states li.new-subflow {
+ border-top-width: 4px;
+}
+.states h2 {
+ float: right;
+ padding: 0.33em 0.5em;
+ margin: -0.5em -0.5em 0.5em 0.5em;
+ background: hsl(0, 0%, 80%);
+ color: hsl(0, 0%, 30%);
+ border-radius: 0 0 0 0.5em;
+}
+.states p {
+ line-height: 1.5;
+}
+.states p + p {
+ margin-top: 0.5em;
}
-.annotation-box img {
- vertical-align:middle;
+var {
+ color: navy;
+}
+var.leak {
+ color: darkred;
+ font-weight: bold;
+ background: hsl(0, 100%, 90%);
}
-.annotation-box.selected {
- background-color:#FEF8CB;
- border: 1px solid #FFE181;
- margin-left:-10px;
+.flow-line {
+ background: hsl(210, 80%, 60%);
+ background-clip: content-box;
+}
+.flow-empty, .flow-line {
+ width: 2px;
+ padding: 0 5px;
+ vertical-align: middle;
+}
+.flow-dot {
+ display: block;
+ background: hsl(210, 80%, 60%);
+ outline: 1px solid rgba(100%, 100%, 100%, 0.5);
+ height: 6px;
+ width: 6px;
+ margin: 0 -2px;
+ border-radius: 100px;
+ outline-radius: 100px;
}
-#annotation-comment {
- margin-top:5px;
- line-height:20px;
+/* Selection overrides */
+.states li {
+ left: 0;
+ transition-property: left background-color border-color;
+}
+.source tr
+.states li h2 {
+ transition-property: background-color;
+}
+td .flow-dot,
+.states li,
+.states li h2 {
+ transition-duration: 0.25s;
+ transition-timing-function: ease-out;
}
-#footer-wrap {
- position: fixed;
- bottom: 0;
- left: 0;
- width: 100%;
+td.selected .flow-dot {
+ height: 10px;
+ width: 10px;
+ margin: 0 -4px;
+ background: hsl(30, 80%, 60%);
}
-#footer-container {
- height: 30px;
- background-color:#0099FF;
+.source tr.selected {
+ background-color: #ffe181;
+}
+.states li.selected {
+ left: -2em;
+ background-color: #fef8cb;
+ border-color: #ffe181;
+}
+.states li.selected h2 {
+ background-color: #ffe181;
}
-#footer {
- width: 1000px;
- margin: 0 auto;
- position: relative;
-}
-#footer-text {
- font-size:12px;
- color:#fff;
- padding-top:8px;
- text-shadow: 0px 1px 0px #000;
+
+
+#notes {
+ background: yellow;
+ min-width: 200px;
}

No commit comments for this range

Something went wrong with that request. Please try again.