GithubHelp home page GithubHelp logo

jdcallgraph's Introduction

jdcallgraph

JDCallgraph - Dynamic call graph generation for Java. Uses ByteBuddy or Javassist to instrument the target application. Can also create a data dependency graph to show field access between methods. Support various output formats like csv, dot or a matrix.

Build Status Coverage Status

How-To

Download the jdcallgraph.jar or build it using mvn install. You have to invoke java with the -javaagent:/path/to/jdcallgraph.jar=/path/to/config.ini. A few examples:

Plain Java/Jar

java -javaagent:/path/to/jdcallgraph.jar=/path/to/config.ini example.Main

or

java -javaagent:/path/to/jdcallgraph.jar=/path/to/config.ini -jar target.jar

Maven

Simply invoke Maven with the -DargLine=-javaagent:/path/to/jdcallgraph.jar=/path/to/config.ini parameter. There is a wrapper script you can use like normal Maven:

./mvn.sh test -f /path/to/pom.xml

Ant

I did not succeed starting it with the ANT_OPTS environment variable. Instead you can edit your build.xml: Change the lines

<junit fork="no">
  ...
</junit>

To

<junit fork="yes" forkmode="once">
  <jvmarg value="-javaagent:/path/to/jdcallgraph.jar=/path/to/config.ini" />
  ...
</junit>

Configuration options

You can pass the path to a configuration file in the following way:

java -javaagent:jdcallgraph=/path/to/config.ini -jar target.jar

The config file has to contain key-value-pairs in a syntax similar to YAML. Whitespace as well as lines starting with # are ignored:

# this is a comment
key1: false
# a list of values
key2: 1, 2, 3

You can check out the configurations in the example folder. Options not present in your config take the value from defaults.ini The following options are supported:

Output directory outDir (String)

Specify an output directory. Either absolute or relative path to a folder. JDCallgraph will put all the resulting graphs and log files into this folder.

Log Level logLevel (int)

Specify a log level. From 6 - TRACE (the most verbose) to 0 - OFF (no logging).

Console Output logConsole (boolean)

Switch logging to console on or off. When set to true it will not only log to the logfiles but also print log statements to the console. The output is mixed with the output of the original program.

Multigraph multiGraph (boolean)

Whether the resulting graphs should contain duplicate edges. Note that JDCallgraph has to keep a list of known edges which might lead to memory issues with large graphs.

Group graphs by groupBy (Enum)

Specify the criteria that is used to group the graphs. It will output one graph per category. Valid options are:

  • THREAD: The default. One graph per thread of the observed program.
  • ENTRY: A new graph for each entry method. An entry method is every interesting method with an empty stacktrace

Output format writeTo ([Enum])

Specify one or multiple output formats. Multiple formats are separated by comma: DOT,TRACE. Valid options:

  • DOT: Write the graph to a .dot file. You can transform it to a png using dot -Tpng file.dot -o file.png
  • MATRIX: Output the coverage matrix to a file called matrix.csv. The file will contain one row per entry method and one column per covered method. For each entry-method-pair it either outputs 1, when it was covered, or 0 otherwise.
  • TRACE: Write a file called trace.csv. It contains one row per entry method and a list of methods that come after behind (Typically a list of methods covered per test).
  • COVERAGE: Write a coverage.csv file. The opposite of TRACE. For each method it lists the tests this method was covered in.
  • DATA: Also compute data dependency graphs. This will output them as .dot graph.

Backend javassist (boolean)

Decide which backend to use for the instrumentation. Since v0.2 ByteBuddy is the default (javassist: false). You can change this by setting this option to true. Note that Javassist is not compatible with Java 9, also the ByteBuddy backend is more tested.

jdcallgraph's People

Contributors

dkarv avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

jdcallgraph's Issues

Run JDCallgraph on D4J

Hi!
First of all, thanks for providing this tool :)
While I'm reading your ICST'20 paper, I found that you use this tool on the D4J dataset to extract the dynamic features.
Would you mind providing an example script to run this tool on the dataset if available?
I think that would be a really great tutorial to get used to this tool.
Thank you.

<clinit> should appear in every call graph

Assume this situation: Multiple tests are executed for the same class. But now the static initializer clinit will only appear in the callgraph of the first test. Once the method is initialized it is not called a second time.
We should remember all clinit calls and apply them to each entry the first time a class is used.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.