[AMD Public Use] Hello Everyone, Requesting review on this patch, Please have a look. Problem Description/Summary: - clang emits DWARFv5 conformant line tables(ie. .debug_line section) which makes 2 things explicitly: 1. The current directory is explicitly present in the directories field and has index 0. 2. The current compilation filename is explicitly present and has index 0. This leads to a subtle issue in GDB while accessing macro information: Consider the following program: ``` #define OUT 4 int main() { int a = OUT;} ``` Compiled as `clang -gdwarf-5 -fdebug-macro test.c` GDB session: ``` $gdb a.out -q .... 2 int main() { int a = OUT;} (gdb) info macro OUT The symbol `OUT' has no definition as a C/C++ preprocessor macro at /home/test.c:-1 ``` This issue cannot be reproduced using GCC compiler as GCC doesnot emit DWARFv5 compliant tables even At `-gdwarf-5` flag. Issue is stemming from line-header.c. When performing a file name lookup for macro filename GDB mistakenly appends FULL path after checking following condition, which as **one may notice** for directory index `0` will always evaluates `true` for DWARv5 line tables and `false` for DWARFv4 line tables. ``` If (dir != NULL) return gdb::unique_xmalloc_ptr (concat (dir, SLASH_STRING, fe->name, (char *) NULL)); ``` Result of this, macro `filename` getting populated with fullname. Eventually macro lookup results in failure due to mismatch in `main_file->filename` and `sal.symtab->filename`. This patch attempts to fix above problem by extending the check for file `0`, i.e for file `0` do not append the fullname. Testing: - NO regressions in GDB testsuite before and after the fix. We also tried add a test case for this fix, but was unsuccessful. GDB test suite uses full path to the test files and this specific problem is not reproducible when user specifies full path. i.e Not reproducible cases: 1. `clang -gdwarf-5 -fdebug-macro ./test.c` // macro visible inside GDB 2. `clang -gdwarf-5 -fdebug-macro /ABSOLUTE_PATH/test.c` // macro visible inside GDB Reproducible: 1. `clang -gdwarf-5 -fdebug-macro test.c` //log shown above. gdb/ChangeLog 2021-03-26 Sourabh Singh Tomar * dwarf2/line-header.c: Updated the comment and extended check in function `line_header::file_file_name` for DWARFv5 line tables. Thank You, Sourabh.