From 23c9f4bafd04a6f964d54de465d665f9d41dd804 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 23 Sep 2025 19:46:01 +0000 Subject: [PATCH 1/6] Initial plan From 06a1958f97f52edfb5af4cfd1a8bdfffe1f16e5d Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 23 Sep 2025 19:54:47 +0000 Subject: [PATCH 2/6] Replace System.out/err.println with logging in analysis and ML files (part 1) Co-authored-by: khatchad <2048831+khatchad@users.noreply.github.com> --- .../client/PythonTurtlePandasMergeAnalysis.java | 3 +++ .../PythonTurtleSKLearnClassifierAnalysis.java | 13 ++++++++----- .../cast/python/ir/PythonCAstToIRTranslator.java | 4 ++-- .../wala/cast/python/ml/cloud/CloudFunction.java | 5 ++++- .../ibm/wala/cast/python/ml/types/TensorType.java | 4 ++-- 5 files changed, 19 insertions(+), 10 deletions(-) diff --git a/core/com.ibm.wala.cast.python/source/com/ibm/wala/cast/python/client/PythonTurtlePandasMergeAnalysis.java b/core/com.ibm.wala.cast.python/source/com/ibm/wala/cast/python/client/PythonTurtlePandasMergeAnalysis.java index 0e8951c8d..b1e8dbc3f 100644 --- a/core/com.ibm.wala.cast.python/source/com/ibm/wala/cast/python/client/PythonTurtlePandasMergeAnalysis.java +++ b/core/com.ibm.wala.cast.python/source/com/ibm/wala/cast/python/client/PythonTurtlePandasMergeAnalysis.java @@ -54,10 +54,13 @@ import java.util.Set; import java.util.SortedSet; import java.util.TreeSet; +import java.util.logging.Logger; import org.json.JSONObject; public class PythonTurtlePandasMergeAnalysis extends PythonTurtleAnalysisEngine { + private static final Logger LOGGER = Logger.getLogger(PythonTurtlePandasMergeAnalysis.class.getName()); + class DataFrameState { private final String fileName; private final String sheetName; diff --git a/core/com.ibm.wala.cast.python/source/com/ibm/wala/cast/python/client/PythonTurtleSKLearnClassifierAnalysis.java b/core/com.ibm.wala.cast.python/source/com/ibm/wala/cast/python/client/PythonTurtleSKLearnClassifierAnalysis.java index 29b504be3..83eda6cef 100644 --- a/core/com.ibm.wala.cast.python/source/com/ibm/wala/cast/python/client/PythonTurtleSKLearnClassifierAnalysis.java +++ b/core/com.ibm.wala.cast.python/source/com/ibm/wala/cast/python/client/PythonTurtleSKLearnClassifierAnalysis.java @@ -45,9 +45,12 @@ import java.util.Set; import java.util.SortedSet; import java.util.TreeSet; +import java.util.logging.Logger; public class PythonTurtleSKLearnClassifierAnalysis extends PythonTurtleAnalysisEngine { + private static final Logger LOGGER = Logger.getLogger(PythonTurtleSKLearnClassifierAnalysis.class.getName()); + private enum State { FRESH, FIT @@ -147,7 +150,7 @@ public LabeledGraph performAnalysis(PropagationCallGraphBu objs.forEach( (tp) -> { - System.out.println(" " + tp.position() + " " + tp.value()); + LOGGER.info("Tensor position and value: " + tp.position() + " " + tp.value()); }); ISupergraph, CGNode> supergraph = @@ -217,7 +220,7 @@ public IntSet getTargets(int d1) { ClassifierState adapt = new ClassifierState(dest.getNode(), i + 1, flow.state); if (!domain.hasMappedIndex(adapt)) { int idx = domain.add(adapt); - System.err.println(adapt + " is " + idx); + LOGGER.fine("Added classifier state: " + adapt + " with index " + idx); } result.add(domain.getMappedIndex(adapt)); } @@ -260,7 +263,7 @@ public IntSet getTargets(int d1) { new ClassifierState(dest.getNode(), pyCall.getDef(0), flow.state); if (!domain.hasMappedIndex(adapt)) { int i = domain.add(adapt); - System.err.println(adapt + " is " + i); + LOGGER.fine("Added return classifier state: " + adapt + " with index " + i); } result.add(domain.getMappedIndex(adapt)); } @@ -568,7 +571,7 @@ Iterable trace( (n) -> { ClassifierState s = domain.getMappedObject(n); if (s.vn == vn && s.node == bbic.getNode()) { - System.err.println( + LOGGER.info( ((AstMethod) bbic.getMethod()) .debugInfo() .getInstructionPosition(inst.iIndex()) @@ -587,7 +590,7 @@ Iterable trace( fp.fst.getLastInstructionIndex())); } }); - System.err.println(trace); + LOGGER.info("Trace positions: " + trace); } }); } diff --git a/core/com.ibm.wala.cast.python/source/com/ibm/wala/cast/python/ir/PythonCAstToIRTranslator.java b/core/com.ibm.wala.cast.python/source/com/ibm/wala/cast/python/ir/PythonCAstToIRTranslator.java index 295346f0a..a7eca1ada 100644 --- a/core/com.ibm.wala.cast.python/source/com/ibm/wala/cast/python/ir/PythonCAstToIRTranslator.java +++ b/core/com.ibm.wala.cast.python/source/com/ibm/wala/cast/python/ir/PythonCAstToIRTranslator.java @@ -665,7 +665,7 @@ protected void leaveVar(CAstNode n, WalkContext c, CAstVisitor visi assert nm != null : "cannot find var for " + CAstPrinter.print(n, context.getSourceMap()); if ("0".equals(nm)) { - System.err.println("got here"); + LOGGER.fine("got here"); } if (isGlobalVar(nm)) { @@ -1202,7 +1202,7 @@ protected boolean doVisit(CAstNode n, WalkContext context, CAstVisitor> diagnostics = PythonDriver.getDiagnostics(uriTextPairs); if (diagnostics == null) { - System.err.println("There was an error generating diagnostics"); + LOGGER.severe("There was an error generating diagnostics"); return "Error"; } // return diagnostics.toString(); diff --git a/ml/com.ibm.wala.cast.python.ml/source/com/ibm/wala/cast/python/ml/types/TensorType.java b/ml/com.ibm.wala.cast.python.ml/source/com/ibm/wala/cast/python/ml/types/TensorType.java index 71be5c35f..cc011e87d 100644 --- a/ml/com.ibm.wala.cast.python.ml/source/com/ibm/wala/cast/python/ml/types/TensorType.java +++ b/ml/com.ibm.wala.cast.python.ml/source/com/ibm/wala/cast/python/ml/types/TensorType.java @@ -359,10 +359,10 @@ public static TensorType shapeArg(CGNode node, int literalVn) throws IOException ((AstMethod) node.getMethod()) .debugInfo() .getInstructionPosition(du.getDef(val).iIndex()); - System.err.println(p); + logger.fine("Position: " + p); SourceBuffer b = new SourceBuffer(p); String expr = b.toString(); - System.err.println(expr); + logger.fine("Expression: " + expr); Integer ival = PythonInterpreter.interpretAsInt(expr); if (ival != null) { r.add(new NumericDim(ival)); From 1dda8292947982cc90d419f3c9595a19325de12c Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 23 Sep 2025 20:01:08 +0000 Subject: [PATCH 3/6] Replace System.out/err.println with logging in parsers and callgraph files (part 2) Co-authored-by: khatchad <2048831+khatchad@users.noreply.github.com> --- .../client/PythonTurtlePandasMergeAnalysis.java | 16 ++++++++-------- .../PythonSSAPropagationCallGraphBuilder.java | 4 ++-- .../wala/cast/python/parser/PythonParser.java | 7 +++++-- .../wala/cast/python/parser/PythonParser.java | 4 ++-- 4 files changed, 17 insertions(+), 14 deletions(-) diff --git a/core/com.ibm.wala.cast.python/source/com/ibm/wala/cast/python/client/PythonTurtlePandasMergeAnalysis.java b/core/com.ibm.wala.cast.python/source/com/ibm/wala/cast/python/client/PythonTurtlePandasMergeAnalysis.java index b1e8dbc3f..322112685 100644 --- a/core/com.ibm.wala.cast.python/source/com/ibm/wala/cast/python/client/PythonTurtlePandasMergeAnalysis.java +++ b/core/com.ibm.wala.cast.python/source/com/ibm/wala/cast/python/client/PythonTurtlePandasMergeAnalysis.java @@ -264,7 +264,7 @@ public IntSet getTargets(int d1) { ValueState vs = domain.getMappedObject(d1); if (AccessPath.isRootedAtLocal(ref, vs.fst)) { ValueState nvs = vs.assign(colName == null ? "*" : colName); - System.err.println("found " + nvs); + LOGGER.fine("Found value state: " + nvs); if (!domain.hasMappedIndex(nvs)) { domain.add(nvs); } @@ -281,7 +281,7 @@ public IntSet getTargets(int d1) { if (!domain.hasMappedIndex(nvs)) { domain.add(nvs); } - System.err.println("found " + nvs); + LOGGER.fine("Found value state: " + nvs); return IntSetUtil.make(new int[] {d1, domain.getMappedIndex(nvs)}); } else { return IntSetUtil.make(new int[] {d1}); @@ -319,7 +319,7 @@ public IntSet getTargets(int d1) { flow.snd); if (!domain.hasMappedIndex(adapt)) { int idx = domain.add(adapt); - System.err.println(adapt + " is " + idx); + LOGGER.fine("Added adapted value state: " + adapt + " with index " + idx); } result.add(domain.getMappedIndex(adapt)); } @@ -484,16 +484,16 @@ public int compare( for (BasicBlockInContext bbic : stmts) { if (bbic.getLastInstruction() != null) { if (bbic.getMethod() != currentMethod) { - System.err.println("method " + currentMethod); + LOGGER.info("Processing method: " + currentMethod); currentMethod = bbic.getMethod(); } - System.err.println( + LOGGER.info("Instruction: " + bbic.getLastInstruction().toString(bbic.getNode().getIR().getSymbolTable())); result .getResult(bbic) .foreach( (i) -> { - System.err.println(domain.getMappedObject(i)); + LOGGER.fine("Domain mapped object: " + domain.getMappedObject(i)); }); } } @@ -501,13 +501,13 @@ public int compare( for (BasicBlockInContext bbic : stmts) { SSAInstruction inst = bbic.getLastInstruction(); if (merges.containsKey(inst)) { - System.err.println(merges.get(inst)); + LOGGER.info("Merge instruction: " + merges.get(inst)); result .getResult(bbic) .foreach( (i) -> { ValueState val = domain.getMappedObject(i); - System.err.println(val); + LOGGER.fine("Value state: " + val); }); } } diff --git a/core/com.ibm.wala.cast.python/source/com/ibm/wala/cast/python/ipa/callgraph/PythonSSAPropagationCallGraphBuilder.java b/core/com.ibm.wala.cast.python/source/com/ibm/wala/cast/python/ipa/callgraph/PythonSSAPropagationCallGraphBuilder.java index caff98332..88a898ef4 100644 --- a/core/com.ibm.wala.cast.python/source/com/ibm/wala/cast/python/ipa/callgraph/PythonSSAPropagationCallGraphBuilder.java +++ b/core/com.ibm.wala.cast.python/source/com/ibm/wala/cast/python/ipa/callgraph/PythonSSAPropagationCallGraphBuilder.java @@ -667,8 +667,8 @@ private InstanceKey toTrampolineIfNeeded(InstanceKey ik, InstanceKey container) .isSubclassOf( ik.getConcreteType(), getClassHierarchy().lookupClass(PythonTypes.LambdaMethod))) { - System.err.println(ik.getConcreteType().getName().toString()); - System.err.println(container.getConcreteType().getName().toString()); + logger.fine("Instance key concrete type: " + ik.getConcreteType().getName().toString()); + logger.fine("Container concrete type: " + container.getConcreteType().getName().toString()); TypeReference trampolineClassRef = PythonInstanceMethodTrampoline.findOrCreate( ik.getConcreteType().getReference(), getClassHierarchy()); diff --git a/jython/com.ibm.wala.cast.python.jython/source/com/ibm/wala/cast/python/parser/PythonParser.java b/jython/com.ibm.wala.cast.python.jython/source/com/ibm/wala/cast/python/parser/PythonParser.java index db1ed057f..36e44e757 100644 --- a/jython/com.ibm.wala.cast.python.jython/source/com/ibm/wala/cast/python/parser/PythonParser.java +++ b/jython/com.ibm.wala.cast.python.jython/source/com/ibm/wala/cast/python/parser/PythonParser.java @@ -55,6 +55,7 @@ import java.util.LinkedList; import java.util.Map; import java.util.function.Supplier; +import java.util.logging.Logger; import org.python.antlr.PythonTree; import org.python.antlr.ast.Assert; import org.python.antlr.ast.Assign; @@ -125,6 +126,8 @@ public abstract class PythonParser extends AbstractParser implements TranslatorToCAst { + private static final Logger LOGGER = Logger.getLogger(PythonParser.class.getName()); + private static boolean COMPREHENSION_IR = true; private CAstType codeBody = @@ -508,7 +511,7 @@ public CAstNode visitClassDef(ClassDef arg0) throws Exception { public Collection getSupertypes() { Collection supertypes = HashSetFactory.make(); for (expr e : arg0.getInternalBases()) { - System.out.println( + LOGGER.fine("Class inheritance: " + arg0.getInternalName() + " " + arg0.getType() @@ -1966,7 +1969,7 @@ public String getMsg() { } public void print(PyObject ast) { - System.err.println(ast.getClass()); + LOGGER.fine("AST class: " + ast.getClass()); } /** diff --git a/jython/com.ibm.wala.cast.python.jython3/source/com/ibm/wala/cast/python/parser/PythonParser.java b/jython/com.ibm.wala.cast.python.jython3/source/com/ibm/wala/cast/python/parser/PythonParser.java index f6719d048..622196f64 100644 --- a/jython/com.ibm.wala.cast.python.jython3/source/com/ibm/wala/cast/python/parser/PythonParser.java +++ b/jython/com.ibm.wala.cast.python.jython3/source/com/ibm/wala/cast/python/parser/PythonParser.java @@ -2058,7 +2058,7 @@ public CAstNode visitTryExcept(TryExcept arg0) throws Exception { CAstVisitor child = new CAstVisitor(catches, parser); CAstNode block = child.block(arg0.getInternalBody()); - System.err.println("catches: " + handlers); + LOGGER.fine("Exception handlers: " + handlers); return Ast.makeNode( CAstNode.TRY, @@ -2496,7 +2496,7 @@ public String getMsg() { } public void print(PyObject ast) { - System.err.println(ast.getClass()); + LOGGER.fine("AST class: " + ast.getClass()); } /** From eb6eb4e8c4e7577079d3c8fd59b239f740b8ccf7 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 23 Sep 2025 20:06:18 +0000 Subject: [PATCH 4/6] Replace System.out/err.println with logging in loaders and analysis engines (part 3) Co-authored-by: khatchad <2048831+khatchad@users.noreply.github.com> --- .../client/PythonTurtlePandasMergeAnalysis.java | 8 +++++--- .../PythonTurtleSKLearnClassifierAnalysis.java | 6 ++++-- .../ibm/wala/cast/python/loader/Python2Loader.java | 14 +++++++++++++- .../ibm/wala/cast/python/parser/PythonParser.java | 5 +++-- .../cast/python/client/PytestAnalysisEngine.java | 11 +++++++---- .../ibm/wala/cast/python/loader/PytestLoader.java | 5 ++++- 6 files changed, 36 insertions(+), 13 deletions(-) diff --git a/core/com.ibm.wala.cast.python/source/com/ibm/wala/cast/python/client/PythonTurtlePandasMergeAnalysis.java b/core/com.ibm.wala.cast.python/source/com/ibm/wala/cast/python/client/PythonTurtlePandasMergeAnalysis.java index 322112685..1a1cb6139 100644 --- a/core/com.ibm.wala.cast.python/source/com/ibm/wala/cast/python/client/PythonTurtlePandasMergeAnalysis.java +++ b/core/com.ibm.wala.cast.python/source/com/ibm/wala/cast/python/client/PythonTurtlePandasMergeAnalysis.java @@ -59,7 +59,8 @@ public class PythonTurtlePandasMergeAnalysis extends PythonTurtleAnalysisEngine { - private static final Logger LOGGER = Logger.getLogger(PythonTurtlePandasMergeAnalysis.class.getName()); + private static final Logger LOGGER = + Logger.getLogger(PythonTurtlePandasMergeAnalysis.class.getName()); class DataFrameState { private final String fileName; @@ -487,8 +488,9 @@ public int compare( LOGGER.info("Processing method: " + currentMethod); currentMethod = bbic.getMethod(); } - LOGGER.info("Instruction: " + - bbic.getLastInstruction().toString(bbic.getNode().getIR().getSymbolTable())); + LOGGER.info( + "Instruction: " + + bbic.getLastInstruction().toString(bbic.getNode().getIR().getSymbolTable())); result .getResult(bbic) .foreach( diff --git a/core/com.ibm.wala.cast.python/source/com/ibm/wala/cast/python/client/PythonTurtleSKLearnClassifierAnalysis.java b/core/com.ibm.wala.cast.python/source/com/ibm/wala/cast/python/client/PythonTurtleSKLearnClassifierAnalysis.java index 83eda6cef..fc1390bb5 100644 --- a/core/com.ibm.wala.cast.python/source/com/ibm/wala/cast/python/client/PythonTurtleSKLearnClassifierAnalysis.java +++ b/core/com.ibm.wala.cast.python/source/com/ibm/wala/cast/python/client/PythonTurtleSKLearnClassifierAnalysis.java @@ -49,7 +49,8 @@ public class PythonTurtleSKLearnClassifierAnalysis extends PythonTurtleAnalysisEngine { - private static final Logger LOGGER = Logger.getLogger(PythonTurtleSKLearnClassifierAnalysis.class.getName()); + private static final Logger LOGGER = + Logger.getLogger(PythonTurtleSKLearnClassifierAnalysis.class.getName()); private enum State { FRESH, @@ -263,7 +264,8 @@ public IntSet getTargets(int d1) { new ClassifierState(dest.getNode(), pyCall.getDef(0), flow.state); if (!domain.hasMappedIndex(adapt)) { int i = domain.add(adapt); - LOGGER.fine("Added return classifier state: " + adapt + " with index " + i); + LOGGER.fine( + "Added return classifier state: " + adapt + " with index " + i); } result.add(domain.getMappedIndex(adapt)); } diff --git a/jython/com.ibm.wala.cast.python.jython/source/com/ibm/wala/cast/python/loader/Python2Loader.java b/jython/com.ibm.wala.cast.python.jython/source/com/ibm/wala/cast/python/loader/Python2Loader.java index 324fb4463..3aba617f2 100644 --- a/jython/com.ibm.wala.cast.python.jython/source/com/ibm/wala/cast/python/loader/Python2Loader.java +++ b/jython/com.ibm.wala.cast.python.jython/source/com/ibm/wala/cast/python/loader/Python2Loader.java @@ -32,9 +32,13 @@ import java.io.IOException; import java.util.Collections; import java.util.List; +import java.util.logging.Logger; import org.python.core.PyObject; public class Python2Loader extends PythonLoader { + + private static final Logger LOGGER = Logger.getLogger(Python2Loader.class.getName()); + public Python2Loader(IClassHierarchy cha, IClassLoader parent) { super(cha, parent, Collections.emptyList()); } @@ -97,7 +101,15 @@ protected Object eval(CAstOperator op, Object lhs, Object rhs) { PyObject x = Python2Interpreter.getInterp().eval(lhs + " " + op.getValue() + " " + rhs); if (x.isNumberType()) { - System.err.println(lhs + " " + op.getValue() + " " + rhs + " -> " + x.asInt()); + LOGGER.fine( + "Expression evaluation: " + + lhs + + " " + + op.getValue() + + " " + + rhs + + " -> " + + x.asInt()); return x.asInt(); } } catch (Exception e) { diff --git a/jython/com.ibm.wala.cast.python.jython/source/com/ibm/wala/cast/python/parser/PythonParser.java b/jython/com.ibm.wala.cast.python.jython/source/com/ibm/wala/cast/python/parser/PythonParser.java index 36e44e757..177b5fecb 100644 --- a/jython/com.ibm.wala.cast.python.jython/source/com/ibm/wala/cast/python/parser/PythonParser.java +++ b/jython/com.ibm.wala.cast.python.jython/source/com/ibm/wala/cast/python/parser/PythonParser.java @@ -511,8 +511,9 @@ public CAstNode visitClassDef(ClassDef arg0) throws Exception { public Collection getSupertypes() { Collection supertypes = HashSetFactory.make(); for (expr e : arg0.getInternalBases()) { - LOGGER.fine("Class inheritance: " + - arg0.getInternalName() + LOGGER.fine( + "Class inheritance: " + + arg0.getInternalName() + " " + arg0.getType() + " extends " diff --git a/jython/com.ibm.wala.cast.python.jython3/source/com/ibm/wala/cast/python/client/PytestAnalysisEngine.java b/jython/com.ibm.wala.cast.python.jython3/source/com/ibm/wala/cast/python/client/PytestAnalysisEngine.java index 932aa60da..5e1b47f99 100644 --- a/jython/com.ibm.wala.cast.python.jython3/source/com/ibm/wala/cast/python/client/PytestAnalysisEngine.java +++ b/jython/com.ibm.wala.cast.python.jython3/source/com/ibm/wala/cast/python/client/PytestAnalysisEngine.java @@ -22,9 +22,12 @@ import com.ibm.wala.util.intset.OrdinalSet; import java.io.File; import java.util.List; +import java.util.logging.Logger; public class PytestAnalysisEngine extends PythonAnalysisEngine { + private static final Logger LOGGER = Logger.getLogger(PytestAnalysisEngine.class.getName()); + private class PytestTargetSelector implements MethodTargetSelector { private final MethodTargetSelector base; @@ -35,7 +38,7 @@ private PytestTargetSelector(MethodTargetSelector base) { @Override public IMethod getCalleeTarget(CGNode caller, CallSiteReference site, IClass receiver) { if (site.getDeclaredTarget().getDeclaringClass().equals(PytestLoader.pytestType)) { - System.err.println("pytest call site " + site + " " + receiver); + LOGGER.fine("Pytest call site: " + site + " " + receiver); PointerKeyFactory pkf = builder.getPointerKeyFactory(); for (SSAAbstractInvokeInstruction inst : caller.getIR().getCalls(site)) { PointerKey test = pkf.getPointerKeyForLocal(caller, inst.getUse(0)); @@ -56,7 +59,7 @@ public IMethod getCalleeTarget(CGNode caller, CallSiteReference site, IClass rec PointerKey names = pkf.getPointerKeyForInstanceField(p, ns); OrdinalSet namesObjs = builder.getPointerAnalysis().getPointsToSet(names); - System.err.println("names: " + namesObjs); + LOGGER.fine("Parameter names: " + namesObjs); IField vs = p.getConcreteType() @@ -64,11 +67,11 @@ public IMethod getCalleeTarget(CGNode caller, CallSiteReference site, IClass rec PointerKey values = pkf.getPointerKeyForInstanceField(p, vs); OrdinalSet valsObjs = builder.getPointerAnalysis().getPointsToSet(values); - System.err.println("values: " + valsObjs); + LOGGER.fine("Parameter values: " + valsObjs); }); } }); - System.err.println(test + " " + testObjs); + LOGGER.fine("Test pointer key and objects: " + test + " " + testObjs); } } return base.getCalleeTarget(caller, site, receiver); diff --git a/jython/com.ibm.wala.cast.python.jython3/source/com/ibm/wala/cast/python/loader/PytestLoader.java b/jython/com.ibm.wala.cast.python.jython3/source/com/ibm/wala/cast/python/loader/PytestLoader.java index f2f6bc8f9..e0cbc9ff6 100644 --- a/jython/com.ibm.wala.cast.python.jython3/source/com/ibm/wala/cast/python/loader/PytestLoader.java +++ b/jython/com.ibm.wala.cast.python.jython3/source/com/ibm/wala/cast/python/loader/PytestLoader.java @@ -27,9 +27,12 @@ import java.util.Map; import java.util.Map.Entry; import java.util.Set; +import java.util.logging.Logger; public class PytestLoader extends Python3Loader { + private static final Logger LOGGER = Logger.getLogger(PytestLoader.class.getName()); + public static final TypeReference pytestType = TypeReference.findOrCreate(PythonTypes.pythonLoader, "LPytest"); @@ -148,6 +151,6 @@ private void handlePytest(WalkContext context, CAstEntity fn, int function) { @Override protected void finishTranslation() { super.finishTranslation(); - System.err.println("xxsymbol " + testParams); + LOGGER.fine("Test parameters: " + testParams); } } From 43d6a02749b88dcceeb8c58a59ed2b509d1e7190 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 23 Sep 2025 20:09:54 +0000 Subject: [PATCH 5/6] Replace System.out/err.println with logging in remaining analysis files (part 4) Co-authored-by: khatchad <2048831+khatchad@users.noreply.github.com> --- .../com/ibm/wala/cast/python/parquet/ParquetPythonReader.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/jep/com.ibm.wala.cast.python.cpython/source/com/ibm/wala/cast/python/parquet/ParquetPythonReader.java b/jep/com.ibm.wala.cast.python.cpython/source/com/ibm/wala/cast/python/parquet/ParquetPythonReader.java index 2151d78ec..973c0ff17 100644 --- a/jep/com.ibm.wala.cast.python.cpython/source/com/ibm/wala/cast/python/parquet/ParquetPythonReader.java +++ b/jep/com.ibm.wala.cast.python.cpython/source/com/ibm/wala/cast/python/parquet/ParquetPythonReader.java @@ -240,6 +240,6 @@ public static void main(String... args) throws IOException, ClassHierarchyExcept code.add((SourceModule) f); }); IClassHierarchy cha = CPythonAstToCAstTranslator.load(code); - System.err.println(cha); + LOGGER.info("Class hierarchy: " + cha); } } From c3197c65a0f8e1f50764abb70991448488dfb4b6 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 23 Sep 2025 20:19:47 +0000 Subject: [PATCH 6/6] Refactor test files to use logging instead of System.out/err.println Co-authored-by: khatchad <2048831+khatchad@users.noreply.github.com> --- .../source/com/ibm/wala/cast/python/test/TestCalls.java | 4 ++-- .../source/com/ibm/wala/cast/python/test/TestClasses.java | 5 ++++- .../source/com/ibm/wala/cast/python/test/TestSource.java | 5 ++++- .../wala/cast/python/ml/test/TestPythonMLCallGraphShape.java | 5 ++++- 4 files changed, 14 insertions(+), 5 deletions(-) diff --git a/core/com.ibm.wala.cast.python.test/source/com/ibm/wala/cast/python/test/TestCalls.java b/core/com.ibm.wala.cast.python.test/source/com/ibm/wala/cast/python/test/TestCalls.java index b6606d64b..df0f16863 100644 --- a/core/com.ibm.wala.cast.python.test/source/com/ibm/wala/cast/python/test/TestCalls.java +++ b/core/com.ibm.wala.cast.python.test/source/com/ibm/wala/cast/python/test/TestCalls.java @@ -170,10 +170,10 @@ public Void performAnalysis(PropagationCallGraphBuilder builder) throws CancelEx public void testCalls8() throws ClassHierarchyException, IllegalArgumentException, CancelException, IOException { CallGraph CG = process("calls8.py"); - System.err.println(CG); + LOGGER.info("Call graph for calls8.py: " + CG); CG.forEach( (n) -> { - System.err.println(n.getIR()); + LOGGER.fine("Node IR: " + n.getIR()); }); // verifyGraphAssertions(CG, assertionsCalls6); } diff --git a/core/com.ibm.wala.cast.python.test/source/com/ibm/wala/cast/python/test/TestClasses.java b/core/com.ibm.wala.cast.python.test/source/com/ibm/wala/cast/python/test/TestClasses.java index 228c5b560..1e5cf5398 100644 --- a/core/com.ibm.wala.cast.python.test/source/com/ibm/wala/cast/python/test/TestClasses.java +++ b/core/com.ibm.wala.cast.python.test/source/com/ibm/wala/cast/python/test/TestClasses.java @@ -6,10 +6,13 @@ import com.ibm.wala.ipa.cha.ClassHierarchyException; import com.ibm.wala.util.CancelException; import java.io.IOException; +import java.util.logging.Logger; import org.junit.Test; public class TestClasses extends TestJythonCallGraphShape { + private static final Logger LOGGER = Logger.getLogger(TestClasses.class.getName()); + protected static final Object[][] assertionsClasses1 = new Object[][] { new Object[] {ROOT, new String[] {"script classes1.py"}}, @@ -114,7 +117,7 @@ public void testClasses3() SSAPropagationCallGraphBuilder builder = (SSAPropagationCallGraphBuilder) engine.defaultCallGraphBuilder(); CallGraph CG = builder.makeCallGraph(builder.getOptions()); - System.err.println(CG); + LOGGER.info("Call graph for classes3.py: " + CG); verifyGraphAssertions(CG, assertionsClasses3); } } diff --git a/core/com.ibm.wala.cast.python.test/source/com/ibm/wala/cast/python/test/TestSource.java b/core/com.ibm.wala.cast.python.test/source/com/ibm/wala/cast/python/test/TestSource.java index 9a5f62ea5..dce524279 100644 --- a/core/com.ibm.wala.cast.python.test/source/com/ibm/wala/cast/python/test/TestSource.java +++ b/core/com.ibm.wala.cast.python.test/source/com/ibm/wala/cast/python/test/TestSource.java @@ -4,17 +4,20 @@ import com.ibm.wala.ipa.cha.ClassHierarchyException; import com.ibm.wala.util.CancelException; import java.io.IOException; +import java.util.logging.Logger; import org.junit.Test; public class TestSource extends TestJythonCallGraphShape { + private static final Logger LOGGER = Logger.getLogger(TestSource.class.getName()); + @Test public void testSource1() throws ClassHierarchyException, IllegalArgumentException, CancelException, IOException { CallGraph CG = process("src1.py"); CG.forEach( (n) -> { - System.err.println(n.getIR()); + LOGGER.fine("Node IR: " + n.getIR()); }); // verifyGraphAssertions(CG, assertionsCalls1); } diff --git a/ml/com.ibm.wala.cast.python.ml.test/source/com/ibm/wala/cast/python/ml/test/TestPythonMLCallGraphShape.java b/ml/com.ibm.wala.cast.python.ml.test/source/com/ibm/wala/cast/python/ml/test/TestPythonMLCallGraphShape.java index c7a458f7d..0e7fea8d1 100644 --- a/ml/com.ibm.wala.cast.python.ml.test/source/com/ibm/wala/cast/python/ml/test/TestPythonMLCallGraphShape.java +++ b/ml/com.ibm.wala.cast.python.ml.test/source/com/ibm/wala/cast/python/ml/test/TestPythonMLCallGraphShape.java @@ -35,9 +35,12 @@ import java.util.Iterator; import java.util.List; import java.util.Set; +import java.util.logging.Logger; public abstract class TestPythonMLCallGraphShape extends TestJythonCallGraphShape { + private static final Logger LOGGER = Logger.getLogger(TestPythonMLCallGraphShape.class.getName()); + @FunctionalInterface protected interface CheckTensorOps { void check(PropagationCallGraphBuilder cgBuilder, CallGraph CG, TensorTypeAnalysis result); @@ -116,7 +119,7 @@ protected void checkTensorOps(String url, CheckTensorOps check) (PropagationCallGraphBuilder) e.defaultCallGraphBuilder(); CallGraph CG = cgBuilder.makeCallGraph(cgBuilder.getOptions()); TensorTypeAnalysis result = e.performAnalysis(cgBuilder); - System.err.println(result); + LOGGER.info("Tensor analysis result: " + result); check.check(cgBuilder, CG, result); }