Bug 27306

Summary: [patch] hw watchpoints work unreliable under gdb(1)
Product: Base System Reporter: kostik <kostik>
Component: binAssignee: freebsd-bugs (Nobody) <bugs>
Status: Closed Overcome By Events    
Severity: Affects Only Me CC: jhb, kostya
Priority: Normal    
Version: 4.3-RELEASE   
Hardware: Any   
OS: Any   
Attachments:
Description Flags
file.diff none

Description kostik 2001-05-13 22:50:01 UTC
The insert_watchpoint()
in the /usr/src/gnu/usr.bin/binutils/gdb/i386/freebsd-nat.c
contains at least 2 bugs:

1. at line 604, fragment
     if (ptrace(PT_SETDBREGS, pid, (caddr_t)&dbr, 0) == -1)
        {
          perror("ptrace(PT_SETDBREGS) failed");
          return 0;
        }
    }
    does not specify return value.
insert_breakpoints() sometimes is misinformed on the result
of the watch insertion. It seems that the "return 0;" statement is missed.

2. At least on my K6-2, reserved bit 10 of dr7 could be eq 1.
In this case, ptrace(PT_SETDBREGS, ...) fails. Might be,
all reserved bits in the dr7 should be explicitly cleared
after ptrace(PT_GETDBREGS,...) at line 535.

The same is true for remove_watchpoint().

Fix: The following is the proposed
diff for
/usr/src/gnu/usr.bin/binutils/gdb/i386/freebsd-nat.c
How-To-Repeat: 	Some attempts of setting hw watchpoint under gdb fail.
Comment 1 dd freebsd_committer freebsd_triage 2001-05-15 01:25:05 UTC
Responsible Changed
From-To: freebsd-bugs->obrien

Over to in-tree toolchain maintainer.
Comment 2 David E. O'Brien freebsd_committer freebsd_triage 2001-09-10 17:33:16 UTC
Responsible Changed
From-To: obrien->freebsd-bugs

I am not the maintainer.
Comment 3 Sheldon Hearn freebsd_committer freebsd_triage 2002-01-30 13:15:55 UTC
Responsible Changed
From-To: freebsd-bugs->mp

Over to maintainer.
Comment 4 Marcel Moolenaar freebsd_committer freebsd_triage 2004-07-17 02:55:20 UTC
Responsible Changed
From-To: mp->marcel

It may be too late to worry about this now, but it's a gdb issue 
nontheless.
Comment 5 Marcel Moolenaar freebsd_committer freebsd_triage 2011-02-21 18:49:51 UTC
Responsible Changed
From-To: marcel->freebsd-bugs

Assign back to the pool. I haven't been working on it and it's unlikely 
I will in the near future.
Comment 6 John Baldwin freebsd_committer freebsd_triage 2016-07-01 15:14:11 UTC
This code has been reworked upstream and should not have the problem of the missing return statement anymore.  Furthermore, the upstream code contains a workaround already to clear reserved bits.