VSCode Debug Does Not Display Module Code #8973
-
Verified issue does not already exist?I have searched and found no existing issue What error did you receive?There is no error and I can step through the code. The variables/watch and call stack update with each execution step. However, the tab that opens in VSCode to display the module code as we step through it remains empty. I have another bug to report. Not being able to see the code as I step through it makes it harder for me to help identify the source of the issue in the module. Steps to Reproduce
Please confirm that you are running the most recent version of dbatools
Other details or mentionsI notice a binary module. Is there a way to update the module to allow VSCode to display the code? What PowerShell host was used when producing this errorVS Code (integrated terminal) PowerShell Host Version
SQL Server Edition and Build numberNA .NET Framework Version.NET 7.0.5
|
Beta Was this translation helpful? Give feedback.
Replies: 8 comments 7 replies
-
Short answer is no because the PowerShell debugger cannot "jump" into a compiled DLL library. |
Beta Was this translation helpful? Give feedback.
-
@wsmelton Darn. Is there a work around? A "debug" module that comes from the same code used for the binary module? Is there any concept of adding debug definitions to a module? |
Beta Was this translation helpful? Give feedback.
-
Not sure if this applies, but it looks relevant. |
Beta Was this translation helpful? Give feedback.
-
Okay, so a clone is the way to go. One step closer to getting entangled in dbatools for fun, not just work. I'm a DBA, will I just be able to clone and run? Do I need to build and deploy the binary module? (It's been about 10 years since I compiled something.) |
Beta Was this translation helpful? Give feedback.
-
I'm not sure I understand. Does this sound correct?
|
Beta Was this translation helpful? Give feedback.
-
Thanks. We had Solarwinds. I think it's only a matter of time before a foreign government sees a DBATools binary or obfuscated dat file as an opportunity. There's no way I can review all the code in the module, but I felt better knowing the code was public. Somebody would notice an issue eventually. I did look through most of the code I used. Can I be sure the binary you signed is the binary you want me to have? |
Beta Was this translation helpful? Give feedback.
-
FYI The reason I wanted to step through the code is to figure out why I was getting debug messages from DBATools. I finally figured out it was F8. I enable debug for my code and temporarily turn it off when importing or running DBATools stuff. (I like the DBATools debug messages, but debug/verbose on module loads and cmdlet executes using 20 threads....) There are no DBATools debug messages when I use F5. With F8, I get debug messages no matter what preferences I set in my function. This might be a VSCode bug or feature request related to F8. I found a fascinating article about running code in the context of a module. https://seeminglyscience.github.io/powershell/2017/09/30/invocation-operators-states-and-scopes I tried it out to see if I could examine if the module was using unexpected preferences.
The results for the script module are the same with f5 and f8. For the binary module, I see the error because Get-Module did not return the session state for the module. (I think Pester will not work on the binary module.)
Anyway, that's probably too much information. |
Beta Was this translation helpful? Give feedback.
-
I've been struggling with this as well since the 2.0 update... When debugging the 1.x versions, stepping into one of the functions would jump you to the allcommands.ps1 file; this seems to have been left out of the 2.x releases. For the casual debugger like me isn't familiar enough to the code to dare actually contribute to the project (yet), being able to debug without cloning was super convenient. From what I've seen of the recent changes and after reading this thread, it looks like cloning the repo is the best/only way to debug reliably now. Am I interpreting that correctly? |
Beta Was this translation helpful? Give feedback.
i probably should make a build.ps1 work but it's SUCH a headache to do because of the way SMO works. if you look in the /build directory in dbatools.library, you can see the pain