.NET Forum / .NET Framework / New Users / July 2007
attach to process not started in debug mode?
|
|
Thread rating:  |
Les Caudle - 03 Jul 2007 16:35 GMT Is there a way to attach to a process of a .NET app not started in debug mode?
I'm having a problem with an app on a remote server, with a 3rd party .net object I dont' have source files for anyway.
I'd like to be able to just attach to the hung process and get some debug info.
Is this possible? -- Thanks in advance, Les Caudle
Peter Duniho - 03 Jul 2007 17:15 GMT > [...] > I'd like to be able to just attach to the hung process and get some > debug info. > > Is this possible? Yes.
Jeffrey Tan[MSFT] - 04 Jul 2007 03:44 GMT Hi Les,
Based on my understanding, I assume your "debug mode" means the application debug build. That is your application components is built in release configuration.
Yes, you can use any debugger to attach a release build application as long as you have enough priviledge/permissions on remote machine. Debugger will use .Net/Win32 debugging service to attach the process, so it does not matter if the target is debug or release build.
Normally, release build is not special comparing to debug build. It will just perform optimize for the generated code. For example, if there is any local variables can be eliminated, the release build will discard them in generated assemblies. Below link talks about the C/C++ code difference between debug and release build, however, the idea is the same for .Net compiler: "Debug versus Release build" http://www.dotnetheaven.com/Uploadfile/mahesh/DebugaRelease05192005033225AM/ DebugaRelease.aspx
Finally, to debug 3rd party assembly, if the assembly is not obfruscated, I would recommend you to download Reflector from the link below and use the Reflector to examine the source code of it. Due to the strong metadata in the .Net assembly, it is possible for Reflector tool to decompile the assembly code for review.(A extreme example is .Net Framework assemblies, which can be decompiled in Reflector for learning) http://www.aisto.com/roeder/dotnet/
Hope this helps.
Best regards, Jeffrey Tan Microsoft Online Community Support ================================================== Get notification to my posts through email? Please refer to http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif ications.
Note: The MSDN Managed Newsgroup support offering is for non-urgent issues where an initial response from the community or a Microsoft Support Engineer within 1 business day is acceptable. Please note that each follow up response may take approximately 2 business days as the support professional working with you may need further investigation to reach the most efficient resolution. The offering is not appropriate for situations that require urgent, real-time or phone-based interactions or complex project analysis and dump analysis issues. Issues of this nature are best handled working with a dedicated Microsoft Support Engineer by contacting Microsoft Customer Support Services (CSS) at http://msdn.microsoft.com/subscriptions/support/default.aspx. ================================================== This posting is provided "AS IS" with no warranties, and confers no rights.
Jeffrey Tan[MSFT] - 09 Jul 2007 03:23 GMT Hi Les,
Have you reviewed my reply to you? Does it make sense to you? If you still need any help or have any concern, please feel free to tell me, thanks.
Best regards, Jeffrey Tan Microsoft Online Community Support ================================================== Get notification to my posts through email? Please refer to http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif ications.
Note: The MSDN Managed Newsgroup support offering is for non-urgent issues where an initial response from the community or a Microsoft Support Engineer within 1 business day is acceptable. Please note that each follow up response may take approximately 2 business days as the support professional working with you may need further investigation to reach the most efficient resolution. The offering is not appropriate for situations that require urgent, real-time or phone-based interactions or complex project analysis and dump analysis issues. Issues of this nature are best handled working with a dedicated Microsoft Support Engineer by contacting Microsoft Customer Support Services (CSS) at http://msdn.microsoft.com/subscriptions/support/default.aspx. ================================================== This posting is provided "AS IS" with no warranties, and confers no rights.
Les Caudle - 09 Jul 2007 14:02 GMT Jeffrey - I've got a box at a remote ISP where I may need to debug the app from time to time. I can debug my code, but there is a 3rd party tool I'm using, and this problem only seems to happen in the field when a method of that tools is called.
I installed Visual Studio Express, but there doesn't seem to be any ability to 'attach to process'.
I should have put the full Visual Studio on it before I took it out there.
So, with the tools I can easily install remotely, is there a way to attach to the process of the C# app, and be able to debug it in some useful manner (esp attach to a hung thread)?
Thanks, Les Caudle
>Hi Les, > [quoted text clipped - 22 lines] >================================================== >This posting is provided "AS IS" with no warranties, and confers no rights. Jeffrey Tan[MSFT] - 10 Jul 2007 04:06 GMT Hi Les,
Thank you for the feedback.
Sorry, but I do not think I understand your question completely. Is your problem caused by VS Express version or 3rd party libraries? If it is caused by 3rd party code, can you be specific about what problem is caused by 3rd party code during debugging? Thanks.
Yes, Visual Studio Express debugger does not support the "Attach to Process" function. You need "Standard Edition" above to get the dynamic attaching function: "How to: Attach to a Running Process " http://msdn2.microsoft.com/en-us/library/c6wf8e4z.aspx
Do you want to perform remote debugging with your application/process running on remote machine? That is you do not want to install the VS debugger on remote machine. Does this problem has anything to do with your original "debug mode" question? If you want to know how to perform remote debugging with VS2005, please refer to the official tutorials below: http://support.microsoft.com/kb/910448 http://blogs.msdn.com/yosit/archive/2003/06/20/9024.aspx http://msdn2.microsoft.com/en-us/library/bt727f1t(VS.80).aspx
Finally, I have written a blog entry regarding how to debug crash/hang in a production environment with windbg/Process Explorer, it may make sense to you: "How to debug application crash/hang in production environment?" http://blogs.msdn.com/msdnts/archive/2006/11/24/how-to-debug-application-cra sh-hang-in-production-environment.aspx
If I have misunderstood your concern, please feel free to let me know, I will work with you, thanks.
Best regards, Jeffrey Tan Microsoft Online Community Support ================================================== Get notification to my posts through email? Please refer to http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif ications.
Note: The MSDN Managed Newsgroup support offering is for non-urgent issues where an initial response from the community or a Microsoft Support Engineer within 1 business day is acceptable. Please note that each follow up response may take approximately 2 business days as the support professional working with you may need further investigation to reach the most efficient resolution. The offering is not appropriate for situations that require urgent, real-time or phone-based interactions or complex project analysis and dump analysis issues. Issues of this nature are best handled working with a dedicated Microsoft Support Engineer by contacting Microsoft Customer Support Services (CSS) at http://msdn.microsoft.com/subscriptions/support/default.aspx. ================================================== This posting is provided "AS IS" with no warranties, and confers no rights.
Les Caudle - 10 Jul 2007 14:17 GMT Jeffrey - I ran into a problem where a 3rd party .NET dll would hang on a method call, but only on my production server.
I wanted to be able to debug this, and tell the 3rd party tool supplier where his code was hanging.
I thought I might be able to debug if I installed VS Express on the box, and that is what I'm trying to figure out - the best way to debug something like this.
The 3rd party tool supplier has already found the problem, but I'm interested in a solutioni in case this comes up again.
Thanks, Les Caudle
>Hi Les, > [quoted text clipped - 51 lines] >================================================== >This posting is provided "AS IS" with no warranties, and confers no rights. Jeffrey Tan[MSFT] - 11 Jul 2007 03:48 GMT Hi Les,
Thank you for providing the background infomation!
Yes, you may install the VS Express on the production server and use the VS debugger to launch the application waiting for the hang. When the hang appears in the debuggee, you may press Ctrl+Break in VS Express debugger to stop the hang application. In the Call Stack window, you may get the hang call stack of your application(remember to switch to the hang thread in the Threads window). Note: to get the full stack trace of the hang, you may need to disable the "Just My Code" feature of VS2005 debugger(the default setting is on). Please refer to the link below for details: "How to: Step Into Just My Code" http://msdn2.microsoft.com/en-us/library/h5e30exc.aspx "Is 'Just my Code' for you?" http://blogs.msdn.com/greggm/archive/2004/07/29/201315.aspx
Actually, due to the big footprint of Visual Studio, it would be better to use windbg or Process Explorer to troubleshoot the hang problem. My blog entry below demonstrated the detailed steps: "How to debug application crash/hang in production environment?" http://blogs.msdn.com/msdnts/archive/2006/11/24/how-to-debug-application-cra sh-hang-in-production-environment.aspx
Hope this helps.
Best regards, Jeffrey Tan Microsoft Online Community Support ================================================== Get notification to my posts through email? Please refer to http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif ications.
Note: The MSDN Managed Newsgroup support offering is for non-urgent issues where an initial response from the community or a Microsoft Support Engineer within 1 business day is acceptable. Please note that each follow up response may take approximately 2 business days as the support professional working with you may need further investigation to reach the most efficient resolution. The offering is not appropriate for situations that require urgent, real-time or phone-based interactions or complex project analysis and dump analysis issues. Issues of this nature are best handled working with a dedicated Microsoft Support Engineer by contacting Microsoft Customer Support Services (CSS) at http://msdn.microsoft.com/subscriptions/support/default.aspx. ================================================== This posting is provided "AS IS" with no warranties, and confers no rights.
Les Caudle - 11 Jul 2007 13:46 GMT Jeffrey - do I need to have the full source code on the production box, and start the program as I would on my development box - or can I somehow debug just the program (compiled in debug mode)?
Thanks, Les Caudle
>Hi Les, > [quoted text clipped - 43 lines] >================================================== >This posting is provided "AS IS" with no warranties, and confers no rights. Jeffrey Tan[MSFT] - 12 Jul 2007 03:37 GMT Hi Les,
Thank you for the feedback.
This depends on your requirement. There are 2 types of debugging: source code level and binary level(without source code). So, do you have the source code for the 3rd party product?
If you have source code for it, you also have to obtain the private symbol file from the 3rd party vendor. The debugger has no knowledge to determine if a set of source files are associated with which assembly, so it must first load the private symbol file for the symbol. The private symbol file internally contains the source code path in it. So, you should set the symbol path to the private symbol file in Tools ->Options ->Debugging ->Symbols. Note: this debugging has nothing to do with debug or release mode. As I stated in the original post, the debug mode only does few/no optimize with the generated assembly. It has nothing to do with debugging.
It is always good to have source code for debugging. However, since the assembly is a 3rd party product, you may not have source code for it. That is the reason of using binary level debugging.(Another example is debugging .Net Framework BCL, whose source code is also not available) Even you do not have source code, you may just perform binary level debugging with it, since the .Net assembly metadata can self-describe its code/data. So you can still get the full stack trace of this hang. The stack method will be displayed in call stack window by querying the metadata.
I am not sure if my explanation has resolved your confusion. If I have misunderstood your key concern, please feel free to tell me and explain your concern in details. Thanks.
Best regards, Jeffrey Tan Microsoft Online Community Support ================================================== Get notification to my posts through email? Please refer to http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif ications.
Note: The MSDN Managed Newsgroup support offering is for non-urgent issues where an initial response from the community or a Microsoft Support Engineer within 1 business day is acceptable. Please note that each follow up response may take approximately 2 business days as the support professional working with you may need further investigation to reach the most efficient resolution. The offering is not appropriate for situations that require urgent, real-time or phone-based interactions or complex project analysis and dump analysis issues. Issues of this nature are best handled working with a dedicated Microsoft Support Engineer by contacting Microsoft Customer Support Services (CSS) at http://msdn.microsoft.com/subscriptions/support/default.aspx. ================================================== This posting is provided "AS IS" with no warranties, and confers no rights.
Les Caudle - 12 Jul 2007 14:09 GMT Jeffrey - I do not have the source to the 3rd party tool used in my .NET app.
Without source to this, and without loading all my source code scattered in different directories on drive letters that don't exist on the production server, what are the steps to try to debug my code if it hangs calling a method of the 3rd party tool?
Is there a way to attach to a process in VS Express, without having the source code, just an exe and dll's?
Thanks, Les Caudle
>Hi Les, > [quoted text clipped - 48 lines] >================================================== >This posting is provided "AS IS" with no warranties, and confers no rights. Jeffrey Tan[MSFT] - 13 Jul 2007 03:18 GMT Hi Les,
Thanks for your feedback.
As I already confirmed in the original reply, VS express debugger does not support the "Attach to Process" function, this has nothing to do with whether we have source code or not. You need "Standard Edition" above installing on your production server to attach to your running Exe.
Alternately, you may download the free debugger windbg from Microsoft site to perform the debugging without installing Visual Studio Standard Edition. I have completely written down the detailed steps in the blog entry below, have you read it? "How to debug application crash/hang in production environment?" http://blogs.msdn.com/msdnts/archive/2006/11/24/how-to-debug-application-cra sh-hang-in-production-environment.aspx
Debugging hang is somewhat easy, since (normally) the call stack will reveal the root cause of the hang position. Also, .Net metadata allows the debugger to display the call stack without getting the symbol files.
Is this clear for you? If there is still any concept unclear, please feel free to point it out. Thanks.
Best regards, Jeffrey Tan Microsoft Online Community Support ================================================== Get notification to my posts through email? Please refer to http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif ications.
Note: The MSDN Managed Newsgroup support offering is for non-urgent issues where an initial response from the community or a Microsoft Support Engineer within 1 business day is acceptable. Please note that each follow up response may take approximately 2 business days as the support professional working with you may need further investigation to reach the most efficient resolution. The offering is not appropriate for situations that require urgent, real-time or phone-based interactions or complex project analysis and dump analysis issues. Issues of this nature are best handled working with a dedicated Microsoft Support Engineer by contacting Microsoft Customer Support Services (CSS) at http://msdn.microsoft.com/subscriptions/support/default.aspx. ================================================== This posting is provided "AS IS" with no warranties, and confers no rights.
Jeffrey Tan[MSFT] - 17 Jul 2007 04:05 GMT Hi Les,
Have you reviewed my reply to you? Does it make sense to you? Is your problem resolved? If you still need any help or have any concern, please feel free to feedback, thanks.
Best regards, Jeffrey Tan Microsoft Online Community Support ================================================== Get notification to my posts through email? Please refer to http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif ications.
Note: The MSDN Managed Newsgroup support offering is for non-urgent issues where an initial response from the community or a Microsoft Support Engineer within 1 business day is acceptable. Please note that each follow up response may take approximately 2 business days as the support professional working with you may need further investigation to reach the most efficient resolution. The offering is not appropriate for situations that require urgent, real-time or phone-based interactions or complex project analysis and dump analysis issues. Issues of this nature are best handled working with a dedicated Microsoft Support Engineer by contacting Microsoft Customer Support Services (CSS) at http://msdn.microsoft.com/subscriptions/support/default.aspx. ================================================== This posting is provided "AS IS" with no warranties, and confers no rights.
Les Caudle - 17 Jul 2007 20:18 GMT Jeffrey - thanks for you detailed info.
I didn't end up having to debug the 3rd party tool, they fixed their problem, but with your info I'll be able to do that if another problem arises.
Thanks, Les Caudle
>Hi Les, > [quoted text clipped - 23 lines] >================================================== >This posting is provided "AS IS" with no warranties, and confers no rights. Jeffrey Tan[MSFT] - 18 Jul 2007 03:33 GMT Hi Les,
Thank you for confirming the status.
Ok, if you need further help, please feel free to post, thanks.
Best regards, Jeffrey Tan Microsoft Online Community Support ================================================== Get notification to my posts through email? Please refer to http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif ications.
Note: The MSDN Managed Newsgroup support offering is for non-urgent issues where an initial response from the community or a Microsoft Support Engineer within 1 business day is acceptable. Please note that each follow up response may take approximately 2 business days as the support professional working with you may need further investigation to reach the most efficient resolution. The offering is not appropriate for situations that require urgent, real-time or phone-based interactions or complex project analysis and dump analysis issues. Issues of this nature are best handled working with a dedicated Microsoft Support Engineer by contacting Microsoft Customer Support Services (CSS) at http://msdn.microsoft.com/subscriptions/support/default.aspx. ================================================== This posting is provided "AS IS" with no warranties, and confers no rights.
Free MagazinesGet these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...
|
|
|