45961 Commits

Author SHA1 Message Date
Sergio Durigan Junior
2bf3b79d05 Search for DWZ files in debug-file-directories as well
When Debian (and Ubuntu) builds its binaries, it (still) doesn't use
dwz's "--relative" option.  This causes their debuginfo files to
carry a .gnu_debugaltlink section containing a full pathname to the
DWZ alt debug file, like this:

  $ readelf -wk /usr/bin/cat
  Contents of the .gnu_debugaltlink section:

    Separate debug info file: /usr/lib/debug/.dwz/x86_64-linux-gnu/coreutils.debug
    Build-ID (0x14 bytes):
   ee 76 5d 71 97 37 ce 46 99 44 32 bb e8 a9 1a ef 99 96 88 db

  Contents of the .gnu_debuglink section:

    Separate debug info file: 06d3bee37b8c7e67b31cb2689cb351102ae73b.debug
    CRC value: 0x53267655

This usually works OK, because most of the debuginfo files installed
via apt will be present in /usr/lib/debug anyway.  However, imagine
the following scenario:

- You are using /usr/bin/cat, it crashes on you and generates a
  corefile.

- You don't want/need to "apt install" the debuginfo file for
  coreutils from the repositories.  Instead, you already have the
  debuginfo files in a separate directory (e.g., $HOME/dbgsym).

- You start GDB and "set debug-file-directory $HOME/dbgsym/usr/lib/debug".
  You then get the following message:

  $ gdb -ex 'set debug-file-directory ./dbgsym/usr/lib/debug' -ex 'file /bin/cat' -ex 'core-file ./cat.core'
  GNU gdb (Ubuntu 10.1-0ubuntu1) 10.1
  ...
  Reading symbols from /bin/cat...
  Reading symbols from /home/sergio/gdb/dbgsym/usr/lib/debug/.build-id/bc/06d3bee37b8c7e67b31cb2689cb351102ae73b.debug...
  could not find '.gnu_debugaltlink' file for /home/sergio/gdb/dbgsym/usr/lib/debug/.build-id/bc/06d3bee37b8c7e67b31cb2689cb351102ae73b.debug

This error happens because GDB is trying to locate the build-id
link (inside /home/sergio/gdb/dbgsym/usr/lib/debug/.build-id) for the
DWZ alt debug file, which doesn't exist.  Arguably, this is a problem
with how dh_dwz works in Debian, and it's something I'm also planning
to tackle.  But, back at the problem at hand.

Besides not being able to find the build-id link in the directory
mentioned above, GDB also tried to open the DWZ alt file using its
filename.  The problem here is that, since we don't have the distro's
debuginfo installed, it can't find anything under /usr/lib/debug that
satisfies it.

It occurred to me that a good way to workaround this problem is to
actually try to locate the DWZ alt debug file inside the
debug-file-directories (that were likely provided by the user).  So
this is what the proposed patch does.

The idea here is simple: get the filename extracted from the
.gnu_debugaltlink section, and manipulate it in order to replace the
initial part of the path (everything before "/.dwz/") by whatever
debug-file-directories the user might have provided.

I talked with Mark Wielaard and he agrees this is a sensible approach.
In fact, apparently this is something that eu-readelf also does.

I regtested this code, and no regressions were found.

2020-12-01  Sergio Durigan Junior  <sergiodj@sergiodj.net>

	* dwarf2/read.c (dwz_search_other_debugdirs): New function.
	(dwarf2_get_dwz_file): Convert 'filename' to a
	std::string.  Use dwz_search_other_debugdirs to search for DWZ
	files in the debug-file-directories provided by the user as well.
2020-12-01 22:03:18 -05:00
Tom Tromey
77bf7e9911 Use new+delete for struct expression
In another series I'm working on, it is necessary to manage
"struct expression" with new and delete.  Because the patch is
straightforward and could be extracted, I've done so here.

gdb/ChangeLog
2020-12-01  Tom Tromey  <tom@tromey.com>

	* parse.c (expr_builder::expr_builder): Initialize expout.
	(expr_builder::release): Use expression::resize.
	(expression::expression, expression::~expression)
	(expression::resize): New methods.
	(write_exp_elt): Use expression::resize.
	(prefixify_expression): Update.
	(increase_expout_size): Use expression::resize.
	* expression.h (struct expression): Add constructor, destructor.
	<resize>: New method.
	(expression_up): Change type.
2020-12-01 17:22:05 -07:00
Simon Marchi
f55a9a37d8 gdb/testsuite: fix indentation in gdb.threads/non-ldr-exc-1.exp
gdb/testsuite/ChangeLog:

	* gdb.threads/non-ldr-exc-1.exp: Fix indentation.

Change-Id: I02ba8a518aae9cb67106d09bef92968a7078e91e
2020-12-01 16:29:45 -05:00
Simon Marchi
0a6155a072 gdb/testsuite: use foreach_with_prefix in gdb.threads/non-ldr-exc-*.exp
Replace the manual with_test_prefix in the do_test proc with using
foreach_with_prefix at the top-level.  This helps reduce the indentation
level of the code a bit, and makes the test names in sync with the
variable names used in the code.

gdb/testsuite/ChangeLog:

	* gdb.threads/non-ldr-exc-1.exp: Use foreach_with_prefix.
	(do_test): Don't use with_test_prefix.
	* gdb.threads/non-ldr-exc-2.exp: Use foreach_with_prefix.
	(do_test): Don't use with_test_prefix.
	* gdb.threads/non-ldr-exc-3.exp: Use foreach_with_prefix.
	(do_test): Don't use with_test_prefix.
	* gdb.threads/non-ldr-exc-4.exp: Use foreach_with_prefix.
	(do_test): Don't use with_test_prefix.

Change-Id: I3af1df2eee1a8add427a67b6048bb6dede41cbeb
2020-12-01 15:08:06 -05:00
Rogerio Alves
539d71e89a PowerPC remove 512 bytes region limit if 2nd DAWR is avaliable.
Power 10 introduces the 2nd DAWR (second watchpoint) and also removed
a restriction that limit the watch region to 512 bytes.

2020-11-08  Rogerio A. Cardoso  <rcardoso@linux.ibm.com>

/gdb

	* ppc-linux-nat.c: (PPC_DEBUG_FEATURE_DATA_BP_ARCH_31): New define.
	(region_ok_for_hw_watchpoint): Check if 2nd DAWR is avaliable before
	set region.
2020-12-01 16:53:38 -03:00
Rogerio Alves
0ae4576980 Add missing ChangeLog entry. 2020-12-01 16:44:31 -03:00
Simon Marchi
4d56d64a85 gdb/testsuite: fix comment in gdb.threads/non-ldr-exit.exp
Maybe there's something I don't understand in that test, but the comment
seems wrong.  It checks what happens when the non-leader thread does an
exit, not the leader.

gdb/testsuite/ChangeLog:

	* gdb.threads/non-ldr-exit.exp: Fix comment.

Change-Id: I35c96a70c097fa9529737874f54f3f78036008a4
2020-12-01 10:31:19 -05:00
Andrew Burgess
54e75f291e gdbsupport/tdesc: print enum fields using 'evalue' syntax
Currently when printing an XML description GDB prints enum values like
this:

  <enum id="levels_type" size="4">
    <field name="low" start="0"/>
    <field name="high" start="1"/>
  </enum>

This is incorrect, and is most likely a copy and paste error with the
struct and flags printing code.  The correct syntax is:

  <enum id="levels_type" size="4">
    <evalue name="low" value="0"/>
    <evalue name="high" value="1"/>
  </enum>

A test is included to cover this functionality.

gdb/testsuite/ChangeLog:

	* gdb.xml/maint-xml-dump-03.xml: New file.

gdbsupport/ChangeLog:

	* tdesc.cc (print_xml_feature::visit): Print enum fields using
	'evalue' syntax.
2020-12-01 11:22:24 +00:00
Tom de Vries
c18d491fbd Revert accidental empty commits
Revert empty commits:
- "[gdb] Don't return non-existing path in debuginfod_source_query"
  commit 59404f827cb1134b68dbf228d380ff86d15c9f01
- "[gdb/testsuite] Fix minimal encodings KPASSes"
  commit 61049d1ee59905589b2ad3f8140a2582e01add7a
2020-11-30 13:59:57 +01:00
Tom de Vries
7ce05d212d [gdb/symtab] Fix gdb.base/vla-optimized-out.exp with clang
Consider test-case gdb.base/vla-optimized-out.exp, compiled using clang-10.

GDB fails to get the size of the vla a:
...
(gdb) p sizeof (a)^M
Cannot access memory at address 0x6^M
(gdb) FAIL: gdb.base/vla-optimized-out.exp: o1: printed size of \
  optimized out vla
...

The relevant DWARF looks like this: the variable a:
...
 <2><12b>: Abbrev Number: 5 (DW_TAG_variable)
    <12c>   DW_AT_name        : a
    <132>   DW_AT_type        : <0x189>
...
has type:
...
 <1><189>: Abbrev Number: 10 (DW_TAG_array_type)
    <18a>   DW_AT_type        : <0x198>
 <2><18e>: Abbrev Number: 11 (DW_TAG_subrange_type)
    <18f>   DW_AT_type        : <0x19f>
    <193>   DW_AT_count       : <0x117>
...
with the count attribute equated to the value of this artificial variable:
...
 <2><117>: Abbrev Number: 4 (DW_TAG_variable)
    <118>   DW_AT_location    : 10 byte block: 75 1 10 ff ff ff ff f 1a 9f \
              (DW_OP_breg5 (rdi): 1;
	       DW_OP_constu: 4294967295;
	       DW_OP_and;
	       DW_OP_stack_value)
    <123>   DW_AT_name        : __vla_expr0
    <127>   DW_AT_type        : <0x182>
    <12b>   DW_AT_artificial  : 1
...

The location description of the variable is terminated with DW_OP_stack_value,
which according to the DWARF spec means that "the DWARF expression represents
the actual value of the object, rather than its location".

However, in attr_to_dynamic_prop, we set is_reference to true:
...
               baton->locexpr.is_reference = true;
...
and use it in dwarf2_evaluate_property to dereference the value of the DWARF
expression, which causes the access to memory at address 0x6.

Fix this by ignoring the baton->locexpr.is_reference == true setting if
the expression evaluation has ctx.location == DWARF_VALUE_STACK, such that we
get:
...
(gdb) p sizeof (a)^M
$2 = 6^M
(gdb) PASS: gdb.base/vla-optimized-out.exp: o1: printed size of \
  optimized out vla
...

Tested on x86_64-linux, with gcc.

Tested the following test-cases (the ones mentioned in PR26905) on
x86_64-linux with clang-10:
- gdb.base/vla-optimized-out.exp
- gdb.base/vla-ptr.exp
- gdb.mi/mi-vla-c99

gdb/ChangeLog:

2020-11-30  Tom de Vries  <tdevries@suse.de>

	PR symtab/26905
	* dwarf2/loc.c (dwarf2_locexpr_baton_eval): Add and handle
	is_reference parameter.
	(dwarf2_evaluate_property): Update dwarf2_locexpr_baton_eval call.

gdb/testsuite/ChangeLog:

2020-11-30  Tom de Vries  <tdevries@suse.de>

	PR symtab/26905
	* gdb.dwarf2/count.exp: Remove kfails.
2020-11-30 13:50:26 +01:00
Tom de Vries
61049d1ee5 [gdb/testsuite] Fix minimal encodings KPASSes
With current master I see a couple of KPASSes:
...
KPASS: gdb.ada/enum_idx_packed.exp: scenario=minimal: ptype small \
  (PRMS minimal encodings)
  ...
KPASS: gdb.ada/mod_from_name.exp: scenario=minimal: print xp \
  (PRMS minimal encodings)
KPASS: gdb.ada/pckd_arr_ren.exp: scenario=minimal: print var \
  (PRMS minimal encodings)
...

The corresponding setup_kfail is called for everything before gnat 11.

However, the test-cases also PASS for me with gnat-4.8, gnat-7.5.0 and
gnat-8.4.0.

Fix the KPASSes by limiting the setup_kfail to gnat 9 and 10.

Tested on x86_64-linux.

gdb/testsuite/ChangeLog:

2020-11-16  Tom de Vries  <tdevries@suse.de>

	* gdb.ada/enum_idx_packed.exp: Limit setup_kfail to gnat 9 and 10.
	* gdb.ada/mod_from_name.exp: Same.
	* gdb.ada/pckd_arr_ren.exp: Same.
2020-11-30 13:44:55 +01:00
Tom de Vries
59404f827c [gdb] Don't return non-existing path in debuginfod_source_query
When setting env var DEBUGINFOD_URLS to " " and running the testsuite, we run
into these regressions:
...
FAIL: gdb.base/list-missing-source.exp: info source
FAIL: gdb.base/source-dir.exp: info source before setting directory search list
...

Setting var DEBUGINFOD_URLS to " " allows the debuginfod query function
debuginfod_source_query to get past its early exit.

The function debuginfod_source_query is documented as: "If the file is
successfully retrieved, its path on the local machine is stored in DESTNAME".

However, in case we get back -ENOENT from libdebuginfod, we still set
DESTNAME:
....
  if (fd.get () < 0 && fd.get () != -ENOENT)
    printf_filtered (_("Download failed: %s.  Continuing without source file %ps.\n"),
                     safe_strerror (-fd.get ()),
                     styled_string (file_name_style.style (),  srcpath));
  else
    *destname = make_unique_xstrdup (srcpath);

  return fd;
...

Fix this by making debuginfod_source_query fit it's documentation and only
setting DESTNAME when successfully retrieving a file.  Likewise in
debuginfod_debuginfo_query.

gdb/ChangeLog:

2020-11-16  Tom de Vries  <tdevries@suse.de>

	* debuginfod-support.c (debuginfod_source_query)
	(debuginfod_debuginfo_query): Only set DESTNAME if successful.
2020-11-30 13:44:55 +01:00
Tom Tromey
88b91969e1 Remove per-language op_name functions
enum exp_opcode is created from all the .def files, but then each
language is required to implement its own op_name function to turn an
enum value to a string.  This seemed over-complicated to me, and this
patch removes the per-language functions in favor of simply using the
.def names for all languages.  Note that op_name is only used for
dumping expressions, which is a maintainer/debug feature.
Furthermore, I don't think there was any case where the .def name and
the string name differed.

gdb/ChangeLog
2020-11-30  Tom Tromey  <tom@tromey.com>

	* rust-lang.c (rust_op_name): Remove.
	(exp_descriptor_rust): Update.
	* parser-defs.h (op_name_standard): Don't declare.
	(struct exp_descriptor) <op_name>: Remove.
	* parse.c (exp_descriptor_standard): Update.
	* opencl-lang.c (exp_descriptor_opencl): Update.
	* m2-lang.c (m2_language::exp_descriptor_modula2): Update.
	* f-lang.c (op_name_f): Remove.
	(f_language::exp_descriptor_tab): Update.
	* expression.h (op_name): Update.
	* expprint.c (op_name): Rewrite.
	(op_name_standard): Remove.
	(dump_raw_expression, dump_subexp): Update.
	* c-lang.c (exp_descriptor_c): Update.
	* ax-gdb.c (gen_expr): Update.
	* ada-lang.c (ada_op_name): Remove.
	(ada_exp_descriptor): Update.
2020-11-30 01:37:10 -07:00
Tom Tromey
1cd49c43f3 Remove some dead code from evaluate_subexp_standard
I noticed that in the OP_ARRAY case in evaluate_subexp_standard,
"index_pc" is read but never set.  This dead code then guards the only
call to init_array_element, so this can be removed as well.

gdb/ChangeLog
2020-11-30  Tom Tromey  <tom@tromey.com>

	* eval.c (init_array_element): Remove.
	(evaluate_subexp_standard) <OP_ARRAY>: Remove "index_pc".
2020-11-30 01:24:57 -07:00
Hannes Domani
9f1212394f Fix Value.format_string docu for static members argument
The argument is called static_members, not static_fields.

gdb/doc/ChangeLog:

2020-11-29  Hannes Domani  <ssbssa@yahoo.de>

	PR python/26974
	* python.texi: Fix docu for static members argument.
2020-11-29 19:07:30 +01:00
Hannes Domani
96fb90861a Don't delete the locator win info
The locator win info is special because it is static, all the others are
created dynamically.

gdb/ChangeLog:

2020-11-29  Hannes Domani  <ssbssa@yahoo.de>

	PR tui/26973
	* tui/tui-layout.c (tui_apply_current_layout): Don't delete the
	static locator win info.
2020-11-29 18:47:38 +01:00
Alex Richardson
b413232211 GDB: Fix detection of ELF support when configuring with -Werror=implicit-function-declaration
I am getting

    I'm sorry, Dave, I can't do that.  Symbol format `elf64-littleriscv' unknown.

errors after updating from GDB 8.3 to 10.  Bisecting showed that since
commit 1ff6de031241 ("bfd, ld: add CTF section linking"), bfd.h depends
on strncmp() being present, so configuring with
-Werror=implicit-function-declaration results in the check for ELF
support in BFD failing:

    .../gdb/gdb/../bfd/elf-bfd.h: In function 'bfd_section_is_ctf':
    .../gdb/gdb/../bfd/elf-bfd.h:3086:10: error: implicit declaration of function 'strncmp' [-Werror=implicit-function-declaration]
       return strncmp (name, ".ctf", 4) == 0 && (name[4] == 0 || name[4] == '.');

gdb/ChangeLog:

	* acincludde.m4 (GDB_AC_CHECK_BFD): Include string.h in the test
	program.

Change-Id: Iec5e21d454c2a544c44d65e23cfde552c424c18e
2020-11-28 11:45:16 -05:00
Andrew Burgess
3df8c6afdd gdb: fix potentially uninitialised variable
In commit:

  commit 037d7135de575c9e0c20e9158c105979bfee339c
  Date:   Mon Nov 16 11:36:56 2020 +0000

      gdb: improve command completion for 'print', 'x', and 'display'

A potential use of an uninitialised variable was introduced.  This is
fixed in this commit.

Previously when analysing /FMT strings for tab completion we
considered two possibilities, either the user has typed '/', or the
user has typed '/' followed by an alpha-numeric character, as these
are the only valid FMT string characters.

This meant that if the user type, for example '/@' and then tried to
tab complete gdb would use an uninitialised variable.

Currently only the first character after the '/' is checked to see if
it is alpha-numeric, so if a user typed '/x@@' then gdb would be happy
to treat this as a FMT string.

Given the goal of this change was primarily to allow tab completion of
symbols later in the command when a /FMT was used then I decided to
just make the /FMT skipping less smart.  Now any characters after the
'/' up to the first white space, will be treated as a FMT string.

gdb/ChangeLog:

	* printcmd.c (skip_over_slash_fmt): Reorder code to ensure in_fmt
	is always initialized.
2020-11-27 14:55:55 +00:00
Rogerio Alves
b1eea24024 Add Rogerio Alves to gdb/MAINTAINERS.
gdb/Changelog
2020-11-26  Rogerio Alves <rcardoso@linux.ibm.com>
	* MAINTAINERS (Write After Approval): Add myself.
2020-11-27 11:41:43 -03:00
Przemyslaw Wirkus
239ca5e497 gdb/aarch64: Add named flags for FPCR and FPSR registers
This patch updates FPCR (Floating-point Control Register) and FPSR
(Floating-point Status Register) named fields in AArch64. For detailed
description of named register FPCR and FPSR bit fields see [1] and [2].

Please not that bit fields FIZ, AH and NEP (bits 0, 1 and 2 respectively) in
FPCR are defined starting from Armv8.7 architecture.

[1]: https://developer.arm.com/docs/ddi0595/i/aarch64-system-registers/fpcr
[2]: https://developer.arm.com/docs/ddi0595/i/aarch64-system-registers/fpsr

Example:
>>> info all-registers fpsr
fpsr           0x10                [ IXC ]
>>> info all-registers fpcr
fpcr           0x0                 [ RMode=0 ]
2020-11-26 12:11:14 +00:00
Tom Tromey
cbfa382abb Remove two unnecessary variables from evaluate_subexp_standard
I noticed a couple of spots in evaluate_subexp_standard that looked
like:

    value *result;
    result = something;
    return result;

This patch simplifies these spots to a simple "return".

gdb/ChangeLog
2020-11-25  Tom Tromey  <tom@tromey.com>

	* eval.c (evaluate_subexp_standard): Remove unnecessary
	variables.
2020-11-25 10:19:40 -07:00
Tom Tromey
af30c400ea Do not include parser-defs.h from c-lang.h
While working on another series, I noticed that c-lang.h does not need
to include parser-defs.h.  This patch makes this change, and fixes up
the two .c files that needed this include.  Tested by rebuilding.

gdb/ChangeLog
2020-11-25  Tom Tromey  <tom@tromey.com>

	* d-lang.c: Include parser-defs.h.
	* rust-lang.c: Include parser-defs.h.
	* c-lang.h: Do not include parser-defs.h.
2020-11-25 10:10:11 -07:00
Simon Marchi
1c64f6cbcf gdb: remove struct cached_reg typedef
Since we are in C++, this typedef is no longer necessary, we can just
refer to the struct name directly.

gdb/ChangeLog:

	* regcache.h (struct cached_reg): Remove typedef.

Change-Id: I0168b5a9cf88e9b962521760c7e2d0e6f0b52cdf
2020-11-24 10:30:37 -05:00
Tankut Baris Aktemur
50757f95a8 gdb/testsuite: do not hard-code location indices in condbreak-multi-context.exp
Breakpoint locations are sorted according to their addresses.  The
addresses are determined by how the compiler emits the code.
Therefore, we may have a different order of locations depending on the
compiler we use.  To make the gdb.base/condbreak-multi-context.exp
test flexible enough for different compilers' output, do not hard-code
location indices.

Tested with GCC and Clang.

gdb/testsuite/ChangeLog:
2020-11-24  Tankut Baris Aktemur  <tankut.baris.aktemur@intel.com>

	* gdb.base/condbreak-multi-context.exp: Do not hard-code location
	indices.
2020-11-24 09:57:31 +01:00
Joel Brobecker
2c20a6018c gdb/README: Fix the URL of the MPFR website (now https).
gdb/ChangeLog:

        * README: Fix the URL of the MPFR library.
2020-11-24 07:10:06 +04:00
Joel Brobecker
c609df6474 gdb/README: Document the --with-libgmp-prefix configure option
gdb/ChangeLog:

        * README: Document the --with-libgmp-prefix configure option.
2020-11-24 07:09:23 +04:00
Joel Brobecker
fa123c3281 gdb/NEWS: Document that GDB now supports DWARF-based fixed point types
gdb/ChangeLog:

        * NEWS: Add entry documenting support for DWARF-based fixed
        point types.
2020-11-24 07:08:42 +04:00
Joel Brobecker
0fb8bb022e gdb/NEWS: Document that building GDB now requires GMP
gdb/ChangeLog:

        * NEWS: Document that building GDB now requires GMP.
2020-11-24 07:08:05 +04:00
Joel Brobecker
4afa9fd9b0 Add TYPE_CODE_FIXED_POINT handling in print_type_scalar
This commit enhances print_type_scalar to include support for
TYPE_CODE_FIXED_POINT. This way, any language falling back to
this function for printing the description of some types
also gets basic ptype support for fixed point types as well.

This fixes a couple of XFAILs in gdb.dwarf2/dw2-fixed-point.exp.

gdb/ChangeLog:

        * typeprint.c (print_type_scalar): Add handling of
        TYPE_CODE_FIXED_POINT.

gdb/testsuite/ChangeLog:

        * gdb.dwarf2/dw2-fixed-point.exp: Fix the expected output of
        the "ptype pck__fp1_range_var" test for the module-2 and pascal
        languages.  Remove the associated setup_xfail.
2020-11-23 22:03:36 -05:00
Joel Brobecker
af619ce989 valarith.c: Replace INIT_VAL_WITH_FIXED_POINT_VAL macro by lambda
gdb/ChangeLog (Simon Marchi  <simark@simark.ca>):

        * valarith.c (fixed_point_binop): Replace the
        INIT_VAL_WITH_FIXED_POINT_VAL macro by a lambda.  Update all
        users accordingly.
2020-11-23 21:50:29 -05:00
Joel Brobecker
e6fcee3a73 Make function fixed_point_scaling_factor a method of struct type
This logically connects this function to the object it inspects.

gdb/ChangeLog:

        * gdbtypes.h (struct type) <fixed_point_scaling_factor>: New method,
        replacing fixed_point_scaling_factor.  All callers updated
        throughout this project.
        (fixed_point_scaling_factor): Delete declaration.
        * gdbtypes.c (type::fixed_point_scaling_factor): Replaces
        fixed_point_scaling_factor.  Adjust implementation accordingly.
2020-11-23 21:49:13 -05:00
Joel Brobecker
d19937a74c Make fixed_point_type_base_type a method of struct type
As suggested by Simon, to logically connect this function to
the object it inspects.

Note that, logically, this method should be "const". Unfortunately,
the implementation iterates on struct type objects starting with "this",
and thus trying to declare the method "const" triggers a compilation
error.

gdb/ChangeLog:

        * gdbtypes.h (struct type) <fixed_point_type_base_type> New method,
        replacing the fixed_point_type_base_type function. All callers
        updated throughout this project.
        (fixed_point_type_base_type): Remove declaration.
        * gdbtypes.c (type::fixed_point_type_base_type): Replaces
        fixed_point_type_base_type.  Adjust implementation accordingly.
2020-11-23 21:48:23 -05:00
Joel Brobecker
2a12c336b9 gdbtypes.h: Get rid of the TYPE_FIXED_POINT_INFO macro
This is one step further towards the removal of all these macros.

gdb/ChangeLog:

        * gdbtypes.h (struct type) <fixed_point_info, set_fixed_point_info>:
        New methods.
        (INIT_FIXED_POINT_SPECIFIC): Adjust.
        (TYPE_FIXED_POINT_INFO): Delete macro.
        (allocate_fixed_point_type_info): Change return type to void.
        * gdbtypes.c (copy_type_recursive): Replace the use of
        TYPE_FIXED_POINT_INFO by a call to the fixed_point_info method.
        (fixed_point_scaling_factor): Likewise.
        (allocate_fixed_point_type_info): Change return type to void.
        Adjust implementation accordingly.
        * dwarf2/read.c (finish_fixed_point_type): Replace the use of
        TYPE_FIXED_POINT_INFO by a call to the fixed_point_info method.
2020-11-23 21:47:40 -05:00
Joel Brobecker
c9f0b43fe4 gmp-utils: Convert the read/write methods to using gdb::array_view
This commit changes the interfaces of some of the methods declared
in gmp-utils to take a gdb::array_view of gdb_byte instead of a
(gdb_byte *, size) couple.

This makes these methods' API probably more C++-idiomatic.

        * gmp-utils.h (gdb_mpz::read): Change buf and len parameters
        into one single gdb::array_view parameter.
        (gdb_mpz::write): Likewise.
        (gdb_mpq::read_fixed_point, gdb_mpq::write_fixed_point): Likewise.
        * gmp-utils.c (gdb_mpz::read): Change buf and len parameters
        into one single gdb::array_view parameter.
        Adjust implementation accordingly.
        (gdb_mpz::write): Likewise.
        (gdb_mpq::read_fixed_point, gdb_mpq::write_fixed_point): Likewise.
        * unittests/gmp-utils-selftests.c: Adapt following changes above.
        * valarith.c, valops.c, valprint.c, value.c: Likewise.
2020-11-23 21:46:38 -05:00
Joel Brobecker
987b670356 change and rename gmp_string_asprintf to return an std::string
This was suggested by Simon during a code review of this package upstream.
The upside is that this makes the function's API more natural and C++.
The downside is an extra malloc, which might be the reason why we went
for using a unique_xmalloc_ptr in the first place. Since this function
is not expected to be called frequently, the API improvement might be
worth the performance impact.

gdb/ChangeLog:

        * gmp-utils.h (gmp_string_printf): Rename from gmp_string_asprintf.
        Change return type to std::string. Update all callers.
        * gmp-utils.c (gmp_string_printf): Likewise.
2020-11-23 21:45:35 -05:00
Joel Brobecker
4fbb7ccebe Fix stack smashing error during gdb_mpq_write_fixed_point selftest
When building GDB using Ubuntu 20.04's system libgmp and compiler,
running the "maintenance selftest" command triggers the following error:

    | Running selftest gdb_mpq_write_fixed_point.
    | *** stack smashing detected ***: terminated
    | [1]    1092790 abort (core dumped)  ./gdb gdb

This happens while trying to construct an mpq_t object (a rational)
from two integers representing the numerator and denominator.
In our test, the numerator is -8, and the denominator is 1.
The problem was that the rational was constructed using the wrong
function. This is what we were doing prior to this patch:

    mpq_set_ui (v.val, numerator, denominator);

The 'u' in "ui" stands for *unsigned*, which is wrong because
numerator and denominator's type is "int".

As a result of the above, instead of getting a rational value of -8,
we get a rational with a very large positive value (gmp_printf
says "18446744073709551608").

From there, the test performs an operation which is expected to
write this value into a buffer which was not dimensioned to fit
such a number, thus leading GMP into a buffer overflow.
This was verified by applying the formula that GMP's documentation
gives for the required memory buffer size needed during export:

    | When an application is allocating space itself the required size can
    | be determined with a calculation like the following. Since
    | mpz_sizeinbase always returns at least 1, count here will be at
    | least one, which avoids any portability problems with malloc(0),
    | though if z is zero no space at all is actually needed (or written).
    |
    |     numb = 8*size - nail;
    |     count = (mpz_sizeinbase (z, 2) + numb-1) / numb;
    |     p = malloc (count * size);

With the very large number, mpz_sizeinbase returns 66 and thus
the malloc size becomes 16 bytes instead of the 8 we allocated.

This patch fixes the issue by using the correct "set" function.

gdb/ChangeLog:

        * unittests/gmp-utils-selftests.c (write_fp_test): Use mpq_set_si
        instead of mpq_set_ui to initialize our GMP rational.
2020-11-24 06:34:57 +04:00
Simon Marchi
15a491af3c gdb/testsuite: show evaluation errors in gdb_assert
Let's say you put this gdb_assert in a test:

    gdb_assert "some invalid tcl code"

You just get:

    FAIL: gdb.base/template.exp: some invalid tcl code

That's not very easy to debug, since you don't know what's invalid in
your code.

Change gdb_assert to print the error message when catch's return code is
1 (TCL_ERROR).  The "warning" is shown both on stdout and in the log
file.  Mark the test as unresolved, because the evaluation error means
we couldn't reach a valid pass/fail conclusion.

gdb/testsuite/ChangeLog:

	* lib/gdb.exp (gdb_assert): Show error message on error.

Change-Id: Ie6477859554e909ed8d07fb2769c6f2f55e7cce6
2020-11-23 17:26:00 -05:00
Tom de Vries
891615f060 [gdb/testsuite] Fix minimal encodings KPASSes
With current master I see a couple of KPASSes:
...
KPASS: gdb.ada/enum_idx_packed.exp: scenario=minimal: ptype small \
  (PRMS minimal encodings)
  ...
KPASS: gdb.ada/mod_from_name.exp: scenario=minimal: print xp \
  (PRMS minimal encodings)
KPASS: gdb.ada/pckd_arr_ren.exp: scenario=minimal: print var \
  (PRMS minimal encodings)
...

The corresponding setup_kfail is called for everything before gnat 11.

However, the test-cases also PASS for me with gnat-4.8, gnat-7.5.0 and
gnat-8.4.0.

Fix the KPASSes by limiting the setup_kfail to gnat 9 and 10.

Tested on x86_64-linux.

gdb/testsuite/ChangeLog:

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

	* gdb.ada/enum_idx_packed.exp: Limit setup_kfail to gnat 9 and 10.
	* gdb.ada/mod_from_name.exp: Same.
	* gdb.ada/pckd_arr_ren.exp: Same.
2020-11-23 20:09:50 +01:00
Tom de Vries
d6ab69dd54 [gdb] Don't return non-existing path in debuginfod_source_query
When setting env var DEBUGINFOD_URLS to " " and running the testsuite, we run
into these regressions:
...
FAIL: gdb.base/list-missing-source.exp: info source
FAIL: gdb.base/source-dir.exp: info source before setting directory search list
...

Setting var DEBUGINFOD_URLS to " " allows the debuginfod query function
debuginfod_source_query to get past its early exit.

The function debuginfod_source_query is documented as: "If the file is
successfully retrieved, its path on the local machine is stored in DESTNAME".

However, in case we get back -ENOENT from libdebuginfod, we still set
DESTNAME:
....
  if (fd.get () < 0 && fd.get () != -ENOENT)
    printf_filtered (_("Download failed: %s.  Continuing without source file %ps.\n"),
                     safe_strerror (-fd.get ()),
                     styled_string (file_name_style.style (),  srcpath));
  else
    *destname = make_unique_xstrdup (srcpath);

  return fd;
...

Fix this by making debuginfod_source_query fit it's documentation and only
setting DESTNAME when successfully retrieving a file.  Likewise in
debuginfod_debuginfo_query.

gdb/ChangeLog:

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

	* debuginfod-support.c (debuginfod_source_query)
	(debuginfod_debuginfo_query): Only set DESTNAME if successful.
2020-11-23 20:09:50 +01:00
Simon Marchi
199225823d gdb/testsuite: add template for test cases
The wiki contains a template for new test cases:

    https://sourceware.org/gdb/wiki/GDBTestcaseCookbook#Building_the_Example_Program

... which is helpful, because even after many years I can't write all
the boilerplate for writing a test case without doing some mistakes.

However, I think it would be nice to have it in the tree.  It's much
faster to cp the files than going to the wiki and copy/pasting the
contents.

As a bonus, the copyright years will get updated in these files, unlike
those in the wiki.  So they will always be good when we start a new
test.

If this patch is merged, I plan to change the wiki to just point to
these files.

gdb/testsuite/ChangeLog:

	* gdb.base/template.exp: New.
	* gdb.base/template.c: New.

Change-Id: I7dbf068a043b48f83cc325087d70e868eee998c6
2020-11-22 22:04:27 -05:00
Gary Benson
117c628d49 [gdb/testsuite] Add testcase for DW_AT_count referencing a variable
Clang describes the upper bounds of variable length arrays using
a DW_AT_count attribute which references the DIE of a synthetic
variable whose value is specified using a DW_AT_location.  GDB handles
these incorrectly if the corresponding DWARF expression finishes with a
DW_OP_stack_value (PR26905).  This commit adds a new kfailed test to
gdb.dwarf2/count.exp with the same DWARF as that generated by Clang for
gdb.base/vla-optimized-out.exp, one of the failing tests.

Checked on Fedora 32 x86_64, with GCC and Clang.

gdb/testsuite/ChangeLog:

2020-11-22  Gary Benson <gbenson@redhat.com>

	PR gdb/26905
	* gdb.dwarf2/count.exp: Add test for an array whose upper bound
	is defined using a DW_AT_count which references another DIE.
2020-11-22 10:54:58 +01:00
Tom de Vries
da39d3ba57 [gdb/testsuite] Add clang xfail in gdb.base/vla-ptr.exp
When running gdb.base/vla-ptr.exp with clang-10, we run into this FAIL:
...
(gdb) print td_vla^M
$6 = 0x7fffffffd2b0^M
(gdb) FAIL: gdb.base/vla-ptr.exp: print td_vla
...

Clang 10.0.1 generates the following DWARF for td_vla.  A variable DIE:
...
 <2><19f>: Abbrev Number: 6 (DW_TAG_variable)
    <1a0>   DW_AT_location    : 0x39 (location list)
    <1a4>   DW_AT_name        : td_vla
    <1aa>   DW_AT_type        : <0x1ae>
....
with typedef type:
...
 <2><1ae>: Abbrev Number: 7 (DW_TAG_typedef)
    <1af>   DW_AT_type        : <0x1fc>
    <1b3>   DW_AT_name        : typedef_vla
...
pointing to:
...
 <1><1fc>: Abbrev Number: 11 (DW_TAG_array_type)
    <1fd>   DW_AT_type        : <0x1d3>
 <2><201>: Abbrev Number: 14 (DW_TAG_subrange_type)
    <202>   DW_AT_type        : <0x1f5>
...

The subrange type is missing the count attribute.  This was filed as
llvm PR48247 - "vla var with typedef'd type has incomplete debug info".

Mark this as xfail.

gdb/testsuite/ChangeLog:

2020-11-21  Tom de Vries  <tdevries@suse.de>

	* gdb.base/vla-ptr.exp: Add XFAIL.
2020-11-21 18:11:36 +01:00
Tom Tromey
dab7264398 Change watchpoint_exp_is_const to return bool
I noticed that watchpoint_exp_is_const should return bool; this patch
implements this change.

gdb/ChangeLog
2020-11-21  Tom Tromey  <tom@tromey.com>

	* breakpoint.c (watchpoint_exp_is_const): Return bool.
2020-11-21 09:16:41 -07:00
Simon Marchi
c0ad05d567 gdb: fix unittests/gmp-utils-selftests.c build on solaris
When building on solaris (gcc farm machine gcc211), I get:

      CXX    unittests/gmp-utils-selftests.o
    /export/home/simark/src/binutils-gdb/gdb/unittests/gmp-utils-selftests.c: In function 'void selftests::gdb_mpz_read_all_from_small()'  :
    /export/home/simark/src/binutils-gdb/gdb/unittests/gmp-utils-selftests.c:128:43: error: call of overloaded 'pow(int, int)'   is ambiguous
       LONGEST l_min = -pow (2, buf_len * 8 - 1);
                                               ^
    In file included from /opt/csw/lib/gcc/sparc-sun-solaris2.10/5.5.0/include-fixed/math.h:22:0,
                     from ../gnulib/import/math.h:27,
                     from /export/home/simark/src/binutils-gdb/gdb/unittests/gmp-utils-selftests.c:23:
    /opt/csw/lib/gcc/sparc-sun-solaris2.10/5.5.0/include-fixed/iso/math_iso.h:210:21: note: candidate: long double std::pow(long double, long double)
      inline long double pow(long double __X, long double __Y) { return
                         ^
    /opt/csw/lib/gcc/sparc-sun-solaris2.10/5.5.0/include-fixed/iso/math_iso.h:170:15: note: candidate: float std::pow(float, float)
      inline float pow(float __X, float __Y) { return __powf(__X, __Y); }
                   ^
    /opt/csw/lib/gcc/sparc-sun-solaris2.10/5.5.0/include-fixed/iso/math_iso.h:71:15: note: candidate: double std::pow(double, double)
     extern double pow __P((double, double));
                   ^

The "pow" function overloads only exist for float-like types, and the
compiler doesn't know which one we want.  Change "2" for "2.0", which
makes the compiler choose one alternative (the double one, I believe).

gdb/ChangeLog:

	* unittests/gmp-utils-selftests.c (gdb_mpz_read_all_from_small):
	Pass 2.0 to pow.
	(gdb_mpz_write_all_from_small): Likewise.

Change-Id: Ied2ae0f01494430244a7c94f8a38b07d819f4213
2020-11-20 11:19:38 -05:00
Simon Marchi
a43b29c90d gdb: fix dwarf2/read.c build on solaris
When building on solaris (gcc farm machine gcc211), I get:

      CXX    dwarf2/read.o
    /export/home/simark/src/binutils-gdb/gdb/dwarf2/read.c: In function 'void finish_fixed_point_type(type*, die_info*, dwarf2_cu*)':
    /export/home/simark/src/binutils-gdb/gdb/dwarf2/read.c:18204:42: error: call of overloaded 'abs(LONGEST&)' is ambiguous
           *num_or_denom = 1 << abs (scale_exp);
                                              ^
    In file included from /usr/include/stdlib.h:11:0,
                     from ../gnulib/import/stdlib.h:36,
                     from /opt/csw/include/c++/5.5.0/cstdlib:72,
                     from /export/home/simark/src/binutils-gdb/gdb/../gdbsupport/common-defs.h:90,
                     from /export/home/simark/src/binutils-gdb/gdb/defs.h:28,
                     from /export/home/simark/src/binutils-gdb/gdb/dwarf2/read.c:31:
    /opt/csw/lib/gcc/sparc-sun-solaris2.10/5.5.0/include-fixed/iso/stdlib_iso.h:163:16: note: candidate: long int std::abs(long int)
      inline long   abs(long _l) { return labs(_l); }
                    ^
    /opt/csw/lib/gcc/sparc-sun-solaris2.10/5.5.0/include-fixed/iso/stdlib_iso.h:117:12: note: candidate: int std::abs(int)
     extern int abs(int);
                ^

I don't know why, but using std::abs instead of just abs fixes it.

gdb/ChangeLog:

	* dwarf2/read.c (finish_fixed_point_type): Use std::abs instead
	of abs.

Change-Id: I57b9098351f2a8b2d2f61e848b97f7b2dfe55908
2020-11-20 11:19:19 -05:00
Nick Alcock
ae41200ba8 libctf, include, binutils, gdb: rename CTF-opening functions
The functions that return ctf_dict_t's given a ctf_archive_t and a name
are very clumsily named.  It sounds like they return *archives*, not
dictionaries, and the names are very long and clunky.  Why do we
have a ctf_arc_open_by_name when it opens a dictionary, not an archive,
and when there is no way to open a dictionary in any other way?  The
answer is purely internal: the function is located in ctf-archive.c,
and everything in there was called ctf_arc_*, and there is another
way to open a dict (by offset in the archive), that is internal to
ctf-archive.c and that nothing else can call.

This is clearly bad naming. The internal organization of the source tree
should not dictate public API names!

So rename things (keeping the old, bad names for compatibility), and
adjust all users.  You now open a dict using ctf_dict_open, and
open it giving ELF sections via ctf_dict_open_sections.

binutils/ChangeLog
2020-11-20  Nick Alcock  <nick.alcock@oracle.com>

	* objdump.c (dump_ctf): Use ctf_dict_open, not
	ctf_arc_open_by_name.
	* readelf.c (dump_section_as_ctf): Likewise.

gdb/ChangeLog
2020-11-20  Nick Alcock  <nick.alcock@oracle.com>

	* ctfread.c (elfctf_build_psymtabs): Use ctf_dict_open, not
	ctf_arc_open_by_name.

include/ChangeLog
2020-11-20  Nick Alcock  <nick.alcock@oracle.com>

	* ctf-api.h (ctf_arc_open_by_name): Rename to...
	(ctf_dict_open): ... this, keeping compatibility function.
	(ctf_arc_open_by_name_sections): Rename to...
	(ctf_dict_open_sections): ... this, keeping compatibility function.

libctf/ChangeLog
2020-11-20  Nick Alcock  <nick.alcock@oracle.com>

	* ctf-archive.c (ctf_arc_open_by_offset): Rename to...
	(ctf_dict_open_by_offset): ... this.  Adjust callers.
	(ctf_arc_open_by_name_internal): Rename to...
	(ctf_dict_open_internal): ... this.  Adjust callers.
	(ctf_arc_open_by_name_sections): Rename to...
	(ctf_dict_open_sections): ... this, keeping compatibility function.
	(ctf_arc_open_by_name): Rename to...
	(ctf_dict_open): ... this, keeping compatibility function.
	* libctf.ver: New functions added.
	* ctf-link.c (ctf_link_one_input_archive): Adjusted accordingly.
	(ctf_link_deduplicating_open_inputs): Likewise.
2020-11-20 13:34:05 +00:00
Nick Alcock
139633c307 libctf, include, binutils, gdb, ld: rename ctf_file_t to ctf_dict_t
The naming of the ctf_file_t type in libctf is a historical curiosity.
Back in the Solaris days, CTF dictionaries were originally generated as
a separate file and then (sometimes) merged into objects: hence the
datatype was named ctf_file_t, and known as a "CTF file".  Nowadays, raw
CTF is essentially never written to a file on its own, and the datatype
changed name to a "CTF dictionary" years ago.  So the term "CTF file"
refers to something that is never a file!  This is at best confusing.

The type has also historically been known as a 'CTF container", which is
even more confusing now that we have CTF archives which are *also* a
sort of container (they contain CTF dictionaries), but which are never
referred to as containers in the source code.

So fix this by completing the renaming, renaming ctf_file_t to
ctf_dict_t throughout, and renaming those few functions that refer to
CTF files by name (keeping compatibility aliases) to refer to dicts
instead.  Old users who still refer to ctf_file_t will see (harmless)
pointer-compatibility warnings at compile time, but the ABI is unchanged
(since C doesn't mangle names, and ctf_file_t was always an opaque type)
and things will still compile fine as long as -Werror is not specified.
All references to CTF containers and CTF files in the source code are
fixed to refer to CTF dicts instead.

Further (smaller) renamings of annoyingly-named functions to come, as
part of the process of souping up queries across whole archives at once
(needed for the function info and data object sections).

binutils/ChangeLog
2020-11-20  Nick Alcock  <nick.alcock@oracle.com>

	* objdump.c (dump_ctf_errs): Rename ctf_file_t to ctf_dict_t.
	(dump_ctf_archive_member): Likewise.
	(dump_ctf): Likewise. Use ctf_dict_close, not ctf_file_close.
	* readelf.c (dump_ctf_errs): Rename ctf_file_t to ctf_dict_t.
	(dump_ctf_archive_member): Likewise.
	(dump_section_as_ctf): Likewise.  Use ctf_dict_close, not
	ctf_file_close.

gdb/ChangeLog
2020-11-20  Nick Alcock  <nick.alcock@oracle.com>

	* ctfread.c: Change uses of ctf_file_t to ctf_dict_t.
	(ctf_fp_info::~ctf_fp_info): Call ctf_dict_close, not ctf_file_close.

include/ChangeLog
2020-11-20  Nick Alcock  <nick.alcock@oracle.com>

	* ctf-api.h (ctf_file_t): Rename to...
	(ctf_dict_t): ... this.  Keep ctf_file_t around for compatibility.
	(struct ctf_file): Likewise rename to...
	(struct ctf_dict): ... this.
	(ctf_file_close): Rename to...
	(ctf_dict_close): ... this, keeping compatibility function.
	(ctf_parent_file): Rename to...
	(ctf_parent_dict): ... this, keeping compatibility function.
	All callers adjusted.
	* ctf.h: Rename references to ctf_file_t to ctf_dict_t.
	(struct ctf_archive) <ctfa_nfiles>: Rename to...
	<ctfa_ndicts>: ... this.

ld/ChangeLog
2020-11-20  Nick Alcock  <nick.alcock@oracle.com>

	* ldlang.c (ctf_output): This is a ctf_dict_t now.
	(lang_ctf_errs_warnings): Rename ctf_file_t to ctf_dict_t.
	(ldlang_open_ctf): Adjust comment.
	(lang_merge_ctf): Use ctf_dict_close, not ctf_file_close.
	* ldelfgen.h (ldelf_examine_strtab_for_ctf): Rename ctf_file_t to
	ctf_dict_t.  Change opaque declaration accordingly.
	* ldelfgen.c (ldelf_examine_strtab_for_ctf): Adjust.
	* ldemul.h (examine_strtab_for_ctf): Likewise.
	(ldemul_examine_strtab_for_ctf): Likewise.
	* ldeuml.c (ldemul_examine_strtab_for_ctf): Likewise.

libctf/ChangeLog
2020-11-20  Nick Alcock  <nick.alcock@oracle.com>

	* ctf-impl.h: Rename ctf_file_t to ctf_dict_t: all declarations
	adjusted.
	(ctf_fileops): Rename to...
	(ctf_dictops): ... this.
	(ctf_dedup_t) <cd_id_to_file_t>: Rename to...
	<cd_id_to_dict_t>: ... this.
	(ctf_file_t): Fix outdated comment.
	<ctf_fileops>: Rename to...
	<ctf_dictops>: ... this.
	(struct ctf_archive_internal) <ctfi_file>: Rename to...
	<ctfi_dict>: ... this.
	* ctf-archive.c: Rename ctf_file_t to ctf_dict_t.
	Rename ctf_archive.ctfa_nfiles to ctfa_ndicts.
	Rename ctf_file_close to ctf_dict_close.  All users adjusted.
	* ctf-create.c: Likewise.  Refer to CTF dicts, not CTF containers.
	(ctf_bundle_t) <ctb_file>: Rename to...
	<ctb_dict): ... this.
	* ctf-decl.c: Rename ctf_file_t to ctf_dict_t.
	* ctf-dedup.c: Likewise.  Rename ctf_file_close to
	ctf_dict_close. Refer to CTF dicts, not CTF containers.
	* ctf-dump.c: Likewise.
	* ctf-error.c: Likewise.
	* ctf-hash.c: Likewise.
	* ctf-inlines.h: Likewise.
	* ctf-labels.c: Likewise.
	* ctf-link.c: Likewise.
	* ctf-lookup.c: Likewise.
	* ctf-open-bfd.c: Likewise.
	* ctf-string.c: Likewise.
	* ctf-subr.c: Likewise.
	* ctf-types.c: Likewise.
	* ctf-util.c: Likewise.
	* ctf-open.c: Likewise.
	(ctf_file_close): Rename to...
	(ctf_dict_close): ...this.
	(ctf_file_close): New trivial wrapper around ctf_dict_close, for
	compatibility.
	(ctf_parent_file): Rename to...
	(ctf_parent_dict): ... this.
	(ctf_parent_file): New trivial wrapper around ctf_parent_dict, for
	compatibility.
	* libctf.ver: Add ctf_dict_close and ctf_parent_dict.
2020-11-20 13:34:04 +00:00
Pedro Alves
cbbcd7a716 language_lookup_primitive_type, std::function -> gdb::function_view
gdb/ChangeLog:

	* language.c (language_arch_info::lookup_primitive_type): Use
	gdb::function_view instead of gdb::function.
	(template language_lookup_primitive_type): Rename to ...
	(language_lookup_primitive_type_1): ... this, and make static.
	(language_lookup_primitive_type(const struct language_defn *,
	struct gdbarch *, const char *): Make non-template.
	(language_lookup_primitive_type(const struct language_defn *,
	struct gdbarch *, std::function<bool (struct type *)>): Make
	non-template and use gdb::function_view.
	* language.h (language_arch_info::lookup_primitive_type): Use
	gdb::function_view instead of std::function.
	(language_lookup_primitive_type): No longer template.
	* opencl-lang.c (lookup_opencl_vector_type): 'filter' is now a
	lambda instead of a std::function.
2020-11-20 13:27:01 +00:00
Andreas Arnez
d5ef21c3ec gdb/s390: Correct recording of "store on condition" insns
The "store on condition" instructions STOC, STOCG, and STOCFH are recorded
as if their instruction formats resembled that of STG.  This is wrong,
usually resulting in "failed to record execution log" errors when trying
to record code with any of these instructions.

This patch fixes the recording of these instructions.

gdb/ChangeLog:

	PR tdep/26916
	* s390-tdep.c (s390_process_record): Fix recording of STOC, STOCG,
	and STOCFH.
2020-11-19 19:10:58 +01:00
Simon Marchi
a5adb8f3b4 gdb: fix format string warnings in f-lang.c
I get a bunch of these warnings when compiling for i386 (32-bit):

      CXX    f-lang.o
    /home/simark/src/binutils-gdb/gdb/f-lang.c: In function 'value* fortran_value_subarray(value*, expression*, int*, int, noside)':
    /home/simark/src/binutils-gdb/gdb/f-lang.c:453:48: error: format '%ld' expects argument of type 'long int', but argument 2 has type 'LONGEST' {aka 'long long int'} [-Werror=format=]
      453 |        debug_printf ("|   |   |-> Low bound: %ld\n", lb);
          |                                              ~~^     ~~
          |                                                |     |
          |                                                |     LONGEST {aka long long int}
          |                                                long int
          |                                              %lld

Fix them by using plongest/pulongest.

gdb/ChangeLog:

	* f-lang.c (fortran_value_subarray): Use plongest/pulongest.

Change-Id: I666ead5593653d5a1a3dab2ffdc72942c928c7d2
2020-11-19 11:32:26 -05:00