If you want to debug an Arduino sketch on a classic AVR board such as the Arduino Uno R3 or Arduino Mega 2560, there is now a solution: PyAvrOCD. For all the classic AVR chips, including the ATtinys, but excluding the USB chips, there exist now Arduino board packages which support debugging. You need to buy a debugger/programmer such as SNAP or you can use an UNO for debugWIRE targets.
I am working on extending this to all UPDI targets and to USB MCUs such as the ATmega32U4. It might take some time, though.
Thanks for all your excellent work on this initiative @fogg! I've been very happy to see the addition of support for using the Arduino IDE 2.x debugger with AVR targets!
Are you going to be doing this via your own fork of the "Arduino AVR Boards" platform, or through some other platform? I know there is an existing platform that provides more comprehensive support for the USB AVR chips:
That project is framed as being a project for leveraging the USB bridge chip on the UNO R3 and Mega boards, but it ended up also being a general purpose platform for the ATmega8U2/16U2/32U2/32U4, AT90USB82/162.
NicoHood isn't very active anymore, so I'm not sure what the chances are of upstreaming, but it might at least serve as the base for a hard fork if that doesn't happen.
I think the best way would be to come up with an independent USB core for the 16U4 and 32U4, similar to what MCUdude offers. I also had a look at the different USB MCUs and bootloaders. And the U2s are different enough to justify a different core.
My own work on extending the “Arduino AVR Boards” is a possibility if it is integrated into the mainstream Arduino core. After looking at what is going on in the forums, I realized that I am not prepared to provide the kind of maintenance you do. In particular, my fork would muddy the waters of who is responsible for what. So, if you think PyAvrOCD should be added to the Arduino core, I am happy to deliver. Otherwise, we should leave it as it is.
I personally would love to see debugger support in the official "Arduino AVR Boards" platform. However, I'm not in the project manager type of role for that project to be able to make a determination either way. I can't speak for the people who are in that role, but I think that we all can see clearly just from looking at Arduino's projects that other projects (e.g., the Zephyr-based platforms) are getting priority for allocation of finite development resources. So it is probably a long shot for this type of significant change to be made to the platform. You are of course very welcome to submit a pull request if you like. I just wouldn't have too strong of expectations for it to be merged. But there is value even in pull requests that aren't merged in that the code is still accessible for the community to use, and the presence of the pull request in such a prominent repository can bring more attention to your work.
Distributing the work through your own fork will give you full control over the project, meaning you will be able to ship enhancements and fixes as soon as you like instead of waiting months if not years for Arduino to get around to making a new release.
Things are progressing more slowly than one wants. However, testing all things before releasing helps to keep the worst bugs at bay (I recently had a case when single steps became double steps). In any case, you can now use the IDE 2 to debug modern ATtinys (series 0, 1, and 2) as well as 0-series ATmega chips, e.g., ATmega4809 on the Nano Every and Uno Wifi Rev2. Consult https://pyavrocd.io