Visual Studio switches from disassembler to source each time I step - visual-studio

On one of my two computers I see following behaviour:
Each time I press F10 (Step over) or F11 (Step Into) in the disassembler window, the focus is switched to the source view, resulting in next F10 / F11 done on the source level unless I switch focus back.
Can anyone recommend me what settings to inspect, or what to try to stay in the disassembler view?

Did you try to reset settings on your VS?
from the Visual Studio command prompt window type devenv /ResetSettings

Look in the Tools > Options > Environment > Keyboard section, and check what F10/F11 are currently assigned to (although I can't believe it's something that simple)
Copying the settings from the working computer might solve it. You don't mention what version you're running, but I think they're in the same location in 2005 onwards : My Documents\Visual Studio 2005\Settings\CurrentSettings.vssettings. There's always the Import and Export Settings Wizard too.

Try setting a breakpoint in the assembly view. I'm assuming the existing breakpoints are in the source view.

Could it perhaps be: Tools->Options->Debugging->Enable address-level debugging?
I just tried in VS05, and when I have that unchecked, I can't even bring up the disassembly view, but I would guess that if you somehow got into disassembly view, having that option off would kick you out of disassembly view when you did a step over/into.

Close the source file window ? I had the inverse problem that cause F11 to always debug in assembly, it was fixed by closing the assembly window. May be it works in reverse too ?

Not sure, if this would work but... try if you can?
Open RegEdit
Browse to HKEY_LOCALMACHINE -> SOFTWARE -> Microsoft -> Internet
Explorer -> Main
Add a DWORD under this key called TabProcGrowth
Set TabProcGrowth to 0 (zero)
This is what I used when VS2005 debug mode stopped working (0:

Try removing any .pdb files from the directory you are executing from. Also make sure your Options->Debugging->Symbols settings aren't pointing to any pdbs for the files in question.
Of course I'm assuming you've been through all the other Options->Debugging options, including the native section.

Related

How can i use the register debug window in visual studio

I am currently learning assembly and i am using visual studio to do so. however when i went to evaluate the registers there was no option in the debug drop down. Would i need to install it or activate a setting?
Dont have enough reputation to embed a picture sorry.
The registers window can be opened via Debug > Windows > Registers, when the debugger is active. In the normal editor mode, it does not show up as an option. The set of registers shown in the registers window can be changed via the right-click menu.
Make sure you have enabled address-level debugging in Tools=> Options=> Debugging node.
Don't forget to set a breakpoint, then run the the program in debugging mode.
If you still can't see the Register Option, consider the following: Go to Tools => import and Export Settings => Reset all settings.
Check "Yes, save my current settings," in case you may need to get your old settings back for some reason.
Microsoft Reference
Another Reference
Do all the steps and check the things the people above me said but to seek the register option in the drop down window, set the break point and run the program and then go to the dropdown window. Now it should be there.

Set a breakpoint in an attached process that is not started yet - VS

I'm trying to debug an executable (.exe) using Visual-Studio (2019). I opened a new solution and added a command contains the path of my exe, as describes in here How do I attach Visual Studio to a process that is not started yet?.
Because of I'm interesting at the first instructions it executes, I want to set a data breakpoint /breakpoint in a specific adress that I've found on the disass window .
when running the solution and hitting the 'Break all' option, I could view the disassembly window, and then I've found the location that I want to break at. When I placed there a breakpoint and restarted, it seemed that the breakpoint was marked off.
How can I achieve that?
Here is what I've tryed so far:
Playing around with the Debugger type window (Solution => properties => debugging => Debugging type)
Open a new solutio, and try it there
Any help would be much appreciated!
You can open the exe in VS like you would a project/solution. From the VS menu use File->Open Project/Solution and select the .exe file you want to debug. This will create an 'exe project'. You can launch it with F5, to pause on the 'first' statement you can launch with F10 instead. Then when you set breakpoints if you save the solution they should be persisted for when you next launch the exe. You'll need symbols and source for the exe if you're to make much sense of when you debug though.

Visual Studio - Prevent F11 from starting the debugger?

Is there a way to prevent Visual studio to start the debugger when pressing F11? I often press it by mistake when I want to actually press F12.
I do not want to loose the functionality of Step-into which F11 provides but it is annoying when it starts the application.
This is for VS 2010, but it should be similar for others.
In Tools->Options, open Keyboard under Environment. Look up the command Debug.StepInfo. You can remove the default shortcut (F11 (Global)) and then just use the toolbar button to step into, or right click and "Step into specific"--which is what I do since it keeps the debugger from diving into STL functions if they're part of a line of code (as an example).
A hack-around that I use is to use the cancel build command after I accidentally hit F11. The default shortcut is ctrl+pause/break.
This doesn't stop F11 starting a build, but should stop it from running your program.
This is the suggestion on Microsoft's VS Community forum. Currently there is a suggestion from MSFT (I assume official MS dev?) that points to this free extension Tweaks:
Don't start debug on F10/F11 Inspired by the suggestion Please provide
a way to disable F10/F11 until debug mode is entered.
F10 (Step Over) and F11 (Step Into) are two commands people often hit
by accident. That starts a new debugging session and that can be
annoying if you didn't mean for that to happen. They should only take
effect during a debug session.
Install Resharper and Change the Key Short Settings

Is there a setting to show assemblies as they are loaded during debugging in Visual Studio?

I believe there is a setting (or combination of settings) in Visual Studio that allow you to see in the Immediate Window (or Output Window, I can't remember which), the timestamp and name of an assembly as it is loaded while debugging. I used to have this switched on as it is very useful for finding performance issue areas. Sadly however, when VS recently decided to undock all my windows for no good reason, I had to reset my VS settings and have now lost this.
I can't find for the life of me which setting it was that I had switched on.
Any help appreciated.
Apart from reading Debug output messages in Output window, you can also use Modules Window (at least in Visual Studio 2013) which gives you a nice searchable list of loaded modules with various additional details:
Debug -> Windows -> Modules
In the Output window, change the "Show output from" combo to Debug if necessary. Right-click the window and tick "Module load messages". And any others you might want to see.

Slow debugging issue in Visual Studio

In my Visual Studio instance, even if I just wrote a single line of return in a C# console application, it will take me a minute after pressing F5 to execute the actual code (I mean the time it takes to stop on the single return statement after pressing F5 -- I set a breakpoint on the return statement in the main function). What is wrong? Is there a check list?
I am using Visual Studio 2008 VSTS edition and debugging on Windows Server 2003 x64.
You may need to delete all your breakpoints---note that you need to click the "Delete all breakpoints" button (or use Ctrl + Shift + F9), NOT just delete them one by one. If Visual Studio has mangled your solution settings the latter will not work. You may need to add a breakpoint first, in order for this to work (clever, eh?).
If worst comes to worst, you may need to delete your .suo file and let Visual Studio start a new one from scratch. Note that you will lose your personal solution configuration settings, however (only for this solution, not any others). However, you may want to move/rename the file temporarily until you determine whether or not this is the problem; that way, you can always move it back. I have seen some online resources recommend deleting (moving/renaming) the .ncb file as well.
I have seen this before. Try deleting all your breakpoints and then set the ones you want. Hit F5. Is it faster now?
I just noticed that you mentioned setting up the .NET source debugging feature. Try to disable that. Your network connectivity to Microsoft's source server may be slow. Also disable any symbol server connectivity in menu Tools → Options → Debugging → Symbols.
Also try disabling "Enable property evaluation and other implicit function calls" in menu Tools → Options → Debugging → General.
Or remove your .suo file which can be found next to your solution (.sln) file.
This solved an issue I had with debug sessions taking a long time to start and stop.
I had this problem. After trying all the listed advice and removing all Visual Studio extensions, we finally figured out that somehow IntelliTrace was enabled. Disabling that fixed everything.
How to: Enable and Disable IntelliTrace
Do you have a lot of breakpoints set? Those can really slow down startup time. Everytime a new module is loaded into the process address space, they all need to be checked to see if they are valid.
Go to menu Tools → Options → Debugger → Symbols and check if you have public symbols set or UNC network paths set. Also check menu Tools* → Options → Debugger → General to see if you have source server set.
All of these can affect debugging based on slow network speed or unavailable servers. The 5 minute wait time is network timeouts.
If nothing in options is set, check to see if you have the _NT_SYMBOL_PATH environment variable set.
My colleague had a very slowly responding Visual Studio, and it literally took minutes to perform a step while debugging.
The root cause turned out to be an anti virus program (Threatfire) that went crazy while Visual Studio was running. Killing its process immediately fixed everything.
In my case changing the debug symbol "Automatically load symbol for" option from "All modules" to "Only specified modules" solved the problem. You can change this option from menu Tools → Options → Debugging → Symbols.
A different cause plus... How to find the problem
To me it was the option ShowOtherThreadIpMarkers. A value of 1 makes Visual Studio (2010) unbearably slow (3-5 seconds for each debug step. With a value of 0, it is fast again.
What is it that option? I have no idea. I could not find it through the Visual Studio user interface.
I unchecked all possible debugging options in there and nothing worked.
So I went to Import/Export Settings and loaded my old settings I've previously saved going backward in time until Visual Studio was fast again, then compared the vssettings files..., etc., etc.
I'd like to remark that if you load the settings while you are in debug mode stopped on a breakpoint, they become effective immediately. You don't have to stop the debugger and restart.
From ScottGu's blog linked by Travis: "One other performance gotcha I've heard about recently is an issue that a few people have reported running into with the Google Toolbar add-in. For some reason this can sometimes cause long delays when attaching the Visual Studio debugger to the browser. If you are seeing long delays with your web application loading, and have the Google Toolbar (or other toolbars) installed, you might want to try uninstalling them to see if that is the cause of the issue."
Running under the debugger for me was roughly 10x slower than running without debugging.
After trying every solution suggested here, I went through every debugger setting and enabled/disabled to see if it made a difference.
For me, it turned out that disabling Suppress JIT optimization on module load in the debug settings massively improved things.
Make sure you don't have any stale network mappings to servers that no longer exist (network timeouts will kill you). Or use something like Process Monitor to see if a network (or other file error) seems to be blocking for a long time.
Are you using a symbolsServer to download symbols for Windows DLL files?
If so, disable that as it can take some time, but I wouldn't expect that to cause long delays in a basic console application.
Menu Tools → Options → Debugging → Symbols.
I know this is an old topic, but for what it's worth...
I've found that if I've had a separate Internet Explorer window open for a long time it can take up to a minute to start debugging. Close all Internet Explorer windows and debugging starts immediately.
In my case Google Toolbar was slowing down my debugging.
gplus_notifications_gadget.html just kept going on and on overloading the debugger. I wanted to keep the Google Toolbar because I use it on a regular basis, so I just disabled the G+ notification button (the small button besides the profile button). It is happy now.
I had the same issue in Visual Studio 2010, with stepping in the code excruciatingly slow (between 3 to 10 seconds). However, none of the above settings modification did the trick.
I eventually found the ultimate solution, which would work in all of the above post issues: reset all your settings, as described here (essentially menu Tools → Import and Export Settings, Reset all settings, with saving existing settings to a file (for reverting)).
You may first want to save a particular part of your settings. For instance, I first saved my color theme (Solarized-like) and then restored it after the global reset.
For me, the setting that killed performance (Windows 8 even hanged except for mouse movement) was to uncheck "Break all processes when one process breaks" in menu Options → Debugging → General.
Just one more cause of a slow Visual Studio debugging experience...
Long time ago I enabled FusionLog to see what was causing an assembly binding problem.
Make sure you disable it after using it. Why? Because it writes a lot of logging data to the disk while enabled.
This is the FusionLog key on Window's Registry (regedit.exe):
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Fusion
Change the ForceLog, LogImmersive and LogResourseBindings values from 1 (enabled) to 0 (disabled).
I had this problem too, but it had nothing to do with breakpoints in my case. It was code shortcuts that I added in the tasks window:
http://www.customsoftwareframeworks.com/blog/longwaittimetoinsertoraddalineoftextbuginvisualstudio--tasklistwindow--onlywhenaddingandremovelines
I'm sure there are other ways you could see a problem like this, but there is a bug somewhere that caused this problem for me...deleting all my options would have fixed this, but that is something that I did not want to do. So, I debugged it and wrote about it in my blog...your problem sounds like mine.
Something that has worked for me is to make sure there are no conditional break points. Other than that, I have had success fixing slow debugging by simply restarting Visual Studio and only opening one instance of Visual Studio at a time.
I had a similar issue and none of the other guidance seemed to help. I had rebooted to no avail. I had removed all breakpoints, deleted the .suo file, checked that symbols weren't being loaded from external sources, and checked that no paths existed in the application that was unavailable.
Then, I thought to clean the solution. I noticed in the output window that C# IntelliSense reported an issue when cleaning:
There was a problem reading metadata
from
'{B0C3592F-F0D1-4B79-BE20-3AD610B07C23}'
('The system cannot find the file
specified.'). IntelliSense may not
work properly until the solution is
reloaded.
In this case, once you actually discover the error message, it tells you exactly how to resolve it. (Good job on the error text, poor job on discoverability!) I unloaded the solution's projects, then reloaded them. I was then able to successfully run clean solution. It worked, and the debugger did as well.
Closing the "Autos" window improved debugging for me in Visual Studio 2008 for a big native C++ solution.
Hiding it won't work. It needs to be closed.
I experienced the same slowdown and disconnecting from the network fixed the problem for me as some other comments and answers have stated (but of course that is not an ideal fix).
For my case this one simple change fixed my solution: In the project properties on the debug tab I disabled "Enable the Visual Studio hosting process" (I am running Visual Studio 2010).
Get more memory and a faster HD. More details are here.

Resources