From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-qt1-x834.google.com (mail-qt1-x834.google.com [IPv6:2607:f8b0:4864:20::834]) by sourceware.org (Postfix) with ESMTPS id E196D385802B for ; Thu, 4 Mar 2021 22:51:26 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org E196D385802B Received: by mail-qt1-x834.google.com with SMTP id h9so280439qtq.7 for ; Thu, 04 Mar 2021 14:51:26 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:to:from:subject:cc:message-id:date:user-agent :mime-version:content-language:content-transfer-encoding; bh=1CUcJuym9YMAiE8TFfTpsVJuxp/JKT6FCa3B31z1mAk=; b=tTrg554o8NXALzLO65eWFDEKuz6xbVL7VH+/TSf2fjEXkqjgEuy61lT1JXDhDQeQTl wRtZGCA2vp0U569yrBai+Buapm8xhXU+uylT7/9dz+Vn0MbbX00Yf9+w3MXxctZSZvMJ wTgl75qwyu0fM61EKg4ORCbObjQVNuaDZWQxDTqfhALkj7UQW1oYKVreCH9yFFxbC7X4 iVO8WLF2FzTjtqNzWph6B5+1U7MXW/FdBityWw/rLyTEU4GFf+MM+SOR+AkbvVqTIjFx luk++xC5ViE0sAfUpFFX/sFFioplHbFk+cqWzLrbIGWEoKGlkuBFDoYLpLG/B7eRU7Sg JVCA== X-Gm-Message-State: AOAM530r5YEb59QTVSLDuvTtIxdUOzQH7m18tUYWYmH/400Sjqjzm3Cf cod66ib5KmfWhlhMIAnR5QWXnMObI7A= X-Google-Smtp-Source: ABdhPJzQPf8O1wI9FrioT538RJkTQrQ/QR8ifG+w80D7IBi3Vo6wvMtdqclxOc6ZKWOMdt5KLrTEiA== X-Received: by 2002:ac8:5503:: with SMTP id j3mr6226616qtq.19.1614898286532; Thu, 04 Mar 2021 14:51:26 -0800 (PST) Received: from [192.168.1.127] ([192.222.216.4]) by smtp.gmail.com with ESMTPSA id c71sm513858qkb.134.2021.03.04.14.51.25 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 04 Mar 2021 14:51:25 -0800 (PST) To: libstdc++@gcc.gnu.org From: Philippe Blain Subject: DWARF debug info version on macOS and 'std::' namespace (and pretty-printers) Cc: iain.sandoe@sandoe-acoustics.co.uk Message-ID: Date: Thu, 4 Mar 2021 17:51:22 -0500 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.11; rv:78.0) Gecko/20100101 Thunderbird/78.8.0 MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: fr Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-1.6 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, KAM_SHORT, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: libstdc++@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libstdc++ mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 04 Mar 2021 22:51:28 -0000 Hello, I'm trying to understand why a 'std::vector' appears in GDB as 'type = vector >' instead of 'std::vector<...>' I have this simple program: ~~~cpp #include void here() {}; int main() { std::vector array(4); here(); return 0; } ~~~ I'm using GCC 7.3 from Homebrew on my macOS 10.11.6 system, but I have similar behaviour with GCC 10.2 on macOS 10.15.7 in GitHub Actions. I compile with: g++-7 -g -O0 -std=c++11 test.cpp -o test and run GDB (self-compiled, 11.0.50.20210223-git) with: gdb test --batch -ex 'b here' -ex run -ex up -ex 'whatis array' I get 'type = vector >'. If I compile with '-gdwarf-3' instead of just '-g', then I get 'type = std::vector'. From the documentation [1], I understand that '-g' defaults to dwarf-2 on macOS, but I do not understand what the DWARF version has to do with the fact that 'vector' is seen by GDB in the global or 'std::' namespace... The behaviour is similar when debugging with LLDB: lldb --batch -o 'b 7' -o r -o 'p array' test shows '(vector >) $0 = { ...' for DWARF-2 and '(std::vector >) $0 = ...' for DWARF-3. Incidentally, it seems that defaulting to DWARF-2 on macOS is a decision taken in 2009 (stemming from 047a3193bd729475182a438d9929ec923f484481, From-SVN: r152127 [2]) and I'm wondering if it's still the best thing to do ? Finally, I was dragged down this hole trying to understand why the Python pretty-printers were not working on my machine. Having 'vector' correctly identified in the 'std::' namespace was one part of the solution, but I also had to create a symlink named /usr/local/Cellar/gcc/7.3.0_1/lib/gcc/7/libstdc++.6.dylib-gdb.py pointing to the existing /usr/local/Cellar/gcc/7.3.0_1/lib/gcc/7/libstdc++.a-gdb.py for the pretty printers to be loaded automatically. Looking at gcc/libstdc++-v3/python/Makefile.am it seems that a file named 'libstdc++.6.dylib-gdb.py' *should* have been created (at least from what I understand), but it seems this is not the case... I'm not sure why either. I also verified that on the GitHub Actions VM, for GCC 8, 9 and 10, only libstdc++.a-gdb.py exists... This is my first post here so I'm sorry if it's not the right forum. I searched the archives but could not find anything about this. Also, I am not subscribed to the list so if I could be CC'ed in the replies this would be ideal. Cheers! Philippe. [1] https://gcc.gnu.org/onlinedocs/gcc/Debugging-Options.html [2] https://github.com/gcc-mirror/gcc/commit/047a3193bd729475182a438d9929ec923f484481