From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 104927 invoked by alias); 2 Dec 2016 23:06:49 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Received: (qmail 104912 invoked by uid 89); 2 Dec 2016 23:06:49 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.4 required=5.0 tests=BAYES_00,FREEMAIL_FROM,RCVD_IN_DNSWL_NONE,RCVD_IN_SORBS_SPAM,SPF_PASS autolearn=no version=3.3.2 spammy=Hx-languages-length:2831, reviewed, 201612 X-HELO: mail-wm0-f66.google.com Received: from mail-wm0-f66.google.com (HELO mail-wm0-f66.google.com) (74.125.82.66) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Fri, 02 Dec 2016 23:06:39 +0000 Received: by mail-wm0-f66.google.com with SMTP id u144so4802070wmu.0 for ; Fri, 02 Dec 2016 15:06:38 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=tPBqRrbhSNv2b7JaSTov6lBL2O8N3Axr2wlbGKZj+uI=; b=MKHmnP003f2UXcryJptpIOYJaCWP60JWomoQ6rXaiNreaeXpeMP93bx+CAtWzxjiJg mpgvf/7EjWGBRzMb0MzkAGjU9WzK56bt4tl9olM7OLI/GOEyjOWOJV/tVblk4ZPix7EG hmlFhFpuZsRdiJzbBEx5RQn2SORaZwiFPjZzbdlDm4HVnbIbxWDqmuyzaXFUb0liW9jf kdN9o6BF4mHv2ftMzioAJSiU7U1/zD1JWvsptJb8wEFDyApKn7TQqDDa8WHi0oqEBBCa gHMD3a5hdbSKTiPrzzDyDkb/cd5k3ZcEdGXKgpaGv1jKjqfKJhu8tdZHajqoszMgdASw moJw== X-Gm-Message-State: AKaTC02oBwVRKspVw+Y14zxFbAyLA3ISqNqfWOZ9CL0FQD2Y63VNDXvN1wRf6H7IQ1apmA== X-Received: by 10.28.187.67 with SMTP id l64mr4735750wmf.114.1480719996973; Fri, 02 Dec 2016 15:06:36 -0800 (PST) Received: from localhost ([2a02:c7d:8e80:c00:edc6:e79a:327b:7624]) by smtp.gmail.com with ESMTPSA id i2sm7729707wjx.44.2016.12.02.15.06.36 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 02 Dec 2016 15:06:36 -0800 (PST) Date: Fri, 02 Dec 2016 23:06:00 -0000 From: Yao Qi To: Bernhard Heckel Cc: gdb-patches@sourceware.org Subject: Re: [PATCH] AMD64, Prologue: Recognize stack decrementation as prologue operation. Message-ID: <20161202230634.vbnlwdc4ge7fft4f@localhost> References: <1480601804-3128-1-git-send-email-bernhard.heckel@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1480601804-3128-1-git-send-email-bernhard.heckel@intel.com> User-Agent: NeoMutt/20161104 (1.7.1) X-IsSubscribed: yes X-SW-Source: 2016-12/txt/msg00120.txt.bz2 On 16-12-01 15:16:44, Bernhard Heckel wrote: > Some compiler decrement stack pointer within the prologue As Luis reviewed, it is clear to mention the name of the compilers here. > sequence in order to reserve memory for local variables. > Recognize this subtraction to stop at the very end of the > prologue. > > 2016-10-20 Bernhard Heckel > > gdb/Changelog: > amd64-tdep.c (amd64_analyze_prologue): Recognize stack decrementation File name should be started with "*". > as prologue operation. > > --- > gdb/amd64-tdep.c | 30 ++++++++++++++++++++++++++++++ > 1 file changed, 30 insertions(+) > > diff --git a/gdb/amd64-tdep.c b/gdb/amd64-tdep.c > index a3a1fde..795d78e 100644 > --- a/gdb/amd64-tdep.c > +++ b/gdb/amd64-tdep.c > @@ -2283,6 +2283,12 @@ amd64_analyze_prologue (struct gdbarch *gdbarch, > /* Ditto for movl %esp, %ebp. */ > static const gdb_byte mov_esp_ebp_1[2] = { 0x89, 0xe5 }; > static const gdb_byte mov_esp_ebp_2[2] = { 0x8b, 0xec }; > + /* Ditto for subtraction on the stack pointer. */ > + static const gdb_byte sub_rsp_imm8[3] = { 0x48, 0x83, 0xec }; > + static const gdb_byte sub_rsp_imm32[3] = { 0x48, 0x81, 0xec }; > + /* Ditto for subtraction on the stack pointer. */ > + static const gdb_byte sub_esp_imm8[2] = { 0x83, 0xec }; > + static const gdb_byte sub_esp_imm32[2] = { 0x81, 0xec }; > > gdb_byte buf[3]; > gdb_byte op; > @@ -2316,6 +2322,18 @@ amd64_analyze_prologue (struct gdbarch *gdbarch, > { > /* OK, we actually have a frame. */ > cache->frameless_p = 0; > + > + /* Some compiler do subtraction on the stack pointer Please mention the name of the compilers here. > + to reserve memory for local variables. > + Two common variants exist to do so. */ > + read_code (pc + 4, buf, 3); > + if (memcmp (buf, sub_rsp_imm8, 3) == 0) > + /* Operand is 1 byte. */ > + return pc + 8; > + else if (memcmp (buf, sub_rsp_imm32, 3) == 0) > + /* Operand is 4 bytes. */ > + return pc + 11; > + > return pc + 4; > } > > @@ -2327,6 +2345,18 @@ amd64_analyze_prologue (struct gdbarch *gdbarch, > { > /* OK, we actually have a frame. */ > cache->frameless_p = 0; > + > + /* Some compiler do subtraction on the stack pointer Likewise. > + to reserve memory for local variables. > + Two common variants exist to do so. */ > + read_code (pc + 3, buf, 2); > + if (memcmp (buf, sub_esp_imm8, 2) == 0) > + /* Operand is 1 byte. */ > + return pc + 6; > + else if (memcmp (buf, sub_esp_imm32, 2) == 0) > + /* Operand is 4 bytes. */ > + return pc + 9; > + Could you add a unit test for this new prologue sequences? Like what we did in this patch https://sourceware.org/ml/gdb-patches/2016-12/msg00071.html Both x86_64 and x32 prologue should be tested, because your patch is for both of them. -- Yao