From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 28406 invoked by alias); 18 Apr 2013 08:37:24 -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 28396 invoked by uid 89); 18 Apr 2013 08:37:23 -0000 X-Spam-SWARE-Status: No, score=-2.8 required=5.0 tests=AWL,BAYES_00,KHOP_RCVD_UNTRUST,KHOP_THREADED,RCVD_IN_DNSWL_LOW,RCVD_IN_HOSTKARMA_NO,RCVD_IN_HOSTKARMA_YE autolearn=ham version=3.3.1 Received: from mail-la0-f50.google.com (HELO mail-la0-f50.google.com) (209.85.215.50) by sourceware.org (qpsmtpd/0.84/v0.84-167-ge50287c) with ESMTP; Thu, 18 Apr 2013 08:37:18 +0000 Received: by mail-la0-f50.google.com with SMTP id el20so2308439lab.37 for ; Thu, 18 Apr 2013 01:37:16 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-received:mime-version:in-reply-to:references:from:date:message-id :subject:to:cc:content-type:x-gm-message-state; bh=0b6t9dmCMbnBV1P5LEH/pMy3wtTq5kr/zimmFjG9kDk=; b=Qus83ekbtKPxavIUHV8Eme5HN9mI7614Y0mxO50yUgjH/zSKfECPpj7G93T1Ld2hGt Nos0Sefsmu2WT9r6A0ykB1H3JXBwyYFlkqPGkLj4dtXYr9q1Wm78bI3LzXeDuR1uJPfV ZM8lo5lpfZnZoZ+ljlyrJzTN/eQtfo4fp8e/ancJwVBA1U1w9+y9/w4q4xcrxPcGkdK3 NX71tz1Z9Gdel+O0qqD9OlcDDQox1nFIk9NAbYlO/8jkH3Bu7WBBFOQak20MZedH9Scc o+C+25bYCnUowIAqWB6H4MSCaYvoGFSSmSRsxTTnkKb21hDGxpPFflTIUueSJPw+bduX JFww== X-Received: by 10.112.125.33 with SMTP id mn1mr5355087lbb.89.1366274235957; Thu, 18 Apr 2013 01:37:15 -0700 (PDT) MIME-Version: 1.0 Received: by 10.112.198.198 with HTTP; Thu, 18 Apr 2013 01:36:55 -0700 (PDT) In-Reply-To: <1365679257.9625.0@abidh-ubunto1104> References: <1365679257.9625.0@abidh-ubunto1104> From: Peter Maydell Date: Thu, 18 Apr 2013 08:37:00 -0000 Message-ID: Subject: Re: [Qemu-devel] GDB function call failing due to memory protection of stack page in QEMU To: "Abid, Hafiz" Cc: qemu-devel@nongnu.org, gdb@sourceware.org, riku.voipio@iki.fi, macro@codesourcery.com Content-Type: text/plain; charset=UTF-8 X-Gm-Message-State: ALoCoQkiglwYy5klNAy60kpiUXxR5Bus6GpPLX0Yl6ordDBLwd8QROpX08zdbG8D9XHXCnnbni+Y X-SW-Source: 2013-04/txt/msg00052.txt.bz2 On 11 April 2013 12:20, Abid, Hafiz wrote: > Hi All, > I have faced a problem using GDB with user-mode qemu. Although problem was > observed for MIPS, I think it is a generic problem. I would appreciate an > advice from experts on how best to deal with. Here is the problem > description. > > GDB has ability to call function from the program being debugged > (http://sourceware.org/gdb/onlinedocs/gdb/Calling.html#Calling). For MIPS > (and on other architectures), it put a breakpoint on the stack that is used > as return address of the function. When that breakpoint is hit, GDB knows > that function is complete and it can return control to user. This breakpoint > on stack causes problem for QEMU. When it runs that instruction from stack, > it add write-protection to that page. So after the function call, GDB is not > able to write to stack. So any future function call or other operation that > need to write to stack will fail. I show an example session below taken > mostly from call-sc.exp of GDB testsuite. > > There are 2 possible solution in my mind. One was to allow writing memory if > this page originally had write access. This is a single line fix and a patch > is below. My worry here is that this will mean that writes by the debugger won't trigger the "code area has been written, QEMU must throw away any cached translated code for that region" check. This is a tricky area of the code... thanks -- PMM