Chris’ CodeGear Debugger Blog

Borland Developer Studio 2006: Automatically close files implicitly opened during debugging

“Automatically close files implicitly opened during debugging”

That’s a mouthful, isn’t it….  That’s the name of a new option added to the Integrated Debugger in BDS 2006.  What exactly does it mean?  This blog post will discuss this new feature.

Before describing this feature, I’d like to discuss the motivation behind it.  Have you ever ended a long debugging session and looked in the code editor to find many files that were not open when you started the debugging session?  Perhaps, these are files that you stepped into to trace the flow of your application, or ones you inadvertantly stepped into when you executed a “Trace Into” where a “Step Over” would have sufficed.  At any rate, now that you are done debugging, perhaps you want to edit one or more of the source files you were editing before you started debugging.  It may be hard to find those files again in the code editor amongst the many files that were opened during debugging.  Enter this new feature.  Now, by setting this option (it is ON by default in BDS 2006), any files that were not opened before you started the debugging session will be automatically closed when you end the debug session.

Here is a screenshot of the Debugger Options page, showing the new option:

In order to visually indicate which files have been opened implicitly during debugging, the editor draws an extra overlay glyph showing a red “bug” on the tab for each file implicitly opened during debugging.  In the following screenshot, 3 units (Forms, Controls, and System) have been opened during debugging by stepping into the RTL and VCL source code.  Note that their editor tabs show the red “bug” glyph:

When you end the debug session, those files are automatically closed.  Note this screenshot which was taken after performing a Program Reset:

 

You’ll note that Forms and System were automatically closed.  Hold on though….  The Controls unit was marked as implicitly opened, yet it was not automatically closed.  Looks like a bug, right?  Actually, this is the way it is meant to work.  What I failed to mention earlier is that the currently active file in the editor will never be automatically closed.  This was a direct result of some usability feedback I received from other members of the Delphi R&D team during the BDS 2006 development cycle. It seems that quite often, people would step into a source file that was not previously open.  They would find the source of one of the bugs they were tracking down in this file, and they would perform a Program Reset (Ctrl-F2) to end the debug session in order to return to design mode so that they could apply the fix.  Well, if the file they were looking at was automatically closed, that became counter-productive.  In order to address this, the debugger will never close the active editor file after a debug session, even if that file was not open before the debug session started.   There are two other actions that will automatically cause a file to lose its “implicitly-opened” attribute.  If at any time, you edit a file, it will no longer be atomatically closed when the debug session ends.  Likewise, if you set a breakpoint in a file that was implicitly opened, this will also cause the file to lose its “implicitly-opened” attribute, and it will stay open after the debug session ends.   If anyone runs into other situations where this feature gets in your way and closes files that you think it should not, please leave a comment here or enter a report in QualityCentral.

There are also a couple of new menu items related to this feature that appear on the local menu that appears when you right click an editor tab for an implicitly-opened file.  They are shown in the screenshot below:

At any time there is at least one file open that was implicitly opened, you can use the “Close All Pages Opened While Debugging” menu item to close all such files.  As I mentioned above, you can prevent a file from being automatically closed by editing the file or by setting a breakpoint.  You can also manually tell the debugger not to close a particular file, by selecting the “Opened While Debugging” menu item.  This menu item acts as a toggle for the selected editor tab (though it is a sort of strange animal since you can only use it to toggle OFF the “Implicitly Opened While Debugging” flag).

One other thing you might notice in this last screenshot is another new menu item on this menu: “Close All Other Pages”.  Although this menu item is not debugger-specific, I’ll mention it here as well.  This menu does exactly what you think.  Any time you select this menu item, all other tabs in the editor will be closed, leaving just the selected tab open.  This even works for non-editor-buffer tabs like the Welcome page, CPU view, Modules view, StarTeam client view, etc…

Posted by Chris Hesik on December 9th, 2005 under CodeGear Debugger |



8 Responses to “Borland Developer Studio 2006: Automatically close files implicitly opened during debugging”

  1. Brad White Says:

    Sweet!

  2. Brad Prendergast Says:

    Excellent! This has always been a pain when debugging dcu’s etc… Seems like you guys have done a lot with D2K6. I am glad to see a lot of blogging about it too.

  3. Florent OUCHET Says:

    Hi,

    Please do the same thing with debug windows. The CPU window stays when the debugging time is finished. (reported as QC #22085).

  4. Chee Wee Chua Says:

    Very innovative, Chris! Definitely a feature I would find very useful when I do development work! ;o)

  5. Adrian Gallero Says:

    This is a very nice feature! Once thing I would add, just to avoid those cases where it closes what it shouldn’t, is a "recycle bin" a la opera.

    If you take a look at opera 8, there is a "recycle bin" where all closed files go, and from where you can reopen last items.

    If there was something like this in Delphi, with an entry to "reopen closed debug files" (maybe with sumbenus allowing to select individual files) we would get a little safer. :) This recycle bin might be useful on its own too, but I am not sure how much.

    Regards and keep the good work!

    Adrian

  6. Peter Kapas Says:

    Hi,

    I could not find how to contact somebody to ask him about some hints in Delphi. My question is: I have 2 HDDs in my PC. On both I have different OSs. How can I find (which procedure is it in Delphi?) from which HDD I started my Windows? Mostly I use D: drive and I have W’XP on this HD (W’98 on the C: drive). I made a program, which modifies an INI file in the Windows directory, but I want to modify on that drive, where the actual Windows started.

    Please help me a send me an e-mail about the solution.

    Thank you

    Peter

    pkapas@sbcglobal.net

  7. Lukasz Says:

    wqerwerwerer

  8. Chris Says:

    Peter:

    Goto the Command prompt, and type

    set<CR>

    and you will see a list of environment variables

    "SystemRoot" is probably the one you want.

    etc.

    Chris

Leave a Comment



Server Response from: blog1.codegear.com