[fpc-devel] bounty: FPC based debugger
Jonas Maebe
jonas.maebe at elis.ugent.be
Tue Sep 13 16:51:08 CEST 2011
On 13 Sep 2011, at 16:52, Hans-Peter Diettrich wrote:
> Michael Schnell schrieb:
>> On 09/12/2011 11:16 PM, Hans-Peter Diettrich wrote:
>>>> - watchpoints. break when data at memory address changed.
>>> I've seen applications crawl when such a feature was used :-(
>> This is bound to happen unless the CPU provides support for this.
>
> It's not the CPU, it's more the MMU which can help in finding
> changed (global) variables.
No. Debuggers sometimes fall back to this method when they run out of
hardware watch points, but it has several problems:
* in general, more than one variable is located on a memory page, so
you'll get a huge slow down because every time some value on that page
is written you get an exception and have to handle the unrelated write
* on certain architectures (e.g. PowerPC), marking pages as read-only
breaks atomic instructions operating on values stored in them (that
can probably be worked around by even slower code, but at least in GDB
it doesn't work)
* you can get into trouble with system calls. Generally before a
system call you have to make copies of all such pages, make them read-
write again, perform the system call, and then compare all old
contents with the new contents. At least on Linux several system calls
do not give an error if you tell them to write their output to a read-
only page, and even if they did then you wouldn't want a system call
to fail just because it is trying to write to a page that is writable
during a normal execution.
> When the static data segment supports interrupts on write, a
> debugger only has to check whether the affected address in the watch
> list. Doing such checks on *every* write to memory (stack!?)
> requires many more lookups.
Marking a page on the stack as read-only is also bound to slow almost
any program to a crawl (exceptions due to trying to write to a read-
only page are not cheap).
Jonas
More information about the fpc-devel
mailing list