Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Eclipse skipping lines while debugging

I am new to both java and eclipse, I have been trying to debug an android app on a device. It is a small project with a jar file reference. I read similar questions but they didn't help.

What I need is to be able to debug the source codes of the jar file so I attached the source codes ( which I obtained using a decompiler ) and I am able to go into source codes of the library so I thought I did that correctly. But I can not succeed in debugging into these source codes; in debug mode it skipps breakpoints (only the ones in the source files which are attached to jar file) and when I try to 'step into code' it goes to random lines skips lines when debugging.

I am using the latest versions of eclipse, android sdk and jdk. I don't know what causes this problem and I'd like to know.

Thanks in advance, I hope I explained sufficiently.

like image 946
Naz Ekin Avatar asked Feb 12 '14 14:02

Naz Ekin


People also ask

Can statements be skipped using new debugger?

In debugger just click on the second WRITE statement and use the menu path Debugging –> Goto Statement as shown below, so that the “LEAVE PROGRAM” statement will be skipped by the debugger. SHIFT + F12 is the shortcut for Goto Statement in ABAP new debugger.


1 Answers

The problem is, that you can't decompile the class files to debug it. Because the lines of the decompiled files will differ to the original Java source code lines (imagine: the real source code has some comments and other things which will not be compiled into class files)!

So, if your Eclipse shows you the current debug line 42, then it only tells you, that the debugger will present you the 42th line of code in the class file. This won't match your decompiled java source file.

However, you could decompile the class files with the option add line numbers as comments. These line numbers in comments you can compare to the actual stacktrace line numbers. This could help you a little bit to imagine the issue.

edit: as Laurent B recommended, you will be able to realign the code with JD-Eclipse, see: http://mchr3k.github.io/jdeclipse-realign/

+1 for the comment! :)

edit2: You won't be able to decompile with line numbers if the class files are compiled with the flag -g:none:

-g:none
Do not generate any debugging information.

So if this is the case: try to find the original source code of your jar file!

like image 186
bobbel Avatar answered Sep 21 '22 12:09

bobbel