From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 30695 invoked by alias); 17 Sep 2003 00:30:41 -0000 Mailing-List: contact gdb-help@sources.redhat.com; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-owner@sources.redhat.com Received: (qmail 30688 invoked from network); 17 Sep 2003 00:30:40 -0000 Received: from unknown (HELO animal.blarg.net) (206.124.128.1) by sources.redhat.com with SMTP; 17 Sep 2003 00:30:40 -0000 Received: by animal.blarg.net (Postfix, from userid 3118) id 3A0596F5A7; Tue, 16 Sep 2003 17:30:40 -0700 (PDT) Date: Wed, 17 Sep 2003 00:30:00 -0000 From: Ben Johnson To: gdb@sources.redhat.com Subject: Re: how are debug registers supposed to work? Message-ID: <20030916173040.B24214@blarg.net> References: <20030828174129.B9184@blarg.net> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.2.5.1i In-Reply-To: <20030828174129.B9184@blarg.net>; from ben@blarg.net on Thu, Aug 28, 2003 at 05:41:29PM -0700 X-SW-Source: 2003-09/txt/msg00202.txt.bz2 I found the problem. The addresses I'm attempting to use are logical addresses, not linear. The (2.0) kernel data segment's base address is 0xc0000000, so in order to get a linear address I have to add that base address to it. altered code that's now trapping in the right place: schedule() { ... static unsigned long has_run = 1; static unsigned long has_run_2 = 0; if( ! has_run && jiffies > 7000 ) { has_run = 1; has_run_2 = 0; /* setup the debug registers */ asm ("movl %%cr4, %%edx\n" /* debug extensions */ " orl $0x8, %%edx\n" " movl %%edx, %%cr4\n" " movl %0, %%db0\n" /* push into db regs */ " movl %1, %%db7\n" " lgdt 0x00106852\n" /* pentium may need this */ : /* no output */ :"a"(0xc0000000 + ((unsigned long)&has_run_2)), "b"(0x000f2202) /*"m"((((char *)&gdt)-6))*/ :"%edx" ); } if( has_run && ! has_run_2 ) /* debug reg generate exception */ { /* whatever */ has_run_2 = 0xffffffff } ... } I'm sure the debug extensions aren't needed. I put in the lgdt instruction because I read section in 18.17.4 of Intel's Software Development Manual (Volume 3) that it may help Pentium processors recognize breakpoints. no other processors need that though. - Ben