Author Topic: Debugger breakpoints issue (again)  (Read 11352 times)

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9694
Debugger breakpoints issue (again)
« on: June 05, 2006, 05:53:37 pm »
Dear all,
after reading this: http://forums.codeblocks.org/index.php?topic=3261.msg25801#msg25801 I started to work on that. There is an easier way to reproduce:
1.) write a file with more that 2 lines of code. ;-)
2.) place a breakpoint at two lines that follow each other (e.g. 5+6).
3.) open the debugger's breakpoint window
4.) place the cursor on the end of the second line with the breakpoint
5.) hit return
-> Expected: The breakpoint shouldn't change.
-> Result: The second breakpoint gets lost.
Reason: There is a difference if you hit return and you are at the end of a line with a breakpoint or at the beginning of that line. If you are at the end the breakpoint of this line shouldn't change at all. If you are at the beginning (inserting a new line on return) the second breakpoint should shift one line.
Unfortunately I don't know how to figure out if the enter has been pressed at the beginning, at the end or somewhere in between... But this should be taken care of.
Any hints? BTW: The code to inspect is: cbEditor::OnEditorModified.
With regards, Morten.
« Last Edit: June 05, 2006, 05:56:30 pm by MortenMacFly »
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: https://www.codeblocks.org/docs/main_codeblocks_en.html
C::B FAQ: https://wiki.codeblocks.org/index.php?title=FAQ

Offline Szabadember

  • Multiple posting newcomer
  • *
  • Posts: 75
  • That's me!
Re: Debugger breakpoints issue (again)
« Reply #1 on: June 07, 2006, 09:18:20 pm »
I know, how to do this with WinApi but i don't know anything about wxWidgets

Sorry.

Offline nix_BB

  • Multiple posting newcomer
  • *
  • Posts: 33
Re: Debugger breakpoints issue (again)
« Reply #2 on: June 08, 2006, 07:48:40 am »
wxWidgets is uses the WinAPI to do its thing, so perhaps by explaining how to do it in the WinAPI we could figure out how to do it in wxWidgets :wink:

Offline taZDeVil

  • Single posting newcomer
  • *
  • Posts: 5
Re: Debugger breakpoints issue (again)
« Reply #3 on: June 08, 2006, 11:15:44 am »
I think i solved the problem (*WHOOOO* my first constructive contribution). For this i simply suppress the resetting of the breakpoints if the cursor position is at EOF. Here is the diff:

Index: cbeditor.cpp
===================================================================
--- cbeditor.cpp   (revision 2537)
+++ cbeditor.cpp   (working copy)
@@ -1900,7 +1900,7 @@
         // at the same time we 'll be removing those breakpoints
         wxArrayInt bps;
         int line = startline;
-        while (line >= 0)// && line >= startline)
+        while (line >= 0 && event.GetPosition() ==  m_pControl->GetLength())// && line >= startline) //don't reset breakpoint if cursor pos is at EOF
         {
             int oldline = line - linesAdded;
             int newline = line;

Offline mandrav

  • Project Leader
  • Administrator
  • Lives here!
  • *****
  • Posts: 4315
    • Code::Blocks IDE
Re: Debugger breakpoints issue (again)
« Reply #4 on: June 08, 2006, 02:18:37 pm »
I think i solved the problem (*WHOOOO* my first constructive contribution).

Hmm, I don't know if your fix fixes an as-of-yet-unknown bug (will check shortly), but it has nothing to do with the reported bug.

Anyway, I 've fixed all breakpoint syncing issues when adding/removing lines in the editor (hopefully!).
Be patient!
This bug will be fixed soon...

Offline mandrav

  • Project Leader
  • Administrator
  • Lives here!
  • *****
  • Posts: 4315
    • Code::Blocks IDE
Re: Debugger breakpoints issue (again)
« Reply #5 on: June 08, 2006, 02:21:06 pm »
I think i solved the problem (*WHOOOO* my first constructive contribution).

Hmm, I don't know if your fix fixes an as-of-yet-unknown bug (will check shortly),

Checked and found no problem. Maybe my fix for the reported problem also fixed another bug you encountered?
Be patient!
This bug will be fixed soon...

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9694
Re: Debugger breakpoints issue (again)
« Reply #6 on: June 08, 2006, 04:10:09 pm »
Hmm, I don't know if your fix fixes an as-of-yet-unknown bug (will check shortly), but it has nothing to do with the reported bug.
I agree on that. Anyway, thanks for the help.

Anyway, I 've fixed all breakpoint syncing issues when adding/removing lines in the editor (hopefully!).
Initially I wanted to say: "That's unfair!" because I was also still working on that one. Anyway, after looking at your solution I saw that we had at least the same idea, but your solution is still more clever than the one I was still implementing.

Anyway, I've done (nearly) all the tests that I had written down with all the special cases that can occure and guess what: Your code simply works. Just for a future reference here is what I had written down (for me) to test the breakpoints:
- (all tests usually for at least 3 lines of code)
- test for BP cases:
  * only first line has a BP
  * first+second line has a BP
  * first+second+third line has a BP
  * first+third line has a BP
- test for position cases:
  * cursor within first line
  * cursor within second line
  * cursor within third line
- test for position of cursor within a line:
  * position the cursor at the very beginning of the line
  * position the cursor in the middle of a line
  * position the cursor at the very end of the line
- test for paste-of-code cases:
  * paste a single line of code
  * paste two lines of code
  * paste three lines of code
- test for del-of-code cases:
  * del a single line of code
  * del two lines of code
  * del three lines of code
- test for insertion / deletion:
  * insert: Press ENTER at the begining of a line
  * insert: Press ENTER at the middle of a line
  * insert: Press ENTER at the end of a line
  * delete: mark a complete line (including "EOL"), press DEL
  * delete: go to the end of a line, press DEL
- special cases:
  * remove all characters of the file (CTRL+A;DEL)
  * single line of code with not end of line marker

To sum up: WELL DONE!!! :P

With regards, Morten.
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: https://www.codeblocks.org/docs/main_codeblocks_en.html
C::B FAQ: https://wiki.codeblocks.org/index.php?title=FAQ

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9694
Re: Debugger breakpoints issue (again)
« Reply #7 on: June 08, 2006, 04:12:46 pm »
- special cases:
  * remove all characters of the file (CTRL+A;DEL)
...after writing this: This does not work yet -> all breakpoints remain in that case but they should all be removed... ;-)
With regards, Morten.

Edit: Another case:
- set BP's at e.g. the last 3 lines of a file
- select the last 4 lines of the file
- press DEL, notice the BP's are NOT removed
I think this is related to the problem above, but just to make sure it's considered. Is there a way to get all registered BP's of a file? I only found {Add/Remove/Toggle}Breakpoint in the driver...?!
« Last Edit: June 08, 2006, 04:35:27 pm by MortenMacFly »
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: https://www.codeblocks.org/docs/main_codeblocks_en.html
C::B FAQ: https://wiki.codeblocks.org/index.php?title=FAQ

Offline killerbot

  • Administrator
  • Lives here!
  • *****
  • Posts: 5490
Re: Debugger breakpoints issue (again)
« Reply #8 on: June 08, 2006, 05:02:56 pm »
:shock: :shock: I have the impression it still does not work  :shock: :shock:

I checked the behaviour before and after todays commit, and it seems even worse then last week. Then some fixes were made (i tested also for this issue back then).
Tomorrow I will give some more elaborate details on what works and what not (have to go now).


[EDIT] : my test was now (different from last week) inserting/removing empty lines when the debugger hit a breakpoint, so quit something different ...
« Last Edit: June 08, 2006, 05:13:26 pm by killerbot »

Offline taZDeVil

  • Single posting newcomer
  • *
  • Posts: 5
Re: Debugger breakpoints issue (again)
« Reply #9 on: June 08, 2006, 05:21:14 pm »
Quote
To sum up: WELL DONE!!!
Oh, thanks. But it seems that this "fix" messes up more than it fixes.

Quote
...after writing this: This does not work yet -> all breakpoints remain in that case but they should all be removed... Wink
With regards, Morten.

Edit: Another case:
- set BP's at e.g. the last 3 lines of a file
- select the last 4 lines of the file
- press DEL, notice the BP's are NOT removed
I think this is related to the problem above, but just to make sure it's considered. Is there a way to get all registered BP's of a file? I only found {Add/Remove/Toggle}Breakpoint in the driver...?!

This problem occurs if marked lines are deleted. There are currently no routines handling this.... oh... to late... mandrav commited some hacks....





Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9694
Re: Debugger breakpoints issue (again)
« Reply #10 on: June 08, 2006, 05:59:45 pm »
Quote
To sum up: WELL DONE!!!
Oh, thanks. But it seems that this "fix" messes up more than it fixes.
No, mandrav's corrections were good. This is indeed an issue with the underlying wxScintilla which mandrav corrected in a fully acceptable way. Anyway, what occurs now is a different problem. This hasn't been taken care of so far at all. Do you have another idea how to fix that? Patches are always welcome but please keep in mind that sometimes there are better solution. (I somehow got the feeling you are unhappy your patch hasn't been applied...?!)
With regards, Morten.
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: https://www.codeblocks.org/docs/main_codeblocks_en.html
C::B FAQ: https://wiki.codeblocks.org/index.php?title=FAQ

Offline taZDeVil

  • Single posting newcomer
  • *
  • Posts: 5
Re: Debugger breakpoints issue (again)
« Reply #11 on: June 08, 2006, 06:29:18 pm »
... (I somehow got the feeling you are unhappy your patch hasn't been applied...?!) ...
Ups, some misunderstanding. With the messing up fixes i  meant mine not mandravs. I've already tested latter, but there seem to be still problems when deleting/cutting marked lines (with marking extended to EOT). Will take a quick glance on it....

Offline taZDeVil

  • Single posting newcomer
  • *
  • Posts: 5
Re: Debugger breakpoints issue (again)
« Reply #12 on: June 12, 2006, 11:44:50 pm »
Edit: Another case:
- set BP's at e.g. the last 3 lines of a file
- select the last 4 lines of the file
- press DEL, notice the BP's are NOT removed
I think this is related to the problem above, but just to make sure it's considered. Is there a way to get all registered BP's of a file? I only found {Add/Remove/Toggle}Breakpoint in the driver...?!

Here's another attempt to fix the issue of non removed debugger breakpoints if a block of lines is deleted. The patch:

Index: cbeditor.cpp
===================================================================
--- cbeditor.cpp   (revision 2551)
+++ cbeditor.cpp   (working copy)
@@ -2105,6 +2105,13 @@
         int origstartline = m_pControl->LineFromPosition(event.GetPosition());
         int startline = origstartline;
 
+        // when removing blocks of lines (linesAdded < -1) also remove all affected breakpoints
+        for (int i=startline ; (linesAdded < -1 && i < (startline - linesAdded)) ; i++)
+        {
+            debugger->RemoveBreakpoint(m_Filename, i);
+            // Manager::Get()->GetMessageManager()->DebugLog(_T("Removed breakpoint from line %d"), i );
+        }
+
         // HACK, part1:
         // ok, here's a hack for scintilla's bad behaviour with markers:
         // if you press Enter on a line with a marker, scintilla doesn't move


If anyone could check this....

« Last Edit: June 13, 2006, 09:33:24 am by taZDeVil »

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9694
Re: Debugger breakpoints issue (again)
« Reply #13 on: June 13, 2006, 11:28:42 pm »
If anyone could check this....
Thanks! :D I've had a similar patch already in the pipeline (for testing). I guess we had the same idea somehow... anyway - it's in SVN now, feel free to do an update and test yourself.
With regards, Morten.
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: https://www.codeblocks.org/docs/main_codeblocks_en.html
C::B FAQ: https://wiki.codeblocks.org/index.php?title=FAQ