From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 56230 invoked by alias); 23 Mar 2016 14:14:47 -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 56164 invoked by uid 89); 23 Mar 2016 14:14:47 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_PASS,T_RP_MATCHES_RCVD autolearn=ham version=3.3.2 spammy=ldi, resumes, D*atmel.com, H*Ad:D*atmel.com X-HELO: eusmtp01.atmel.com Received: from eusmtp01.atmel.com (HELO eusmtp01.atmel.com) (212.144.249.242) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-SHA encrypted) ESMTPS; Wed, 23 Mar 2016 14:14:36 +0000 Received: from HNOCHT02.corp.atmel.com (10.161.30.162) by eusmtp01.atmel.com (10.161.101.30) with Microsoft SMTP Server (TLS) id 14.3.235.1; Wed, 23 Mar 2016 15:14:28 +0100 Received: from CHELT0346 (10.161.30.18) by HNOCHT02.corp.atmel.com (10.161.30.162) with Microsoft SMTP Server (TLS) id 14.3.235.1; Wed, 23 Mar 2016 15:14:32 +0100 Date: Wed, 23 Mar 2016 14:14:00 -0000 From: Pitchumani Sivanupandi To: , CC: , Subject: [patch, avr, pr19401] Update PC after break Message-ID: <20160323141426.GA10252@CHELT0346> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="2oS5YaxWCcQjTEyO" Content-Disposition: inline User-Agent: Mutt/1.5.24 (2015-08-30) X-IsSubscribed: yes X-SW-Source: 2016-03/txt/msg00469.txt.bz2 --2oS5YaxWCcQjTEyO Content-Type: text/plain; charset="us-ascii" Content-Disposition: inline Content-length: 2172 avr-gdb doesn't seem to be rewinding the PC after break. If a breakpoint is at four byte instruction, it resumes from the middle of the instruction. This caused the target to reject the next (half) instruction as illegal. In case of breakpoint at two byte instruction, it resumes from the the next instruction. Instruction at breakpoint location was skipped as the PC was rewinded after break. Test case in PR19401 is the example for the first situation. Below example is for second situation. volatile int a = 12; int main () { a = 23; while (1) a++; return 0; } command line: avr-gcc test.c -mmcu=atmega2560 -g -o test.elf avr-gdb test.elf (gdb) target sim (gdb) load (gdb) b main (gdb) run 0x00000124 in main () at sim1.c:5 5 a = 0x0123; (gdb) disassemble Dump of assembler code for function main: 0x0000011a <+0>: push r28 0x0000011c <+2>: push r29 0x0000011e <+4>: in r28, 0x3d ; 61 0x00000120 <+6>: in r29, 0x3e ; 62 0x00000122 <+8>: ldi r24, 0x23 ; 35 => 0x00000124 <+10>: ldi r25, 0x01 ; 1 0x00000126 <+12>: sts 0x0201, r25 0x0000012a <+16>: sts 0x0200, r24 0x0000012e <+20>: lds r24, 0x0200 0x00000132 <+24>: lds r25, 0x0201 0x00000136 <+28>: adiw r24, 0x01 ; 1 0x00000138 <+30>: sts 0x0201, r25 0x0000013c <+34>: sts 0x0200, r24 0x00000140 <+38>: rjmp .-20 ; 0x12e End of assembler dump. (gdb) si 0x00000126 5 a = 0x0123; (gdb) p $r24 $1 = 0 (gdb) p $r25 $2 = 1 -- Register r24 should have value 0x23. Attached patch decrements the PC after break so that target can execute the instruction at breakpoint location. No regressions found when tested with the simulator. If ok, could someone commit please? I do not have commit access. Regards, Pitchumani gdb/ChangeLog 2016-03-23 Pitchumani Sivanupandi * avr-tdep.c (avr_break_insn): Define. (avr_breakpoint_from_pc): Remove avr_break_insn define. (avr_gdbarch_init): Set decr_pc_after_break hook with the size of the break instruction. --2oS5YaxWCcQjTEyO Content-Type: text/plain; charset="us-ascii" Content-Disposition: attachment; filename="pr19401.patch" Content-length: 1090 diff --git a/gdb/avr-tdep.c b/gdb/avr-tdep.c index 088fe51..be53db2 100644 --- a/gdb/avr-tdep.c +++ b/gdb/avr-tdep.c @@ -236,6 +236,8 @@ avr_register_type (struct gdbarch *gdbarch, int reg_nr) return builtin_type (gdbarch)->builtin_uint8; } +static const unsigned char avr_break_insn [] = { 0x98, 0x95 }; + /* Instruction address checks and convertions. */ static CORE_ADDR @@ -916,7 +918,6 @@ static const unsigned char * avr_breakpoint_from_pc (struct gdbarch *gdbarch, CORE_ADDR *pcptr, int *lenptr) { - static const unsigned char avr_break_insn [] = { 0x98, 0x95 }; *lenptr = sizeof (avr_break_insn); return avr_break_insn; } @@ -1518,6 +1519,7 @@ avr_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches) set_gdbarch_inner_than (gdbarch, core_addr_lessthan); set_gdbarch_breakpoint_from_pc (gdbarch, avr_breakpoint_from_pc); + set_gdbarch_decr_pc_after_break (gdbarch, sizeof (avr_break_insn)); frame_unwind_append_unwinder (gdbarch, &avr_frame_unwind); frame_base_set_default (gdbarch, &avr_frame_base); --2oS5YaxWCcQjTEyO--