public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: Zied Guermazi <zied.guermazi@trande.de>
To: "Metzger, Markus T" <markus.t.metzger@intel.com>
Cc: "gdb-patches@sourceware.org" <gdb-patches@sourceware.org>
Subject: Re: [PATCH v6 3/7] start/stop btrace with coresight etm and parse etm buffer. nat independant
Date: Tue, 10 May 2022 14:58:19 +0200	[thread overview]
Message-ID: <b329be0f-94e6-9cef-f33b-97be9778c4c5@trande.de> (raw)
In-Reply-To: <DM8PR11MB57499698F0E9E3BFAC4B6AB0DEEC9@DM8PR11MB5749.namprd11.prod.outlook.com>

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 <http://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 <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.


  reply	other threads:[~2022-05-10 12:58 UTC|newest]

Thread overview: 35+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-05-31 21:33 [PATCH v6 0/7] extend branch tracing to use ARM CoreSight traces Zied Guermazi
2021-05-31 21:33 ` [PATCH v6 1/7] configure gdb build system for supporting btrace on arm processors Zied Guermazi
2021-06-30 12:17   ` Luis Machado
2021-05-31 21:33 ` [PATCH v6 2/7] add btrace coresight related commands Zied Guermazi
2021-06-01 12:07   ` Eli Zaretskii
2021-06-01 15:47     ` Zied Guermazi
2021-06-30 12:26   ` Luis Machado
2021-05-31 21:33 ` [PATCH v6 3/7] start/stop btrace with coresight etm and parse etm buffer. nat independant Zied Guermazi
2021-06-22 14:59   ` Metzger, Markus T
2022-04-07 16:33     ` Zied Guermazi
2022-04-13  7:00       ` Metzger, Markus T
2022-05-10 12:58         ` Zied Guermazi [this message]
2022-05-10 13:21           ` Metzger, Markus T
2021-06-30 12:54   ` Luis Machado
2021-05-31 21:33 ` [PATCH v6 4/7] start/stop btrace with coresight etm and collect etm buffer on linux os Zied Guermazi
2021-06-23  8:00   ` Metzger, Markus T
2022-05-12 22:52     ` Zied Guermazi
2022-05-13  5:31       ` Metzger, Markus T
2022-06-12 21:02         ` Zied Guermazi
2022-06-20 12:52           ` Metzger, Markus T
2022-07-18 19:06             ` Zied Guermazi
2022-07-19  5:04               ` Metzger, Markus T
2022-07-21 22:20                 ` Zied Guermazi
2022-07-25 14:33                   ` Metzger, Markus T
2021-06-30 13:24   ` Luis Machado
2021-05-31 21:33 ` [PATCH v6 5/7] fix issue: gdb hangs in the command following a commad returning with TARGET_WAITKIND_NO_HISTORY Zied Guermazi
2021-06-23  8:08   ` Metzger, Markus T
2021-05-31 21:33 ` [PATCH v6 6/7] add support for coresight btrace via remote protocol Zied Guermazi
2021-06-01 12:08   ` Eli Zaretskii
2021-06-23 10:59   ` Metzger, Markus T
2021-05-31 21:33 ` [PATCH v6 7/7] adapt btrace testcases for arm target Zied Guermazi
2021-06-22 21:28   ` Lancelot SIX
2021-06-23 14:16   ` Metzger, Markus T
2022-05-13 11:08   ` Richard Earnshaw
2022-05-17  9:44     ` Zied Guermazi

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=b329be0f-94e6-9cef-f33b-97be9778c4c5@trande.de \
    --to=zied.guermazi@trande.de \
    --cc=gdb-patches@sourceware.org \
    --cc=markus.t.metzger@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).