Immediate Window for Eclipse - visual-studio

Does Eclipse have an analog to Visual Studio's "Immediate Window", a window where I can evaluate statements while in the debugger?

Yes. The view name is "Display".
Window->Show View->Other
It is under the Debug folder.
Once in there you evaluate statements while in the debugger.

Eclipse has a really cool concept call Scrapbook Pages where you can evaluate statements even when you're not debugging. However, if you want to eval code using values from the current program, go to Window->Show View->Expressions. There you can put in any expression you want and track it as your program executes.

Inspect ctrl-shift-i or Display ctrl-shift-d?

Related

Display screen in VisualStudio like in Eclipce

In eclipse I have a window called "Display" where I can run functions in debugger mode.
Do I have some thing like that in VisualStudio ?
If i do how it called and how to open?
You need Immediate Window. You can type required methods and execute them there when debugging.

Visual Studio.NET 2010 debugging - how to stop execution when any Response.Redirect is hit

In my solution (partly c#, partly VB.NET), I am suspecting that somewhere during the execution there is a Response.Redirect that I am unaware of that destroys my page context.
There are currently 218 Response.Redirects in my code. I have set breakpoints to the usual suspects, but I'd prefer a way to tell Visual Studio to stop whenever a line with Response.Redirect is hit. Is there a way? Or an alternate debugging practise?
A more generic version of that question would be: is there a way to add breakpoints to a solution through a Find action, similar to the "Bookmark All" button? Or to "convert" bookmarks to breakpoints?
IMHO the cleanest way would be to refactor the redirect functionality into a helper, and add your logging/debugging there where there's a single point.
If you just want something quick, you could turn on Exceptions in the debugging menu, and there should be a thread abort exception that you can break on.
In Visual Studio, go to Debug/New BreakPoint/Break at Function.... Type in System.Web.Response.Redirect.
Now the debugger will break whenever Redirect is called.
If you want a specific overload of Redirect, you can add the parameters, e.g., System.Web.Response.Redirect(string)`. See MSDN for more information.

Can I change code/values while in debugging mode?

In Visual Studio 2010 (Ultimate), is it possible to step through some code, and, if a variable is not correct (e.g. you want to get all records beginning with 'A' but there is none, so you want to try 'B' instead), is it possible to change the code while in debug mode, to do this (change variables while in debug mode)?
It is quite annoying to have to stop debugging, change a value, then debug again and see the result. It'd be much easier to do it all in debug mode, anyway.
Thanks
In the watch window just enter the statement you want executed. For example if you want to set the variable prefix to "B" then just type prefix = "B" and hit enter.
You may also change code while running, however there are a number of limitations to this feature. See Microsoft's Edit and Continue documentation for details: http://msdn.microsoft.com/en-us/library/bcew296c(v=vs.80).aspx.
In the Solution Explorer view, right-click on each reference of References, choose Properties. In the Properties view, sign False to the field of Embed Interop Types. This works for me.
c

Follow program execution through .DLL in hex representation

Is there a way to follow a program's execution through DLL code in hex?
For example, I want to see what sections have just been read when I press a button. It has to work for x64 DLL's.
Thanks!
Yes you load the process into debugger and single step it.
Load the project in visual studio.
Press 'Play' or F5 to start the program in the debugger.
You will need to eventually halt execution sometime so you can start stepping through code or assembly code. You can do this by inserting a breakpoint, or breaking the execution by hitting the break command in the visual studio IDE.
Once halted, you can right click in the code view window, and select "Show Disassembly". Then it will show you the machine instructions.
Also in the watch window in the visual studio debugger, the right click pop up menu has an option to display all variables as hexidecimal. I'm beginning to prefer hex myself lately, because I can see invalid memory patterns easier.
You can use the tool at http://ircdb.org to log function calls arbitrary DLLs.
It's name is SocketSpy, because initially it was created for tracing winsock.dll only, but it does allow you to trace other dlls.
From http://fixunix.com/programmer/95098-tracing-library-dll-calls-win32.html
Use Option->Default Break Point List
Menu to add or remove soft breakpoints
from attached DLLs. Put soft
breakpoints only at function you need
to maximize execution time.
Soft breakpoint means that socketspy
does not stop at this breakpoint, only
log breakpoint information. Hard
breakpoint means that socketspy DOES
STOP at this breakpoint, and
Breakpoint dialog is opened. Specify
what calls should be captured ALL,
FROM EXE FILE or from DLLs (Combobox).
Specify log file File->Open Log File
menu if you want to save function
DLLs' calls into the text file, enable
logging (check box).
Then select a new or already action
process (Select Process button). The
tool can be used in NT/2000/XP only
Alternatively, there is StraceNT, which can trace arbitrary Dlls. It is available for free from http://www.intellectualheaven.com/default.asp?BH=projects&H=strace.htm
I've not used it, but I once stumble upon an Intel tool, which samples the context of the Instruction Pointer, and is able to use symbol files to convert IP to an actual function name... VTune maybe?
I guess there might be other such tools
UPDATE: aka. "statistical profilers"...
Debugging using IDE does not show you the assembly language equivalent of the execution of an IL instruction. You need to write your own hooks to a proper disassembler.

Can VS be made to eval a debug watch even while the application is still running?

Normally in Visual Studio, a watch cannot be evaluated unless the debugger is stopped at a breakpoint. Is there a trick or add-on to make Visual Studio evaluate a watch while the application is still running? For example, evaluate the watch every time execution passes a point in the code while it's still running and without changing the code to insert statements like Debug.WriteLine.
Not sure this is possible, but I thought I'd ask.
Yes, this is possible. Set a breakpoint at the location where you'd want to see the value. Right-click the breakpoint and choose "When Hit...". Tick "Print a message" and write an expression like { value }. The message is displayed in the Output window while your program runs.
I would do that using compiler directives.
#if DEBUG
Debug.WriteLine
#end if
No this is not possible to do. The evaluation feature in Visual Studio is a stack frame based mechanism. That is that every evaluation is done in the context of a given stack frame (as viewed through the stack window). When the program is running the set of stack frames is currently changing and hence it's not possible to do a stable evaluation.
Additionally there are other limitations in the CLR which prevent this from managed code. It's not possible for instance to execute a function unless the debugee process is in a very specific state.

Resources