Skip to content

Commit f210b85

Browse files
committed
Trying to debug Scala Port with valgrind.
1 parent f981884 commit f210b85

File tree

5 files changed

+59
-23
lines changed

5 files changed

+59
-23
lines changed

source/ports/scala_port/README.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,3 +19,25 @@ PORT_LIBRARY_PATH
1919
```
2020

2121
> Note: You'll find the bindings and the code that runs on `sbt test` in `src/main/scala/MetaCall.scala`.
22+
23+
## Debugging
24+
25+
Uncomment this line in `build.sbt`:
26+
```
27+
"-Djava.compiler=NONE",
28+
```
29+
30+
Build the project:
31+
```
32+
sbt compile
33+
```
34+
35+
For runing valgrind with the correct classpath, run:
36+
```
37+
sbt "export test:fullClasspath"
38+
```
39+
40+
Then copy the classpath into the valgrind command:
41+
```
42+
valgrind --tool=memcheck --trace-children=yes --error-limit=no scala -Djava.compiler=NONE -cp <classpath> src/test/scala/MetaCallSpecMain.scala
43+
```

source/ports/scala_port/build.sbt

Lines changed: 26 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,32 @@
1-
ThisBuild / scalaVersion := "2.13.4"
2-
ThisBuild / version := "0.1.0-SNAPSHOT"
3-
ThisBuild / organization := "com.metacall"
4-
ThisBuild / organizationName := "metacall"
1+
lazy val commonSettings = Seq(
2+
scalaVersion := "2.13.4",
3+
version := "0.1.0-SNAPSHOT",
4+
organization := "com.metacall",
5+
organizationName := "metacall",
6+
scalacOptions ++= Seq(
7+
// Only for debugging purposes
8+
// "-Djava.compiler=NONE",
9+
"-feature",
10+
"-deprecation",
11+
"-Wunused:imports,patvars,privates,locals,explicits,implicits,params",
12+
"-Xlint",
13+
"-explaintypes",
14+
"-Wdead-code",
15+
"-Wextra-implicit",
16+
"-Wnumeric-widen",
17+
"-Wconf:cat=lint-byname-implicit:silent"
18+
),
19+
scalacOptions in (Compile, console) := Seq.empty,
20+
libraryDependencies ++= Seq(
21+
"net.java.dev.jna" % "jna" % "5.6.0",
22+
"org.typelevel" %% "cats-core" % "2.3.1",
23+
"org.scalatest" %% "scalatest" % "3.2.2" % Test,
24+
)
25+
)
526

627
lazy val root = (project in file("."))
28+
.settings(commonSettings: _*)
729
.settings(
830
name := "metacall",
9-
scalacOptions ++= Seq(
10-
"-feature",
11-
"-deprecation",
12-
"-Wunused:imports,patvars,privates,locals,explicits,implicits,params",
13-
"-Xlint",
14-
"-explaintypes",
15-
"-Wdead-code",
16-
"-Wextra-implicit",
17-
"-Wnumeric-widen",
18-
"-Wconf:cat=lint-byname-implicit:silent"
19-
),
20-
scalacOptions in (Compile, console) := Seq.empty,
21-
libraryDependencies ++= Seq(
22-
"net.java.dev.jna" % "jna" % "5.6.0",
23-
"org.typelevel" %% "cats-core" % "2.3.1",
24-
"org.scalatest" %% "scalatest" % "3.2.2" % Test,
25-
"com.lihaoyi" %% "pprint" % "0.5.6" % Test
26-
),
2731
fork in (Test / run) := true
2832
)

source/ports/scala_port/src/test/scala/MetaCallSpec.scala

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -414,5 +414,4 @@ class MetaCallSpec extends AnyFlatSpec {
414414
"MetaCall was not successfully destroyed"
415415
)
416416
}
417-
418417
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import metacall._
2+
3+
object Main extends App {
4+
(new MetaCallSpec()).execute()
5+
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
ignore_jvm
3+
Memcheck:Leak
4+
...
5+
obj:*/libjvm.so*
6+
}

0 commit comments

Comments
 (0)