OPAL-Regarding implementing construct call graph in OPAL

蹲街弑〆低调 提交于 2019-12-12 04:27:53

问题


In Paper [A Software Product Line for Static Analyses(2014)], there is an illustration related constructing call graph(Listing7).

In this example, Line14 is related to construct call graph. while i check the src code and API, what i could find is DefaultCHACallGraphDomain.scala which has no implementation of construct call graph.

As my purpose is using OPAL to construct call graph. Is there any demo or documents help me understanding existing CallGraphDomain in OPAL? currently, i can only find some class declaration.

I'll be really appreciated if anyone can give me some suggestions related this topic.

Thanks in advance.

Jiang


回答1:


The interface that was shown in the paper doesn't exist anymore, so you can totally forget about it.

The default interface to get a CallGraph class is provided by the Project object you retrieve when you load the bytecode a Java project.

A general code Example:

val project = ... // a java project
val computedCallGraph = project.get(/* Some call graph key */)
val callGraph = computedCallGraph.callGraph // the final call graph interface.

The computed call graph contains several things. It contains the entry points, unresolved method calls, exceptions when something went wrong at the construction time and the actual call graph.

OPAL provides you several call graph algorithms, you can retrieve each by passing the corresponding call graph key to the Project's get method.

Currently, the following two keys are available and can be passed to Project.get (more information is available in the documentation of this classes):

  • CHACallGraphKey
  • VTACallGraphKey

Analysis mode - Library vs Application

To construct a valid call graph for a software project it depends on the project kind which analysis mode to chose. While applications provide complete information (except incomplete projects, class loading and so on), software libraries are intended to be used by other projects. However, those two different scenarios have to be kept in mind, when construction call graphs. More details can be found here: org.opalj.AnalysisModes

OPAL offers the following analysis modes:

  • DesktopApplication (safe for application call graphs)
  • LibraryWithClosePackagesAssumption (safe for call graphs that are used for security-insensitive analyses)
  • LibraryWithOpenPackagesAssumption (very conservative/safe for security analyses)

The analysis mode can be either configured in OPAL's config file or set as project setting at runtime. You can find the config file in the Common project under /src/main/resources/reference.conf.

All of those analysis modes are supported by the the CHACallGraphKey while VTACallGraphKey only supports applications so far.

NOTE: The interface may change in upcoming versions again.



来源:https://stackoverflow.com/questions/41043654/opal-regarding-implementing-construct-call-graph-in-opal

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!