From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 20260 invoked by alias); 16 Oct 2006 08:51:51 -0000 Received: (qmail 20238 invoked by uid 22791); 16 Oct 2006 08:51:50 -0000 X-Spam-Check-By: sourceware.org Received: from lon-del-04.spheriq.net (HELO lon-del-04.spheriq.net) (195.46.50.101) by sourceware.org (qpsmtpd/0.31) with ESMTP; Mon, 16 Oct 2006 08:51:44 +0000 Received: from lon-out-02.spheriq.net ([195.46.50.130]) by lon-del-04.spheriq.net with ESMTP id k9G8pQqB009208 for ; Mon, 16 Oct 2006 08:51:26 GMT Received: from lon-cus-01.spheriq.net (lon-cus-01.spheriq.net [195.46.50.37]) by lon-out-02.spheriq.net with ESMTP id k9G8pPrh028179 for ; Mon, 16 Oct 2006 08:51:25 GMT Received: from beta.dmz-eu.st.com (beta.dmz-eu.st.com [164.129.1.35]) by lon-cus-01.spheriq.net with ESMTP id k9G8pMMM024384 (version=TLSv1/SSLv3 cipher=EDH-RSA-DES-CBC3-SHA bits=168 verify=OK); Mon, 16 Oct 2006 08:51:24 GMT Received: from zeta.dmz-eu.st.com (ns2.st.com [164.129.230.9]) by beta.dmz-eu.st.com (STMicroelectronics) with ESMTP id A1E22DA4C; Mon, 16 Oct 2006 08:49:14 +0000 (GMT) Received: from mail1.cro.st.com (mail1.cro.st.com [164.129.40.131]) by zeta.dmz-eu.st.com (STMicroelectronics) with ESMTP id 5F289473ED; Mon, 16 Oct 2006 08:49:13 +0000 (GMT) Received: from [164.129.44.49] (crx549.cro.st.com [164.129.44.49]) by mail1.cro.st.com (MOS 3.5.8-GR) with ESMTP id CIR86858 (AUTH "frederic riss"); Mon, 16 Oct 2006 10:49:11 +0200 (CEST) Subject: Re: gdb breakpoint on x86 From: Frederic RISS To: s88 Cc: gdb@sourceware.org In-Reply-To: References: <20061016003930.GA525@nevyn.them.org> Content-Type: text/plain Date: Mon, 16 Oct 2006 08:51:00 -0000 Message-Id: <1160988550.3423.28.camel@crx549.cro.st.com> Mime-Version: 1.0 X-Mailer: Evolution 2.8.0 Content-Transfer-Encoding: 7bit X-IsSubscribed: yes Mailing-List: contact gdb-help@sourceware.org; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-owner@sourceware.org X-SW-Source: 2006-10/txt/msg00109.txt.bz2 On Mon, 2006-10-16 at 09:15 +0800, s88 wrote: > > > By the way, the following code can compile without any error. But the > > > sizeof which in the "i386_breakpoint_from_pc" derives segmentation > > > fault. > > > > You need to read up on memory protection. You can't modify a running > > program directly this way on most platforms. > > > Thank gor your reply... > > I have a new question, how to remove the memory protection? I'm trying > to find out this part in gdb, but I do not find anything!! On Linux, GDB uses the ptrace(2) API to get access to another process' address space. This API allows a debugger process to modify the memory of another (debuggee) process. Looking at your segmentation fault issue, it's not a breakpoint issue, it's a simple C issue AFAICT. You do: int *len=0; b = (my_byte *)i386_breakpoint_from_pc ((CORE_ADDR *)(t), len); and in i386_breakpoint_from_pc: *len = sizeof (break_insn); which is *0 = sizeof (break_insn); That's also a memory protection error, but not due to editing executable memory pages, it's simply a NULL pointer dereference. Fred.