H4ck3rm1k3's Blog

exploration of free/libre open source software and things

Sparql Queries against the gcc tree graphs — March 27, 2016

Sparql Queries against the gcc tree graphs

Here is one of the first nice looking outputs of my work on the gcc introspector in a long time. I am using the semantic web stack to processs gcc compiler graphs. My new take on this is to parse the tree dump outputs of the compiler as it’s own language using a python lex/yacc. Then I convert the tree graphs into RDF graphs and load them into a sparql database server and visualize them using d3/sparql.

The d3forcegraph graph looks like this :

graph1

Source of graph https://gist.github.com/h4ck3rm1k3/f8ca2cb3b9643e83200b

This query collects the edges of OP0,..OP3 args and it shows how there is a great graph of interconnections in the code.

SELECT ?on ?bn WHERE {
bind(replace(str(?o),’http://introspector.xyz/projects/bash/build/eval.c.001t.tu#’,”) as ?on)
bind(replace(str(?b),’http://introspector.xyz/projects/bash/build/eval.c.001t.tu#’,”) as ?bn){
?o <http://introspector.xyz/gcc/field_types.owl#OP0&gt; ?b.
}union {
?o <http://introspector.xyz/gcc/field_types.owl#OP1&gt; ?b.
}union {
?o <http://introspector.xyz/gcc/field_types.owl#OP2&gt; ?b.
}union {
?o <http://introspector.xyz/gcc/field_types.owl#OP3&gt; ?b.
}}

I have a patched version of the d3 sparql system :
https://github.com/h4ck3rm1k3/d3sparql

It is talking to the blazegraph server:
https://www.blazegraph.com/

That has this graph loaded (rdf) :
https://gist.github.com/h4ck3rm1k3/b99f78e7d415e80d1590

That was produced by my python code parsing the tu files:
https://github.com/h4ck3rm1k3/gcc_py_introspector

Reading the compiler graph data from bash, collected here
https://archive.org/details/bash.compilation

gccgo emacs go error message — April 9, 2015

gccgo emacs go error message

The gccgo runtime produces errors like this :

goroutine 18 [runnable]:
created by run_time.$init3
/home/h4ck3rm1k3/testgo2/src/github.com/h4ck3rm1k3/gocore/run_time/proc.go:116

Error message

I am matching them like this :

(custom-set-variables
;; custom-set-variables was added by Custom.
;; If you edit it by hand, you could mess it up, so be careful.
;; Your init file should contain only one such instance.
;; If there is more than one, they won’t work right.
‘(compilation-error-regexp-alist
(quote
(absoft ada aix ant bash borland python-tracebacks-and-caml comma cucumber msft edg-1 edg-2 epc ftnchek iar ibm irix java jikes-file maven jikes-line gcc-inc\
lude ruby-Test::Unit gnu lcc makepp mips-1 mips-2 msft omake oracle perl php rxp sparc-pascal-file sparc-pascal-line sparc-pascal-example sun sun-ada watcom 4bsd\
gcov-file gcov-header gcov-nomark gcov-called-line gcov-never-called perl–Pod::Checker perl–Test perl–Test2 perl–Test::Harness weblint go-test
(” \\(/[a-zA-Z/0-9._]+\\):\\([0-9]+\\)” 1 2 nil 2))))
‘(diff-switches “-u”))

see:

http://www.let.rug.nl/~kleiweg/go/go-emacs.html

Test random permutations of files and lines for gccgo golang go compiler bug reporting — March 31, 2015

Test random permutations of files and lines for gccgo golang go compiler bug reporting

If you are trying to debug a crash of the compiler you need to reduce your test case to something small.

Compiler writers cannot just take your huge project and find the crash.

For go (golang), at least the gccgo compiler,  you pass in a set of files and they are compiled in a package, so the number of files passed to the compiler matters.

I have two simple bash scripts to provoke a compiler crash by first selecting pairs of files to compile and testing them.

After you found the files, you can concatenate them together and select random lines until you can find the exact minimum lines to provoke a crash.

We are using the command shuf from GNU coreutils (https://www.gnu.org/software/coreutils/manual/html_node/shuf-invocation.html) to create random permutations, then use “head -$COUNT” to select COUNT lines from that permutation. This will pick random lines from an input. Then we look for the line “report” in the stderr to look for a sign of the crash, this will end the loop. The program stops when it finds a crash.

Here is the one to select files to compile

rm stop.txt
touch stop.txt
while [ $(wc -l stop.txt | cut -f1 -d ” “) -eq 0 ];
do echo test;
ls *.go | shuf | head -2 | tee test.txt | xargs ~/install/bin/gccgo > out.txt 2>err.txt;
echo $?;
grep report out.txt err.txt > stop.txt;
done

This takes a file with arg 1 and selects n lines with arg 2

rm stop.txt
touch stop.txt
while [ $(wc -l stop.txt | cut -f1 -d ” “) -eq 0 ];
do echo .;
echo “package main” > ~/test.go
cat $1 | shuf | head -$2 >> ~/test.go
~/install/bin/gccgo ~/test.go > out.txt 2>err.txt;
grep report out.txt err.txt > stop.txt;
done

cat ~/test.go # show the error

Feedback :