I attach VS 2010 to service process; after that I put breakpoint in several methods but they never seem to be hit. Any idea or tips?
Note: The services process installed is a release build. Do I have to have a debug build installed for this?
You need to have a debug build for this.
In release mode, the debug info is discarded and code is optimized, so there is no way to link to original source code.
In debug mode, debugging and project state information is retained so the debugger canlink to the source code. It also emits DebuggableAttribute that tells JIT compiler that the assembly has debug info.
Helpful link: http://msdn.microsoft.com/en-us/library/ms241903.aspx
Related
In Visual Studio, you can distinguish between Debug and Release modes using the _DEBUG definition. But even in release mode, you can either "Start Debugging" (F5) or "Start Without Debugging" (Ctrl + F5). Is there a preprocessor definition that distinguishes between these?
Start Debugging means Start your program in the debugger.
Start Without Debugging means Start your program normally.
Since you choose one of these actions after building the program (either in Debug or
Release), there cannot be any preprocessor macro or other compiletime difference
between the actions.
The Debug build of your program can be run in the debugger, and it can be run
normally. The Release build of your program can also be run in the debugger, or
normally. But if you run the Release build in the debugger, the debugger's
ability to present the program's internal state correctly, or at all, at any
given point may be hampered for lack of valid debugging information.
It appears what you want is be able to run a Release build effectively in the debugger.
There is nothing to stop you configuring your Release build to generate
debugging information like a Debug build: it's just not the default. See How to: Debug a Release Build
This would probably be a temporary measure. While debugging a Release build in this
way, the program flow you observe might at times appear unexpected, due to Release mode optimizations.
How can I get Visual Studio 2017 to display data tips while running in Release Mode rather than only in Debug Mode?
Data tips are the tool tips that pop up when hovering the mouse over a property, variable, etc. while paused on a breakpoint.
I've read that these are only displayed while running in "Debug" configuration, but for one of my current projects, the program will only run correctly while in "Release" configuration. This is making it extremely difficult to debug anything.
UPDATE:
Today it started working for me without me having changed anything.
The only explanation I have is that on the previous night I switched to Debug mode, built the application (which failed with errors), then switched back to Release mode, and built again. When I ran the application the next morning, the data tips were back.
(1) Disable Optimize Code option under your project properties.
(2) Enable Use Managed Compatibility Mode under Tools->Options->Debugging->General.
And then debug your app in release mode, check it again after the Breakpoint is hit.
(3) Maybe it was related to your project files, so you could re-open your project, view it again.
I have a program I made using Visual Studio that won't start unless VS is debugging. Where should I look for problems?
The program works when debugging through VS but won't start from the debug folder. The program works fine when debugging. No output is given.
For this sort of startup problem I'd suggest running your app in Windbg (part of the Debugging Tools for Windows). Do File -> Attach to executable and then hit F5. You should get more informative output there. I suspect it's a dll dependency or manifest problem. Another useful tool is the Dependency Walker which may highlight some dlls that are on Visual Studio's path but not your default path, which may also explain the error. Another thing to try is check that all types of debug output are being shown in Visual Studio: right-click to get the context menu in the debug output window and ensure it's showing exception messages and module load messages.
Try turning on Stop on Exceptions
Debug - Exceptions - Common Language Runtime Exceptions (thrown and user unhandled)
I see that with the 'Attach to Process', one can debug the process by setting up break point in Visual Studio IDE.
I think it's pretty cool, and I'm curious what's the mechanism that enables it. I also found that gdb and Mac's Xcode supports the technology.
Q1 : Can anyone explain how does this work? How can the process mapped to a breakpoint in an IDE or gdb environment?
Q2 : Are there other compiler/debugger options than /Zi or -g (adding debug info)?
Q3 : Is this the way to debug dll (dynamic library)?
ADDED
I found this one with MSDN - http://msdn.microsoft.com/en-us/library/c6wf8e4z.aspx
The most common scenario I know of is using a browser to debug web code. In these cases, you start Visual Studio in debug mode and then attach to the browser and call the page in question. When the page is called it starts running the code in the debugger. Essentially, the debugger watches the process and when it hits code in VS, it starts debugging.
The same is true with other applications that are calling code you are running in Visual Studio. When you cross the boundary to the code, the debugger catches the call and starts running code in VS.
I use it fairly frequently when developing plugins for existing applications (Maya, Reaper, etc). As a general rule, plugins can't be run independently, so in order to debug them I have to run the host program and use "Attach to Process" to run the debugger on my plugin, at which point I can set breakpoints and all that other debugging goodness. You need to have debugging symbols and al that for the plugin, but you don't need to have them for the host application.
My debugger keep jumping into debugging the IL instead of jumping to debug code of another assembly. How can I turn it off?
Visual Studio right?
Tools -> Options
Click the Debugging section then deselect the Show disassembly if source is not available checkbox
But that will leave you without any debug information if source is not available. It sounds like the debug information is missing from those assemblies. Maybe they were built in release mode? Or the pdb files have not been copied? Of course if you don't have access to the original source code then it won't make any difference