View the CLR Running code and debug the clr code

Source: Internet
Author: User

View the CLR Running code and debug the clr code

The SOS (Son of Strike) debugging extension allows us to view the CLR Running code during the debugging process. SOS. dll is installed along with. NET. For. NET 4.0, the position of SOS. dll is C: \ Windows \ Microsoft. NET \ Framework \ v4.0.30319 \ SOS. dll.

 

□Install Debugging Tools for Windows

 

Install the debugging tool before using SOS. Find the resource to be downloaded in "Standalone Debugging Tools for Windows (WinDbg)" And download an executable file named "sdksetup.exe.

→ Double-click to run
→ Select the installation location and click "Next" several times to go to the "Select the features you want to install" Page
→ Select "Debugging Tools for Windows" and click "Install"

 

□Use SOS debugging Extension

 

→ Right-click Project Properties
→ Select "enable local code debugging" under "debug"

→ Save
→ Place a breakpoint somewhere in the Code and click "start"
→ Wait until the program runs to the breakpoint and click "debug" -- "window" -- "instant". In the "instant window", enter the following command to load the SOS debugging extension:

Note: Due to the first loading and use, it may take several minutes for the program to run at the breakpoint)
→ Run the following command to view all threads managed by CLR in the process:


□Other functions of SOS debugging Extension

 

Using the SOS debugging extension can also help us do the following:
○ View object destruction
○ View memory leakage
○ Viewing the object generation
......

For more information, here.


How to enable CLR debugging for connections

These steps are not required if you debug only T-SQL database objects. To debug multi-tier database applications, you must have enabled project debugging. For more information, see How to: enable SQL debugging for projects. You must have enabled application debugging for the selected database connection. For more information, see How to: Enable multi-layer debugging. Note that the CLR assembly must be able to run on SQL Server. For more information, find options that support clr in SQL Server 2005 books online. Note that once debugging is started, it is too late to change the settings in "server resource manager. Changes made in "server resource manager" will take effect only after the next debugging session starts. Note that the displayed dialog box and menu command may be different from the description in "help", depending on the current settings or version. To change the settings, select "Import and Export Settings" from the "Tools" menu ". For more information, see Visual Studio settings. Enable SQL/CLR debugging and open "server resource manager ". In "server resource manager", right-click the connection you want to debug and select "allow SQL CLR debugging ". This setting enables SQL CLR debugging for all connections on the server. A message box appears, with a warning: "SQL CLR debugging will stop all hosting threads on the server. Do you want to continue ?". When debugging SQL CLR database objects, if execution is interrupted, all threads on the server will be interrupted, thus affecting other users. Therefore, SQL CLR applications should not be debugged on the finished server. Click Yes to enable debugging.

For myeclipse breakpoint debugging, You need to observe the view to see how the program runs?

Go to the Debug view,
There is a Debug window in the upper left corner, which is used to track the lines of code running during debugging. Press F6 to run the current line and continue to run;
There is a Variables window in the upper right corner. This window is used to view the values of Variables or objects in the program. You can see whether the values of Variables or objects are what you want;
The code window is in the middle. You can see how the program runs during debugging;
The following figure shows the output value of a printed variable on the console;
Debugging is enough to see these windows.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.