* tdesc_get_features_xml() logic
@ 2022-01-26 7:30 Nicholas Kulikov
2022-01-26 7:42 ` Joel Brobecker
0 siblings, 1 reply; 2+ messages in thread
From: Nicholas Kulikov @ 2022-01-26 7:30 UTC (permalink / raw)
To: gdb
Hello,
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?
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.
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: tdesc_get_features_xml() logic
2022-01-26 7:30 tdesc_get_features_xml() logic Nicholas Kulikov
@ 2022-01-26 7:42 ` Joel Brobecker
0 siblings, 0 replies; 2+ messages in thread
From: Joel Brobecker @ 2022-01-26 7:42 UTC (permalink / raw)
To: Nicholas Kulikov via Gdb; +Cc: Joel Brobecker
> 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
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2022-01-26 7:42 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-01-26 7:30 tdesc_get_features_xml() logic Nicholas Kulikov
2022-01-26 7:42 ` Joel Brobecker
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).