From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 50940 invoked by alias); 21 Nov 2018 15:02:48 -0000 Mailing-List: contact gdb-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-owner@sourceware.org Received: (qmail 50925 invoked by uid 89); 21 Nov 2018 15:02:47 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-1.3 required=5.0 tests=AWL,BAYES_00,RCVD_IN_DNSWL_NONE,SPF_PASS,UNSUBSCRIBE_BODY autolearn=no version=3.3.2 spammy=D*protonmail.com, U*mathieu.tarral, spots, Command X-HELO: mail-wr1-f42.google.com Received: from mail-wr1-f42.google.com (HELO mail-wr1-f42.google.com) (209.85.221.42) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 21 Nov 2018 15:02:43 +0000 Received: by mail-wr1-f42.google.com with SMTP id c14so404141wrr.0 for ; Wed, 21 Nov 2018 07:02:43 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=embecosm.com; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=1tD7AKAZp+MjsxyYUSWbNpM2A3+ki+wlZpfwMM5c26w=; b=hWK7+PTAd8I4C0S2UP1E6Whydx3mwRaVG+xNa3EJ0K7g1vETkvpREkp0svuIQb8mic p+EyMuCJGzRlrI4kxDdj43AIPnxHDNdrz9CXrCsmqsDPbn2Mc+leTqktGYwjkM1cZnsm mC0XtvzwVmCr3RfVvuyIfNlYneuPUYXXHUen+PVUzJPw2kbNwOePj7DmWxb+QtxWQ/WT SNmlujA7clucPwoFMpsvE0CwRfz8h1LRhSwjTnj0XfZ8L/uQyYtM6gqxV1UVT9xlGZpJ ZRiz2t3QPF/ebU7k8lgpl/EAfZivoeGFmbnaE8VXmeB3lfpKrAVFF5Z/NCdUiOoayuQb +FMQ== Return-Path: Received: from localhost (host81-156-111-139.range81-156.btcentralplus.com. [81.156.111.139]) by smtp.gmail.com with ESMTPSA id l3sm24077645wru.36.2018.11.21.07.02.39 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 21 Nov 2018 07:02:40 -0800 (PST) Date: Wed, 21 Nov 2018 15:02:00 -0000 From: Andrew Burgess To: Mathieu Tarral Cc: "gdb@sourceware.org" Subject: Re: Force software breakpoint on read-only memory Message-ID: <20181121150238.GZ16539@embecosm.com> References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Fortune: Birthdays are like busses, never the number you want. X-Editor: GNU Emacs [ http://www.gnu.org/software/emacs ] User-Agent: Mutt/1.9.2 (2017-12-15) X-IsSubscribed: yes X-SW-Source: 2018-11/txt/msg00019.txt.bz2 * Mathieu Tarral [2018-11-21 09:40:15 +0000]: > Hi, > > I'm trying to set a software breakpoint on a read-only memory page. > GDB automatically sets the breakpoint as hardware, but I would like to > keep using software breakpoints. > > I found the `set breakpoint auto-hw off option in` in the > documentation: > "If the target provides a memory map, GDB will warn when > trying to set software breakpoint at a read-only address." > > However, even when I set it, GDB gives me a warning and my command is aborted: > > $ gdb -x gdbinit ~/tmp/ntoskrnl.exe > 0x80545c9f in ?? () > (gdb) set breakpoint auto-hw off > (gdb) b NtOpenFile > Breakpoint 1 at 0x4a30b1 > (gdb) continue > Continuing. > Warning: > Cannot insert breakpoint 1. > Cannot set software breakpoint at read-only address 0x4a30b1 > > Command aborted. > (gdb) > > > > My stub interacts directly with the guest hardware, from the > hypervisor, so I can bypass the read-only protections. > That's why i wanted to force the software breakpoint > and ignore the memory map. > > Is this a bug in GDB ? Not in the sense that this is the designed behaviour. Once GDB has a memory map it assumes this is accurate. When it spots you trying to place a breakpoint in read-only memory if checks the 'auto-hw' setting. If this is on then it converts to a h/w breakpoint, otherwise, it fails, after all you can't write to read-only memory. The place to look in the GDB source is gdb/breakpoint.c:insert_bp_location. My question would be, do you allow _all_ writes to read-only memory, or only breakpoint writes? If it's all, then could you "fix" the memory map? If you only want to allow s/w breakpoint writes then you'll need to hack GDB, possibly adding a switch to ignore memory maps for s/w breakpoints. Thanks, Andrew > > Thanks ! > -- > Mathieu Tarral > > Sent with ProtonMail Secure Email.