From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 2960 invoked by alias); 12 Jan 2011 04:03:14 -0000 Received: (qmail 2827 invoked by uid 22791); 12 Jan 2011 04:03:12 -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; Wed, 12 Jan 2011 04:03:04 +0000 Received: (qmail 10424 invoked from network); 12 Jan 2011 04:03:02 -0000 Received: from unknown (HELO ?198.18.137.225?) (yao@127.0.0.2) by mail.codesourcery.com with ESMTPA; 12 Jan 2011 04:03:02 -0000 Message-ID: <4D2D27F2.7050303@codesourcery.com> Date: Wed, 12 Jan 2011 05:39:00 -0000 From: Yao Qi User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.2.13) Gecko/20101208 Thunderbird/3.1.7 MIME-Version: 1.0 To: gdb-patches@sourceware.org Subject: [try 3rd] arm_pc_is_thumb takes displaced stepping into account References: <4D0F0ABA.9010506@codesourcery.com> <201012200804.oBK84oPu005379@glazunov.sibelius.xs4all.nl> <4D0F5D36.2040909@codesourcery.com> <4D10D377.8080100@codesourcery.com> <20101223042236.GS2596@adacore.com> <4D12F3A8.3020102@codesourcery.com> In-Reply-To: <4D12F3A8.3020102@codesourcery.com> Content-Type: multipart/mixed; boundary="------------080905050106060800020100" 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-01/txt/msg00248.txt.bz2 This is a multi-part message in MIME format. --------------080905050106060800020100 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Content-length: 901 On 12/23/2010 01:00 AM, Yao Qi wrote: > OK. I have to try the second approach, which is 1) exposing displaced > stepping state to tdep, and 2) take displaced stepping state into > account when determining the mode. > After talked with Ulrich, I realize that it is *not* a good idea to expose displaced stepping outside of infrun, and my patch is a little bit too intrusive. > 2010-12-23 Yao Qi > > * arm-tdep.c: (arm_pc_is_thumb): Adjust MEMADDR if it is within > copy area of displaced stepping. > * infrun.c (struct displaced_step_inferior_state): Move to ... > Expose get_displaced_stepping_state. > * inferior.h: ... here. > Declare get_displaced_stepping_state. This time, instead of exposing displaced_step_inferior_state to tdep, we return displaced_step_closure, which is defined by each tdep, instance to tdep appropriately. OK to mainline? -- Yao Qi --------------080905050106060800020100 Content-Type: text/x-patch; name="arm_displace_step_in_thumb_0111.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="arm_displace_step_in_thumb_0111.patch" Content-length: 2445 gdb/ * infrun.c (get_displaced_step_closure_by_addr): New. * inferior.h: Declare it. * arm-tdep.c: (arm_pc_is_thumb): Call get_displaced_step_closure_by_addr. Adjust MEMADDR if it returns non-NULL. diff --git a/gdb/arm-tdep.c b/gdb/arm-tdep.c index ef4d9f3..fb080c1 100644 --- a/gdb/arm-tdep.c +++ b/gdb/arm-tdep.c @@ -368,6 +368,20 @@ arm_pc_is_thumb (struct gdbarch *gdbarch, CORE_ADDR memaddr) struct obj_section *sec; struct minimal_symbol *sym; char type; + struct displaced_step_closure* dsc + = get_displaced_step_closure_by_addr(memaddr); + + /* If checking the mode of displaced instruction in copy area, the mode + should be determined by instruction on the original address. */ + if (dsc) + { + if (debug_displaced) + fprintf_unfiltered (gdb_stdlog, + "displaced: check mode of %.8lx instead of %.8lx\n", + (unsigned long) dsc->insn_addr, + (unsigned long) memaddr); + memaddr = dsc->insn_addr; + } /* If bit 0 of the address is set, assume this is a Thumb address. */ if (IS_THUMB_ADDR (memaddr)) diff --git a/gdb/inferior.h b/gdb/inferior.h index 7052d6f..a319847 100644 --- a/gdb/inferior.h +++ b/gdb/inferior.h @@ -366,6 +366,8 @@ extern int debug_displaced; void displaced_step_dump_bytes (struct ui_file *file, const gdb_byte *buf, size_t len); +struct displaced_step_closure* +get_displaced_step_closure_by_addr (CORE_ADDR addr); /* Possible values for gdbarch_call_dummy_location. */ #define ON_STACK 1 diff --git a/gdb/infrun.c b/gdb/infrun.c index dd6fe6c..0714308 100644 --- a/gdb/infrun.c +++ b/gdb/infrun.c @@ -1078,6 +1078,26 @@ add_displaced_stepping_state (int pid) return state; } +/* If inferior is in displaced stepping, and ADDR equals to starting address + of copy area, return corresponding displaced_step_closure. Otherwise, + return NULL. */ + +struct displaced_step_closure* +get_displaced_step_closure_by_addr (CORE_ADDR addr) +{ + struct displaced_step_inferior_state *displaced + = get_displaced_stepping_state (ptid_get_pid (inferior_ptid)); + + /* If checking the mode of displaced instruction in copy area. */ + if (displaced && !ptid_equal (displaced->step_ptid, null_ptid) + && (displaced->step_copy == addr)) + return displaced->step_closure; + + return NULL; +} + /* Remove the displaced stepping state of process PID. */ static void --------------080905050106060800020100--