aboutsummaryrefslogtreecommitdiff
path: root/gdb
diff options
context:
space:
mode:
Diffstat (limited to 'gdb')
-rw-r--r--gdb/MAINTAINERS1
-rw-r--r--gdb/ada-lang.c115
-rw-r--r--gdb/ada-varobj.c14
-rw-r--r--gdb/cli/cli-decode.h2
-rw-r--r--gdb/cli/cli-dump.c2
-rw-r--r--gdb/config/djgpp/README2
-rw-r--r--gdb/config/djgpp/djconfig.sh2
-rwxr-xr-xgdb/copyright.py101
-rw-r--r--gdb/corelow.c38
-rw-r--r--gdb/dwarf2/comp-unit-head.c23
-rw-r--r--gdb/dwarf2/comp-unit-head.h7
-rw-r--r--gdb/dwarf2/read.c225
-rw-r--r--gdb/dwarf2/read.h36
-rw-r--r--gdb/dwarf2/section.h13
-rw-r--r--gdb/maint.h3
-rw-r--r--gdb/python/py-value.c3
-rw-r--r--gdb/testsuite/gdb.ada/scalar_storage.exp28
-rw-r--r--gdb/testsuite/gdb.arch/aarch64-sve-sigunwind.c205
-rw-r--r--gdb/testsuite/gdb.arch/aarch64-sve-sigunwind.exp106
-rw-r--r--gdb/testsuite/gdb.base/bg-execution-repeat.c2
-rw-r--r--gdb/testsuite/gdb.base/corefile3.c118
-rw-r--r--gdb/testsuite/gdb.base/corefile3.exp71
-rw-r--r--gdb/testsuite/gdb.base/dlmopen-ns-ids.exp20
-rw-r--r--gdb/testsuite/gdb.base/printcmds.exp7
-rw-r--r--gdb/testsuite/gdb.cp/cplusfuncs.exp3
-rw-r--r--gdb/testsuite/gdb.dwarf2/fission-with-type-unit.exp4
-rw-r--r--gdb/testsuite/gdb.threads/clone-attach-detach.exp2
-rw-r--r--gdb/unittests/rsp-low-selftests.c2
-rw-r--r--gdb/valops.c28
-rw-r--r--gdb/value.h5
30 files changed, 856 insertions, 332 deletions
diff --git a/gdb/MAINTAINERS b/gdb/MAINTAINERS
index 187a1f6..5e1aada 100644
--- a/gdb/MAINTAINERS
+++ b/gdb/MAINTAINERS
@@ -724,6 +724,7 @@ Theodore A. Roth troth@openavr.org
Yvan Roux yvan.roux@foss.st.com
Ian Roxborough irox@redhat.com
Maciej W. Rozycki macro@orcam.me.uk
+Piotr Rudnicki piotr.rudnicki@intel.com
Kamil Rytarowski n54@gmx.com
Grace Sainsbury graces@redhat.com
Kei Sakamoto sakamoto.kei@renesas.com
diff --git a/gdb/ada-lang.c b/gdb/ada-lang.c
index 9d35440..3f5e707 100644
--- a/gdb/ada-lang.c
+++ b/gdb/ada-lang.c
@@ -36,7 +36,7 @@
#include "objfiles.h"
#include "breakpoint.h"
#include "gdbcore.h"
-#include "hashtab.h"
+#include "gdbsupport/unordered_set.h"
#include "gdbsupport/gdb_obstack.h"
#include "ada-lang.h"
#include "completer.h"
@@ -52,6 +52,7 @@
#include "namespace.h"
#include "cli/cli-style.h"
#include "cli/cli-decode.h"
+#include "gdbsupport/string-set.h"
#include "value.h"
#include "mi/mi-common.h"
@@ -349,56 +350,58 @@ struct cache_entry_search
{
const char *name;
domain_search_flags domain;
+};
+
+/* Hash function for cache entry. */
+
+struct cache_entry_hash
+{
+ using is_transparent = void;
+ using is_avalanching = void;
- hashval_t hash () const
+ /* This implementation works for both cache_entry and
+ cache_entry_search. */
+ template<typename T>
+ uint64_t operator() (const T &entry) const noexcept
{
- /* This must agree with hash_cache_entry, below. */
- return htab_hash_string (name);
+ return ankerl::unordered_dense::hash<std::string_view> () (entry.name);
}
};
-/* Hash function for cache_entry. */
+/* Equality function for cache entry. */
-static hashval_t
-hash_cache_entry (const void *v)
+struct cache_entry_eq
{
- const cache_entry *entry = (const cache_entry *) v;
- return htab_hash_string (entry->name.c_str ());
-}
-
-/* Equality function for cache_entry. */
+ using is_transparent = void;
-static int
-eq_cache_entry (const void *a, const void *b)
-{
- const cache_entry *entrya = (const cache_entry *) a;
- const cache_entry_search *entryb = (const cache_entry_search *) b;
+ /* This implementation works for both cache_entry and
+ cache_entry_search. */
+ template<typename T>
+ bool operator() (const T &lhs, const cache_entry &rhs) const noexcept
+ {
+ return lhs.domain == rhs.domain && lhs.name == rhs.name;
+ }
+};
- return entrya->domain == entryb->domain && entrya->name == entryb->name;
-}
+using cache_entry_set
+ = gdb::unordered_set<cache_entry, cache_entry_hash, cache_entry_eq>;
/* Key to our per-program-space data. */
-static const registry<program_space>::key<htab, htab_deleter>
+static const registry<program_space>::key<cache_entry_set>
ada_pspace_data_handle;
-/* Return this module's data for the given program space (PSPACE).
- If not is found, add a zero'ed one now.
-
- This function always returns a valid object. */
+/* Return this module's data for the given program space (PSPACE). If
+ not is found, one is created. This function always returns a valid
+ object. */
-static htab_t
+static cache_entry_set &
get_ada_pspace_data (struct program_space *pspace)
{
- htab_t data = ada_pspace_data_handle.get (pspace);
+ cache_entry_set *data = ada_pspace_data_handle.get (pspace);
if (data == nullptr)
- {
- data = htab_create_alloc (10, hash_cache_entry, eq_cache_entry,
- htab_delete_entry<cache_entry>,
- xcalloc, xfree);
- ada_pspace_data_handle.set (pspace, data);
- }
+ data = ada_pspace_data_handle.emplace (pspace);
- return data;
+ return *data;
}
/* Utilities */
@@ -1603,7 +1606,7 @@ ada_decode_tests ()
storage leak, it should not be significant unless there are massive
changes in the set of decoded names in successive versions of a
symbol table loaded during a single session. */
-static struct htab *decoded_names_store;
+static gdb::string_set decoded_names_store;
/* Returns the decoded name of GSYMBOL, as for ada_decode, caching it
in the language-specific part of GSYMBOL, if it has not been
@@ -1637,13 +1640,7 @@ ada_decode_symbol (const struct general_symbol_info *arg)
which case, we put the result on the heap. Since we only
decode when needed, we hope this usually does not cause a
significant memory leak (FIXME). */
-
- char **slot = (char **) htab_find_slot (decoded_names_store,
- decoded.c_str (), INSERT);
-
- if (*slot == NULL)
- *slot = xstrdup (decoded.c_str ());
- *resultp = *slot;
+ *resultp = decoded_names_store.insert (decoded);
}
}
@@ -3950,9 +3947,9 @@ ada_type_match (struct type *ftype, struct type *atype)
atype = ada_check_typedef (atype);
if (ftype->code () == TYPE_CODE_REF)
- ftype = ftype->target_type ();
+ ftype = ada_check_typedef (ftype->target_type ());
if (atype->code () == TYPE_CODE_REF)
- atype = atype->target_type ();
+ atype = ada_check_typedef (atype->target_type ());
switch (ftype->code ())
{
@@ -4695,19 +4692,18 @@ static int
lookup_cached_symbol (const char *name, domain_search_flags domain,
struct symbol **sym, const struct block **block)
{
- htab_t tab = get_ada_pspace_data (current_program_space);
+ cache_entry_set &htab = get_ada_pspace_data (current_program_space);
cache_entry_search search;
search.name = name;
search.domain = domain;
- cache_entry *e = (cache_entry *) htab_find_with_hash (tab, &search,
- search.hash ());
- if (e == nullptr)
+ auto iter = htab.find (search);
+ if (iter == htab.end ())
return 0;
if (sym != nullptr)
- *sym = e->sym;
+ *sym = iter->sym;
if (block != nullptr)
- *block = e->block;
+ *block = iter->block;
return 1;
}
@@ -4735,21 +4731,8 @@ cache_symbol (const char *name, domain_search_flags domain,
return;
}
- htab_t tab = get_ada_pspace_data (current_program_space);
- cache_entry_search search;
- search.name = name;
- search.domain = domain;
-
- void **slot = htab_find_slot_with_hash (tab, &search,
- search.hash (), INSERT);
-
- cache_entry *e = new cache_entry;
- e->name = name;
- e->domain = domain;
- e->sym = sym;
- e->block = block;
-
- *slot = e;
+ cache_entry_set &tab = get_ada_pspace_data (current_program_space);
+ tab.insert (cache_entry {name, domain, sym, block});
}
/* Symbol Lookup */
@@ -14049,10 +14032,6 @@ When enabled, the debugger will stop using the DW_AT_GNAT_descriptive_type\n\
DWARF attribute."),
NULL, NULL, &maint_set_ada_cmdlist, &maint_show_ada_cmdlist);
- decoded_names_store = htab_create_alloc (256, htab_hash_string,
- htab_eq_string,
- NULL, xcalloc, xfree);
-
/* The ada-lang observers. */
gdb::observers::new_objfile.attach (ada_new_objfile_observer, "ada-lang");
gdb::observers::all_objfiles_removed.attach (ada_clear_symbol_cache,
diff --git a/gdb/ada-varobj.c b/gdb/ada-varobj.c
index 140fc71..c87e7be 100644
--- a/gdb/ada-varobj.c
+++ b/gdb/ada-varobj.c
@@ -379,16 +379,14 @@ ada_varobj_get_number_of_children (struct value *parent_value,
whose index is CHILD_INDEX:
- If CHILD_NAME is not NULL, then a copy of the child's name
- is saved in *CHILD_NAME. This copy must be deallocated
- with xfree after use.
+ is saved in *CHILD_NAME.
- If CHILD_VALUE is not NULL, then save the child's value
in *CHILD_VALUE. Same thing for the child's type with
CHILD_TYPE if not NULL.
- If CHILD_PATH_EXPR is not NULL, then compute the child's
- path expression. The resulting string must be deallocated
- after use with xfree.
+ path expression.
Computing the child's path expression requires the PARENT_PATH_EXPR
to be non-NULL. Otherwise, PARENT_PATH_EXPR may be null if
@@ -805,9 +803,7 @@ ada_varobj_get_type_of_child (struct value *parent_value,
}
/* Return a string that contains the image of the given VALUE, using
- the print options OPTS as the options for formatting the result.
-
- The resulting string must be deallocated after use with xfree. */
+ the print options OPTS as the options for formatting the result. */
static std::string
ada_varobj_get_value_image (struct value *value,
@@ -825,9 +821,7 @@ ada_varobj_get_value_image (struct value *value,
in the array inside square brackets, but there are situations where
it's useful to add more info.
- OPTS are the print options used when formatting the result.
-
- The result should be deallocated after use using xfree. */
+ OPTS are the print options used when formatting the result. */
static std::string
ada_varobj_get_value_of_array_variable (struct value *value,
diff --git a/gdb/cli/cli-decode.h b/gdb/cli/cli-decode.h
index 217afbc..9be446f 100644
--- a/gdb/cli/cli-decode.h
+++ b/gdb/cli/cli-decode.h
@@ -62,6 +62,8 @@ struct cmd_list_element
type (not_set_cmd),
doc (doc_)
{
+ gdb_assert (name != nullptr);
+ gdb_assert (doc != nullptr);
memset (&function, 0, sizeof (function));
}
diff --git a/gdb/cli/cli-dump.c b/gdb/cli/cli-dump.c
index 0ecc7b0..3055734 100644
--- a/gdb/cli/cli-dump.c
+++ b/gdb/cli/cli-dump.c
@@ -397,7 +397,7 @@ restore_one_section (bfd *ibfd, asection *isec,
if (sec_end <= load_start
|| (load_end > 0 && sec_start >= load_end))
{
- /* No, no useable data in this section. */
+ /* No, no usable data in this section. */
gdb_printf (_("skipping section %s...\n"),
bfd_section_name (isec));
return;
diff --git a/gdb/config/djgpp/README b/gdb/config/djgpp/README
index 2ae6535..cecc9d0 100644
--- a/gdb/config/djgpp/README
+++ b/gdb/config/djgpp/README
@@ -175,7 +175,7 @@ SOMETHING.tst (where SOMETHING is the name of the failed test). You
should compare each of the *.tst files with the corresponding *.out
file and convince yourself that the differences do not indicate a real
problem. Examples of differences you can disregard are changes in the
-copyright blurb printed by GDB, values of unitialized variables,
+copyright blurb printed by GDB, values of uninitialized variables,
addresses of global variables like argv[] and envp[] (which depend on
the size of your environment), etc.
diff --git a/gdb/config/djgpp/djconfig.sh b/gdb/config/djgpp/djconfig.sh
index 4952a11..05b3bbe 100644
--- a/gdb/config/djgpp/djconfig.sh
+++ b/gdb/config/djgpp/djconfig.sh
@@ -123,7 +123,7 @@ do
done
# Now set the config shell. It is really needed, that the shell
-# points to a shell with full path and also it must conatain the
+# points to a shell with full path and also it must contain the
# .exe suffix. I assume here, that bash is installed. If not,
# install it. Additionally, the pathname must not contain a
# drive letter, so use the /dev/x/foo format supported by versions
diff --git a/gdb/copyright.py b/gdb/copyright.py
index 5ec9944..bd854dc 100755
--- a/gdb/copyright.py
+++ b/gdb/copyright.py
@@ -30,13 +30,16 @@
#
# This removes the bulk of the changes which are most likely to be correct.
+# pyright: strict
+
import argparse
import locale
import os
import os.path
+import pathlib
import subprocess
import sys
-from typing import List, Optional
+from typing import Iterable
def get_update_list():
@@ -66,24 +69,20 @@ def get_update_list():
.split("\0")
)
- def include_file(filename):
- (dirname, basename) = os.path.split(filename)
- dirbasename = os.path.basename(dirname)
- return not (
- basename in EXCLUDE_ALL_LIST
- or dirbasename in EXCLUDE_ALL_LIST
- or dirname in EXCLUDE_LIST
- or dirname in NOT_FSF_LIST
- or dirname in BY_HAND
- or filename in EXCLUDE_LIST
- or filename in NOT_FSF_LIST
- or filename in BY_HAND
- )
+ full_exclude_list = EXCLUDE_LIST + BY_HAND
+
+ def include_file(filename: str):
+ path = pathlib.Path(filename)
+ for pattern in full_exclude_list:
+ if path.full_match(pattern):
+ return False
+
+ return True
return filter(include_file, result)
-def update_files(update_list):
+def update_files(update_list: Iterable[str]):
"""Update the copyright header of the files in the given list.
We use gnulib's update-copyright script for that.
@@ -128,7 +127,7 @@ def update_files(update_list):
print("*** " + line)
-def may_have_copyright_notice(filename):
+def may_have_copyright_notice(filename: str):
"""Check that the given file does not seem to have a copyright notice.
The filename is relative to the root directory.
@@ -166,7 +165,7 @@ def get_parser() -> argparse.ArgumentParser:
return parser
-def main(argv: List[str]) -> Optional[int]:
+def main(argv: list[str]) -> int | None:
"""The main subprogram."""
parser = get_parser()
_ = parser.parse_args(argv)
@@ -210,8 +209,14 @@ def main(argv: List[str]) -> Optional[int]:
# generated, non-FSF, or otherwise special (e.g. license text,
# or test cases which must be sensitive to line numbering).
#
-# Filenames are relative to the root directory.
+# Entries are treated as glob patterns.
EXCLUDE_LIST = (
+ "**/aclocal.m4",
+ "**/configure",
+ "**/COPYING.LIB",
+ "**/COPYING",
+ "**/fdl.texi",
+ "**/gpl.texi",
"gdb/copying.c",
"gdb/nat/glibc_thread_db.h",
"gdb/CONTRIBUTE",
@@ -219,45 +224,11 @@ EXCLUDE_LIST = (
"gdbsupport/unordered_dense.h",
"gnulib/doc/gendocs_template",
"gnulib/doc/gendocs_template_min",
- "gnulib/import",
+ "gnulib/import/**",
"gnulib/config.in",
"gnulib/Makefile.in",
-)
-
-# Files which should not be modified, either because they are
-# generated, non-FSF, or otherwise special (e.g. license text,
-# or test cases which must be sensitive to line numbering).
-#
-# Matches any file or directory name anywhere. Use with caution.
-# This is mostly for files that can be found in multiple directories.
-# Eg: We want all files named COPYING to be left untouched.
-
-EXCLUDE_ALL_LIST = (
- "COPYING",
- "COPYING.LIB",
- "configure",
- "fdl.texi",
- "gpl.texi",
- "aclocal.m4",
-)
-
-# The list of files to update by hand.
-BY_HAND = (
- # Nothing at the moment :-).
-)
-
-# Files containing multiple copyright headers. This script is only
-# fixing the first one it finds, so we need to finish the update
-# by hand.
-MULTIPLE_COPYRIGHT_HEADERS = (
- "gdb/doc/gdb.texinfo",
- "gdb/doc/refcard.tex",
- "gdb/syscalls/update-netbsd.sh",
-)
-
-# The list of file which have a copyright, but not held by the FSF.
-# Filenames are relative to the root directory.
-NOT_FSF_LIST = (
+ "sim/Makefile.in",
+ # The files below have a copyright, but not held by the FSF.
"gdb/exc_request.defs",
"gdb/gdbtk",
"gdb/testsuite/gdb.gdbtk/",
@@ -294,9 +265,27 @@ NOT_FSF_LIST = (
"sim/mips/sim-main.c",
"sim/moxie/moxie-gdb.dts",
# Not a single file in sim/ppc/ appears to be copyright FSF :-(.
- "sim/ppc",
+ "sim/ppc/**",
"sim/testsuite/mips/mips32-dsp2.s",
)
+# The list of files to update by hand.
+#
+# Entries are treated as glob patterns.
+BY_HAND: tuple[str, ...] = (
+ # Nothing at the moment :-).
+)
+
+# Files containing multiple copyright headers. This script is only
+# fixing the first one it finds, so we need to finish the update
+# by hand.
+#
+# Entries are treated as glob patterns.
+MULTIPLE_COPYRIGHT_HEADERS = (
+ "gdb/doc/gdb.texinfo",
+ "gdb/doc/refcard.tex",
+ "gdb/syscalls/update-netbsd.sh",
+)
+
if __name__ == "__main__":
sys.exit(main(sys.argv[1:]))
diff --git a/gdb/corelow.c b/gdb/corelow.c
index fc0df25..4518781 100644
--- a/gdb/corelow.c
+++ b/gdb/corelow.c
@@ -540,11 +540,41 @@ core_target::build_file_mappings ()
/* If ABFD was opened, but the wrong format, close it now. */
abfd = nullptr;
+ /* When true, this indicates that the mapped contents of this
+ file are available within the core file. When false, some of
+ the mapped contents are not available. If the contents are
+ entirely available within the core file, then we don't need to
+ warn the user if GDB cannot find the file. */
+ bool content_is_in_core_file_p = true;
+
/* Record all regions for this file as unavailable. */
for (const mapped_file::region &region : file_data.regions)
- m_core_unavailable_mappings.emplace_back (region.start,
- region.end
- - region.start);
+ {
+ /* Check to see if the region is available within the core
+ file. */
+ bool found_region_in_core_file = false;
+ for (const target_section &ts : m_core_section_table)
+ {
+ if (ts.addr <= region.start && ts.endaddr >= region.end
+ && (ts.the_bfd_section->flags & SEC_HAS_CONTENTS) != 0)
+ {
+ found_region_in_core_file = true;
+ break;
+ }
+ }
+
+ /* This region is not available within the core file.
+ Without the file available to read from it is not possible
+ for GDB to read this mapping within the inferior. Warn
+ the user about this case. */
+ if (!found_region_in_core_file)
+ content_is_in_core_file_p = false;
+
+ /* Record the unavailable region. */
+ m_core_unavailable_mappings.emplace_back (region.start,
+ region.end
+ - region.start);
+ }
/* And give the user an appropriate warning. */
if (build_id_mismatch)
@@ -564,7 +594,7 @@ core_target::build_file_mappings ()
styled_string (file_name_style.style (),
expanded_fname.get ()));
}
- else
+ else if (!content_is_in_core_file_p)
{
if (expanded_fname == nullptr
|| filename == expanded_fname.get ())
diff --git a/gdb/dwarf2/comp-unit-head.c b/gdb/dwarf2/comp-unit-head.c
index 8ec8897..a35d664 100644
--- a/gdb/dwarf2/comp-unit-head.c
+++ b/gdb/dwarf2/comp-unit-head.c
@@ -26,7 +26,6 @@
#include "dwarf2/comp-unit-head.h"
#include "dwarf2/leb.h"
-#include "dwarf2/read.h"
#include "dwarf2/section.h"
#include "dwarf2/stringify.h"
#include "dwarf2/error.h"
@@ -149,15 +148,13 @@ read_comp_unit_head (struct comp_unit_head *cu_header,
Perform various error checking on the header. */
static void
-error_check_comp_unit_head (dwarf2_per_objfile *per_objfile,
- struct comp_unit_head *header,
- struct dwarf2_section_info *section,
- struct dwarf2_section_info *abbrev_section)
+error_check_comp_unit_head (comp_unit_head *header,
+ dwarf2_section_info *section,
+ dwarf2_section_info *abbrev_section)
{
const char *filename = section->get_file_name ();
- if (to_underlying (header->abbrev_sect_off)
- >= abbrev_section->get_size (per_objfile->objfile))
+ if (to_underlying (header->abbrev_sect_off) >= abbrev_section->size)
error (_(DWARF_ERROR_PREFIX
"bad offset (%s) in compilation unit header "
"(offset %s + 6) [in module %s]"),
@@ -179,12 +176,10 @@ error_check_comp_unit_head (dwarf2_per_objfile *per_objfile,
/* See comp-unit-head.h. */
const gdb_byte *
-read_and_check_comp_unit_head (dwarf2_per_objfile *per_objfile,
- struct comp_unit_head *header,
- struct dwarf2_section_info *section,
- struct dwarf2_section_info *abbrev_section,
- const gdb_byte *info_ptr,
- rcuh_kind section_kind)
+read_and_check_comp_unit_head (comp_unit_head *header,
+ dwarf2_section_info *section,
+ dwarf2_section_info *abbrev_section,
+ const gdb_byte *info_ptr, rcuh_kind section_kind)
{
const gdb_byte *beg_of_comp_unit = info_ptr;
@@ -194,7 +189,7 @@ read_and_check_comp_unit_head (dwarf2_per_objfile *per_objfile,
header->first_die_cu_offset = (cu_offset) (info_ptr - beg_of_comp_unit);
- error_check_comp_unit_head (per_objfile, header, section, abbrev_section);
+ error_check_comp_unit_head (header, section, abbrev_section);
return info_ptr;
}
diff --git a/gdb/dwarf2/comp-unit-head.h b/gdb/dwarf2/comp-unit-head.h
index 5134893..ea09153 100644
--- a/gdb/dwarf2/comp-unit-head.h
+++ b/gdb/dwarf2/comp-unit-head.h
@@ -129,11 +129,8 @@ extern const gdb_byte *read_comp_unit_head
The contents of the header are stored in HEADER.
The result is a pointer to the start of the first DIE. */
extern const gdb_byte *read_and_check_comp_unit_head
- (dwarf2_per_objfile *per_objfile,
- struct comp_unit_head *header,
- struct dwarf2_section_info *section,
- struct dwarf2_section_info *abbrev_section,
- const gdb_byte *info_ptr,
+ (comp_unit_head *header, dwarf2_section_info *section,
+ dwarf2_section_info *abbrev_section, const gdb_byte *info_ptr,
rcuh_kind section_kind);
#endif /* GDB_DWARF2_COMP_UNIT_HEAD_H */
diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c
index 6e96afe..55cf02f 100644
--- a/gdb/dwarf2/read.c
+++ b/gdb/dwarf2/read.c
@@ -1039,14 +1039,7 @@ static struct dwo_unit *lookup_dwo_unit_in_dwp
(dwarf2_per_bfd *per_bfd, struct dwp_file *dwp_file,
const char *comp_dir, ULONGEST signature, int is_debug_types);
-static struct dwp_file *get_dwp_file (dwarf2_per_objfile *per_objfile);
-
-static struct dwo_unit *lookup_dwo_comp_unit
- (dwarf2_cu *cu, const char *dwo_name, const char *comp_dir,
- ULONGEST signature);
-
-static struct dwo_unit *lookup_dwo_type_unit
- (dwarf2_cu *cu, const char *dwo_name, const char *comp_dir);
+static void open_and_init_dwp_file (dwarf2_per_objfile *per_objfile);
static void queue_and_load_all_dwo_tus (dwarf2_cu *cu);
@@ -1295,6 +1288,15 @@ dwarf2_has_info (struct objfile *objfile,
{
warning (_("%s"), err.what ());
}
+
+ try
+ {
+ open_and_init_dwp_file (per_objfile);
+ }
+ catch (const gdb_exception_error &err)
+ {
+ warning (_("%s"), err.what ());
+ }
}
return has_info;
@@ -1632,7 +1634,7 @@ dw2_do_instantiate_symtab (dwarf2_per_cu *per_cu,
&& per_objfile->per_bfd->index_table != NULL
&& !per_objfile->per_bfd->index_table->version_check ()
/* DWP files aren't supported yet. */
- && get_dwp_file (per_objfile) == NULL)
+ && per_objfile->per_bfd->dwp_file == nullptr)
queue_and_load_all_dwo_tus (cu);
}
@@ -2383,16 +2385,16 @@ read_abbrev_offset (dwarf2_per_objfile *per_objfile,
return (sect_offset) read_offset (abfd, info_ptr, offset_size);
}
-/* A helper for create_debug_types_hash_table. Read types from SECTION
+/* A helper for create_dwo_debug_types_hash_table. Read types from SECTION
and fill them into DWO_FILE's type unit hash table. It will process only
type units, therefore DW_UT_type. */
-static void
-create_debug_type_hash_table (dwarf2_per_objfile *per_objfile,
- dwo_file *dwo_file, dwarf2_section_info *section,
- rcuh_kind section_kind)
+void
+cutu_reader::create_dwo_debug_type_hash_table (dwarf2_per_bfd *per_bfd,
+ dwo_file *dwo_file,
+ dwarf2_section_info *section,
+ rcuh_kind section_kind)
{
- struct objfile *objfile = per_objfile->objfile;
struct dwarf2_section_info *abbrev_section;
bfd *abfd;
const gdb_byte *info_ptr, *end_ptr;
@@ -2403,7 +2405,6 @@ create_debug_type_hash_table (dwarf2_per_objfile *per_objfile,
section->get_name (),
abbrev_section->get_file_name ());
- section->read (objfile);
info_ptr = section->buffer;
if (info_ptr == NULL)
@@ -2432,8 +2433,8 @@ create_debug_type_hash_table (dwarf2_per_objfile *per_objfile,
/* We need to read the type's signature in order to build the hash
table, but we don't need anything else just yet. */
- ptr = read_and_check_comp_unit_head (per_objfile, &header, section,
- abbrev_section, ptr, section_kind);
+ ptr = read_and_check_comp_unit_head (&header, section, abbrev_section,
+ ptr, section_kind);
length = header.get_length_with_initial ();
@@ -2447,8 +2448,7 @@ create_debug_type_hash_table (dwarf2_per_objfile *per_objfile,
continue;
}
- dwo_unit *dwo_tu
- = OBSTACK_ZALLOC (&per_objfile->per_bfd->obstack, dwo_unit);
+ dwo_unit *dwo_tu = OBSTACK_ZALLOC (&per_bfd->obstack, dwo_unit);
dwo_tu->dwo_file = dwo_file;
dwo_tu->signature = header.signature;
dwo_tu->type_offset_in_tu = header.type_cu_offset_in_tu;
@@ -2478,14 +2478,14 @@ create_debug_type_hash_table (dwarf2_per_objfile *per_objfile,
Note: This function processes DWO files only, not DWP files. */
-static void
-create_debug_types_hash_table
- (dwarf2_per_objfile *per_objfile, dwo_file *dwo_file,
+void
+cutu_reader::create_dwo_debug_types_hash_table
+ (dwarf2_per_bfd *per_bfd, dwo_file *dwo_file,
gdb::array_view<dwarf2_section_info> type_sections)
{
for (dwarf2_section_info &section : type_sections)
- create_debug_type_hash_table (per_objfile, dwo_file, &section,
- rcuh_kind::TYPE);
+ create_dwo_debug_type_hash_table (per_bfd, dwo_file, &section,
+ rcuh_kind::TYPE);
}
/* Add an entry for signature SIG to per_bfd->signatured_types. */
@@ -2610,7 +2610,7 @@ lookup_dwp_signatured_type (struct dwarf2_cu *cu, ULONGEST sig)
{
dwarf2_per_objfile *per_objfile = cu->per_objfile;
dwarf2_per_bfd *per_bfd = per_objfile->per_bfd;
- struct dwp_file *dwp_file = get_dwp_file (per_objfile);
+ dwp_file *dwp_file = per_objfile->per_bfd->dwp_file.get ();
gdb_assert (cu->dwo_unit);
gdb_assert (dwp_file != NULL);
@@ -2652,7 +2652,7 @@ lookup_signatured_type (struct dwarf2_cu *cu, ULONGEST sig)
{
/* We're in a DWO/DWP file, and we're using .gdb_index.
These cases require special processing. */
- if (get_dwp_file (per_objfile) == NULL)
+ if (per_objfile->per_bfd->dwp_file == nullptr)
return lookup_dwo_signatured_type (cu, sig);
else
return lookup_dwp_signatured_type (cu, sig);
@@ -2712,9 +2712,8 @@ cutu_reader::read_cutu_die_from_dwo (dwarf2_cu *cu, dwo_unit *dwo_unit,
die_info *stub_comp_unit_die,
const char *stub_comp_dir)
{
- dwarf2_per_objfile *per_objfile = cu->per_objfile;
dwarf2_per_cu *per_cu = cu->per_cu;
- struct objfile *objfile = per_objfile->objfile;
+ struct objfile *objfile = cu->per_objfile->objfile;
bfd *abfd;
struct dwarf2_section_info *dwo_abbrev_section;
@@ -2790,9 +2789,10 @@ cutu_reader::read_cutu_die_from_dwo (dwarf2_cu *cu, dwo_unit *dwo_unit,
{
signatured_type *sig_type = (struct signatured_type *) per_cu;
- m_info_ptr = read_and_check_comp_unit_head (per_objfile, &cu->header,
- section, dwo_abbrev_section,
+ m_info_ptr = read_and_check_comp_unit_head (&cu->header, section,
+ dwo_abbrev_section,
m_info_ptr, rcuh_kind::TYPE);
+
/* This is not an assert because it can be caused by bad debug info. */
if (sig_type->signature != cu->header.signature)
{
@@ -2818,7 +2818,7 @@ cutu_reader::read_cutu_die_from_dwo (dwarf2_cu *cu, dwo_unit *dwo_unit,
else
{
m_info_ptr
- = read_and_check_comp_unit_head (per_objfile, &cu->header, section,
+ = read_and_check_comp_unit_head (&cu->header, section,
dwo_abbrev_section, m_info_ptr,
rcuh_kind::COMPILE);
gdb_assert (dwo_unit->sect_off == cu->header.sect_off);
@@ -2873,8 +2873,9 @@ lookup_dwo_id (struct dwarf2_cu *cu, struct die_info* comp_unit_die)
Returns nullptr if the specified DWO unit cannot be found. */
-static struct dwo_unit *
-lookup_dwo_unit (dwarf2_cu *cu, die_info *comp_unit_die, const char *dwo_name)
+dwo_unit *
+cutu_reader::lookup_dwo_unit (dwarf2_cu *cu, die_info *comp_unit_die,
+ const char *dwo_name)
{
#if CXX_STD_THREAD
/* We need a lock here to handle the DWO hash table. */
@@ -3047,7 +3048,7 @@ cutu_reader::cutu_reader (dwarf2_per_cu &this_cu,
if (this_cu.is_debug_types)
{
m_info_ptr
- = read_and_check_comp_unit_head (&per_objfile, &cu->header, section,
+ = read_and_check_comp_unit_head (&cu->header, section,
abbrev_section, m_info_ptr,
rcuh_kind::TYPE);
@@ -3070,7 +3071,7 @@ cutu_reader::cutu_reader (dwarf2_per_cu &this_cu,
else
{
m_info_ptr
- = read_and_check_comp_unit_head (&per_objfile, &cu->header, section,
+ = read_and_check_comp_unit_head (&cu->header, section,
abbrev_section, m_info_ptr,
rcuh_kind::COMPILE);
@@ -3204,12 +3205,11 @@ cutu_reader::cutu_reader (dwarf2_per_cu &this_cu,
m_info_ptr = section->buffer + to_underlying (this_cu.sect_off);
const gdb_byte *begin_info_ptr = m_info_ptr;
- m_info_ptr
- = read_and_check_comp_unit_head (&per_objfile, &m_new_cu->header, section,
- abbrev_section, m_info_ptr,
- (this_cu.is_debug_types
- ? rcuh_kind::TYPE
- : rcuh_kind::COMPILE));
+ m_info_ptr = read_and_check_comp_unit_head (&m_new_cu->header, section,
+ abbrev_section, m_info_ptr,
+ (this_cu.is_debug_types
+ ? rcuh_kind::TYPE
+ : rcuh_kind::COMPILE));
m_new_cu->str_offsets_base = parent_cu.str_offsets_base;
m_new_cu->addr_base = parent_cu.addr_base;
@@ -3510,7 +3510,7 @@ process_skeletonless_type_units (dwarf2_per_objfile *per_objfile,
cooked_index_worker_result *storage)
{
/* Skeletonless TUs in DWP files without .gdb_index is not supported yet. */
- if (get_dwp_file (per_objfile) == nullptr)
+ if (per_objfile->per_bfd->dwp_file == nullptr)
for (const dwo_file_up &file : per_objfile->per_bfd->dwo_files)
for (dwo_unit *unit : file->tus)
process_skeletonless_type_unit (unit, per_objfile, storage);
@@ -3692,6 +3692,7 @@ read_comp_units_from_section (dwarf2_per_objfile *per_objfile,
{
const gdb_byte *info_ptr;
struct objfile *objfile = per_objfile->objfile;
+ dwarf2_per_bfd *per_bfd = per_objfile->per_bfd;
dwarf_read_debug_printf ("Reading %s for %s",
section->get_name (),
@@ -3708,20 +3709,19 @@ read_comp_units_from_section (dwarf2_per_objfile *per_objfile,
sect_offset sect_off = (sect_offset) (info_ptr - section->buffer);
comp_unit_head cu_header;
- read_and_check_comp_unit_head (per_objfile, &cu_header, section,
- abbrev_section, info_ptr,
- section_kind);
+ read_and_check_comp_unit_head (&cu_header, section, abbrev_section,
+ info_ptr, section_kind);
unsigned int length = cu_header.get_length_with_initial ();
/* Save the compilation unit for later lookup. */
if (cu_header.unit_type != DW_UT_type)
- this_cu
- = per_objfile->per_bfd->allocate_per_cu (section, sect_off, length, is_dwz);
+ this_cu = per_bfd->allocate_per_cu (section, sect_off, length, is_dwz);
else
{
- auto sig_type = per_objfile->per_bfd->allocate_signatured_type
- (section, sect_off, length, is_dwz, cu_header.signature);
+ auto sig_type
+ = per_bfd->allocate_signatured_type (section, sect_off, length,
+ is_dwz, cu_header.signature);
signatured_type *sig_ptr = sig_type.get ();
sig_type->type_offset_in_tu = cu_header.type_cu_offset_in_tu;
this_cu.reset (sig_type.release ());
@@ -3737,7 +3737,7 @@ read_comp_units_from_section (dwarf2_per_objfile *per_objfile,
}
info_ptr = info_ptr + this_cu->length ();
- per_objfile->per_bfd->all_units.push_back (std::move (this_cu));
+ per_bfd->all_units.push_back (std::move (this_cu));
}
}
@@ -6307,16 +6307,14 @@ lookup_dwo_file (dwarf2_per_bfd *per_bfd, const char *dwo_name,
/* Create the dwo_units for the CUs in a DWO_FILE.
Note: This function processes DWO files only, not DWP files. */
-static void
-create_cus_hash_table (dwarf2_cu *cu, dwo_file &dwo_file)
+void
+cutu_reader::create_dwo_cus_hash_table (dwarf2_cu *cu, dwo_file &dwo_file)
{
dwarf2_per_objfile *per_objfile = cu->per_objfile;
- struct objfile *objfile = per_objfile->objfile;
dwarf2_per_bfd *per_bfd = per_objfile->per_bfd;
const gdb_byte *info_ptr, *end_ptr;
auto &section = dwo_file.sections.info;
- section.read (objfile);
info_ptr = section.buffer;
if (info_ptr == NULL)
@@ -6342,6 +6340,12 @@ create_cus_hash_table (dwarf2_cu *cu, dwo_file &dwo_file)
if (reader.is_dummy())
continue;
+ /* DWARF 5 .debug_info.dwo sections may contain some type units. Skip
+ everything that is not a compile unit. */
+ if (const auto ut = reader.cu ()->header.unit_type;
+ ut != DW_UT_compile && ut != DW_UT_split_compile)
+ continue;
+
std::optional<ULONGEST> signature
= lookup_dwo_id (reader.cu (), reader.top_level_die ());
if (!signature.has_value ())
@@ -6530,27 +6534,18 @@ create_cus_hash_table (dwarf2_cu *cu, dwo_file &dwo_file)
Note: This function processes DWP files only, not DWO files. */
static struct dwp_hash_table *
-create_dwp_hash_table (dwarf2_per_objfile *per_objfile,
- struct dwp_file *dwp_file, int is_debug_types)
+create_dwp_hash_table (dwarf2_per_bfd *per_bfd, struct dwp_file *dwp_file,
+ dwarf2_section_info &index)
{
- struct objfile *objfile = per_objfile->objfile;
bfd *dbfd = dwp_file->dbfd.get ();
- const gdb_byte *index_ptr, *index_end;
- struct dwarf2_section_info *index;
uint32_t version, nr_columns, nr_units, nr_slots;
struct dwp_hash_table *htab;
- if (is_debug_types)
- index = &dwp_file->sections.tu_index;
- else
- index = &dwp_file->sections.cu_index;
-
- if (index->empty ())
+ if (index.empty ())
return NULL;
- index->read (objfile);
- index_ptr = index->buffer;
- index_end = index_ptr + index->size;
+ const gdb_byte *index_ptr = index.buffer;
+ const gdb_byte *index_end = index_ptr + index.size;
/* For Version 5, the version is really 2 bytes of data & 2 bytes of padding.
For now it's safe to just read 4 bytes (particularly as it's difficult to
@@ -6581,7 +6576,7 @@ create_dwp_hash_table (dwarf2_per_objfile *per_objfile,
pulongest (nr_slots), dwp_file->name);
}
- htab = OBSTACK_ZALLOC (&per_objfile->per_bfd->obstack, struct dwp_hash_table);
+ htab = OBSTACK_ZALLOC (&per_bfd->obstack, struct dwp_hash_table);
htab->version = version;
htab->nr_columns = nr_columns;
htab->nr_units = nr_units;
@@ -7520,9 +7515,9 @@ try_open_dwop_file (dwarf2_per_bfd *per_bfd, const char *file_name, int is_dwp,
Upon success, the canonicalized path of the file is stored in the bfd,
same as symfile_bfd_open. */
-static gdb_bfd_ref_ptr
-open_dwo_file (dwarf2_per_bfd *per_bfd, const char *file_name,
- const char *comp_dir)
+gdb_bfd_ref_ptr
+cutu_reader::open_dwo_file (dwarf2_per_bfd *per_bfd, const char *file_name,
+ const char *comp_dir)
{
if (IS_ABSOLUTE_PATH (file_name))
return try_open_dwop_file (per_bfd, file_name,
@@ -7557,9 +7552,9 @@ open_dwo_file (dwarf2_per_bfd *per_bfd, const char *file_name,
/* This function is mapped across the sections and remembers the offset and
size of each of the DWO debugging sections we are interested in. */
-static void
-dwarf2_locate_dwo_sections (struct objfile *objfile, bfd *abfd,
- asection *sectp, dwo_sections *dwo_sections)
+void
+cutu_reader::locate_dwo_sections (struct objfile *objfile, bfd *abfd,
+ asection *sectp, dwo_sections *dwo_sections)
{
const struct dwop_section_names *names = &dwop_section_names;
@@ -7606,11 +7601,12 @@ dwarf2_locate_dwo_sections (struct objfile *objfile, bfd *abfd,
by PER_CU. This is for the non-DWP case.
The result is NULL if DWO_NAME can't be found. */
-static dwo_file_up
-open_and_init_dwo_file (dwarf2_cu *cu, const char *dwo_name,
- const char *comp_dir)
+dwo_file_up
+cutu_reader::open_and_init_dwo_file (dwarf2_cu *cu, const char *dwo_name,
+ const char *comp_dir)
{
dwarf2_per_objfile *per_objfile = cu->per_objfile;
+ dwarf2_per_bfd *per_bfd = per_objfile->per_bfd;
gdb_bfd_ref_ptr dbfd
= open_dwo_file (per_objfile->per_bfd, dwo_name, comp_dir);
@@ -7627,17 +7623,18 @@ open_and_init_dwo_file (dwarf2_cu *cu, const char *dwo_name,
dwo_file->dbfd = std::move (dbfd);
for (asection *sec : gdb_bfd_sections (dwo_file->dbfd))
- dwarf2_locate_dwo_sections (per_objfile->objfile, dwo_file->dbfd.get (),
- sec, &dwo_file->sections);
+ this->locate_dwo_sections (per_objfile->objfile, dwo_file->dbfd.get (), sec,
+ &dwo_file->sections);
- create_cus_hash_table (cu, *dwo_file);
+ create_dwo_cus_hash_table (cu, *dwo_file);
if (cu->header.version < 5)
- create_debug_types_hash_table (per_objfile, dwo_file.get (),
- dwo_file->sections.types);
+ create_dwo_debug_types_hash_table (per_bfd, dwo_file.get (),
+ dwo_file->sections.types);
else
- create_debug_type_hash_table (per_objfile, dwo_file.get (),
- &dwo_file->sections.info, rcuh_kind::COMPILE);
+ create_dwo_debug_type_hash_table (per_bfd, dwo_file.get (),
+ &dwo_file->sections.info,
+ rcuh_kind::COMPILE);
dwarf_read_debug_printf ("DWO file found: %s", dwo_name);
@@ -7803,10 +7800,9 @@ open_dwp_file (dwarf2_per_bfd *per_bfd, const char *file_name)
}
/* Initialize the use of the DWP file for the current objfile.
- By convention the name of the DWP file is ${objfile}.dwp.
- The result is NULL if it can't be found. */
+ By convention the name of the DWP file is ${objfile}.dwp. */
-static dwp_file_up
+static void
open_and_init_dwp_file (dwarf2_per_objfile *per_objfile)
{
struct objfile *objfile = per_objfile->objfile;
@@ -7844,7 +7840,7 @@ open_and_init_dwp_file (dwarf2_per_objfile *per_objfile)
{
dwarf_read_debug_printf ("DWP file not found: %s", dwp_name.c_str ());
- return dwp_file_up ();
+ return;
}
const char *name = bfd_get_filename (dbfd.get ());
@@ -7858,9 +7854,10 @@ open_and_init_dwp_file (dwarf2_per_objfile *per_objfile)
dwarf2_locate_common_dwp_sections (objfile, dwp_file->dbfd.get (), sec,
dwp_file.get ());
- dwp_file->cus = create_dwp_hash_table (per_objfile, dwp_file.get (), 0);
-
- dwp_file->tus = create_dwp_hash_table (per_objfile, dwp_file.get (), 1);
+ dwp_file->cus = create_dwp_hash_table (per_bfd, dwp_file.get (),
+ dwp_file->sections.cu_index);
+ dwp_file->tus = create_dwp_hash_table (per_bfd, dwp_file.get (),
+ dwp_file->sections.tu_index);
/* The DWP file version is stored in the hash table. Oh well. */
if (dwp_file->cus && dwp_file->tus
@@ -7900,20 +7897,8 @@ open_and_init_dwp_file (dwarf2_per_objfile *per_objfile)
bfd_cache_close (dwp_file->dbfd.get ());
- return dwp_file;
-}
-
-/* Wrapper around open_and_init_dwp_file, only open it once. */
-
-static struct dwp_file *
-get_dwp_file (dwarf2_per_objfile *per_objfile)
-{
- if (!per_objfile->per_bfd->dwp_checked)
- {
- per_objfile->per_bfd->dwp_file = open_and_init_dwp_file (per_objfile);
- per_objfile->per_bfd->dwp_checked = 1;
- }
- return per_objfile->per_bfd->dwp_file.get ();
+ /* Everything worked, install this dwp_file in the per_bfd. */
+ per_objfile->per_bfd->dwp_file = std::move (dwp_file);
}
/* Subroutine of lookup_dwo_comp_unit, lookup_dwo_type_unit.
@@ -7932,22 +7917,23 @@ get_dwp_file (dwarf2_per_objfile *per_objfile)
The result is a pointer to the dwo_unit object or NULL if we didn't find it
(dwo_id mismatch or couldn't find the DWO/DWP file). */
-static struct dwo_unit *
-lookup_dwo_cutu (dwarf2_cu *cu, const char *dwo_name, const char *comp_dir,
- ULONGEST signature, int is_debug_types)
+dwo_unit *
+cutu_reader::lookup_dwo_cutu (dwarf2_cu *cu, const char *dwo_name,
+ const char *comp_dir, ULONGEST signature,
+ int is_debug_types)
{
dwarf2_per_objfile *per_objfile = cu->per_objfile;
dwarf2_per_bfd *per_bfd = per_objfile->per_bfd;
struct objfile *objfile = per_objfile->objfile;
const char *kind = is_debug_types ? "TU" : "CU";
- struct dwp_file *dwp_file;
/* First see if there's a DWP file.
If we have a DWP file but didn't find the DWO inside it, don't
look for the original DWO file. It makes gdb behave differently
depending on whether one is debugging in the build tree. */
- dwp_file = get_dwp_file (per_objfile);
+ dwp_file *dwp_file = per_objfile->per_bfd->dwp_file.get ();
+
if (dwp_file != NULL)
{
const struct dwp_hash_table *dwp_htab =
@@ -8048,9 +8034,9 @@ lookup_dwo_cutu (dwarf2_cu *cu, const char *dwo_name, const char *comp_dir,
/* Lookup the DWO CU DWO_NAME/SIGNATURE referenced from THIS_CU.
See lookup_dwo_cutu_unit for details. */
-static struct dwo_unit *
-lookup_dwo_comp_unit (dwarf2_cu *cu, const char *dwo_name, const char *comp_dir,
- ULONGEST signature)
+dwo_unit *
+cutu_reader::lookup_dwo_comp_unit (dwarf2_cu *cu, const char *dwo_name,
+ const char *comp_dir, ULONGEST signature)
{
gdb_assert (!cu->per_cu->is_debug_types);
@@ -8060,8 +8046,9 @@ lookup_dwo_comp_unit (dwarf2_cu *cu, const char *dwo_name, const char *comp_dir,
/* Lookup the DWO TU DWO_NAME/SIGNATURE referenced from THIS_TU.
See lookup_dwo_cutu_unit for details. */
-static struct dwo_unit *
-lookup_dwo_type_unit (dwarf2_cu *cu, const char *dwo_name, const char *comp_dir)
+dwo_unit *
+cutu_reader::lookup_dwo_type_unit (dwarf2_cu *cu, const char *dwo_name,
+ const char *comp_dir)
{
gdb_assert (cu->per_cu->is_debug_types);
@@ -8104,7 +8091,7 @@ queue_and_load_all_dwo_tus (dwarf2_cu *cu)
gdb_assert (cu != nullptr);
gdb_assert (!cu->per_cu->is_debug_types);
- gdb_assert (get_dwp_file (cu->per_objfile) == nullptr);
+ gdb_assert (cu->per_objfile->per_bfd->dwp_file == nullptr);
dwo_unit = cu->dwo_unit;
gdb_assert (dwo_unit != NULL);
@@ -19182,7 +19169,7 @@ dwarf2_symbol_mark_computed (const struct attribute *attr, struct symbol *sym,
/* .debug_loc{,.dwo} may not exist at all, or the offset may be outside
the section. If so, fall through to the complaint in the
other branch. */
- && attr->as_unsigned () < section->get_size (objfile))
+ && attr->as_unsigned () < section->size)
{
struct dwarf2_loclist_baton *baton;
diff --git a/gdb/dwarf2/read.h b/gdb/dwarf2/read.h
index 3177b19..a9a2aa4 100644
--- a/gdb/dwarf2/read.h
+++ b/gdb/dwarf2/read.h
@@ -634,9 +634,6 @@ public:
/* Set of dwo_file objects. */
dwo_file_up_set dwo_files;
- /* True if we've checked for whether there is a DWP file. */
- bool dwp_checked = false;
-
/* The DWP file if there is one, or NULL. */
dwp_file_up dwp_file;
@@ -1028,6 +1025,39 @@ private:
const char *read_dwo_str_index (ULONGEST str_index);
+ gdb_bfd_ref_ptr open_dwo_file (dwarf2_per_bfd *per_bfd, const char *file_name,
+ const char *comp_dir);
+
+ dwo_file_up open_and_init_dwo_file (dwarf2_cu *cu, const char *dwo_name,
+ const char *comp_dir);
+
+ void locate_dwo_sections (struct objfile *objfile, bfd *abfd, asection *sectp,
+ struct dwo_sections *dwo_sections);
+
+ void create_dwo_cus_hash_table (dwarf2_cu *cu, dwo_file &dwo_file);
+
+ void create_dwo_debug_types_hash_table
+ (dwarf2_per_bfd *per_bfd, dwo_file *dwo_file,
+ gdb::array_view<dwarf2_section_info> type_sections);
+
+ void create_dwo_debug_type_hash_table (dwarf2_per_bfd *per_bfd,
+ dwo_file *dwo_file,
+ dwarf2_section_info *section,
+ rcuh_kind section_kind);
+
+ dwo_unit *lookup_dwo_cutu (dwarf2_cu *cu, const char *dwo_name,
+ const char *comp_dir, ULONGEST signature,
+ int is_debug_types);
+
+ dwo_unit *lookup_dwo_comp_unit (dwarf2_cu *cu, const char *dwo_name,
+ const char *comp_dir, ULONGEST signature);
+
+ dwo_unit *lookup_dwo_type_unit (dwarf2_cu *cu, const char *dwo_name,
+ const char *comp_dir);
+
+ dwo_unit *lookup_dwo_unit (dwarf2_cu *cu, die_info *comp_unit_die,
+ const char *dwo_name);
+
/* The bfd of die_section. */
bfd *m_abfd;
diff --git a/gdb/dwarf2/section.h b/gdb/dwarf2/section.h
index 85da485..b9d3c31 100644
--- a/gdb/dwarf2/section.h
+++ b/gdb/dwarf2/section.h
@@ -81,19 +81,6 @@ struct dwarf2_section_info
If the section is compressed, uncompress it before returning. */
void read (struct objfile *objfile);
- /* A helper function that returns the size of a section in a safe way.
- If you are positive that the section has been read before using the
- size, then it is safe to refer to the dwarf2_section_info object's
- "size" field directly. In other cases, you must call this
- function, because for compressed sections the size field is not set
- correctly until the section has been read. */
- bfd_size_type get_size (struct objfile *objfile)
- {
- if (!readin)
- read (objfile);
- return size;
- }
-
/* Issue a complaint that something was outside the bounds of this
buffer. */
void overflow_complaint () const;
diff --git a/gdb/maint.h b/gdb/maint.h
index 434d2a9..0ddc62b 100644
--- a/gdb/maint.h
+++ b/gdb/maint.h
@@ -22,6 +22,9 @@
#include "gdbsupport/run-time-clock.h"
#include <chrono>
+struct obj_section;
+struct objfile;
+
extern void set_per_command_time (int);
extern void set_per_command_space (int);
diff --git a/gdb/python/py-value.c b/gdb/python/py-value.c
index 3855bde..8a2e263 100644
--- a/gdb/python/py-value.c
+++ b/gdb/python/py-value.c
@@ -1096,8 +1096,7 @@ valpy_getitem (PyObject *self, PyObject *key)
res_val = value_struct_elt (&tmp, {}, field.get (), NULL,
"struct/class/union");
else if (bitpos >= 0)
- res_val = value_struct_elt_bitpos (&tmp, bitpos, field_type,
- "struct/class/union");
+ res_val = value_struct_elt_bitpos (tmp, bitpos, field_type);
else if (base_class_type != NULL)
{
struct type *val_type;
diff --git a/gdb/testsuite/gdb.ada/scalar_storage.exp b/gdb/testsuite/gdb.ada/scalar_storage.exp
index 6b29226..52a85cd 100644
--- a/gdb/testsuite/gdb.ada/scalar_storage.exp
+++ b/gdb/testsuite/gdb.ada/scalar_storage.exp
@@ -45,10 +45,30 @@ if {![runto "storage.adb:$bp_location"]} {
return
}
-gdb_test "print V_LE" "= \\(value => 126, another_value => 12, color => green\\)"
+set re "value => 126, another_value => 12, color => green"
# This requires a compiler fix that is in GCC 14.
-if { ![gnat_version_compare >= 14] } {
- setup_kfail "DW_AT_endianity on enum types" *-*-*
+set have_xfail [expr ![gnat_version_compare >= 14]]
+set re_color "(red|green|blue|$decimal)"
+set re_xfail \
+ "value => $decimal, another_value => $decimal, color => $re_color"
+
+set re_pre [string_to_regexp " = ("]
+set re_post [string_to_regexp ")"]
+set re $re_pre$re$re_post
+set re_xfail $re_pre$re_xfail$re_post
+
+foreach var { V_LE V_BE } {
+ gdb_test_multiple "print $var" "" {
+ -re -wrap $re {
+ pass $gdb_test_name
+ }
+ -re -wrap $re_xfail {
+ if { $have_xfail } {
+ xfail $gdb_test_name
+ } else {
+ fail $gdb_test_name
+ }
+ }
+ }
}
-gdb_test "print V_BE" "= \\(value => 126, another_value => 12, color => green\\)"
diff --git a/gdb/testsuite/gdb.arch/aarch64-sve-sigunwind.c b/gdb/testsuite/gdb.arch/aarch64-sve-sigunwind.c
new file mode 100644
index 0000000..c86beaf
--- /dev/null
+++ b/gdb/testsuite/gdb.arch/aarch64-sve-sigunwind.c
@@ -0,0 +1,205 @@
+/* This testcase is part of GDB, the GNU debugger.
+
+ Copyright 2025 Free Software Foundation, Inc.
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>. */
+
+/* Exercise unwinding AArch64's SVE registers from a signal frame. */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <signal.h>
+#include <sys/prctl.h>
+#include <unistd.h>
+
+static int second_vl = 0;
+
+static void
+initialize_sve_state_main ()
+{
+ __asm __volatile ("dup z0.b, -1");
+ __asm __volatile ("dup z1.b, -1");
+ __asm __volatile ("dup z2.b, -1");
+ __asm __volatile ("dup z3.b, -1");
+ __asm __volatile ("dup z4.b, -1");
+ __asm __volatile ("dup z5.b, -1");
+ __asm __volatile ("dup z6.b, -1");
+ __asm __volatile ("dup z7.b, -1");
+ __asm __volatile ("dup z8.b, -1");
+ __asm __volatile ("dup z9.b, -1");
+ __asm __volatile ("dup z10.b, -1");
+ __asm __volatile ("dup z11.b, -1");
+ __asm __volatile ("dup z12.b, -1");
+ __asm __volatile ("dup z13.b, -1");
+ __asm __volatile ("dup z14.b, -1");
+ __asm __volatile ("dup z15.b, -1");
+ __asm __volatile ("dup z16.b, -1");
+ __asm __volatile ("dup z17.b, -1");
+ __asm __volatile ("dup z18.b, -1");
+ __asm __volatile ("dup z19.b, -1");
+ __asm __volatile ("dup z20.b, -1");
+ __asm __volatile ("dup z21.b, -1");
+ __asm __volatile ("dup z22.b, -1");
+ __asm __volatile ("dup z23.b, -1");
+ __asm __volatile ("dup z24.b, -1");
+ __asm __volatile ("dup z25.b, -1");
+ __asm __volatile ("dup z26.b, -1");
+ __asm __volatile ("dup z27.b, -1");
+ __asm __volatile ("dup z28.b, -1");
+ __asm __volatile ("dup z29.b, -1");
+ __asm __volatile ("dup z30.b, -1");
+ __asm __volatile ("dup z31.b, -1");
+ __asm __volatile ("ptrue p0.d");
+ __asm __volatile ("ptrue p1.d");
+ __asm __volatile ("ptrue p2.d");
+ __asm __volatile ("ptrue p3.d");
+ __asm __volatile ("ptrue p4.d");
+ __asm __volatile ("ptrue p5.d");
+ __asm __volatile ("ptrue p6.d");
+ __asm __volatile ("ptrue p7.d");
+ __asm __volatile ("ptrue p8.d");
+ __asm __volatile ("ptrue p9.d");
+ __asm __volatile ("ptrue p10.d");
+ __asm __volatile ("ptrue p11.d");
+ __asm __volatile ("ptrue p12.d");
+ __asm __volatile ("ptrue p13.d");
+ __asm __volatile ("ptrue p14.d");
+ __asm __volatile ("ptrue p15.d");
+ __asm __volatile ("setffr");
+}
+
+static void
+initialize_sve_state_sighandler ()
+{
+ __asm __volatile ("dup z0.b, -2");
+ __asm __volatile ("dup z1.b, -2");
+ __asm __volatile ("dup z2.b, -2");
+ __asm __volatile ("dup z3.b, -2");
+ __asm __volatile ("dup z4.b, -2");
+ __asm __volatile ("dup z5.b, -2");
+ __asm __volatile ("dup z6.b, -2");
+ __asm __volatile ("dup z7.b, -2");
+ __asm __volatile ("dup z8.b, -2");
+ __asm __volatile ("dup z9.b, -2");
+ __asm __volatile ("dup z10.b, -2");
+ __asm __volatile ("dup z11.b, -2");
+ __asm __volatile ("dup z12.b, -2");
+ __asm __volatile ("dup z13.b, -2");
+ __asm __volatile ("dup z14.b, -2");
+ __asm __volatile ("dup z15.b, -2");
+ __asm __volatile ("dup z16.b, -2");
+ __asm __volatile ("dup z17.b, -2");
+ __asm __volatile ("dup z18.b, -2");
+ __asm __volatile ("dup z19.b, -2");
+ __asm __volatile ("dup z20.b, -2");
+ __asm __volatile ("dup z21.b, -2");
+ __asm __volatile ("dup z22.b, -2");
+ __asm __volatile ("dup z23.b, -2");
+ __asm __volatile ("dup z24.b, -2");
+ __asm __volatile ("dup z25.b, -2");
+ __asm __volatile ("dup z26.b, -2");
+ __asm __volatile ("dup z27.b, -2");
+ __asm __volatile ("dup z28.b, -2");
+ __asm __volatile ("dup z29.b, -2");
+ __asm __volatile ("dup z30.b, -2");
+ __asm __volatile ("dup z31.b, -2");
+ __asm __volatile ("pfalse p0.b");
+ __asm __volatile ("pfalse p1.b");
+ __asm __volatile ("pfalse p2.b");
+ __asm __volatile ("pfalse p3.b");
+ __asm __volatile ("pfalse p4.b");
+ __asm __volatile ("pfalse p5.b");
+ __asm __volatile ("pfalse p6.b");
+ __asm __volatile ("pfalse p7.b");
+ __asm __volatile ("pfalse p8.b");
+ __asm __volatile ("pfalse p9.b");
+ __asm __volatile ("pfalse p10.b");
+ __asm __volatile ("pfalse p11.b");
+ __asm __volatile ("pfalse p12.b");
+ __asm __volatile ("pfalse p13.b");
+ __asm __volatile ("pfalse p14.b");
+ __asm __volatile ("pfalse p15.b");
+ __asm __volatile ("setffr");
+}
+
+/* Set new value for the SVE vector length.
+ Return the value that was set. */
+
+static int
+set_vl (int vl)
+{
+ int rc;
+
+ rc = prctl (PR_SVE_SET_VL, vl, 0, 0, 0);
+ if (rc < 0)
+ {
+ perror ("FAILED to PR_SVE_SET_VL");
+ exit (EXIT_FAILURE);
+ }
+
+ return rc & PR_SVE_VL_LEN_MASK;
+}
+
+static void
+sighandler (int sig, siginfo_t *info, void *ucontext)
+{
+ /* Set vector length to the second value. */
+ second_vl = set_vl (second_vl);
+ initialize_sve_state_sighandler ();
+ printf ("sighandler: second_vl = %d\n", second_vl); /* Break here. */
+}
+
+int
+main (int argc, char *argv[])
+{
+ if (argc != 3)
+ {
+ fprintf (stderr, "Usage: %s <first vl> <second vl>\n", argv[0]);
+ return 1;
+ }
+
+ int first_vl = atoi (argv[1]);
+ second_vl = atoi (argv[2]);
+
+ if (first_vl == 0 || second_vl == 0)
+ {
+ fprintf (stderr, "Invalid vector length.\n");
+ return 1;
+ }
+
+ /* Set vector length to the first value. */
+ first_vl = set_vl (first_vl);
+
+ printf ("main: first_vl = %d\n", first_vl);
+
+ unsigned char buf[256];
+
+ /* Use an SVE register to make the kernel start saving the SVE bank. */
+ asm volatile ("mov z0.b, #255\n\t"
+ "str z0, %0"
+ :
+ : "m" (buf)
+ : "z0", "memory");
+
+ initialize_sve_state_main ();
+
+ struct sigaction sigact;
+ sigact.sa_sigaction = sighandler;
+ sigact.sa_flags = SA_SIGINFO;
+ sigaction (SIGUSR1, &sigact, NULL);
+
+ kill (getpid (), SIGUSR1);
+
+ return 0;
+}
diff --git a/gdb/testsuite/gdb.arch/aarch64-sve-sigunwind.exp b/gdb/testsuite/gdb.arch/aarch64-sve-sigunwind.exp
new file mode 100644
index 0000000..32340bb
--- /dev/null
+++ b/gdb/testsuite/gdb.arch/aarch64-sve-sigunwind.exp
@@ -0,0 +1,106 @@
+# Copyright 2025 Free Software Foundation, Inc.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+# Exercise unwinding AArch64's SVE registers from a signal frame.
+
+require allow_aarch64_sve_tests
+# Remote targets can't communicate vector length changes to GDB via the RSP.
+require !gdb_protocol_is_remote
+
+set first_vl 0
+set second_vl 0
+
+# Find two valid VL values to use in the test.
+# The minimum supported VL is 16 bytes, maximum is 256 bytes, and VL can change
+# in increments of at least 16 bytes.
+for {set i 16} {$i <= 256} {incr i 16} {
+ if {![aarch64_supports_sve_vl $i]} {
+ continue
+ }
+
+ if {$first_vl == 0} {
+ set first_vl $i
+ } elseif {$second_vl == 0} {
+ set second_vl $i
+ break
+ }
+}
+
+if {$first_vl == 0 || $second_vl == 0} {
+ untested "test needs to support at least two vector lengths"
+ return
+}
+
+standard_testfile
+if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile} \
+ [list debug additional_flags=-march=armv9-a]] } {
+ return
+}
+
+# We want SIGUSR1 to be delivered normally.
+gdb_test "handle SIGUSR1 nostop" \
+ [multi_line {Signal Stop Print Pass to program Description} \
+ {SIGUSR1 No Yes Yes User defined signal 1}] \
+ "don't stop for SIGUSR1"
+
+set linespec ${srcfile}:[gdb_get_line_number "Break here."]
+gdb_test_no_output "set args $first_vl $second_vl"
+
+if ![runto ${linespec}] {
+ return
+}
+
+set first_vg [expr $first_vl/8]
+set second_vg [expr $second_vl/8]
+
+gdb_test "print \$vg" ". = $second_vg" "vg was changed"
+
+for {set row 0} {$row < 32} {incr row} {
+ set register_name "\$z${row}\.b\.u"
+ gdb_test "print sizeof $register_name" " = $second_vl" \
+ "size of $register_name in the signal handler"
+ gdb_test "print $register_name" ". = \\{254 <repeats $second_vl times>\\}" \
+ "$register_name contents in signal handler"
+}
+
+for {set row 0} {$row < 16} {incr row} {
+ set register_name "\$p${row}"
+ gdb_test "print $register_name" ". = \\{(0, ){[expr $second_vl/8 - 1]}0\\}" \
+ "$register_name contents in signal handler"
+}
+gdb_test "print \$ffr" ". = \\{(255, ){[expr $second_vl/8 - 1]}255\\}" \
+ "ffr contents in signal handler"
+
+gdb_test "frame function main" \
+ [multi_line "#$decimal $hex in main \[^\r\n\]+" \
+ "$decimal\[ \t\]+kill \\(getpid \\(\\), SIGUSR1\\);"]
+
+gdb_test "print \$vg" ". = $first_vg" "vg was correctly unwound"
+
+for {set row 0} {$row < 32} {incr row} {
+ set register_name "\$z${row}\.b\.u"
+ gdb_test "print sizeof $register_name" " = $first_vl" \
+ "size of $register_name was correctly unwound"
+ gdb_test "print $register_name" ". = \\{255 <repeats $first_vl times>\\}" \
+ "$register_name contents were correctly unwound"
+}
+
+for {set row 0} {$row < 16} {incr row} {
+ set register_name "\$p${row}"
+ gdb_test "print $register_name" ". = \\{(1, ){[expr $first_vl/8 - 1]}1\\}" \
+ "$register_name contents were correctly unwound"
+}
+gdb_test "print \$ffr" ". = \\{(255, ){[expr $first_vl/8 - 1]}255\\}" \
+ "ffr contents were correctly unwound"
diff --git a/gdb/testsuite/gdb.base/bg-execution-repeat.c b/gdb/testsuite/gdb.base/bg-execution-repeat.c
index 8e9bae4..3c0cc76 100644
--- a/gdb/testsuite/gdb.base/bg-execution-repeat.c
+++ b/gdb/testsuite/gdb.base/bg-execution-repeat.c
@@ -37,9 +37,9 @@ main (void)
{
alarm (60);
+ do_wait = 1;
foo ();
- do_wait = 1;
wait ();
/* do_wait set to 0 externally. */
diff --git a/gdb/testsuite/gdb.base/corefile3.c b/gdb/testsuite/gdb.base/corefile3.c
new file mode 100644
index 0000000..16030dd
--- /dev/null
+++ b/gdb/testsuite/gdb.base/corefile3.c
@@ -0,0 +1,118 @@
+/* Copyright 1992-2025 Free Software Foundation, Inc.
+
+ This file is part of GDB.
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>. */
+
+/* This file is based on coremaker.c. */
+
+#include <stdio.h>
+#include <sys/types.h>
+#include <fcntl.h>
+#include <sys/mman.h>
+#include <signal.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <string.h>
+#include <assert.h>
+#include <sys/ipc.h>
+#include <sys/shm.h>
+
+#define MAPSIZE (8 * 1024)
+
+/* Global pointers so it's easier to access them from GDB. */
+
+char *rw_mapping = NULL;
+char *malloc_buffer = NULL;
+char *anon_mapping = NULL;
+char *shm_mapping = NULL;
+
+/* Create mappings within this process. */
+
+void
+mmapdata ()
+{
+ /* Allocate and initialize a buffer that will be used to write the file
+ that is later mapped in. */
+
+ malloc_buffer = (char *) malloc (MAPSIZE);
+ for (int j = 0; j < MAPSIZE; ++j)
+ malloc_buffer[j] = j;
+
+ /* Write the file to map in. */
+
+ int fd = open ("coremmap.data", O_CREAT | O_RDWR, 0666);
+ assert (fd != -1);
+ write (fd, malloc_buffer, MAPSIZE);
+
+ /* Now map the file into our address space as RW_MAPPING. */
+
+ rw_mapping
+ = (char *) mmap (0, MAPSIZE, PROT_READ | PROT_WRITE, MAP_PRIVATE, fd, 0);
+ assert (rw_mapping != (char *) MAP_FAILED);
+
+ /* Verify that the original data and the mapped data are identical. If
+ not, we'd rather fail now than when trying to access the mapped data
+ from the core file. */
+
+ for (int j = 0; j < MAPSIZE; ++j)
+ assert (malloc_buffer[j] == rw_mapping[j]);
+
+ /* Touch RW_MAPPING so the kernel writes it out into 'core'. */
+ rw_mapping[0] = malloc_buffer[0];
+
+ /* Create yet another region which is allocated, but not written to. */
+ anon_mapping = mmap (NULL, MAPSIZE, PROT_READ | PROT_WRITE,
+ MAP_ANONYMOUS | MAP_PRIVATE, -1, 0);
+ assert (anon_mapping != MAP_FAILED);
+
+ /* Create a shared memory mapping. */
+ int sid = shmget (IPC_PRIVATE, MAPSIZE, IPC_CREAT | IPC_EXCL | 0777);
+ assert (sid != -1);
+ shm_mapping = (char *) shmat (sid, NULL, 0);
+ int res = shmctl (sid, IPC_RMID, NULL);
+ assert (res == 0);
+ assert (shm_mapping != MAP_FAILED);
+}
+
+void
+func2 ()
+{
+#ifdef SA_FULLDUMP
+ /* Force a corefile that includes the data section for AIX. */
+ {
+ struct sigaction sa;
+
+ sigaction (SIGABRT, (struct sigaction *)0, &sa);
+ sa.sa_flags |= SA_FULLDUMP;
+ sigaction (SIGABRT, &sa, (struct sigaction *)0);
+ }
+#endif
+
+ abort ();
+}
+
+void
+func1 ()
+{
+ func2 ();
+}
+
+int
+main (void)
+{
+ mmapdata ();
+ func1 ();
+ return 0;
+}
diff --git a/gdb/testsuite/gdb.base/corefile3.exp b/gdb/testsuite/gdb.base/corefile3.exp
new file mode 100644
index 0000000..57b2300
--- /dev/null
+++ b/gdb/testsuite/gdb.base/corefile3.exp
@@ -0,0 +1,71 @@
+# Copyright 2025 Free Software Foundation, Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+# Create a core file with some mapped file regions, but ensure that
+# the the kernel should write the regions into the core file (e.g. r/w
+# file backed mapping).
+#
+# We then delete the file that backed the mapping and load the core
+# file into GDB.
+#
+# GDB shouldn't warn about the file being missing. It doesn't matter;
+# the file contents can all be found in the core file itself.
+
+require isnative
+require {!is_remote host}
+
+standard_testfile
+
+if {[build_executable $testfile.exp $testfile $srcfile] == -1} {
+ return
+}
+
+set corefile [core_find $binfile {}]
+if {$corefile == ""} {
+ return
+}
+
+# Move the coremap.data file out of the way, so it cannot be found
+# when we later load the core file into GDB. This file was generated
+# by the inferior as it was running.
+set data_filename \
+ [standard_output_file coredir.[getpid]/coremmap.data]
+set backup_filename \
+ [standard_output_file coredir.[getpid]/coremmap.data.backup]
+remote_exec host "mv ${data_filename} ${backup_filename}"
+
+clean_restart $binfile
+
+# Load the core file. The 'coremap.data' file cannot be found by GDB,
+# but all the mappings for that file are r/w and should be present in
+# the core file, so we shouldn't get any warnings from GDB about it.
+set warnings_seen 0
+gdb_test_multiple "core-file $corefile" "core-file command" {
+ -re "^warning: Can't open file \[^\r\n\]+ during file-backed mapping note processing\r\n" {
+ incr warnings_seen
+ exp_continue
+ }
+ -re "^$gdb_prompt $" {
+ gdb_assert { $warnings_seen == 0 } $gdb_test_name
+ }
+ -re "^\[^\r\n\]*\r\n" {
+ exp_continue
+ }
+}
+
+# Check the mappings are all readable.
+foreach label { rw_mapping malloc_buffer anon_mapping shm_mapping } {
+ gdb_test "x/1wd $label" "^$hex:\\s+$decimal"
+}
diff --git a/gdb/testsuite/gdb.base/dlmopen-ns-ids.exp b/gdb/testsuite/gdb.base/dlmopen-ns-ids.exp
index 03b7a52..3ddc07e 100644
--- a/gdb/testsuite/gdb.base/dlmopen-ns-ids.exp
+++ b/gdb/testsuite/gdb.base/dlmopen-ns-ids.exp
@@ -24,7 +24,8 @@ require allow_dlmopen_tests
standard_testfile -main.c -lib.c
set srcfile_lib $srcfile2
-set binfile_lib [standard_output_file dlmopen-lib.so]
+set so_name dlmopen-lib.so
+set binfile_lib [standard_output_file $so_name]
if { [build_executable "build shlib" $binfile_lib $srcfile_lib \
[list debug shlib]] == -1 } {
@@ -41,18 +42,19 @@ if { [build_executable "failed to build" $testfile $srcfile \
# for the so
proc get_first_so_ns {} {
set ns -1
- gdb_test_multiple "info sharedlibrary" "get SO namespace" -lbl {
- -re "From\\s+To\\s+\(NS\\s+\)?Syms\\s+Read\\s+Shared Object Library\r\n" {
+ set lib_regexp [string_to_regexp ${::binfile_lib}]
+ gdb_test_multiple "info sharedlibrary $::so_name" "get SO namespace" -lbl {
+ -re "\r\nFrom\\s+To\\s+\(NS\\s+\)?Syms\\s+Read\\s+Shared Object Library(?=\r\n)" {
exp_continue
}
- -re "^$::hex\\s+$::hex\\s+\\\[\\\[($::decimal)\\\]\\\]\\s+\[^\r\n]+$::binfile_lib.*" {
- set ns $expect_out(1,string)
- }
- -re "^$::gdb_prompt $" {
- }
- -re "^\[^\r\n\]+\r\n" {
+ -re "\r\n$::hex\\s+$::hex\\s+\\\[\\\[($::decimal)\\\]\\\]\\s+\[^\r\n]+${lib_regexp}(?=\r\n)" {
+ if {$ns == -1} {
+ set ns $expect_out(1,string)
+ }
exp_continue
}
+ -re -wrap "" {
+ }
}
return $ns
}
diff --git a/gdb/testsuite/gdb.base/printcmds.exp b/gdb/testsuite/gdb.base/printcmds.exp
index e1c996e..8634668 100644
--- a/gdb/testsuite/gdb.base/printcmds.exp
+++ b/gdb/testsuite/gdb.base/printcmds.exp
@@ -744,6 +744,12 @@ proc test_print_char_arrays {} {
gdb_test_no_output "set print address off" "address off char arrays"
}
+proc test_print_arrays_negative {} {
+ # Check whether correct error messages are printed
+ gdb_test "p 1 == { }" "size of the array element must not be zero"
+ gdb_test "p 1 == { 1, 'a' }" "array elements must all be the same size"
+}
+
proc test_print_nibbles {} {
gdb_test_no_output "set print nibbles on"
foreach lang_line {
@@ -1235,6 +1241,7 @@ test_print_int_arrays
test_print_typedef_arrays
test_artificial_arrays
test_print_char_arrays
+test_print_arrays_negative
test_print_nibbles
# We used to do the runto main here.
test_print_string_constants
diff --git a/gdb/testsuite/gdb.cp/cplusfuncs.exp b/gdb/testsuite/gdb.cp/cplusfuncs.exp
index 94d9df3..e785909 100644
--- a/gdb/testsuite/gdb.cp/cplusfuncs.exp
+++ b/gdb/testsuite/gdb.cp/cplusfuncs.exp
@@ -579,7 +579,8 @@ proc do_tests {} {
gdb_test_no_output "set width 0"
- runto_main
+ # Don't run to main, to avoid loading and expanding debug info for
+ # libstdc++.
gdb_test_no_output "set language c++"
probe_demangler
diff --git a/gdb/testsuite/gdb.dwarf2/fission-with-type-unit.exp b/gdb/testsuite/gdb.dwarf2/fission-with-type-unit.exp
index a1b3bb7..0a02f7c 100644
--- a/gdb/testsuite/gdb.dwarf2/fission-with-type-unit.exp
+++ b/gdb/testsuite/gdb.dwarf2/fission-with-type-unit.exp
@@ -91,6 +91,10 @@ if { [gdb_compile_shlib $dwo_asm_file $dwo_file nodebug] != "" } {
return
}
+if { [is_remote host] } {
+ gdb_remote_download host $dwo_file
+}
+
clean_restart ${testfile}
# This would cause an internal error.
diff --git a/gdb/testsuite/gdb.threads/clone-attach-detach.exp b/gdb/testsuite/gdb.threads/clone-attach-detach.exp
index 0ae4281..3da2c3e 100644
--- a/gdb/testsuite/gdb.threads/clone-attach-detach.exp
+++ b/gdb/testsuite/gdb.threads/clone-attach-detach.exp
@@ -74,7 +74,7 @@ set attempts 3
for {set attempt 1} {$attempt <= $attempts} {incr attempt} {
with_test_prefix "bg attach $attempt" {
- gdb_test "attach $testpid &" \
+ gdb_test -no-prompt-anchor "attach $testpid &" \
"Attaching to program.*process $testpid.*" \
"attach"
diff --git a/gdb/unittests/rsp-low-selftests.c b/gdb/unittests/rsp-low-selftests.c
index df849c9..7a1b2de 100644
--- a/gdb/unittests/rsp-low-selftests.c
+++ b/gdb/unittests/rsp-low-selftests.c
@@ -51,7 +51,7 @@ static void test_hex2str ()
{
SELF_CHECK (hex2str ("666f6f") == "foo");
SELF_CHECK (hex2str ("666f6fa") == "foo");
- SELF_CHECK (hex2str ("666f6f", 2) == "fo");
+ SELF_CHECK (hex2str ("666f6f", 2) == "fo"); /* codespell:ignore */
SELF_CHECK (hex2str ("666", 2) == "f");
SELF_CHECK (hex2str ("666", 6) == "f");
SELF_CHECK (hex2str ("") == "");
diff --git a/gdb/valops.c b/gdb/valops.c
index 09af0ae..94f908d 100644
--- a/gdb/valops.c
+++ b/gdb/valops.c
@@ -1695,6 +1695,9 @@ value_array (int lowbound, gdb::array_view<struct value *> elemvec)
/* Validate that the bounds are reasonable and that each of the
elements have the same size. */
+ if (elemvec.empty ())
+ error (_("size of the array element must not be zero"));
+
typelength = type_length_units (elemvec[0]->enclosing_type ());
for (struct value *other : elemvec.slice (1))
{
@@ -2417,47 +2420,42 @@ value_struct_elt (struct value **argp,
return v;
}
-/* Given *ARGP, a value of type structure or union, or a pointer/reference
+/* Given VAL, a value of type structure or union, or a pointer/reference
to a structure or union, extract and return its component (field) of
type FTYPE at the specified BITPOS.
Throw an exception on error. */
struct value *
-value_struct_elt_bitpos (struct value **argp, int bitpos, struct type *ftype,
- const char *err)
+value_struct_elt_bitpos (struct value *val, int bitpos, struct type *ftype)
{
struct type *t;
int i;
- *argp = coerce_array (*argp);
+ val = coerce_array (val);
- t = check_typedef ((*argp)->type ());
+ t = check_typedef (val->type ());
while (t->is_pointer_or_reference ())
{
- *argp = value_ind (*argp);
- if (check_typedef ((*argp)->type ())->code () != TYPE_CODE_FUNC)
- *argp = coerce_array (*argp);
- t = check_typedef ((*argp)->type ());
+ val = value_ind (val);
+ if (check_typedef (val->type ())->code () != TYPE_CODE_FUNC)
+ val = coerce_array (val);
+ t = check_typedef (val->type ());
}
if (t->code () != TYPE_CODE_STRUCT
&& t->code () != TYPE_CODE_UNION)
- error (_("Attempt to extract a component of a value that is not a %s."),
- err);
+ error (_("Attempt to extract a component of non-aggregate value."));
for (i = TYPE_N_BASECLASSES (t); i < t->num_fields (); i++)
{
if (!t->field (i).is_static ()
&& bitpos == t->field (i).loc_bitpos ()
&& types_equal (ftype, t->field (i).type ()))
- return (*argp)->primitive_field (0, i, t);
+ return val->primitive_field (0, i, t);
}
error (_("No field with matching bitpos and type."));
-
- /* Never hit. */
- return NULL;
}
/* Search through the methods of an object (and its bases) to find a
diff --git a/gdb/value.h b/gdb/value.h
index 0cbcfca..71d0ba1 100644
--- a/gdb/value.h
+++ b/gdb/value.h
@@ -1297,10 +1297,9 @@ extern struct value *value_struct_elt (struct value **argp,
const char *name, int *static_memfuncp,
const char *err);
-extern struct value *value_struct_elt_bitpos (struct value **argp,
+extern struct value *value_struct_elt_bitpos (struct value *val,
int bitpos,
- struct type *field_type,
- const char *err);
+ struct type *field_type);
extern struct value *value_aggregate_elt (struct type *curtype,
const char *name,