From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from nx250.node01.secure-mailgate.com (nx250.node01.secure-mailgate.com [89.22.108.250]) by sourceware.org (Postfix) with ESMTPS id 21E8D3856DD0 for ; Tue, 10 May 2022 12:58:35 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 21E8D3856DD0 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=trande.de Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=trande.de Received: from host202.checkdomain.de ([185.137.168.148]) by node01.secure-mailgate.com with esmtps (TLSv1.2:AES128-GCM-SHA256:128) (Exim 4.92) (envelope-from ) id 1noPRa-002J7W-E0; Tue, 10 May 2022 14:58:30 +0200 X-SecureMailgate-Identity: zied.guermazi@trande.de;host202.checkdomain.de Received: from [192.168.178.42] (dynamic-077-180-084-243.77.180.pool.telefonica.de [77.180.84.243]) (Authenticated sender: zied.guermazi@trande.de) by host202.checkdomain.de (Postfix) with ESMTPSA id 1D2A1280CB1; Tue, 10 May 2022 14:58:20 +0200 (CEST) X-SecureMailgate-Identity: zied.guermazi@trande.de;host202.checkdomain.de Message-ID: Date: Tue, 10 May 2022 14:58:19 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.8.1 Subject: Re: [PATCH v6 3/7] start/stop btrace with coresight etm and parse etm buffer. nat independant Content-Language: en-US To: "Metzger, Markus T" Cc: "gdb-patches@sourceware.org" References: <20210531213307.275079-1-zied.guermazi@trande.de> <20210531213307.275079-4-zied.guermazi@trande.de> <94c5034f-c042-9e24-8120-17b3ca59287b@trande.de> From: Zied Guermazi In-Reply-To: X-PPP-Message-ID: <20220510125820.2744654.79880@host202.checkdomain.de> X-PPP-Vhost: trande.de X-Originating-IP: 185.137.168.148 X-SecureMailgate-Domain: host202.checkdomain.de X-SecureMailgate-Username: 185.137.168.148 Authentication-Results: secure-mailgate.com; auth=pass smtp.auth=185.137.168.148@host202.checkdomain.de X-SecureMailgate-Outgoing-Class: ham X-SecureMailgate-Outgoing-Evidence: Combined (0.02) X-Recommended-Action: accept X-Filter-ID: Pt3MvcO5N4iKaDQ5O6lkdGlMVN6RH8bjRMzItlySaT/ysIcF2lmb6zNQ2g222zbBPUtbdvnXkggZ 3YnVId/Y5jcf0yeVQAvfjHznO7+bT5xepKJyYLZISh0ScmnJxtOQL++T0fzDkcbraJCnPSgcQrqW ghmgrvbuYBMbgPFqhEjKF590ee3aGyyzch48U9RYPumU89c8OaxcWLmp7ynpEgMcwvdHCUpYqM48 99HmuDjasE0yYSwoSJtDBJTXEF44+qKA9WNimSzzMEEnsLmJnD3bQmEqUddg4pDcHxi62gxzSOZO aYOlkYc6lCBjGxXRtrdIeJGUu23VykQIijZdTM9OO12tKvW9/EX5OZ0Bv15y8oFzlZDzSFMZMCEJ KqX3DU5uCP5D/CUxYBzL65HHiH6YFrhxVw5i30CZMe0+JKoB15eMIME6iZU0/33rc4pTBldNoc4/ ugpbufbubK+x4vA/QHsSr98zh4ylHHSOvF4EizIlMC06U8aFKFbkglvNo7UbuWzwvM5eRjzlfUYD MWFgOK8gW+hazh84oBeMtGGs+REr5it4yuwWmXN5FmKajBUnmlmmmmIH8Dg80WcRp/siHDX/Zpgn R2L6ZSxUhuCgUnzQUUh7zrY+gccQHlvFmt+fzLCFvNtAPKUqO5VGqp8FbbUxmz2UNr7o91bamklX 2ibJH6e7tvxuTzj4jek2E1+Q9DR4YbQGRn/SCFVSMcnBwnfP7vEWuFdTNkRGVKAamUdylUIKhf3z 2GAHxH7IVsiIEM7JXlUJp+2U5tuI2sRuIJyuhZR+P8yF7St/bF2Uq7Vd5uBJqcr9ZIit2KdVZx2d pNIvAu3i/DtG9q+CPUSgqh1aSZBWE6Fm5wM3qi3gdSgP5whZTOyo9Oyg3Kjq92PNDpgLsd6Ddd/s 7VM53p3I6Nu32zPVGDkLAgPu//hKSn44Ye1f4872iFAiJcIMLgzL+9SfCunDWXg2PFOLMuEGZY9g pmLKA99TZWwvFxtm4zuNRcgRKiGg7nXFaZTxeagq/SpbNI9AF1R/ms1wcE9vcx+aNwwAwprRQPvw LCFRxzUItopLwVtBg0PfurSZUEIUN3F7U6mYOs2L/vXn7Gmw9NR4AQazxtzM670FEZNzKLefV/le S7MPVqZMaRuLDNhzVfdYAWUP9T27PHqOuEzcJf4QyeB45bMoYMjx+B4AVwkcOgLxCOxBtwMaFJwp EpMrbY+BfHj4zU0gfU7Kfw== X-Report-Abuse-To: spam@node04.secure-mailgate.com X-Spam-Status: No, score=1.0 required=5.0 tests=BAYES_00, BODY_8BITS, FOREIGN_BODY1, HTML_MESSAGE, KAM_DMARC_STATUS, NICE_REPLY_A, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Content-Filtered-By: Mailman/MimeDel 2.1.29 X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 10 May 2022 12:58:37 -0000 Hello Markus, please see the comments below. /Zied On 13.04.22 09:00, Metzger, Markus T wrote: > > Hello Zied, > > + > +static void > +ftrace_remove_last_insn (struct btrace_thread_info *btinfo) > +{ > +  /* If we didn't have a function, we return.  */ > +  if (btinfo->functions.empty ()) > +    return; > Should this be an error? > + > +  struct btrace_function *bfun = &btinfo->functions.back (); > +  /* If we had a gap before, we return.  */ > +  if (bfun->errcode != 0) > +    return; > In which case can we have a gap? > > [Zied] this is to make sure that following calls are safe to be executed. > > + > +  if (!bfun->insn.empty ()) > +    bfun->insn.pop_back (); > +  else > +    { > +      /* A valid function must have at least one instruction.  */ > +      internal_error (__FILE__, __LINE__, > +                 _("Attempt to remove last instruction" > +                  "from an empty function")); > We just removed an instruction in the then statement, which > could well result in BFUN->INSN to become empty(). > The statement about valid functions above may be a bit too > generic.  Also, ftrace_new_* () may create empty function > segments. > Isn't it rather that in our use-case, the caller knows that the > function segment cannot be empty? > > [Zied] yes, we are sure that we have at least the last executed > instruction that raised the breakpoint execption. > > Would it make more sense to simply do ‘bfun->insn.pop_back ()’ inside > the caller? > > Apparently, the caller knows that there must be an instruction so it > could safely remove it.  If we turn this into a separate function, we > need to handle the general case. > [Zied] what will happens in the case  of a gap proceeding current instruction, the function is still not created at this point, isn't it? to be sure that none tries to use the function as a generic one, we can remove it and put the code in the caller function. It is called only once. will this be fine from your point of view? > +    case ocsd_isa_custom: > +      return BTRACE_INSN_FLAG_ISA_CUSTOM; > + > +    case ocsd_isa_unknown: > +      return BTRACE_INSN_FLAG_ISA_UNKNOWN; > + > +    default: > +      internal_error (__FILE__, __LINE__, > +                 _("Undefined elem->isa value returned by OpenCsd.")); > This internal error kills GDB.  Should this be a normal error that just > stops trace processing for this unknown ISA? > > [Zied] since I listed all possible values that may get returned by the > decoder, the default case means that gdb and the decoder are doing > something wrong and this should be handled as a fatal error. > > The error is fatal for trace decode but not for GDB.  I think we > should use error () instead of internal_error () for all those cases. > [Zied] done. > Even for normal trace off/on pairs, we'd want a gap if PC is moving. > > [Zied] yes, but I do not have here a mean for checking if the PC has > moved. The pc field is not valid in this kind of elements > > In libipt, I compare the IPs of the stop and the resume trace packets. > If something like that doesn’t work in your case I won’t insist. > [Zied] unfortunately such a feature is not available in OpenCsd > > Regards, > > Markus. > > Intel Deutschland GmbH > Registered Address: Am Campeon 10, 85579 Neubiberg, Germany > Tel: +49 89 99 8853-0, www.intel.de > Managing Directors: Christin Eisenschmid, Sharon Heck, Tiffany Doon Silva > Chairperson of the Supervisory Board: Nicole Lau > Registered Office: Munich > Commercial Register: Amtsgericht Muenchen HRB 186928 > -- *Zied Guermazi* founder Trande GmbH Leuschnerstraße 2 69469 Weinheim/Germany Mobile: +491722645127 mailto:zied.guermazi@trande.de *Trande GmbH* Leuschnerstraße 2, D-69469 Weinheim; Telefon: +491722645127 Sitz der Gesellschaft: Weinheim- Registergericht: AG Mannheim HRB 736209 - Geschäftsführung: Zied Guermazi *Confidentiality Note* This message is intended only for the use of the named recipient(s) and may contain confidential and/or privileged information. If you are not the intended recipient, please contact the sender and delete the message. Any unauthorized use of the information contained in this message is prohibited.