All Projects → ShiftLeftSecurity → Llvm2graphml

ShiftLeftSecurity / Llvm2graphml

Licence: apache-2.0
Explore LLVM Bitcode interactively using a graph database

Projects that are alternatives of or similar to Llvm2graphml

Gremlin Orm
gremlin-orm is an ORM for graph databases in Node.js
Stars: ✭ 136 (+209.09%)
Mutual labels:  graph-database, gremlin
Tinkerpop
Apache TinkerPop - a graph computing framework
Stars: ✭ 1,309 (+2875%)
Mutual labels:  graph-database, gremlin
Janusgraph
JanusGraph: an open-source, distributed graph database
Stars: ✭ 4,277 (+9620.45%)
Mutual labels:  graph-database, gremlin
Ferma
An ORM / OGM for the TinkerPop graph stack.
Stars: ✭ 130 (+195.45%)
Mutual labels:  graph-database, gremlin
Gremlin Javascript
JavaScript tools for graph processing in Node.js and the browser inspired by the Apache TinkerPop API
Stars: ✭ 209 (+375%)
Mutual labels:  graph-database, gremlin
janusgraph-docker
Yet another JanusGraph, Cassandra/Scylla and Elasticsearch in Docker Compose setup
Stars: ✭ 54 (+22.73%)
Mutual labels:  graph-database, gremlin
Gremlin Scala
Scala wrapper for Apache TinkerPop 3 Graph DSL
Stars: ✭ 462 (+950%)
Mutual labels:  graph-database, gremlin
Cfl
a Compileable statically typed Functional programming Language
Stars: ✭ 7 (-84.09%)
Mutual labels:  llvm
Llvm Cheatsheet
LLVM, clang, ninja, dyld and others.
Stars: ✭ 36 (-18.18%)
Mutual labels:  llvm
Pragmascript
Stars: ✭ 7 (-84.09%)
Mutual labels:  llvm
Llvm Tutor
A collection of out-of-tree LLVM passes for teaching and learning
Stars: ✭ 941 (+2038.64%)
Mutual labels:  llvm
Llhttp
Port of http_parser to llparse
Stars: ✭ 841 (+1811.36%)
Mutual labels:  llvm
Coat
EDSL for C++ to make just-in-time code generation easier
Stars: ✭ 37 (-15.91%)
Mutual labels:  llvm
Woboq codebrowser
Woboq CodeBrowser
Stars: ✭ 837 (+1802.27%)
Mutual labels:  llvm
Researchnote
通过issue和README来记录日常学习研究笔记 关注 机器学习系统,深度学习, LLVM,性能剖视, Linux操作系统内核 话题 关注 C/C++. JAVA. Python. Golang. Chisel. 编程语言话题 ( Writing Blogs using github issue and markdown! (inculding Machine Learning algs and system, LLVM, Linux kernel, java, python, c++, golang)
Stars: ✭ 41 (-6.82%)
Mutual labels:  llvm
Ldc
The LLVM-based D Compiler.
Stars: ✭ 937 (+2029.55%)
Mutual labels:  llvm
Domtresat
Dominator Tree LLVM Pass to Test Satisfiability
Stars: ✭ 42 (-4.55%)
Mutual labels:  llvm
Llvm To Snes
LLVM IR → WLA DX (ASM 65c816) → SNES Rom
Stars: ✭ 39 (-11.36%)
Mutual labels:  llvm
Zion
A statically-typed strictly-evaluated garbage-collected readable programming language.
Stars: ✭ 33 (-25%)
Mutual labels:  llvm
Llvm Gbz80
LLVM port to the GBZ80 CPU
Stars: ✭ 32 (-27.27%)
Mutual labels:  llvm

llvm2graphml

llvm2graphml is a tool that helps you explore LLVM Bitcode interactively using a graph database.

Installation

Get the latest binary from here or build llvm2graphml yourself:

git clone https://github.com/ShiftLeftSecurity/llvm2graphml.git --recursive
mkdir build.dir; cd build.dir
cmake ../llvm2graphml
make
make install

Usage

Take this file:

; main.ll
define i32 @increment(i32 %x) {
  %result = add i32 %x, 1
  ret i32 %result
}

Convert it into GraphML:

> llvm2graphml --output-dir=/tmp main.ll
[llvm2graphml] [info] More details: /var/folders/pp/lt3pgm5971n1qw7pp2g_bmfr0000gn/T/llvm2graphml-77ed40.log
[llvm2graphml] [info] Loading main.ll
[llvm2graphml] [info] Saved result into /tmp/llvm.graphml.xml
[llvm2graphml] [info] Shutting down

The /tmp/llvm.graphml.xml now contains the graph version of the bitcode.

Run queries

To follow the example you need to install Gremlin Console from the Apache TinkerPop project.

Run the gremlin.sh to start the interactive session and load /tmp/llvm.graphml.xml into it.

> gremlin-console/bin/gremlin.sh

         \,,,/
         (o o)
-----oOOo-(3)-oOOo-----
plugin activated: tinkerpop.server
plugin activated: tinkerpop.utilities
plugin activated: tinkerpop.tinkergraph
gremlin> 
gremlin> graph = TinkerGraph.open()
gremlin> g = graph.traversal()
gremlin> g.io("/tmp/llvm.graphml.xml").read()

List all modules:

gremlin> g.V().hasLabel('module').valueMap().unfold()
==>moduleIdentifier=[main.ll]

List all functions:

gremlin> g.V().hasLabel('function').valueMap().unfold()
==>argSize=[1]
==>basicBlockCount=[1]
==>name=[increment]
==>isDeclaration=[false]
==>isVarArg=[false]
==>isIntrinsic=[false]
==>numOperands=[0]
==>instructionCount=[2]

Count all the instructions:

gremlin> g.V().hasLabel('instruction').groupCount().by('opcode').unfold()
==>ret=1
==>add=1

Explore the types:

gremlin> g.V().hasLabel('type').valueMap().unfold()
==>typeID=[void]
==>typeID=[label]
==>typeID=[pointer]
==>typeID=[function]
==>typeID=[integer]
==>bitwidth=[32]

Find functions with an argument called x:

gremlin> g.V().has('argument', 'name', 'x').out('function').valueMap('name')
==>[name:[increment]]

See more of those in the Queries.md.

Feature (in)completeness

llvm2graphml is not feature complete and is in a very early stage. Properties of instructions and values are not there yet, global variables and constants are also missing. Some more edges between things would probably help as well.

But we welcome contributions!

Contributing

Please, look at the CONTRIBUTING.md

License

Apache 2. See the LICENSE for more details.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].