Sources Bugzilla – Bug 12956
Watchpoint on invalid memory addressed is too slow, they should be 'pending' until allocated
Last modified: 2011-07-31 19:08:32 UTC
I am setting a watchpoint for the memory address that is not yet allocated. I am interested in what happens when it is allocated and later. 'watch' statement sets a software watchpoint, and program instantly becomes very slow. My guess is that gdb traces the program and checks if the memory is valid after each instruction. This is wrong. Since memory can only become valid after mmap or brk/sbrk calls, gdb should only trace those calls in such situation, which is a 'pending' state for a watchpoint. Once the memory address becomes valid, gdb should change status to hardware watchpoint. If the memory is deallocated again (with munmap or brk/sbrk calls) gdb should change state back to 'pending' and wait for the possible other allocations.
(In reply to comment #0) > I am setting a watchpoint for the memory address that is not yet allocated. I > am interested in what happens when it is allocated and later. > > 'watch' statement sets a software watchpoint, and program instantly becomes > very slow. My guess is that gdb traces the program and checks if the memory is > valid after each instruction. This is wrong. > yes, in software watchpoint, gdb will execute program in a single step manner, and check memory changed or not. That is why program is slow, but I don't think it is wrong. > Since memory can only become valid after mmap or brk/sbrk calls, gdb should > only trace those calls in such situation, which is a 'pending' state for a > watchpoint. Once the memory address becomes valid, gdb should change status to > hardware watchpoint. If the memory is deallocated again (with munmap or ^^^^^^^^^^^^^^^^^^^ I guess you mean "software watchpoint" here. > brk/sbrk calls) gdb should change state back to 'pending' and wait for the > possible other allocations. This approach you proposed should speed up watchpoint in some cases. GDB also supports debugging ELF without OS on some bare-mental boards, so syscall mmap/brk/sbrk/ is not available there.
> > watchpoint. Once the memory address becomes valid, gdb should change status to > > hardware watchpoint. If the memory is deallocated again (with munmap or > ^^^^^^^^^^^^^^^^^^^ > I guess you mean "software watchpoint" here. No I meant hardware watchpoint. If requested memory address isn't available, watchpoint is creates as "Pending". When it becomes available it becomes hardware watchpoint. On the platforms where mmap/brk/sbrk aren't available previous behavior should be preserved.
Exact dup of PR10645 *** This bug has been marked as a duplicate of bug 10645 ***