Dotneteer / spectnetide

ZX Spectrum IDE with Visual Studio 2017 and 2019 integration
MIT License
205 stars 27 forks source link

Step through code is not working while debugging #199

Closed hexdump2002 closed 4 years ago

hexdump2002 commented 4 years ago

Hi,

First of all I would like to thank you for assembling this awesome toolset aiding in the zx spectrum development.

I have read almost all documentation at your site and from my understanding spectnetide seems to support stepping through code after setting a breakpoint. In my case this is not the case. I see how after running the program through the "Debug program" command the execution stops at the breakpoint I set but I can't step through code. The step into and step over options in debugging menu are disabled.

So, is this perhaps a future feature? Or I can do this right now? Cheers!

Dotneteer commented 4 years ago

@hexdump2002, step through should work.

If not, it either must be a bug or some issue on your machine. Please, send me a zipped project with some explanations that help me reproduce what you experience so that I can examine and fix this issue.

codingmarmotte commented 4 years ago

@hexdump2002 I have the same issue - I worked around it by opening the Z80 Disassembly window. Once this window is open the step into/step over commands work as expected.

@Dotneteer Hopefully this will help with tracking down/fixing this issue. I am using Visual Studio 2019 Professional on Windows 10, standard 48K Spectrum 'image'

Dotneteer commented 4 years ago

@codingmarmotte, do you place the breakpoint in the source code, or in the Z80 Disassembly window?

codingmarmotte commented 4 years ago

@Dotneteer Hi - Break point in the source code on the first line of your example Z80 code file (i.e. at address 0x8000).

I did a little more testing and it appears to be related to the interupt routine at 0x0038. The flow is as follows:

Not sure if this helps? I have pulled down your source from GH but it has been a long time since I looked at extensions :-)

hexdump2002 commented 4 years ago

Hi again,

I have recorded a little video for you to check what I said. The project as you see is the one created by the plugin without any modifcation, anyway I have uploaded it.

vide: https://streamable.com/ofers4 project: https://gofile.io/d/RqCCWa

Edit: Based on @codingmarmotte answer, I looked into the problema a bit more. I see in the emulator window how step into buttons, etc. are activated now, but shortcuts (F10, F11, etc..) doesn't work. I need to press the button to make it work.

Edit2: To be true, no shourtcut is working for me. Start (ctr-F5), Debug (F5), Step into, out, etc. No shourtcut is working.

If you need me for any testing I'm ready to help as much as I can.

Again, thanks for all you hard work ;)

Dotneteer commented 4 years ago

@codingmarmotte, @hexdump2002, thanks a lot for your help! I try to fix this issue as soon as I can.

Dotneteer commented 4 years ago

@codingmarmotte, @hexdump2002, I've just watched the video, and now I understand what your problem is. You can still use the Step-Into, Step-Out, and Step-Over functionality, but not from the Debug menu of Visual Studio. This article discribes how you can access them from the ZX Spectrum emulator window: https://dotneteer.github.io/spectnetide/getting-started/zx-spectrum-emulator-window-2#article.

While the focus is in any of the ZX Spectrum IDE tool windows, you can use the F5, Ctrl+F5, F10, F11, and F12 hotkeys. However, if you're in the code editor, these hotkeys do not work :-(

Unfortunately, I can't do to much to allow using the commands from the Debug menu of the VS IDE. The situation is the following:

Visual Studio Extensibility is not easy, as many things are undocumented, and not really straighforward. Such an issue is to override the the commands in the Debug menu. To do that, you need to implement a so-called custom project system in Visual Studio and a custom debugger.

When developing SpectNetIDE, I'd been spending weeks struggling with the lack of documentation. Finally, I decided to create my own custom project, but not a custom debugger (not one that integrates with the VS IDE). Instead, I implemented a separate debugger with the functionality you can access right now. Unfortunately, this implementation does not allow integration with the Debug menu of VS.

For a short time, I had a contributor, who started developing a custom debugger for SpectNetIDE. Last time I had a call with him about 7-8 months ago, when he demonstrated some initial solution. Alas, I havn't heard from him since that time.

Sorry for telling you this answer, it's a nail under my skin. If you have any idea, or someone who would contribute to solve this issue, I'm happy to listen to you!

hexdump2002 commented 4 years ago

No problem @Dotneteer, happy to be of any help.

I have no experience creating visual studio extensions, so, I think I wont be able to help here.

Anyway, would it be possible at least to have shortcuts to start debugging? It is a bit ackward the need to do right click and debug everytime. The debugging would be better with shortcuts but hey! it is nice to have it the way it is now.

This is what I get when i try to assign a shourtcut to spectnetide actions:

imagen

Would be really nice at least to have the run and start debugging commands assigned to keys. I mean, the commands that we fire up from the contextual menu when we do right click on a z80asm file.

Cheers!

Dotneteer commented 4 years ago

@hexdump2002, it's a good idea. Let me check if I can do this!

Dotneteer commented 4 years ago

@hexdump2002, @codingmarmotte, here is a private build that allows you assign custom key bindings to the emulator key.

Spect.Net.VsPackage.zip

Do not forget to rename this file to .vsix so that you can install it!

With this feature, you can even assign those you use with other tools (such as F5, Ctrl+F5, F10, and so on). Unfortunately, I can't setup SpectNetIDE to use the well-known keys as defaults, however, you can do it manually after installing SpectNetIDE.

I updated the documentation with this feature: https://dotneteer.github.io/spectnetide/getting-started/zx-spectrum-emulator-window-2#article

Do not forget, the new shortcuts override previous ones! Thus, for example, if you assign Ctrl+F5 for starting the ZX Spectrum Emulator, you cannot use this command later for running a C# program unless you assign it back to its original command.

hexdump2002 commented 4 years ago

Awesome! Will test it as soon as I get home. Thanks!

hexdump2002 commented 4 years ago

Ok, I have tested it and it is true that I could assign custom shortcuts to the different emulator buttons. This way we will be able to debug nicely :). Thanks!

But... there's something that still breaks my workflow a bit. And it is to always have to right click on the code file and trigger the "Run/Debug program" command. It can be seen here. imagen

Can we have shortcuts for these two menu options? This was my first request beside being able to debug. Could you do that? With this change, Spectnetide will be my daily driver for zx spectrum development.

Cheers!

Dotneteer commented 4 years ago

@hexdump2002, there are two commands for running and debugging a program. First, in the context menu, as in the figure above. Second, in the context menu of the project node. While the first group of commands does not have a shortcut, the second has:

shortcuts

So, you can run the default program with Ctrl+M, Ctrl+R, and debug it with Ctrl+M, Ctrl+R. Of course, before that, you should use the Set as defalut code file command to mark one of the code files as default.

As you may have multiple code files in a single project, I cannot assign shortcut to the first kind of commands, for the system would not know which code file to run. Using a default code file solves this issue.

Nonetheless, right now, you cannot customize the shortcut for these commands. Soon, I will send you a new private build with the fix :-)

Dotneteer commented 4 years ago

@hexdump2002, here is the private build with the fix I mentioned above:

Spect.Net.VsPackage.zip

Now, you can customize the shortcuts for ZXSpectrumIDE.DebugProgram, and ZXSpectrumIDE.RunProgram commands, too.

hexdump2002 commented 4 years ago

Well, I finally have tried last private build you sent me and ussability is much better now . It is a pleasure to press a combination of keys and run the proram in debug on the emulator and be able to step into, out and over with shortcuts.

The only downside is that I have to configure the keys everytime I want to do same speccy coding because I extensively use dot net core. But well, it is not too bad IMO :)

Nice work!

Dotneteer commented 4 years ago

Released in v2 Preview 9.