Commit Graph

110646 Commits

Author SHA1 Message Date
Enze Li
44ca285b73 gdb: initialize the data_head variable to eliminate compilation warnings
On a machine with gcc 12, I get this warning:

  CXX    nat/linux-btrace.o
In function ‘btrace_error linux_read_bts(btrace_data_bts*, btrace_target_info*, btrace_read_type)’,
    inlined from ‘btrace_error linux_read_btrace(btrace_data*, btrace_target_info*, btrace_read_type)’ at ../gdb/nat/linux-btrace.c:935:29:
../gdb/nat/linux-btrace.c:865:21: warning: ‘data_head’ may be used uninitialized [-Wmaybe-uninitialized]
  865 |   pevent->last_head = data_head;
      |   ~~~~~~~~~~~~~~~~~~^~~~~~~~~~~
../gdb/nat/linux-btrace.c: In function ‘btrace_error linux_read_btrace(btrace_data*, btrace_target_info*, btrace_read_type)’:
../gdb/nat/linux-btrace.c:792:9: note: ‘data_head’ was declared here
  792 |   __u64 data_head, data_tail;
      |         ^~~~~~~~~

Fix this by initializing the 'data_head' variable.

Tested by rebuilding on x86_64 openSUSE Tumbleweed with gcc 12.
2022-07-08 21:48:15 +08:00
Andrew Burgess
ec54dc915f libopcodes/s390: add support for disassembler styling
This commit adds disassembler style to the libopcodes s390
disassembler.  This conversion was pretty straight forward, I just
converted the fprintf_func calls to fprintf_styled_func calls and
added an appropriate style.

For testing the new styling I just assembled then disassembled the
source files in gas/testsuite/gas/s390 and manually checked that the
styling looked reasonable.

If the user does not request styled output from objdump, then there
should be no change in the disassembler output after this commit.
2022-07-08 13:14:33 +01:00
Nick Clifton
5bbe6ec5b1 Fix regeneration of ld configure and makefiles 2022-07-08 12:41:48 +01:00
Nick Clifton
e1ec7b9f9f Update release README with new version numbers 2022-07-08 11:55:59 +01:00
Nick Clifton
631ec08cb1 Update version to 2.39.50 and regenerate files 2022-07-08 11:19:44 +01:00
Nick Clifton
0bd0932314 Add markers for 2.39 branch 2022-07-08 10:41:07 +01:00
GDB Administrator
97a8d0ab53 Automatic date update in version.in 2022-07-08 00:00:16 +00:00
Vladimir Mezentsev
5236c98902 gprofng: fix regression in testing for not yet installed version
gprofng/ChangeLog
2022-07-07  Vladimir Mezentsev  <vladimir.mezentsev@oracle.com>

	* src/Settings.cc (Settings::read_rc): Read environment variable
	GPROFNG_SYSCONFDIR.
	* testsuite/lib/Makefile.skel: Export GPROFNG_SYSCONFDIR.
	* testsuite/gprofng.display/display.exp: Shorten the list of tests.
2022-07-07 13:20:39 -07:00
Simon Marchi
c0abbd96b4 gdb: fix {rs6000_nat_target,aix_thread_target}::wait to not use inferior_ptid
Trying to run a simple program (empty main) on AIX, I get:

    (gdb) run
    Starting program: /scratch/simark/build/gdb/a.out
    Child process unexpectedly missing: There are no child processes..
    ../../src/binutils-gdb/gdb/inferior.c:304: internal-error: find_inferior_pid: Assertion `pid != 0' failed.
    A problem internal to GDB has been detected,
    further debugging may prove unreliable.
    ----- Backtrace -----
    0x10ef12a8 gdb_internal_backtrace_1()
            ../../src/binutils-gdb/gdb/bt-utils.c:122
    0x10ef1470 gdb_internal_backtrace()
            ../../src/binutils-gdb/gdb/bt-utils.c:168
    0x1004d368 internal_vproblem(internal_problem*, char const*, int, char const*, char*)
            ../../src/binutils-gdb/gdb/utils.c:396
    0x1004d8a8 internal_verror(char const*, int, char const*, char*)
            ../../src/binutils-gdb/gdb/utils.c:476
    0x1004c424 internal_error(char const*, int, char const*, ...)
            ../../src/binutils-gdb/gdbsupport/errors.cc:55
    0x102ab344 find_inferior_pid(process_stratum_target*, int)
            ../../src/binutils-gdb/gdb/inferior.c:304
    0x102ab4a4 find_inferior_ptid(process_stratum_target*, ptid_t)
            ../../src/binutils-gdb/gdb/inferior.c:318
    0x1061bae8 find_thread_ptid(process_stratum_target*, ptid_t)
            ../../src/binutils-gdb/gdb/thread.c:519
    0x10319e98 handle_inferior_event(execution_control_state*)
            ../../src/binutils-gdb/gdb/infrun.c:5532
    0x10315544 fetch_inferior_event()
            ../../src/binutils-gdb/gdb/infrun.c:4221
    0x10952e34 inferior_event_handler(inferior_event_type)
            ../../src/binutils-gdb/gdb/inf-loop.c:41
    0x1032640c infrun_async_inferior_event_handler(void*)
            ../../src/binutils-gdb/gdb/infrun.c:9548
    0x10673188 check_async_event_handlers()
            ../../src/binutils-gdb/gdb/async-event.c:335
    0x1066fce4 gdb_do_one_event()
            ../../src/binutils-gdb/gdbsupport/event-loop.cc:214
    0x10001a94 start_event_loop()
            ../../src/binutils-gdb/gdb/main.c:411
    0x10001ca0 captured_command_loop()
            ../../src/binutils-gdb/gdb/main.c:471
    0x10003d74 captured_main(void*)
            ../../src/binutils-gdb/gdb/main.c:1329
    0x10003e48 gdb_main(captured_main_args*)
            ../../src/binutils-gdb/gdb/main.c:1344
    0x10000744 main
            ../../src/binutils-gdb/gdb/gdb.c:32
    ---------------------
    ../../src/binutils-gdb/gdb/inferior.c:304: internal-error: find_inferior_pid: Assertion `pid != 0' failed.
    A problem internal to GDB has been detected,
    further debugging may prove unreliable.
    Quit this debugging session? (y or n)

This is due to some bit-rot in the AIX port, still relying on the entry
value of inferior_ptid in the wait methods.

Problem #1 is in rs6000_nat_target::wait, here:

      /* Ignore terminated detached child processes.  */
      if (!WIFSTOPPED (status) && pid != inferior_ptid.pid ())
	pid = -1;

At this point, waitpid has returned an "exited" status for some pid, so
pid is non-zero.  Since inferior_ptid is set to null_ptid on entry, the
pid returned by wait is not equal to `inferior_ptid.pid ()`, so we reset
pid to -1 and go to waiting again.  Since there are not more children to
wait for, waitpid then returns -1 so we get here:

      if (pid == -1)
	{
	  gdb_printf (gdb_stderr,
		      _("Child process unexpectedly missing: %s.\n"),
		      safe_strerror (save_errno));

	  /* Claim it exited with unknown signal.  */
	  ourstatus->set_signalled (GDB_SIGNAL_UNKNOWN);
	  return inferior_ptid;
	}

We therefore return a "signalled" status with a null_ptid (again,
inferior_ptid is null_ptid).  This confuses infrun, because if the
target returns a "signalled" status, it should be coupled with a ptid
for an inferior that exists.

So, the first step is to fix the snippets above to not use
inferior_ptid.  In the first snippet, use find_inferior_pid to see if
we know the event process.  If there is no inferior with that pid, we
assume it's a detached child process to we ignore the event.  That
should be enough to fix the problem, because it should make it so we
won't go into the second snippet.  But still, fix the second snippet to
return an "ignore" status.  This is copied from inf_ptrace_target::wait,
which is where rs6000_nat_target::wait appears to be copied from in the
first place.

These changes, are not sufficient, as the aix_thread_target, which sits
on top of rs6000_nat_target, also relies on inferior_ptid.
aix_thread_target::wait, by calling pd_update, assumes that
rs6000_nat_target has set inferior_ptid to the appropriate value (the
ptid of the event thread), but that's not the case.  pd_update
returns inferior_ptid - null_ptid - and therefore
aix_thread_target::wait returns null_ptid too, and we still hit the
assert shown above.

Fix this by changing pd_activate, pd_update, sync_threadlists and
get_signaled_thread to all avoid using inferior_ptid.  Instead, they
accept as a parameter the pid of the process we are working on.

With this patch, I am able to run the program to completion:

    (gdb) r
    Starting program: /scratch/simark/build/gdb/a.out
    [Inferior 1 (process 11010794) exited normally]

As well as break on main:

    (gdb) b main
    Breakpoint 1 at 0x1000036c
    (gdb) r
    Starting program: /scratch/simark/build/gdb/a.out

    Breakpoint 1, 0x1000036c in main ()
    (gdb) c
    Continuing.
    [Inferior 1 (process 26083688) exited normally]

Change-Id: I7c2613bbefe487d75fa1a0c0994423471d961ee9
2022-07-07 09:55:01 -04:00
Pedro Alves
a2a176c46b Fix pedantically invalid DWARF in gdb.trace/unavailable-dwarf-piece.exp
The DWARF spec says:

  Any debugging information entry representing the declaration of an object,
  module, subprogram or type may have DW_AT_decl_file, DW_AT_decl_line and
  DW_AT_decl_column attributes, each of whose value is an unsigned integer
							  ^^^^^^^^
  constant.

Grepping around the DWARF-assembler-based testcases, I noticed that
gdb.trace/unavailable-dwarf-piece.exp emits decl_line with
DW_FORM_sdata, a signed integer form.  This commit tweaks it to use
DW_FORM_udata instead.

Unsurprisingly, this:

  $ make check \
      TESTS="gdb.trace/unavailable-dwarf-piece.exp" \
      RUNTESTFLAGS="--target_board=native-gdbserver"

... still passes cleanly for me after this change.

I've noticed this because current llvm-dwarfdump crashed on an
ROCm-internal DWARF-assembler-based testcase that incorrectly used
signed forms for DW_AT_decl_file/DW_AT_decl_line.

The older llvm-dwarfdump found on Ubuntu 20.04 (LLVM 10) reads the
line numbers with signed forms as "0" instead of crashing.  Here's the
before/after fix for gdb.trace/unavailable-dwarf-piece.exp with that
llvm-dwarfdump version:

  $ diff -up before.txt after.txt
  --- before.txt    2022-07-07 13:21:28.387690334 +0100
  +++ after.txt     2022-07-07 13:21:39.379801092 +0100
  @@ -18,7 +18,7 @@
		   DW_AT_name     ("s")
		   DW_AT_byte_size        (3)
		   DW_AT_decl_file        (0)
  -                DW_AT_decl_line        (0)
  +                DW_AT_decl_line        (1)

   0x0000002f:     DW_TAG_member
		     DW_AT_name   ("a")
  @@ -41,7 +41,7 @@
		   DW_AT_name     ("t")
		   DW_AT_byte_size        (3)
		   DW_AT_decl_file        (0)
  -                DW_AT_decl_line        (0)
  +                DW_AT_decl_line        (1)

   0x00000054:     DW_TAG_member
		     DW_AT_name   ("a")

Change-Id: I5c866946356da421ff944019d0eca2607b2b738f
2022-07-07 13:27:39 +01:00
Tiezhu Yang
83f477f25a gdb: LoongArch: Fix typos in code comments
"it’s" should be "it's".

Signed-off-by: Tiezhu Yang <yangtiezhu@loongson.cn>
2022-07-07 19:14:43 +08:00
Maciej W. Rozycki
309e147fbd GDB/testsuite: Add coverage for `print -elements' command
We currently have no coverage for the `print -elements ...' command (or
`p -elements ...' in the shortened form), so add a couple of test cases
mimicking ones using corresponding `set print elements ...' values.
2022-07-07 12:00:18 +01:00
Tiezhu Yang
88de583569 gdb: LoongArch: Implement the push_dummy_call gdbarch method
According to "Procedure Calling Convention" in "LoongArch ELF ABI
specification" [1], implement the push_dummy_call gdbarch method
as clear as possible.

[1] https://loongson.github.io/LoongArch-Documentation/LoongArch-ELF-ABI-EN.html#_procedure_calling_convention

Signed-off-by: Tiezhu Yang <yangtiezhu@loongson.cn>
2022-07-07 17:05:11 +08:00
Tsukasa OI
045f385d9a RISC-V: Added Zfhmin and Zhinxmin.
This commit adds Zfhmin and Zhinxmin extensions (subsets of Zfh and
Zhinx extensions, respectively).  In the process supporting Zfhmin and
Zhinxmin extension, this commit also changes how instructions are
categorized considering Zfhmin, Zhinx and Zhinxmin extensions.

Detailed changes,

* From INSN_CLASS_ZFH to INSN_CLASS_ZFHMIN:

flh, fsh, fmv.x.h and fmv.h.x.

* From INSN_CLASS_ZFH to INSN_CLASS_ZFH_OR_ZHINX:

fmv.h.

* From INSN_CLASS_ZFH_OR_ZHINX to INSN_CLASS_ZFH_OR_ZHINX:

fneg.h, fabs.h, fsgnj.h, fsgnjn.h, fsgnjx.h,
fadd.h, fsub.h, fmul.h, fdiv.h, fsqrt.h, fmin.h, fmax.h,
fmadd.h, fnmadd.h, fmsub.h, fnmsub.h,
fcvt.w.h, fcvt.wu.h, fcvt.h.w, fcvt.h.wu,
fcvt.l.h, fcvt.lu.h, fcvt.h.l, fcvt.h.lu,
feq.h, flt.h, fle.h, fgt.h, fge.h,
fclass.h.

* From INSN_CLASS_ZFH_OR_ZHINX to INSN_CLASS_ZFHMIN_OR_ZHINXMIN:

fcvt.s.h and fcvt.h.s.

* From INSN_CLASS_D_AND_ZFH_INX to INSN_CLASS_ZFHMIN_AND_D:

fcvt.d.h and fcvt.h.d.

* From INSN_CLASS_Q_AND_ZFH_INX to INSN_CLASS_ZFHMIN_AND_Q:

fcvt.q.h and fcvt.h.q.

bfd/ChangeLog:

	* elfxx-riscv.c (riscv_implicit_subsets): Change implicit
	subsets.  Zfh->Zicsr is not needed and Zfh->F is replaced with
	Zfh->Zfhmin and Zfhmin->F.  Zhinx->Zicsr is not needed and
	Zhinx->Zfinx is replaced with Zhinx->Zhinxmin and
	Zhinxmin->Zfinx.
	(riscv_supported_std_z_ext): Added zfhmin and zhinxmin.
	(riscv_multi_subset_supports):  Rewrite handling for new
	instruction classes.
	(riscv_multi_subset_supports_ext): Updated.
	(riscv_parse_check_conflicts): Change error message to include
	zfh and zfhmin extensions.

gas/ChangeLog:

	* testsuite/gas/riscv/zfhmin-d-insn-class-fail.s: New complex
	error handling test.
	* testsuite/gas/riscv/zfhmin-d-insn-class-fail-1.d: Likewise.
	* testsuite/gas/riscv/zfhmin-d-insn-class-fail-1.l: Likewise.
	* testsuite/gas/riscv/zfhmin-d-insn-class-fail-2.d: Likewise.
	* testsuite/gas/riscv/zfhmin-d-insn-class-fail-2.l: Likewise.
	* testsuite/gas/riscv/zfhmin-d-insn-class-fail-3.d: Likewise.
	* testsuite/gas/riscv/zfhmin-d-insn-class-fail-3.l: Likewise.
	* testsuite/gas/riscv/zfhmin-d-insn-class-fail-4.d: Likewise.
	* testsuite/gas/riscv/zfhmin-d-insn-class-fail-4.l: Likewise.
	* testsuite/gas/riscv/zfhmin-d-insn-class-fail-5.d: Likewise.
	* testsuite/gas/riscv/zfhmin-d-insn-class-fail-5.l: Likewise.
	* testsuite/gas/riscv/zhinx.d: Renamed from fp-zhinx-insns.d
	and refactored.
	* testsuite/gas/riscv/zhinx.s: Likewise.

include/ChangeLog:

	* opcode/riscv.h (enum riscv_insn_class): Removed INSN_CLASS_ZFH,
	INSN_CLASS_D_AND_ZFH_INX and INSN_CLASS_Q_AND_ZFH_INX.  Added
	INSN_CLASS_ZFHMIN, INSN_CLASS_ZFHMIN_OR_ZHINXMIN,
	INSN_CLASS_ZFHMIN_AND_D and INSN_CLASS_ZFHMIN_AND_Q.

opcodes/ChangeLog:

	* riscv-opc.c (riscv_opcodes): Change instruction classes for
	Zfh and Zfhmin instructions.  Fix `fcvt.h.lu' instruction
	(two operand variant) mask.
2022-07-07 16:23:54 +08:00
Vladimir Mezentsev
1bb1f55d64 gprofng: adjust GPROFNG_VARIANT
GPROFNG_VARIANT depends on compiler options, not on $(host).

gprofng/ChangeLog
2022-07-06  Vladimir Mezentsev  <vladimir.mezentsev@oracle.com>

	PR gprofng/29116
	* libcollector/configure.ac: Adjust GPROFNG_VARIANT.
	* libcollector/configure: Rebuild.
2022-07-06 22:36:44 -07:00
Tsukasa OI
3d5d6bd554 RISC-V: Fix disassembling Zfinx with -M numeric
This commit fixes floating point operand register names from ABI ones
to dynamically set ones.

gas/ChangeLog:

	* testsuite/gas/riscv/zfinx-dis-numeric.s: Test new behavior of
	Zfinx extension and -M numeric disassembler option.
	* testsuite/gas/riscv/zfinx-dis-numeric.d: Likewise.

opcodes/ChangeLog:

	* riscv-dis.c (riscv_disassemble_insn): Use dynamically set GPR
	names to disassemble Zfinx instructions.
2022-07-07 12:06:02 +08:00
Tsukasa OI
37cf60c6a6 RISC-V: Fix requirement handling on Zhinx+{D,Q}
This commit fixes how instructions are masked on Zhinx+Z{d,q}inx.
fcvt.h.d and fcvt.d.h require ((D&&Zfh)||(Zdinx&&Zhinx)) and
fcvt.h.q and fcvt.q.h require ((Q&&Zfh)||(Zqinx&&Zhinx)).

bfd/ChangeLog:

	* elfxx-riscv.c (riscv_multi_subset_supports): Fix feature gate
	on INSN_CLASS_{D,Q}_AND_ZFH_INX.
	(riscv_multi_subset_supports_ext): Fix feature gate diagnostics
	on INSN_CLASS_{D,Q}_AND_ZFH_INX.

gas/ChangeLog:

	* testsuite/gas/riscv/fp-zhinx-insns.d: Add Zqinx to -march
	for proper testing.
2022-07-07 12:05:56 +08:00
Alan Modra
9b5ebf652b PR29320, 'struct obstack' declared inside parameter list
PR 29320
	* frags.h: Move declaration of struct obstack..
	* as.h: ..to here.
2022-07-07 11:52:05 +09:30
GDB Administrator
2025522ac7 Automatic date update in version.in 2022-07-07 00:00:21 +00:00
Ruud van der Pas
41bbac64c3 gprofng: implement a functional gp-display-html
This patch enables the first support for the "gprofng display html" command.
This command works for C/C++ applications on x86_64. Using one or more gprofng
experiment directories as input, a new directory with html files is created.
Through the index.html file in this directory, the performance results may be
viewed in a browser.

gprofng/Changelog:
2022-06-28  Ruud van der Pas  <ruud.vanderpas@oracle.com>

	* gp-display-html/gp-display-html.in: implement first support for x86_64 and C/C++
2022-07-06 14:39:33 -07:00
H.J. Lu
fb5a4a581d elf: Copy p_align of PT_GNU_STACK for stack alignment
commit 74e315dbfe
Author: H.J. Lu <hjl.tools@gmail.com>
Date:   Mon Dec 13 19:46:04 2021 -0800

    elf: Set p_align to the minimum page size if possible

may ignore p_align of PT_GNU_STACK when copying ELF program header if
the maximum page size is larger than p_align of PT_LOAD segments.  Copy
p_align of PT_GNU_STACK since p_align of PT_GNU_STACK describes stack
alignment, not page size,

	PR binutils/29319
	* elf.c (copy_elf_program_header): Copy p_align of PT_GNU_STACK
	for stack alignment.
2022-07-06 12:39:06 -07:00
Jan Beulich
8bd915b770 x86: make D attribute usable for XOP and FMA4 insns
This once again allows to reduce redundancy in (and size of) the opcode
table.

Don't go as far as also making D work on the two 5-operand XOP insns:
This would significantly complicate the code, as there the first
(immediate) operand would need special treatment in several places.

Note that the .s suffix isn't being enabled to have any effect, for
being deprecated. Whereas neither {load} nor {store} pseudo prefixes
make sense here, as the respective operands are inputs (loads) only
anyway, regardless of order. Hence there is (as before) no way for the
programmer to request the alternative encoding to be used for register-
only insns.

Note further that it is always the first original template which is
retained (and altered), to make sure the same encoding as before is
used for register-only insns. This has the slightly odd (but pre-
existing) effect of XOP register-only insns having XOP.W clear, but FMA4
ones having VEX.W set.
2022-07-06 15:40:04 +02:00
Jan Beulich
3d0738af2a x86: fold two switch() statements in match_template()
I don't see why two of them were introduced (very long ago) using
similar fall-through logic.
2022-07-06 15:39:37 +02:00
Jan Beulich
c975cec5ff x86: fix 3-operand insn reverse-matching
The middle operand would have gone entirely unchecked, allowing e.g.

	vmovss		%xmm0, %esp, %xmm2

to assemble successfully, or e.g.

	vmovss		%xmm0, $4, %xmm2

causing an internal error. Alongside dealing with this also drop a
related comment, which hasn't been applicable anymore since the
introduction of 3-operand patterns with D set (and which perhaps never
had been logical to be there, as reverse-matched insns don't make it
there in the first place).
2022-07-06 15:39:03 +02:00
Bhuvanendra Kumar N
ad349f2493 Descriptive DWARF operations dump support for DW_AT_rank
DW_AT_rank is a dwarf-5 feature.
2022-07-06 16:27:47 +05:30
Jan Beulich
f68697e823 x86: introduce a state stack for .arch
When using just slightly non-trivial combinations of .arch, it can be
quite useful to be able to go back to prior state without needing to
re-invoke perhaps many earlier directives and without needing to invoke
perhaps many "negative" ones. Like some other architectures allow
saving (pushing) and restoring (popping) present/prior state.

For now require the same .code<N> to be in effect for ".arch pop" that
was in effect for the corresponding ".arch push".

Also change the global "no_cond_jump_promotion" to be bool, to match the
new struct field.
2022-07-06 09:22:47 +02:00
Jan Beulich
ae89daecb1 x86: generalize disabling of sub-architectures
I never really understood upon what basis ".arch .no*" options were made
available. Let's not have any "criteria" at all, and simply allow
disabling of all of them. Then we also have all data for a sub-arch in
a single place, as we now only need a single table.
2022-07-06 09:22:11 +02:00
Jan Beulich
3ce2ebcf88 x86: permit "default" with .arch
So far there was no way to reset the architecture to that assembly would
start with in the absence of any overrides (command line or directives).
Note that for Intel MCU "default" is merely an alias of "iamcu".

While there also zap a stray @item from the doc section, as noticed
when inspecting the generated output (which still has some quirks, but
those aren't easy to address without re-flowing almost the entire
section).
2022-07-06 09:21:40 +02:00
Jan Beulich
d92c7521f9 x86: don't leak sub-architecture accumulated strings
While it may not be necessary in i386_target_format() (but then setting
the variable to NULL also wouldn't be necessary), at least in the other
cases strings may already have accumulated.
2022-07-06 09:20:29 +02:00
GDB Administrator
8df9766816 Automatic date update in version.in 2022-07-06 00:00:17 +00:00
Tom de Vries
22f8e2e726 [gdb/exp] Fix internal error when printing C++ pointer-to-member
When running the test-case included with this patch, we run into:
...
(gdb) print ptm^M
$1 = gdb/gdbtypes.h:695: internal-error: loc_bitpos: \
  Assertion `m_loc_kind == FIELD_LOC_KIND_BITPOS' failed.^M
...
while printing a c++ pointer-to-member.

Fix this by skipping static fields in cp_find_class_member, such that we have:
...
(gdb) print ptm^M
$1 = &A::i^M
...

Tested on x86_64-linux.

Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=29294
2022-07-05 22:41:25 +02:00
Tom Tromey
99298c958c Add gdb.Objfile.is_file attribute
Sometimes an objfile comes from memory and not from a file.  It can be
useful to be able to check this from Python, so this patch adds a new
"is_file" attribute.
2022-07-05 11:22:20 -06:00
Tom Tromey
3acd9a692d Make 'import gdb.events' work
Pierre-Marie noticed that, while gdb.events is a Python module, it
can't be imported.  This patch changes how this module is created, so
that it can be imported, while also ensuring that the module is always
visible, just as it was in the past.

This new approach required one non-obvious change -- when running
gdb.base/warning.exp, where --data-directory is intentionally not
found, the event registries can now be nullptr.  Consequently, this
patch probably also requires

    https://sourceware.org/pipermail/gdb-patches/2022-June/189796.html

Note that this patch obsoletes

    https://sourceware.org/pipermail/gdb-patches/2022-June/189797.html
2022-07-05 10:28:39 -06:00
Xi Ruoyao
736918239b gdb: LoongArch: add orig_a0 into register set
The basic support for LoongArch has been merged into the upstream Linux
kernel since 5.19-rc1 on June 5, 2022.  This commit adds orig_a0 which
is added into struct user_pt_regs [1] to match the upstream kernel, and
then the upstream GDB will work with the upstream kernel.

Note that orig_a0 was added into struct user_pt_regs in the development
cycle for merging LoongArch port into the upstream Linux kernel, so
earlier kernels (notably, the product kernel with version 4.19 used in
distros like UOS and Loongnix) don't have it.  Inspect
arch/loongarch/include/uapi/asm/ptrace.h in the kernel tree to make sure.
To build upstream GDB for a kernel lacking orig_a0, it's necessary to
revert this commit locally.

[1]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/arch/loongarch/include/uapi/asm/ptrace.h#n24

Signed-off-by: Xi Ruoyao <xry111@xry111.site>
Signed-off-by: Tiezhu Yang <yangtiezhu@loongson.cn>
2022-07-05 22:26:45 +08:00
Bhuvanendra Kumar N
4694a0e5fe Support for location and range lists for split-dwarf and dwarf-5.
Adding support for location and range lists for split-dwarf and dwarf-5.
Following issues are taken care.
1. Display of the index values for DW_FORM_loclistx and DW_FORM_rnglistx.
2. Display of .debug_loclists.dwo and .debug_rnglists.dwo sections.

        * dwarf.c(read_and_display_attr_value): Handle DW_FORM_loclistx
        and DW_FORM_rnglistx for .dwo files.
        (process_debug_info): Load .debug_loclists.dwo and
        .debug_rnglists.dwo if exists.
        (load_separate_debug_files): Load .debug_loclists and
        .debug_rnglists if exists.
        Include 2 entries in debug_displays table.
        * dwarf.h (enum dwarf_section_display_enum): Include 2 entries.
2022-07-05 16:56:13 +05:30
Jan Beulich
c368d2a802 x86: introduce fake processor type to mark sub-arch entries in cpu_arch[]
This is in preparation of dropping the leading . from the strings.

While there also move PROCESSOR_GENERIC{32,64} from the middle of AMD
entries to near the top.
2022-07-05 08:40:39 +02:00
Jan Beulich
6ceeed2506 x86: macro-ize cpu_arch[] entries
Putting individual elements behind macros, besides (imo) improving
readability, will make subsequent (and likely also future) changes less
intrusive.

Utilize this right away to pack the table a little more tightly, by
converting "skip" to bool and putting it earlier in a group of bitfields
together with "len".
2022-07-05 08:40:09 +02:00
Jan Beulich
8180707f90 x86: de-duplicate sub-architecture strings accumulation
Introduce a helper function to replace 4 instances of similar code. Use
reconcat() to cover the previously explicit free().
2022-07-05 08:39:43 +02:00
GDB Administrator
10e52570b8 Automatic date update in version.in 2022-07-05 00:00:18 +00:00
Nick Clifton
96c33f79de Fix snafu in rust demangler recursion limit code 2022-07-04 16:28:02 +01:00
Alan Modra
eeeaf705fe alloc gas seginfo on notes obstack
Lots of memory used in gas should go on this obstack.  The patch also
frees all the gas obstacks on exit, which isn't a completely trivial
task.

	* subsegs.c (alloc_seginfo): New function.
	(subseg_change, subseg_get): Use it.
	(subsegs_end): New function.
	* as.h (subsegs_end): Declare.
	* output-file.c: Include subsegs.h
	(stash_frchain_obs): New function.
	(output_file_close): Save obstacks attached to output bfd before
	closing.  Call subsegs_end with the array of obstacks.
2022-07-04 22:51:56 +09:30
Alan Modra
0772daccb3 objcopy: bfd_alloc orelocation
This fixes an inconsequential objcopy memory leak.  I'd normally
ignore reports of leaks like this one, that are merely one block or
fewer per section processed, since objcopy soon exits and frees all
memory.  However I thought it worth providing support for allocating
memory on a bfd objalloc in objcopy and other utils.

	PR 29233
	* bucomm.c (bfd_xalloc): New function.
	* bucomm.h (bfd_xalloc): Declare.
	* objcopy.c (copy_relocations_in_section): Use it to allocate
	array of reloc pointers.  Rewrite code stripping relocs to do
	without extra memory allocation.
2022-07-04 22:51:56 +09:30
Nick Clifton
d8efadbdd9 Synchronize libbierty sources with gcc. 2022-07-04 13:57:12 +01:00
Bhuvanendra Kumar N
407115429b Modified changes for split-dwarf and dwarf-5.
* dwarf.c(process_debug_info): Include DW_TAG_skeleton_unit.
        (display_debug_str_offsets): While dumping .debug_str_offsets.dwo,
        pass proper str_offsets_base to fetch_indexed_string().
        (load_separate_debug_files): Skip DWO ID dump for dwarf-5.
2022-07-04 16:42:35 +05:30
Marcus Nilsson
a0f3a4c646 opcodes/avr: Implement style support in the disassembler
* disassemble.c: (disassemble_init_for_target): Set
	created_styled_output for AVR based targets.
	* avr-dis.c: (print_insn_avr): Use fprintf_styled_ftype
	instead of fprintf_ftype throughout.
	(avr_operand): Pass in and fill disassembler_style when
	parsing operands.
2022-07-04 11:25:42 +01:00
Tom de Vries
2c474c4694 [gdb/symtab] Add get/set functions for per_cu->lang/unit_type
The dwarf2_per_cu_data fields lang and unit_type both have a dont-know
initial value (respectively language_unknown and (dwarf_unit_type)0), which
allows us to add certain checks, f.i. checking that that a field is not read
before written.

Add get/set member functions for the two fields as a convenient location to
add such checks, make the fields private to enforce using the member
functions, and add the m_ prefix.

Tested on x86_64-linux.
2022-07-04 10:28:42 +02:00
Jan Beulich
58098fd779 gas/testsuite: properly exclude aout in all/weakref1u
Use the (wider) predicate rather than a triplet. This eliminates the sole
i386-msdos failure in the testsuite.
2022-07-04 08:42:10 +02:00
Jan Beulich
a775efc84d x86: fold Disp32S and Disp32
The only case where 64-bit code uses non-sign-extended (can also be
considered zero-extended) displacements is when an address size override
is in place for a memory operand (i.e. particularly excluding
displacements of direct branches, which - if at all - are controlled by
operand size, and then are still sign-extended, just from 16 bits).
Hence the distinction in templates is unnecessary, allowing code to be
simplified in a number of places. The only place where logic becomes
more complicated is when signed-ness of relocations is determined in
output_disp().

The other caveat is that Disp64 cannot be specified anymore in an insn
template at the same time as Disp32. Unlike for non-64-bit mode,
templates don't specify displacements for both possible addressing
modes; the necessary adjustment to the expected ones has already been
done in match_template() anyway (but of course the logic there needs
tweaking now). Hence the single template so far doing so is split.
2022-07-04 08:32:50 +02:00
Jan Beulich
02b83698ef x86: restore masking of displacement kinds
Commit 7d5e4556a3 rendered the check near the end of what is now
i386_finalize_displacement() entirely dead for AT&T mode, since for
operands involving a displacement .unspecified will always be set. But
the logic there is bogus anyway - Intel syntax operand size specifiers
are of no interest there either. The only thing which matters in the
"displacement only" determination is .baseindex.

Of course when masking displacement kinds we should not at the same time
also mask off other attributes.

Furthermore the type mask returned by lex_got() also needs to be
adjusted: The only case where we want Disp32 (rather than Disp32S) is
when dealing with 32-bit addressing mode in 64-bit code.
2022-07-04 08:32:20 +02:00
Jan Beulich
9386188e95 x86-64: improve handling of branches to absolute addresses
There are two related problems here: The use of "addr32" on a direct
branch would, besides causing a warning, result in operands to be
permitted which mistakenly are refused without "addr32". Plus at some
point not too long ago I'm afraid it may have been me who regressed the
relocation addends emitted for such branches. Correct both problems,
adding a testcase to guard against regressing this again.
2022-07-04 08:31:21 +02:00