From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wm1-x32a.google.com (mail-wm1-x32a.google.com [IPv6:2a00:1450:4864:20::32a]) by sourceware.org (Postfix) with ESMTPS id F1BA9385E440 for ; Wed, 26 Jan 2022 07:42:21 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org F1BA9385E440 Received: by mail-wm1-x32a.google.com with SMTP id r126so2889922wma.0 for ; Tue, 25 Jan 2022 23:42:21 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=Fmca/N0KIYkjY5psYZppNFwDqrK3WQw4feJqy5ezgL0=; b=SlCwXNZ6CiwI/eKWoKi3Cvbc4+Qne/9zEZHiXJ+w6IF6MYeukYC/2xhbp7npClxPGf 7pOZP3oUlfSeNt4FA4UjBjT4b5NUpRaGqGrXJkvWEO/WtqQGmhu0Wd9EldC7PKHpJNWR HDcGxgKR/ccoWZd5K45PQNbY+g0OIO8sSeiARyMUuy3jFjPJgRFY8FzjYloJeR0vqxDL lK7W0kf0flQcyIg/pkl4wJ8XPqRopqJog8C/waQfKqHzGtYGTfcbHuq+Dh2uDY1V4ErJ 4NbsMUxhm/gdA+U54k9oAxK6k7EtpBr1cse/IMsIumQQJ9eG7gki5aqXJBRdTfrMklcq RS2w== X-Gm-Message-State: AOAM533HX3NS6XX6DesszJYZaNHNpzB0IlFlVZN6jnm2ZacxUV+BJq09 koWFFDMwGnD1vOwpNP64MRF7NMM9m52W X-Google-Smtp-Source: ABdhPJxCidmKn3go7iiWPqM3saXKqQKB6ZfqWX9p06kO+9zVL+n0G2n8PZMoypDVMm8KbEyYyxz8Bw== X-Received: by 2002:a05:600c:2309:: with SMTP id 9mr6228857wmo.82.1643182941056; Tue, 25 Jan 2022 23:42:21 -0800 (PST) Received: from takamaka.home (lfbn-reu-1-503-119.w92-130.abo.wanadoo.fr. [92.130.90.119]) by smtp.gmail.com with ESMTPSA id n10sm23754196wrf.96.2022.01.25.23.42.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 25 Jan 2022 23:42:20 -0800 (PST) Received: by takamaka.home (Postfix, from userid 1000) id E608FA1610; Wed, 26 Jan 2022 11:42:17 +0400 (+04) Date: Wed, 26 Jan 2022 11:42:17 +0400 From: Joel Brobecker To: Nicholas Kulikov via Gdb Cc: Joel Brobecker Subject: Re: tdesc_get_features_xml() logic Message-ID: References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-4.3 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: gdb@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 26 Jan 2022 07:42:23 -0000 > 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