From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 109788 invoked by alias); 5 Feb 2018 04:02:17 -0000 Mailing-List: contact gdb-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-owner@sourceware.org Received: (qmail 109779 invoked by uid 89); 5 Feb 2018 04:02:16 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=3.1 required=5.0 tests=BAYES_00,FREEMAIL_FROM,HTML_MESSAGE,RCVD_IN_DNSWL_NONE,SPF_PASS autolearn=no version=3.3.2 spammy=raising, H*c:alternative, HERE X-HELO: mail-wm0-f47.google.com Received: from mail-wm0-f47.google.com (HELO mail-wm0-f47.google.com) (74.125.82.47) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Mon, 05 Feb 2018 04:02:14 +0000 Received: by mail-wm0-f47.google.com with SMTP id j21-v6so11253089wmh.1 for ; Sun, 04 Feb 2018 20:02:14 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:from:date:message-id:subject:to; bh=2B0VNXm87zVt5ILCBQYHuAdE0ERAhaQDcmwhE+3g79I=; b=QIaPnNELlCuasOOHyOzJvt2v4EZ8MRAsPZi3TF5wdJgZA6mQvqw1eVGVGWbZRBN5de 7JMVifDq0OOCx4c8pdfWgfW1aSAhxBtQbwacsnFtg7SVd1MITbhlwCqYLah1uvg5KPcR fTnzITDPfS7ximc/unqogf/KTFdHFQkeOZkzUy8uuWqB9q3Xq8H4aik/5nBxNmUVi/hJ G/fKCKFR3UOPO4T7l9dcnjd4J9VK1Ppx7Zap3AlEQMOJZ2s7mWaNAjiyBlHOixbIbs48 Q8GWXGq1urFJlXZjx0Pbz8MyahCVd9tneFXhHzOL+skM+CG7H5iNQnTUZnfBzP4Xe+ai phjw== X-Gm-Message-State: AKwxytdBseT0xIDYwuUAIvqqIxPk9iyAoKQj9sbGVwQwirx65N22gxlk ostGPvVDWxruPzjd3z/ajDeArqv9yuFx078dy21gAw== X-Google-Smtp-Source: AH8x224Y8tg4+2SRJQa+qNnory4wOKXBBmnTwFb/15v4aOsJ+o1vTQv+/oiy1LsSTxrT5PPL8VKg11BywOmIL1lYwaw= X-Received: by 10.28.185.196 with SMTP id j187mr38775088wmf.94.1517803332272; Sun, 04 Feb 2018 20:02:12 -0800 (PST) MIME-Version: 1.0 Received: by 10.28.122.19 with HTTP; Sun, 4 Feb 2018 20:02:11 -0800 (PST) From: Roman Popov Date: Mon, 05 Feb 2018 04:02:00 -0000 Message-ID: Subject: GDB returns wrong type when traversing optimized-out Fields To: gdb@sourceware.org Content-Type: text/plain; charset="UTF-8" X-IsSubscribed: yes X-SW-Source: 2018-02/txt/msg00019.txt.bz2 Hi all, I've encountered strange GDB behavior when requesting a value of optimized-away field. Instead of returning None or raising exception, GDB returns an optimizied-out value of wrong type. Here is a small reproducer *optimize_out.cpp*: template struct TRAITS { static const unsigned val1 = v1; static const unsigned val2 = v2; }; template < class TRAITS > struct foo { static const unsigned x1 = TRAITS::v1; static const unsigned x2 = TRAITS::v2; }; int main () { foo> f1; // SET BREAKPOINT HERE return 0; } # Using g++ 7.3 $ g++ -g optimize_out.cpp # Using gdb 8.1 $ gdb a.out (gdb) break optimize_out.cpp:14 (gdb) r (gdb) p f1 $1 = {static x1 = , static x2 = } Ok, looks good. Now traverse fields: (gdb) python >f1 = gdb.parse_and_eval("f1") >for field in f1.type.fields(): > print ("field name: ", field.name, "field type: ", field.type) > field_val = f1[field] > print ("optout?: ",field_val.is_optimized_out, "type: ",field_val.type) >end field name: x1 field type: const unsigned int optout?: True type: foo > field name: x2 field type: const unsigned int optout?: True type: foo > So type we get is foo >, not unsigned int. Looks like GDB-MI has same behavior. At least this code sample totatlly confuses GDB GUI I use. Thanks, Roman