[Bug exp/34034] GDB fails to evaluate Fortran module variables
"cvs-commit at gcc dot gnu.org via Gdb-prs" <[email protected]>
| Newsgroups | gmane.comp.gdb.bugs.discuss |
|---|---|
| Message-ID | <[email protected]/bugzilla/> |
https://sourceware.org/bugzilla/show_bug.cgi?id=34034 --- Comment #5 from Sourceware Commits <cvs-commit at gcc dot gnu.org> --- The master branch has been updated by Tom de Vries <[email protected]>: https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=2e2f760e5765fbc923aac825ea3118c06ff5d827 commit 2e2f760e5765fbc923aac825ea3118c06ff5d827 Author: Tom de Vries <[email protected]> Date: Tue Jul 14 10:43:14 2026 +0200 [gdb/exp] Handle recursive namespace import Consider test.c, compiled to a.out using "g++ -g test.c": ... 1 namespace mod_a { int xxx = 10; } 2 namespace mod_b { using namespace mod_a; 3 int yyy = 20; } 4 int main (void) { 5 using namespace mod_b; 6 void (xxx + yyy); 7 return 0; 8 } ... When trying to print the value of variable xxx we get: ... $ gdb -q -batch a.out -ex start -ex "print xxx" ... Temporary breakpoint 1, main () at test.c:7 7 return 0; No symbol "xxx" in current context. ... The symbol xxx is defined in namespace mod_a, so it's available as: ... (gdb) p mod_a::xxx $1 = 10 ... and namespace mod_b uses namespace mod_a, so it's available as: ... (gdb) p mod_b::xxx $2 = 10 ... Then main uses namespace mod_b so xxx should also be available in main, but it's not. The problem happens here in cp_lookup_symbol_via_imports: ... Thread 1 "gdb" hit Breakpoint 1, cp_lookup_symbol_via_imports (scope=0x5f43d0 "", name=0xfffffffface0 "xxx", block=0x2fba5a0, domain=..., search_scope_first=0, declaration_only=0, search_parents=1, found_symbols=...) at /home/vries/gdb/src/gdb/cp-namespace.c:505 505 cp_lookup_symbol_via_imports (current->import_src, name, ... We're about to follow the "using namespace mod_b" statement: ... (gdb) p *current $1 = {import_src = 0x2ed2140 "mod_b", import_dest = 0x66e910 "", alias = 0x0, declaration = 0x0, next = 0x0, decl_line = 5, searched = 1, excludes = {0x0}} ... But it does so using the current block, which is the function block for main: ... (gdb) p block->function ().m_name $7 = 0x2f8bc20 "main()" ... and the block containing the "using namespace mod_a" statement is the static block. Fix this by additionally iterating over the static and global blocks instead of only using the current block. Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=34034 -- You are receiving this mail because: You are on the CC list for the bug.