Community
Participate
Working Groups
R3.0 I had a breakpoint in a finally block and the debugger never stopped. I then added a println and well: it this got printed out as expected. I then added a breakpoint before the finally block and stepped through and it stepped through the finally block. The reason for this is most likely the following enabled compiler option: [] Inline finally blocks Marking as major since I lost time due to wrong results.
Do you have a source code example? I am able to hit breakpoints in finally blocks when I have this option tunred on.
sure: ProjectionViewer rev. 1.50 line 1486
I had all class file generation options enabled.
OK, and how do I trigger the breakpoint from the UI (I'm not familiar with this class :-)
Sorry ;-) Enable folding in the Java editor and cut or copy some text.
As reported, the breakpoint on line 1486 of ProjectionViewer is not hit when the option to "inline finally blocks" is on. However, the debugger claims to install the breakpoint, as it is provided with a valid location for the executable line. When using "javap" to look at the debug attributes in the classfile, the line table for the method "copyToClipboard(...)" is strangely missing. Via JDI we are getting line number attributes, but the javap tool does not show any. Moving to JCORE for comment.
Olivier - pls investigate. Is the finally block inlining somehow corrupting our line number attribute ?
I will investigate.
Created attachment 13680 [details] Test case
Here is the test case I tried. I made some changes in the try statement code generation and now I get the following line number attribute table: 0 getstatic #21 <Field java/lang/System.out Ljava/io/PrintStream;> 3 ldc #23 <String "Hello World!"> 5 invokevirtual #29 <Method java/io/PrintStream.println(Ljava/lang/String;)V> 8 new #31 java/io/File 11 dup 12 ldc #33 <String "c:/tests_sources/X.java"> 14 invokespecial #35 <Method java/io/File.<init>(Ljava/lang/String;)V> 17 astore_1 18 aload_1 19 invokevirtual #39 <Method java/io/File.exists()Z> 22 ifeq 74 25 new #41 java/io/FileWriter 28 dup 29 aload_1 30 iconst_1 31 invokespecial #44 <Method java/io/FileWriter.<init>(Ljava/io/File;Z)V> 34 astore_2 35 aload_2 36 ldc #46 <String "line.separator"> 38 invokestatic #50 <Method java/lang/System.getProperty(Ljava/lang/String;)Ljava/lang/String;> 41 invokevirtual #53 <Method java/io/FileWriter.write(Ljava/lang/String;)V> 44 aload_2 45 invokevirtual #56 <Method java/io/FileWriter.flush()V> 48 aload_2 49 invokevirtual #59 <Method java/io/FileWriter.close()V> 52 goto 74 55 astore_1 56 aload_1 57 invokevirtual #64 <Method java/io/IOException.printStackTrace()V> 60 goto 74 63 astore_3 64 getstatic #21 <Field java/lang/System.out Ljava/io/PrintStream;> 67 ldc #66 <String "DONE"> 69 invokevirtual #29 <Method java/io/PrintStream.println(Ljava/lang/String;)V> 72 aload_3 73 athrow 74 getstatic #21 <Field java/lang/System.out Ljava/io/PrintStream;> 77 ldc #66 <String "DONE"> 79 invokevirtual #29 <Method java/io/PrintStream.println(Ljava/lang/String;)V> 82 return Exception Table: [pc: 0, pc: 55] -> 55 when : java.io.IOException [pc: 0, pc: 63] -> 63 when : any Line numbers: [pc: 0, line: 8] [pc: 8, line: 9] [pc: 18, line: 10] [pc: 25, line: 11] [pc: 35, line: 12] [pc: 44, line: 13] [pc: 48, line: 14] [pc: 55, line: 16] [pc: 56, line: 17] [pc: 64, line: 19] [pc: 72, line: 20] [pc: 74, line: 19] [pc: 82, line: 21] Local variable table: [pc: 0, pc: 83] local: args index: 0 type: [Ljava/lang/String; [pc: 18, pc: 55] local: f index: 1 type: Ljava/io/File; [pc: 35, pc: 55] local: writer index: 2 type: Ljava/io/FileWriter; [pc: 56, pc: 60] local: e index: 1 type: Ljava/io/IOException; But still when I try to debug I cannot break inside the finally block (line 19). I don't see why after executing line 14 (pc 48-54 included), it doesn't stop on line 19. I will attach the patch for this. Move to JDT/Debug for comment.
Created attachment 13681 [details] Apply on HEAD Once it is applied patch your eclipse install by running the exportplugin build script and replacing your org.eclipse.jdt.core plugin in the eclipse install (version 3.1). Use the latest integration build for that. Even if it doesn't break on line 19, if I step over I reach line 19. So something is definitely weird.
How do you check the line where the breakpoint should be located? When the finally block is inlined, the same code is generated twice so could it be possible that the breakpoint is not located on the right line?
This appears to work in 3.1 M1. We have changed nothing - perhaps a compiler fix has made this work.
Not fixed. 1. enable [x] Inline finally blocks 2. checkout org.eclipse.jface.text 3. open ProjectionViewer rev.150 4. add breakpoint in line 1486 5. start to debug using: java version "1.4.2_03" Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_03-b02) Java HotSpot(TM) Client VM (build 1.4.2_03-b02, mixed mode) 6. open a Java file in the Java editor (ensure folding is enabled) 7. select all + copy
We only set the breakpoint in one location, even though there are two.
I modified the code to install at all locations for a line, but I still do not hit the breakpoint. The (2) installed locations are as follows: Code Index: 76 lineNumber: 1486 Code Index: 106 lineNumber: 1486
Created attachment 14101 [details] patch Suggested fix to jdt-debug
I applied the patch that Olivier sent me by e-mail to I200408170800 and also imported the jdt-debug plug-in into may workspace. It does not work here. I start my workspace and my debug target with 1.4.2_03. Here's the console output: Code Index: 78 lineNumber: 1486 Code Index: 106 lineNumber: 1486 Using j9 to launch the debug target gives: Code Index: 76 lineNumber: 1486 Code Index: 106 lineNumber: 1486 Olivier: did you check "Inline finally"? When I disable this compiler preference it works and the console shows: Code Index: 78 lineNumber: 1486 Code Index: 106 lineNumber: 1486 Code Index: 112 lineNumber: 1486 Note: I also rebuilt.
Note that the "HelloWorld" example in comment#9 does not work for me either. I am using IBM1.4.2 VM (build 1.4.2, J2RE 1.4.2 IBM Windows 32 build cn1420- 20040626), but switching to JDK1.4.2 does not seem to make a difference.
I have released the debug fix to HEAD, and filed a seperate bug for the "install in all locations for a line" problem (bug 72431). Moving this bug to JCORE for further investigation.
I will release a patch to update the line number attributes in case the finally block is inlined. Please double-check if this is working with integration/nightly builds > 20040823.
Fixed and released in HEAD. Please reopen if it is still failing.
verified in I200408241200