Author Topic: several times the same file is opened by debugger  (Read 17252 times)

Offline killerbot

  • Administrator
  • Lives here!
  • *****
  • Posts: 5490
several times the same file is opened by debugger
« on: January 24, 2006, 12:40:17 am »
I think there has been a post of this before, but I don't know if it got fixed in the meantime or if it was in the same circumstances.

I was debugging in cbEditor.cpp, and had some breakpoints in there, for example in SetTitle. arriving at the breakpoint I was watching the call stack, and clicked on the client of the SetTitle() method. The client appeared to be in the same file, clicking on that client in the call stack, took me to the calling code, but it opened up a new editor for the already opened file.

Anyone else came across this ??

Cheers,
Lieven

PS : @ devs : during my debugging session (trying to fix a CB bug), I noticed there are a tremendous amount of calls to the SetTitle method, pfffeuh  :shock:.

sethjackson

  • Guest
Re: several times the same file is opened by debugger
« Reply #1 on: January 24, 2006, 12:47:32 am »
PS : @ devs : during my debugging session (trying to fix a CB bug), I noticed there are a tremendous amount of calls to the SetTitle method, pfffeuh  :shock:.

Not a dev.  :lol: Probably to pre-pend the asterisk to the file name......

Offline killerbot

  • Administrator
  • Lives here!
  • *****
  • Posts: 5490
Re: several times the same file is opened by debugger
« Reply #2 on: January 24, 2006, 12:49:54 am »
then we would have a lot of '*' in front  :lol:

sethjackson

  • Guest
Re: several times the same file is opened by debugger
« Reply #3 on: January 24, 2006, 12:51:44 am »
then we would have a lot of '*' in front  :lol:

That is the only use of SetTitle() I'm sure....  :lol:

EDIT:

Did you get the XML problem fixed???

Offline killerbot

  • Administrator
  • Lives here!
  • *****
  • Posts: 5490
Re: several times the same file is opened by debugger
« Reply #4 on: January 24, 2006, 01:11:11 am »
then we would have a lot of '*' in front  :lol:

That is the only use of SetTitle() I'm sure....  :lol:

EDIT:

Did you get the XML problem fixed???
nope, will create a screenshot tomorrow, so you can see. It is obvious I am doing something wrong ;-)

Offline rickg22

  • Lives here!
  • ****
  • Posts: 2283
Re: several times the same file is opened by debugger
« Reply #5 on: January 24, 2006, 01:12:31 am »
I haven't been able to replicate this bug (it's rather old). Please give us as many details!

Offline killerbot

  • Administrator
  • Lives here!
  • *****
  • Posts: 5490
Re: several times the same file is opened by debugger
« Reply #6 on: January 24, 2006, 01:18:32 am »
as described in my post. I am debugging revision 1843 at this very moment.

Reconstruction : put a break point in cbEditor::SetTitle(), in the debug CB, open a project, and add for example a new file (which get's some default code in it from the default code settings). Once at the breakpoint, double click on a call site of this function, when in the same file --> file opens again in a new editor.

Lieven

Offline duncanka

  • Multiple posting newcomer
  • *
  • Posts: 53
Re: several times the same file is opened by debugger
« Reply #7 on: January 24, 2006, 05:17:57 am »
I had the same problem debugging my own program, using Lieven's Win98-compatible ANSI build (rev1843) on Win98SE.  I set a breakpoint on a line in main(), and when the debugger hit that line, CB opened a second file tab with main.cpp in it with the little current-debug-line widget next to the breakpoint line.  The breakpoint symbol was only shown in the original tab, while the debugging widget was only shown in the freshly opened tab.  In fact, with each line I "stepped over," another tab with the file opened up.  (The debugging-current-line widget was removed from all but the latest tab.)
I hope this helps.

Offline killerbot

  • Administrator
  • Lives here!
  • *****
  • Posts: 5490
Re: several times the same file is opened by debugger
« Reply #8 on: January 30, 2006, 10:31:35 pm »
ok, dear devs please help others and me out, so we get rid of this horrible bug.
Here's a full story on it.

First : how it should work :
Say that a given file in the project is open in the editor, and you put a breakpoint in there, or it is on the call stack (when being stopped at some other point in the code), when you double click on the entry in the call stack dialog for that 'file', this is what should happen :

BacktraceDlg::OnDblClick ==> m_pDbg->SyncEditor(file, atoi(line.mb_str()))  ==>     cbEditor* ed = Manager::Get()->GetEditorManager()->Open(filename);

And in the EditorManager::Open, I added some lines to the code (between those LDC lines)
Code
    EditorBase* eb = IsOpen(fname);
    // LDC
    if(eb)
    {
wxMessageBox(_("Is open ") + fname, _("Debug"), wxICON_WARNING);
}
    else
    {
wxMessageBox(_("Is NOT open ") + fname, _("Debug"), wxICON_WARNING);
    }
    // end LDC

SO : if the file would be open -> no need to reopen it again -> message box saying it is open, we will see although the file is open in the editor, we get a bunch of NOT open MessageBoxes. So either the BUG is in the IsOpen() method, or the fname is somehow different on what we have in the editor manager.

Attached is a zip file containing a dummy project, main calls function1 (function1.cpp), which in turn calls function2 (function2.cpp), which in turn calls function3 (function3.cpp). Unzip the file for example at the root of C:  -> c:\DebuggerCallStack  directory.

When you have build a CB, with my 2 MessageBoxes, and you open up the project (use it's layout -> function1,2,3.cpp open) you'll see 3 times the "NOT open" messagebox, ok, since they are now opened for the first time. Did you count correctly, yes, indeed it 4 times not 3, the last one apparantly is opened twice (yes it's the last one, do it with 2 files open), but the second time indeed it is saying it is already open.

Allrighty time for the experiment : put a breakpoint in the open function3.cpp (for example on line 8).
Startup the debugger, when it hits the breakpoint, we get our first messagebox saying the function3.cpp is already open. Very good, this is correct. Now go to Debug menu->Debugging Windows->Call stack ===> OOPS, look at that first entry, antoher little bug, unction3, should be function3.
Ok, time for the big test, double click an entry in the call stack, for example function2 and/or function1 (remember those files are open) --> we see our NOT open messagebox !!!!
Click those entries once more --> NOT open again.
Now, I think I don't have to tell how annoying this is during debugging :-(

Wait a minute, let's do our experiment again, choose continue in the debugger, so the program runs till the end, then close all those EXTRA functionX.cpp's, so the original 3 are still open. Close the project, and copy the whole project directory into the "My Projects" folder.
Open the project from there, 4 messageboxes, ok, put again the breakpoint at the same location, and let's debug : well well well, NOW even the file with the breakpoint is considered as NOT open (look at the nice filenames now -> is it a filename issue ??, AND in our extra function3.cpp we have a yellow arrow of the current line, but we don't see our breakpoint red dot, that on is still visible in the original opened function3.cpp, confusing hey), and as you would expect entries from the call stack : NOT open (and ... unction3).

I didn't do any further analysis, I hope one of you devs can have a quick look, and knowing you guys, a quick fix (patch mechanism is a bit too slow), so I can have more pleasant debug sessions for fixing other CB bugs.

Cheers,
Lieven

PS : I changed the extension to .7z.txt, just remove the .txt part

« Last Edit: January 31, 2006, 09:44:28 am by killerbot »

Offline rickg22

  • Lives here!
  • ****
  • Posts: 2283
Re: several times the same file is opened by debugger
« Reply #9 on: January 31, 2006, 01:36:31 am »
I think a reason for this (It's just a supposition, since i haven't read the code) this opening of files is event-driven. Am I correct?

In that case, I think I know what happens.


a) Event "1" for file A is posted / triggered.
b) File A is in the process of adding, event "2" is posted in the process.
c) Event "3" for file A is posted / triggered.
d) File A is in the process of being added AGAIN, since it hasn't been fully added yet. Event "4" is posted.
e) Pending events are handled, events 2 and 4 are triggered, and the file is added twice.

In that case, i think having an STL map (or set) for files-to-be-added would be the appropriate solution. This would be instant, no event handling required.

Offline killerbot

  • Administrator
  • Lives here!
  • *****
  • Posts: 5490
Re: several times the same file is opened by debugger
« Reply #10 on: January 31, 2006, 07:34:12 am »
i think the file was already fully added, when it was initally opened. No debugging session was going on at that time, that means the editormanager should return true for IsOpen at that time. then we start a debugging session, we say to the editor manager, hey here's a filename, is it open yes/no And then he says no, as described above the location of the project can even influence the open status of the file containing our breakpoint. Maybe the relative/full path switching goes wrong when the filename is returned from the debugger  when it's listing its frames (call stack).

Offline tiwag

  • Developer
  • Lives here!
  • *****
  • Posts: 1196
  • sailing away ...
    • tiwag.cb
Re: several times the same file is opened by debugger
« Reply #11 on: January 31, 2006, 08:22:34 am »

Cheers,
Lieven

PS : I changed the extension to .7z.txt, just remove the .txt part

i can't open your attachement - seems to be a corrupt .7z file ?

Offline mandrav

  • Project Leader
  • Administrator
  • Lives here!
  • *****
  • Posts: 4315
    • Code::Blocks IDE
Re: several times the same file is opened by debugger
« Reply #12 on: January 31, 2006, 09:11:20 am »
Yes, appears corrupted...
Be patient!
This bug will be fixed soon...

Offline killerbot

  • Administrator
  • Lives here!
  • *****
  • Posts: 5490
Re: several times the same file is opened by debugger
« Reply #13 on: January 31, 2006, 09:19:08 am »
new try
« Last Edit: January 31, 2006, 09:44:45 am by killerbot »

Offline killerbot

  • Administrator
  • Lives here!
  • *****
  • Posts: 5490
Re: several times the same file is opened by debugger
« Reply #14 on: January 31, 2006, 09:30:20 am »