binutils-gdb/gdb/dwarf2
Bruno Larsen 68ce1575fc gdb/c++: validate 'using' directives based on the current line
When asking GDB to print a variable from an imported namespace, we only
want to see variables imported in lines that the inferior has already
gone through, as is being tested last in gdb.cp/nsusing.exp. However
with the proposed change to gdb.cp/nsusing.exp, we get the following
failures:

(gdb) PASS: gdb.cp/nsusing.exp: continue to breakpoint: marker10 stop
print x
$9 = 911
(gdb) FAIL: gdb.cp/nsusing.exp: print x, before using statement
next
15        y += x;
(gdb) PASS: gdb.cp/nsusing.exp: using namespace M
print x
$10 = 911
(gdb) PASS: gdb.cp/nsusing.exp: print x, only using M

Showing that the feature wasn't functioning properly, it just so
happened that gcc ordered the namespaces in a convenient way.
This happens because GDB doesn't take into account the line where the
"using namespace" directive is written. So long as it shows up in the
current scope, we assume it is valid.

To fix this, add a new member to struct using_direct, that stores the
line where the directive was written, and a new function that informs if
the using directive is valid already.

Unfortunately, due to a GCC bug, the failure still shows up. Compilers
that set the declaration line of the using directive correctly (such as
Clang) do not show such a bug, so the test includes an XFAIL for gcc
code.

Finally, because the final test of gdb.cp/nsusing.exp has turned into
multiple that all would need XFAILs for older GCCs (<= 4.3), and that
GCC is very old, if it is detected, the test just exits early.

Approved-by: Tom Tromey <tom@tromey.com>
2022-12-21 16:26:44 +01:00
..
abbrev-cache.c Introduce DWARF abbrev cache 2022-04-12 09:31:16 -06:00
abbrev-cache.h Add comments to dwarf2/abbrev-cache.h 2022-04-16 13:58:34 -06:00
abbrev.c Fix method naming bug in new DWARF indexer 2022-04-22 06:40:49 -06:00
abbrev.h Statically examine abbrev properties 2022-04-12 09:31:16 -06:00
attribute.c Automatic Copyright Year update after running gdb/copyright.py 2022-01-01 19:13:23 +04:00
attribute.h Automatic Copyright Year update after running gdb/copyright.py 2022-01-01 19:13:23 +04:00
comp-unit-head.c internal_error: remove need to pass __FILE__/__LINE__ 2022-10-19 15:32:36 +01:00
comp-unit-head.h Automatic Copyright Year update after running gdb/copyright.py 2022-01-01 19:13:23 +04:00
cooked-index.c Add name canonicalization for C 2022-12-01 11:16:41 -07:00
cooked-index.h Fix incorrect .gdb_index with new DWARF scanner 2022-10-21 09:54:38 -06:00
cu.c Fix jump on uninit producer_is_clang bit of cu.h dwarf2_cu struct. 2022-11-26 12:43:58 +01:00
cu.h remove the declared but undefined/unused method find_partial_die 2022-11-26 12:42:41 +01:00
die.h Automatic Copyright Year update after running gdb/copyright.py 2022-01-01 19:13:23 +04:00
dwz.c Automatic Copyright Year update after running gdb/copyright.py 2022-01-01 19:13:23 +04:00
dwz.h Automatic Copyright Year update after running gdb/copyright.py 2022-01-01 19:13:23 +04:00
expr.c internal_error: remove need to pass __FILE__/__LINE__ 2022-10-19 15:32:36 +01:00
expr.h Change GDB to use frame_info_ptr 2022-10-10 11:57:10 +02:00
file-and-dir.h Add "fullname" handling to file_and_directory 2022-04-12 09:31:16 -06:00
frame-tailcall.c Change GDB to use frame_info_ptr 2022-10-10 11:57:10 +02:00
frame-tailcall.h Change GDB to use frame_info_ptr 2022-10-10 11:57:10 +02:00
frame.c gdb: skip objfiles with no BFD in DWARF unwinder 2022-12-08 11:30:25 +00:00
frame.h gdb: remove spurious spaces after frame_info_ptr 2022-10-25 11:04:58 -04:00
index-cache.c Use gdb_bfd_ref_ptr in objfile 2022-08-03 13:26:58 -06:00
index-cache.h Automatic Copyright Year update after running gdb/copyright.py 2022-01-01 19:13:23 +04:00
index-common.c Add new overload of dwarf5_djb_hash 2022-04-12 09:31:16 -06:00
index-common.h Add new overload of dwarf5_djb_hash 2022-04-12 09:31:16 -06:00
index-write.c Fix incorrect .gdb_index with new DWARF scanner 2022-10-21 09:54:38 -06:00
index-write.h Rename write_psymtabs_to_index 2022-04-12 09:31:16 -06:00
leb.c internal_error: remove need to pass __FILE__/__LINE__ 2022-10-19 15:32:36 +01:00
leb.h Automatic Copyright Year update after running gdb/copyright.py 2022-01-01 19:13:23 +04:00
line-header.c gdbsupport: change path_join parameter to array_view<const char *> 2022-09-21 11:36:01 -04:00
line-header.h gdb: add "id" fields to identify symtabs and subfiles 2022-07-29 20:54:49 -04:00
loc.c PowerPC, fix support for printing the function return value for non-trivial values. 2022-11-14 16:22:37 -05:00
loc.h PowerPC, fix support for printing the function return value for non-trivial values. 2022-11-14 16:22:37 -05:00
macro.c gdb: Fix issue with Clang CLI macros 2022-11-03 14:08:17 +01:00
macro.h gdb: Fix issue with Clang CLI macros 2022-11-03 14:08:17 +01:00
mapped-index.h Fix crash when creating index from index 2022-05-04 08:38:05 -06:00
public.h Always use dwarf2_initialize_objfile 2022-04-21 12:18:25 -06:00
read.c gdb/c++: validate 'using' directives based on the current line 2022-12-21 16:26:44 +01:00
read.h gdb: Fix issue with Clang CLI macros 2022-11-03 14:08:17 +01:00
sect-names.h Automatic Copyright Year update after running gdb/copyright.py 2022-01-01 19:13:23 +04:00
section.c Automatic Copyright Year update after running gdb/copyright.py 2022-01-01 19:13:23 +04:00
section.h Automatic Copyright Year update after running gdb/copyright.py 2022-01-01 19:13:23 +04:00
stringify.c Automatic Copyright Year update after running gdb/copyright.py 2022-01-01 19:13:23 +04:00
stringify.h Automatic Copyright Year update after running gdb/copyright.py 2022-01-01 19:13:23 +04:00
tag.h Fix .debug_names regression with new indexer 2022-04-29 13:16:44 -06:00