-
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
Fix the issue where breakpoints in the source code could not be hit even after generating PDBs and the source project #3623
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
…ven after generating PDBs and the source project.
|
Humor me for a second - why not flip the noLogo default value? |
|
Can you please provide a reproducer/example? If the issue is an off by one error introduced by the additional line, then the fix is something else. Thanks! |
|
Using the master branch from my repository: https://github.com/sonyps5201314/ILSpy With ILSpy compiled from the following commit (i.e., the version without the fix in this PR): If you decompile However, if you use the version from the following commit (which includes the fix from this PR): The issue where breakpoints jump to temporary files no longer occurs. Here is a demonstration video: |
This is the expected behavior of Visual Studio, of course, the debugger will use/extract the source code that matches the generated sequence points in the PDB. This is the reason why we embed the source code in the PDB in the first place. Also, why would you want to use a PDB containing decompiled source code? You have the source code and should actually just use the PDB generated by the C# compiler, which would give you the best debugging experience. The PDB generator is useful when you don't have the source code, but still need to debug something. The sequence points in the generated PDB are always inferior to the ones generated by the C# compiler, because we cannot rely on |
|
@sonyps5201314 you might want to look up the various open issues on pdbgen that should give you an idea about the limitations. |
This not how this feature is supposed to be used. You either generate a PDB OR you export a project and RECOMPILE that WITH DEBUG INFO. These are two distinct features and the way you are using it is NOT the expected usecase. |
|
If you want such behavior you can always write your own tool on top of the decompiler engine and use that. But this is NOT A BUG and the INTENDED/EXPECTED behavior of ILSpy as well as Visual Studio. |
You seem unfamiliar with the VS debugger. If a matching source file exists locally, it will not extract the file from inside the PDB. It only extracts from the PDB when the local file is missing or does not match.
If ILSpy were perfect, I wouldn't have needed to submit so many PRs recently. currently, the VS projects decompiled by ILSpy simply cannot be recompiled into DLLs. If they could, why would I bother settling for the next best thing and using these generated PDBs?
Then how do you explain that the breakpoints work correctly after I delete that comment line? Please don't rush to answer—please watch my video first. |
|
The breakpoints work because the files are identical as soon as you delete the line, but as I said, this is not the expected usecase, you don't need to export a project, if you have a PDB with embedded source code. Why so complicated? Just tell Visual Studio to load the generated PDB and set the breakpoints in the correct file! As I said: if you want custom behavior write a custom tool, but do not force your expectations onto everybody else! |
|
If I don't export the full VS project, how can I perform a global analysis of the entire codebase? If I set breakpoints in the temporary files embedded in the PDB, those files are generated in a temporary folder. Once the files are cleared, the breakpoints become invalid. This is also not conducive to system management or long-term maintenance. |
My point is simply that this change leads to a better and more consistent debugging experience for users. I am honestly confused as to why you would disagree. It essentially just amounts to removing a single line of advertisement. People who appreciate ILSpy won't stop loving this excellent product just because that line is missing. However, the presence of that extra line causes a disjointed experience, creating a disconnect between the code used for development and the code used for debugging. |
|
If you are interested in getting a better experience, I believe there are other features in Visual Studio that will help you debug the project. Would you be willing to describe your setup in a separate discussion? Once I understand how you actually set up your project, I am sure I will be able to tell you what feature in VS to use. Please describe:
In this screenshot I have a project with a reference to RestSharp.dll with a PDB generated by ILSpy. Visual Studio automatically detects it and I can browse the contents of the PDB and add breakpoints in advance. Note: the breakpoints persist across debugging sessions! |
Exactly, that is precisely where the inconvenience lies. These file and directory structures only exist during the debugging session. However, as developers, we spend the vast majority of our time analyzing code in a non-debugging state—we only debug when a bug actually appears. |
|
The reason you might not feel bothered by this right now is likely because the DLLs you are debugging contain relatively few source files. However, when you debug a massive application like Furthermore, Visual Studio's symbol search capabilities are significantly weaker during debugging than during normal development. Symbols within these temporary files—which are loaded only during debugging—are not indexed, so you cannot find them using |
|
I discovered that |



As mentioned in the title, the source code embedded in the PDB starts with the line
// PDB and source generated by ICSharpCode.Decompiler. This causes a mismatch with the version in the source project generated during DLL decompilation.Consequently, even when breakpoints are set in the source code, the debugger hits them in a temporary file (e.g.,
%TEMP%\.vsdbgsrc\...\ModelProviderApiBase.cs) instead of the file in the C# project directory (e.g.,Microsoft.VisualStudio.Copilot.Core\...\ModelProviderApiBase.cs). This causes significant inconvenience for debugging and code analysis.