1

I see that with the 'Attach to Process', one can debug the process by setting up break point in Visual Studio IDE.

I think it's pretty cool, and I'm curious what's the mechanism that enables it. I also found that gdb and Mac's Xcode supports the technology.

  • Q1 : Can anyone explain how does this work? How can the process mapped to a breakpoint in an IDE or gdb environment?
  • Q2 : Are there other compiler/debugger options than /Zi or -g (adding debug info)?
  • Q3 : Is this the way to debug dll (dynamic library)?

ADDED

I found this one with MSDN - http://msdn.microsoft.com/en-us/library/c6wf8e4z.aspx

prosseek
  • 182,215
  • 215
  • 566
  • 871
  • 2
    Can you expand on exactly what you want to know? "How does it work?" is rather vague... – Oded Jan 18 '11 at 16:50

2 Answers2

2

The most common scenario I know of is using a browser to debug web code. In these cases, you start Visual Studio in debug mode and then attach to the browser and call the page in question. When the page is called it starts running the code in the debugger. Essentially, the debugger watches the process and when it hits code in VS, it starts debugging.

The same is true with other applications that are calling code you are running in Visual Studio. When you cross the boundary to the code, the debugger catches the call and starts running code in VS.

Marc Gravell
  • 1,026,079
  • 266
  • 2,566
  • 2,900
Gregory A Beamer
  • 16,870
  • 3
  • 25
  • 32
0

I use it fairly frequently when developing plugins for existing applications (Maya, Reaper, etc). As a general rule, plugins can't be run independently, so in order to debug them I have to run the host program and use "Attach to Process" to run the debugger on my plugin, at which point I can set breakpoints and all that other debugging goodness. You need to have debugging symbols and al that for the plugin, but you don't need to have them for the host application.

phoff
  • 173
  • 1
  • 10