how to use a debugger

Door thegeps

Paragon (1027)

afbeelding van thegeps

17-02-2022, 19:38

ok, there's a first time for everything...
I haven't used a debugger till now, so I don't know how to do what I need.
Is there some guide somewhere? I have openMSX debugger.
Actually I need to understand wich part of my code writes (accidentally) something in some RAM locations. Usually these locations aren't used but to avoid space wasting I've started to move some variables and tables there and suddenly some strange behaviors started to happen!
I've started openmsx debugger and pointed to one of these RAM addresses but it seemed unchanged until I've paused and restarted the debugger. after the restart the address content was changed (I know for sure that that address content changes, because if I move the SAT buffer around that address one of the Turrican feet change color randomly after some time)

Aangemeld of registreer om reacties te plaatsen

Van Manuel

Ascended (18779)

afbeelding van Manuel

17-02-2022, 21:47

Try to set openMSX in the breaked state, that will update the debugger's view. There's a button in the debugger for that.
You could let openMSX get into breaked state automatically when a value is written to a certain memory address. For that, set a watchpoint.

Van santiontanon

Paragon (1636)

afbeelding van santiontanon

17-02-2022, 22:28

Exactly!

In the openMSX debugger, the easy way to do it is this:
- start the debugger and connect it to openMSX
- hit the "break" button at least once (the red circle): this is needed, as for some reason, if you don't first break openMSX, some times (about 50% in my case) any breakpoints that you set will not be actually set. You only need to break once, then you can let it continue running if you want (the "running dude" button).
- in the "breakpoint" menu at the top, click "Add ..."
- then select the "Memory write watchpoint" type, and specify the address or range you want to detect
- there you go, let your game run, and the debugger will stop as soon as an instruction writes there!

Something that is amazing in openMSX is that once you are in a breakpoint, you can actually "step back in time", to see what happened earlier that led to the state you are in. If you want to go back step by step click the "step back" button in the debugger. If you want to go back longer intervals (e.g., a whole frame, or 10 seconds), then it's easier to do it from the console of openMSX itself, for example: "rewind goback 0.1" will go back 0.1 seconds in time).

openMSX is amazing for debugging. So, I'm sure you'll find the issue Smile

Van thegeps

Paragon (1027)

afbeelding van thegeps

17-02-2022, 22:37

Thank you Manuel and Santi! Tomorrow I will try to apply your hints Smile

Van mcolom

Master (241)

afbeelding van mcolom

17-02-2022, 23:42

You can also use the openMSX console (F10) an add watch or break points from there (with the debugger attached, of course).
For example:
debug set_watchpoint read_mem 0x1234
debug set_watchpoint read_io 0x2E

Van thegeps

Paragon (1027)

afbeelding van thegeps

17-02-2022, 23:59

Thanks!

Van Manuel

Ascended (18779)

afbeelding van Manuel

18-02-2022, 00:18

santiontanon wrote:

for example: "rewind goback 0.1" will go back 0.1 seconds in time).

Small correction: reverse goback 0.1

Van santiontanon

Paragon (1636)

afbeelding van santiontanon

18-02-2022, 01:02

ooops, true, thanks Manuel Smile

Van Grauw

Ascended (10578)

afbeelding van Grauw

18-02-2022, 01:43

Manuel wrote:
santiontanon wrote:

for example: "rewind goback 0.1" will go back 0.1 seconds in time).

Small correction: reverse goback 0.1

There’s also prev_frame and next_frame which I use quite regularly.

Van thegeps

Paragon (1027)

afbeelding van thegeps

18-02-2022, 18:57

Solved! It tooks me literally 12 minutes thanks to the debugger! Nevermore without!

Van santiontanon

Paragon (1636)

afbeelding van santiontanon

18-02-2022, 19:04

Wohoo!! Nice! It's an extremely useful tool!