public inbox for gdb@sourceware.org
 help / color / mirror / Atom feed
From: Joel Brobecker <brobecker@adacore.com>
To: Nicholas Kulikov via Gdb <gdb@sourceware.org>
Cc: Joel Brobecker <brobecker@adacore.com>
Subject: Re: tdesc_get_features_xml() logic
Date: Wed, 26 Jan 2022 11:42:17 +0400	[thread overview]
Message-ID: <YfD7WVVzB56YX3nc@adacore.com> (raw)
In-Reply-To: <CAOOM2W1kxEx0DWfj0fe2PNzRjxZK8mnhfWApSoMRKtVRGT74=g@mail.gmail.com>

> What is the idea to check the precondition `tdesc->xmltarget != NULL`
> in assert while there is (the code below) conditional logic which
> handles this case? Do I miss something or there is a flaw in assert
> logic?

I think the comment just above the call to gdb_assert explains it?

    /* Either .xmltarget or .features is not NULL.  */

Said differently, if you don't have one, then you have the other.

> gdbserver/tdesc.cc:
> 
> const char *
> tdesc_get_features_xml (const target_desc *tdesc)
> {
>   /* Either .xmltarget or .features is not NULL.  */
>   gdb_assert (tdesc->xmltarget != NULL
>               || (!tdesc->features.empty ()
>                   && tdesc->arch != NULL));
> 
>   if (tdesc->xmltarget == NULL)
>     {
>       std::string buffer ("@");
>       print_xml_feature v (&buffer);
>       tdesc->accept (v);
>       tdesc->xmltarget = xstrdup (buffer.c_str ());
>     }
> 
>   return tdesc->xmltarget;
> }
> 
> This assert triggered at first call of tdesc_get_features_xml() when
> tdesc->xmltarget is NULL.

-- 
Joel

      reply	other threads:[~2022-01-26  7:42 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-01-26  7:30 Nicholas Kulikov
2022-01-26  7:42 ` Joel Brobecker [this message]

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=YfD7WVVzB56YX3nc@adacore.com \
    --to=brobecker@adacore.com \
    --cc=gdb@sourceware.org \
    /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).