-
Notifications
You must be signed in to change notification settings - Fork 326
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
19 changed files
with
539 additions
and
235 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,48 +1,3 @@ | ||
# Debugging Enso and Java Code at Once | ||
|
||
Enso libraries are written in a mixture of Enso code and Java libraries. | ||
Debugging both sides (the Java as well as Enso code) is possible with a decent | ||
IDE. | ||
|
||
Get [NetBeans](http://netbeans.apache.org) version 13 or newer or | ||
[VS Code with Apache Language Server extension](https://cwiki.apache.org/confluence/display/NETBEANS/Apache+NetBeans+Extension+for+Visual+Studio+Code) | ||
and _start listening on port 5005_ with _Debug/Attach Debugger_ or by specifying | ||
following debug configuration in VSCode: | ||
|
||
```json | ||
{ | ||
"name": "Listen to 5005", | ||
"type": "java+", | ||
"request": "attach", | ||
"listen": "true", | ||
"hostName": "localhost", | ||
"port": "5005" | ||
} | ||
``` | ||
|
||
Then it is just about executing following Sbt command which builds CLI version | ||
of the engine, launches it in debug mode and passes all other arguments to the | ||
started process: | ||
|
||
```bash | ||
sbt:enso> runEngineDistribution --debug --run ./test/Tests/src/Data/Numbers_Spec.enso | ||
``` | ||
|
||
Alternatively you can pass in special JVM arguments when launching the | ||
`bin/enso` launcher: | ||
|
||
```bash | ||
enso$ JAVA_OPTS=-agentlib:jdwp=transport=dt_socket,server=n,address=5005 ./built-distribution/enso-engine-*/enso-*/bin/enso --run ./test/Tests/src/Data/Numbers_Spec.enso | ||
``` | ||
|
||
As soon as the debuggee connects and the Enso language starts - choose the | ||
_Toggle Pause in GraalVM Script_ button in the toolbar: | ||
|
||
![NetBeans Debugger](https://user-images.githubusercontent.com/26887752/209614191-b0513635-819b-4c64-a6f9-9823b90a1513.png) | ||
|
||
and your execution shall stop on the next `.enso` line of code. This mode allows | ||
to debug both - the Enso code as well as Java code. The stack traces shows a | ||
mixture of Java and Enso stack frames by default. Right-clicking on the thread | ||
allows one to switch to plain Java view (with a way more stack frames) and back. | ||
Analyzing low level details as well as Enso developer point of view shall be | ||
simple with such tool. | ||
Desribed at [Runtime Debugging](runtime-debugging.md). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
85 changes: 85 additions & 0 deletions
85
engine/runtime-parser/src/main/java/org/enso/compiler/core/ir/IrLazyMap.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
package org.enso.compiler.core.ir; | ||
|
||
import java.io.IOException; | ||
import java.util.AbstractMap; | ||
import java.util.LinkedHashMap; | ||
import java.util.LinkedHashSet; | ||
import java.util.Map; | ||
import java.util.Objects; | ||
import java.util.Set; | ||
|
||
import org.enso.persist.Persistance; | ||
import org.enso.persist.Persistance.Reference; | ||
|
||
|
||
final class IrLazyMap<K, V> extends AbstractMap<K, V> { | ||
private final Map<K, Entry<K, V>> delegate; | ||
|
||
@SuppressWarnings("unchecked") | ||
IrLazyMap(Persistance.Input in) throws IOException { | ||
var map = new LinkedHashMap<K, Entry<K, V>>(); | ||
var n = in.readInt(); | ||
for (var i = 0; i < n; i++) { | ||
var key = (K) in.readObject(); | ||
var ref = (Reference<V>) in.readReference(Object.class); | ||
var en = new En<>(key, ref); | ||
map.put(key, en); | ||
} | ||
this.delegate = map; | ||
} | ||
|
||
@Override | ||
public Set<Entry<K, V>> entrySet() { | ||
return new LinkedHashSet<>(this.delegate.values()); | ||
} | ||
|
||
@Override | ||
public V get(Object key) { | ||
var entry = this.delegate.get(key); | ||
return entry == null ? null : entry.getValue(); | ||
} | ||
|
||
private static final class En<K, V> implements Entry<K, V> { | ||
private final K key; | ||
private final Reference<V> ref; | ||
|
||
En(K key, Reference<V> ref) { | ||
this.key = key; | ||
this.ref = ref; | ||
} | ||
|
||
@Override | ||
public K getKey() { | ||
return key; | ||
} | ||
|
||
@Override | ||
@SuppressWarnings("unchecked") | ||
public V getValue() { | ||
return (V) ref.get(Object.class); | ||
} | ||
|
||
@Override | ||
public V setValue(V value) { | ||
throw new UnsupportedOperationException(); | ||
} | ||
|
||
@Override | ||
public int hashCode() { | ||
int hash = 7; | ||
hash = 29 * hash + Objects.hashCode(this.key); | ||
return hash; | ||
} | ||
|
||
@Override | ||
public boolean equals(Object obj) { | ||
if (this == obj) { | ||
return true; | ||
} | ||
if (obj instanceof En<?, ?> other) { | ||
return Objects.equals(this.key, other.key); | ||
} | ||
return false; | ||
} | ||
} | ||
} |
Oops, something went wrong.