From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 11897 invoked by alias); 8 Sep 2011 17:16:24 -0000 Received: (qmail 11882 invoked by uid 22791); 8 Sep 2011 17:16:19 -0000 X-SWARE-Spam-Status: No, hits=-2.6 required=5.0 tests=AWL,BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,RP_MATCHES_RCVD,SPF_HELO_PASS X-Spam-Check-By: sourceware.org Received: from smtp-out.google.com (HELO smtp-out.google.com) (74.125.121.67) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Thu, 08 Sep 2011 17:16:04 +0000 Received: from hpaq3.eem.corp.google.com (hpaq3.eem.corp.google.com [172.25.149.3]) by smtp-out.google.com with ESMTP id p88HG1De005336 for ; Thu, 8 Sep 2011 10:16:01 -0700 Received: from yib12 (yib12.prod.google.com [10.243.65.76]) by hpaq3.eem.corp.google.com with ESMTP id p88HFTgS009848 (version=TLSv1/SSLv3 cipher=RC4-SHA bits=128 verify=NOT) for ; Thu, 8 Sep 2011 10:15:59 -0700 Received: by yib12 with SMTP id 12so94012yib.38 for ; Thu, 08 Sep 2011 10:15:59 -0700 (PDT) Received: by 10.91.101.3 with SMTP id d3mr904063agm.45.1315502159404; Thu, 08 Sep 2011 10:15:59 -0700 (PDT) MIME-Version: 1.0 Received: by 10.91.101.3 with SMTP id d3mr904055agm.45.1315502159108; Thu, 08 Sep 2011 10:15:59 -0700 (PDT) Received: by 10.90.84.9 with HTTP; Thu, 8 Sep 2011 10:15:59 -0700 (PDT) In-Reply-To: <20110722215821.GA3433@host1.jankratochvil.net> References: <20110722215821.GA3433@host1.jankratochvil.net> Date: Thu, 08 Sep 2011 17:31:00 -0000 Message-ID: Subject: Re: [patch] workaround gcc46: prologue skip skips too far (PR 12435) #2 From: Doug Evans To: Jan Kratochvil Cc: gdb-patches@sourceware.org Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-System-Of-Record: true X-IsSubscribed: yes 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 X-SW-Source: 2011-09/txt/msg00145.txt.bz2 On Fri, Jul 22, 2011 at 2:58 PM, Jan Kratochvil wrote: > Hi, > > this is an improved patch of a former: > =A0 =A0 =A0 =A0[patch] workaround gcc46: prologue skip skips too far (PR = 12435) > =A0 =A0 =A0 =A0http://sourceware.org/ml/gdb-patches/2011-03/msg01108.html > =A0 =A0 =A0 =A0cancel/FYI: Re: [patch] workaround gcc46: prologue skip sk= ips too far (PR 12435) > =A0 =A0 =A0 =A0http://sourceware.org/ml/gdb-patches/2011-03/msg01123.html > > [...] > > I will update the code after FSF gcc gets fixed to minimize the workaroun= d. I realize this is checked in, but a couple of comments for maybe the next patch for this. > [...] > > --- a/gdb/amd64-tdep.c > +++ b/gdb/amd64-tdep.c > @@ -1902,6 +1902,9 @@ amd64_skip_prologue (struct gdbarch *gdbarch, CORE_= ADDR start_pc) > =A0{ > =A0 struct amd64_frame_cache cache; > =A0 CORE_ADDR pc; > + =A0struct symtab_and_line start_pc_sal, next_sal; > + =A0gdb_byte buf[4 + 8 * 7]; > + =A0int offset, xmmreg; > > =A0 amd64_init_frame_cache (&cache); > =A0 pc =3D amd64_analyze_prologue (gdbarch, start_pc, 0xffffffffffffffffL= L, > @@ -1909,7 +1912,71 @@ amd64_skip_prologue (struct gdbarch *gdbarch, CORE= _ADDR start_pc) > =A0 if (cache.frameless_p) > =A0 =A0 return start_pc; > > - =A0return pc; > + =A0/* GCC PR debug/48827 produced false prologue end: > + =A0 =A0 84 c0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0test =A0 %al,%al > + =A0 =A0 74 23 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0je =A0 =A0 after > + =A0 =A0 <-- here is 0 lines advance - the false prologue end marker. > + =A0 =A0 0f 29 85 70 ff ff ff movaps %xmm0,-0x90(%rbp) > + =A0 =A0 0f 29 4d 80 =A0 =A0 =A0 =A0 =A0movaps %xmm1,-0x80(%rbp) > + =A0 =A0 0f 29 55 90 =A0 =A0 =A0 =A0 =A0movaps %xmm2,-0x70(%rbp) > + =A0 =A0 0f 29 5d a0 =A0 =A0 =A0 =A0 =A0movaps %xmm3,-0x60(%rbp) > + =A0 =A0 0f 29 65 b0 =A0 =A0 =A0 =A0 =A0movaps %xmm4,-0x50(%rbp) > + =A0 =A0 0f 29 6d c0 =A0 =A0 =A0 =A0 =A0movaps %xmm5,-0x40(%rbp) > + =A0 =A0 0f 29 75 d0 =A0 =A0 =A0 =A0 =A0movaps %xmm6,-0x30(%rbp) > + =A0 =A0 0f 29 7d e0 =A0 =A0 =A0 =A0 =A0movaps %xmm7,-0x20(%rbp) > + =A0 =A0 after: =A0*/ > + > + =A0if (pc =3D=3D start_pc) > + =A0 =A0return pc; > + > + =A0start_pc_sal =3D find_pc_sect_line (start_pc, NULL, 0); > + =A0if (start_pc_sal.symtab =3D=3D NULL > + =A0 =A0 =A0|| !start_pc_sal.symtab->amd64_prologue_line_bug > + =A0 =A0 =A0|| start_pc_sal.pc !=3D start_pc || pc >=3D start_pc_sal.end) > + =A0 =A0return pc; > + > + =A0next_sal =3D find_pc_sect_line (start_pc_sal.end, NULL, 0); > + =A0if (next_sal.line !=3D start_pc_sal.line) > + =A0 =A0return pc; > + > + =A0/* START_PC can be from overlayed memory, ignored here. =A0*/ > + =A0if (target_read_memory (next_sal.pc - 4, buf, sizeof (buf)) !=3D 0) > + =A0 =A0return pc; > + > + =A0/* test %al,%al */ > + =A0if (buf[0] !=3D 0x84 || buf[1] !=3D 0xc0) > + =A0 =A0return pc; > + =A0/* je AFTER */ > + =A0if (buf[2] !=3D 0x74) > + =A0 =A0return pc; > + > + =A0offset =3D 4; > + =A0for (xmmreg =3D 0; xmmreg < 8; xmmreg++) > + =A0 =A0{ > + =A0 =A0 =A0/* movaps %xmmreg?,-0x??(%rbp) */ > + =A0 =A0 =A0if (buf[offset] !=3D 0x0f || buf[offset + 1] !=3D 0x29 > + =A0 =A0 =A0 =A0 =A0|| (buf[offset + 2] & 0b00111111) !=3D (xmmreg << 3 = | 0b101)) > + =A0 =A0 =A0 return pc; > + > + =A0 =A0 =A0if ((buf[offset + 2] & 0b11000000) =3D=3D 0b01000000) > + =A0 =A0 =A0 { > + =A0 =A0 =A0 =A0 /* 8-bit displacement. =A0*/ > + =A0 =A0 =A0 =A0 offset +=3D 4; > + =A0 =A0 =A0 } > + =A0 =A0 =A0else if ((buf[offset + 2] & 0b11000000) =3D=3D 0b10000000) > + =A0 =A0 =A0 { > + =A0 =A0 =A0 =A0 /* 32-bit displacement. =A0*/ > + =A0 =A0 =A0 =A0 offset +=3D 7; > + =A0 =A0 =A0 } > + =A0 =A0 =A0else > + =A0 =A0 =A0 return pc; > + =A0 =A0} > + > + =A0/* je AFTER */ > + =A0if (offset - 4 !=3D buf[3]) > + =A0 =A0return pc; > + > + =A0return next_sal.end; > =A0} These kinds of functions tend to grow and grow and become hard to maintain. IWBN if all this new code is about a specific issue then tuck it away in its own function. [Or at least document both the start and end of it.] > [...] > > --- a/gdb/symtab.h > +++ b/gdb/symtab.h > @@ -784,6 +784,11 @@ struct symtab > > =A0 unsigned int epilogue_unwind_valid : 1; > > + =A0/* At least GCC 4.6.0 and 4.6.1 can produce invalid false prologue a= nd marker > + =A0 =A0 on amd64. =A0This flag is set independently of the symtab arch.= =A0*/ > + > + =A0unsigned amd64_prologue_line_bug : 1; > + > =A0 /* The macro table for this symtab. =A0Like the blockvector, this > =A0 =A0 =A0may be shared between different symtabs --- and normally is for > =A0 =A0 =A0all the symtabs in a given compilation unit. =A0*/ I can hear the screams of pushback if a random net person wanted to check in anything architecture specific to the architecture independent part of gdb. :-)