Skip to content

Instantly share code, notes, and snippets.

@tasosxak
Last active April 28, 2022 13:18
Show Gist options
  • Save tasosxak/57e8338909939e10de24aca7350f383b to your computer and use it in GitHub Desktop.
Save tasosxak/57e8338909939e10de24aca7350f383b to your computer and use it in GitHub Desktop.
tracemonitor_runtime_with_master.scala
var moni_ = new PropertyMonitor
def eval(event: String): Boolean = {
//println("MONITOR RECEIVED: ", event)
openResultFile("dejavu-results")
var input = event.split(",")
var name = input(0)
var args = new ListBuffer[Any]()
Options.BITS = 20
for (i <- 1 until input.length) {
args += input(i)
}
moni_.lineNr+=1
//println("arguments:", args.toList)
moni_.submit(name, args.toList)
//println("%d",moni_.lineNr)
closeResultFile()
return true;
}
@tasosxak
Copy link
Author

Extracting a runtime monitor in order to import to a C++ FMI master.

$DEJAVU=~/dejavu/dir

  1. java -cp $DEJAVU/dejavu.jar dejavu.Verify prop1.qtl (Parse & create monitor for the specified stl prop)
  2. scalac -cp .:$DEJAVU/dejavu.jar TraceMonitor.scala 2>&1 -d TraceMonitor.jar (Compile & group the generated class files in to a single jar file)

You can run the program to verify that until now all works as expected:
3. scala -cp $DEJAVU/dejavu.jar TraceMonitor.jar log1.csv

Make the TraceMonitor.class file as main class file of the jar
4. jar --update --verbose --file TraceMonitor.jar --main-class TraceMonitor

Run:
5. java -cp $DEJAVU/dejavu.jar:/usr/share/scala-2.11/lib/scala-library.jar:TraceMonitor.jar TraceMonitor log1.csv

Now you can run the monitor as jar with the necessary depedencies.

@tasosxak
Copy link
Author

How to create a monitor for FMI master?

  1. Write the property in dejavu
  2. Execute the first command above
  3. Add the function named "eval" and the object moni_ in TraceMonitor object of the file TraceMonitor.scala
  4. Complete the next commands of the above description (step 2)
  5. Add the TraceMonitor.jar file path in the FMI Master code
  6. Compile the FMI Master

@tasosxak
Copy link
Author

How to compile the Master with the monitor jar file ?
g++ src/DEPLOY_TEMPLATE.cpp -I includes -I/usr/lib/jvm/java-1.11.0-openjdk-amd64/include/ -I/usr/lib/jvm/java-1.11.0-openjdk-amd64/include/linux -L/lib64 -Lbip_example -ljvm -ldl -o master

Problems with libjvm.so ?
sudo ln -s /usr/lib/jvm/java-1.11.0-openjdk-amd64/lib/server/libjvm.so /lib/x86_64-linux-gnu/libjvm.so

@tasosxak
Copy link
Author

tasosxak commented Apr 28, 2022

If you want to find a java function's signature in bytecode format run:
javap -v -classpath TraceMonitor.jar TraceMonitor

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment