Debugging Sandbox Code
If you find yourself in a situation when you need to attach to a process from VS 2010, to debug, and you’re code is running in a “sandbox”.
Solution:
You need to attach to the process SPUserCodeService.exe, not w3wp.exe.
SharePoint 2010 hosts sandbox code in a secure service – the user code service. Hence it can monitor resources and make sure the user’s code isn’t performing any action that could compromise the platform.
Source : Microsoft SharePoint 2010 – Expert’s voice in SharePoint.