English Amiga Board


Go Back   English Amiga Board > Support > support.WinUAE

 
 
Thread Tools
Old 02 February 2021, 00:30   #1
Jobbo
Registered User
 
Jobbo's Avatar
 
Join Date: Jun 2020
Location: Druidia
Posts: 386
Investigating code in WinUAE

How do other people disassemble and debug in WinUAE?


I don't know my way around the Shift-F12 debug features.

Is there a way to just dump the memory as code to a file and look it over in there?
What are those tabs along the bottom used for? (OUT1, OUT2, MEM1, MEM2, DASM1, DASM2 etc)


How do some of you experts dissect other peoples exe's and for that matter how do you patch them?
Jobbo is offline  
Old 02 February 2021, 01:00   #2
DanScott
Lemon. / Core Design
 
DanScott's Avatar
 
Join Date: Mar 2016
Location: Tier 5
Posts: 1,209
The debugger in WinUAE is a nightmare to use properly. It's the most unfriendly interface ever... surprised nobody has offered to make it better to be honest...

I try to avoid using it, but when debugging my own code it's not so difficult, as I can have the source open in another window and follow it through easier that way
DanScott is offline  
Old 02 February 2021, 01:29   #3
Radertified
Registered User
 
Join Date: Jan 2011
Location: -
Posts: 728
You press SHIFT+F12 and you're given the GUI debugger. Don't like the GUI? You can switch to the console by typing 'xx' (and go back to GUI if you want).

The GUI is essentially a frontend to the console. Yes there's some places where you can right click or double click for ease of use but realistically you'll be typing... a lot.

First thing is learning that 'h' will give you help. You'll be using that pretty often.

So let's say you want to search for a string in memory: s "blahblah"
Quote:
Searching from 00000000 to 00200000..
Scanning.. 00000000 - 00200000 (Chip memory)
00002E8E 00002F8A 00002FAB 0000328A 000032AB 0000352B 00013187 0001E1A0 0001E1B7 0001F32E 0001F3BA 00102E8E 00102F8A 00102FAB 0010328A 001032AB 0010352B 00113187 0011E1A0 0011E1B7 0011F32E 0011F3BA
You want to view one of those using the GUI? mg 2E8E

Want to see where a memory address is references in memory? fa 1e6fe
Quote:
Searching from 00000000 to 00200000
Scanning.. 00000000 - 00200000 (Chip memory)
0001E6F2 0839 000a 00df f016 BTST.B #$000a,$00dff016
0001E6FA 6702 BEQ.B #$02 == $0001e6fe (F)
Want to set a breakpoint on an address? f 1E6F2

Want to set a memory watchpoint on an address? (eg. find when lives are subtracted) w 0 1df0 1 w (watch only 1 byte that's being written to - r for reading, w for writing, rw for read/write)

Want to save a bit of memory? S blah.dmp 2E8E 16
Quote:
Wrote 00002E8E - 00002EA4 (22 bytes) to 'blah.dmp'.
Want to continue emulation? g

etc.

It's not easy when you're new to it, but once you've grasped how it all works, it's way more convenient than for example, Action Replay in my opinion.

OUT1, OUT2, MEM1, MEM2, DASM1, DASM2, etc. can be accessed using the function keys (F1, F2, etc). They just give different debugging views.
Radertified is offline  
Old 02 February 2021, 01:31   #4
Radertified
Registered User
 
Join Date: Jan 2011
Location: -
Posts: 728
Quote:
Originally Posted by DanScott View Post
The debugger in WinUAE is a nightmare to use properly. It's the most unfriendly interface ever... surprised nobody has offered to make it better to be honest...
This is the rewrite.

Initially it was purely console based. I believe Toni still uses it like this and he has no interest in updating the GUI (it's not his code).

I'd love to see changes made to the GUI (scrollbars to scroll through memory and disassembly!) but I'm not holding my breath
Radertified is offline  
Old 02 February 2021, 01:56   #5
Jobbo
Registered User
 
Jobbo's Avatar
 
Join Date: Jun 2020
Location: Druidia
Posts: 386
Quote:
Originally Posted by DanScott View Post
The debugger in WinUAE is a nightmare to use properly. It's the most unfriendly interface ever... surprised nobody has offered to make it better to be honest...

I try to avoid using it, but when debugging my own code it's not so difficult, as I can have the source open in another window and follow it through easier that way

Fortunately for my own code I use Bartman's VSCode setup. You still need to jump through a few hoops so it'll show you the inline asm properly. But once you have it running you can single step through the asm line by line and watch the register and memory contents fairly well. At least until it crashes after a few minutes


I've also used his profiler on other peoples running code which is nice if you want to see all the blitter and dma activity in a more digestible form.



Using the WinUAE debugger is mostly so I can see what other people are doing. In the past I've only really investigated the chip ram contents. In the old days I had a ripper tool that let me scan the memory. Now I can save a state and use Maptapper in the same way. I can normally figure out how someone else has coded some effect just from the graphics layout. But obviously that doesn't help much for more code heavy effects.
Jobbo is offline  
Old 02 February 2021, 01:56   #6
Jobbo
Registered User
 
Jobbo's Avatar
 
Join Date: Jun 2020
Location: Druidia
Posts: 386
Quote:
Originally Posted by Radertified View Post
OUT1, OUT2, MEM1, MEM2, DASM1, DASM2, etc. can be accessed using the function keys (F1, F2, etc). They just give different debugging views.

Thanks I didn't know that.
Jobbo is offline  
Old 02 February 2021, 02:20   #7
Radertified
Registered User
 
Join Date: Jan 2011
Location: -
Posts: 728
I forgot to mention F11 and F12 to step through code. One steps into functions, while the other steps over them. I can't remember which is which, so experiment to find out
Radertified is offline  
Old 02 February 2021, 08:35   #8
mcgeezer
Registered User
 
Join Date: Oct 2017
Location: Sunderland, England
Posts: 2,702
I debug routines mainly with MonAm

For deep bugs i use the Winuae debugger with the uaedbg side loader, this allows for debugging non system code with symbols included.

It also helps track if all kinds of stuff like memory allocations. Also useful is for when you have things like unitialised copper lists or pointers that read from low memory - the debugger will tell you even if it's something like Bitplanes or Sprites.

Most used and useful is the watch points, I watch a low address and trigger it in my code.

w 0 100 2 W ALL

Then somewhere problematic in my code clr.w $100.w

Agree it can be difficult to use but worth investing the time, not any harder than using the likes of gdb.

Last edited by mcgeezer; 02 February 2021 at 09:21. Reason: typos.
mcgeezer is offline  
Old 02 February 2021, 08:53   #9
Toni Wilen
WinUAE developer
 
Join Date: Aug 2001
Location: Hämeenlinna/Finland
Age: 49
Posts: 26,502
The only problem is still the same: some nice multi-window resizable GUI framework is needed. Anything that takes care of windowing stuff.

Without it: 99% of work would be implementing GUI code. The rest would be debugger functionality.
Toni Wilen is offline  
Old 02 February 2021, 09:22   #10
sparhawk
Registered User
 
sparhawk's Avatar
 
Join Date: Sep 2019
Location: Essen/Germany
Age: 55
Posts: 463
I would like to update the debugger, but then I also want to work on some Amiga code.

To much work, not enough time.
sparhawk is offline  
Old 02 February 2021, 14:40   #11
a/b
Registered User
 
Join Date: Jun 2016
Location: europe
Posts: 1,039
Quote:
Originally Posted by DanScott View Post
The debugger in WinUAE is a nightmare to use properly. It's the most unfriendly interface ever... surprised nobody has offered to make it better to be honest...

I try to avoid using it, but when debugging my own code it's not so difficult, as I can have the source open in another window and follow it through easier that way
Winuae 10/10 best app ever, winuae GUI debugger -10/10.

You know what's also -10? Its window's Y coord. It keeps crawling up every time it shows up until it finally gets under the taskbar (yeah, I have it on top, just like Amiga's screenbar) and you can't see D0/A0 any more.
Just my way of saying: hi, Toni. :P
a/b is offline  
Old 02 February 2021, 14:45   #12
roondar
Registered User
 
Join Date: Jul 2015
Location: The Netherlands
Posts: 3,408
Quote:
Originally Posted by mcgeezer View Post
For deep bugs i use the Winuae debugger with the uaedbg side loader, this allows for debugging non system code with symbols included.
How did I miss this uaedbg package... Something to investigate for sure!
http://eab.abime.net/showthread.php?t=91321
roondar is offline  
Old 02 February 2021, 15:54   #13
Old_Bob
BiO-sanitation Battalion
 
Old_Bob's Avatar
 
Join Date: Jun 2017
Location: Scotland
Posts: 151
I have to say that I don't quite get the hate for the GUI debugger. I find it to be easy enough to use. However, some kind of modern multi-window setup would certainly be an improvement.

Is there any chance at all that this might happen, in the future?

B
Old_Bob is offline  
Old 02 February 2021, 16:38   #14
Radertified
Registered User
 
Join Date: Jan 2011
Location: -
Posts: 728
Quote:
Originally Posted by Old_Bob View Post
Is there any chance at all that this might happen, in the future?
Toni said he's looking for "some nice multi-window resizable GUI framework", so I guess that's the hold up. If someone can suggest something good that works to his requirements, then presumably it will be implemented.
Radertified is offline  
Old 02 February 2021, 17:25   #15
Gorf
Registered User
 
Gorf's Avatar
 
Join Date: May 2017
Location: Munich/Bavaria
Posts: 2,294
Quote:
Originally Posted by Toni Wilen View Post
The only problem is still the same: some nice multi-window resizable GUI framework is needed. Anything that takes care of windowing stuff.

Without it: 99% of work would be implementing GUI code. The rest would be debugger functionality.
https://github.com/Immediate-Mode-UI/Nuklear
Gorf is offline  
Old 02 February 2021, 18:48   #16
Jobbo
Registered User
 
Jobbo's Avatar
 
Join Date: Jun 2020
Location: Druidia
Posts: 386
Quote:
Originally Posted by Gorf View Post
That looks decent. But I haven't seen it in use.

I was going to suggest DearImGui which I have used and is widely held in high regard.

https://github.com/ocornut/imgui

Last edited by Jobbo; 02 February 2021 at 19:13.
Jobbo is offline  
Old 02 February 2021, 18:56   #17
Thomas Richter
Registered User
 
Join Date: Jan 2019
Location: Germany
Posts: 3,214
Quote:
Originally Posted by Toni Wilen View Post
The only problem is still the same: some nice multi-window resizable GUI framework is needed. Anything that takes care of windowing stuff.

Without it: 99% of work would be implementing GUI code. The rest would be debugger functionality.
Frankly, Toni: It's not. It's not the GUI that makes the thing unusable. It's the lack of some very elementary features, like expression evaluation, and using the register contents as part of an expression. I don't want to "copy/paste" an address from a register just to be able to access it. "Unassemble a2+4" - something like this.

Also, step over/next should really be more careful for branches such that as "next" does not simply place a breakpoint behind a branch (where it might never get).

That alone would improve the usefulness of the thing by 50%. Look at COP or its commands as an example what I would consider useful features. its "GUI" stinks as well, but that is not relevant.
Thomas Richter is offline  
Old 02 February 2021, 19:04   #18
Gorf
Registered User
 
Gorf's Avatar
 
Join Date: May 2017
Location: Munich/Bavaria
Posts: 2,294
Quote:
Originally Posted by Jobbo View Post
That looks decent. But I haven't seen it in use.

I was going to suggest DearImGui which is I have used and is widely held in high regard.

https://github.com/ocornut/imgui
Also very nice - but I was under the impression pure C might be a better fit - but that's of course up to Toni or who ever actually wants to du this.
Gorf is offline  
Old 02 February 2021, 19:17   #19
Toni Wilen
WinUAE developer
 
Join Date: Aug 2001
Location: Hämeenlinna/Finland
Age: 49
Posts: 26,502
Quote:
Originally Posted by Thomas Richter View Post
Frankly, Toni: It's not. It's not the GUI that makes the thing unusable. It's the lack of some very elementary features, like expression evaluation, and using the register contents as part of an expression. I don't want to "copy/paste" an address from a register just to be able to access it. "Unassemble a2+4" - something like this.
First, I don't care what the GUI version does. It uses same parser but there can be issues.

Console version does support evaluations, for example "d ra2+4" disassembles from contents of register A2 + 4.

Quote:
Also, step over/next should really be more careful for branches such that as "next" does not simply place a breakpoint behind a branch (where it might never get).
These are trivial changes. "Debugger" only contains features that I (or Bernd) needed to debug something. It was never meant to be anything useful for generic debugging.
Toni Wilen is offline  
Old 02 February 2021, 19:27   #20
Toni Wilen
WinUAE developer
 
Join Date: Aug 2001
Location: Hämeenlinna/Finland
Age: 49
Posts: 26,502
Quote:
Originally Posted by Jobbo View Post
That looks decent. But I haven't seen it in use.

I was going to suggest DearImGui which I have used and is widely held in high regard.

https://github.com/ocornut/imgui
This looks interesting. As long as it can work as a dll because I am not going to statically link some huge libraries
Toni Wilen is offline  
 


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools

Similar Threads
Thread Thread Starter Forum Replies Last Post
native x86 code in WinUAE? Falk support.WinUAE 20 21 January 2023 18:30
Profiling code under WinUAE? deimos Coders. General 8 08 October 2018 17:55
Investigating Guru message selco support.WinUAE 2 17 March 2016 12:03
Calling Windows code from WinUAE is risky! Leandro Jardim support.WinUAE 2 22 January 2012 10:09
editing winuae source code petee1979 Coders. General 2 22 April 2008 04:19

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +2. The time now is 12:50.

Top

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Page generated in 0.09917 seconds with 13 queries