joncampbell123 / dosbox-x

DOSBox-X fork of the DOSBox project
GNU General Public License v2.0
2.56k stars 373 forks source link

Read Breakpoint in Debugger for Reverse Engineering #2468

Open LowLevelMahn opened 3 years ago

LowLevelMahn commented 3 years ago

i've started to add a "break point on memory read" feature into dosbox mainline

https://www.vogons.org/viewtopic.php?f=32&p=957743#p957743

in the last post is my super tiny patch attached (just a few lines of code)

sadly its still not working as expected - maybe you're also interested in such a feature and can give tips what i've did not get right about the dosbox internals

joncampbell123 commented 3 years ago

I am interested, however I'm also concerned that checking for breakpoints every memory access will put significant overhead on emulation.

Here's my understanding of the code: There's a readb for linear that uses the "translation lookaside buffer" in paging.cpp to decide what page to use. If that page returns a host pointer, it caches that and uses it directly later (which is why flushing is needed for dynamic core whenever memory mapping changes). Otherwise it calls readb/readw/readd methods of the page object.

LowLevelMahn commented 3 years ago

I am interested,

great! :)

however I'm also concerned that checking for breakpoints every memory access will put significant overhead on emulation.

i am too - but its for analysing, not playing

the feature is currently planned as a "HEAVY_DEBUG/core=normal" only feature (i think the same constraints as for the other already implemented memory bp features)

maybe i can add another flag that makes the check real fast if there is a memory read bp at all,etc.

Here's my understanding of the code: There's a readb for linear that uses the "translation lookaside buffer" in paging.cpp to decide what page to use. If that page returns a host pointer, it caches that and uses it directly later (which is why flushing is needed for dynamic core whenever memory mapping changes). Otherwise it calls readb/readw/readd methods of the page object.

is that behavior also given in core=normal?

does that mean i also need to extend the readb of the PageHandler?