Commit Graph

102700 Commits

Author SHA1 Message Date
H.J. Lu
377170fa31 PKG_CHECK_MODULES: Properly check if $pkg_cv_[]$1[]_LIBS works
There is no need to check $pkg_cv_[]$1[]_LIBS works if package check
failed.

config/

	PR binutils/26301
	* pkg.m4 (PKG_CHECK_MODULES): Use AC_TRY_LINK only if
	$pkg_failed = no.

binutils/

	PR binutils/26301
	* configure: Regenerated.

gdb/

	PR binutils/26301
	* configure: Regenerated.
2020-07-28 06:59:30 -07:00
Tom de Vries
866b34a12d [gdb/build] Fix Wmaybe-uninitialized in gdb_optional.h
When building with CFLAGS/CXXFLAGS="-O2 -g -Wall", we run into:
...
In file included from src/gdb/exceptions.h:23,
                 from src/gdb/utils.h:24,
                 from src/gdb/defs.h:630,
                 from src/gdb/record-btrace.c:22:
src/gdb/ui-out.h: In function 'void btrace_insn_history(ui_out*, \
  const btrace_thread_info*, const btrace_insn_iterator*, \
  const btrace_insn_iterator*, gdb_disassembly_flags)':
src/gdb/ui-out.h:352:18: warning: \
  'asm_list.ui_out_emit_type<ui_out_type_list>::m_uiout' may be used \
  uninitialized in this function [-Wmaybe-uninitialized]
  352 |     m_uiout->end (Type);
      |     ~~~~~~~~~~~~~^~~~~~
src/gdb/record-btrace.c:795:35: note: \
  'asm_list.ui_out_emit_type<ui_out_type_list>::m_uiout' was declared here
  795 |   gdb::optional<ui_out_emit_list> asm_list;
      |                                   ^~~~~~~~
...

This is reported as PR gcc/80635 - "[8/9/10/11 regression] std::optional and
bogus -Wmaybe-uninitialized warning".

Silence the warning by using the workaround suggested here (
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80635#c53 ):
...
   union
   {
     struct { } m_dummy;
     T m_item;
+    volatile char dont_use; // Silences -Wmaybe-uninitialized warning.
   };
...

Build on x86_64-linux.

gdbsupport/ChangeLog:

2020-07-28  Tom de Vries  <tdevries@suse.de>

	PR build/26281
	* gdb_optional.h (class optional): Add volatile member to union
	contaning m_dummy and m_item.
2020-07-28 15:07:44 +02:00
H.J. Lu
d70f978b44 PKG_CHECK_MODULES: Check if $pkg_cv_[]$1[]_LIBS works
It is quite normal to have headers without library on multilib OSes.
Add AC_TRY_LINK to PKG_CHECK_MODULES to check if $pkg_cv_[]$1[]_LIBS
works.

config/

	PR binutils/26301
	* pkg.m4 (PKG_CHECK_MODULES): Add AC_TRY_LINK to check if
	$pkg_cv_[]$1[]_LIBS works.

binutils/

	PR binutils/26301
	* configure: Regenerated.

gdb/

	PR binutils/26301
	* configure: Regenerated.
2020-07-28 03:56:34 -07:00
H.J. Lu
1a02d6b0ff x86: Handle {disp32} for (%bp)/(%ebp)/(%rbp)
Since (%bp)/(%ebp)/(%rbp) are encoded as 0(%bp)/0(%ebp)/0(%rbp), use
disp32/disp16 on 0(%bp)/0(%ebp)/0(%rbp) for {disp32}.

Note: Since there is no disp32 on 0(%bp), use disp16 instead.

	PR gas/26305
	* config/tc-i386.c (build_modrm_byte): Use disp32/disp16 on
	(%bp)/(%ebp)/(%rbp) for {disp32}.
	* doc/c-i386.texi: Update {disp32} documentation.
	* testsuite/gas/i386/pseudos.s: Add (%bp)/(%ebp) tests.
	* testsuite/gas/i386/x86-64-pseudos.s: Add (%ebp)/(%rbp) tests.
	* testsuite/gas/i386/pseudos.d: Updated.
	* testsuite/gas/i386/x86-64-pseudos.d: Likewise.
2020-07-28 03:55:53 -07:00
Andrew Burgess
43d5901ded gdb/python: make more use of RegisterDescriptors
This commit unifies all of the Python register lookup code (used by
Frame.read_register, PendingFrame.read_register, and
gdb.UnwindInfo.add_saved_register), and adds support for using a
gdb.RegisterDescriptor for register lookup.

Currently the register unwind code (PendingFrame and UnwindInfo) allow
registers to be looked up either by name, or by GDB's internal
number.  I suspect the number was added for performance reasons, when
unwinding we don't want to repeatedly map from name to number for
every unwind.  However, this kind-of sucks, it means Python scripts
could include GDB's internal register numbers, and if we ever change
this numbering in the future users scripts will break in unexpected
ways.

Meanwhile, the Frame.read_register method only supports accessing
registers using a string, the register name.

This commit unifies all of the register to register-number lookup code
in our Python bindings, and adds a third choice into the mix, the use
of gdb.RegisterDescriptor.

The register descriptors can be looked up by name, but once looked up,
they contain GDB's register number, and so provide all of the
performance benefits of using a register number directly.  However, as
they are looked up by name we are no longer tightly binding the Python
API to GDB's internal numbering scheme.

As we may already have scripts in the wild that are using the register
numbers directly I have kept support for this in the API, but I have
listed this method last in the manual, and I have tried to stress that
this is NOT a good method to use and that users should use either a
string or register descriptor approach.

After this commit all existing Python code should function as before,
but users now have new options for how to identify registers.

gdb/ChangeLog:

	* python/py-frame.c: Remove 'user-regs.h' include.
	(frapy_read_register): Rewrite to make use of
	gdbpy_parse_register_id.
	* python/py-registers.c (gdbpy_parse_register_id): New function,
	moved here from python/py-unwind.c.  Updated the return type, and
	also accepts register descriptor objects.
	* python/py-unwind.c: Remove 'user-regs.h' include.
	(pyuw_parse_register_id): Moved to python/py-registers.c.
	(unwind_infopy_add_saved_register): Update to use
	gdbpy_parse_register_id.
	(pending_framepy_read_register): Likewise.
	* python/python-internal.h (gdbpy_parse_register_id): Declare.

gdb/testsuite/ChangeLog:

	* gdb.python/py-unwind.py: Update to make use of a register
	descriptor.

gdb/doc/ChangeLog:

	* python.texi (Unwinding Frames in Python): Update descriptions
	for PendingFrame.read_register and
	gdb.UnwindInfo.add_saved_register.
	(Frames In Python): Update description of Frame.read_register.
2020-07-28 10:27:54 +01:00
Andrew Burgess
14fa8fb307 gdb: Add a find method for RegisterDescriptorIterator
Adds a new method 'find' to the gdb.RegisterDescriptorIterator class,
this allows gdb.RegisterDescriptor objects to be looked up directly by
register name rather than having to iterate over all registers.

This will be of use for a later commit.

I've documented the new function in the manual, but I don't think a
NEWS entry is required here, as, since the last release, the whole
register descriptor mechanism is new, and is already mentioned in the
NEWS file.

gdb/ChangeLog:

	* python/py-registers.c: Add 'user-regs.h' include.
	(register_descriptor_iter_find): New function.
	(register_descriptor_iterator_object_methods): New static global
	methods array.
	(register_descriptor_iterator_object_type): Add pointer to methods
	array.

gdb/testsuite/ChangeLog:

	* gdb.python/py-arch-reg-names.exp: Add additional tests.

gdb/doc/ChangeLog:

	* python.texi (Registers In Python): Document new find function.
2020-07-28 10:27:53 +01:00
Alan Modra
67411cbf63 PR25022 testcase segfault for generic ELF linker targets
Even a testcase that is expected to fail shouldn't segfault.

	* elf.c (assign_section_numbers): Comment.  Don't segfault on
	discarded sections when setting linked-to section for generic
	ELF linker.
	* elflink.c (bfd_elf_match_symbols_in_sections): Allow NULL info.
2020-07-28 16:56:14 +09:30
Alan Modra
f437dadd89 More just-syms changes
* ldlang.c (lang_check): Don't complain about relocs or merge
	attributes from --just-symbols input.
	* testsuite/ld-misc/just-symbols.exp: Just dump .data section.
	Don't run test on a number of targets.
2020-07-28 13:09:20 +09:30
Alan Modra
c38166b376 Re: Allow new just-symbols test to run on XCOFF and PE
This ensures we don't match random data *before* the line we want to
see, ie. that --just-symbols has excluded section contents from
just-symbols-0.o.  Oops, missed the ChangeLog entry before too.

	* testsuite/ld-misc/just-symbols-1.dd: Revert last change.
2020-07-28 13:09:20 +09:30
GDB Administrator
cf0ae6e41f Automatic date update in version.in 2020-07-28 00:00:05 +00:00
John Baldwin
ddce17585c Use SIGTRAP si_code values for all FreeBSD architectures on 11.3 and later.
Fixes to set correct si_code values (such as TRAP_BRKPT) were made to
the remaining FreeBSD architectures (MIPS and sparc64) in the head
branch leading up to 12.0 and were merged back between the 11.2 and
11.3 releases.

gdb/ChangeLog:

	* fbsd-nat.h: Include <osreldate.h>.  Define USE_SIGTRAP_SIGINFO
	for all architectures on FreeBSD 11.3 and later.
2020-07-27 08:58:48 -07:00
Tom Tromey
a4089f524f Remove unused declaration from gcore.h
gcore.h declares load_corefile, but there are no other mentions of
this in the source.  This patch removes it.  Tested by grep and
rebuilding.

gdb/ChangeLog
2020-07-27  Tom Tromey  <tromey@adacore.com>

	* gcore.h (load_corefile): Don't declare.
2020-07-27 09:54:05 -06:00
Alan Modra
32377a8037 Allow new just-symbols test to run on XCOFF and PE
* testsuite/ld-misc/just-symbols.exp: Run for x86_64 PE too.
	Set LDFLAGS for PE and XCOFF.
	* testsuite/ld-misc/just-symbols.ld: Accept XCOFF mapped .data.
2020-07-27 22:31:37 +09:30
Alan Modra
93fd13c704 Accept --just-symbols symbols as absolute for xcoff
This patch is aimed at curing
    just-symbols-1.o: loader reloc in unrecognized section `*ABS*'
for xcoff by treating symbols defined by --just-symbols objects as
absolute.

	* xcofflink.c (xcoff_need_ldrel_p): Accept --just-symbols symbols and
	similar as absolute.
	(bfd_xcoff_import_symbol): Don't fuss over absolute symbol
	redefinitions here.
2020-07-27 22:31:37 +09:30
Alan Modra
8fab9282e5 Prevent strange "section mentioned in a -j option but not found"
"objdump -s -j .bss" results in a message that indicates objdump
couldn't find a .bss section when present.  Fix that.

	* objdump.c (dump_section): Don't return without calling
	process_section_p.
2020-07-27 22:31:37 +09:30
Alan Modra
344e66534e ctf test ERROR: $target-cc does not exist
* testsuite/lib/ld-lib.exp (check_ctf_available): Check first that
	target compiler is available.
2020-07-27 22:31:37 +09:30
Alan Modra
afd2ea2362 [GOLD] Power10 stub selection
gold version of commit e10a07b32d.

	* options.h (DEFINE_enum): Add optional_arg__ param, adjust
	all uses.
	(General_options): Add --power10-stubs and --no-power10-stubs.
	* options.cc (General_options::finalize): Handle --power10-stubs.
	* powerpc.cc (set_power10_stubs): Don't set when --power10-stubs=no.
	(power10_stubs_auto): New.
	(struct Plt_stub_ent): Add toc_ and tocoff_.  Don't use a bitfield
	for indx_.
	(struct Branch_stub_ent): Add toc_and tocoff_.  Use bitfields for
	iter_, notoc_ and save_res_.
	(add_plt_call_entry): Set toc_.  Adjust resizing conditions for
	--power10-stubs=auto.
	(add_long_branch_entry): Set toc_.
	(add_eh_frame, define_stub_syms): No longer use const_iterators
	for plt and long branch stub iteration.
	(build_tls_opt_head, build_tls_opt_tail): Change parameters and
	return value.  Move tests for __tls_get_addr to callers.
	(plt_call_size): Handle --power10-stubs=auto.
	(branch_stub_size): Likewise.
	(Stub_table::do_write): Likewise.
	(relocate): Likewise.
2020-07-27 22:31:37 +09:30
H.J. Lu
608d61c202 doc: Replace preceeded with preceded
binutils/

	* doc/binutils.texi: Replace preceeded with preceded.

gas/

	* doc/as.texi: Replace preceeded with preceded.
2020-07-27 05:52:14 -07:00
Tom de Vries
95420d3027 [gdb/build] Fix typo sys/sockets.h -> sys/socket.h
I'm running into a build breaker:
...
src/gdb/ser-tcp.c:65:13: error: conflicting declaration ‘typedef int
socklen_t’
   65 | typedef int socklen_t;
      |             ^~~~~~~~~
In file included from ../gnulib/import/unistd.h:40,
                 from
/home/vries/gdb_versions/devel/src/gdb/../gnulib/import/pathmax.h:42,
                 from
/home/vries/gdb_versions/devel/src/gdb/../gdbsupport/common-defs.h:120,
                 from src/gdb/defs.h:28,
                 from src/gdb/ser-tcp.c:20:
/usr/include/unistd.h:277:21: note: previous declaration as ‘typedef
__socklen_t socklen_t’
  277 | typedef __socklen_t socklen_t;
      |                     ^~~~~~~~~
...
after commit 05a6b8c28b "Don't unnecessarily redefine 'socklen_t' type in
MinGW builds".

The root cause is a typo in gdb/configure.ac, using sys/sockets.h where
sys/socket.h was meant:
...
AC_CHECK_HEADERS([sys/sockets.h])
...

Fix the typo.

Build and tested on x86_64-linux.

gdb/ChangeLog:

2020-07-27  Tom de Vries  <tdevries@suse.de>

	* configure.ac: Fix sys/sockets.h -> sys/socket.h typo.
	* config.in: Regenerate.
	* configure: Regenerate.
2020-07-27 13:46:27 +02:00
GDB Administrator
9e3d7d43cf Automatic date update in version.in 2020-07-27 00:00:07 +00:00
Eli Zaretskii
555adca2e3 libctf: compilation failure on MinGW due to missing errno values
This commit fixes a compilation failure in a couple of libctf files
due to the use of EOVERFLOW and ENOTSUP, which are not defined
when compiling on MinGW.

libctf/ChangeLog:

	PR binutils/25155:
	* ctf-create.c (EOVERFLOW): If not defined by system header,
	redirect to ERANGE as a poor man's substitute.
	* ctf-subr.c (ENOTSUP): If not defined, use ENOSYS instead.

(cherry picked from commit 50500ecfef)
2020-07-26 16:11:36 -07:00
Eli Zaretskii
05a6b8c28b Don't unnecessarily redefine 'socklen_t' type in MinGW builds.
The original configure-time tests in gdb/ and gdbserver/ failed to
detect that 'socklen_t' is defined in MinGW headers because the test
program included only sys/socket.h, which is absent in MinGW system
headers.  However on MS-Windows this data type is declared in another
header, ws2tcpip.h.  The modified test programs try using ws2tcpip.h
if sys/socket.h is unavailable.

Thanks to Joel Brobecker who helped me regenerate the configure
scripts and the config.in files.

gdb/ChangeLog:
2020-07-26  Eli Zaretskii  <eliz@gnu.org>

	* configure.ac (AC_CHECK_HEADERS): Check for sys/socket.h and
	ws2tcpip.h.  When checking whether socklen_t type is defined, use
	ws2tcpip.h if it is available and sys/socket.h isn't.
	* configure: Regenerate.
	* config.in: Regenerate.

gdbserver/ChangeLog:
2020-07-26  Eli Zaretskii  <eliz@gnu.org>

	* configure.ac (AC_CHECK_HEADERS): Add ws2tcpip.h.
	When checking whether socklen_t type is defined, use ws2tcpip.h if
	it is available and sys/socket.h isn't.
	* configure: Regenerate.
	* config.in: Regenerate.
2020-07-26 19:35:48 +03:00
Maciej W. Rozycki
3abf975826 MIPS/binutils/testsuite: Correct mips.exp test ABI/emul/endian arrangement
The binutils testsuite supports involving LD in processing test cases
and with the MIPS target that has the same issues the LD testsuite does.

So to support LD in the MIPS part of the binutils testsuite similarly
to commit 86b24e15c4 ("MIPS/LD/testsuite: Correct comm-data.exp test
ABI/emul/endian arrangement") update the mips.exp test script to:

- correctly select emulations for targets using non-traditional MIPS
  emulations,

- correctly select ABIs for targets that do not support all of them,

- use the default endianness selection where possible to benefit targets
  that support only one,

- simplify test invocation by providing ABI-specific `run_dump_test'
  wrappers, specifically `run_dump_test_o32', `run_dump_test_n32' and
  `run_dump_test_n64', which remove the need to use conditionals across
  the Expect script or to repeat ABI-specific GAS and LD flags with each
  invocation,

borrowing changes from commit 78da84f994 ("MIPS/LD/testsuite: Correct
mips-elf.exp test ABI/emul/endian arrangement").

As a side effect this disables o32 ABI testing for targets that are not
supposed to support them and do not with LD, but still have such support
with BFD and GAS due to our inflexibility in configuration.  Ultimately
we ought to support having o32 completely disabled.

	binutils/
	* testsuite/binutils-all/mips/mips.exp (run_dump_test_abi)
	(run_dump_test_o32, run_dump_test_n32, run_dump_test_n64): New
	procedures.
	(has_newabi): Remove variable.
	(has_abi, abi_asflags, abi_ldflags): New associative array
	variables.
	(irixemul): New variable.
	Replace `run_dump_test' calls where applicable throughout with
	`run_dump_test_o32', `run_dump_test_n32' and `run_dump_test_n64'
	as appropriate.  Use `noarch' for tests that require their own
	architecture setting.
	* testsuite/binutils-all/mips/mips-ase-1.d: Remove GAS flags.
	* testsuite/binutils-all/mips/mips-ase-2.d: Likewise.
	* testsuite/binutils-all/mips/mips-ase-3.d: Likewise.
	* testsuite/binutils-all/mips/mips-note-2-n32.d: Likewise.
	* testsuite/binutils-all/mips/mips-note-2-n64.d: Likewise.
	* testsuite/binutils-all/mips/mips-note-2.d: Likewise.
	* testsuite/binutils-all/mips/mips-note-2r-n32.d: Likewise.
	* testsuite/binutils-all/mips/mips-note-2r-n64.d: Likewise.
	* testsuite/binutils-all/mips/mips-note-2r.d: Likewise.
	* testsuite/binutils-all/mips/mips-reginfo-n32.d: Likewise.
	* testsuite/binutils-all/mips/mips-reginfo.d: Likewise.
	* testsuite/binutils-all/mips/mips16-extend-noinsn.d: Likewise.
	* testsuite/binutils-all/mips/mips16-pcrel.d: Likewise.
	* testsuite/binutils-all/mips/mips16-alias.d: Remove `-32' from
	GAS flags.
	* testsuite/binutils-all/mips/mips16-extend-insn.d: Likewise.
	* testsuite/binutils-all/mips/mips16-noalias.d: Likewise.
	* testsuite/binutils-all/mips/mips16-undecoded.d: Likewise.
	* testsuite/binutils-all/mips/mips16e2-extend-insn.d: Likewise.
	* testsuite/binutils-all/mips/mips16e2-undecoded.d: Likewise.
	* testsuite/binutils-all/mips/mixed-micromips.d: Likewise.
	* testsuite/binutils-all/mips/mixed-mips16.d: Likewise.
2020-07-26 14:43:21 +01:00
GDB Administrator
a237ab1af0 Automatic date update in version.in 2020-07-26 00:00:06 +00:00
Andrew Burgess
e79eb02f2f gdb/fortran: resolve dynamic types when readjusting after an indirection
After dereferencing a pointer (in value_ind) or following a
reference (in coerce_ref) we call readjust_indirect_value_type to
"fixup" the type of the resulting value object.

This fixup handles cases relating to the type of the resulting object
being different (a sub-class) of the original pointers target type.

If we encounter a pointer to a dynamic type then after dereferencing a
pointer (in value_ind) the type of the object created will have had
its dynamic type resolved.  However, in readjust_indirect_value_type,
we use the target type of the original pointer to "fixup" the type of
the resulting value.  In this case, the target type will be a dynamic
type, so the resulting value object, once again has a dynamic type.

This then triggers an assertion later within GDB.

The solution I propose here is that we call resolve_dynamic_type on
the pointer's target type (within readjust_indirect_value_type) so
that the resulting value is not converted back to a dynamic type.

The test case is based on the original test in the bug report.

gdb/ChangeLog:

	PR fortran/23051
	PR fortran/26139
	* valops.c (value_ind): Pass address to
	readjust_indirect_value_type.
	* value.c (readjust_indirect_value_type): Make parameter
	non-const, and add extra address parameter.  Resolve original type
	before using it.
	* value.h (readjust_indirect_value_type): Update function
	signature and comment.

gdb/testsuite/ChangeLog:

	PR fortran/23051
	PR fortran/26139
	* gdb.fortran/class-allocatable-array.exp: New file.
	* gdb.fortran/class-allocatable-array.f90: New file.
	* gdb.fortran/pointer-to-pointer.exp: New file.
	* gdb.fortran/pointer-to-pointer.f90: New file.
2020-07-25 01:30:20 +01:00
GDB Administrator
719251fee1 Automatic date update in version.in 2020-07-25 00:00:06 +00:00
Tom de Vries
876518dd0a [gdb/symtab] Ignore zero line table entries
The DWARF standard states for the line register in the line number information
state machine the following:
...
An unsigned integer indicating a source line number.  Lines are numbered
beginning at 1.  The compiler may emit the value 0 in cases where an
instruction cannot be attributed to any source line.
...

So, it's possible to have a zero line number in the DWARF line table.

This is currently not handled by GDB.  The zero value is read in as any other
line number, but internally the zero value has a special meaning:
end-of-sequence, so the line table entry ends up having a different
interpretation than intended in some situations.

I've created a test-case where various aspects are tested, which has these 4
interesting tests.

1. Next-step through a zero-line instruction, is_stmt == 1
gdb.dwarf2/dw2-line-number-zero.exp: bar1, 2nd next

2. Next-step through a zero-line instruction, is_stmt == 0
gdb.dwarf2/dw2-line-number-zero.exp: bar2, 2nd next

3. Show source location at zero-line instruction, is_stmt == 1
gdb.dwarf2/dw2-line-number-zero.exp: continue to breakpoint: bar1_label_3

4. Show source location at zero-line instruction, is_stmt == 0
gdb.dwarf2/dw2-line-number-zero.exp: continue to breakpoint: bar2_label_3

And we have the following results:

8.3.1, 9.2:
...
FAIL: gdb.dwarf2/dw2-line-number-zero.exp: bar1, 2nd next
PASS: gdb.dwarf2/dw2-line-number-zero.exp: bar2, 2nd next
PASS: gdb.dwarf2/dw2-line-number-zero.exp: continue to breakpoint: bar1_label_3
FAIL: gdb.dwarf2/dw2-line-number-zero.exp: continue to breakpoint: bar2_label_3
...

commit 8c95582da8 "gdb: Add support for tracking the DWARF line table is-stmt
field":
...
PASS: gdb.dwarf2/dw2-line-number-zero.exp: bar1, 2nd next
PASS: gdb.dwarf2/dw2-line-number-zero.exp: bar2, 2nd next
FAIL: gdb.dwarf2/dw2-line-number-zero.exp: continue to breakpoint: bar1_label_3
FAIL: gdb.dwarf2/dw2-line-number-zero.exp: continue to breakpoint: bar2_label_3
...

commit d8cc8af6a1 "[gdb/symtab] Fix line-table end-of-sequence sorting",
master:
FAIL: gdb.dwarf2/dw2-line-number-zero.exp: bar1, 2nd next
FAIL: gdb.dwarf2/dw2-line-number-zero.exp: bar2, 2nd next
PASS: gdb.dwarf2/dw2-line-number-zero.exp: continue to breakpoint: bar1_label_3
PASS: gdb.dwarf2/dw2-line-number-zero.exp: continue to breakpoint: bar2_label_3
...

The regression in test 2 at commit d8cc8af6a1 was filed as PR symtab/26243,
where clang emits zero line numbers.

The way to fix all tests is to make sure line number zero internally doesn't
clash with special meaning values, and by handling it appropriately
everywhere.  That however looks too intrusive for the GDB 10 release.

Instead, we decide to ensure defined behaviour for line number zero by
ignoring it.  This gives us back the test results from before commit
d8cc8af6a1, fixing PR26243.

We mark the FAILs for tests 3 and 4 as KFAILs.  Test 4 was already failing for
the 9.2 release, and we consider the regression of test 3 from gdb 9.2 to gdb
10 the cost for having defined behaviour.

Build and reg-tested on x86_64-linux.

gdb/ChangeLog:

2020-07-25  Tom de Vries  <tdevries@suse.de>

	PR symtab/26243
	* dwarf2/read.c (lnp_state_machine::record_line): Ignore zero line
	entries.

gdb/testsuite/ChangeLog:

2020-07-25  Tom de Vries  <tdevries@suse.de>

	PR symtab/26243
	* gdb.dwarf2/dw2-line-number-zero.c: New test.
	* gdb.dwarf2/dw2-line-number-zero.exp: New file.
2020-07-25 00:23:06 +02:00
Aaron Merey
f6720b1cfe config/debuginfod.m4: Use PKG_CHECK_MODULES
Use PKG_CHECK_MODULES to set debuginfod autoconf vars. Also add
pkg.m4 to config/.

ChangeLog:

	* config/debuginfod.m4: use PKG_CHECK_MODULES.
	* config/pkg.m4: New file.
	* configure: Rebuild.
	* configure.ac: Remove AC_DEBUGINFOD.

ChangeLog/binutils:

	* Makefile.am: Replace LIBDEBUGINFOD with DEBUGINFOD_LIBS.
	* Makefile.in: Rebuild.
	* configure: Rebuild.
	* doc/Makefile.in: Rebuild.

ChangeLog/gdb:

	* Makefile.in: Replace LIBDEBUGINFOD with DEBUGINFOD_LIBS.
	* configure: Rebuild.
2020-07-24 15:16:20 -04:00
Tom de Vries
6dcfb80a28 [gdb/testsuite] Require gnatmake-8 for gdb.ada/mi_prot.exp
With gcc-7, I run into:
...
gcc -c -I./ -gnata -Isrc/gdb/testsuite/gdb.ada/mi_prot -g -lm -I- \
  src/gdb/testsuite/gdb.ada/mi_prot/prot.adb^M
prot.adb:21:04: info: "Obj_Type" is frozen here, aspects evaluated at this \
  point^M
prot.adb:23:09: visibility of aspect for "Obj_Type" changes after freeze \
  point^M
gnatmake: "src/gdb/testsuite/gdb.ada/mi_prot/prot.adb" compilation error^M
compiler exited with status 1
  ...
FAIL: gdb.ada/mi_prot.exp: compilation prot.adb
...

Fix this by requiring gnatmake-8 for this test-case.

Tested on x86_64-linux, with gnatmake-7, gnatmake-8 and gnatmake-11.

gdb/testsuite/ChangeLog:

2020-07-24  Tom de Vries  <tdevries@suse.de>

	PR testsuite/26293
	* gdb.ada/mi_prot.exp: Require gnatmake-8.
2020-07-24 14:10:50 +02:00
Nick Clifton
bf772a1ecd Update documentation on how to make a release 2020-07-24 12:07:41 +01:00
Nick Clifton
04f096fb9e Move the xc16x target to the obsolete list 2020-07-24 12:01:48 +01:00
Nick Clifton
2dddfa201b Updated German translation for the opcodes sub-directory 2020-07-24 10:14:22 +01:00
GDB Administrator
4b495c31c1 Automatic date update in version.in 2020-07-24 00:00:07 +00:00
Kevin Buettner
513487e1a8 Fix BZ 26294 - Add period to help text for maint print core-file-backed-mappings
gdb/ChangeLog:

	PR corefiles/26294
	* corelow.c (_initialize_corelow): Add period to help text
	for "maintenance print core-file-backed-mappings".
2020-07-23 13:41:36 -07:00
Maciej W. Rozycki
97c79e2174 PR ld/26288: Allow the use of `--just-symbols' with ET_EXEC input
Fix a regression from commit a87e1817a4 ("Have the linker fail if any
attempt to link in an executable is made.") and do not reject ET_EXEC
input supplied with the `--just-symbols' option.  Such use is legitimate
as the file requested is not actually linked and only the symbols are
extracted. Furthermore it is often the most useful application, as
already observed in our documentation for the option, where it allows
"to refer symbolically to absolute locations of memory defined in other
programs."

Provide a set of tests for the use of ET_EXEC with `--just-symbols'.
These are excluded however for SH/PE targets because they complain if a
section's VMA is 0:

ld: zero vma section reloc detected: `.text' #0 f=32795
ld: zero vma section reloc detected: `.data' #1 f=291

and for x86_64/PE targets because they seem to hardwire the VMA:

 100000000 12000000 01000000 00000000 00000000  ................

	ld/
	PR ld/26288
	* ldelf.c (ldelf_after_open): Do not reject ET_EXEC input
	supplied with `--just-symbols'.
	* testsuite/ld-misc/just-symbols.exp: New test script.
	* testsuite/ld-misc/just-symbols-1.dd: New test dump.
	* testsuite/ld-misc/just-symbols.ld: New test linker script.
	* testsuite/ld-misc/just-symbols-0.s: New test source.
	* testsuite/ld-misc/just-symbols-1.s: New test source.
2020-07-23 20:11:29 +01:00
Maciej W. Rozycki
b5dd7120f6 PR ld/26288: Revert obsolete part of PR ld/26047 fix
Revert commit a3fc941881 ("Stop the linker from accepting executable
ELF files as inputs to other links."), which has been made obsolete by
commit a87e1817a4 ("Have the linker fail if any attempt to link in an
executable is made.").  An earlier check triggers added with the latter
commit making the piece of code removed dead.

	ld/
	PR ld/26288

	Revert:
	PR 26047
	* ldelf.c (ldelf_after_open): Fail if attempting to link one
	executable into another.
2020-07-23 20:11:29 +01:00
Pedro Alves
e7bc9db8f4 Don't touch frame_info objects if frame cache was reinitialized
This fixes yet another bug exposed by ASAN + multi-target.exp

Running an Asan-enabled GDB against gdb.multi/multi-target.exp exposed
yet another latent GDB bug.  See here for the full log:

  https://sourceware.org/pipermail/gdb-patches/2020-July/170761.html

As Simon described, the problem is:

 - We create a new frame_info object in restore_selected_frame (by
   calling find_relative_frame)

 - The frame is allocated on the frame_cache_obstack

 - In frame_unwind_try_unwinder, we try to find an unwinder for that
   frame

 - While trying unwinders, memory read fails because the remote target
   closes, because of "monitor exit"

 - That calls reinit_frame_cache (as shown above), which resets
   frame_cache_obstack

 - When handling the exception in frame_unwind_try_unwinder, we try to
   set some things on the frame_info object (like *this_cache, which
   in fact tries to write into frame_info::prologue_cache), but the
   frame_info object is no more, it went away with the obstack.

Fix this by maintaining a frame cache generation counter.  Then in
exception handling code paths, don't touch frame objects if the
generation is not the same as it was on entry.

This commit generalizes the gdb.server/server-kill.exp testcase and
reuses it to test the scenario in question.  The new tests fail
without the GDB fix.

gdb/ChangeLog:

	* frame-unwind.c (frame_unwind_try_unwinder): On exception, don't
	touch THIS_CACHE/THIS_FRAME if the frame cache was cleared
	meanwhile.
	* frame.c (frame_cache_generation, get_frame_cache_generation):
	New.
	(reinit_frame_cache): Increment FRAME_CACHE_GENERATION.
	(get_prev_frame_if_no_cycle): On exception, don't touch
	PREV_FRAME/THIS_FRAME if the frame cache was cleared meanwhile.
	* frame.h (get_frame_cache_generation): Declare.

gdb/testsuite/ChangeLog:

	* gdb.server/server-kill.exp (prepare): New, factored out from the
	top level.
	(kill_server): New.
	(test_tstatus, test_unwind_nosyms, test_unwind_syms): New.
	(top level) : Call test_tstatus, test_unwind_nosyms, test_unwind_syms.
2020-07-23 16:29:28 +01:00
Tom de Vries
90fcc46681 [gdb/tui] Fix Wmaybe-uninitialized warning in tui-winsource.c
When compiling with CFLAGS/CXXFLAGS="-O0 -g -Wall" and using g++ 11.0.0, we
run into:
...
src/gdb/tui/tui-winsource.c: In function \
  'void tui_update_all_breakpoint_info(breakpoint*)':
src/gdb/tui/tui-winsource.c:427:58: warning: '<unknown>' may be used \
  uninitialized [-Wmaybe-uninitialized]
  427 |   for (tui_source_window_base *win : tui_source_windows ())
      |                                                          ^
In file included from src/gdb/tui/tui-winsource.c:38:
src/gdb/tui/tui-winsource.h:236:30: note: by argument 1 of type \
  'const tui_source_windows*' to 'tui_source_window_iterator \
  tui_source_windows::begin() const' declared here
  236 |   tui_source_window_iterator begin () const
      |                              ^~~~~
src/gdb/tui/tui-winsource.c:427:58: note: '<anonymous>' declared here
  427 |   for (tui_source_window_base *win : tui_source_windows ())
      |                                                          ^
...

The warning doesn't make sense for an empty struct, PR gcc/96295 has been
filed about that.

For now, work around the warning by defining a default constructor.

Build on x86_64-linux.

gdb/ChangeLog:

2020-07-23  Tom de Vries  <tdevries@suse.de>

	PR tui/26282
	* tui/tui-winsource.h (struct tui_source_windows::tui_source_windows):
	New default constructor.
2020-07-23 13:45:46 +02:00
Andrew Burgess
78344df7b5 gdb/disassembly: Update to handle non-statement addresses
After the introduction of support for non-statement addresses in the
line table, the output for 'disassemble /m' can be broken in some
cases.

With the /m format disassembly GDB associates a set of addresses with
each line, these addresses are then sorted and printed for each line.

When the non-statement support was added GDB was incorrectly told to
ignore non-statement instructions, and not add these to the result
table.  This means that these instructions are completely missing from
the output.

This commit removes the code that caused non-statement lines to be
ignored.

A result of this change is that GDB will now potentially include new
line numbers in the 'disassemble /m' output, lines that previously
were only in the line table as non-statement lines will now appear in
the disassembly output.  This feels like an improvement though.

gdb/ChangeLog:

	* disasm.c (do_mixed_source_and_assembly_deprecated): Don't
	exclude non-statement entries.

gdb/testsuite/ChangeLog:

	* gdb.dwarf2/dw2-disasm-over-non-stmt.exp: New file.
2020-07-23 11:16:50 +01:00
Sandra Loosemore
25dfed247b Fix more bugs in gdb testglue wrapper handling
In commit 24ac169ac5, this patch:

	2020-02-21  Shahab Vahedi  <shahab@synopsys.com>

	* lib/gdb.exp (gdb_wrapper_init): Reset
	"gdb_wrapper_initialized" to 0 if "wrapper_file" does
	not exist.

attempted to fix problems finding the gdb test wrapper gdb_tg.o in
some tests that cd to some non-default directory by rebuilding also
the test wrapper in that directory.  This had the side-effect of
leaving these .o files in various places in the GDB source directory
tree.

Furthermore, while the tests that cd to some non-default directory
cannot run on remote host, the code that was added to probe for the
presence of the wrapper file was also specific to host == build.

This patch reverts the problematic parts of that commit and replaces
it with forcing use of an absolute (rather than relative) pathname to
the .o file for linking when host == build.

While debugging this patch, I also observed that use of the construct
"[info exists gdb_wrapper_file]" was not reliable for detecting when
that variable had been initialized by gdb_wrapper_init.  I rewrote
that so that the variable is always initialized and has a value of an
empty string when no wrapper file is needed.

2020-07-22  Sandra Loosemore  <sandra@codesourcery.com>

	gdb/testsuite/
	* lib/gdb.exp (gdb_wrapper_file, gdb_wrapper_flags):
	Initialize to empty string at top level.
	(gdb_wrapper_init): Revert check for file existence on build.
	Build the wrapper in its default place, not a build-specific
	location.  When host == build, make the pathname absolute.
	(gdb_compile): Delete leftover declaration of
	gdb_wrapper_initialized.  Check gdb_wrapper_file being an empty
	string instead of uninitialized.
2020-07-22 20:42:20 -07:00
GDB Administrator
25322a133a Automatic date update in version.in 2020-07-23 00:00:08 +00:00
Kevin Buettner
7da515fd76 New core file tests with mappings over existing program memory
This test case was inspired by Pedro's demonstration of a problem
with my v2 patches.  It can be found here:

    https://sourceware.org/pipermail/gdb-patches/2020-May/168826.html

In a nutshell, my earlier patches could not handle the case in
which a read-only mapping created with mmap() was created at
an address used by other file-backed read-only memory in use by
the process.

This problem has been fixed (for Linux, anyway) by the commit "Use
NT_FILE note section for reading core target memory".

When I run this test without any of my recent corefile patches,
I see these failures:

FAIL: gdb.base/corefile2.exp: kernel core: print/x mbuf_ro[0]@4
FAIL: gdb.base/corefile2.exp: kernel core: print/x mbuf_ro[pagesize-4]@4
FAIL: gdb.base/corefile2.exp: kernel core: print/x mbuf_ro[-3]@6
FAIL: gdb.base/corefile2.exp: kernel core: print/x mbuf_rw[pagesize-3]@6
FAIL: gdb.base/corefile2.exp: kernel core: print/x mbuf_ro[pagesize-3]@6
FAIL: gdb.base/corefile2.exp: maint print core-file-backed-mappings
FAIL: gdb.base/corefile2.exp: gcore core: print/x mbuf_ro[-3]@6

The ones involving mbuf_ro will almost certainly fail when run on
non-Linux systems; I've used setup_xfail on those tests to prevent
them from outright FAILing when not run on Linux.  For a time, I
had considered skipping these tests altogether when not run on
Linux, but I changed my mind due to this failure...

FAIL: gdb.base/corefile2.exp: print/x mbuf_rw[pagesize-3]@6

I think it *should* pass without my recent corefile patches.  The fact
that it doesn't is likely due to a bug in GDB.  The following
interaction with GDB demonstrates the problem:

(gdb) print/x mbuf_rw[pagesize-3]@6
$1 = {0x0, 0x0, 0x0, 0x0, 0x0, 0x0}
(gdb) print/x mbuf_rw[pagesize]@3
$2 = {0x6b, 0x6b, 0x6b}

The last three values in display of $1 should be the same as those
shown by $2.  Like this...

(gdb) print/x mbuf_rw[pagesize-3]@6
$1 = {0x0, 0x0, 0x0, 0x6b, 0x6b, 0x6b}
(gdb) print/x mbuf_rw[pagesize]@3
$2 = {0x6b, 0x6b, 0x6b}

That latter output was obtained with the use of all of my current
corefile patches.  I see no failures on Linux when running this test
with my current set of corefile patches.  I tested 3 architectures:
x86_64, s390x, and aarch64.

I also tested on FreeBSD 12.1-RELEASE.  I see the following results
both with and without the current set of core file patches:

    # of expected passes		26
    # of expected failures		8

Of particular interest is that I did *not* see the problematic mbuf_rw
failure noted earlier (both with and without the core file patches).
I still don't have an explanation for why this failure occurred on
Linux.  Prior to running the tests, I had hypothesized that I'd see
this failure on FreeBSD too, but testing shows that this is not the
case.

Also of importance is that we see no FAILs with this test on FreeBSD
which indicates that I XFAILed the correct tests.

This version runs the interesting tests twice, once with a kernel
created core file and another time with a gcore created core file.

It also does a very minimal test of the new command "maint print
core-file-backed-mappings".

gdb/testsuite/ChangeLog:

	* gdb.base/corefile2.exp: New file.
	* gdb.base/coremaker2.exp: New file.
2020-07-22 12:53:37 -07:00
Kevin Buettner
b089853a22 Add documentation for "maint print core-file-backed-mappings"
gdb/ChangeLog:

	* NEWS (New commands): Mention new command
	"maintenance print core-file-backed-mappings".

gdb/doc/ChangeLog:

	* gdb.texinfo (Maintenance Commands): Add documentation for
	new command "maintenance print core-file-backed-mappings".
2020-07-22 12:52:31 -07:00
Kevin Buettner
09c2f5d45c Add new command "maint print core-file-backed-mappings"
I wrote a read_core_file_mappings method for FreeBSD and then registered
this gdbarch method.  I saw some strange behavior while testing it and
wanted a way to make sure that mappings were being correctly loaded
into corelow.c, so I wrote the new command which is the topic of this
commit.  I think it might be occasionally useful for debugging strange
corefile behavior.

With regard to FreeBSD, my work isn't ready yet.  Unlike Linux,
FreeBSD puts all mappings into its core file note.  And, unlike Linux,
it doesn't dump load segments which occupy no space in the file.  So
my (perhaps naive) implementation of a FreeBSD read_core_file_mappings
didn't work all that well:  I saw more failures in the corefile2.exp
tests than without it.  I think it should be possible to make FreeBSD
work as well as Linux, but it will require doing something with all of
the mappings, not just the file based mappings that I was considering.

In the v4 series, Pedro asked the following:

    I don't understand what this command provides that "info proc
    mappings" doesn't?  Can you give an example of when you'd use this
    command over "info proc mappings" ?

On Linux, "info proc mappings" and "maint print core-file-backed-mappings"
will produce similar, possibly identical, output.  This need not be
the case for other OSes.  E.g. on FreeBSD, had I finished the
implementation, the output from these commands would have been very
different.  The FreeBSD "info proc mappings" command would show
additional (non-file-backed) mappings in addition to at least one
additional field (memory permissions) for each mapping.

As noted earlier, I was seeing some unexpected behavior while working
on the FreeBSD implementation and wanted to be certain that the
mappings were being correctly loaded by corelow.c.  "info proc
mappings" prints the core file mappings, but doesn't tell us anything
about whether they've been loaded by corelow.c This new maintenance
command directly interrogates the data structures and prints the
values found there.

gdb/ChangeLog:

	* corelow.c (gdbcmd.h): Include.
	(core_target::info_proc_mappings): New method.
	(get_current_core_target): New function.
	(maintenance_print_core_file_backed_mappings): New function.
	(_initialize_corelow): Add core-file-backed-mappings to
	"maint print" commands.
2020-07-22 12:50:30 -07:00
Kevin Buettner
9c5ec5c2da Adjust coredump-filter.exp to account for NT_FILE note handling
This commit makes adjustments to coredump-filter.exp to account
for the fact that NT_FILE file-backed mappings are now available
when a core file is loaded.  Thus, a test which was expected
to PASS when a memory region was determined to be unavailable
(due to no file-backed mappings being available) will now FAIL
due to those mappings being available from having loaded the
NT_FILE note.

I had originally marked the test as XFAIL, but Mihails Strasuns
suggested a much better approach:

    1) First test that it still works if file is accessible in the
       filesystem.
    2) Temporarily move / rename the file and test that disassembly
       doesn't work anymore.

That's what this commit implements.

gdb/testsuite/ChangeLog:

	* gdb.base/coredump-filter.exp: Add second
	non-Private-Shared-Anon-File test.
	(test_disasm): Rename binfile for test which is expected
	to fail.
2020-07-22 12:49:18 -07:00
Kevin Buettner
4ba11f89a2 gcore command: Place all file-backed mappings in NT_FILE note
When making a core file with the GDB's gcore command on Linux,
the same criteria used for determining which mappings should be
dumped were also being used for determining which entries should
be placed in the NT_FILE note.  This is wrong; we want to place
all file-backed mappings in this note.

The predicate function, dump_mapping_p, was used to determine whether
or not to dump a mapping from within linux_find_memory_regions_full.
This commit leaves this predicate in place, but adds a new parameter,
should_dump_mapping_p, to linux_find_memory_regions_full.  It then
calls should_dump_mapping_p instead of dump_mapping_p.  dump_mapping_p
is passed to linux_find_memory_regions_full at one call site; at the
other call site, dump_note_entry_p is passed instead.

gdb/ChangeLog:

	* linux-tdep.c (dump_note_entry_p): New function.
	(linux_dump_mapping_p_ftype): New typedef.
	(linux_find_memory_regions_full): Add new parameter,
	should_dump_mapping_p.
	(linux_find_memory_regions): Adjust call to
	linux_find_memory_regions_full.
	(linux_make_mappings_core_file_notes): Use dump_note_entry_p in
	call to linux_find_memory_regions_full.
2020-07-22 12:47:50 -07:00
Kevin Buettner
f9e233c9c4 Add test for accessing read-only mmapped data in a core file
This test passes when run using a GDB with my corefile patches.  When
run against a GDB without my patches, I see the following failures,
the first of which is due to the test added by this commit:

FAIL: gdb.base/corefile.exp: accessing read-only mmapped data in core file (mapping address not found in core file)
FAIL: gdb.base/corefile.exp: accessing anonymous, unwritten-to mmap data

gdb/testsuite/ChangeLog:

	* gdb.base/corefile.exp: Add test "accessing read-only mmapped
	data in core file".
	* gdb.base/coremaker.c (buf2ro): New global.
	(mmapdata): Add a read-only mmap mapping.
2020-07-22 12:47:30 -07:00
Kevin Buettner
db082f5979 Use NT_FILE note section for reading core target memory
In his reviews of my v1 and v2 corefile related patches, Pedro
identified two cases which weren't handled by those patches.

In https://sourceware.org/pipermail/gdb-patches/2020-May/168826.html,
Pedro showed that debugging a core file in which mmap() is used to
create a new mapping over an existing file-backed mapping will
produce incorrect results.  I.e, for his example, GDB would
show:

(gdb) disassemble main
Dump of assembler code for function main:
   0x00000000004004e6 <+0>:	push   %rbp
   0x00000000004004e7 <+1>:	mov    %rsp,%rbp
=> 0x00000000004004ea <+4>:	callq  0x4003f0 <abort@plt>
End of assembler dump.

This sort of looks like it might be correct, but is not due to the
fact that mmap(...MAP_FIXED...) was used to create a mapping (of all
zeros) on top of the .text section.  So, the correct result should be:

(gdb) disassemble main
Dump of assembler code for function main:
   0x00000000004004e6 <+0>:	add    %al,(%rax)
   0x00000000004004e8 <+2>:	add    %al,(%rax)
=> 0x00000000004004ea <+4>:	add    %al,(%rax)
   0x00000000004004ec <+6>:	add    %al,(%rax)
   0x00000000004004ee <+8>:	add    %al,(%rax)
End of assembler dump.

The other case that Pedro found involved an attempted examination of a
particular section in the test case from gdb.base/corefile.exp.  On
Fedora 27 or 28, the following behavior may be observed:

(gdb) info proc mappings
Mapped address spaces:

          Start Addr           End Addr       Size     Offset objfile
...
      0x7ffff7839000     0x7ffff7a38000   0x1ff000   0x1b5000 /usr/lib64/libc-2.27.so
...
(gdb) x/4x 0x7ffff7839000
0x7ffff7839000:	Cannot access memory at address 0x7ffff7839000

FYI, this section appears to be unrelocated vtable data.  See
https://sourceware.org/pipermail/gdb-patches/2020-May/168331.html for
a detailed analysis.

The important thing here is that GDB should be able to access this
address since it should be backed by the shared library.  I.e. it
should do this:

(gdb) x/4x 0x7ffff7839000
0x7ffff7839000:	0x0007ddf0	0x00000000	0x0007dba0	0x00000000

Both of these cases are fixed with this commit.

In a nutshell, this commit opens a "binary" target BFD for each of the
files that are mentioned in an NT_FILE / .note.linuxcore.file note
section.  It then uses these mappings instead of the file stratum
mappings that GDB has used in the past.

If this note section doesn't exist or is mangled for some reason, then
GDB will use the file stratum as before.  Should this happen, then
we can expect both of the above problems to again be present.

See the code comments in the commit for other details.

gdb/ChangeLog:

	* corelow.c (solist.h, unordered_map): Include.
	(class core_target): Add field m_core_file_mappings and
	method build_file_mappings.
	(core_target::core_target): Call build_file_mappings.
	(core_target::~core_target): Free memory associated with
	m_core_file_mappings.
	(core_target::build_file_mappings): New method.
	(core_target::xfer_partial): Use m_core_file_mappings
	for memory transfers.
	* linux-tdep.c (linux_read_core_file_mappings): New
	function.
	(linux_core_info_proc_mappings): Rewrite to use
	linux_read_core_file_mappings.
	(linux_init_abi): Register linux_read_core_file_mappings.
2020-07-22 12:45:29 -07:00
Kevin Buettner
7e183d2736 Add new gdbarch method, read_core_file_mappings
The new gdbarch method, read_core_file_mappings, will be used for
reading file-backed mappings from a core file.  It'll be used
for two purposes: 1) to construct a table of file-backed mappings
in corelow.c, and 2) for display of core file mappings.

For Linux, I tried a different approach in which knowledge of the note
format was placed directly in corelow.c.  This seemed okay at first;
it was only one note format and the note format was fairly simple.
After looking at FreeBSD's note/mapping reading code, I concluded
that it's best to leave architecture specific details for decoding
the note in (architecture specific) tdep files.

With regard to display of core file mappings, I experimented with
placing the mappings display code in corelow.c.  It has access to the
file-backed mappings which were read in when the core file was loaded.
And, better, still common code could be used for all architectures.
But, again, the FreeBSD mapping code convinced me that this was not
the best approach since it has even more mapping info than Linux.
Display code which would work well for Linux will leave out mappings
as well as protection info for mappings.

So, for these reasons, I'm introducing a new gdbarch method for
reading core file mappings.

gdb/ChangeLog:

	* arch-utils.c (default_read_core_file_mappings): New function.
	* arch-utils.c (default_read_core_file_mappings): Declare.
	* gdbarch.sh (read_core_file_mappings): New gdbarch method.
	* gdbarch.h, gdbarch.c: Regenerate.
2020-07-22 12:44:13 -07:00
Kevin Buettner
5efb677960 Update binary_get_section_contents to seek using section's file position
I have a patch for GDB which opens and reads from BFDs using the
"binary" target.  However, for it to work, we need to be able to get a
section's contents based from the file position of that section.

At the moment, reading a section's contents will always read from the
start of the file regardless of where that section is located.  While
this was fine for the original use of the "binary" target, it won't
work for my use case.  This change shouldn't impact any existing
callers due to the fact that the single .data section is initialized
with a filepos of 0.

bfd/ChangeLog:

	* binary.c (binary_get_section_contents): Seek using offset
	from section's file position.
2020-07-22 12:42:31 -07:00