From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 47973 invoked by alias); 11 Dec 2015 15:38:30 -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 47962 invoked by uid 89); 11 Dec 2015 15:38:28 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.3 required=5.0 tests=AWL,BAYES_00,FREEMAIL_FROM,RCVD_IN_DNSWL_LOW,SPF_PASS autolearn=ham version=3.3.2 X-HELO: mail-pa0-f54.google.com Received: from mail-pa0-f54.google.com (HELO mail-pa0-f54.google.com) (209.85.220.54) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-GCM-SHA256 encrypted) ESMTPS; Fri, 11 Dec 2015 15:38:27 +0000 Received: by padhk6 with SMTP id hk6so27038877pad.2 for ; Fri, 11 Dec 2015 07:38:25 -0800 (PST) X-Received: by 10.66.100.196 with SMTP id fa4mr25798807pab.21.1449848305793; Fri, 11 Dec 2015 07:38:25 -0800 (PST) Received: from E107787-LIN (gcc1-power7.osuosl.org. [140.211.15.137]) by smtp.gmail.com with ESMTPSA id r79sm25948173pfa.61.2015.12.11.07.38.21 (version=TLS1_2 cipher=AES128-SHA bits=128/128); Fri, 11 Dec 2015 07:38:24 -0800 (PST) From: Yao Qi To: Antoine Tremblay Cc: Yao Qi , Pedro Alves , Subject: Re: [PATCH v7.1] Support software single step on ARM in GDBServer. References: <1449583641-18156-7-git-send-email-antoine.tremblay@ericsson.com> <1449691701-11845-1-git-send-email-antoine.tremblay@ericsson.com> <8637v9qc50.fsf@gmail.com> <566AE65E.5080209@ericsson.com> Date: Fri, 11 Dec 2015 15:38:00 -0000 In-Reply-To: <566AE65E.5080209@ericsson.com> (Antoine Tremblay's message of "Fri, 11 Dec 2015 10:06:06 -0500") Message-ID: <86twnpov11.fsf@gmail.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-IsSubscribed: yes X-SW-Source: 2015-12/txt/msg00237.txt.bz2 Antoine Tremblay writes: > > I'm not sure a macro is a good thing, it often makes the code harder > to parse for ides/emacs etc... Why macro is bad? > > And I don't think shortening the lines is a good justification in > general for a macro. It is! Supposing we have a macro like this ... #define ARM_READ_UINT(MEMADDR, LEN, BYTE_ORDER) \ self->ops->read_memory_unsigned_integer ((MEMADDR), (LEN), (BYTE_ORDER)) > > How about I use a function pointer variable like : > > ULONGEST (*read_memory_uint) (CORE_ADDR memaddr, int len, int byte_order); > > read_memory_uint =3D self->ops->read_memory_unsigned_integer; > > That would be already 23 shorter. > >>> + loc +=3D 2; >>> + if (!((insn1 & 0xfff0) =3D=3D 0xe850 >>> + || ((insn1 & 0xfff0) =3D=3D 0xe8d0 && (insn2 & 0x00c0) =3D=3D = 0x0040))) >>> + return NULL; >>> + >>> + /* Assume that no atomic sequence is longer than "atomic_sequence_le= ngth" >>> + instructions. */ >>> + for (insn_count =3D 0; insn_count < atomic_sequence_length; ++insn_c= ount) >>> + { >>> + insn1 >>> + =3D self->ops->read_memory_unsigned_integer (loc, 2,byte_order_for_co= de); >>> + loc +=3D 2; >>> + >>> + if (thumb_insn_size (insn1) !=3D 4) >>> + { >>> + /* Assume that there is at most one conditional branch in the >>> + atomic sequence. If a conditional branch is found, put a >>> + breakpoint in its destination address. */ >>> + if ((insn1 & 0xf000) =3D=3D 0xd000 && bits (insn1, 8, 11) !=3D 0x0f) >>> + { >>> + if (last_breakpoint > 0) >>> + return NULL; /* More than one conditional branch found, >>> + fallback to the standard code. */ >>> + >>> + breaks[1] =3D loc + 2 + (sbits (insn1, 0, 7) << 1); >>> + last_breakpoint++; >>> + } >>> + >>> + /* We do not support atomic sequences that use any *other* >>> + instructions but conditional branches to change the PC. >>> + Fall back to standard code to avoid losing control of >>> + execution. */ >>> + else if (thumb_instruction_changes_pc (insn1)) >>> + return NULL; >>> + } >>> + else >>> + { >>> + insn2 =3D self->ops->read_memory_unsigned_integer >>> + (loc, 2, byte_order_for_code); >> >> Format looks wrong, multiple instances of this problem in the patch. >> > > Yes actually I was not sure about that and discussed this with Pedro > and he agreed this was ok. That's why I went with that. > > At some point when you have > if > if > if > long_function_name (long variable, > > And that does not fit you could have > > long_function_name ( > long variable, ... ) > > or long_function_name > (long variable, ...) > > or ? > ... then, this problem doesn't exist at all. Isn't it better below? insn2 =3D ARM_READ_UINT (loc, 2, byte_order_for_code); --=20 Yao (=E9=BD=90=E5=B0=A7)