Commit Graph

113746 Commits

Author SHA1 Message Date
Tom de Vries
1b79c725e4 [gdb/testsuite] Fix gdb.base/signals-state-child.exp for remote-gdbserver-on-localhost
With test-case gdb.base/signals-state-child.exp on target board
remote-gdbserver-on-localhost I run into:
...
builtin_spawn /usr/bin/ssh -t -l remote-target localhost \
  $outputs/gdb.base/signals-state-child/signals-state-child-standalone^M
bash: $outputs/gdb.base/signals-state-child/signals-state-child-standalone: \
  Permission denied^M
Connection to localhost closed.^M^M
FAIL: gdb.base/signals-state-child.exp: collect standalone signals state
...

The problem is that we're trying to run an executable on the target board using
a host path.

After fixing this by downloading the exec to the target board, we run into:
...
builtin_spawn /usr/bin/ssh -t -l remote-target localhost \
  signals-state-child-standalone^M
bash: signals-state-child-standalone: command not found^M
Connection to localhost closed.^M^M
FAIL: gdb.base/signals-state-child.exp: collect standalone signals state
...

Fix this by using an absolute path name for the exec on the target board.

The dejagnu proc standard_file does not support op == "absolute" for target
boards, so add an implementation in remote-gdbserver-on-localhost.exp.

Also:
- fix a PATH-in-test-name issue
- cleanup gdb.txt and standalone.txt on target board

Tested on x86_64-linux.
2023-03-07 14:46:24 +01:00
Tom de Vries
a50a8e305d [gdb/testsuite] Fix gdb.cp/breakpoint-shlib-func.exp with remote-gdbserver-on-localhost
Test-case gdb.cp/breakpoint-shlib-func.exp fails with target board
remote-gdbserver-on-localhost.

Fix this by adding the missing gdb_load_shlib.

Tested on x86_64-linux.
2023-03-07 11:11:03 +01:00
Aditya Vidyadhar Kamath
60204874f5 Modify altivec-regs.exp testcase for AIX
On AIX, the debugger cannot access vector registers before they
are first used by the inferior.  Hence we change the test case
such that some vector registers are accessed by the variable 'x' in AIX
and other targets are not affected as a consequence of the same.
2023-03-07 10:54:53 +01:00
Tom de Vries
e8850b5262 [gdb/testsuite] Fix gdb.mi/*.exp with remote-gdbserver-on-localhost
When running test-cases gdb.mi/*.exp with target board
remote-gdbserver-on-localhost, we run into a few fails.

Fix these (and make things more similar to the gdb.exp procs) by:
- factoring out mi_load_shlib out of mi_load_shlibs
- making mi_load_shlib use gdb_download_shlib, like
  gdb_load_shlib
- factoring out mi_locate_shlib out of mi_load_shlib
- making mi_locate_shlib check for mi_spawn_id, like
  gdb_locate_shlib
- using gdb_download_shlib and mi_locate_shlib in the test-cases.

Tested on x86_64-linux, with and without target board
remote-gdbserver-on-localhost.
2023-03-07 09:59:56 +01:00
Simon Marchi
07f2859348 gdb: fix -Wsingle-bit-bitfield-constant-conversion warning in z80-tdep.c
When building with clang 16, I see:

    /home/smarchi/src/binutils-gdb/gdb/z80-tdep.c:338:32: error: implicit truncation from 'int' to a one-bit wide bit-field changes value from 1 to -1 [-Werror,-Wsingle-bit-bitfield-constant-conversion]
            info->prologue_type.load_args = 1;
                                          ^ ~
    /home/smarchi/src/binutils-gdb/gdb/z80-tdep.c:345:36: error: implicit truncation from 'int' to a one-bit wide bit-field changes value from 1 to -1 [-Werror,-Wsingle-bit-bitfield-constant-conversion]
          info->prologue_type.critical = 1;
                                       ^ ~
    /home/smarchi/src/binutils-gdb/gdb/z80-tdep.c:351:37: error: implicit truncation from 'int' to a one-bit wide bit-field changes value from 1 to -1 [-Werror,-Wsingle-bit-bitfield-constant-conversion]
          info->prologue_type.interrupt = 1;
                                        ^ ~
    /home/smarchi/src/binutils-gdb/gdb/z80-tdep.c:367:36: error: implicit truncation from 'int' to a one-bit wide bit-field changes value from 1 to -1 [-Werror,-Wsingle-bit-bitfield-constant-conversion]
                  info->prologue_type.fp_sdcc = 1;
                                              ^ ~
    /home/smarchi/src/binutils-gdb/gdb/z80-tdep.c:375:35: error: implicit truncation from 'int' to a one-bit wide bit-field changes value from 1 to -1 [-Werror,-Wsingle-bit-bitfield-constant-conversion]
          info->prologue_type.fp_sdcc = 1;
                                      ^ ~
    /home/smarchi/src/binutils-gdb/gdb/z80-tdep.c:380:35: error: implicit truncation from 'int' to a one-bit wide bit-field changes value from 1 to -1 [-Werror,-Wsingle-bit-bitfield-constant-conversion]
          info->prologue_type.fp_sdcc = 1;
                                      ^ ~

Fix that by using "unsigned int" as the bitfield's underlying type.

Change-Id: I3550a0112f993865dc70b18f02ab11bb5012693d
2023-03-06 21:00:52 -05:00
Simon Marchi
ae61525fcf gdbsupport: ignore -Wenum-constexpr-conversion in enum-flags.h
When building with clang 16, we get:

      CXX    gdb.o
    In file included from /home/smarchi/src/binutils-gdb/gdb/gdb.c:19:
    In file included from /home/smarchi/src/binutils-gdb/gdb/defs.h:65:
    /home/smarchi/src/binutils-gdb/gdb/../gdbsupport/enum-flags.h:95:52: error: integer value -1 is outside the valid range of values [0, 15] for this enumeration type [-Wenum-constexpr-conversion]
        integer_for_size<sizeof (T), static_cast<bool>(T (-1) < T (0))>::type
                                                       ^

The error message does not make it clear in the context of which enum
flag this fails (i.e. what is T in this context), but it doesn't really
matter, we have similar warning/errors for many of them, if we let the
build go through.

clang is right that the value -1 is invalid for the enum type we cast -1
to.  However, we do need this expression in order to select an integer
type with the appropriate signedness.  That is, with the same signedness
as the underlying type of the enum.

I first wondered if that was really needed, if we couldn't use
std::underlying_type for that.  It turns out that the comment just above
says:

    /* Note that std::underlying_type<enum_type> is not what we want here,
       since that returns unsigned int even when the enum decays to signed
       int.  */

I was surprised, because std::is_signed<std::underlying_type<enum_type>>
returns the right thing.  So I tried replacing all this with
std::underlying_type, see if that would work.  Doing so causes some
build failures in unittests/enum-flags-selftests.c:

      CXX    unittests/enum-flags-selftests.o
    /home/smarchi/src/binutils-gdb/gdb/unittests/enum-flags-selftests.c:254:1: error: static assertion failed due to requirement 'gdb::is_same<selftests::enum_flags_tests::check_valid_expr254::archetype<enum_flags<s
    elftests::enum_flags_tests::RE>, selftests::enum_flags_tests::RE, enum_flags<selftests::enum_flags_tests::RE2>, selftests::enum_flags_tests::RE2, enum_flags<selftests::enum_flags_tests::URE>, selftests::enum_fla
    gs_tests::URE, int>, selftests::enum_flags_tests::check_valid_expr254::archetype<enum_flags<selftests::enum_flags_tests::RE>, selftests::enum_flags_tests::RE, enum_flags<selftests::enum_flags_tests::RE2>, selfte
    sts::enum_flags_tests::RE2, enum_flags<selftests::enum_flags_tests::URE>, selftests::enum_flags_tests::URE, unsigned int>>::value == true':
    CHECK_VALID (true,  int,  true ? EF () : EF2 ())
    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    /home/smarchi/src/binutils-gdb/gdb/unittests/enum-flags-selftests.c:91:3: note: expanded from macro 'CHECK_VALID'
      CHECK_VALID_EXPR_6 (EF, RE, EF2, RE2, UEF, URE, VALID, EXPR_TYPE, EXPR)
      ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    /home/smarchi/src/binutils-gdb/gdb/../gdbsupport/valid-expr.h:105:3: note: expanded from macro 'CHECK_VALID_EXPR_6'
      CHECK_VALID_EXPR_INT (ESC_PARENS (typename T1, typename T2,           \
      ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    /home/smarchi/src/binutils-gdb/gdb/../gdbsupport/valid-expr.h:66:3: note: expanded from macro 'CHECK_VALID_EXPR_INT'
      static_assert (gdb::is_detected_exact<archetype<TYPES, EXPR_TYPE>,    \
      ^              ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

This is a bit hard to decode, but basically enumerations have the
following funny property that they decay into a signed int, even if
their implicit underlying type is unsigned.  This code:

    enum A {};
    enum B {};

    int main() {
      std::cout << std::is_signed<std::underlying_type<A>::type>::value
                << std::endl;
      std::cout << std::is_signed<std::underlying_type<B>::type>::value
                << std::endl;
      auto result = true ? A() : B();
      std::cout << std::is_signed<decltype(result)>::value << std::endl;
    }

produces:

    0
    0
    1

So, the "CHECK_VALID" above checks that this property works for enum flags the
same way as it would if you were using their underlying enum types.  And
somehow, changing integer_for_size to use std::underlying_type breaks that.

Since the current code does what we want, and I don't see any way of doing it
differently, ignore -Wenum-constexpr-conversion around it.

Change-Id: Ibc82ae7bbdb812102ae3f1dd099fc859dc6f3cc2
2023-03-06 21:00:52 -05:00
John Baldwin
f173b2fc9d gdb.threads/next-bp-other-thread.c: Ensure child thread is started.
Use a pthread_barrier to ensure the child thread is started before
the main thread gets to the first breakpoint.
2023-03-06 16:55:22 -08:00
John Baldwin
5c1e53c99c gdb.threads/execl.c: Ensure all threads are started before execl.
Use a pthread_barrier to ensure all threads are started before
proceeding to the breakpoint where info threads output is checked.
2023-03-06 16:55:22 -08:00
John Baldwin
cf622c39ab gdb.base/catch-syscall.exp: Remove some Linux-only assumptions.
- Some OS's use a different syscall for exit().  For example, the
  BSD's use SYS_exit rather than SYS_exit_group.  Update the C source
  file and the expect script to support SYS_exit as an alternative to
  SYS_exit_group.

- The cross-arch syscall number tests are all Linux-specific with
  hardcoded syscall numbers specific to Linux kernels.  Skip these
  tests on non-Linux systems.  FreeBSD kernels for example use the
  same system call numbers on all platforms, so the test is also not
  relevant on FreeBSD.
2023-03-06 16:55:22 -08:00
John Baldwin
3c75f00adc gdb.threads/multi-create: Double the existing stack size.
Setting the stack size to 2*PTHREAD_STACK_MIN actually lowered the
stack on FreeBSD rather than raising it causing non-main threads in
the test program to overflow their stack and crash.  Double the
existing stack size rather than assuming that the initial stack size
is PTHREAD_STACK_MIN.
2023-03-06 16:55:22 -08:00
John Baldwin
3625712636 amd64-linux-tdep: Don't treat fs_base and gs_base as system registers.
These registers can be changed directly in userspace, and similar
registers to support TLS on other architectures (tpidr* on ARM and
AArch64, tp on RISC-V) are treated as general purpose registers.

Reviewed-By: Tom Tromey <tom@tromey.com>
2023-03-06 16:47:03 -08:00
John Baldwin
b1453f150c gdb.arch/amd64-gs_base.exp: Support non-Linux.
The orig_rax pseudo-register is Linux-specific and isn't relevant to
this test.  The fs_base and gs_base registers are also not treated as
system registers in other OS ABIs.  This allows the test to pass on
FreeBSD.

Reviewed-By: Tom Tromey <tom@tromey.com>
2023-03-06 16:47:03 -08:00
GDB Administrator
a06baa832c Automatic date update in version.in 2023-03-07 00:00:46 +00:00
Kévin Le Gouguec
1d6653fd3f gdb/python: Fix --disable-tui build
As of 2023-02-13 "gdb/python: deallocate tui window factories at Python
shut down" (9ae4519da9), a TUI-less build fails with:

$src/gdb/python/py-tui.c: In function ‘void gdbpy_finalize_tui()’:
$src/gdb/python/py-tui.c:621:3: error: ‘gdbpy_tui_window_maker’ has not been declared
  621 |   gdbpy_tui_window_maker::invalidate_all ();
      |   ^~~~~~~~~~~~~~~~~~~~~~

Since gdbpy_tui_window_maker is only defined under #ifdef TUI, add an
#ifdef guard in gdbpy_finalize_tui as well.
2023-03-06 17:31:57 +01:00
Tom de Vries
f69005750d [gdb/testsuite] Move gdb.base/gdb-caching-proc.exp to gdb.testsuite
Test-case gdb.base/gdb-caching-proc.exp doesn't really test gdb, but it tests
the gdb_caching_procs in the testsuite, so it belongs in gdb.testsuite rather
than gdb.base.

Move test-case gdb.base/gdb-caching-proc.exp to gdb.testsuite, renaming it to
gdb.testsuite/gdb-caching-proc-consistency.exp to not clash with
recently added gdb.testsuite/gdb-caching-proc.exp.

Tested on x86_64-linux.

Reviewed-By: Tom Tromey <tom@tromey.com>
2023-03-06 16:49:19 +01:00
Tom de Vries
71f1ab80f1 [gdb/testsuite] Allow args in gdb_caching_proc
Test-case gdb.base/morestack.exp contains:
...
require {have_compile_flag -fsplit-stack}
...
and I want to cache the result of have_compile_flag.

Currently gdb_caching_proc doesn't allow args, so I could add:
...
gdb_caching_proc have_compile_flag_fsplit_stack {
    return [have_compile_flag -fsplit-stack]
}
...
and then use that proc instead, but I find this cumbersome and
maintenance-unfriendly.

Instead, allow args in a gdb_caching_proc, such that I can simply do:
...
-proc have_compile_flag { flag } {
+gdb_caching_proc have_compile_flag { flag } {
...

Note that gdb_caching_procs with args do not work with the
gdb.base/gdb-caching-procs.exp test-case, so those procs are skipped.

Tested on x86_64-linux.

Reviewed-By: Tom Tromey <tom@tromey.com>
2023-03-06 16:49:19 +01:00
Tom de Vries
b50420fd05 [gdb/testsuite] Use regular proc syntax for gdb_caching_proc
A regular tcl proc with no args looks like:
...
proc foo {} {
     return 1
}
...
but a gdb_caching_proc deviates from that syntax by dropping the explicit no
args bit:
...
gdb_caching_proc foo {
     return 1
}
...

Make the gdb_caching_proc use the same syntax as regular procs, such that we
have instead:
...
gdb_caching_proc foo {} {
     return 1
}
...

Tested on x86_64-linux.

Reviewed-By: Tom Tromey <tom@tromey.com>
2023-03-06 16:49:19 +01:00
Tom de Vries
b24a386d75 [gdb/testsuite] Add gdb.testsuite/gdb-caching-proc.exp
Add test-case gdb.testsuite/gdb-caching-proc.exp that excercises
gdb_caching_proc.

Tested on x86_64-linux.

Reviewed-By: Tom Tromey <tom@tromey.com>
2023-03-06 16:49:19 +01:00
Tom Tromey
68ca7890dd Fix DAP stackTrace through frames without debuginfo
The DAP stackTrace implementation did not fully account for frames
without debuginfo.  Attemping this would yield a result like:

{"request_seq": 5, "type": "response", "command": "stackTrace", "success": false, "message": "'NoneType' object has no attribute 'filename'", "seq": 11}

This patch fixes the problem by adding another check for None.
2023-03-06 08:15:04 -07:00
Tom Tromey
c52e4861c6 Remove exception_catchpoint::resources_needed
exception_catchpoint::resources_needed has a FIXME comment that I
think makes this method obsolete.  Also, I note that similar
catchpoints, for example Ada catchpoints, don't have this method.
This patch removes the method.  Regression tested on x86-64 Fedora 36.
2023-03-06 08:09:17 -07:00
Tom Tromey
72ee804c92 Remove two more files in gdb "distclean"
The recent work to have gdb link via libtool means that there are a
couple more generated files in the build directory that should be
removed by "distclean".

Note that gdb can't really fully implement distclean due to the desire
to put certain generated files into the distribution.  Still, it can
get pretty close.
2023-03-06 08:03:52 -07:00
Alan Modra
a1f4d06969 macho null dereference read
The main problem here was not returning -1 from canonicalize_symtab on
an error, leaving the vector of relocs only partly initialised and one
with a null sym_ptr_ptr.

	* mach-o.c (bfd_mach_o_canonicalize_symtab): Return -1 on error,
	not 0.
	(bfd_mach_o_pre_canonicalize_one_reloc): Init sym_ptr_ptr to
	undefined section sym.
2023-03-06 20:42:01 +10:30
Alan Modra
889d15d574 PR30198, Assertion and segfault when linking x86_64 elf and coff
PR 30198
	* coff-x86_64.c (coff_amd64_reloc): Set *error_message when
	returning bfd_reloc_dangerous.  Also check that __ImageBase is
	defined before accessing h->u.def.
2023-03-06 13:11:22 +10:30
Alan Modra
d845ea8cd3 More _bfd_ecoff_locate_line sanity checks
* ecofflink.c (mk_fdrtab): Discard fdr with negative cpd.
	(lookup_line): Sanity check fdr cbLineOffset and cbLine.
	Sanity check pdr cbLineOffset.
2023-03-06 13:11:22 +10:30
Alan Modra
d919194f08 Correct odd loop in ecoff lookup_line
I can't see why this really odd looking loop was written the way it
was in commit a877f5917f, but it can result in a buffer overrun.

	* ecofflink.c (lookup_line): Don't swap in pdr at pdr_end.
2023-03-06 13:11:22 +10:30
Alan Modra
ffdfc835dd Downgrade objdump fatal errors to non-fatal
* objdump.c (slurp_symtab): Replace bfd_fatal calls with calls
	to my_bfd_nonfatal.
	(slurp_dynamic_symtab, disassemble_section): Likewise.
	(disassemble_data): Replace fatal call with non_fatal call, and
	set exit_status.  Don't error on non-existent dynamic relocs.
	Don't call bfd_fatal on bfd_canonicalize_dynamic_reloc error.
	(dump_ctf, dump_section_sframe): Replace bfd_fatal calls with
	calls to my_bfd_nonfatal and clean up memory.
	(dump_relocs_in_section): Don't call bfd_fatal on errors.
	(dump_dynamic_relocs): Likewise.
	(display_any_bfd): Make archive nesting too depp non_fatal.
2023-03-06 13:11:22 +10:30
Alan Modra
5db0367e1b Downgrade addr2line fatal errors to non-fatal
* addr2line.c (slurp_symtab): Don't exit on errors.
	(process_file): Likewise.
2023-03-06 13:11:22 +10:30
Alan Modra
86a2562b09 Downgrade nm fatal errors to non-fatal
Many of the fatal errors in nm ought to be recoverable.  This patch
downgrades most of them.  The ones that are left are most likely due
to memory allocation failures.

	* nm.c (print_symdef_entry): Don't bomb with a fatal error
	on a corrupted archive symbol table.
	(filter_symbols): Silently omit symbols that return NULL
	from bfd_minisymbol_to_symbol rather than giving a fatal
	error.
	(display_rel_file): Don't give a fatal error on
	bfd_read_minisymbols returning an error, or on not being able
	to read dynamic symbols for synth syms.
	(display_archive): Downgrade bfd_openr_next_archived_file
	error.
	(display_file): Don't bomb on a bfd_close failure.
2023-03-06 13:11:10 +10:30
Alan Modra
e3f450f393 Move nm.c cached line number info to bfd usrdata
Replace the static variables used by nm to cache line number info
with a struct attached to the bfd.  Cleaner, and it avoids any concern
that lineno_cache_bfd is somehow left pointing at memory for a closed
bfd and that memory is later reused for another bfd, not that I think
this is possible.  Also don't bomb via bfd_fatal on errors getting
the line number info, just omit the line numbers.

	* nm.c (struct lineno_cache): Rename from get_relocs_info.
	Add symcount.
	(lineno_cache_bfd, lineno_cache_rel_bfd): Delete.
	(get_relocs): Adjust for struct rename.  Don't call bfd_fatal
	on errors.
	(free_lineno_cache): New function.
	(print_symbol): Use lineno_cache in place of statics.  Don't
	call bfd_fatal on errors reading symbols, just omit the line
	info.
	(display_archive, display_file): Call free_lineno_cache.
2023-03-06 10:42:36 +10:30
Alan Modra
a734d906cc Correct objdump command line error handling
bfd_nonfatal is used when a bfd error is to be printed.  That's not
the case for command line errors.

	* objdump.c (nonfatal): Rename to my_bfd_nonfatal.
	(main): Use non_fatal and call usage on unrecognized arg errors.
	Don't set exit_status when calling usage.
2023-03-06 10:42:22 +10:30
GDB Administrator
ec95986dc2 Automatic date update in version.in 2023-03-06 00:00:27 +00:00
GDB Administrator
fd9cdf3000 Automatic date update in version.in 2023-03-05 00:00:29 +00:00
GDB Administrator
d1702fea87 Automatic date update in version.in 2023-03-04 00:00:31 +00:00
Simon Marchi
803392dc5b gdb/testsuite: use kill -FOO instead of kill -SIGFOO
When running gdb.base/bg-exec-sigint-bp-cond.exp when SHELL is dash,
rather than bash, I get:

    c&^M
    Continuing.^M
    (gdb) sh: 1: kill: Illegal option -S^M
    ^M
    Breakpoint 2, foo () at /home/jenkins/smarchi/binutils-gdb/build/gdb/testsuite/../../../gdb/testsuite/gdb.base/bg-exec-sigint-bp-cond.c:23^M
    23        return 0;^M
    FAIL: gdb.base/bg-exec-sigint-bp-cond.exp: no force memory write: SIGINT does not interrupt background execution (timeout)

This is because it uses the kill command built-in the dash shell, and
using the SIG prefix with kill does not work with dash's kill.  The
difference is listed in the documentation for bash's POSIX-correct mode
[1]:

    The kill builtin does not accept signal names with a ‘SIG’ prefix.

Replace SIGINT with INT in that test.

By grepping, I found two other instances (gdb.base/sigwinch-notty.exp
and gdb.threads/detach-step-over.exp).  Those were not problematic on my
system though.  Since they are done through remote_exec, they don't go
through the shell and therefore invoke /bin/kill.  On my Arch Linux,
it's:

    $ /bin/kill --version
    kill from util-linux 2.38.1 (with: sigqueue, pidfd)

and on my Ubuntu:

    $ /bin/kill --version
    kill from procps-ng 3.3.17

These two implementations accept "-SIGINT".  But according to the POSIX
spec [2], the kill utility should recognize the signal name without the
SIG prefix (if it recognizes them with the SIG prefix, it's an
extension):

    -s  signal_name
        Specify the signal to send, using one of the symbolic names defined
	in the <signal.h> header. Values of signal_name shall be recognized
	in a case-independent fashion, without the SIG prefix. In addition,
	the symbolic name 0 shall be recognized, representing the signal
	value zero. The corresponding signal shall be sent instead of SIGTERM.
    -signal_name
        [XSI] [Option Start]
        Equivalent to -s signal_name. [Option End]

So, just in case some /bin/kill implementation happens to not recognize
the SIG prefixes, change these two other calls to remove the SIG
prefix.

[1] https://www.gnu.org/software/bash/manual/html_node/Bash-POSIX-Mode.html
[2] https://pubs.opengroup.org/onlinepubs/9699919799/utilities/kill.html

Change-Id: I81ccedd6c9428ab63b9261813f1905a18941f8da
Reviewed-By: Tom Tromey <tom@tromey.com>
2023-03-03 14:13:00 -05:00
Tom de Vries
9c2c346137 [gdb/testsuite] Use set always-read-ctf on instead of --strip-debug
Use "set always-read-ctf on" instead of --strip-debug in the ctf test-cases.

Tested on x86_64-linux.
2023-03-03 16:51:57 +01:00
Tom Tromey
c35b7b2252 Update expected results in long_long.exp
Simon pointed out that the recent patch to add half-float support to
'x/f' caused a couple of regressions in long_long.exp.  This patch
fixes these by updating the expected results.
2023-03-03 08:05:41 -07:00
Nick Clifton
adbe951fc9 Prevent the ASCII linker script directive from generating huge amounts of padding if the size expression is not a constant.
PR 30193 * ldgram.y (ASCII): Fail if the size is not a constant.
2023-03-03 13:56:36 +00:00
Andrew Burgess
6a208145d2 gdb/python: replace strlen call with std::string::size call
Small cleanup to use std::string::size instead of calling strlen on
the result of std::string::c_str.

Should be no user visible changes after this call.
2023-03-03 09:56:21 +00:00
Jan Beulich
67748abf53 x86: use swap_2_operands() in build_vex_prefix()
Open-coding part of what may eventually be needed is somewhat risky.
Let's use the function we have, taking care of all pieces of data which
may need swapping, no matter that
- right now i.flags[] and i.reloc[] aren't relevant here (yet),
- EVEX masking and embedded broadcast aren't applicable.
2023-03-03 08:46:41 +01:00
Jan Beulich
43da3d648e x86: drop redundant calculation of EVEX broadcast size
In commit a5748e0d8c ("x86/Intel: allow MASM representation of
embedded broadcast") I replaced the calculation of i.broadcast.bytes in
check_VecOperands() not paying attention to the immediately following
call to get_broadcast_bytes() doing exactly that (again) first thing.
2023-03-03 08:46:13 +01:00
Jan Beulich
e9339bee56 gas: default .debug section compression method adjustments
While commit b0c295e1b8 ("add --enable-default-compressed-debug-
sections-algorithm configure option") adjusted flag_compress_debug's
initializer, it didn't alter the default used when the command line
option was specified with an (optional!) argument. This rendered help
text inconsistent with actual behavior in certain configurations.

As to help text - the default reported there clearly shouldn't be
affected by a possible earlier --compress-debug-sections= option, so
flag_compress_debug can't be used when emitting usage information.
2023-03-03 08:45:54 +01:00
Jan Beulich
81588de012 x86: avoid .byte in testcases where possible
In the course of using the upcoming .insn directive to eliminate various
.byte uses in testcases I've come across these, which needlessly use
more .byte than necessary even without the availability of .insn.
2023-03-03 08:45:12 +01:00
Alan Modra
945efa5c53 Tidy type handling in binutils/rdcoff.c
There isn't really any good reason for code in rdcoff.c to distinguish
between "basic" types and any other type.  This patch dispenses with
the array reserved for basic types and instead handles all types using
coff_get_slot, simplifying the code.

	* rdcoff.c (struct coff_types, coff_slots): Merge.  Delete
	coff_slots.
	(T_MAX): Delete.
	(parse_coff_base_type): Use coff_get_slot to store baseic types.
	(coff_get_slot, parse_coff_type, parse_coff_base_type),
	(parse_coff_struct_type, parse_coff_enum_type),
	(parse_coff_symbol, parse_coff): Pass types as coff_types**.
2023-03-03 12:31:24 +10:30
Alan Modra
de357ff4e4 binutils coff type list
As for commit 72d225ef9c, handle type numbers starting anywhere.

	PR 17512
	* rdcoff.c (struct coff_slots): Add base_index.
	(coff_get_slot): Delete pr17512 excessively large slot check.
	Don't allocate entire array from 0 to type number, allocate a
	sparse array.
2023-03-03 10:35:54 +10:30
GDB Administrator
425ec1add7 Automatic date update in version.in 2023-03-03 00:00:34 +00:00
Simon Marchi
344642355c gdb: fix -Wmaybe-uninitialized warning in value.c
Since commit 11470e70ea ("gdb: store internalvars in an std::map"), bulding
with -O2, with g++ 11.3.0 on Ubuntu 22.04, I see:

      CXX    value.o
    In constructor ‘internalvar::internalvar(internalvar&&)’,
        inlined from ‘constexpr std::pair<_T1, _T2>::pair(_U1&&, _U2&&) [with _U1 = const char*&; _U2 = internalvar; typename std::enable_if<(std::_PCC<true, _T1, _T2>::_MoveConstructiblePair<_U1, _U2>() && std::_PCC<true, _T1, _T2>::_ImplicitlyMoveConvertiblePair<_U1, _U2>()), bool>::type <anonymous> = true; _T1 = const char*; _T2 = internalvar]’ at /usr/include/c++/11/bits/stl_pair.h:353:35,
        inlined from ‘constexpr std::pair<typename std::__strip_reference_wrapper<typename std::decay<_Tp>::type>::__type, typename std::__strip_reference_wrapper<typename std::decay<_Tp2>::type>::__type> std::make_pair(_T1&&, _T2&&) [with _T1 = const char*&; _T2 = internalvar]’ at /usr/include/c++/11/bits/stl_pair.h:572:72,
        inlined from ‘internalvar* create_internalvar(const char*)’ at /home/smarchi/src/binutils-gdb/gdb/value.c:1933:52:
    /home/smarchi/src/binutils-gdb/gdb/value.c:1831:8: warning: ‘<unnamed>.internalvar::u’ may be used uninitialized [-Wmaybe-uninitialized]
     1831 | struct internalvar
          |        ^~~~~~~~~~~
    /home/smarchi/src/binutils-gdb/gdb/value.c: In function ‘internalvar* create_internalvar(const char*)’:
    /home/smarchi/src/binutils-gdb/gdb/value.c:1933:76: note: ‘<anonymous>’ declared here
     1933 |   auto pair = internalvars.emplace (std::make_pair (name, internalvar (name)));
          |                                                                            ^

This is because the union field internalvar::u is not initialized when
constructing the temporary internalvar object above.  That object is then used
for move-construction, and the (implicit) move constructor copies the
uninitialized bytes of field u over from the temporary object to the new
internalvar object.  The compiler therefore complains that we use uninitialized
bytes.  I don't think it's really a problem, because the internalvar object is
in the `kind == INTERNALVAR_VOID` state, in which the contents of the union is
irrelevant.  Still, mute the warning by default-initializing the union.

Change-Id: I70c392842f35255f50d8e63f4099cb6685366fb7
Reviewed-By: Tom Tromey <tom@tromey.com>
2023-03-02 16:02:50 -05:00
Tom Tromey
70728e1d39 Handle half-float in 'x' command
Using 'x/hf' should print bytes as float16, but instead it currently
prints as an integer.  I tracked this down to a missing case in
float_type_from_length.

Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=30161
Approved-By: Simon Marchi <simon.marchi@efficios.com>
2023-03-02 08:49:37 -07:00
Tom Tromey
2641391a87 Fix some value comments
I noticed a very stale comment in valarith.c.  This patch fixes a few
comments in this area.

Reviewed-By: Andrew Burgess <aburgess@redhat.com>
2023-03-02 08:15:23 -07:00
Hui Li
78c7a5288e gdb: LoongArch: Add support for static data member in struct
As described in C++ reference [1], static data members are not part
of objects of a given class type. Modified compute_struct_member ()
to ignore static data member so that we can get the expected result.

loongson@linux:~$ cat test.c
#include<stdio.h>
struct struct_01 { static unsigned a; float b;};
unsigned struct_01::a = 66;
struct struct_01 struct_01_val = { 99.00 };
int check_arg_struct(struct struct_01 arg)
  {
    printf("arg.a = %d\n", arg.a);
    printf("arg.b = %f\n", arg.b);
    return 0;
  }
int main()
  {
    check_arg_struct(struct_01_val);
    return 0;
  }
loongson@linux:~$ g++ -g test.c -o test++
loongson@linux:~$ gdb test++

Without this patch:
...
(gdb) start
...
(gdb) p check_arg_struct(struct_01_val)
arg.a = 66
arg.b = 0.000000
$1 = 0

With this patch:
...
(gdb) start
...
(gdb) p check_arg_struct(struct_01_val)
arg.a = 66
arg.b = 99.000000
$1 = 0

[1] https://learn.microsoft.com/en-us/cpp/cpp/static-members-cpp?view=msvc-170

Signed-off-by: Hui Li <lihui@loongson.cn>
Reviewed-By: Tom Tromey <tom@tromey.com>
Signed-off-by: Tiezhu Yang <yangtiezhu@loongson.cn>
2023-03-02 22:32:20 +08:00
Alan Modra
281309f3c8 Don't write zeros to a gap in the output file
Writing out zeros is counterproductive if a file system supports
sparse files.  A very large gap need not take much actual disk space,
but it usually will if zeros are written.

memory_bseek also supports not writing out zeros in a gap.

	* elf.c (write_zeros): Delete.
	(assign_file_positions_for_load_sections): Don't call write_zeros.
	Comment.
2023-03-02 21:17:49 +10:30