From mboxrd@z Thu Jan 1 00:00:00 1970 From: Stephane Eranian Date: Mon, 26 Feb 2007 23:51:54 +0000 Subject: debug registers and fork Message-Id: <20070226235154.GB19630@frankl.hpl.hp.com> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: linux-kernel@vger.kernel.org Cc: linux-ia64@vger.kernel.org, Stephane Eranian , ak@suse.de, akpm@linux-foundation.org, tony.luck@intel.com Hello, I have come across an issue with a monitoring using the hardware debug registers on ia64/i386/x86-64. It seems that the way debug registers are inherited across fork differs between ia-64 and i386/x86-64. On ia-64, the debug registers are NEVER inherited in the child. The copy_thread() routine clears the necessary thread flags to avoid reloading the debug registers in the child. Now, on x86-64, it appears that the TIF_DEBUG flag is inherited via setup_thread_stack(). By virtue of dup_task_struct() the debug registers get copied into the child task on fork. So the child has active breakpoints, unless I am mistaken somewhere. Given the way the ptrace() interface works, I would tend to think that the ia-64 way is the correct one. Any comment? Furthermore, on i386/x86-64, when switching out from a task with TIF_DEBUG enabled to another which does not, it seems we do not clear the debug registers (at least dr7) so they become inactive. -- -Stephane