Commit Graph

108850 Commits

Author SHA1 Message Date
Tom Tromey
b583c328e7 Add a way to temporarily set a gdb parameter from Python
It's sometimes useful to temporarily set some gdb parameter from
Python.  Now that the 'endian' crash is fixed, and now that the
current language is no longer captured by the Python layer, it seems
reasonable to add a helper function for this situation.

This adds a new gdb.with_parameter function.  This creates a context
manager which temporarily sets some parameter to a specified value.
The old value is restored when the context is exited.  This is most
useful with the Python "with" statement:

   with gdb.with_parameter('language', 'ada'):
      ... do Ada stuff

This also adds a simple function to set a parameter,
gdb.set_parameter, as suggested by Andrew.

This is PR python/10790.

Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=10790
2022-01-26 06:49:51 -07:00
Tom Tromey
dedb7102b3 Fix another crash with gdb parameters in Python
While looking into the language-capturing issue, I found another way
to crash gdb using parameters from Python:

(gdb) python print(gdb.parameter('endian'))

(This is related to PR python/12188, though this patch isn't going to
fix what that bug is really about.)

The problem here is that the global variable that underlies the
"endian" parameter is initialized to NULL.  However, that's not a
valid value for an "enum" set/show parameter.

My understanding is that, in gdb, an "enum" parameter's underlying
variable must have a value that is "==" (not just strcmp-equal) to one
of the values coming from the enum array.  This invariant is relied on
in various places.

I started this patch by fixing the problem with "endian".  Then I
added some assertions to add_setshow_enum_cmd to try to catch other
problems of the same type.

This patch fixes all the problems that I found.  I also looked at all
the calls to add_setshow_enum_cmd to ensure that they were all
included in the gdb I tested.  I think they are: there are no calls in
nat-* files, or in remote-sim.c; and I was trying a build with all
targets, Python, and Guile enabled.

Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=12188
2022-01-26 06:49:51 -07:00
Tom Tromey
1da5d0e664 Change how Python architecture and language are handled
Currently, gdb's Python layer captures the current architecture and
language when "entering" Python code.  This has some undesirable
effects, and so this series changes how this is handled.

First, there is code like this:

  gdbpy_enter enter_py (python_gdbarch, python_language);

This is incorrect, because both of these are NULL when not otherwise
assigned.  This can cause crashes in some cases -- I've added one to
the test suite.  (Note that this crasher is just an example, other
ones along the same lines are possible.)

Second, when the language is captured in this way, it means that
Python code cannot affect the current language for its own purposes.
It's reasonable to want to write code like this:

    gdb.execute('set language mumble')
    ... stuff using the current language
    gdb.execute('set language previous-value')

However, this won't actually work, because the language is captured on
entry.  I've added a test to show this as well.

This patch changes gdb to try to avoid capturing the current values.
The Python concept of the current gdbarch is only set in those few
cases where a non-default value is computed or needed; and the
language is not captured at all -- instead, in the cases where it's
required, the current language is temporarily changed.
2022-01-26 06:49:51 -07:00
H.J. Lu
8a782bbf70 bfd: Make bfd.stamp depend on source bfd.texi
Make bfd.stamp depend on source bfd.texi to avoid regenerating
doc/bfd.info for each make run.

	PR binutils/28807
	* Makefile.in: Regenerate.
	* doc/local.mk (%D%/bfd.stamp): Depend on $(srcdir)/%D%/bfd.texi.
2022-01-26 05:30:50 -08:00
H.J. Lu
c804c6f98d ld: Rewrite lang_size_relro_segment_1
1. Compute the desired PT_GNU_RELRO segment base and find the maximum
section alignment of sections starting from the PT_GNU_RELRO segment.
2. Find the first preceding load section.
3. Don't add the 1-page gap between the first preceding load section and
the relro segment if the maximum page size >= the maximum section
alignment.  Align the PT_GNU_RELRO segment first.  Subtract the maximum
page size if therer is still a 1-page gap.

	PR ld/28743
	PR ld/28819
	* ldlang.c (lang_size_relro_segment_1): Rewrite.
	* testsuite/ld-x86-64/pr28743-1.d: New file.
	* testsuite/ld-x86-64/pr28743-1.s: Likewise.
	* testsuite/ld-x86-64/x86-64.exp: Run pr28743-1.
2022-01-26 05:27:56 -08:00
Lancelot SIX
8357282156 gdb/testsuite: Ensure constant test name in gdb.base/break-interp.exp
When running the testsuite, I have lines similar to the following in the
gdb.sum file:

~~~
PASS: gdb.base/break-interp.exp: ldprelink=NO: ldsepdebug=NO: first backtrace: p /x 0x7f283d2f0fd1
...
PASS: gdb.base/break-interp.exp: ldprelink=NO: ldsepdebug=NO: binprelink=NO: binsepdebug=NO: binpie=NO: INNER: first backtrace: p /x 0x7f00de0317a5
...
~~~

The address part of the command might change between execution of the
test, which adds noise to a diff between two .sum files.

This patch changes to test name to "p /x $pc" in order to have constant
test name.

Tested on x86_64-Linux.

Change-Id: I973c1237a084dd6d424276443cbf0920533c9a21
2022-01-26 04:38:33 -05:00
GDB Administrator
a80032197f Automatic date update in version.in 2022-01-26 00:00:19 +00:00
Tom Tromey
a8e9f25759 Always print the "host libthread-db" message to stdout
linux-thread-db.c has a bit of unusual code that unconditionally
prints a message, but decides whether to print to gdb_stdout or
gdb_stdlog based on a debug flag.  It seems better to me to simply
always print this; and this is the only spot in gdb where we
conditionally pass gdb_stdout to one of the f*_unfiltered functions.
2022-01-25 15:22:49 -07:00
Tom Tromey
d4396e0e97 Reduce explicit use of gdb_stdout
In an earlier version of the pager rewrite series, it was important to
audit unfiltered output calls to see which were truly necessary.

This is no longer necessary, but it still seems like a decent cleanup
to change calls to avoid explicitly passing gdb_stdout.  That is,
rather than using something like fprintf_unfiltered with gdb_stdout,
the code ought to use plain printf_unfiltered instead.

This patch makes this change.  I went ahead and converted all the
_filtered calls I could find, as well, for the same clarity.
2022-01-25 15:22:49 -07:00
Tom Tromey
244ac24b51 Sent timing stats to gdb_stdlog
This changes the time / space / symtab per-command statistics code to
send its output to gdb_stdlog rather than gdb_stdout.  This seems
slightly more correct to me.
2022-01-25 15:22:49 -07:00
Tom Tromey
1475b18b77 Send some error output to gdb_stderr
This changes some code to send some error messages to gdb_stderr
rather than gdb_stdout.
2022-01-25 15:22:49 -07:00
Klaus Ziegler
b6437be687 Fix a probem building the binutils on SPARC/amd64
PR 28816
	* elf/common.h (AT_SUN_HWCAP): Make definition conditional.
2022-01-25 17:33:03 +00:00
H.J. Lu
042a82e5ee bfd: Regenerate Makefile.in
* Makefile.in: Regenerate.
2022-01-25 08:54:36 -08:00
Mike Frysinger
7d9d9c1078 gold: drop old cygnus install hack
The gold subdir doesn't actually have a manual, so this hack doesn't
do anything.  Plus the automake cygnus option was removed years ago
by Simon in d0ac1c4488 ("Bump to autoconf 2.69 and
automake 1.15.1").  So delete it here.
2022-01-24 19:58:33 -05:00
Mike Frysinger
9a84a44d5d gas: drop old cygnus install hack
This was needed when gas was using the automake cygnus option, but
this was removed years ago by Simon in d0ac1c4488
("Bump to autoconf 2.69 and automake 1.15.1").  So delete it here.
The info pages are already & still installed by default w/out it.
2022-01-24 19:58:33 -05:00
GDB Administrator
823f6c5f05 Automatic date update in version.in 2022-01-25 00:00:17 +00:00
H.J. Lu
94fd627d46 bfd: Update doc/local.mk
PR binutils/28807
	* Makefile.in: Regenerate.
	* doc/local.mk (AM_MAKEINFOFLAGS): Add -I "$(srcdir)/%D%" -I %D%.
	(TEXI2DVI): New.
	(%D%/bfd.texi): Removed.
	(doc/bfd/index.html): Remove -I$(srcdir).  Replace bfd.texi with
	%D%/bfd.texi.
2022-01-24 12:56:48 -08:00
Roland McGrath
fdf55097a3 bfd/doc: Fix racy build failure from missing mkdir
bfd/
	* doc/local.mk (%D%/bfdver.texi): Add mkdir command.
2022-01-24 12:38:50 -08:00
Martin Sebor
2f279a64a2 Fix a proble building the libiberty library with gcc-12.
PR 28779
	* regex.c: Suppress -Wuse-after-free.
2022-01-24 17:56:23 +00:00
Andrew Burgess
965c919f98 gdb/doc: improve description for Window.click on Python TUI windows
The description of the Window.click method doesn't mention where the
coordinates are anchored (it's the top left corner).

This minor tweak just mentions this point.
2022-01-24 15:33:55 +00:00
Nick Clifton
5fe73d4624 Update Bulgarian, French, Romaniam and Ukranian translation for some of the sub-directories 2022-01-24 14:22:49 +00:00
GDB Administrator
2b1ca85cf8 Automatic date update in version.in 2022-01-24 00:00:15 +00:00
Tom Tromey
f10522c0e7 Simplify some Rust expression-evaluation code
A few Rust operations do a bit of work in their 'evaluate' functions
and then call another function -- but are also the only caller.  This
patch simplifies this code by removing the extra layer.

Tested on x86-64 Fedora 34.  I'm checking this in.
2022-01-23 12:52:44 -07:00
H.J. Lu
451c003d5f bfd: Partially revert commit 0e3839bde6
Partially revert

commit 0e3839bde6
Author: H.J. Lu <hjl.tools@gmail.com>
Date:   Sun Jan 23 07:29:27 2022 -0800

    bfd: Properly install library and header files

	PR binutils/28807
	* Makefile.am: Revert bfdlib_LTLIBRARIES and bfdinclude_HEADERS
	changes.
	* Makefile.in: Regenerate.
2022-01-23 10:40:46 -08:00
H.J. Lu
0e3839bde6 bfd: Properly install library and header files
Rename bfdlib_LTLIBRARIES and bfdinclude_HEADERS to lib_LTLIBRARIES and
include_HEADERS to fix the missing installed library and header files in
bfd caused by

commit bd32be01c9
Author: Mike Frysinger <vapier@gentoo.org>
Date:   Fri Dec 3 00:23:20 2021 -0500

    bfd: merge doc subdir up a level

	PR binutils/28807
	* Makefile.am (bfdlib_LTLIBRARIES): Renamed to ...
	(lib_LTLIBRARIES): This.
	(bfdinclude_HEADERS): Renamed to ...
	(include_HEADERS): This.
	* Makefile.in: Regenerate.
	* doc/local.mk (install): Removed.
2022-01-23 07:29:27 -08:00
H.J. Lu
ad69b6b861 Regenerate Makefile.in files with automake 1.15.1
Regenerate Makefile.in files with the unmodified automake 1.15.1 to
remove

runstatedir = @runstatedir@

bfd/

	* Makefile.in: Regenerate.

binutils/

	* Makefile.in: Regenerate.

gas/

	* Makefile.in: Regenerate.

gold/

	* Makefile.in: Regenerate.
	* testsuite/Makefile.in: Likewise.

gprof/

	* Makefile.in: Regenerate.

ld/

	* Makefile.in: Regenerate.

opcodes/

	* Makefile.in: Regenerate.
2022-01-23 06:59:20 -08:00
H.J. Lu
31b0378d53 Regenerate configure files with autoconf 2.69
Regenerate configure files with the unmodified autoconf 2.69 to remove

  --runstatedir=DIR       modifiable per-process data [LOCALSTATEDIR/run]

bfd/

	* configure: Regenerate.

binutils/

	* configure: Regenerate.

gas/

	* configure: Regenerate.

gold/

	* configure: Regenerate.

gprof/

	* configure: Regenerate.

ld/

	* configure: Regenerate.

opcodes/

	* configure: Regenerate.
2022-01-23 05:27:01 -08:00
GDB Administrator
35638469cb Automatic date update in version.in 2022-01-23 00:00:12 +00:00
Mike Frysinger
bd32be01c9 bfd: merge doc subdir up a level
This avoids a recursive make into the doc subdir and speeds up the
build slightly.  It also allows for more parallelism.
2022-01-22 16:47:35 -05:00
Mike Frysinger
cb803d3749 bfd: rename core.texi to corefile.texi
This is a generated file name from a correspondingly named C file.
Rename it to avoid unique build rules since there's no difference
to the generated manual.
2022-01-22 16:07:16 -05:00
Mike Frysinger
3dd8e5b615 bfd: replace doc header generation with pattern rules
This unifies boilerplate rules for most files with pattern rules.
2022-01-22 16:06:53 -05:00
Martin Storsj?
58de646be2 Allow inferring tmp_prefix from the dll name from a def file. 2022-01-22 14:31:22 +00:00
Alexander von Gluck IV
cc5e40736d Adjust default page sizes for haiku arm.
* configure.tgt (arm-haiku): Fix typo.
	* emulparams/armelf_haiku.su (MAXPAGESIZE): Use the default value.
	(COMMONPAGESIZE): Likewise.
2022-01-22 14:18:34 +00:00
Nick Clifton
5f7a57f131 Update release makeing script with new release numbers 2022-01-22 13:26:54 +00:00
Nick Clifton
f908e960c5 Change version number to 2.38.50 and regenerate files 2022-01-22 12:39:28 +00:00
Nick Clifton
a74e1cb344 Add markers for 2.38 branch 2022-01-22 12:08:55 +00:00
Lifang Xia
cb2562f553 RISC-V: create new frag after alignment.
PR 28793:

The alignment may be removed in linker. We need to create new frag after
alignment to prevent the assembler from computing static offsets.

gas/
	* config/tc-riscv.c (riscv_frag_align_code): Create new frag.
2022-01-22 17:20:18 +08:00
GDB Administrator
5b4ea8a740 Automatic date update in version.in 2022-01-22 00:00:12 +00:00
Simon Marchi
ed09c325ec gdb: include gdbsupport/buildargv.h in ser-mingw.c
Fixes:

      CXX    ser-mingw.o
    /home/simark/src/binutils-gdb/gdb/ser-mingw.c: In function ‘int pipe_windows_open(serial*, const char*)’:
    /home/simark/src/binutils-gdb/gdb/ser-mingw.c:870:3: error: ‘gdb_argv’ was not declared in this scope
      870 |   gdb_argv argv (name);
          |   ^~~~~~~~

Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=28802
Change-Id: I7f3e8ec5f9ca8582d587545fdf6b69901259f199
2022-01-21 11:34:30 -05:00
Nick Clifton
e901223d53 Updated Serbian translation for the ld sub-directory 2022-01-21 15:42:18 +00:00
Andrew Burgess
b13d7831eb gdb/doc: fill in two missing @r
I noticed two places in the docs where we appear to be missing @r.
makeinfo seems to do the correct things despite these being
missing (at least, I couldn't see any difference in the pdf or info
output), but it doesn't hurt to have the @r in place.
2022-01-21 12:49:48 +00:00
Mike Frysinger
ec7194506d drop old unused stamp-h.in file
This was needed by ancient versions of automake, but that hasn't been
the case since at least automake-1.5, so punt this from the tree.
2022-01-21 03:11:47 -05:00
Simon Marchi
7bf5587873 gdbsupport/gdb_regex.cc: replace defs.h include with common-defs.h
This was forgotten when gdb_regex was moved from gdb to gdbsupport.

Change-Id: I73b446f71861cabbf7afdb7408ef9d59fa64b804
2022-01-20 22:58:21 -05:00
GDB Administrator
df9d50bb22 Automatic date update in version.in 2022-01-21 00:00:15 +00:00
Tom Tromey
6d263fe46e Avoid bad breakpoints with --gc-sections
We found a case where --gc-sections can cause gdb to set an invalid
breakpoint.  In the included test case, gdb will set a breakpoint with
two locations, one of which is 0x0.

The code in lnp_state_machine::check_line_address is intended to
filter out this sort of problem, but in this case, the entire CU is
empty, causing unrelocated_lowpc==0x0 -- which circumvents the check.

It seems to me that if a CU is empty like this, then it is ok to
simply ignore the line table, as there won't be any locations anyway.
2022-01-20 07:22:23 -07:00
GDB Administrator
dd8a5a84a7 Automatic date update in version.in 2022-01-20 00:00:18 +00:00
Maciej W. Rozycki
101d68a9fa Add `set print array-indexes' tests for C/C++ arrays
Add `set print array-indexes' tests for C/C++ arrays, complementing one
for Fortran arrays.
2022-01-19 21:55:10 +00:00
Maciej W. Rozycki
5d4c63a635 Respect `set print array-indexes' with Fortran arrays
Add `set print array-indexes' handling for Fortran arrays.  Currently
the setting is ignored and indices are never shown.

Keep track of the most recent index handled so that any outstanding
repeated elements printed when the limit set by `set print elements' is
hit have the correct index shown.

Output now looks like:

(gdb) set print array-indexes on
(gdb) print array_1d
$1 = ((-2) = 1, (-1) = 1, (0) = 1, (1) = 1, (2) = 1)
(gdb) set print repeats 4
(gdb) set print elements 12
(gdb) print array_2d
$2 = ((-2) = ((-2) = 2, <repeats 5 times>) (-1) = ((-2) = 2, <repeats 5 times>) (0) = ((-2) = 2, (-1) = 2, ...) ...)
(gdb)

for a 5-element vector and a 5 by 5 array filled with the value of 2.
2022-01-19 21:55:10 +00:00
Maciej W. Rozycki
6b4338c868 Add `set print repeats' tests for C/C++ arrays
Add `set print repeats' tests for C/C++ arrays, complementing one for
Fortran arrays and covering the different interpretation of the `set
print elements' setting in particular where the per-dimension count of
the elements handled is matched against the trigger rather than the
total element count as with Fortran arrays.
2022-01-19 21:55:10 +00:00
Maciej W. Rozycki
476f77a94c Respect `set print repeats' with Fortran arrays
Implement `set print repeats' handling for Fortran arrays.  Currently
the setting is ignored and always treated as if no limit was set.

Unlike the generic array walker implemented decades ago the Fortran one
is a proper C++ class.  Rather than trying to mimic the old walker then,
which turned out a bit of a challenge where interacting with the `set
print elements' setting, write it entirely from scratch, by adding an
extra specialization handler method for processing dimensions other than
the innermost one and letting the specialization class call the `walk_1'
method from the handler as it sees fit.  This way repeats can be tracked
and the next inner dimension recursed into as a need arises only, or
unconditionally in the base class.

Keep track of the dimension number being handled in the class rather as
a parameter to the walker so that it does not have to be passed across
by the specialization class.

Use per-dimension element count tracking, needed to terminate processing
early when the limit set by `set print elements' is hit.  This requires
extra care too where the limit triggers exactly where another element
that is a subarray begins.  In that case rather than recursing we need
to terminate processing or lone `(...)' would be printed.  Additionally
if the skipped element is the last one in the current dimension we need
to print `...' by hand, because `continue_walking' won't print it at the
upper level, because it can see the last element has already been taken
care of.

Preserve the existing semantics of `set print elements' where the total
count of the elements handled is matched against the trigger level which
is unlike with the C/C++ array printer where the per-dimension element
count is used instead.

Output now looks like:

(gdb) set print repeats 4
(gdb) print array_2d
$1 = ((2, <repeats 5 times>) <repeats 5 times>)
(gdb) set print elements 12
(gdb) print array_2d
$2 = ((2, <repeats 5 times>) (2, <repeats 5 times>) (2, 2, ...) ...)
(gdb)

for a 5 by 5 array filled with the value of 2.

Amend existing test cases accordingly that rely on the current incorrect
behavior and explicitly request that there be no limit for printing
repeated elements there.

Add suitable test cases as well covering sliced arrays in particular.

Co-Authored-By: Andrew Burgess <andrew.burgess@embecosm.com>
2022-01-19 21:55:10 +00:00