Memory / Variable runtime watch

Por Bengalack

Champion (405)

Imagen del Bengalack

03-04-2020, 19:31

Inspired by the profiler osd, I could like to have a similar small little box in the corner with a selection of variables I'd like to watch during program execution. Has anyone made anything like that?

I have no experience with tcl, so I find it somewhat hard at the moment to just go about and make one, but I belive it could be easily done with the help from Grauw's symbols-file. So, at startup one adds watch on write to named locations in memory where you have your variables stored. Right now, it is hard to "debug" whats going on in my program at times. --Firing up the debugger, and manually finding the memory location and then find the value amongst tons of other values on screen takes time Smile

Any directions would be appreciated Smile

Login sesión o register para postear comentarios

Por Grauw

Ascended (10062)

Imagen del Grauw

03-04-2020, 20:17

Check out the built-in ram_watch script. Type help ram_watch for usage information.


ram_watch add 0xFC9E -type word

Example with my symbols script:

ram_watch add [symbol JIFFY] -type word

Por Bengalack

Champion (405)

Imagen del Bengalack

06-04-2020, 14:56

WoooooooooooooooooW! Smile EXACTLY what I wanted! This will speed up things, thanks a lot!

Por Bengalack

Champion (405)

Imagen del Bengalack

22-04-2020, 19:36

Would you guys have any pointers on how to control the slot for the address you type in? I'm currently running a small program in dos that goes straight into page 1 and it seems like another slot is showing both in the watch and "default" in the debugger: Slot 0 (on "break" the debugger shows correct, NMS 8255 ram slots 3-2). How to instruct slot in the ram_watch?

Por pgimeno

Champion (300)

Imagen del pgimeno

25-04-2020, 02:22

I've looked into it a bit. It looks like you will need to hack _tas_tools.tcl yourself in order to make it peek the debuggable "slotted memory", instead of the default Z80-visible address map.

You need to make it accept 5 digits instead of 4; that's in this fragment:

        # sanitize input
        set addr [format 0x%04X $addr_str]
        if {($addr < 0) || ($addr > 0xffff)} {
                error "Address must be in range 0x0..0xffff, got: $addr_str"

(That's the easy part; you just change 0x%04X to 0x%05X, and all 0xffff to 0xfffff).

Then in this fragment:

        set exprStr "set v \[$peek_method $addr\]; set r \"\[expr {(\$v < 0) ? \"-\" : \"\"}\]\[format $fmtStr2 \[expr {abs(\$v)}\]\]\"; set r"

you need to change \[$peek_method $addr\] to: \[$peek_method $addr \"slotted memory\"\]

Then your addresses need a fifth digit to the left, corresponding to the slot and subslot, which need to be 4*slot+subslot (use subslot 0 if not expanded). For example, slot 3 subslot 2 is 4*3+2 = 14 = 0xE, so the address should be 0xEXXXX, e.g. 0xF380 in slot 3-2 becomes 0xEF380.

That will do it, but you also need to make room for the larger address in the OSD. In this fragment:

proc ram_watch_init_widget {} {
       osd create rectangle ram_watch.addr \
               -x 257 -y 1 -w 62 -h 221 \

change the last line to:

               -x 255 -y 1 -w 64 -h 221 \

In ram_watch_add_to_widget you need three changes. The first:

proc ram_watch_add_to_widget {nr} {
       osd create rectangle ram_watch.addr.mem$nr \
               -x 2 -y [expr {8 + ($nr * 6)}] -h 5 -w 16 -rgba 0x40404080

Change the 16 in the last line to a 19, as follows:

               -x 2 -y [expr {8 + ($nr * 6)}] -h 5 -w 19 -rgba 0x40404080

The second one is in this fragment:

       osd create rectangle ram_watch.addr.val$nr \
               -x 19 -y [expr {8 + ($nr * 6)}] -h 5 -w 17 -rgba 0x40404080

Change the 19 in that last line to a 22, leaving it as follows:

               -x 22 -y [expr {8 + ($nr * 6)}] -h 5 -w 17 -rgba 0x40404080

Finally, in this fragment:

       osd create rectangle ram_watch.addr.desc$nr \
               -x 37 -y [expr {8 + ($nr * 6)}] -h 5 -w 23 -rgba 0x40404080 -clip true

change the 37 in the last line to a 40, leaving it like this:

               -x 40 -y [expr {8 + ($nr * 6)}] -h 5 -w 23 -rgba 0x40404080 -clip true

Here's the complete patch against current head, in case it's more useful to you:

Por Bengalack

Champion (405)

Imagen del Bengalack

26-04-2020, 12:13

Awesome @pgimeno! With my extremely limited tcl-knowledge, I would not have been able figure this out. Thanks a lot.

But maybe it should go into the official repo?

Por pgimeno

Champion (300)

Imagen del pgimeno

26-04-2020, 17:30

I think it should be optional, not mandatory. For one, it could break debugging setups of people. And my patch doesn't make it optional; my Tcl skills aren't that good either.