[Soot-list] Unable to fetch line numbers for units from a .dex file

Linghui Luo linghui.luo at uni-paderborn.de
Sun Sep 3 07:10:24 EDT 2017


Hi Samit,

You can use BytecodeViewer  https://github.com/Konloch/bytecode-viewer
to open .dex file and save the classes into a .zip file.

Best regards,
Linghui
Von: Samit Anwer [mailto:samit1274 at iiitd.ac.in]
Gesendet: Sonntag, 3. September 2017 12:32
An: Linghui Luo <linghui.luo at uni-paderborn.de>
Cc: soot-list at sable.mcgill.ca
Betreff: Re: [Soot-list] Unable to fetch line numbers for units from a .dex file

Thanks Linghui for your response.

I have the keep-line-number option turned on.

I checked the class files generated for the original Android application in the bin folder, they do contain the LineNumberTable attribute. I am using dex as the output format for Soot. The next thing to check is whether the line numbers are preserved in the classes.dex file, is there a way to verify this?

On Sun, Sep 3, 2017 at 2:07 PM, Linghui Luo <linghui.luo at uni-paderborn.de<mailto:linghui.luo at uni-paderborn.de>> wrote:
Hello Samit,

I have tried your code to my test classes and I didn’t get just “has no Line Number”. Your code is totally fine.
If you have turned on the soot option “-keep-line-number”, I think there maybe one reason:
The java bytecodes didn’t included the line numbers. You should check your java complier options.
Line number is debug information and you can look your .class file if it contains LineNumberTable.

Best regards,
Linghui Luo

Von: Soot-list [mailto:soot-list-bounces at CS.McGill.CA<mailto:soot-list-bounces at CS.McGill.CA>] Im Auftrag von Samit Anwer
Gesendet: Freitag, 25. August 2017 16:14
An: soot-list at sable.mcgill.ca<mailto:soot-list at sable.mcgill.ca>
Betreff: [Soot-list] Unable to fetch line numbers for units from a .dex file

Hi

I am trying to retrieve line number for a unit  referred by variable "u".

Here is my code:

 if (u.hasTag("SourceLineNumberTag")) {
                                                            SourceLineNumberTag l = (SourceLineNumberTag) u.getTag("SourceLineNumberTag");
                                                            System.out.println("Line No. is: "+l.getLineNumber());
                                                            }

                                                            else if (u.hasTag("LineNumberTag")) { // see if a LineNumberTag exists (it will if you use -keep-line-number)
                                                                 LineNumberTag tag = (LineNumberTag)u.getTag(("LineNumberTag"));
                                                                 System.out.println(u + " has Line Number: " + tag.getLineNumber()); // print out the unit and line number
                                                               }
                                                            else if (u.hasTag("SourceLnPosTag")){

                                                                         System.out.println(u + " has Line Number: " + ((SourceLnPosTag) u.getTag("SourceLnPosTag")).startLn());
                                                             }
                                                             else {
                                                                 System.out.println(u + " has no Line Number");
                                                               }

For some reason, I am always getting "has no Line Number". I am using the nightly build soot-trunk.jar from https://soot-build.cs.uni-paderborn.de/nightly/soot/.

Could somebody please help out?

--
Regards,
Samit Anwer
MT12074
MTech-MUC
IIIT Delhi
http://about.me/samitanwer



--
Regards,
Samit Anwer
MT12074
MTech-MUC
IIIT Delhi
http://about.me/samitanwer
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mailman.CS.McGill.CA/pipermail/soot-list/attachments/20170903/6211b01a/attachment-0001.html>


More information about the Soot-list mailing list