How to attach to a process and debug the code that doesn't build?

593 Views Asked by At

I'm working on a project and trying to fix a bug found in the system. The code that I have access to doesn't build (it's a huge project with a lot of dll files, some of which are missing on my workspace). I have access to the part of the code I'm trying to debug, but can't build it. So I started the compiled .exe file and attached to it in VS. When I set a breakpoint in the code, it's disabled and says No symbols have been loaded for this document. So my question is, what additional info/files is the debugger looking for? I'm assuming it's looking for the pdb file for that specific assembly, which doesn't exist on my machine.

When I try to attach to the exe file, I get this warning:

enter image description here

3

There are 3 best solutions below

1
On BEST ANSWER

what additional info/files is the debugger looking for? I'm assuming it's looking for the pdb file for that specific assembly, which doesn't exist on my machine.

Your assumption is correct.

Some ways you can solve your problem are:

  • Obtain the location of a symbol server that has your PDB, and configure VS to automatically download the PDBs.
  • Obtain the PDB via some other means.
  • Figure out how to build it yourself; build your own PDB.
  • Ask whomever did build it to debug the problem for you. It's probably their bug, so make them do the work.
  • Debug the problem by reading the sources and simulating the execution of the program in your head. When you come across code that doesn't do what it should in the simulation, that's your bug.
  • Debug the problem in the debugger, reading the assembly code instead of the sources.
0
On

It is looking for the pdb file, without it you won't be able to debug. I don't know the details of your situation but making it build on your system is probably the best approach. In my experience this situation is usually due to taking too deep a node in the source tree. While working on larger projects, taking a more shallow node in source control has dramatically simplified my life. When you're working on a project like that you gotta be able to make it build, otherwise you probably won't get anywhere.

If the thing you're remote debugging comes from an official build it won't have pdb files so there's no simple work around like finding the drop folder and copying the pdb over.

2
On

I don't understand what will you do by running any executable. You said your code doesn't build. So running any executable cannot help you. You code can't compile is that what you are facing than share the build errors or compile errors? For missing assemblies - remove from project reference and comment out code in your project that may refer to any such assemply. Can you build your code after that?

Once you can build code then you can go ahead debugging or attaching any executable.

Hope this helps!