Issue 177040
Summary [flang][debug] DW_TAG_imported_module missing for simple USE statement after #168541
Labels flang
Assignees
Reporter jiel-nv
    #### Description
After commit dc9c08e6e0081ae0799597ba5f95ca5a6eddeac0 ([flang][debug] Generate DWARF debug info using fir.use_stmt. (#168541)), simple use module_name statements no longer emit DW_TAG_imported_module in DWARF debug info, causing debuggers like GDB to fail to find module variables.

#### Reproducer
```
module test_module
  integer :: module_variable
end module test_module

program module_test
  use test_module
  implicit none

  module_variable = 1
  print *,'module_variable = ',module_variable
end program module_test
```

#### Compile and debug
```
flang -g -o test.out test.f90
gdb -q -ex "b 10" -ex "r" -ex "p module_variable" -ex "q" test.out
```

#### Expected Behavior
GDB should print:
`$1 = 1`

#### Actual Behavior
GDB reports:
`No symbol "module_variable" in current context.`

#### Root Cause
The DWARF output is missing DW_TAG_imported_module for the use test_module statement.
Before dc9c08e (working):
```
0x00000052: DW_TAG_subprogram
                DW_AT_name  ("MODULE_TEST")
 ...

0x0000006c:     DW_TAG_imported_module           <-- PRESENT
 DW_AT_decl_file  ("test.f90")
 DW_AT_decl_line  (1)
                  DW_AT_import     (0x0000002a "test_module")
```

After dc9c08e (broken):
```
0x00000052: DW_TAG_subprogram
                DW_AT_name  ("MODULE_TEST")
 ...
                                                  <-- MISSING DW_TAG_imported_module!
```
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to