Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Visual studio 2012 profiling remotely debugged process

Is it possible to profile remotely debugged process?

I have tried using tips from article on remote debugging with VS 2012

which don't help as, when launching profiler, it asks for paths to dll and exe debugged: these paths are not treated as paths on the remote machine even though you apply remote debugging settings(as in the article).

like image 777
Alexandra B. Avatar asked May 21 '14 10:05

Alexandra B.


People also ask

How do I debug a remote process in Visual Studio?

You can attach the Visual Studio debugger to a running process on a local or remote computer. After the process is running, select Debug > Attach to Process or press Ctrl+Alt+p in Visual Studio, and use the Attach to Process dialog to attach the debugger to the process.

How do I run a performance profiler in Visual Studio?

Open the Performance Profiler by choosing Debug > Performance Profiler (or Alt + F2). For more information on using the CPU Usage or Memory usage tool in the Performance Profiler vs. the debugger-integrated tools, see Run profiling tools with or without the debugger.

How do I disable remote debugging in Visual Studio?

05 On the General settings panel, under Debugging, select Off next to Remote debugging setting to disable remote debugging using Microsoft Visual Studio for the selected Azure App Services web application. Click Save to apply the changes.


2 Answers

Unfortunately, that's not possible (at least as I understood by lot of research) directly from Visual Studio IDE and the only possible way for now is using stand-alone profiler.

NOTE: the following applies to Visual Studio 2013, but might be a guideline for older distributions.

Stand-alone profiler let's you profile an application straight from production machine without the need to install all development framework.

This stand-alone profiler is shipped with Visual Studio and there can be found its setup file. I found it in the following folder:

C:\Program Files (x86)\Microsoft Visual Studio 12.0\Team Tools\Performance Tools\Setups\

I found two files: vs_profiler_x64_enu.exe and vs_profiler_x86_enu.exe. I picked the first one, but depends on the destination machine's architecture. Take this file to the destination machine and install it.

Now, on the destination machine, you have to launch the application to profile by the utility VCPrefCmd.exe located in the folder:

C:\Program Files (x86)\Microsoft Visual Studio 12.0\Team Tools\Performance Tools

through command line. So you can add the above path in the environment or just type the following:

"c:\Program Files (x86)\Microsoft Visual Studio 12.0\Team Tools\Performance Tools\VSPerfCmd.exe" /start:sample /output:"c:\report.vsp" /launch:"c:\pathTo\appToProfile.exe"

where:

  • /start is the profiling mode, "sampling" in this case
  • /output pathname of the report to produce
  • /launch your application to profile

now your application will start automatically and you'll do all your work.

Once you are done, close your profiling application and type the following command to the previous command line:

"c:\Program Files (x86)\Microsoft Visual Studio 12.0\Team Tools\Performance Tools\VSPerfCmd.exe" /shutdown

and this will stop the profiling and produce your report.vsp (or whatever you called it) file with all the data.

Now take this produced file to your development machine and provide it to your Visual Studio (open or drag'n'drop) and you'll have your application profile.

While looking forward to complete embedding of "Remote debugging and profiling" in Visual Studio, this procedure might be fair enough.

like image 81
TechNyquist Avatar answered Sep 30 '22 11:09

TechNyquist


Just want to add to this very good answer, that the tools for Visual Studio 2017 are in the following folder:

C:\Program Files (x86)\Microsoft Visual Studio 15.0\Team Tools\Performance Tools\x64

the setup files are in:

c:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\Team Tools\Performance Tools\Setups\

The command for attaching to a running ASP.net application is:

VSPerfCmd.exe /attach:4716 /Crosssession /start:sample /output:report.vsp <br/>

In my case, this did not work on an older windows 7 machine.

But the following one did:

C:\Program Files (x86)\Microsoft Visual Studio 15.0\Team Tools\Performance Tools

VSPerf.exe /attach:4711 /file:report.vspx
VSPerf.exe /status
VSPerf.exe /stop

The resulting VSPX file can then be opened with Visual Studio.

like image 43
cskwg Avatar answered Sep 30 '22 09:09

cskwg