[Bug exp/34201] [gdb/exp] Namespace variable not found when stopped at inlined function call
"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=34201 --- Comment #2 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=2ce366ef2aa4b547362617be339765c6f0de3fb2 commit 2ce366ef2aa4b547362617be339765c6f0de3fb2 Author: Tom de Vries <[email protected]> Date: Mon Jul 13 19:09:35 2026 +0200 [gdb/exp] Fix ns var lookup when stopped at inlined fn call Consider test.c: ... 1 namespace mod_a { 2 int xxx = 10; 3 } 4 5 static inline int __attribute__((always_inline)) 6 inlined () { 7 return 0; 8 } 9 10 int main () { 11 using namespace mod_a; 12 int res = inlined (); 13 return res + xxx; 14 } ... compiled with "g++ test.c -g". Trying to print variable xxx at line 12 fails: ... $ gdb -q -batch a.out -ex start -ex "p xxx" ... Temporary breakpoint 1, main () at test.c:12 12 int res = inlined (); No symbol "xxx" in current context. ... The problem is here in function using_direct::valid_line: ... CORE_ADDR curr_pc = get_frame_pc (get_selected_frame (nullptr)); symtab_and_line curr_sal = find_sal_for_pc (curr_pc, 0); return (decl_line <= curr_sal.line) || (decl_line >= boundary); ... where we're trying to decide whether "using namespace mod_a" is applicable. The decl_line is 11, as expected. If curr_sal.line were 12, decl_line <= curr_sal.line would be true, and using_direct::valid_line would return true. But instead, curr_sal.line is 7. This is sort of correct, the current PC maps to that line. It's just that gdb steps into inlined functions in two steps, each with identical PC: - once stopping at the call site (line 12 in this case) - once stopping at the PC line (line 7 in this case) The function using_direct::valid_line doesn't apply this logic, and consequently line 7 is used for both cases. Fix this by using find_frame_sal instead. Tested on x86_64-linux. Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=34201 -- You are receiving this mail because: You are on the CC list for the bug.