Execution tracing for call graph generation

Página 1/3
| 2 | 3

Por jblang

Rookie (29)

Imagen del jblang

09-02-2019, 17:52

I am just starting to use openMSX. I have been using blueMSX till now, and it comes with ROMs and has a hardware configuration called just "MSX" that uses MSX.rom and PHILLIPSDISK.rom, which is what I have been using there. I copied these to my systemroms folder on openMSX and tried to figure out which hardware to use. I got it to boot using Philips VG-8020/20 and it started BASIC but there's no disk support.

I then copied all the files from blueMSX Shared ROMs folder from to openMSX systemroms folder, and just randomly tried a few different machines, but I haven't found one that's a MSX1 with working disk. Being from America, I never had a real MSX and am not that familiar with the different models. Can someone suggest a good "standard" European MSX1 model to use in openMSX that has disk support? Preferably one that I can just copy the ROMs over from blueMSX and not go hunting for them.

Login sesión o register para postear comentarios

Por Grauw

Ascended (10821)

Imagen del Grauw

09-02-2019, 18:00

No need to hunt with this secret link.

As for MSX1s with disk drive, I think you can try the National CF-3300. As for PAL systems, I don’t know, you could browse the MSX1 category of the wiki further and check the specs of the MSX1 machines, or plug in a disk drive extension cartridge, or pick an MSX2 machine like the Philips NMS 8245.

Por jblang

Rookie (29)

Imagen del jblang

09-02-2019, 18:30

Thanks. That wasn't one that blueMSX had the ROMs for but I was able to find it in that zip. Now I have a menu option to insert a disk but it isn't booting from it when I reset. I am trying to run this demo. When I use the disk image in blueMSX, it boots automatically. Is there some trick I am missing?

Edit: I also tried Philips VG-8020/20 with VY-0010 3.5" disk, and it does the same thing. There is some disk activity on the FDD indicator but it eventually boots into BASIC instead of MSX-DOS.

Por Manuel

Ascended (19678)

Imagen del Manuel

09-02-2019, 18:35

THe VY-0010 is a single sided drive. Try the Sony HBD-F1 instead. There wasn't any European MSX1 with a double sided disk drive. Why not try an MSX2 like the Philips NMS 8245?

AFAIK that demo (Bold) also exists in ROM format. So that's also an alternative.

By the way, by following your link and clicking download, I got to the dvik/joyrex website, but I can't download anything there (anymore). Does that work for you?

Por jblang

Rookie (29)

Imagen del jblang

09-02-2019, 19:01

Thanks! Using Sony HBD-F1 with the Philips VG-8020/20 worked.

As for the demo link, I just tried it and it didn't work anymore. I downloaded the demo some time back, so I'm not sure what happened.

As to why not use an MSX2, I have built my own homebrew computer that has hardware very similar to a MSX1, on which I have run the demo successfully, and I was trying to keep the emulated hardware as close to that as possible.

Further background: I have disassembled the demo and been looking through the code to learn more about how it works. I have gotten pretty far just manually stepping through the code in blueMSX but I read some about openMSX scripting interface and thought I might be able to use that to generate some call graphs and memory map of important variables to help me put the pieces together more easily. Here are the symbols I have created for the disassembly so far, which can be used to disassemble the code with z80dasm.

Por Grauw

Ascended (10821)

Imagen del Grauw

09-02-2019, 20:53

Sounds neat, I’d be interested in seeing some examples of those graphs and tools Smile.

Por jblang

Rookie (29)

Imagen del jblang

09-02-2019, 21:01

If I get something working, I will be sure to share it.

Por Manuel

Ascended (19678)

Imagen del Manuel

09-02-2019, 22:01

You already tried the openMSX debugger as well? It doesn't contain the functionality you are talking about, but it may still be useful. You can also step back one instruction, which may be useful as well.

Por jblang

Rookie (29)

Imagen del jblang

09-02-2019, 22:15

I have tried it a bit. For interactive debugging I actually prefer blueMSX's debugger, but the scripting in openMSX is very powerful to automatically record things.

I think I can use debug set_condition to check when a call instruction is executed, and then record the call's instruction's address as well as the address jumped to, and save that information to a file. Then I can do some post processing on the file to generate a call graph.

Por jblang

Rookie (29)

Imagen del jblang

09-02-2019, 23:02

Here is a very basic starting point:

namespace eval call_graph {

set_help_text call_graph \
{Builds a call graph of functions used in the running code.}

variable log_file

proc check_call {} {
	set address [reg PC]
    set instr [peek $address]
    expr {$instr == 0xCD || $instr & 0xC7 == 0xC4}
}

proc log_call {} {
	variable log_file
	if {![info exists log_file]} return
    set from [reg PC]
    set to [peek16 [expr {$from + 1}]]
	puts $log_file [format "%x %x" $from $to]
}

proc call_graph {filename} {
	variable log_file
	set log_file [open $filename {WRONLY TRUNC CREAT}]
	debug set_condition {[call_graph::check_call]} {call_graph::log_call}
	return ""
}

namespace export call_graph

} ;# namespace call_log

namespace import call_graph::*

Right now it just logs every call instruction with the source and destination of the call. Even this very basic code is enough to do some interesting analysis though. For example:

jblang@cloud9:~/winhome/Retro/MSX/openmsx$ awk '{print $2}' calls | sort | uniq -c | sort -n | tail -10
   1033 167e
   1033 168a
   1033 1941
   1034 153
   1034 1eec
   2207 1813
   3099 155a
   3102 4b7
   5300 2f43
  53009 1137

This gives a list of the 10 most frequently called subroutines while a certain section of the demo is running. When inspecting disassembled code, I find it is best to start with frequently used utility subroutines and understand what they do, which provides context for better understanding the functions that are calling them. So now I know I should probably investigate what functions at address 1137 and 2f43 do first in order to understand this part of the demo better. Cool

Por Manuel

Ascended (19678)

Imagen del Manuel

09-02-2019, 23:58

Great!

Just curious: do you have any hints on how we should/can improve the debugger?

Página 1/3
| 2 | 3