Skip to content

Commit 38f828a

Browse files
committed
fix constraint collection
1 parent 61c3d76 commit 38f828a

18 files changed

Lines changed: 181 additions & 697 deletions

File tree

.claude/settings.local.json

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,13 @@
2929
"Bash(./test-auto-fixed.bat)",
3030
"Bash(mvn test-compile:*)",
3131
"Bash(./compile-and-run-simple-test.bat)",
32-
"Bash(mvn compile:*)"
32+
"Bash(mvn compile:*)",
33+
"Bash(cmd /c \"run-symbolic-execution.bat multivar > log.txt 2>&1\")",
34+
"Bash(run-symbolic-execution.bat:*)",
35+
"Bash(javap:*)",
36+
"Bash(cmd /c \"dir /s /b %USERPROFILE%\\\\.m2\\\\repository\\\\edu\\\\gmu\\\\swe\\\\greensolver 2>nul | findstr pom\")",
37+
"Bash(cmd /c \"cd /d C:\\\\Users\\\\10239\\\\galette-vitruv\\\\knarr-runtime && mvn clean compile -DskipTests -Dcheckstyle.skip=true 2>&1 | findstr /C:\"ERROR\" /C:\"WARNING\" /C:\"BUILD SUCCESS\" /C:\"BUILD FAILURE\"\")",
38+
"Bash(cmd /c \"cd /d C:\\\\Users\\\\10239\\\\galette-vitruv\\\\knarr-runtime && mvn clean compile -DskipTests -Dcheckstyle.skip=true\")"
3339
]
3440
}
3541
}

knarr-runtime/execution_paths_automatic.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
"CreateAscetTaskRoutine:execute:userChoice_forTask_specialname==0"
1010
],
1111
"numConstraints": 2,
12-
"executionTimeMs": 2838
12+
"executionTimeMs": 1587
1313
},
1414
{
1515
"pathId": 2,
@@ -21,7 +21,7 @@
2121
"CreateAscetTaskRoutine:execute:userChoice_forTask_specialname==1"
2222
],
2323
"numConstraints": 2,
24-
"executionTimeMs": 58
24+
"executionTimeMs": 49
2525
},
2626
{
2727
"pathId": 3,
@@ -33,7 +33,7 @@
3333
"CreateAscetTaskRoutine:execute:userChoice_forTask_specialname==2"
3434
],
3535
"numConstraints": 2,
36-
"executionTimeMs": 48
36+
"executionTimeMs": 53
3737
},
3838
{
3939
"pathId": 4,
@@ -45,7 +45,7 @@
4545
"CreateAscetTaskRoutine:execute:userChoice_forTask_specialname==3"
4646
],
4747
"numConstraints": 2,
48-
"executionTimeMs": 50
48+
"executionTimeMs": 41
4949
},
5050
{
5151
"pathId": 5,
@@ -57,6 +57,6 @@
5757
"CreateAscetTaskRoutine:execute:userChoice_forTask_specialname==4"
5858
],
5959
"numConstraints": 2,
60-
"executionTimeMs": 46
60+
"executionTimeMs": 33
6161
}
6262
]

knarr-runtime/execution_paths_multivar.json

Lines changed: 25 additions & 25 deletions
Large diffs are not rendered by default.
Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
ord__wPadwN9UEfCxvehXjuLeOg|file:/C:/Users/10239/galette-vitruv/knarr-runtime/galette-output-automatic-0/example.model2#/0
2-
ord__wTiIwN9UEfCxvehXjuLeOg|galette-output-automatic-0/example.model#/0/@tasks.0
3-
ord__wOpowN9UEfCxvehXjuLeOg|galette-output-automatic-0/example.model#/0
4-
ord__wUFiYN9UEfCxvehXjuLeOg|file:/C:/Users/10239/galette-vitruv/knarr-runtime/galette-output-automatic-0/example.model2#/0/@tasks.0
1+
ord__t8ZNEN9mEfCKlNtLwWrujQ|galette-output-automatic-0/example.model#/0/@tasks.0
2+
ord__t5EzUN9mEfCKlNtLwWrujQ|galette-output-automatic-0/example.model#/0
3+
ord__t80D0N9mEfCKlNtLwWrujQ|file:/C:/Users/10239/galette-vitruv/knarr-runtime/galette-output-automatic-0/example.model2#/0/@tasks.0
4+
ord__t5lwsN9mEfCKlNtLwWrujQ|file:/C:/Users/10239/galette-vitruv/knarr-runtime/galette-output-automatic-0/example.model2#/0
Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
ord__wYux0N9UEfCxvehXjuLeOg|file:/C:/Users/10239/galette-vitruv/knarr-runtime/galette-output-automatic-1/example.model2#/0
2-
ord__wZBFsN9UEfCxvehXjuLeOg|file:/C:/Users/10239/galette-vitruv/knarr-runtime/galette-output-automatic-1/example.model2#/0/@tasks.0
3-
ord__wY5w8N9UEfCxvehXjuLeOg|galette-output-automatic-1/example.model#/0/@tasks.0
4-
ord__wYrugN9UEfCxvehXjuLeOg|galette-output-automatic-1/example.model#/0
1+
ord__uAPLQN9mEfCKlNtLwWrujQ|galette-output-automatic-1/example.model#/0
2+
ord__uARngN9mEfCKlNtLwWrujQ|file:/C:/Users/10239/galette-vitruv/knarr-runtime/galette-output-automatic-1/example.model2#/0
3+
ord__uAg4EN9mEfCKlNtLwWrujQ|file:/C:/Users/10239/galette-vitruv/knarr-runtime/galette-output-automatic-1/example.model2#/0/@tasks.0
4+
ord__uAZjUN9mEfCKlNtLwWrujQ|galette-output-automatic-1/example.model#/0/@tasks.0
Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
ord__wZjRMN9UEfCxvehXjuLeOg|galette-output-automatic-2/example.model#/0
2-
ord__wZltcN9UEfCxvehXjuLeOg|file:/C:/Users/10239/galette-vitruv/knarr-runtime/galette-output-automatic-2/example.model2#/0
3-
ord__wZ0W8N9UEfCxvehXjuLeOg|file:/C:/Users/10239/galette-vitruv/knarr-runtime/galette-output-automatic-2/example.model2#/0/@tasks.0
4-
ord__wZu3YN9UEfCxvehXjuLeOg|galette-output-automatic-2/example.model#/0/@tasks.0
1+
ord__uBRGAN9mEfCKlNtLwWrujQ|file:/C:/Users/10239/galette-vitruv/knarr-runtime/galette-output-automatic-2/example.model2#/0/@tasks.0
2+
ord__uBKYUN9mEfCKlNtLwWrujQ|galette-output-automatic-2/example.model#/0/@tasks.0
3+
ord__uA9kAN9mEfCKlNtLwWrujQ|galette-output-automatic-2/example.model#/0
4+
ord__uBAAQN9mEfCKlNtLwWrujQ|file:/C:/Users/10239/galette-vitruv/knarr-runtime/galette-output-automatic-2/example.model2#/0
Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
ord__wahhkN9UEfCxvehXjuLeOg|file:/C:/Users/10239/galette-vitruv/knarr-runtime/galette-output-automatic-3/example.model2#/0/@tasks.0
2-
ord__waRp8N9UEfCxvehXjuLeOg|file:/C:/Users/10239/galette-vitruv/knarr-runtime/galette-output-automatic-3/example.model2#/0
3-
ord__waba8N9UEfCxvehXjuLeOg|galette-output-automatic-3/example.model#/0/@tasks.0
4-
ord__waPNsN9UEfCxvehXjuLeOg|galette-output-automatic-3/example.model#/0
1+
ord__uBz4kN9mEfCKlNtLwWrujQ|galette-output-automatic-3/example.model#/0/@tasks.0
2+
ord__uBquoN9mEfCKlNtLwWrujQ|galette-output-automatic-3/example.model#/0
3+
ord__uBsj0N9mEfCKlNtLwWrujQ|file:/C:/Users/10239/galette-vitruv/knarr-runtime/galette-output-automatic-3/example.model2#/0
4+
ord__uB5YIN9mEfCKlNtLwWrujQ|file:/C:/Users/10239/galette-vitruv/knarr-runtime/galette-output-automatic-3/example.model2#/0/@tasks.0
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
ord__wbOFIN9UEfCxvehXjuLeOg|galette-output-automatic-4/example.model#/0/@tasks.0
2-
ord__wbDtEN9UEfCxvehXjuLeOg|file:/C:/Users/10239/galette-vitruv/knarr-runtime/galette-output-automatic-4/example.model2#/0
3-
ord__wbBQ0N9UEfCxvehXjuLeOg|galette-output-automatic-4/example.model#/0
1+
ord__uCZucN9mEfCKlNtLwWrujQ|galette-output-automatic-4/example.model#/0/@tasks.0
2+
ord__uCTAwN9mEfCKlNtLwWrujQ|file:/C:/Users/10239/galette-vitruv/knarr-runtime/galette-output-automatic-4/example.model2#/0
3+
ord__uCRyoN9mEfCKlNtLwWrujQ|galette-output-automatic-4/example.model#/0

knarr-runtime/pom.xml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,13 @@
2727
<groupId>edu.gmu.swe.greensolver</groupId>
2828
<artifactId>green</artifactId>
2929
<version>1.0-SNAPSHOT</version>
30+
<!-- Exclude transitive dependencies due to invalid POM systemPath declarations -->
31+
<exclusions>
32+
<exclusion>
33+
<groupId>*</groupId>
34+
<artifactId>*</artifactId>
35+
</exclusion>
36+
</exclusions>
3037
</dependency>
3138

3239
<!-- Z3 SMT Solver dependency for advanced constraint solving -->

knarr-runtime/src/main/java/edu/neu/ccs/prl/galette/concolic/knarr/runtime/GaletteSymbolicator.java

Lines changed: 81 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,12 @@ public class GaletteSymbolicator {
4646
*/
4747
public static final boolean DEBUG = true; // Boolean.valueOf(System.getProperty("DEBUG", "false"));
4848

49+
/**
50+
* Manual mode flag - when true, Tag verification is skipped.
51+
* This is used when running with PathUtils API instead of javaagent instrumentation.
52+
*/
53+
public static final boolean MANUAL_MODE = Boolean.valueOf(System.getProperty("skip.instrumentation.check", "false"));
54+
4955
/**
5056
* Internal class name for bytecode instrumentation.
5157
*/
@@ -78,6 +84,13 @@ public class GaletteSymbolicator {
7884
*/
7985
private static final ConcurrentHashMap<String, Tag> labelToTag = new ConcurrentHashMap<>();
8086

87+
/**
88+
* ThreadLocal mapping from concrete values to their qualified names.
89+
* Used for hybrid constraint collection when Tag propagation fails.
90+
* This enables symbolicVitruviusChoice to infer variable names.
91+
*/
92+
private static final ThreadLocal<Map<Integer, String>> valueToQualifiedName = ThreadLocal.withInitial(HashMap::new);
93+
8194
static {
8295
initializeSymbolicator();
8396
}
@@ -168,11 +181,15 @@ public static Integer getOrMakeSymbolicInt(String qualifiedName, int concreteVal
168181
+ " = " + concreteValue);
169182
}
170183

171-
// CRITICAL FIX: Re-record constraints even when reusing tag!
172-
// PathUtils.resetPC() clears constraints between iterations, so we must re-add them
173-
// Both domain and switch constraints are needed for PathExplorer
184+
// HYBRID: Record domain constraint here
185+
// Switch constraint will be added by symbolicVitruviusChoice
174186
PathUtils.addIntDomainConstraint(qualifiedName, min, max + 1);
175-
PathUtils.addSwitchConstraint(qualifiedName, concreteValue);
187+
188+
// Register value-to-name mapping for hybrid inference
189+
valueToQualifiedName.get().put(concreteValue, qualifiedName);
190+
191+
// Remove manual switch constraint (let symbolicVitruviusChoice handle it)
192+
// PathUtils.addSwitchConstraint(qualifiedName, concreteValue);
176193

177194
if (DEBUG) {
178195
System.out.println("[GaletteSymbolicator:getOrMakeSymbolicInt] Re-recorded constraints:");
@@ -183,17 +200,21 @@ public static Integer getOrMakeSymbolicInt(String qualifiedName, int concreteVal
183200
// Apply the tag to the value and return
184201
Integer taggedValue = Tainter.setTag(concreteValue, existingTag);
185202

186-
// Debug: Verify the tag was actually applied
187-
Tag verifyTag = Tainter.getTag(taggedValue);
188-
if (verifyTag == null) {
189-
System.err.println(
190-
"[GaletteSymbolicator:getOrMakeSymbolicInt] WARNING: Reused tag was not applied!");
191-
System.err.println(" Instrumentation may not be working. Check that Galette agent is loaded.");
192-
} else {
193-
if (DEBUG) {
194-
System.out.println("[GaletteSymbolicator:getOrMakeSymbolicInt] Verified reused tag applied: "
195-
+ verifyTag.getLabels()[0]);
203+
// Debug: Verify the tag was actually applied (skip in manual mode)
204+
if (!MANUAL_MODE) {
205+
Tag verifyTag = Tainter.getTag(taggedValue);
206+
if (verifyTag == null) {
207+
System.err.println(
208+
"[GaletteSymbolicator:getOrMakeSymbolicInt] WARNING: Reused tag was not applied!");
209+
System.err.println(" Instrumentation may not be working. Check that Galette agent is loaded.");
210+
} else {
211+
if (DEBUG) {
212+
System.out.println("[GaletteSymbolicator:getOrMakeSymbolicInt] Verified reused tag applied: "
213+
+ verifyTag.getLabels()[0]);
214+
}
196215
}
216+
} else if (DEBUG) {
217+
System.out.println("[GaletteSymbolicator:getOrMakeSymbolicInt] Manual mode: Skipping tag verification for reused tag");
197218
}
198219

199220
return taggedValue;
@@ -208,13 +229,16 @@ public static Integer getOrMakeSymbolicInt(String qualifiedName, int concreteVal
208229
// Store for reuse in future iterations
209230
labelToTag.put(qualifiedName, newTag);
210231

211-
// Record domain constraint [min, max] (only on first iteration)
232+
// HYBRID: Record domain constraint here
233+
// Switch constraint will be added by symbolicVitruviusChoice
212234
// Note: PathUtils.addIntDomainConstraint uses exclusive upper bound
213235
PathUtils.addIntDomainConstraint(qualifiedName, min, max + 1);
214236

215-
// CRITICAL: Also record the switch constraint for this specific value
216-
// This is needed for path exploration to generate alternative inputs
217-
PathUtils.addSwitchConstraint(qualifiedName, concreteValue);
237+
// Register value-to-name mapping for hybrid inference
238+
valueToQualifiedName.get().put(concreteValue, qualifiedName);
239+
240+
// Remove manual switch constraint (let symbolicVitruviusChoice handle it)
241+
// PathUtils.addSwitchConstraint(qualifiedName, concreteValue);
218242

219243
if (DEBUG) {
220244
System.out.println("[GaletteSymbolicator:getOrMakeSymbolicInt] Created new tag for: " + qualifiedName
@@ -226,11 +250,15 @@ public static Integer getOrMakeSymbolicInt(String qualifiedName, int concreteVal
226250
// Apply the tag to the value and return
227251
Integer taggedValue = Tainter.setTag(concreteValue, newTag);
228252

229-
// Debug: Verify the tag was actually applied
230-
Tag verifyTag = Tainter.getTag(taggedValue);
231-
if (verifyTag == null) {
232-
System.err.println("[GaletteSymbolicator:getOrMakeSymbolicInt] WARNING: New tag was not applied!");
233-
System.err.println(" Instrumentation may not be working. Check that Galette agent is loaded.");
253+
// Debug: Verify the tag was actually applied (skip in manual mode)
254+
if (!MANUAL_MODE) {
255+
Tag verifyTag = Tainter.getTag(taggedValue);
256+
if (verifyTag == null) {
257+
System.err.println("[GaletteSymbolicator:getOrMakeSymbolicInt] WARNING: New tag was not applied!");
258+
System.err.println(" Instrumentation may not be working. Check that Galette agent is loaded.");
259+
}
260+
} else if (DEBUG) {
261+
System.out.println("[GaletteSymbolicator:getOrMakeSymbolicInt] Manual mode: Skipping tag verification");
234262
}
235263

236264
return taggedValue;
@@ -672,13 +700,43 @@ public static InputSolution sendConstraintToServer(Expression constraint) {
672700
}
673701
}
674702

703+
/**
704+
* Get qualified name for a concrete value (for hybrid constraint collection).
705+
* This is used by symbolicVitruviusChoice to auto-infer variable names
706+
* when Tag propagation fails.
707+
*
708+
* @param value The concrete value
709+
* @return Qualified name, or null if not found
710+
*/
711+
public static String getQualifiedNameForValue(int value) {
712+
String name = valueToQualifiedName.get().get(value);
713+
if (DEBUG && name != null) {
714+
System.out.println(
715+
"[GaletteSymbolicator:getQualifiedNameForValue] Resolved value " + value + " -> " + name);
716+
}
717+
return name;
718+
}
719+
720+
/**
721+
* Clear value-to-name mapping at the end of each iteration.
722+
* This is called by PathExplorer after each iteration.
723+
*/
724+
public static void clearValueMapping() {
725+
Map<Integer, String> map = valueToQualifiedName.get();
726+
if (DEBUG && !map.isEmpty()) {
727+
System.out.println("[GaletteSymbolicator:clearValueMapping] Clearing " + map.size() + " value mappings");
728+
}
729+
map.clear();
730+
}
731+
675732
/**
676733
* Reset the symbolicator state.
677734
*/
678735
public static void reset() {
679736
valueToTag.clear();
680737
tagToExpression.clear();
681738
labelToTag.clear(); // Clear label-to-tag mappings for tag reuse
739+
clearValueMapping(); // Also clear value-to-name mapping
682740
mySoln = null;
683741
GaletteGreenBridge.clearVariableCache();
684742
PathUtils.reset();

0 commit comments

Comments
 (0)