johnl@esegue.segue.boston.ma.us (John R. Levine) (01/24/90)
I am putting code into gdb to handle watchpoints, although the only machine I plan to implement them for at this point is the 386 which makes it easy by having hardware support. It's no big deal to add code to the breakpoint routines to store watchpoints in the same list as breakpoints and to handle them, though there are a few tricky bits, e.g. seeing if you hit a watchpoint while single stepping over a breakpointed instruction. The problem arises in setting watchpoints on stack local variables. Currently I just set them the same way I set them on static data, but that is not very satisfactory for two reasons. If you set them while a routine is active, you get false hits after it returns and some other routine reuses the same memory. On the other hand, a routine is likely to be called with the stack at various different places and the addresses of locals change every time. The right thing to do is to insert the watchpoint when the routine is entered and remove it when the routine returns, but that is quite slow if the routine is called very often. Does anyone have any other inspirations about a good way to handle local watchpoints? (Yes, I'll send out the diffs, but at the moment it's too buggy to be of much use to anyone.) -- John R. Levine, Segue Software, POB 349, Cambridge MA 02238, +1 617 864 9650 johnl@esegue.segue.boston.ma.us, {ima|lotus|spdcc}!esegue!johnl "Now, we are all jelly doughnuts."