From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 20364 invoked by alias); 17 Mar 2011 19:54:56 -0000 Received: (qmail 20353 invoked by uid 22791); 17 Mar 2011 19:54:55 -0000 X-SWARE-Spam-Status: No, hits=-1.9 required=5.0 tests=AWL,BAYES_00,T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from mail.codesourcery.com (HELO mail.codesourcery.com) (38.113.113.100) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Thu, 17 Mar 2011 19:54:15 +0000 Received: (qmail 18686 invoked from network); 17 Mar 2011 19:54:13 -0000 Received: from unknown (HELO scottsdale.localnet) (pedro@127.0.0.2) by mail.codesourcery.com with ESMTPA; 17 Mar 2011 19:54:13 -0000 From: Pedro Alves To: gdb-patches@sourceware.org Subject: Re: [PATCH] Fix instruction relocation for fast tracepoints Date: Fri, 18 Mar 2011 07:58:00 -0000 User-Agent: KMail/1.13.5 (Linux/2.6.35-27-generic; KDE/4.6.1; x86_64; ; ) Cc: Kwok Cheung Yeung References: <4D82611B.50609@codesourcery.com> In-Reply-To: <4D82611B.50609@codesourcery.com> MIME-Version: 1.0 Content-Type: Text/Plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Message-Id: <201103171954.09934.pedro@codesourcery.com> 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-03/txt/msg00907.txt.bz2 On Thursday 17 March 2011 19:29:31, Kwok Cheung Yeung wrote: > Hello > > There is a problem with the instruction relocation facility in GDB, which is > triggered when fast tracepoints are set on call or jump instructions. The third > and fourth arguments of calls to store_signed_integer (defined in findvar.c) in > the i386 and amd64 implementations of relocate_instruction are the wrong way > around, which results in a relative jump one byte forward. In the context of > fast tracepoints, this results in a jump to the address portion of another jump > instruction, which typically causes the program to crash when the tracepoint is > reached. > > This patch fixes the ordering of the arguments to store_signed_integer. It also > adds debug messages to the case where a call instruction is relocated (identical > to the ones for jump instructions), and tidies up the presentation of the > messages by removing the duplicate '0x0x' prefix of hexadecimal numbers (since > hex_string and paddress already output the prefix). Thanks! This is okay for both mainline and the 7.2 branch. We should get you cvs write access so you can apply your own patches. Follow the instructions at http://sourceware.org/, and mention me as approver. Then add yourself in the Write After Approval section of gdb/MAINTAINERS. > > Kwok Cheung Yeung > > > 2011-03-17 Kwok Cheung Yeung > > * amd64-tdep.c (amd64_relocate_instruction): Fix ordering of arguments > to store_signed_integer. Add debug message when relocating CALL > instructions. Fix formatting of debug message. > * i386-tdep.c (i386_relocate_instruction): Ditto. > > --- gdb-7.2/gdb/amd64-tdep.c 2010-05-26 19:19:26.000000000 +0100 > +++ gdb-7.2.new/gdb/amd64-tdep.c 2011-03-17 18:28:11.390662621 +0000 > @@ -1588,7 +1588,14 @@ amd64_relocate_instruction (struct gdbar > /* Adjust the destination offset. */ > rel32 = extract_signed_integer (insn + 1, 4, byte_order); > newrel = (oldloc - *to) + rel32; > - store_signed_integer (insn + 1, 4, newrel, byte_order); > + store_signed_integer (insn + 1, 4, byte_order, newrel); > + > + if (debug_displaced) > + fprintf_unfiltered (gdb_stdlog, > + "Adjusted insn rel32=%s at %s to" > + " rel32=%s at %s\n", > + hex_string (rel32), paddress (gdbarch, oldloc), > + hex_string (newrel), paddress (gdbarch, *to)); > > /* Write the adjusted jump into its displaced location. */ > append_insns (to, 5, insn); > @@ -1611,11 +1618,11 @@ amd64_relocate_instruction (struct gdbar > { > rel32 = extract_signed_integer (insn + offset, 4, byte_order); > newrel = (oldloc - *to) + rel32; > - store_signed_integer (insn + offset, 4, newrel, byte_order); > + store_signed_integer (insn + offset, 4, byte_order, newrel); > if (debug_displaced) > fprintf_unfiltered (gdb_stdlog, > - "Adjusted insn rel32=0x%s at 0x%s to" > - " rel32=0x%s at 0x%s\n", > + "Adjusted insn rel32=%s at %s to" > + " rel32=%s at %s\n", > hex_string (rel32), paddress (gdbarch, oldloc), > hex_string (newrel), paddress (gdbarch, *to)); > } > --- gdb-7.2/gdb/i386-tdep.c 2010-06-22 03:15:45.000000000 +0100 > +++ gdb-7.2.new/gdb/i386-tdep.c 2011-03-17 18:28:11.398608604 +0000 > @@ -747,7 +747,14 @@ i386_relocate_instruction (struct gdbarc > /* Adjust the destination offset. */ > rel32 = extract_signed_integer (insn + 1, 4, byte_order); > newrel = (oldloc - *to) + rel32; > - store_signed_integer (insn + 1, 4, newrel, byte_order); > + store_signed_integer (insn + 1, 4, byte_order, newrel); > + > + if (debug_displaced) > + fprintf_unfiltered (gdb_stdlog, > + "Adjusted insn rel32=%s at %s to" > + " rel32=%s at %s\n", > + hex_string (rel32), paddress (gdbarch, oldloc), > + hex_string (newrel), paddress (gdbarch, *to)); > > /* Write the adjusted jump into its displaced location. */ > append_insns (to, 5, insn); > @@ -766,11 +773,11 @@ i386_relocate_instruction (struct gdbarc > { > rel32 = extract_signed_integer (insn + offset, 4, byte_order); > newrel = (oldloc - *to) + rel32; > - store_signed_integer (insn + offset, 4, newrel, byte_order); > + store_signed_integer (insn + offset, 4, byte_order, newrel); > if (debug_displaced) > fprintf_unfiltered (gdb_stdlog, > - "Adjusted insn rel32=0x%s at 0x%s to" > - " rel32=0x%s at 0x%s\n", > + "Adjusted insn rel32=%s at %s to" > + " rel32=%s at %s\n", > hex_string (rel32), paddress (gdbarch, oldloc), > hex_string (newrel), paddress (gdbarch, *to)); > } > -- Pedro Alves