BartmanAbyss / vscode-amiga-debug

One-stop Visual Studio Code Extension to compile, debug and profile Amiga C/C++ programs compiled by the bundled gcc 12.2 with the bundled WinUAE/FS-UAE.
GNU General Public License v3.0
314 stars 39 forks source link

Weird bugs in 1.2.1 #84

Closed rjobling closed 2 years ago

rjobling commented 2 years ago

I just wanted to let you know there may be some problems with 1.2.1

My code has been working fine on older versions but now suddenly some of my line blits are getting lost or corrupt. And in the profiler some simple fill and clear blits are showing up with insanely tall sizes. When I hover over them the profiles hangs.

I wonder if there are some bugs in the lastest WinUAE that have been missed?

Alternately it might be an undiscovered bug in my own code. But I've been testing it for some time both in WinUAE as an A500 and on my real A1200. I'm more inclined to think it's WinUAE.

I've rolled back to 1.1.0 because that's the last version you have posted a vsix file for. I could try anything else if you want to see if it's the 1.2.0 gcc changes?

BartmanAbyss commented 2 years ago

Thanks for your post. I will try to reproduce with the included sample.

BartmanAbyss commented 2 years ago

Hmm.. can't reproduce with the sample project. I'll upload the 1.2.0 vsix so maybe you can test with that version.

BartmanAbyss commented 2 years ago

I can confirm the following issues with the Amiga 4000 config:

rjobling commented 2 years ago

It's going to be a hard one to track down. Is there anything I can do to help? I can try comparing the .s output for my project with 1.1.0 and 1.2.0 to see if it's a gcc thing? I've certainly run into very subtle issues in the past due to the fickle nature of the inline assembler. I can also try running my code on different versions of WinUAE to see if the problem clears up with a regular or older install.

rjobling commented 2 years ago

I've been looking at the compiler output and it's difficult to see the differences because all the addresses get moved around.

But I did notice that the 1.2.0 version is using __mulsi3 in code that the 1.1.0 version is not. I'm going to get rid of those 32bit mul/div helpers and make sure my code never needs them and keep digging.

But at a minimum the new version does generate some slightly different code which might explain my issues. It's only one 32bit mul per frame so it seems questionable that it's the only problem. Will post whatever else I find.

BartmanAbyss commented 2 years ago

I can confirm the following issues with the Amiga 4000 config:

some glitches with debug overlay

happens with all machines. Also, thumbnails of multi-frame profiles are broken for 32-bit machines

Uint16Array should be aligned to 2 bytes

fixed

no blits showing up at all

also A4000 doesn't show any profiling A4000 execution is very flaky

rjobling commented 2 years ago

I get this message when doing a multi frame profile on A500:

"Unable to start profiling: RangeError: start offset of Uint16Array should be a multiple of 2",

It'll profile a single frame without complaining, but then it hangs when I hover over my fill blit.

rjobling commented 2 years ago

The other glitch issues I see are probably just my code going slower due to gcc throwing in a 32bit mul. I'm not sure why it's suddenly deciding to do that. Or if it's the only issues but I'll let you know.

Anyway, the issue seems unrelated to the profiler stuff.

BartmanAbyss commented 2 years ago

fixed thumbnails of multi-frame profiles

BartmanAbyss commented 2 years ago

pushed the fixes mentioned above to 1.2.2 (should be on marketplace soon)

rjobling commented 2 years ago

I fixed all my code so it no longer generates any of: mulsi3, udivsi3, divsi3, modsi3, umodsi3. (Incidentally to do this I had to fix mulsw/muluw so they can return a 32bit int/uint). But this doesn't fix anything!

I do see that with 1.1.0 versus 1.2.2 the code generated is 10bytes larger for 1.2.2. It's hard to narrow down where that difference is happening but I guess it's not necessarily a problem.

Exe's generated with both 1.1.0 and 1.2.2 will both run perfectly fine in WinUAE 4.4.0. But both have the same glitches when running with the 1.2.2 version of WinUAE 4.9.0.

I could try a clean gdb free version of WinUAE 4.9.0 but I don't know where to get that, without having to compile WinUAE myself, which I haven't tried.

Anyway, the bottom line is that my code works fine in 1.1.0 because it's using WinUAE 4.4.0. But for whatever reason it's breaking under 4.9.0. Maybe this is my code or maybe it's something in WinUAE?

BartmanAbyss commented 2 years ago

WinUAE did some major rewrites of the blitter emulation. The version I compiled for the extension is not the final 4.9.0 version, but something like beta37. You can just use the winuae-gdb.exe and use it instead of your regular WinUAE. I didn't remove any features, and the debugging features are only enabled if you use a special command line parameter.

BartmanAbyss commented 2 years ago

here are binaries of the latest betas: http://eab.abime.net/showthread.php?t=104099&page=50

BartmanAbyss commented 2 years ago

I will update when WinUAE 4.9.0 final is released.

rjobling commented 2 years ago

I downloaded Beta 37 and Beta 38.

The problem is present in Beta 37 and then fixed in Beta 38.

So, definitely seems like an unfortunately timed WinUAE bug.

BartmanAbyss commented 2 years ago

Thanks for trying it. Will update WinUAE.