Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 323457 - [EDC] setting breakpoint on source line without code fails to resolve at nearby line with code.
Summary: [EDC] setting breakpoint on source line without code fails to resolve at near...
Status: RESOLVED FIXED
Alias: None
Product: CDT
Classification: Tools
Component: cdt-debug-edc (show other bugs)
Version: 7.0   Edit
Hardware: All All
: P3 normal (vote)
Target Milestone: 8.0   Edit
Assignee: Ling Wang CLA
QA Contact: Ken Ryall CLA
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-08-23 23:32 EDT by Kirk Beitz CLA
Modified: 2012-05-22 14:50 EDT (History)
1 user (show)

See Also:


Attachments
patch for edc line number table code to resolve line number to nearby address (7.01 KB, patch)
2010-08-23 23:32 EDT, Kirk Beitz CLA
no flags Details | Diff
patch for edc line number table code to resolve line number to nearby address (7.01 KB, patch)
2010-08-28 04:00 EDT, Kirk Beitz CLA
no flags Details | Diff
patch for edc line number table code to resolve line number to nearby address (7.01 KB, patch)
2010-08-28 04:06 EDT, Kirk Beitz CLA
cdtdoug: iplog+
kirk.beitz: review?
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Kirk Beitz CLA 2010-08-23 23:32:21 EDT
Created attachment 177281 [details]
patch for edc line number table code to resolve line number to nearby address

standard CDT behavior (as evidenced in testing with DSF-GDB) is that setting a breakpoint on a line without source will cause a breakpoint to be resolved and set on the next subsequent source-line represented in the LNT.

the attached patch fixes this behavior.

tested versus edc JUnit suite.
Comment 1 Kirk Beitz CLA 2010-08-28 04:00:06 EDT
Created attachment 177663 [details]
 patch for edc line number table code to resolve line number to nearby address

replacement to go on top of recent changes to fix java 1.6 vs 1.5 errors
Comment 2 Kirk Beitz CLA 2010-08-28 04:06:48 EDT
Created attachment 177664 [details]
patch for edc line number table code to resolve line number to nearby address

patch adjusted to work on top of recently committed changes to conform to java 1.5 vs java 1.6 (and forgot to obsolete the previous patch, so obsoleting both now).
Comment 3 Ken Ryall CLA 2010-08-30 14:49:11 EDT
Committed to HEAD.
Comment 5 Ling Wang CLA 2011-03-01 15:21:08 EST
New API and new implementation is needed. See bug 337493.
Comment 6 Ling Wang CLA 2011-03-01 15:24:29 EST
New API and new implementaion are done. See bug 337493.
With the new implementation, breakpoint marker is also moved accordingly when the breakpoint is moved.

Aside from the unit test in bug 337493, here's how to test/verify the feature manually with EDC Windows debugger with the program compiled by MingW. 

// code snippet 

11 int foo();
12 int func1();
13 int func2();
14
15 int func2()
16 {
17 volatile int a,b,c;
18
19 a = 1; /* set breakpoint here */
20 b = 2;
21 c = (b + a) * (a + b); /* set a breakpoint here in disassembly code */
22 return 0;
23 }
24
25 int func1()
26 {
27 volatile int x,y,z;
28
29 x = 1; /* set breakpoint here */
30 y = 2;

First let's call a breapoint at line N "bpN". 
1. Set bp11, 12, 18, 19, 28.
2. Remove all other breakpoints in the program and disable stop-at-main.
3. start debugger. You should see:
a. Either bp11 or bp12 (actually which one is indeterministic) is moved to line 16. Namely a resolved breakpoint appears on line 16, while bp11 or bp12 disappear while the other one remains and is unresolved.
b. bp18 is unresolved while bp19 is resolved.
c. bp28 is moved to line 29 (becomes bp29) and resolved.
d. the program stops at bp29.
4. set bp24, you should get resolved bp26.
5. set bp24 again, you should get unresolved bp24.
6. remove bp26, set bp24, you should get resolved bp26 again.


More test cases.

1) When debugger needs to move a breakpoint, it will search in 5-line neighborhood of current line (5 lines above and 5 lines below current line) for the closest line with code, and move the breakpoint there. E.g. with code like below:

9   i = 1;
10  // blank line 1
11  // blank line 1
12  // blank line 1
13  // blank line 1
14  // blank line 1
15  i++;

Set bp at line 11, it will be moved to line 9. Set bp at line 13, it will be moved to line 15. When set bp at line 12, namely in the right middle of two code lines, it will be moved to the line below i.e. line 15.

2) A breakpoint won't be moved beyond 5 lines. namely for code like this

1  /*
2   * comment ...
3   * comment ...
4   * comment ...
5   * comment ...
6   * comment ...
7   */
8   int main() 
9   {
10   ...

If you set a breakpoint at line 2, the breakpoint won't be moved, it will just stay at line 2 unresolved. However, if you set a bp at line 4, it will be moved to line 8 or 9.