[Soot-list] Parse source code problem
Alexandre Bartel
alexandre.bartel at cased.de
Fri Aug 28 06:49:42 EDT 2015
Are you using the latest version of Soot?
You can get it from:
https://ssebuild.cased.de/nightly/soot/
If you are, please send the complete stack trace and a minimal working
example to reproduce your problem including input files.
Cheers,
Alexandre
On Fri, 2015-08-28 at 18:29 +0800, csytang wrote:
> Hi Alexandre,
> Thanks for your reply
> My command:
> "-src-prec java -cp "all depended classes" -process-dir
> /Users/tangchris/Documents/workspace/WordCount2.0/src/ -f none"
> I don't know why it always got ArrayOutofBounds problem in
> BytecodeParser.
>
> I use following to get the source location
>
> private void getDebugTags(Host h) {
> for (Tag tag : (Collection<Tag>) h.getTags()) {
> if (tag instanceof LineNumberTag) {
> byte[] value = tag.getValue();
> //TODO: this assumes LOC < 65k
> lineNumber = ((value[0] & 0xff) << 8) | (value[1] &
> 0xff);
> } else if (tag instanceof SourceLnPosTag) {
> //TODO: also keep track of endLn() ?
> lineNumber = ((SourceLnPosTag) tag).startLn();
> startPos = ((SourceLnPosTag) tag).startPos();
> endlineNumber = ((SourceLnPosTag) tag).endLn();
> endPos = ((SourceLnPosTag) tag).endPos();
> } else if (tag instanceof SourceLineNumberTag) {
> lineNumber = ((SourceLineNumberTag)
> tag).getLineNumber();
> }
> }
> }
>
> It is invoked by getDebugTags(u); u is a Unit instance
>
> Thanks for your time and patient
> Chris.
> Soot started on Fri Aug 28 18:23:17 HKT 2015
> 在 2015-08-28 17:54,Alexandre Bartel 写道:
> > Hi Chris,
> >
> > Retrieving the line number should work. Could you share your code?
> >
> > A minimal example should look like this:
> >
> > public static void main(String[] args) {
> > PackManager.v().getPack("jtp").add(new
> > Transform("jtp.myBodyTransformer", new BodyTransformer() {
> > protected void internalTransform(Body body, String
> > phase, Map options) {
> > for (Unit u : body.getUnits()) {
> > System.out.println("unit u: " + u);
> > SourceLnPosTag slnpt = (SourceLnPosTag)
> > u.getTag("SourceLnPosTag");
> > if (slnpt != null) {
> > System.out.println(" @ line: " +
> > slnpt.startLn());
> > }
> > }
> > }
> > }));
> >
> > soot.Main.main(args);
> > }
> >
> > Cheers,
> > Alexandre
> >
> > On Fri, 2015-08-28 at 17:26 +0800, csytang wrote:
> > > Thanks Alexandre,
> > > I think it runs well with source, but I wonder that I still
> > > cannot
> > > obtain the SourceLnPosTag from Host instance(like, unit), is
> > > there
> > > any additional settings for my purpose? Thanks so much.
> > > Best
> > > Chris.
> > > 在 2015-08-28 16:30,Alexandre Bartel 写道:
> > > > Hi Chris,
> > > >
> > > > You should use the following option to analyze your Java files
> > > > in
> > > > the
> > > > /WordCount2.0/src/ directory:
> > > >
> > > > -process-dir /WordCount2.0/src/
> > > >
> > > > Cheers,
> > > > Alexandre
> > > >
> > > > On Fri, 2015-08-28 at 15:30 +0800, csytang wrote:
> > > > > Hi all,
> > > > > I wanna use soot to parse my java source code
> > > > > with command
> > > > > -src-prec java /WordCount2.0/src/WordCount2.java -cp
> > > > > 'all
> > > > > depended class' -f none
> > > > > I got Attempt to create RefType containing a / -->
> > > > > /WordCount2.0/src/WordCount2.java
> > > > > So any suggestions for this error?
> > > > > Thanks
> > > > > Chris
> > > > > _______________________________________________
> > > > > Soot-list mailing list
More information about the Soot-list
mailing list