New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Invalid order of command-line and built-in macro definitions in .debug_macros #54506
Labels
Comments
@llvm/issue-subscribers-debuginfo |
saagarjha
pushed a commit
to ahjragaas/binutils-gdb
that referenced
this issue
Nov 3, 2022
Clang up to version 15 (current) adds macros that were defined in the command line or by "other means", according to the Dwarf specification, after the last DW_MACRO_end_file, instead of before the first DW_MACRO_start_file, as the specification dictates. When GDB reads the macros after the last file is closed, the macros never end up "in scope" and so we can't print them. This has been submitted as a bug to Clang developers (llvm/llvm-project#54506), and PR macros/29034 was opened for GDB to keep track of this. Seeing as there is no expected date for it to be fixed, add a workaround for all current versions of Clang. The workaround detects when the main file would be closed and if the producer is Clang, and turns that operation into a noop, so we keep a reference to the current_file as those macros are read. A test case was added to confirm the functionality, and the KFAIL for running gdb.base/macro-source-path when using clang. Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=29034 Approved-By: Simon Marchi <simon.marchi@efficios.com>
Yeah, looks like this is because we enter the source file being compiled here:
Before we process the builtin macros here:
Not sure exactly what the right way to fix this is - maybe we just fix this up in LLVM & reorder all the file-less macros before the others... |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Using this source file:
Compiled with:
We get
We see that the definition for
ONE
(a macro defined on the command line) is placed after theDW_MACRO_end_file
leaving the main source file. That makes the definition not visible from a point somewhere in the main source file. Same for all the built-in macros (like__llvm__
).According to DWARF5 section
6.3.2.4 Entries for Command Line Options
:I think that the definition of
ONE
should be placed before the firstDW_MACRO_start_file
. The paragraph above talks about the macros defined using command line options, but in my opinion the built-in macros should also be placed before the firstDW_MACRO_start_file
. They fit thedefined or undefined by some means other than such a directive within the compiled source text
description.The goal is that when stopped in the main source file (or any source file it includes) in a debugger, we are able to
print ONE
orprint __llvm__
.The text was updated successfully, but these errors were encountered: