timtadh / jpdg

generate program dependence graphs for java programs.
Other
25 stars 11 forks source link

JPDG.java Line 213 PDG_Builder undefined #2

Closed qiujing closed 7 years ago

qiujing commented 7 years ago

Hi, could you provide the definition of "PDG_Builder.build(cg, lm, classes, excluded)" in JPDG.java line 213. I have extracted the pre-built jar, and did not find the class "PDG_Builder".

qiujing commented 7 years ago

Done by Java Decompiler :(

package edu.cwru.jpdg;

import edu.cwru.jpdg.graph.Graph; import edu.cwru.jpdg.label.LabelMaker; import java.io.PrintStream; import java.util.List; import soot.Body; import soot.SootClass; import soot.SootMethod; import soot.toolkits.graph.BlockGraph; import soot.toolkits.graph.UnitBlockGraph; import soot.util.Chain;

public class PDG_Builder { LabelMaker lm; Graph g = new Graph(); Chain classes; List excluded;

public static Graph build(LabelMaker lm, Chain classes, List excluded) throws pDG_Builder.Error { PDG_Builder self = new PDG_Builder(lm, classes, excluded); self.build_PDG(); return self.g; }

private PDG_Builder(LabelMaker lm, Chain classes, List excluded) { this.lm = lm; this.classes = classes; this.excluded = excluded; }

void build_PDG() throws pDG_Builder.Error { System.out.println(this.classes); for (SootClass c : this.classes) { String pkg_name = c.getPackageName(); String cls_name = c.getName(); boolean use = true; for (String exclude : this.excluded) { if ((exclude.startsWith("")) && (exclude.endsWith(""))) { exclude = exclude.substring(1, exclude.length() - 1); if ((pkg_name.contains(exclude)) || (cls_name.contains(exclude))) { use = false; break; } } else if (exclude.startsWith("*")) { exclude = exclude.substring(1); if ((pkg_name.endsWith(exclude)) || (cls_name.contains(exclude))) { use = false; break; } } else if (pkg_name.startsWith(exclude)) { use = false; break; } } if (use) { try { process_class(c); } catch (Exception e) { System.err.println(e); } } } }

void process_class(SootClass c) throws pDG_Builder.Error { System.out.println(c); for (SootMethod m : c.getMethods()) { System.out.println(String.format(" %s", new Object[] { m })); Body body = null; try { body = m.retrieveActiveBody(); } catch (RuntimeException e) { System.err.println(e); } continue;

  BlockGraph ebg = new UnitBlockGraph(body);
  try
  {
    pDG_Builder.build(this.lm, this.g, c, m, body, ebg);
  }
  catch (pDG_Builder.SootError e)
  {
    System.err.println(String.format("soot error for method %s\n%s", new Object[] { m, e }));
  }
}

} }

timtadh commented 7 years ago

@qiujing did you figure it out? I just started a new job. Sorry I was not responsive to your question.

qiujing commented 7 years ago

Hi, that is because I check out the source code in Windows (file name are case-sensitive) and pDG_Builder'' andPDG_Builder'' are regarded as one file by OS.

timtadh commented 7 years ago

Oops! Sorry about that. I recommend building on ubuntu 14.04 for best results at the moment.

Cheers, Tim Henderson Sent from my phone

On Aug 4, 2017 6:22 PM, "qiujing" notifications@github.com wrote:

Hi, that is because I check out the source code in Windows (file name are case-sensitive) and pDG_Builder'' andPDG_Builder'' are regarded as one file by OS.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/timtadh/jpdg/issues/2#issuecomment-320373368, or mute the thread https://github.com/notifications/unsubscribe-auth/AACW3IRJKotLL8nfyzhbxAUMaXxFDYQOks5sU6eegaJpZM4Opu6p .