From patchwork Wed Nov 5 03:53:04 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sandra Loosemore X-Patchwork-Id: 3582 Received: (qmail 27667 invoked by alias); 5 Nov 2014 03:53:16 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Delivered-To: mailing list gdb-patches@sourceware.org Received: (qmail 27655 invoked by uid 89); 5 Nov 2014 03:53:14 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.7 required=5.0 tests=AWL, BAYES_00, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.2 X-HELO: relay1.mentorg.com Received: from relay1.mentorg.com (HELO relay1.mentorg.com) (192.94.38.131) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 05 Nov 2014 03:53:12 +0000 Received: from svr-orw-fem-05.mgc.mentorg.com ([147.34.97.43]) by relay1.mentorg.com with esmtp id 1Xlref-00072f-Ip from Sandra_Loosemore@mentor.com for gdb-patches@sourceware.org; Tue, 04 Nov 2014 19:53:09 -0800 Received: from [IPv6:::1] (147.34.91.1) by svr-orw-fem-05.mgc.mentorg.com (147.34.97.43) with Microsoft SMTP Server id 14.3.181.6; Tue, 4 Nov 2014 19:53:06 -0800 Message-ID: <54599F20.1090300@codesourcery.com> Date: Tue, 4 Nov 2014 20:53:04 -0700 From: Sandra Loosemore User-Agent: Mozilla/5.0 (X11; Linux i686; rv:17.0) Gecko/20130329 Thunderbird/17.0.5 MIME-Version: 1.0 To: CC: Yao Qi Subject: [patch, nios2] remove obsolete code sequences from prologue analyzer This patch removes detection of some obsolete code sequences from the Nios II prologue analyzer, as part of the campaign to get rid of literal instruction encodings from this code. The first sequence is profiling code generated by some very old version of GCC -- it was already noted in the code as being obsolete in Altera's GCC 3.4-based out-of-tree toolchain port that formed the basis for what is now in the FSF repository. The second sequence is for hand-written interrupt handler code in some similarly ancient version of Altera's HAL development environment. Altera has indicated that preserving support for debugging legacy code generated by such old toolchain versions in current and future versions of GDB is not a priority for them. OK to commit? -Sandra diff --git a/gdb/nios2-tdep.c b/gdb/nios2-tdep.c index 69cefac..1b647ac 100644 --- a/gdb/nios2-tdep.c +++ b/gdb/nios2-tdep.c @@ -331,58 +331,6 @@ nios2_in_function_epilogue_p (struct gdbarch *gdbarch, CORE_ADDR pc) return 0; } -/* Define some instruction patterns supporting wildcard bits via a - mask. */ - -typedef struct -{ - unsigned int insn; - unsigned int mask; -} wild_insn; - -static const wild_insn profiler_insn[] = -{ - { 0x0010e03a, 0x00000000 }, /* nextpc r8 */ - { 0xf813883a, 0x00000000 }, /* mov r9,ra */ - { 0x02800034, 0x003fffc0 }, /* movhi r10,257 */ - { 0x52800004, 0x003fffc0 }, /* addi r10,r10,-31992 */ - { 0x00000000, 0xffffffc0 }, /* call */ - { 0x483f883a, 0x00000000 } /* mov ra,r9 */ -}; - -static const wild_insn irqentry_insn[] = -{ - { 0x0031307a, 0x00000000 }, /* rdctl et,estatus */ - { 0xc600004c, 0x00000000 }, /* andi et,et,1 */ - { 0xc0000026, 0x003fffc0 }, /* beq et,zero, */ - { 0x0031313a, 0x00000000 }, /* rdctl et,ipending */ - { 0xc0000026, 0x003fffc0 } /* beq et,zero, */ -}; - - -/* Attempt to match SEQUENCE, which is COUNT insns long, at START_PC. */ - -static int -nios2_match_sequence (struct gdbarch *gdbarch, CORE_ADDR start_pc, - const wild_insn *sequence, int count) -{ - CORE_ADDR pc = start_pc; - int i; - unsigned int insn; - enum bfd_endian byte_order = gdbarch_byte_order (gdbarch); - - for (i = 0 ; i < count ; i++) - { - insn = read_memory_unsigned_integer (pc, NIOS2_OPCODE_SIZE, byte_order); - if ((insn & ~sequence[i].mask) != sequence[i].insn) - return 0; - - pc += NIOS2_OPCODE_SIZE; - } - - return 1; -} - /* Do prologue analysis, returning the PC of the first instruction after the function prologue. Assumes CACHE has already been initialized. THIS_FRAME can be null, in which case we are only @@ -390,30 +338,15 @@ nios2_match_sequence (struct gdbarch *gdbarch, CORE_ADDR start_pc, from the frame information. The prologue will consist of the following parts: - 1) Optional profiling instrumentation. The old version uses six - instructions. We step over this if there is an exact match. - nextpc r8 - mov r9, ra - movhi r10, %hiadj(.LP2) - addi r10, r10, %lo(.LP2) - call mcount - mov ra, r9 - The new version uses two or three instructions (the last of + 1) Optional profiling instrumentation. + This uses two or three instructions (the last of these might get merged in with the STW which saves RA to the stack). We interpret these. mov r8, ra call mcount mov ra, r8 - 2) Optional interrupt entry decision. Again, we step over - this if there is an exact match. - rdctl et,estatus - andi et,et,1 - beq et,zero, - rdctl et,ipending - beq et,zero, - - 3) A stack adjustment or stack which, which will be one of: + 2) A stack adjustment or stack which, which will be one of: addi sp, sp, -constant or: movi r8, constant @@ -428,7 +361,7 @@ nios2_match_sequence (struct gdbarch *gdbarch, CORE_ADDR start_pc, stw sp, constant(rx) mov sp, rx - 4) An optional stack check, which can take either of these forms: + 3) An optional stack check, which can take either of these forms: bgeu sp, rx, +8 break 3 or @@ -437,7 +370,7 @@ nios2_match_sequence (struct gdbarch *gdbarch, CORE_ADDR start_pc, .Lstack_overflow: break 3 - 5) Saving any registers which need to be saved. These will + 4) Saving any registers which need to be saved. These will normally just be stored onto the stack: stw rx, constant(sp) but in the large frame case will use r8 as an offset back @@ -449,7 +382,7 @@ nios2_match_sequence (struct gdbarch *gdbarch, CORE_ADDR start_pc, rdctl rx, ctlN stw rx, constant(sp) - 6) An optional FP setup, either if the user has requested a + 5) An optional FP setup, either if the user has requested a frame pointer or if the function calls alloca. This is always: mov fp, sp @@ -511,23 +444,6 @@ nios2_analyze_prologue (struct gdbarch *gdbarch, const CORE_ADDR start_pc, /* Set up the default values of the registers. */ nios2_setup_default (cache); - - /* If the first few instructions are the profile entry, then skip - over them. Newer versions of the compiler use more efficient - profiling code. */ - if (nios2_match_sequence (gdbarch, pc, profiler_insn, - ARRAY_SIZE (profiler_insn))) - pc += ARRAY_SIZE (profiler_insn) * NIOS2_OPCODE_SIZE; - - /* If the first few instructions are an interrupt entry, then skip - over them too. */ - if (nios2_match_sequence (gdbarch, pc, irqentry_insn, - ARRAY_SIZE (irqentry_insn))) - { - pc += ARRAY_SIZE (irqentry_insn) * NIOS2_OPCODE_SIZE; - exception_handler = 1; - } - prologue_end = start_pc; /* Find the prologue instructions. */