binutils-gdb.git
4 years agoOops - failed to commit change to verilog.c. Trying again.
Nick Clifton [Wed, 16 Sep 2020 15:19:53 +0000 (16:19 +0100)]
Oops - failed to commit change to verilog.c.  Trying again.

* verilog.c (verilog_write_address): Properly handle 64-bit
addresses to avoid truncation of the high part.

4 years agogdb/breakpoint: make a copy of the "commands" command's argument
Tankut Baris Aktemur [Fri, 11 Sep 2020 13:04:01 +0000 (15:04 +0200)]
gdb/breakpoint: make a copy of the "commands" command's argument

When GDB reads commands from the input, its internal buffer is re-used
for each line.  This is usually just fine because commands are
executed in order; by the time we read the next line, we are already
done with the current line.  However, a problematic case is breakpoint
commands that are input from a script.  The header (e.g. commands 1 2)
is overwritten with the next line before the breakpoint numbers are
processed completely.

For example, suppose we have the following script:

  break main
  break main
  commands 1 2
    print 100123
  end

and source this script:

  (gdb) source script.gdb
  Breakpoint 1 at 0x1245: file main.cpp, line 27.
  Breakpoint 2 at 0x1245: file main.cpp, line 27.
  No breakpoint number 123.

Note the "No breakpoint number 123." error message.  This happens
because GDB first reads "commands 1 2" into its internal buffer

  buffer -> "commands 1 2"

and then starts parsing the breakpoint numbers.  After parsing the first
token, the "next token" pointer is as below:

  buffer -> "commands 1 2"
  next-token -----------^

So, if we continue parsing, we would tokenize "2" correctly.  However,
before parsing the next number, GDB reads the commands to attach them
to breakpoint 1.  Reading the commands causes the buffer to be
overwritten:

  buffer -> "  print 100123"
  next-token -----------^

So, the next time we parse the breakpoint number, we read "123".

To fix, simply create a copy of the arguments of the header.

gdb/ChangeLog:
2020-09-16  Tankut Baris Aktemur  <tankut.baris.aktemur@intel.com>

* breakpoint.c (commands_command_1): Make a copy of the 'arg'
argument.

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

* gdb.base/bp-cmds-sourced-script.c: New file.
* gdb.base/bp-cmds-sourced-script.exp: New test.
* gdb.base/bp-cmds-sourced-script.gdb: New file.

4 years agoelf/x86-64: Adjust relocation for PE/x86-64 inputs
H.J. Lu [Wed, 16 Sep 2020 14:11:16 +0000 (07:11 -0700)]
elf/x86-64: Adjust relocation for PE/x86-64 inputs

PE linker calls _bfd_relocate_contents to resolve relocation, instead of
bfd_perform_relocation.  But ELF linker calls bfd_perform_relocation, not
_bfd_relocate_contents.  When linking PE/x86-64 inputs to generate ELF
output, we need to adjust PE/x86-64 relocations in bfd_perform_relocation.

Enable PE/x86-64 in bfd together with PEI/x86-64.  Update run_ld_link_tests
to handle bzip2 binary inputs.

bfd/

PR ld/26583
* config.bfd (targ64_selvecs, targ_selvecs): Add x86_64_pe_vec
to x86_64_pei_vec.
* reloc.c: Include "coff/internal.h".
(bfd_perform_relocation): Adjust relocation for PE/x86-64 inputs.

ld/

PR ld/26583
* testsuite/ld-x86-64/pe-x86-64-1.od: New file.
* testsuite/ld-x86-64/pe-x86-64-1a.obj.bz2: Likewise.
* testsuite/ld-x86-64/pe-x86-64-1b.obj.bz2: Likewise.
* testsuite/ld-x86-64/pe-x86-64-1c.obj.bz2: Likewise.
* testsuite/ld-x86-64/pe-x86-64-2.od: Likewise.
* testsuite/ld-x86-64/pe-x86-64-2a.obj.bz2: Likewise.
* testsuite/ld-x86-64/pe-x86-64-2b.obj.bz2: Likewise.
* testsuite/ld-x86-64/pe-x86-64-2c.obj.bz2: Likewise.
* testsuite/ld-x86-64/pe-x86-64-3.od: Likewise.
* testsuite/ld-x86-64/pe-x86-64-3a.obj.bz2: Likewise.
* testsuite/ld-x86-64/pe-x86-64-3b.obj.bz2: Likewise.
* testsuite/ld-x86-64/pe-x86-64-3c.obj.bz2: Likewise.
* testsuite/ld-x86-64/pe-x86-64-3d.obj.bz2: Likewise.
* testsuite/ld-x86-64/pe-x86-64-4.od: Likewise.
* testsuite/ld-x86-64/pe-x86-64-4a.obj.bz2: Likewise.
* testsuite/ld-x86-64/pe-x86-64-4b.obj.bz2: Likewise.
* testsuite/ld-x86-64/pe-x86-64-4c.obj.bz2: Likewise.
* testsuite/ld-x86-64/pe-x86-64-4d.obj.bz2: Likewise.
* testsuite/ld-x86-64/pe-x86-64.exp: Likewise.
* testsuite/lib/ld-lib.exp (run_ld_link_tests): Handle bz2 binary
inputs.

4 years ago[gdb/testsuite] Detect gdb prompt after monitor exit
Tom de Vries [Wed, 16 Sep 2020 12:53:26 +0000 (14:53 +0200)]
[gdb/testsuite] Detect gdb prompt after monitor exit

With this gdbserver-support.exp patch:
...
@@ -451,8 +451,10 @@ proc gdbserver_exit { is_mi } {
      # We use expect rather than gdb_expect because
      # we want to suppress printing exception messages, otherwise,
      # remote_expect, invoked by gdb_expect, prints the exceptions.
+     set have_prompt 0
      expect {
  -i "$gdb_spawn_id" -re "$gdb_prompt $" {
+     set have_prompt 1
      exp_continue
  }
  -i "$server_spawn_id" eof {
@@ -463,6 +465,7 @@ proc gdbserver_exit { is_mi } {
                    warning "Timed out waiting for EOF in server after $monitor_exit"
                }
      }
+     gdb_assert {$have_prompt}
  }
     }
     close_gdbserver
...
and with this in parallel:
...
$ stress -c 5
...
we run into this and similar FAILs:
...
FAIL: gdb.multi/multi-target.exp: continue: non-stop=on: $have_prompt
...

In more detail:
...
(gdb) PASS: gdb.multi/multi-target.exp: continue: non-stop=on: inferior 5
Remote debugging from host ::1, port 40712^M
Process build/gdb/testsuite/outputs/gdb.multi/multi-target/multi-target \
  created; pid = 11098^M
monitor exit^M
Killing process(es): 11098^M
FAIL: gdb.multi/multi-target.exp: continue: non-stop=on: $have_prompt
spawn build/gdb/testsuite/../../gdb/gdb -nw -nx -data-directory \
  build/gdb/testsuite/../data-directory^M
...

After issuing a "monitor exit" command, we should always get a prompt back, so
check for that.

Tested on x86_64-linux.

gdb/testsuite/ChangeLog:

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

* lib/gdbserver-support.exp (gdbserver_exit): Make sure we
get the gdb prompt after issuing "monitor exit".

4 years agobfd: verilog hex dump backend should handle 64-bit addresses
Anatoly Parshintsev [Wed, 16 Sep 2020 12:17:24 +0000 (13:17 +0100)]
bfd: verilog hex dump backend should handle 64-bit addresses

       * verilog.c (verilog_write_address): Properly handle 64-bit
addresses to avoid truncation of the high part.

4 years ago[gdb/testsuite] Catch condition evaluation errors in gdb_assert
Tom de Vries [Wed, 16 Sep 2020 11:27:32 +0000 (13:27 +0200)]
[gdb/testsuite] Catch condition evaluation errors in gdb_assert

When running test-case gdb.base/watchpoint-stops-at-right-insn.exp, we may run
into a tcl error, which can be reproduced reliably using this trigger patch:
...
+       set hw_watch_pc ""
        gdb_assert {$sw_watch_pc == $hw_watch_pc} \
  "hw watchpoint stops at right instruction"
...
such that we have:
...
ERROR: tcl error sourcing watchpoint-stops-at-right-insn.exp.
ERROR: missing operand at _@_
in expression "0x4004b7 == _@_"
    (parsing expression "0x4004b7 == ")
    invoked from within
"expr $sw_watch_pc == $hw_watch_pc"
    ("uplevel" body line 1)
    invoked from within
"uplevel 1 expr $condition"
    (procedure "gdb_assert" line 6)
    invoked from within
"gdb_assert {$sw_watch_pc == $hw_watch_pc} \
  "hw watchpoint stops at right instruction""
...

A similar problem was fixed in commit 5f0e2eb79e "GDB/testsuite: Fix a
catastrophic step-over-no-symbols.exp failure", by making the assert condition
more robust:
...
-    gdb_assert {$before_addr != $after_addr} "advanced"
+    gdb_assert {{[string is integer -strict $before_addr] \
+                && [string is integer -strict $after_addr] \
+                && $before_addr != $after_addr}} "advanced"
...

Fix this instead in gdb_assert, by catching errors while evaluating the assert
condition.

Tested on x86_64-linux.

gdb/testsuite/ChangeLog:

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

PR testsuite/26624
* lib/gdb.exp (gdb_assert): Catch errors in condition evaluation.

4 years agogdb: Remove language_data struct
Andrew Burgess [Tue, 4 Aug 2020 16:13:40 +0000 (17:13 +0100)]
gdb: Remove language_data struct

The language_data type, from which language_defn inherits, is now
empty, and this commit removes it.

Each language is updated to no longer create and use a language_data
struct.

There should be no user visible changes after this commit.

gdb/ChangeLog:

* ada-lang.c (ada_language_data): Delete.
(ada_language): Remove references to ada_language_data.
* c-lang.c (c_language_data): Delete.
(c_language): Remove references to c_language_data.
(cplus_language_data): Delete.
(cplus_language): Remove references to cplus_language_data.
(asm_language_data): Delete.
(asm_language): Remove references to asm_language_data.
(minimal_language_data): Delete.
(minimal_language): Remove references to minimal_language_data.
* d-lang.c (d_language_data): Delete.
(d_language): Remove references to d_language_data.
* f-lang.c (f_language_data): Delete.
(f_language): Remove references to f_language_data.
* go-lang.c (go_language_data): Delete.
(go_language): Remove references to go_language_data.
* language.c (unknown_language_data): Delete.
(unknown_language): Remove references to unknown_language_data.
(auto_language_data): Delete.
(auto_language): Remove references to auto_language_data.
* language.h (language_data): Delete struct.
(language_defn): No longer inherit from language_data.
* m2-lang.c (m2_language_data): Delete.
(m2_language): Remove references to m2_language_data.
* objc-lang.c (objc_language_data): Delete.
(objc_language): Remove references to objc_language_data.
* opencl-lang.c (opencl_language_data): Delete.
(opencl_language): Remove references to opencl_language_data.
* p-lang.c (pascal_language_data): Delete.
(pascal_language): Remove references to pascal_language_data.
* rust-lang.c (rust_language_data): Delete.
(rust_language): Remove references to rust_language_data.

4 years agogdb: Convert language_data::la_op_print_tab to a method
Andrew Burgess [Tue, 4 Aug 2020 16:07:59 +0000 (17:07 +0100)]
gdb: Convert language_data::la_op_print_tab to a method

Convert language_data::la_op_print_tab member variable to a virtual
method language_defn::opcode_print_table.  I changed the name in order
to make it clearer (I hope) what the method does.

There should be no user visible changes after this commit.

gdb/ChangeLog:

* ada-lang.c (ada_language_data): Remove la_op_print_tab
initializer.
(ada_language::opcode_print_table): New member function.
* c-lang.c (c_language_data): Remove la_op_print_tab initializer.
(c_language::opcode_print_table): New member function.
(cplus_language_data): Remove la_op_print_tab initializer.
(cplus_language::opcode_print_table): New member function.
(asm_language_data): Remove la_op_print_tab initializer.
(asm_language::opcode_print_table): New member function.
(minimal_language_data): Remove la_op_print_tab initializer.
(minimal_language::opcode_print_table): New member function.
* d-lang.c (d_language_data): Remove la_op_print_tab initializer.
(d_language::opcode_print_table): New member function.
* expprint.c (print_subexp_standard): Update call to
opcode_print_table.
(op_string): Likewise.
* f-lang.c (f_language_data): Remove la_op_print_tab initializer.
(f_language::opcode_print_table): New member function.
* go-lang.c (go_language_data): Remove la_op_print_tab
initializer.
(go_language::opcode_print_table): New member function.
* language.c (unknown_language_data): Remove la_op_print_tab
initializer.
(unknown_language::opcode_print_table): New member function.
(auto_language_data): Remove la_op_print_tab initializer.
(auto_language::opcode_print_table): New member function.
* language.h (language_data): Remove la_op_print_tab field.
(language_defn::opcode_print_table): Declare new member function.
* m2-lang.c (m2_language_data): Remove la_op_print_tab
initializer.
(m2_language::opcode_print_table): New member function.
* objc-lang.c (objc_language_data): Remove la_op_print_tab
initializer.
(objc_language::opcode_print_table): New member function.
* opencl-lang.c (opencl_language_data): Remove la_op_print_tab
initializer.
(opencl_language::opcode_print_table): New member function.
* p-lang.c (pascal_language_data): Remove la_op_print_tab
initializer.
(pascal_language::opcode_print_table): New member function.
* rust-lang.c (rust_language_data): Remove la_op_print_tab
initializer.
(rust_language::opcode_print_table): New member function.

4 years agogdb: Convert language_data::la_exp_desc to a method
Andrew Burgess [Tue, 4 Aug 2020 15:31:56 +0000 (16:31 +0100)]
gdb: Convert language_data::la_exp_desc to a method

Convert language_data::la_exp_desc member variable to a virtual
method language_defn::expression_ops.  The change of names brings this
method more into line with the existing varobj_ops method, that also
returns a table of function pointers.

There should be no user visible changes after this commit.

gdb/ChangeLog:

* ada-lang.c (ada_language_data): Remove la_exp_desc initializer.
(ada_language::expression_ops): New member function.
* c-lang.c (c_language_data): Remove la_exp_desc initializer.
(c_language::expression_ops): New member function.
(cplus_language_data): Remove la_exp_desc initializer.
(cplus_language::expression_ops): New member function.
(asm_language_data): Remove la_exp_desc initializer.
(asm_language::expression_ops): New member function.
(minimal_language_data): Remove la_exp_desc initializer.
(minimal_language::expression_ops): New member function.
* d-lang.c (d_language_data): Remove la_exp_desc initializer.
(d_language::expression_ops): New member function.
* eval.c (evaluate_subexp): Update call to expression_ops.
* expprint.c (print_subexp): Likewise.
(op_name): Likewise.
(dump_subexp_body): Likewise.
* f-lang.c (f_language_data): Remove la_exp_desc initializer.
(f_language::expression_ops): New member function.
* go-lang.c (go_language_data): Remove la_exp_desc initializer.
(go_language::expression_ops): New member function.
* language.c (language_defn::expression_ops): New function.
(unknown_language_data): Remove la_exp_desc initializer.
(auto_language_data): Likewise.
* language.h (language_data): Remove la_exp_desc field.
(language_defn::expression_ops): Declare new member function.
* m2-lang.c (m2_language_data): Remove la_exp_desc initializer.
(m2_language::expression_ops): New member function.
* objc-lang.c (objc_language_data): Remove la_exp_desc
initializer.
* opencl-lang.c (opencl_language_data): Remove la_exp_desc
initializer.
(opencl_language::expression_ops): New member function.
* p-lang.c (pascal_language_data): Remove la_exp_desc initializer.
* parse.c (operator_length): Update call to expression_ops.
(exp_iterate): Likewise.
* rust-lang.c (rust_language_data): Remove la_exp_desc
initializer.
(ruse_language::expression_ops): New member function.

4 years agogdb: Convert language_data::la_varobj_ops to a method
Andrew Burgess [Tue, 4 Aug 2020 14:59:52 +0000 (15:59 +0100)]
gdb: Convert language_data::la_varobj_ops to a method

Convert language_data::la_varobj_ops member variable to a virtual
method language_defn::varobj_ops.

There should be no user visible changes after this commit.

gdb/ChangeLog:

* ada-lang.c (ada_language_data): Remove la_varobj_ops
initializer.
(ada_language::varobj_ops): New member function.
* c-lang.c (c_language_data): Remove la_varobj_ops
initializer.
(cplus_language_data): Likewise.
(cplus_language::varobj_ops): New member function.
(asm_language_data): Remove la_varobj_ops initializer.
(minimal_language_data): Likewise.
* d-lang.c (d_language_data): Likewise.
* f-lang.c (f_language_data): Likewise.
* go-lang.c (go_language_data): Likewise.
* language.c (language_defn::varobj_ops): New function.
(unknown_language_data): Remove la_varobj_ops
initializer.
(auto_language_data): Likewise.
* language.h (language_data): Remove la_varobj_ops field.
(language_defn::varobj_ops): Declare new member function.
* m2-lang.c (m2_language_data): Remove la_varobj_ops initializer.
* objc-lang.c (objc_language_data): Likewise.
* opencl-lang.c (opencl_language_data): Likewise.
* p-lang.c (pascal_language_data): Likewise.
* rust-lang.c (rust_language_data): Likewise.
* varobj.c (varobj_create): Update call to varobj_ops.
* varobj.h (default_varobj_ops): Delete define.

4 years agogdb: Convert language_data::la_macro_expansion to a method
Andrew Burgess [Fri, 31 Jul 2020 14:56:15 +0000 (15:56 +0100)]
gdb: Convert language_data::la_macro_expansion to a method

Convert language_data::la_macro_expansion member variable to a virtual
method language_defn::macro_expansion.

There should be no user visible changes after this commit.

gdb/ChangeLog:

* ada-lang.c (ada_language_data): Remove la_macro_expansion
initializer.
* c-lang.c (c_language_data): Likewise.
(c_language::macro_expansion): New member function.
(cplus_language_data): Likewise.
(cplus_language::macro_expansion): New member function.
(asm_language_data): Likewise.
(asm_language::macro_expansion): New member function.
(minimal_language_data): Likewise.
(minimal_language::macro_expansion): New member function.
* d-lang.c (d_language_data): Remove la_macro_expansion
initializer.
* f-lang.c (f_language_data): Likewise.
* go-lang.c (go_language_data): Likewise.
* language.c (unknown_language_data): Likewise.
(auto_language_data): Likewise.
* language.h (language_data): Remove la_macro_expansion field.
(language_defn::macro_expansion): New member function.
* m2-lang.c (m2_language_data): Remove la_macro_expansion
initializer.
* objc-lang.c (objc_language_data): Likewise.
(objc_language::macro_expansion): New member function.
* opencl-lang.c (opencl_language_data): Likewise.
(opencl_language::macro_expansion): New member function.
* p-lang.c (pascal_language_data): Remove la_macro_expansion
initializer.
* rust-lang.c (rust_language_data): Likewise.
* symtab.c (default_collect_symbol_completion_matches_break_on):
Update call to macro_expansion.

4 years agogdb: Convert language_data::la_array_ordering to a method
Andrew Burgess [Sun, 12 Jul 2020 15:00:06 +0000 (16:00 +0100)]
gdb: Convert language_data::la_array_ordering to a method

Convert language_data::la_array_ordering member variable to a virtual
method language_defn::array_ordering.

There should be no user visible changes after this commit.

gdb/ChangeLog:

* ada-lang.c (ada_language_data): Remove la_array_ordering
initializer.
* c-lang.c (c_language_data): Likewise.
(cplus_language_data): Likewise.
(asm_language_data): Likewise.
(minimal_language_data): Likewise.
* d-lang.c (d_language_data): Likewise.
* dwarf2/read.c (read_array_order): Update for call to
array_ordering.
* f-lang.c (f_language_data): Remove la_array_ordering
initializer.
(f_language::array_ordering): New member function.
* go-lang.c (go_language_data): Remove la_array_ordering
initializer.
* language.c (unknown_language_data): Likewise.
(auto_language_data): Likewise.
* language.h (language_data): Delete la_array_ordering field.
(language_defn::array_ordering): New member function.
* m2-lang.c (m2_language_data): Remove la_array_ordering
initializer.
* objc-lang.c (objc_language_data): Likewise.
* opencl-lang.c (opencl_language_data): Likewise.
* p-lang.c (pascal_language_data): Likewise.
* rust-lang.c (rust_language_data): Likewise.

4 years agogdb: Convert language_data::la_case_sensitivity to a method
Andrew Burgess [Sun, 12 Jul 2020 14:09:52 +0000 (15:09 +0100)]
gdb: Convert language_data::la_case_sensitivity to a method

Convert language_data::la_case_sensitivity member variable to a virtual
method language_defn::case_sensitivity.

This is mostly straight forward.  The only slight problem is that I
ended up deleting this comment from ada-lang.c:

  /* Yes, Ada is case-insensitive, but that's not quite what this
     means.  */

However, as the comment (which has existed since Ada support was first
added to GDB) doesn't explain _why_ Ada sets case sensitivity to on
despite being a generally case insensitive language, this doesn't
really help me much.

If I understood _why_ the setting doesn't quite mean what it seems to
mean (at least as far as Ada is concerned) then I would extend the
comment on language_defn::case_sensitivity (in language.h) to include
the detail, and note how this impacts Ada.  But as it stands I've just
deleted the comment for now.

There should be no user visible changes after this commit.

gdb/ChangeLog:

* ada-lang.c (ada_language_data): Remove la_case_sensitivity
initializer.
* c-lang.c (c_language_data): Likewise.
(cplus_language_data): Likewise.
(asm_language_data): Likewise.
(minimal_language_data): Likewise.
* d-lang.c (d_language_data): Likewise.
* f-lang.c (f_language_data): Likewise.
(f_language::case_sensitivity): New member function.
* go-lang.c (go_language_data): Remove la_case_sensitivity
initializer.
* language.c (enum case_mode): Moved here from language.h.
(case_mode): Make static.
(show_case_command): Update for case_sensitivity being a method.
(set_case_command): Likewise.
(set_range_case): Likewise.
(unknown_language_data): Remove la_case_sensitivity initializer.
(auto_language_data): Likewise.
* language.h (case_mode): Delete, move enum declaration to
language.c.
(language_data): Delete la_case_sensitivity field.
(language_defn::case_sensitivity): New member function.
* m2-lang.c (m2_language_data): Remove la_case_sensitivity
initializer.
* objc-lang.c (objc_language_data): Likewise.
* opencl-lang.c (opencl_language_data): Likewise.
* p-lang.c (pascal_language_data): Likewise.
* rust-lang.c (rust_language_data): Likewise.

4 years agogdb: Convert language_data::la_range_check to a method
Andrew Burgess [Sun, 12 Jul 2020 09:15:32 +0000 (10:15 +0100)]
gdb: Convert language_data::la_range_check to a method

Convert language_data::la_range_check member variable to a virtual
method language_defn::range_checking_on_by_default.

Where the previous member variable was of type 'enum range_check', the
new member function returns a boolean that selects between range
checking being on or off.  This removes the possibility of a language
having its default be the third enum state, range_check_warn, which
no language currently used.

This all makes sense I think, the language's true/false provides the
default when the global 'set check range' is set to 'auto'.

There should be no user visible changes after this commit.

gdb/ChangeLog:

* ada-lang.c (ada_language_data): Remove la_range_check
initializer.
* c-lang.c (c_language_data): Likewise.
(cplus_language_data): Likewise.
(asm_language_data): Likewise.
(minimal_language_data): Likewise.
* d-lang.c (d_language_data): Likewise.
* f-lang.c (f_language_data): Likewise.
(f_language::range_checking_on_by_default): New member function.
* go-lang.c (go_language_data): Remove la_range_check initializer.
* language.c (enum range_mode): Moved here from language.h.
(range_mode): Made static.
(show_range_command): Update to use
range_checking_on_by_default.
(set_range_command): Likewise.
(set_range_case): Likewise.
(unknown_language_data): Remove la_range_check initializer.
(auto_language_data): Likewise.
* language.h (range_mode): Delete.  Enum definition moved to
language.c.
(language_data): Remove la_range_check field.
(language_defn::range_checking_on_by_default): New member
function.
* m2-lang.c (m2_language_data): Remove la_range_check initializer.
(m2_language::range_checking_on_by_default): New member function.
* objc-lang.c (objc_language_data): Remove la_range_check
initializer.
* opencl-lang.c (opencl_language_data): Likewise.
* p-lang.c (pascal_language_data): Likewise.
(pascal_language::range_checking_on_by_default): New member
function.
* rust-lang.c (rust_language_data): Remove la_range_check
initializer.
(rust_language::range_checking_on_by_default): New member
function.

4 years agogdb: Override store_sym_names_in_linkage_form_p for Go language
Andrew Burgess [Wed, 8 Jul 2020 10:09:45 +0000 (11:09 +0100)]
gdb: Override store_sym_names_in_linkage_form_p for Go language

When store_sym_names_in_linkage_form_p was introduced in this commit:

  commit 59cc4834e53565da1de4a7b615ed8890ed55c7da
  Date:   Tue Mar 27 08:57:16 2018 -0500

      problem looking up some symbols when they have a linkage name

A special case was left behind for Go, however, this special case was
not really needed anymore, it could be handled by having
store_sym_names_in_linkage_form_p return the true for go, instead of
false.

This commit overrides store_sym_names_in_linkage_form_p for Go, and
then removes the special case.  As store_sym_names_in_linkage_form_p
is only called once throughout GDB this should be perfectly safe.

There should be no user visible changes after this commit.

gdb/ChangeLog:

* dwarf2/read.c (dwarf2_physname): Remove special case for
language_go.
* go-lang.c (go_language::store_sym_names_in_linkage_form_p): New
member function.

4 years agogdb: Convert la_store_sym_names_in_linkage_form_p to a method
Andrew Burgess [Wed, 8 Jul 2020 09:55:56 +0000 (10:55 +0100)]
gdb: Convert la_store_sym_names_in_linkage_form_p to a method

Convert language_data::la_store_sym_names_in_linkage_form_p member
variable to language_defn::store_sym_names_in_linkage_form_p virtual
function.

There should be no user visible changes after this commit.

gdb/ChangeLog:

* ada-lang.c (ada_language_data): Remove
la_store_sym_names_in_linkage_form_p initializer.
(ada_language::store_sym_names_in_linkage_form_p): New member
function.
* c-lang.c (c_language_data): Remove
la_store_sym_names_in_linkage_form_p initializer.
(c_language::store_sym_names_in_linkage_form_p): New member
function.
(cplus_language_data): Remove la_store_sym_names_in_linkage_form_p
initializer.
(asm_language_data): Likewise.
(asm_language::store_sym_names_in_linkage_form_p): New member
function.
(minimal_language_data): Remove
la_store_sym_names_in_linkage_form_p initializer.
(minimal_language::store_sym_names_in_linkage_form_p): New member
function.
* d-lang.c (d_language_data): Remove
la_store_sym_names_in_linkage_form_p initializer.
* dwarf2/read.c (dwarf2_physname): Update call to
store_sym_names_in_linkage_form_p.
* f-lang.c (f_language_data): Remove
la_store_sym_names_in_linkage_form_p initializer.
* go-lang.c (go_language_data): Remove
la_store_sym_names_in_linkage_form_p initializer.
* language.c (unknown_language_data): Remove
la_store_sym_names_in_linkage_form_p initializer.
(unknown_language::store_sym_names_in_linkage_form_p): New member
function.
(auto_language_data): Remove la_store_sym_names_in_linkage_form_p
initializer.
(auto_language::store_sym_names_in_linkage_form_p): New member
function.
* language.h (language_data): Remove
la_store_sym_names_in_linkage_form_p member variable.
(language_defn::store_sym_names_in_linkage_form_p): New member
function.
* m2-lang.c (m2_language_data): Remove
la_store_sym_names_in_linkage_form_p initializer.
* objc-lang.c (objc_language_data): Likewise.
* opencl-lang.c (opencl_language_data): Likewise.
* p-lang.c (pascal_language_data): Likewise.
* rust-lang.c (rust_language_data): Likewise.

4 years agogdb: Convert language_data::string_lower_bound to a method
Andrew Burgess [Sun, 5 Jul 2020 08:29:34 +0000 (09:29 +0100)]
gdb: Convert language_data::string_lower_bound to a method

Convert language_data::string_lower_bound member variable to a virtual
method language_defn::string_lower_bound.

Over all of the languages we currently support there are currently
only two values for the lower bound, 0 or 1.  I noticed that in all
cases, if a language has C style arrays then the lower bound is 0,
otherwise the lower bound is 1.  So the default for the virtual method
in language.h makes use of this, which means languages don't have to
worry about providing a string_lower_bound method at all.

Except for Modula2.  This language is defined to not have C style
arrays, but has a string_lower_bound index of 0, this behaviour is
maintained after this commit by having Modula2 be the only language
that overrides the string_lower_bound method.

There should be no user visible changes after this commit.

gdb/ChangeLog:

* ada-lang.c (ada_language_data): Remove string_lower_bound
initializer.
* c-lang.c (c_language_data): Likewise.
(cplus_language_data): Likewise.
(asm_language_data): Likewise.
(minimal_language_data): Likewise.
* d-lang.c (d_language_data): Likewise.
* f-lang.c (f_language_data): Likewise.
* go-lang.c (go_language_data): Likewise.
* language.c (unknown_language_data): Likewise.
(auto_language_data): Likewise.
* language.h (language_data): Remove string_lower_bound field.
(language_defn::string_lower_bound): New member function.
* m2-lang.c (m2_language_data): Remove string_lower_bound
initializer.
(m2_language::string_lower_bound): New member function.
* objc-lang.c (objc_language_data): Remove string_lower_bound
initializer.
* opencl-lang.c (opencl_language_data): Likewise.
* p-lang.c (pascal_language_data): Likewise.
* rust-lang.c (rust_language_data): Likewise.
* valops.c (value_cstring): Update call to string_lower_bound.
(value_string): Likewise.
* value.c (allocate_repeated_value): Likewise.

4 years agogdb: Fix an incorrect comment
Andrew Burgess [Sat, 4 Jul 2020 08:10:27 +0000 (09:10 +0100)]
gdb: Fix an incorrect comment

A comment uses the wrong parameter name.  Fixed in this commit.

gdb/ChangeLog:

* valops.c (value_repeat): Fix incorrect argument name in comment.

4 years agogdb: Convert language_data::c_style_arrays to a method
Andrew Burgess [Sat, 4 Jul 2020 08:06:08 +0000 (09:06 +0100)]
gdb: Convert language_data::c_style_arrays to a method

Convert language_data::c_style_arrays member variable to a virtual
method language_defn::c_style_arrays_p.

There should be no user visible changes after this commit.

gdb/ChangeLog:

* ada-lang.c (ada_language_data): Remove c_style_arrays
initializer.
(ada_language::c_style_arrays_p): New member fuction.
* c-lang.c (c_language_data): Remove c_style_arrays
initializer.
(cplus_language_data): Likewise.
(asm_language_data): Likewise.
(minimal_language_data): Likewise.
* d-lang.c (d_language_data): Likewise.
* eval.c (ptrmath_type_p): Update call to c_style_arrays_p.
* f-lang.c (f_language_data): Remove c_style_arrays initializer.
(f_language::c_style_arrays_p): New member function.
* go-lang.c (go_language_data): Remove c_style_arrays initializer.
* infcall.c (value_arg_coerce): Update call to c_style_arrays_p.
* language.c (unknown_language_data): Remove c_style_arrays
initializer.
(auto_language_data): Likewise.
* language.h (language_data): Remove c_style_arrays field.
(language_defn::c_style_arrays_p): New member function.
* m2-lang.c (m2_language_data): Remove c_style_arrays initializer.
(m2_language::c_style_arrays_p): New member function.
* objc-lang.c (objc_language_data): Remove c_style_arrays
initializer.
* opencl-lang.c (opencl_language_data): Likewise.
* p-lang.c (pascal_language_data): Likewise.
* rust-lang.c (rust_language_data): Likewise.
* valarith.c (value_subscript): Update call to c_style_arrays_p,
and update local variable to a bool.
* valops.c (value_cast): Update call to c_style_arrays_p.
(value_array): Likewise.
* value.c (coerce_array): Likewise.

4 years agogdb: Move la_language into the language_defn class
Andrew Burgess [Fri, 3 Jul 2020 17:51:34 +0000 (18:51 +0100)]
gdb: Move la_language into the language_defn class

Move the language_data::la_language member variable into the
langage_defn class.

I have not made the la_language member variable a method of
langage_defn simply because of the large number of places that
la_language is referenced throughout GDB.  I have made the new member
variable constant though, so this should prevent accidental
assignment.

In the future we might consider converting la_language to a method,
but right now my goal is to remove the langage_data class, so I'm
happy to leave la_language as a constant member variable.

There should be no user visible changes after this commit.

gdb/ChangeLog:

* ada-lang.c (ada_language_data): Remove la_language initializer.
* c-lang.c (c_language_data): Likewise.
(cplus_language_data): Likewise.
(asm_language_data): Likewise.
(minimal_language_data): Likewise.
* d-lang.c (d_language_data): Likewise.
* f-lang.c (f_language_data): Likewise.
* go-lang.c (go_language_data): Likewise.
* language.c (unknown_language_data): Likewise.
(auto_language_data): Likewise.
* language.h (language_data): Remove la_language field.
(language_defn::language_defn): Initialise la_language field.
(language_defn::la_language): New member variable.
* m2-lang.c (m2_language_data): Remove la_language field.
* objc-lang.c (objc_language_data): Likewise.
* opencl-lang.c (opencl_language_data): Likewise.
* p-lang.c (pascal_language_data): Likewise.
* rust-lang.c (rust_language_data): Likewise.

4 years agogdb: Convert la_filename_extensions to a method
Andrew Burgess [Fri, 3 Jul 2020 17:46:16 +0000 (18:46 +0100)]
gdb: Convert la_filename_extensions to a method

Convert language_data::la_filename_extensions member variable to a
virtual method language_defn::filename_extensions.

The new method returns a vector of filename extensions, which means
that where previously we needed a NULL marker on the end of the list,
we can now discard this.

All of the old arrays that contained the extensions now become static
data within each languages filename_extensions method.

I've updated the single use of the filename_extensions method to make
use of this method returning a vector.  And, just in case anyone
accidentally adds a NULL marked into a languages extensions list, I've
added a new assert in add_filename_language (symtab.c) to catch this.

gdb/ChangeLog:

* ada-lang.c (ada_extensions): Delete, moved into
ada_language::filename_extensions.
(ada_language_data): Remove la_filename_extensions initializer.
(ada_language::filename_extensions): New member function.
* c-lang.c (c_extensions): Delete, moved into
c_language::filename_extensions.
(c_language_data): Remove la_filename_extensions initializer.
(c_language::filename_extensions): New member function.
(cplus_extensions): Delete, moved into
cplus_language::filename_extensions.
(cplus_language_data): Remove la_filename_extensions initializer.
(cplus_language::filename_extensions): New member function.
(asm_extensions): Delete, moved into
asm_language::filename_extensions.
(asm_language_data): Remove la_filename_extensions initializer.
(asm_language::filename_extensions): New member function.
(minimal_language_data): Remove la_filename_extensions
initializer.
* d-lang.c (d_extensions): Delete, moved into
d_language::filename_extensions.
(d_language_data): Remove la_filename_extensions initializer.
(d_language::filename_extensions): New member function.
* f-lang.c (f_extensions): Delete, moved into
f_language::filename_extensions.
(f_language_data): Remove la_filename_extensions initializer.
(f_language::filename_extensions): New member function.
* go-lang.c (go_language_data): Remove la_filename_extensions
initializer.
* language.c (add_set_language_command): Update now that
filename_extensions returns a vector.
(unknown_language_data): Remove la_filename_extensions
initializer.
(auto_language_data): Likewise.
* language.h (language_data): Remove la_filename_extensions field.
(language_defn::filename_extensions): New member function.
* m2-lang.c (m2_language_data): Remove la_filename_extensions
initializer.
* objc-lang.c (objc_extensions): Delete, moved into
objc_language::filename_extensions.
(objc_language_data): Remove la_filename_extensions initializer.
(objc_language::filename_extensions): New member function.
* opencl-lang.c (opencl_language_data): Remove
la_filename_extensions initializer.
* p-lang.c (pascal_extensions): Delete, moved into
pascal_language::filename_extensions.
(pascal_language_data): Remove la_filename_extensions initializer.
(pascal_language::filename_extensions): New member function.
* rust-lang.c (rust_extensions): Delete, moved into
rust_language::filename_extensions.
(rust_language_data): Remove la_filename_extensions initializer.
(rust_language::filename_extensions): New member function.
* symfile.c (add_filename_language): Add new assert.

4 years agogdb: Convert la_name and la_natural_name to methods
Andrew Burgess [Tue, 23 Jun 2020 19:07:09 +0000 (20:07 +0100)]
gdb: Convert la_name and la_natural_name to methods

Convert the two language_data member variables la_name and
la_natural_name to virtual methods in language_defn struct called name
and natural_name respectively.

The virtual methods in the language_defn base class are pure virtual,
as every language must implement these, and as every language has a
unique name there's no sensible default here.

Given that every language must implement these methods I did wonder
about making this data passed into the base class constructor, but in
the end I went with the virtual method approach.  I'm open to changing
this approach if people prefer the constructor approach.

During updating the calls to language_defn::name I found in
add_set_language_command a place where we took la_name and then
capitalised the first letter to create a language name that could be
used in the documentation string.  I replaced this with a use of
natural_name instead as this seemed a better choice, in most cases
this will make no difference, as for most languages the natural_name
is just the name with the first character in upper case, but for some
languages, for example 'Open-CL' and 'Objective-C' this is not the
case.

In the case of asm_language the name is 'asm', while the natural_name
was previously 'assembly'.  I changed the natural name to 'Assembly',
this makes the documentation string case above cleaner, however, this
will change the MI output for -var-info-expression, where the 'lang'
field will change from 'assembly' to 'Assembly'.  It is possible this
could be a breaking change if a front-end is relying on the existing
name.

gdb/ChangeLog:

* ada-lang.c (ada_language_data): Remove la_name and
la_natural_name initializers.
(ada_language::name): New member function.
(ada_language::natural_name): New member function.
* c-lang.c (c_language_data): Remove la_name and
la_natural_name initializers.
(c_language::name): New member function.
(c_language::natural_name): New member function.
(cplus_language_data): Remove la_name and
la_natural_name initializers.
(cplus_language::name): New member function.
(cplus_language::natural_name): New member function.
(asm_language_data): Remove la_name and
la_natural_name initializers.
(asm_language::name): New member function.
(asm_language::natural_name): New member function.
(minimal_language_data): Remove la_name and
la_natural_name initializers.
(minimal_language::name): New member function.
(minimal_language::natural_name): New member function.
* compile/compile.c (compile_to_object): Update call to
lanugage_defn::name.
* d-lang.c (d_language_data): Remove la_name and
la_natural_name initializers.
(d_language::name): New member function.
(d_language::natural_name): New member function.
* expprint.c (print_subexp_standard): Update call to
language_defn::name.
(dump_raw_expression): Likewise
(dump_prefix_expression): Likewise.
* f-lang.c (f_language_data): Remove la_name and
la_natural_name initializers.
(f_language::name): New member function.
(f_language::natural_name): New member function.
* go-lang.c (go_language_data): Remove la_name and
la_natural_name initializers.
(go_language::name): New member function.
(go_language::natural_name): New member function.
* language.c (show_language_command): Update call to
language_defn::name.
(set_language_command): Likewise.
(language_enum): Likewise.
(language_str): Likewise.
(add_set_language_command): Likewise, use
language_defn::natural_name in the doc string.
(unknown_language_data): Remove la_name and
la_natural_name initializers.
(unknown_language::name): New member function.
(unknown_language::natural_name): New member function.
(auto_language_data): Remove la_name and
la_natural_name initializers.
(auto_language::name): New member function.
(auto_language::natural_name): New member function.
(language_lookup_primitive_type_as_symbol): Update call to
language_defn::name.
* language.h (language_data): Remove la_name and la_natural_name
member variables.
(language_defn::name): New member function.
(language_defn::natural_name): New member function.
* m2-lang.c (m2_language_data): Remove la_name and
la_natural_name initializers.
(m2_language::name): New member function.
(m2_language::natural_name): New member function.
* mi/mi-cmd-var.c (mi_cmd_var_info_expression): Update call to
language_defn::natural_name.
* objc-lang.c (objc_language_data): Remove la_name and
la_natural_name initializers.
(objc_language::name): New member function.
(objc_language::natural_name): New member function.
* opencl-lang.c (opencl_language_data): Remove la_name and
la_natural_name initializers.
(opencl_language::name): New member function.
(opencl_language::natural_name): New member function.
* p-lang.c (pascal_language_data): Remove la_name and
la_natural_name initializers.
(pascal_language::name): New member function.
(pascal_language::natural_name): New member function.
* rust-lang.c (rust_language_data): Remove la_name and
la_natural_name initializers.
(rust_language::name): New member function.
(rust_language::natural_name): New member function.
* symtab.c (lookup_language_this): Update call to
language_defn::name.

4 years agogdb: Convert la_name_of_this to a method
Andrew Burgess [Tue, 23 Jun 2020 13:42:14 +0000 (14:42 +0100)]
gdb: Convert la_name_of_this to a method

Convert language_data::la_name_of_this member variable to a virtual
method language_defn::name_of_this.

There should be no user visible changes after this commit.

gdb/ChangeLog:

* ada-lang.c (ada_language_data): Remove la_name_of_this
initializer.
* ax-gdb.c (gen_expr): Update call to name_of_this.
* c-exp.y (classify_name): Likewise.
* c-lang.c (c_language_data): Remove la_name_of_this initializer.
(cplus_language_data): Likewise.
(cplus_language::name_of_this): New member function.
(asm_language_data): Remove la_name_of_this initializer.
(minimal_language_data): Likewise.
* d-lang.c (d_language_data): Likewise.
(d_language::name_of_this): New member function.
* expprint.c (print_subexp_standard): Update call to name_of_this.
* f-lang.c (f_language_data): Remove la_name_of_this initializer.
* go-lang.c (go_language_data): Likewise.
* language.c (unknown_language_data): Likewise.
(unknown_language::name_of_this): New member function.
(auto_language_data): Remove la_name_of_this initializer.
(auto_language::name_of_this): New member function.
* language.h (language_data): Delete la_name_of_this member
variable.
(language_defn::name_of_this): New member function.
* m2-lang.c (m2_language_data): Remove la_name_of_this
initializer.
* objc-lang.c (objc_language_data): Likewise.
(objc_language::name_of_this): New member function.
* opencl-lang.c (opencl_language_data): Remove la_name_of_this
initializer.
* p-lang.c (pascal_language_data): Likewise.
(pascal_language::name_of_this): New member function.
* rust-lang.c (rust_language_data): Remove la_name_of_this
initializer.
* symtab.c (lookup_language_this): Update call to name_of_this.
(lookup_symbol_aux): Likewise.
* valops.c (value_of_this): Likewise.

4 years agogdb: Convert la_struct_too_deep_ellipsis to a method
Andrew Burgess [Tue, 23 Jun 2020 13:16:32 +0000 (14:16 +0100)]
gdb: Convert la_struct_too_deep_ellipsis to a method

Convert language_data::la_struct_too_deep_ellipsis member variable to
a method in language_defn.

There should be no user visible changes after this commit.

gdb/ChangeLog:

* ada-lang.c (ada_language_data): Remove
la_struct_too_deep_ellipsis initializer.
(ada_language::struct_too_deep_ellipsis): New member function.
* c-lang.c (c_language_data): Remove la_struct_too_deep_ellipsis
initializer.
(cplus_language_data): Likewise.
(asm_language_data): Likewise.
(minimal_language_data): Likewise.
* cp-valprint.c (cp_print_value): Update call to
struct_too_deep_ellipsis.
* d-lang.c (d_language_data): Remove la_struct_too_deep_ellipsis
initializer.
* f-lang.c (f_language_data): Likewise.
(f_language::struct_too_deep_ellipsis): New member function.
* go-lang.c (go_language_data): Remove la_struct_too_deep_ellipsis
initializer.
* language.c (unknown_language_data): Likewise.
(auto_language_data): Likewise.
* language.h (language_data): Delete la_struct_too_deep_ellipsis
member variable.
(language_defn::struct_too_deep_ellipsis): New member function.
* m2-lang.c (m2_language_data): Remove la_struct_too_deep_ellipsis
initializer.Q
* objc-lang.c (objc_language_data): Likewise.
* opencl-lang.c (opencl_language_data): Likewise.
* p-lang.c (pascal_language_data): Likewise.
* rust-lang.c (rust_language_data): Likewise.
* valprint.c (val_print_check_max_depth): Update call to
struct_too_deep_ellipsis.

4 years agoAdd myself to gdb/MAINTAINERS.
Felix Willgerodt [Wed, 16 Sep 2020 08:04:53 +0000 (10:04 +0200)]
Add myself to gdb/MAINTAINERS.

gdb/ChangeLog:
2020-09-16  Felix Willgerodt  <felix.willgerodt@intel.com>

* MAINTAINERS (Write After Approval): Add myself.

4 years ago[gdb/testsuite] Fix unbalanced braces in gdb.tui/new-layout.exp
Tom de Vries [Wed, 16 Sep 2020 08:57:17 +0000 (10:57 +0200)]
[gdb/testsuite] Fix unbalanced braces in gdb.tui/new-layout.exp

On SLE-11 with tcl version 8.5, we run into:
...
UNRESOLVED: gdb.tui/new-layout.exp: testcase aborted due to \
  invalid command name: }
ERROR: Couldn't send tui new-layout example src 1} to GDB.
...

Apparently tcl 8.6 is more forgiving about unbalanced braces.

Expose the unbalanced braces on tcl 8.6 by temporarily wrapping the
test-case in:
...
proc do_this { args } {
    uplevel 1 {*}$args
}

do_this {
  ...
}
...
and escape them using a backslash.

Tested on x86_64-linux.

gdb/testsuite/ChangeLog:

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

PR testsuite/26618
* gdb.tui/new-layout.exp: Escape unbalanced braces.

4 years agoTidy elf_symbol_from
Alan Modra [Tue, 15 Sep 2020 23:55:56 +0000 (09:25 +0930)]
Tidy elf_symbol_from

bfd/
* elf-bfd.h (elf_symbol_from): Remove unused ABFD parameter.
* elf.c (ignore_section_sym, _bfd_elf_copy_private_symbol_data),
(swap_out_syms): Adjust elf_symbol_from invocation.
binutils/
* nm.c (print_symbol): Adjust elf_symbol_from invocation.
* objcopy.c (is_hidden_symbol): Likewise.
gas/
* config/obj-elf.c (obj_elf_visibility, elf_frob_symbol): Adjust
elf_symbol_from invocation.
* config/tc-aarch64.c (s_variant_pcs): Likewise.
* config/tc-m68hc11.c (s_m68hc11_mark_symbol): Likewise.
* config/tc-ppc.c (ppc_elf_localentry, ppc_force_relocation),
(ppc_fix_adjustable): Likewise.
* config/tc-xgate.c (xgate_frob_symbol): Likewise.
ld/
* plugin.c (asymbol_from_plugin_symbol): Adjust elf_symbol_from
invocation.
opcodes/
* ppc-dis.c (ppc_symbol_is_valid): Adjust elf_symbol_from invocation.

4 years agoPR26623, buffer overflow in ppc_symbol_is_valid
Alan Modra [Tue, 15 Sep 2020 23:52:36 +0000 (09:22 +0930)]
PR26623, buffer overflow in ppc_symbol_is_valid

PR 26623
* elf-bfd.h (elf_symbol_from): Exclude synthetic symbols.

4 years agoRemove TYPE_CODE_INT case from f_value_print_inner
Tom Tromey [Wed, 16 Sep 2020 00:44:37 +0000 (18:44 -0600)]
Remove TYPE_CODE_INT case from f_value_print_inner

I looked through the various language value-print functions, to see if
any code could be consolidated.  Pretty much all I found was that
f_value_print_inner does not need to handle TYPE_CODE_INT itself, but
can simply dispatch to the generic printer.

gdb/ChangeLog
2020-09-15  Tom Tromey  <tom@tromey.com>

* f-valprint.c (f_value_print_inner) <case TYPE_CODE_INT>:
Remove.

4 years agoHandle member pointers directly in generic_value_print
Tom Tromey [Wed, 16 Sep 2020 00:44:37 +0000 (18:44 -0600)]
Handle member pointers directly in generic_value_print

TYPE_CODE_MEMBERPTR and TYPE_CODE_METHODPTR are only used for C++, so
it seems to me that the generic value-printing code ought to handle
these cases -- that way, printing these objects will work even when
the current language is not C++.  This patch implements this idea.

gdb/ChangeLog
2020-09-15  Tom Tromey  <tom@tromey.com>

* rust-lang.c (rust_value_print_inner): Remove TYPE_CODE_MEMBERPTR
and TYPE_CODE_METHODPTR cases.
* c-valprint.c (c_value_print_memberptr): Move to valprint.c.
(c_value_print_inner): Update.
* valprint.c (generic_value_print_memberptr): New function, from
c_value_print_memberptr.
(generic_value_print): Use it.  Call cplus_print_method_ptr.

4 years agoAutomatic date update in version.in
GDB Administrator [Wed, 16 Sep 2020 00:00:06 +0000 (00:00 +0000)]
Automatic date update in version.in

4 years agoPE/x86-64: Display PE relocation names
H.J. Lu [Tue, 15 Sep 2020 20:56:18 +0000 (13:56 -0700)]
PE/x86-64: Display PE relocation names

For PE/x86-64, display PE relocation names:

R_X86_64_64   -> IMAGE_REL_AMD64_ADDR64
R_X86_64_32   -> IMAGE_REL_AMD64_ADDR32.
rva32         -> IMAGE_REL_AMD64_ADDR32NB
R_X86_64_PC32 -> IMAGE_REL_AMD64_REL32
DISP32+1      -> IMAGE_REL_AMD64_REL32_1
DISP32+2      -> IMAGE_REL_AMD64_REL32_2
DISP32+3      -> IMAGE_REL_AMD64_REL32_3
DISP32+4      -> IMAGE_REL_AMD64_REL32_4
DISP32+5      -> IMAGE_REL_AMD64_REL32_5
secrel32      -> IMAGE_REL_AMD64_SECREL

bfd/

* coff-x86_64.c (howto_table): Display PE relocation names.

gas/

* testsuite/gas/cfi/reloc-pe-i386.d: Updated.
* testsuite/gas/i386/x86-64-w64-pcrel.d: Likewise.

4 years agoelf: Check bfd_target_elf_flavour on input first
H.J. Lu [Tue, 15 Sep 2020 20:05:04 +0000 (13:05 -0700)]
elf: Check bfd_target_elf_flavour on input first

Check bfd_target_elf_flavour on input first in ldelf_after_open before
checking elf_tdata.

* ldelf.c (ldelf_after_open): Check bfd_target_elf_flavour first.

4 years agoDon't use PyInt_FromLong
Tom Tromey [Tue, 15 Sep 2020 17:08:56 +0000 (11:08 -0600)]
Don't use PyInt_FromLong

Avoid the use of PyInt_FromLong, preferring gdb_py_object_from_longest
instead.  I found found another spot that was incorrectly handling
errors (see gdbpy_create_ptid_object) while writing this patch; it is
fixed here.

gdb/ChangeLog
2020-09-15  Tom Tromey  <tromey@adacore.com>

* python/python-internal.h (PyInt_FromLong): Remove define.
* python/py-value.c (convert_value_from_python): Use
gdb_py_object_from_longest.
* python/py-type.c (typy_get_code): Use
gdb_py_object_from_longest.
* python/py-symtab.c (salpy_get_line): Use
gdb_py_object_from_longest.
* python/py-symbol.c (sympy_get_addr_class, sympy_line): Use
gdb_py_object_from_longest.
* python/py-record.c (recpy_gap_reason_code): Use
gdb_py_object_from_longest.
* python/py-record-btrace.c (recpy_bt_insn_size)
(recpy_bt_func_level, btpy_list_count): Use
gdb_py_object_from_longest.
* python/py-infthread.c (gdbpy_create_ptid_object): Use
gdb_py_object_from_longest.  Fix error handling.
* python/py-framefilter.c (bootstrap_python_frame_filters): Use
gdb_py_object_from_longest.
* python/py-frame.c (frapy_type, frapy_unwind_stop_reason): Use
gdb_py_object_from_longest.
* python/py-breakpoint.c (bppy_get_type, bppy_get_number)
(bppy_get_thread, bppy_get_task, bppy_get_hit_count)
(bppy_get_ignore_count): Use gdb_py_object_from_longest.

4 years agoDon't use PyLong_FromUnsignedLong
Tom Tromey [Tue, 15 Sep 2020 17:08:56 +0000 (11:08 -0600)]
Don't use PyLong_FromUnsignedLong

This changes gdb to avoid PyLong_FromUnsignedLong, preferring
gdb_py_object_from_ulongest instead.

gdb/ChangeLog
2020-09-15  Tom Tromey  <tromey@adacore.com>

* python/python.c (gdbpy_parameter_value): Use
gdb_py_object_from_ulongest.

4 years agoDon't use PyLong_FromLongLong
Tom Tromey [Tue, 15 Sep 2020 17:08:56 +0000 (11:08 -0600)]
Don't use PyLong_FromLongLong

This changes gdb to avoid PyLong_FromLongLong, preferring to use
gdb_py_object_from_longest instead.

gdb/ChangeLog
2020-09-15  Tom Tromey  <tromey@adacore.com>

* python/py-infevents.c (create_register_changed_event_object):
Use gdb_py_object_from_longest.
* python/py-exitedevent.c (create_exited_event_object): Use
gdb_py_object_from_longest.

4 years agoDon't use PyLong_FromLong
Tom Tromey [Tue, 15 Sep 2020 17:08:56 +0000 (11:08 -0600)]
Don't use PyLong_FromLong

This changes gdb to avoid PyLong_FromLong, preferring to
gdb_py_object_from_longest instead.

gdb/ChangeLog
2020-09-15  Tom Tromey  <tromey@adacore.com>

* python/python.c (gdbpy_parameter_value): Use
gdb_py_object_from_longest.
* python/py-type.c (convert_field, typy_range): Use
gdb_py_object_from_longest.
* python/py-tui.c (gdbpy_tui_width, gdbpy_tui_height): Use
gdb_py_object_from_longest.
* python/py-lazy-string.c (stpy_get_length): Use
gdb_py_object_from_longest.
* python/py-infthread.c (thpy_get_num, thpy_get_global_num): Use
gdb_py_object_from_longest.
* python/py-infevents.c (create_memory_changed_event_object): Use
gdb_py_object_from_longest.
* python/py-inferior.c (infpy_get_num): Use
gdb_py_object_from_longest.
(infpy_get_pid): Likewise.

4 years agoDon't use gdb_py_long_from_ulongest
Tom Tromey [Tue, 15 Sep 2020 17:08:56 +0000 (11:08 -0600)]
Don't use gdb_py_long_from_ulongest

Remove the gdb_py_long_from_ulongest defines and change the Python
layer to prefer gdb_py_object_from_ulongest.  While writing this I
noticed that the error handling in archpy_disassemble was incorrect --
it could call PyDict_SetItemString with a NULL value.  This patch also
fixes this bug.

gdb/ChangeLog
2020-09-15  Tom Tromey  <tromey@adacore.com>

* python/python-internal.h (gdb_py_long_from_ulongest): Remove
defines.
* python/py-value.c (valpy_long): Use
gdb_py_object_from_ulongest.
* python/py-symtab.c (salpy_get_pc): Use
gdb_py_object_from_ulongest.
(salpy_get_last): Likewise.
* python/py-record-btrace.c (recpy_bt_insn_pc): Use
gdb_py_object_from_ulongest.
* python/py-lazy-string.c (stpy_get_address): Use
gdb_py_object_from_ulongest.
* python/py-frame.c (frapy_pc): Use gdb_py_object_from_ulongest.
* python/py-arch.c (archpy_disassemble): Use
gdb_py_object_from_ulongest and gdb_py_object_from_longest.  Fix
error handling.

4 years agoDon't use gdb_py_long_from_longest
Tom Tromey [Tue, 15 Sep 2020 17:08:56 +0000 (11:08 -0600)]
Don't use gdb_py_long_from_longest

Change the Python layer to avoid gdb_py_long_from_longest, and remove
the defines.

gdb/ChangeLog
2020-09-15  Tom Tromey  <tromey@adacore.com>

* python/python-internal.h (gdb_py_long_from_longest): Remove
defines.
* python/py-value.c (valpy_long): Use gdb_py_object_from_longest.
* python/py-type.c (convert_field, typy_get_sizeof): Use
gdb_py_object_from_longest.
* python/py-record-btrace.c (btpy_list_index): Use
gdb_py_object_from_longest.

4 years agoDon't use PyInt_FromSsize_t
Tom Tromey [Tue, 15 Sep 2020 17:08:56 +0000 (11:08 -0600)]
Don't use PyInt_FromSsize_t

Change the Python layer to avoid PyInt_FromSsize_t, and remove the
compatibility define.

gdb/ChangeLog
2020-09-15  Tom Tromey  <tromey@adacore.com>

* python/python-internal.h (PyInt_FromSsize_t): Remove define.
* python/py-record.c (recpy_element_number): Use
gdb_py_object_from_longest.
(recpy_gap_number): Likewise.

4 years agoAvoid running one Rust test against older LLVM
Tom Tromey [Tue, 15 Sep 2020 15:27:01 +0000 (09:27 -0600)]
Avoid running one Rust test against older LLVM

LLVM 8.0 introduced some changes to let the Rust compiler emit DWARF
variant parts.  Before this change, the compiler would emit two types
with the same name, and unfortunately gdb happens to pick the wrong
one.  So, this patch disables the test when using an older version of
LLVM.

gdb/testsuite/ChangeLog
2020-09-15  Tom Tromey  <tromey@adacore.com>

PR rust/26197:
* lib/rust-support.exp (rust_llvm_version): New proc.
* gdb.rust/simple.exp: Check rust_llvm_version.

4 years agoRemove ui::num
Tom Tromey [Tue, 15 Sep 2020 14:54:03 +0000 (08:54 -0600)]
Remove ui::num

I noticed that nothing uses ui::num, so this patch removes it.

gdb/ChangeLog
2020-09-15  Tom Tromey  <tromey@adacore.com>

* top.c (ui::ui): Update.
(highest_ui_num): Remove.
* top.h (struct ui) <num>: Remove.

4 years agoUse arrays rather than pointers for global string constants
Tom Tromey [Tue, 15 Sep 2020 14:38:22 +0000 (08:38 -0600)]
Use arrays rather than pointers for global string constants

My understanding is that it's mildly better to use a static const
array, as opposed to a "const char *", for a global string constant,
when possible.  This makes sense to me because the pointer requires a
load from an address, whereas the array is just the address.

So, I searched for these in gdb and gdbserver.  This patch fixes the
ones I found.

gdb/ChangeLog
2020-09-15  Tom Tromey  <tromey@adacore.com>

* unittests/memory-map-selftests.c (valid_mem_map): Now array.
* ui-style.c (ansi_regex_text): Now array.
* rust-exp.y (number_regex_text): Now array.
* linespec.c (linespec_quote_characters): Now array.
* jit.c (jit_break_name, jit_descriptor_name, reader_init_fn_sym):
Now arrays.

gdbserver/ChangeLog
2020-09-15  Tom Tromey  <tromey@adacore.com>

* linux-x86-low.cc (xmltarget_i386_linux_no_xml)
(xmltarget_amd64_linux_no_xml): Now arrays.

4 years agoPR26610, ARM's "VFPv3 vldr to vmov" gas testcase fail
Alan Modra [Tue, 15 Sep 2020 11:25:02 +0000 (20:55 +0930)]
PR26610, ARM's "VFPv3 vldr to vmov" gas testcase fail

I removed a few too many parentheses in git commit 7af677524e2.  This
patch fixes that problem, rewriting the expression so it won't happen
again.  The patch also avoids more UB with shifts of signed values.

PR 26610
* config/tc-arm.c (move_or_literal_pool): Correct extraction of
bignum.  Use unsigned "v"
(is_double_a_single): Make "v" and "mantissa" unsigned.  Formatting.
(double_to_single): Likewise.

4 years agoAdd note about creating a bugzilla tag for a point release.
Nick Clifton [Tue, 15 Sep 2020 10:32:34 +0000 (11:32 +0100)]
Add note about creating a bugzilla tag for a point release.

* README-how-to-make-a-release (https): Add a reminder to create a
new Bugzilla tag for the point release, once it has been published.

4 years agoFix the assembler's new .nop directive so that the input line pointer is preserved.
Nick Clifton [Tue, 15 Sep 2020 09:53:46 +0000 (10:53 +0100)]
Fix the assembler's new .nop directive so that the input line pointer is preserved.

* read.c (s_nop): Preserve the input_line_pointer around the call
to md_assemble.
* config/tc-s12z.c (md_assemble): Revert previous delta.

4 years agoChange the /nop directive for the BPF port of the assembler to use the encoding expec...
David Faust [Tue, 15 Sep 2020 09:33:49 +0000 (10:33 +0100)]
Change the /nop directive for the BPF port of the assembler to use the encoding expected by the kernel.

* config/tc-bpf.h (md_single_noop_insn): Use 'ja 0' for no-op.

4 years agogdb: introduce debuginfod_client_up type
Simon Marchi [Tue, 15 Sep 2020 02:28:42 +0000 (22:28 -0400)]
gdb: introduce debuginfod_client_up type

Introduce and use a unique pointer specialization for the
debuginfod_client type.  The deleter calls debuginfod_end to free the
client.

gdb/ChangeLog:

* debuginfod-support.c (debuginfod_client_deleter): New.
(debuginfod_client_up): New.
(debuginfod_init): Return debuginfod_client_up.
(debuginfod_source_query): Adjust.
(debuginfod_debuginfo_query): Adjust.

Change-Id: Ie56441e123ab80b78e5311c824c162cd804f68c0

4 years agogdb: use make_unique_xstrdup in debuginfod-support.c
Simon Marchi [Tue, 15 Sep 2020 02:28:25 +0000 (22:28 -0400)]
gdb: use make_unique_xstrdup in debuginfod-support.c

Use make_unique_xstrdup instead of reset + xstrdup.

gdb/ChangeLog:

* debuginfod-support.c (debuginfod_source_query): Use
make_unique_xstrdup.

Change-Id: Iee9524fea7630b4d6ee5c74e30c60fe222dc1d2c

4 years agogdb: remove TYPE_INSTANCE_FLAGS
Simon Marchi [Tue, 15 Sep 2020 02:22:33 +0000 (22:22 -0400)]
gdb: remove TYPE_INSTANCE_FLAGS

Remove it, use the `type::instance_flags` method everywhere.

gdb/ChangeLog:

* gdbtypes.h (TYPE_INSTANCE_FLAGS): Remove, replace all uses
with `type::instance_flags`.

Change-Id: I3653108b712e6186529cb0102e2b70247bbcabbe

4 years agoCRIS: fix PR ld/26589, a missing NULL check in fix for PR ld/22269
Hans-Peter Nilsson [Tue, 15 Sep 2020 00:57:39 +0000 (02:57 +0200)]
CRIS: fix PR ld/26589, a missing NULL check in fix for PR ld/22269

Not sure why there wasn't a NULL check in the ld/22269 patch
(e01c16a8) at the time, as there was one for the corresponding patch
to elf32-m68k.c (5056ba1d).

Incidentally, I had missed that in 2017, as a prerequisite for the
ld/22269 series, the check_relocs function finally were made "safe"!
(I.e. the number of references and symbol types are final, garbage
collection done, so port-specific accounting can be made sanely.)

Committed.

bfd:
PR ld/26589
* elf32-cris.c (cris_elf_check_relocs): Add missing NULL check
on argument before calling UNDEFWEAK_NO_DYNAMIC_RELOC.

ld:
PR ld/26589
* testsuite/ld-elf/pr26589.d, testsuite/ld-elf/locref3.s: New test.

4 years agogdb: fix compile break when HAVE_LIBEXPAT is not defined
Michael Mullin [Tue, 15 Sep 2020 00:39:54 +0000 (20:39 -0400)]
gdb: fix compile break when HAVE_LIBEXPAT is not defined

Fixes:

      CXX    xml-tdesc.o
    /home/smarchi/src/binutils-gdb/gdb/xml-tdesc.c: In function const target_desc* file_read_description_xml(const char*):
    /home/smarchi/src/binutils-gdb/gdb/xml-tdesc.c:681:60: error: too few arguments to function target_desc* tdesc_parse_xml(const char*, xml_fetch_another, void*)
      681 |   return tdesc_parse_xml (tdesc_str->data (), fetch_another);
          |                                                            ^
    /home/smarchi/src/binutils-gdb/gdb/xml-tdesc.c:44:1: note: declared here
       44 | tdesc_parse_xml (const char *document, xml_fetch_another fetcher,
          | ^~~~~~~~~~~~~~~

Commit 8400a90d19c5 ("gdb: change xml_fetch_another a function_view")
removed the `baton` parameter of `tdesc_parse_xml`, but didn't update
the version of the function used when GDB is built with no libexpat
support.  Remove the parameter in that definition too.

gdb/ChangeLog:

* xml-tdesc.c [!defined(HAVE_LIBEXPAT)] (tdesc_parse_xml):
Remove baton parameter.

Change-Id: I4ad29fbb7c3323f30ce5204c2976eaea16151a2e

4 years agoAutomatic date update in version.in
GDB Administrator [Tue, 15 Sep 2020 00:00:06 +0000 (00:00 +0000)]
Automatic date update in version.in

4 years agoRewrite enum_flags, add unit tests, fix problems
Pedro Alves [Mon, 14 Sep 2020 20:16:59 +0000 (21:16 +0100)]
Rewrite enum_flags, add unit tests, fix problems

This patch started by adding comprehensive unit tests for enum_flags.

For the testing part, it adds:

 - tests of normal expected uses of the API.

 - checks that _invalid_ uses of the API would fail to compile.  I.e.,
   it validates that enum_flags really is a strong type, and that
   incorrect mixing of enum types would be caught at compile time.  It
   pulls that off making use of SFINEA and C++11's decltype/constexpr.

This revealed many holes in the enum_flags API.  For example, the f1
assignment below currently incorrectly fails to compile:

 enum_flags<flags> f1 = FLAG1;
 enum_flags<flags> f2 = FLAG2 | f1;

The unit tests also revealed that this useful use case doesn't work:

    enum flag { FLAG1 = 1, FLAG2 = 2 };
    enum_flags<flag> src = FLAG1;
    enum_flags<flag> f1 = condition ? src : FLAG2;

It fails to compile because enum_flags<flag> and flag are convertible
to each other.

Turns out that making enum_flags be implicitly convertible to the
backing raw enum type was not a good idea.

If we make it convertible to the underlying type instead, we fix that
ternary operator use case, and, we find cases throughout the codebase
that should be using the enum_flags but were using the raw backing
enum instead.  So it's a good change overall.

Also, several operators were missing.

These holes and more are plugged by this patch, by reworking how the
enum_flags operators are implemented, and making use of C++11's
feature of being able to delete methods/functions.

There are cases in gdb/compile/ where we need to call a function in a
C plugin API that expects the raw enum.  To address cases like that,
this adds a "raw()" method to enum_flags.  This way we can keep using
the safer enum_flags to construct the value, and then be explicit when
we need to get at the raw enum.

This makes most of the enum_flags operators constexpr.  Beyond
enabling more compiler optimizations and enabling the new unit tests,
this has other advantages, like making it possible to use operator|
with enum_flags values in switch cases, where only compile-time
constants are allowed:

    enum_flags<flags> f = FLAG1 | FLAG2;
    switch (f)
      {
      case FLAG1 | FLAG2:
break;
      }

Currently that fails to compile.

It also switches to a different mechanism of enabling the global
operators.  The current mechanism isn't namespace friendly, the new
one is.

It also switches to C++11-style SFINAE -- instead of wrapping the
return type in a SFINAE-friently structure, we use an unnamed template
parameter.  I.e., this:

  template <typename enum_type,
    typename = is_enum_flags_enum_type_t<enum_type>>
  enum_type
  operator& (enum_type e1, enum_type e2)

instead of:

  template <typename enum_type>
  typename enum_flags_type<enum_type>::type
  operator& (enum_type e1, enum_type e2)

Note that the static_assert inside operator~() was converted to a
couple overloads (signed vs unsigned), because static_assert is too
late for SFINAE-based tests, which is important for the CHECK_VALID
unit tests.

Tested with gcc {4.8, 7.1, 9.3} and clang {5.0.2, 10.0.0}.

gdb/ChangeLog:

* Makefile.in (SELFTESTS_SRCS): Add
unittests/enum-flags-selftests.c.
* btrace.c (ftrace_update_caller, ftrace_fixup_calle): Use
btrace_function_flags instead of enum btrace_function_flag.
* compile/compile-c-types.c (convert_qualified): Use
enum_flags::raw.
* compile/compile-cplus-symbols.c (convert_one_symbol)
(convert_symbol_bmsym):
* compile/compile-cplus-types.c (compile_cplus_convert_method)
(compile_cplus_convert_struct_or_union_methods)
(compile_cplus_instance::convert_qualified_base):
* go-exp.y (parse_string_or_char): Add cast to int.
* unittests/enum-flags-selftests.c: New file.
* record-btrace.c (btrace_thread_flag_to_str): Change parameter's
type to btrace_thread_flags from btrace_thread_flag.
(record_btrace_cancel_resume, record_btrace_step_thread): Change
local's type to btrace_thread_flags from btrace_thread_flag.  Add
cast in DEBUG call.

gdbsupport/ChangeLog:

* enum-flags.h: Include "traits.h".
(DEF_ENUM_FLAGS_TYPE): Declare a function instead of defining a
structure.
(enum_underlying_type): Update comment.
(namespace enum_flags_detail): New.  Move struct zero_type here.
(EnumIsUnsigned, EnumIsSigned): New.
(class enum_flags): Make most methods constexpr.
(operator&=, operator|=, operator^=): Take an enum_flags instead
of an enum_type.  Make rvalue ref versions deleted.
(operator enum_type()): Delete.
(operator&, operator|, operator^, operator~): Delete, moved out of
class.
(raw()): New method.
(is_enum_flags_enum_type_t): Declare.
(ENUM_FLAGS_GEN_BINOP, ENUM_FLAGS_GEN_COMPOUND_ASSIGN)
(ENUM_FLAGS_GEN_COMP): New.  Use them to reimplement global
operators.
(operator~): Now constexpr and reimplemented.
(operator<<, operator>>): New deleted functions.
* valid-expr.h (CHECK_VALID_EXPR_5, CHECK_VALID_EXPR_6): New.

4 years agoRewrite valid-expr.h's internals in terms of the detection idiom (C++17/N4502)
Pedro Alves [Mon, 14 Sep 2020 20:16:57 +0000 (21:16 +0100)]
Rewrite valid-expr.h's internals in terms of the detection idiom (C++17/N4502)

An earlier attempt at doing this had failed (wouldn't work in GCCs
around 4.8, IIRC), but now that I try again, it works.  I suspect that
my previous attempt did not use the pre C++14-safe void_t (in
traits.h).

I want to switch to this model because:

 - It's the standard detection idiom that folks will learn starting
   with C++17.

 - In the enum_flags unit tests, I have a static_assert that triggers
   a warning (resulting in build error), which GCC does not suppress
   because the warning is not being triggered in the SFINAE context.
   Switching to the detection idiom fixes that.  Alternatively,
   switching to the C++03-style expression-validity checking with a
   varargs overload would allow addressing that, but I think that
   would be going backwards idiomatically speaking.

 - While this patch shows a net increase of lines of code, the magic
   being added to traits.h can be removed in a few years when we start
   requiring C++17.

gdbsupport/ChangeLog:

* traits.h (struct nonesuch, struct detector, detected_or)
(detected_or_t, is_detected, detected_t, detected_or)
(detected_or_t, is_detected_exact, is_detected_convertible): New.
* valid-expr.h (CHECK_VALID_EXPR_INT): Use gdb::is_detected_exact.

4 years agoRename address_space_int_to_name/address_space_name_to_int
Pedro Alves [Mon, 14 Sep 2020 20:16:57 +0000 (21:16 +0100)]
Rename address_space_int_to_name/address_space_name_to_int

These methods now take/return a type_instance_flags instead of a raw
integer, so rename them accordingly.

gdb/ChangeLog:

* c-typeprint.c (c_type_print_modifier): Adjust to rename.
* gdbtypes.c (address_space_name_to_int): Rename to ...
(address_space_name_to_type_instance_flags): ... this.
(address_space_int_to_name): Rename to ...
(address_space_type_instance_flags_to_name): ... this.
* gdbtypes.h (address_space_name_to_int): Rename to ...
(address_space_name_to_type_instance_flags): ... this.
(address_space_int_to_name): Rename to ...
(address_space_type_instance_flags_to_name): ... this.
* type-stack.c (type_stack::insert): Adjust to rename.
* type-stack.h (type_stack::insert): Likewise.

4 years agoUse type_instance_flags more throughout
Pedro Alves [Mon, 14 Sep 2020 20:16:56 +0000 (21:16 +0100)]
Use type_instance_flags more throughout

A later patch in this series will rewrite enum_flags fixing some API
holes.  That would cause build failures around code using
type_instance_flags.  Or rather, that should be using it, but wasn't.

This patch fixes it by using type_instance_flags throughout instead of
plain integers.

Note that we can't make the seemingly obvious change to struct
type::instance_flags:

 -  unsigned instance_flags : 9;
 +  ENUM_BITFIELD (type_instance_flag_value) instance_flags : 9;

Because G++ complains then that 9 bits isn't sufficient for holding
all values of type_instance_flag_value.

So the patch adds an type::instance_flags() method, which takes care
of casting appropriately, and adds a separate type::set_instance_flags
method, following the pattern of the ongoing TYPE_XXX macro
elimination.  This converts uses of TYPE_INSTANCE_FLAGS to
type::instance_flags() in the places where the code was already being
touched, but there are still many references to the
TYPE_INSTANCE_FLAGS macro left behind.  Those could/should be fully
replaced at some point.

gdb/ChangeLog:

* avr-tdep.c (avr_address_class_type_flags): Return
type_instance_flags.
(avr_address_class_type_flags_to_name): Take a
type_instance_flags.
(avr_address_class_name_to_type_flags): Return bool and take a
type_instance_flags.
* d-lang.c (build_d_types): Use type::set_instance_flags.
* ft32-tdep.c (ft32_address_class_type_flags): Return
type_instance_flags.
(ft32_address_class_type_flags_to_name): Take a
type_instance_flags.
(ft32_address_class_name_to_type_flags): Return bool and take a
type_instance_flags.
(ft32_gdbarch_init): Use type::set_instance_flags.
* eval.c (fake_method::fake_method): Use type::set_instance_flags.
* gdbarch.h, gdbarch.c: Regenerate.
* gdbarch.sh (address_class_type_flags): Use type_instance_flags.
(address_class_name_to_type_flags): Use type_instance_flags and
bool.
* gdbtypes.c (address_space_name_to_int)
(address_space_int_to_name, make_qualified_type): Use
type_instance_flags.
(make_qualified_type): Use type_instance_flags and
type::set_instance_flags.
(make_type_with_address_space, make_cv_type, make_vector_type)
(check_typedef): Use type_instance_flags.
(recursive_dump_type): Cast type_instance_flags to unsigned for
printing.
(copy_type_recursive): Use type::set_instance_flags.
(gdbtypes_post_init): Use type::set_instance_flags.
* gdbtypes.h (struct type) <instance_flags>: Rename to ...
<m_instance_flags>: ... this.
<instance_flags, set_instance_flags>: New methods.
(TYPE_INSTANCE_FLAGS): Use the instance_flags method.
(SET_TYPE_INSTANCE_FLAGS): New.
(address_space_name_to_int, address_space_int_to_name)
(make_type_with_address_space): Pass flags using
type_instance_flags instead of int.
* stabsread.c (cleanup_undefined_types_noname): Use
type::set_instance_flags.
* s390-tdep.c (s390_address_class_type_flags): Return
type_instance_flags.
(s390_address_class_type_flags_to_name): Take a
type_instance_flags.
(s390_address_class_name_to_type_flags): Return bool and take a
type_instance_flags.
* type-stack.c (type_stack::follow_types): Use
type_instance_flags.
* dwarf2/read.c (read_tag_pointer_type): Use type_instance_flags.

4 years agoApply 'const' in more places
Tom Tromey [Mon, 14 Sep 2020 18:09:59 +0000 (12:09 -0600)]
Apply 'const' in more places

Many global arrays in gdb could be marked "const" but are not.  This
patch changes some of them.  (There may be other arrays that could
benefit from this treatment.  I only examined arrays of strings.)

This lets the linker move some symbols to the readonly data section.
For example, previously:

0000000000000000 d _ZL18can_use_agent_enum

is now:

0000000000000030 r _ZL18can_use_agent_enum

2020-09-14  Tom Tromey  <tromey@adacore.com>

* x86-tdep.h (x86_in_indirect_branch_thunk): Update.
* x86-tdep.c (x86_is_thunk_register_name)
(x86_in_indirect_branch_thunk): Update.
* sparc64-tdep.c (sparc64_fpu_register_names)
(sparc64_cp0_register_names, sparc64_register_names)
(sparc64_pseudo_register_names): Now const.
* sparc-tdep.h (struct gdbarch_tdep) <fpu_register_names,
cp0_registers_num>: Now const.
* sparc-tdep.c (sparc_core_register_names)
(sparc32_fpu_register_names, sparc32_cp0_register_names)
(sparc32_pseudo_register_names): Now const.
(validate_tdesc_registers): Update.
* rust-lang.c (rust_extensions): Now const.
* p-lang.c (p_extensions): Now const.
* objc-lang.c (objc_extensions): Now const.
* nto-tdep.c (nto_thread_state_str): Now const.
* moxie-tdep.c (moxie_register_names): Now const.
* mips-tdep.h (struct gdbarch_tdep) <mips_processor_reg_names>:
Now const.
* mips-tdep.c (mips_generic_reg_names, mips_tx39_reg_names)
(mips_linux_reg_names): Now const.
(mips_gdbarch_init): Update.
* microblaze-tdep.c (microblaze_register_names): Now const.
* m68k-tdep.c (m68k_register_names): Now const.
* m32r-tdep.c (m32r_register_names): Now const.
* ia64-tdep.c (ia64_register_names): Now const.
* i386-tdep.h (struct gdbarch_tdep) <register_names,
ymmh_register_names, ymm16h_regnum, mpx_register_names,
k_register_names, zmmh_register_names, xmm_avx512_register_names,
ymm_avx512_register_names, pkeys_register_names>: Now const.
* i386-tdep.c (i386_register_names, i386_zmm_names)
(i386_zmmh_names, i386_k_names, i386_ymm_names, i386_ymmh_names)
(i386_mpx_names, i386_pkeys_names, i386_bnd_names)
(i386_mmx_names, i386_byte_names, i386_word_names): Now const.
* f-lang.c (f_extensions): Now const.
* d-lang.c (d_extensions): Now const.
* csky-tdep.c (csky_register_names): Now const.
* charset.c (default_charset_names, charset_enum): Now const.
(_initialize_charset): Update.
* c-lang.c (c_extensions, cplus_extensions, asm_extensions): Now
const.
* bsd-uthread.c (bsd_uthread_solib_names): Now const.
(bsd_uthread_solib_loaded): Update.
(bsd_uthread_state): Now const.
* amd64-tdep.c (amd64_register_names, amd64_ymm_names)
(amd64_ymm_avx512_names, amd64_ymmh_names)
(amd64_ymmh_avx512_names, amd64_mpx_names, amd64_k_names)
(amd64_zmmh_names, amd64_zmm_names, amd64_xmm_avx512_names)
(amd64_pkeys_names, amd64_byte_names, amd64_word_names)
(amd64_dword_names): Now const.
* agent.c (can_use_agent_enum): Now const.
* ada-tasks.c (task_states, long_task_states): Now const.
* ada-lang.c (known_runtime_file_name_patterns)
(known_auxiliary_function_name_patterns, attribute_names)
(standard_exc, ada_extensions): Now const.

gdbserver/ChangeLog
2020-09-14  Tom Tromey  <tromey@adacore.com>

* tracepoint.cc (eval_result_names): Now const.
* ax.cc (gdb_agent_op_names): Now const.

4 years agogdb: turn gdb::bcache's function pointers into virtual methods
Simon Marchi [Mon, 14 Sep 2020 18:02:30 +0000 (14:02 -0400)]
gdb: turn gdb::bcache's function pointers into virtual methods

The two function pointers optionally passed to gdb::bcache are very good
candidates to be turned into virtual methods, this patch does that in
the most straightforward / unsurprising way.

gdb/ChangeLog:

* bcache.h (struct bcache) <bcache>: Remove constructor.
<m_hash_function, m_compare_function>: Remove.
<~bcache>: Make virtual.
<compare>: Remove static method, introduce virtual method.
<default_hash>: Remove.
<hash>: New virtual method.
* bcache.c (bcache::expand_hash_table): Update.
(bcache::insert): Update.
(bcache::hash): New.
(bcache::compare): Update comment and parameter names.
* gdbtypes.c (types_deeply_equal): Update.
* psymtab.h (struct psymbol_bcache): New struct.
(class psymtab_storage) <psymtab_storage>: Make default.
<psymbol_cache>: Change type to psymbol_bcache.
* psymtab.c (psymtab_storage::psymtab_storage): Remove.
(psymbol_hash): Change to...
(psymbol_bcache::hash): ... this.
(psymbol_compare): Change to...
(psymbol_bcache::compare): ... this.

Change-Id: I41d578e61de8ac1163461a28fbd220d1f855e372

4 years agoFix support for theassembler's new ".nop" directive on the IA64 target.
Nick Clifton [Mon, 14 Sep 2020 15:56:41 +0000 (16:56 +0100)]
Fix support for theassembler's new ".nop" directive on the IA64 target.

* config/tc-ia64.h (md_single_noop_insn): Define.

4 years agogdb: don't use inferior_ptid in linux_nat_wait_1
Simon Marchi [Mon, 14 Sep 2020 15:51:04 +0000 (11:51 -0400)]
gdb: don't use inferior_ptid in linux_nat_wait_1

target_ops::wait implementations should not rely on the value of
inferior_ptid on entry.  While looking at another wait-related patch, I
noticed that the code in linux_nat_wait_1, checking for a newly created
process, did just that.  This patch fixes it.  Note that I didn't see
any bug, this "fix" is simply to make the function respect the
target_ops::wait contract.

Instead of checking inferior_ptid, check for the passed in `ptid`
value.

During startup, linux_nat_wait_1 gets called a few times with the
pid-only ptid, while startup_inferior waits for the expected number of
exec events.  For this reason, I needed to add a `find_lwp_pid` call to
ensure that the actions of changing the main thread's ptid, and adding
the initial lwp, were done only once for a given process.

This was not needed before, since thread_change_ptid, through the
thread_ptid_changed observer, ends up changing inferior_ptid.  So the
second time around, inferior_ptid was not a pid-only ptid.

That find_lwp_pid won't add much overhead, as it will only be called
when the ptid is a pid-only ptid.  And AFAIK, that only happens during
inferior startup.

An alternative to that `find_lwp_pid` call might be to make
startup_inferior realize that the main thread has changed ptid, and make
it wait for the new ptid.  But that doesn't look easy to do.

Regtested on amd64/Linux.

gdb/ChangeLog:

* linux-nat.c (linux_nat_wait_1): Don't use inferior_ptid when
checking for initial lwp.

Change-Id: I8f1d5c766f5cb2a29c948bc75fa4582d7130c23f

4 years agoVarious m68k fixes for gdb
Tom Tromey [Mon, 14 Sep 2020 14:30:10 +0000 (08:30 -0600)]
Various m68k fixes for gdb

Recently I tried the m68k port of gdb.  It had some issues, which are
fixed in this patch.

* Various types of return values were not being handled properly.  In
  particular:

  * arrays are returned by following the same convention as
    structures.  This matters in languages like Ada, where an array
    can in fact be returned as a value.

  * "long double" was not being handled correctly in
    m68k_svr4_return_value.

  * GCC's m68k back end does not return vector types in registers, so
    change gdb to follow.

  * GCC's m68k back end doesn't faithfully implement the ABI, and so
    some objects with unusual size (not possible in C, but possible in
    Ada) are not returned correctly.

* gcc implements an m68k ABI variant that it simply describes as
  "embedded".  This ABI is similar to the SVR4 ABI, but rather than
  returning pointer-typed values in %a0, such values are returned in
  %d0.  To support this, an ELF osabi sniffer is added.

* Commit 85f7484a ("m68k: tag floating-point ABI used") adds an
  attribute that can be used to recognize when hard- or soft-float is
  in use.  gdb can now read this tag and choose the ABI accordingly.

I was unable to run the gdb test suite with this patch.  Instead, I
tested it using qemu and the internal AdaCore test suite.

gdb/ChangeLog
2020-09-14  Tom Tromey  <tromey@adacore.com>

* m68k-tdep.c (m68k_extract_return_value): Use
pointer_result_regnum.
(m68k_store_return_value): Likewise.
(m68k_reg_struct_return_p): Handle vectors and arrays.
(m68k_return_value): Handle arrays.
(m68k_svr4_return_value): Fix single-element aggregate handling.
Handle long double.  Adjust for embedded ABI.
(m68k_svr4_init_abi): Set pointer_result_regnum.
(m68k_embedded_init_abi): New function.
(m68k_gdbarch_init): Handle Tag_GNU_M68K_ABI_FP.
(m68k_osabi_sniffer): New function.
(_initialize_m68k_tdep): Register osabi sniffer.
* m68k-tdep.h (struct gdbarch_tdep) <pointer_result_regnum>: New
member.

4 years agogdb: remove xfree in xml-support.c
Simon Marchi [Mon, 14 Sep 2020 15:12:55 +0000 (11:12 -0400)]
gdb: remove xfree in xml-support.c

Replace an xfree with automatic memory management with a unique pointer.

gdb/ChangeLog:

* xml-support.c (xml_fetch_content_from_file): Replace xfree
with gdb::unique_xmalloc_ptr<char>.

Change-Id: Ia4d735b383e3b9eb660f445f2c7f2c5e27411b64

4 years agogdb: change xml_fetch_another a function_view
Simon Marchi [Mon, 14 Sep 2020 15:12:55 +0000 (11:12 -0400)]
gdb: change xml_fetch_another a function_view

The xml_fetch_another is currently a plain function pointer type, with a
`void *` baton parameter.  To improve type-safety, change this to a
function_view.  Any required data is captured by a lambda at the call
site.

gdb/ChangeLog:

* xml-support.h (xml_fetch_another): Change type to be a
function_view.
(xml_process_xincludes): Remove baton parameter.
(xml_fetch_content_from_file): Change baton parameter to
dirname.
* xml-support.c (struct xinclude_parsing_data)
<xinclude_parsing_data>: Remove baton parameter.
<fetcher_baton>: Remove.
(xinclude_start_include): Adjust.
(xml_process_xincludes): Adjust.
(xml_fetch_content_from_file): Replace baton parameter with
dirname.
* xml-syscall.c (syscall_parse_xml): Remove baton parameter.
(xml_init_syscalls_info): Use a lambda.
* xml-tdesc.c (tdesc_parse_xml): Remove baton parameter.
(file_read_description_xml): Use a lambda.
(fetch_available_features_from_target): Change baton parameter
to target_ops.
(target_read_description_xml): Use a lambda.
(target_fetch_description_xml): Use a lambda.
(string_read_description_xml): Update.

Change-Id: I7ba4b8f5e97fc6a952c6c20ccc3be92a06cc2bd2

4 years agoAdd a new ".nop" directive to the assembler to allow the creation of no-op instructio...
Nick Clifton [Mon, 14 Sep 2020 15:14:24 +0000 (16:14 +0100)]
Add a new ".nop" directive to the assembler to allow the creation of no-op instructions in an architeture neutral manner.

* read.c (s_nop): New function.  Handles the .nop directive.
(potable): Add entry for "nop".
(s_nops): Code tidy.
* read.h (s_nop): Add prototype.
* config/tc-bpf.h (md_single_noop_insn): Define.
* config/tc-mmix.h (md_single_noop_insn): Define.
* config/tc-or1k.h (md_single_noop_insn): Define.
* config/tc-s12z.c (md_assemble): Preserve the input line pointer,
rather than corrupting it.
* write.c (relax_segment): Update error message regarding
non-absolute values passed to .fill and .nops.
* NEWS: Mention the new directive.
* doc/as.texi: Document the new directive.
* doc/internals.texi: Document the new internal macros used to
implement the new directive.
* testsuite/gas/all/nop.s: New test.
* testsuite/gas/all/nop.d: New test control file.
* testsuite/gas/all/gas.exp: Run the new test.
* testsuite/gas/elf/dwarf-5-nop-for-line-table.s: New test.
* testsuite/gas/elf/dwarf-5-nop-for-line-table.d: New test
control file.
* testsuite/gas/elf/elf.exp: Run the new test.
* testsuite/gas/i386/space1.l: Adjust expected output.

4 years agogdb: remove TYPE_ENDIANITY_NOT_DEFAULT
Simon Marchi [Mon, 14 Sep 2020 15:08:08 +0000 (11:08 -0400)]
gdb: remove TYPE_ENDIANITY_NOT_DEFAULT

gdb/ChangeLog:

* gdbtypes.h (TYPE_ENDIANITY_NOT_DEFAULT): Remove, replace all
uses with type::endianity_is_not_default.

Change-Id: I61956093c8ce6703299e913746ba91313108a0f2

4 years agogdb: add type::endianity_is_not_default / type::set_endianity_is_not_default
Simon Marchi [Mon, 14 Sep 2020 15:08:07 +0000 (11:08 -0400)]
gdb: add type::endianity_is_not_default / type::set_endianity_is_not_default

Add the `endianity_is_not_default` and `set_endianity_is_not_default`
methods on `struct type`, in order to remove the
`TYPE_ENDIANITY_NOT_DEFAULT` macro.  In this patch, the macro is changed
to use the getter, so all the call sites of the macro that are used as a
setter are changed to use the setter method directly.  The next patch
will remove the macro completely.

gdb/ChangeLog:

* gdbtypes.h (struct type) <endianity_is_not_default,
set_endianity_is_not_default>: New methods.
(TYPE_ENDIANITY_NOT_DEFAULT): Use
type::endianity_is_not_default, change all write call sites to
use type::set_endianity_is_not_default.

Change-Id: I67acd68fcdae424d7e4a601afda78612ad5d92db

4 years agogdb: remove TYPE_FIXED_INSTANCE
Simon Marchi [Mon, 14 Sep 2020 15:08:07 +0000 (11:08 -0400)]
gdb: remove TYPE_FIXED_INSTANCE

gdb/ChangeLog:

* gdbtypes.h (TYPE_FIXED_INSTANCE): Remove, replace all
uses with type::is_fixed_instance.

Change-Id: I57731b5ab44aac7d8896a32b9c7481891baea51a

4 years agogdb: add type::is_fixed_instance / type::set_is_fixed_instance
Simon Marchi [Mon, 14 Sep 2020 15:08:06 +0000 (11:08 -0400)]
gdb: add type::is_fixed_instance / type::set_is_fixed_instance

Add the `is_fixed_instance` and `set_is_fixed_instance` methods on `struct
type`, in order to remove the `TYPE_FIXED_INSTANCE` macro.  In this patch, the
macro is changed to use the getter, so all the call sites of the macro that are
used as a setter are changed to use the setter method directly.  The next patch
will remove the macro completely.

gdb/ChangeLog:

* gdbtypes.h (struct type) <is_fixed_instance,
set_is_fixed_instance>: New methods.
(TYPE_FIXED_INSTANCE): Use type::is_fixed_instance, change all
write call sites to use type::set_is_fixed_instance.

Change-Id: I4401d81512fab9eab4232bbea48ce6c7d586b94c

4 years agogdb: remove TYPE_GNU_IFUNC
Simon Marchi [Mon, 14 Sep 2020 15:08:06 +0000 (11:08 -0400)]
gdb: remove TYPE_GNU_IFUNC

gdb/ChangeLog:

* gdbtypes.h (TYPE_GNU_IFUNC): Remove, replace all
uses with type::is_gnu_ifunc.

Change-Id: I72aae22599b5e582910c5d50588feaf159032bd8

4 years agogdb: add type::is_gnu_ifunc / type::set_is_gnu_ifunc
Simon Marchi [Mon, 14 Sep 2020 15:08:05 +0000 (11:08 -0400)]
gdb: add type::is_gnu_ifunc / type::set_is_gnu_ifunc

Add the `is_gnu_ifunc` and `set_is_gnu_ifunc` methods on `struct type`, in
order to remove the `TYPE_GNU_IFUNC` macro.  In this patch, the macro is
changed to use the getter, so all the call sites of the macro that are
used as a setter are changed to use the setter method directly.  The
next patch will remove the macro completely.

gdb/ChangeLog:

* gdbtypes.h (struct type) <is_gnu_ifunc, set_is_gnu_ifunc>: New methods.
(TYPE_GNU_IFUNC): Use type::is_gnu_ifunc, change all write call sites to
use type::set_is_gnu_ifunc.

Change-Id: Ic23ba8c5b8e589d9fc368385111aa16a94e014e2

4 years agogdb: remove TYPE_STUB_SUPPORTED
Simon Marchi [Mon, 14 Sep 2020 15:08:04 +0000 (11:08 -0400)]
gdb: remove TYPE_STUB_SUPPORTED

gdb/ChangeLog:

* gdbtypes.h (TYPE_STUB_SUPPORTED): Remove, replace all
uses with type::stub_is_supported.

Change-Id: I69dbc32a619455605b7f934a701bc36bd664b7c0

4 years agogdb: add type::stub_is_supported / type::set_stub_is_supported
Simon Marchi [Mon, 14 Sep 2020 15:08:03 +0000 (11:08 -0400)]
gdb: add type::stub_is_supported / type::set_stub_is_supported

Add the `stub_is_supported` and `set_stub_is_supported` methods on `struct type`, in
order to remove the `TYPE_STUB_SUPPORTED` macro.  In this patch, the macro is
changed to use the getter, so all the call sites of the macro that are
used as a setter are changed to use the setter method directly.  The
next patch will remove the macro completely.

gdb/ChangeLog:

* gdbtypes.h (struct type) <stub_is_supported, set_stub_is_supported>: New methods.
(TYPE_STUB_SUPPORTED): Use type::stub_is_supported, change all write call sites to
use type::set_stub_is_supported.

Change-Id: I4dfecf2b5df9c2b7bb8db1e9252082140adf3028

4 years agogdb: remove TYPE_VECTOR
Simon Marchi [Mon, 14 Sep 2020 15:08:03 +0000 (11:08 -0400)]
gdb: remove TYPE_VECTOR

gdb/ChangeLog:

* gdbtypes.h (TYPE_VECTOR): Remove, replace all
uses with type::is_vector.

Change-Id: I1ac28755af44b1585c190553f9961288c8fb9137

4 years agogdb: add type::is_vector / type::set_is_vector
Simon Marchi [Mon, 14 Sep 2020 15:08:02 +0000 (11:08 -0400)]
gdb: add type::is_vector / type::set_is_vector

Add the `is_vector` and `set_is_vector` methods on `struct type`, in
order to remove the `TYPE_VECTOR` macro.  In this patch, the macro is
changed to use the getter, so all the call sites of the macro that are
used as a setter are changed to use the setter method directly.  The
next patch will remove the macro completely.

gdb/ChangeLog:

* gdbtypes.h (struct type) <is_vector, set_is_vector>: New methods.
(TYPE_VECTOR): Use type::is_vector, change all write call sites to
use type::set_is_vector.

Change-Id: I415e8d169f058662e0750329bfa4017bea3ca0cb

4 years agogdb: remove TYPE_VARARGS
Simon Marchi [Mon, 14 Sep 2020 15:08:02 +0000 (11:08 -0400)]
gdb: remove TYPE_VARARGS

gdb/ChangeLog:

* gdbtypes.h (TYPE_VARARGS): Remove, replace all
uses with type::has_varargs.

Change-Id: Ieea4a64b4bfa4b8be643e68cb403081881133740

4 years agogdb: add type::has_varargs / type::set_has_varargs
Simon Marchi [Mon, 14 Sep 2020 15:08:01 +0000 (11:08 -0400)]
gdb: add type::has_varargs / type::set_has_varargs

Add the `has_varargs` and `set_has_varargs` methods on `struct type`, in
order to remove the `TYPE_VARARGS` macro.  In this patch, the macro is
changed to use the getter, so all the call sites of the macro that are
used as a setter are changed to use the setter method directly.  The
next patch will remove the macro completely.

gdb/ChangeLog:

* gdbtypes.h (struct type) <has_varargs, set_has_varargs>: New methods.
(TYPE_VARARGS): Use type::has_varargs, change all write call sites to
use type::set_has_varargs.

Change-Id: I898a1093ae40808b37a7c6fced7f6fa2aae604de

4 years agogdb: remove TYPE_PROTOTYPED
Simon Marchi [Mon, 14 Sep 2020 15:08:01 +0000 (11:08 -0400)]
gdb: remove TYPE_PROTOTYPED

gdb/ChangeLog:

* gdbtypes.h (TYPE_PROTOTYPED): Remove, replace all
uses with type::is_prototyped.

Change-Id: Ic96b19c24ce5afcd7e1302a75c39909767e4d885

4 years agogdb: add type::is_prototyped / type::set_is_prototyped
Simon Marchi [Mon, 14 Sep 2020 15:08:00 +0000 (11:08 -0400)]
gdb: add type::is_prototyped / type::set_is_prototyped

Add the `is_prototyped` and `set_is_prototyped` methods on `struct
type`, in order to remove the `TYPE_PROTOTYPED` macro.  In this patch,
the macro is changed to use the getter, so all the call sites of the
macro that are used as a setter are changed to use the setter method
directly.  The next patch will remove the macro completely.

gdb/ChangeLog:

* gdbtypes.h (struct type) <is_prototyped, set_is_prototyped>:
New methods.
(TYPE_PROTOTYPED): Use type::is_prototyped, change all write
call sites to use type::set_is_prototyped.

Change-Id: I6ba285250fae413f7c1bf2ffcb5a2cedc8e743da

4 years agogdb: remove TYPE_TARGET_STUB
Simon Marchi [Mon, 14 Sep 2020 15:08:00 +0000 (11:08 -0400)]
gdb: remove TYPE_TARGET_STUB

gdb/ChangeLog:

* gdbtypes.h (TYPE_TARGET_STUB): Remove, replace all
uses with type::target_is_stub.

Change-Id: I3e7dadcb485d991af68a1e93693e3895b0e755d5

4 years agogdb: add type::target_is_stub / type::set_target_is_stub
Simon Marchi [Mon, 14 Sep 2020 15:07:59 +0000 (11:07 -0400)]
gdb: add type::target_is_stub / type::set_target_is_stub

Add the `target_is_stub` and `set_target_is_stub` methods on `struct
type`, in order to remove the `TYPE_TARGET_STUB` macro.  In this patch,
the macro is changed to use the getter, so all the call sites of the
macro that are used as a setter are changed to use the setter method
directly.  The next patch will remove the macro completely.

gdb/ChangeLog:

* gdbtypes.h (struct type) <target_is_stub, set_target_is_stub>:
New methods.
(TYPE_TARGET_STUB): Use type::is_stub, change all write call
sites to use type::set_target_is_stub.

Change-Id: I9c71a89adc7ae8d018db9ee156f41c623be0484a

4 years agogdb: remove TYPE_STUB
Simon Marchi [Mon, 14 Sep 2020 15:07:59 +0000 (11:07 -0400)]
gdb: remove TYPE_STUB

gdb/ChangeLog:

* gdbtypes.h (TYPE_STUB): Remove, replace all
uses with type::is_stub.

Change-Id: Iec25b50449a0d10a38f815209e478c343e98632c

4 years agogdb: add type::is_stub / type::set_is_stub
Simon Marchi [Mon, 14 Sep 2020 15:07:58 +0000 (11:07 -0400)]
gdb: add type::is_stub / type::set_is_stub

Add the `is_stub` and `set_is_stub` methods on `struct type`, in order
to remove the `TYPE_STUB` macro.  In this patch, the macro is changed to
use the getter, so all the call sites of the macro that are used as a
setter are changed to use the setter method directly.  The next patch
will remove the macro completely.

gdb/ChangeLog:

* gdbtypes.h (struct type) <is_stub, set_is_stub>: New methods.
(TYPE_STUB): Use type::is_stub, change all write call sites to
use type::set_is_stub.

Change-Id: Ie935e8fe72c908afd8718411e83f4ff00c386bf3

4 years agogdb: remove TYPE_NOSIGN
Simon Marchi [Mon, 14 Sep 2020 15:07:58 +0000 (11:07 -0400)]
gdb: remove TYPE_NOSIGN

gdb/ChangeLog:

* gdbtypes.h (TYPE_NOSIGN): Remove, replace all uses with
type::has_no_signedness.

Change-Id: Iaf8d1cedad195d03a4358e90f6ada77290d03bf2

4 years agogdb: add type::has_no_signedness / type::set_has_no_signedness
Simon Marchi [Mon, 14 Sep 2020 15:07:57 +0000 (11:07 -0400)]
gdb: add type::has_no_signedness / type::set_has_no_signedness

Add the `has_no_signedness` and `set_has_no_signednes` methods on `struct
type`, in order to remove the `TYPE_NOSIGN` macro.  In this patch, the macro is
changed to use the getter, so all the call sites of the macro that are used as
a setter are changed to use the setter method directly.  The next patch will
remove the macro completely.

gdb/ChangeLog:

* gdbtypes.h (struct type) <has_no_signedness,
set_has_no_signedness>: New methods.
(TYPE_NOSIGN): Use type::has_no_signedness, change all write
call sites to use type::set_has_no_signedness.

Change-Id: I80d8e774316d146fbd814b2928ad5392bada39d5

4 years agogdb: remove TYPE_UNSIGNED
Simon Marchi [Mon, 14 Sep 2020 15:07:57 +0000 (11:07 -0400)]
gdb: remove TYPE_UNSIGNED

gdb/ChangeLog:

* gdbtypes.h (TYPE_UNSIGNED): Remove, replace all uses with
type::is_unsigned.

Change-Id: I84f76f5cd44ff7294e421d317376a9e476bc8666

4 years agogdb: add type::is_unsigned / type::set_is_unsigned
Simon Marchi [Mon, 14 Sep 2020 15:07:56 +0000 (11:07 -0400)]
gdb: add type::is_unsigned / type::set_is_unsigned

Add the `is_unsigned` and `set_is_unsigned` methods on `struct type`, in
order to remove the `TYPE_UNSIGNED` macro.  In this patch, the
`TYPE_UNSIGNED` macro is changed to use `type::is_unsigned`, so all the
call sites that are used to set this property on a type are changed to
use the new method.  The next patch will remove the macro completely.

gdb/ChangeLog:

* gdbtypes.h (struct type) <is_unsigned, set_is_unsigned>: New
methods.
(TYPE_UNSIGNED): Use type::is_unsigned.  Change all write call
sites to use type::set_is_unsigned.

Change-Id: Ib09ddce84eda160a801a8f288cccf61c8ef136bc

4 years agoFix exception stack unwinding for ARM Cortex-M
Fredrik Hederstierna [Mon, 14 Sep 2020 13:56:34 +0000 (14:56 +0100)]
Fix exception stack unwinding for ARM Cortex-M

For Cortex-M targets using floating-point, eg the Cortex-M4F, its not possible
to get any call-stack backtrace if setting a breakpoint in ISR.

The exception stack unwinder for Cortex-M does not consider if floating-point
registers was stacked or not, further the Cortex-M has two stack pointers: MSP
(Main Stack Pointer) and PSP (Process Stack Pointer).
This is not handled when GDB tries to backtrace in the exception stack
unwinder.

This patch fixes this, and gives a correct call-stack backtrace from
breakpoints set in a handler or ISR.

gdb/ChangeLog:

        * arm-tdep.c (arm_m_exception_cache): Try use correct stack
        pointer and stack frame offset when unwinding.

4 years agoCSKY: Set feature flags for default cpu.
Cooper Qu [Sun, 13 Sep 2020 12:48:06 +0000 (20:48 +0800)]
CSKY: Set feature flags for default cpu.

Fix floating point instructions not recognized when building GCC.

gas/
PR 26608
* config/tc-csky.c (md_begin): Set feature flags for default
cpu.

4 years ago[gdb/testsuite] Fix PATH warning in gdb.rust/traits.exp
Tom de Vries [Mon, 14 Sep 2020 07:54:47 +0000 (09:54 +0200)]
[gdb/testsuite] Fix PATH warning in gdb.rust/traits.exp

When running the rust test-cases with release 1.36.0 and LLVM version 7.0, I
run into:
...
(gdb) UNTESTED: gdb.rust/traits.exp: could not read \
  outputs/gdb.rust/traits/traits with readelf
PATH: gdb.rust/traits.exp: could not read \
  outputs/gdb.rust/traits/traits with readelf
...

Fix the PATH warning by printing [file tail $binfile] instead $binfile.

Tested on x86_64-linux.

gdb/testsuite/ChangeLog:

2020-09-14  Tom de Vries  <tdevries@suse.de>

* gdb.rust/traits.exp: Fix PATH warning.

4 years agoAutomatic date update in version.in
GDB Administrator [Mon, 14 Sep 2020 00:00:14 +0000 (00:00 +0000)]
Automatic date update in version.in

4 years agogdb/testsuite: Explicitly return from main
Pedro Alves [Sun, 13 Sep 2020 21:47:01 +0000 (22:47 +0100)]
gdb/testsuite: Explicitly return from main

I've been playing with a board file that forces every testcase to
include a header file that does something like:

  #define main __gdb_testcase_main

and then links an actual main() function that does some
initialization and then jumps to __gdb_testcase_main.

That runs into a number of testcases relying on main not having an
explicit return statement, like e.g.,:

 gdb/build/gdb/testsuite/../../../src/gdb/testsuite/gdb.base/catch-follow-exec.c:27:1: warning: non-void function does not return a value [-Wreturn-type]
 gdb/build/gdb/testsuite/../../../src/gdb/testsuite/gdb.base/catch-signal.c:47:1: warning: non-void function does not return a value [-Wreturn-type]

We don't get those warnings without my board because it is valid to
not explicitly return from main.  There's an implicit "return 0;".

Since it doesn't hurt to be explicit, I've went ahead and added the
explicit return statements.

Also, a couple testcases either don't explicitly specify main's return
type, or return void.  Those are tweaked to explicitly return int.

gdb/testsuite/ChangeLog:

* gdb.base/catch-follow-exec.c (main): Add explicit return
statement.
* gdb.base/catch-signal.c (main): Likewise.
* gdb.base/condbreak-call-false.c (main): Likewise.
* gdb.base/consecutive.c (main): Add explicit return
statement and return type.
* gdb.base/cursal.c (main): Add explicit return statement.
* gdb.base/cvexpr.c (main): Likewise.
* gdb.base/display.c (main): Add explicit return statement and
return type.
* gdb.base/dprintf-detach.c (main): Add explicit return statement.
* gdb.base/endianity.c (main): Likewise.
* gdb.base/execd-prog.c (main): Likewise.
* gdb.base/gdb1090.c (main): Likewise.
* gdb.base/info_qt.c (main): Likewise.
* gdb.base/lineinc.c (main): Likewise.
* gdb.base/load-command.c (main): Likewise.
* gdb.base/macscp1.c (main): Likewise.
* gdb.base/pr10179-a.c (main): Likewise.
* gdb.base/quit-live.c (main): Likewise.
* gdb.base/scope0.c (main): Likewise.
* gdb.base/settings.c (main): Likewise.
* gdb.base/stack-checking.c (main): Return int.
* gdb.base/varargs.c (main): Add explicit return statement.
* gdb.cp/ambiguous.cc (main): Likewise.
* gdb.cp/anon-struct.cc (main): Likewise.
* gdb.cp/anon-union.cc (main): Likewise.
* gdb.cp/bool.cc (main): Likewise.
* gdb.cp/bs15503.cc (main): Likewise.
* gdb.cp/cplusfuncs.cc (main): Likewise.
* gdb.cp/cttiadd.cc (main): Likewise.
* gdb.cp/extern-c.cc (main): Likewise.
* gdb.cp/filename.cc (main): Likewise.
* gdb.cp/formatted-ref.cc (main): Likewise.
* gdb.cp/mb-ctor.cc (main): Likewise.
* gdb.cp/member-ptr.cc (main): Likewise.
* gdb.cp/minsym-fallback-main.cc (main): Likewise.
* gdb.cp/overload-const.cc (main): Likewise.
* gdb.cp/paren-type.cc (main): Likewise.
* gdb.cp/parse-lang.cc (main): Likewise.
* gdb.cp/pr-1023.cc (main): Likewise.
* gdb.cp/psmang1.cc (main): Likewise.
* gdb.cp/readnow-language.cc (main): Likewise.
* gdb.cp/ref-params.cc (main): Likewise.
* gdb.cp/rvalue-ref-params.cc (main): Likewise.
* gdb.cp/virtbase2.cc (main): Likewise.
* gdb.dwarf2/dw2-abs-hi-pc.c (main): Likewise.
* gdb.dwarf2/dw2-namespaceless-anonymous.c (main): Likewise.
* gdb.dwarf2/dw4-toplevel-types.cc (main): Likewise.
* gdb.mi/mi-console.c (main): Likewise.
* gdb.mi/mi-read-memory.c (main): Likewise.
* gdb.modula2/multidim.c (main): Likewise.
* gdb.opt/inline-small-func.c (main): Likewise.
* gdb.python/py-rbreak.c (main): Likewise.
* gdb.stabs/exclfwd1.c (main): Likewise.
* gdb.trace/qtro.c (main): Likewise.

4 years agoFix gdb.base/share-env-with-gdbserver.exp with Clang
Pedro Alves [Sun, 13 Sep 2020 20:28:09 +0000 (21:28 +0100)]
Fix gdb.base/share-env-with-gdbserver.exp with Clang

The testcase has GDB call my_getenv in the inferior, and that fails
with Clang, because Clang optimizes out my_getenv completely, since it
isn't called anywhere (in the program).

This commit fixes it.

gdb/testsuite/ChangeLog:

* gdb.base/share-env-with-gdbserver.c (main): Call my_getenv
instead of getenv.

4 years agoMake default_mi_gdb_start/dbx_gdb_start use gdb_spawn
Pedro Alves [Sun, 13 Sep 2020 19:31:25 +0000 (20:31 +0100)]
Make default_mi_gdb_start/dbx_gdb_start use gdb_spawn

If a board file wants to customize how gdb is launched, the obvious
way is to have the board override gdb_spawn.  However, that doesn't
work for either gdb.mi/ testcases or gdb.base/dbx.exp, because
default_mi_gdb_start and dbx_gdb_start don't use gdb_spawn currently.

That is fixed by this patch.

gdb/testsuite/

* gdb.base/dbx.exp (dbx_gdb_start): Adjust to use gdb_spawn
instead of spawning GDB with remote_spawn.
* lib/mi-support.exp (default_mi_gdb_start): Adjust to use
gdb_spawn instead of spawning GDB with remote_spawn.

4 years agoFix a couple gdb.dwarf2/ testcases with "clang -flto"
Pedro Alves [Sun, 13 Sep 2020 17:17:18 +0000 (18:17 +0100)]
Fix a couple gdb.dwarf2/ testcases with "clang -flto"

gdb.dwarf2/atomic-type.exp and gdb.dwarf2/ada-linkage-name.exp fail
when testing with "clang -flto" as compiler, like:

 $ make check TESTS="gdb.dwarf2/ada-linkage-name.exp" RUNTESTFLAGS="CC_FOR_TARGET='clang -flto'"

because with -flto, functions that aren't referenced anywhere are not
emitted in the final binary.  Fix it by adding uses of the functions.

gdb/testsuite/ChangeLog:

* gdb.dwarf2/ada-linkage-name.c (main): Move to the bottom of the
file and add calls to first and second.
* gdb.dwarf2/atomic.c (main): Move to the bottom of the file and
add call to f.

4 years agoAdd MI "-break-insert --qualified"
Pedro Alves [Sun, 13 Sep 2020 17:02:19 +0000 (18:02 +0100)]
Add MI "-break-insert --qualified"

Currently -break-insert always creates a wildmatching breakpoint, and
there's no way to ask for a fullname match.  To address that, this
patch adds the equivalent of "break -qualified" to MI:

  "-break-insert --qualified".

For the testcase, curiously, it doesn't look like we have _any_
testcase that tests a breakpoint with multiple locations, and, the
existing mi_create_breakpoint / mi_make_breakpoint procedures are only
good for breakpoints with a single location.  This patch thus adds a
few new companion routines to mi-support.exp for breakpoints with
multiple locations: mi_create_breakpoint_multi,
mi_make_breakpoint_loc, mi_make_breakpoint_multi.

gdb/ChangeLog:

* NEWS: Document "-break-insert --qualified".
* mi/mi-cmd-break.c (mi_cmd_break_insert_1): Handle "--qualified".

gdb/doc/ChangeLog:

* gdb.texinfo (GDB/MI Breakpoint Commands): Document
"-break-insert --qualified" and "-dprintf-insert --qualified".

gdb/testsuite/ChangeLog:

* gdb.mi/mi-break-qualified.cc: New file.
* gdb.mi/mi-break-qualified.exp: New file.
* lib/mi-support.exp (mi_create_breakpoint_multi)
(mi_make_breakpoint_loc, mi_make_breakpoint_multi): New
procedures.
(mi_create_breakpoint_1): New, factored out from
mi_create_breakpoint.

4 years agoRemove stale "register" bits from gdb.cp/misc.cc
Pedro Alves [Sat, 22 Aug 2020 17:00:55 +0000 (18:00 +0100)]
Remove stale "register" bits from gdb.cp/misc.cc

gdb.cp/misc.cc seems to have been originally copied from
gdb.cp/classes.cc.  The testcases that use it, misc.exp and
inherit.exp don't reference the "register" bits anywhere.  Remove
them, since they trigger warnings with newer GCCs, given "register" is
being removed in C++17.

gdb/testsuite/ChangeLog:

* gdb.cp/inherit.exp: No longer pass -Wno-deprecated-register.
* gdb.cp/misc.exp: No longer pass -Wno-deprecated-register.
* gdb.cp/misc.cc (class small, small::method, marker_reg1)
(register_class): Delete.
(main): Don't call register_class.

4 years agoMove "register" test out of classes.exp to a separate testcase
Pedro Alves [Sun, 13 Sep 2020 14:36:00 +0000 (15:36 +0100)]
Move "register" test out of classes.exp to a separate testcase

The gdb.cp/classes.exp testcase has one test that tries to exercise
the case of calling a method on a variable that has been put in a
register.

See the declaration of small in classes.cc:

/* Try to get the compiler to allocate a class in a register.  */
class small {
 public:
  int x;
  int method ();
};

and the comment in classes.exp:

    # This class is so small that an instance of it can fit in a register.
    # When gdb tries to call a method, it gets embarrassed about taking
    # the address of a register.
    #
    # TODO: I think that message should be a PASS, not an XFAIL.
    # gdb prints an informative message and declines to do something
    # impossible.
    #
    # The method call actually succeeds if the compiler allocates very
    # small classes in memory instead of registers.  So this test does
    # not tell us anything interesting if the call succeeds.
    #
    # -- chastain 2003-12-31

And these comments:

 https://gcc.gnu.org/legacy-ml/gcc/2010-05/msg00116.html
 https://gcc.gnu.org/legacy-ml/gcc/2010-05/msg00117.html

 "register keyword has other uses, e.g. for -O0 code variables
 declared with register keyword can be put into registers, while
 variables declared without it always get stack slots."

 "I think it does, without optimization.  There's some unique GDB
 tests that use this.  It causes them to be live between statements in
 a machine register instead of always stored in stack slots."

The "register" keyword seems to be ignored by the compiler nowadays
even at -O0, though.  With or without the register keyword, the
variable is given a stack slot, at least on x86-64 with GCC 9.

However, if we use the GCC extension to put the variable
in a specific variable:

 https://gcc.gnu.org/onlinedocs/gcc-10.2.0/gcc/Local-Register-Variables.html#Local-Register-Variables

 diff --git c/gdb/testsuite/gdb.cp/classes.cc w/gdb/testsuite/gdb.cp/classes.cc
 index 5ea360e4d06..6dcf34689b8 100644
 --- c/gdb/testsuite/gdb.cp/classes.cc
 +++ w/gdb/testsuite/gdb.cp/classes.cc
 @@ -629,7 +629,7 @@ register_class ()
    /* We don't call any methods for v, so gcc version cygnus-2.3.3-930220
       might put this variable in a register.  This is a lose, though, because
       it means that GDB can't call any methods for that variable.  */
 -  register small v;
 +  register small v asm ("rax");

then it works, and we get an XFAIL:

 print v.method ()
 Address requested for identifier "v" which is in register $rax
 (gdb) XFAIL: gdb.cp/classes.exp: calling method for small class (PRMS 2972)

I think that what we should do here is move this test into its own
file, use that GCC syntax to force it to a register, and do as the
comment says -- issue a pass instead of an XFAIL.

That's what this commit does.

Note that we don't need -Wno-deprecated-register (nor -Wno-register)
anymore in the new testcase, because GNU register-asm local variables
don't trigger the warning, with either GCC or Clang.

gdb/testsuite/ChangeLog:

* gdb.cp/classes.exp: No longer pass -Wno-deprecated-register.
(do_tests): Remove "calling method for small class" test.
* gdb.cp/classes.cc (class small, small::method, marker_reg1)
(register_class): Delete.
(main): Don't call register_class.
* gdb.cp/call-method-register.exp: New file, based on bits removed
from classes.exp.
* gdb.cp/call-method-register.cc: New file, based on bits removed
from classes.cc.

4 years agoDon't drop static function bp locations w/o debug info
Pedro Alves [Sun, 13 Sep 2020 12:34:10 +0000 (13:34 +0100)]
Don't drop static function bp locations w/o debug info

Currently, with a program built from these sources:

 $ cat extern.c
 void foo () {}
 $ cat static.c
 static void foo () {}
 $ cat main.c
 int main () { return 0; }

... if you set a breakpoint on "foo", like:

 (gdb) break foo

.. when there's debug info, GDB creates a breakpoint with two
locations, one for each of the external and static functions.

But, when there's no debug info, GDB creates a breakpoint with a
single location, for the external foo.  Vis:

 $ gcc extern.c static.c main.c -o classify.nodebug
 $ gcc extern.c static.c main.c -o classify.debug -g

 $ gdb classify.nodebug
 Reading symbols from classify.nodebug...
 (No debugging symbols found in classify.nodebug)
 (gdb) b foo
 Breakpoint 1 at 0x40048b
 (gdb) info breakpoints
 Num     Type           Disp Enb Address            What
 1       breakpoint     keep y   0x000000000040048b <foo+4>
 (gdb)

 $ gdb classify.debug
 Reading symbols from classify.debug...
 (gdb) b foo
 Breakpoint 1 at 0x40048b: foo. (2 locations)
 (gdb) info breakpoints
 Num     Type           Disp Enb Address            What
 1       breakpoint     keep y   <MULTIPLE>
 1.1                         y   0x000000000040048b in foo at extern.c:1
 1.2                         y   0x0000000000400492 in foo at static.c:1

GDB drops the static function is search_minsyms_for_name, where at the
very end of that function we pick only the locations with highest
classification, according to classify_type.

The classify_type logic was introduced here:

  https://sourceware.org/pipermail/gdb-patches/2011-December/087864.html

which said:

 "Previously, linespec was trying to filter out minsyms as they were
  seen.  However, this isn't faithful to gdb's historical approach,
  which is to priority-order minsyms; see lookup_minimal_symbol."

lookup_minimal_symbol's intro says, in the .c file:

/* Look through all the current minimal symbol tables and find the
   first minimal symbol that matches NAME.  If OBJF is non-NULL, limit
   the search to that objfile.  If SFILE is non-NULL, the only file-scope
   symbols considered will be from that source file (global symbols are
   still preferred).  Returns a pointer to the minimal symbol that
   matches, or NULL if no match is found.

   Note:  One instance where there may be duplicate minimal symbols with
   the same name is when the symbol tables for a shared library and the
   symbol tables for an executable contain global symbols with the same
   names (the dynamic linker deals with the duplication).

   It's also possible to have minimal symbols with different mangled
   names, but identical demangled names.  For example, the GNU C++ v3
   ABI requires the generation of two (or perhaps three) copies of
   constructor functions --- "in-charge", "not-in-charge", and
   "allocate" copies; destructors may be duplicated as well.
   Obviously, there must be distinct mangled names for each of these,
   but the demangled names are all the same: S::S or S::~S.  */

struct bound_minimal_symbol
lookup_minimal_symbol (const char *name, const char *sfile,
       struct objfile *objf)
{

If you look inside this function, you'll see:

  /* External symbols are best.  */
...
  /* File-local symbols are next best.  */
...
  /* Symbols for shared library trampolines are next best.  */
...

While this logic is good when you're looking for the single "best"
symbol by name, I question it for linespecs, since we want to set
breakpoints in all the multiple locations that match.  I see no point
in hidding static functions.

Now, for breakpoints, it does make sense to filter out PLT/trampoline
symbols if we find the actual global matching function symbol.
Otherwise, if we did no filtering (i.e., just removed the
classify_type logic), you would end up with e.g.:

 (gdb) b printf
 Breakpoint 1 at 0x413a60 (2 locations)
 (top-gdb) info breakpoints
 Num     Type           Disp Enb Address            What
 1      breakpoint     keep y   <MULTIPLE>
 1.1                         y   0x0000000000413a60 <printf@plt>
 1.2                         y   0x00007ffff4653640 in __printf at printf.c:28

instead of this (which is what we get currently) before the shared
library is loaded (a location set in the PLT):

 (gdb) b printf
 Breakpoint 1 at 0x413a60
 Num     Type           Disp Enb Address            What
 1       breakpoint     keep y   0x0000000000413a60 <printf@plt>

and this after the library is loaded (only one location, no breakpoint
in the PLT):

 (gdb) b printf
 Breakpoint 1 at 0x7ffff4653640: file printf.c, line 28.
 (gdb) info breakpoints
 Num     Type           Disp Enb Address            What
 1       breakpoint     keep y   0x00007ffff4653640 in __printf at printf.c:28

This patch fixes the missing breakpoint locations issue by replacing
the classify_type logic in linespec.c with a different logic.
Instead, discard a trampoline symbol if we also found a
global/external symbol with the same name.  The patch adds a couple of
testcases testing locations in external vs static functions vs
trampolines/PLTs.

We now get:

For the msym-bp.exp testcase (extern vs static), without debug info:

 (gdb) info breakpoints
 Num     Type           Disp Enb Address            What
 1       breakpoint     keep y   <MULTIPLE>
 1.1                         y   0x000000000040048b <foo+4>          ### missing before patch
 1.2                         y   0x000000000040049d <foo+4>

For the msym-bp.exp testcase (extern vs static), with debug info:

 (gdb) info breakpoints
 Num     Type           Disp Enb Address            What
 1       breakpoint     keep y   <MULTIPLE>
 1.1                         y   0x000000000040048b in foo at src/gdb/testsuite/gdb.base/msym-bp.c:21
 1.2                         y   0x000000000040049d in foo at src/gdb/testsuite/gdb.base/msym-bp-2.c:21

For the msym-bp-shl.exp testcase (static vs plt), without debug info, before running to main:

 (gdb) info breakpoints
 Num     Type           Disp Enb Address            What
 1       breakpoint     keep y   <MULTIPLE>
 1.1                         y   0x00000000004004e0 <foo@plt>        ### missing before patch
 1.2                         y   0x00000000004005db <foo+4>

For the msym-bp-shl.exp testcase (static vs plt), without debug info, after running to main:

 (gdb) info breakpoints
 Num     Type           Disp Enb Address            What
 1       breakpoint     keep y   <MULTIPLE>
 1.1                         y   0x00000000004005db <foo+4>          ### missing before patch
 1.2                         y   0x00007ffff7bd65de <foo+4>

For the msym-bp-shl.exp testcase (static vs plt), with debug info, before running to main:

 (gdb) info breakpoints
 Num     Type           Disp Enb Address            What
 1       breakpoint     keep y   <MULTIPLE>
 1.1                         y   0x00000000004004e0 <foo@plt>        ### missing before patch
 1.2                         y   0x00000000004005db in foo at src/gdb/testsuite/gdb.base/msym-bp-shl-main-2.c:21

For the msym-bp-shl.exp testcase (static vs plt), with debug info, after running to main:

 (gdb) info breakpoints
 Num     Type           Disp Enb Address            What
 1       breakpoint     keep y   <MULTIPLE>
 1.1                         y   0x00000000004005db in foo at src/gdb/testsuite/gdb.base/msym-bp-shl-main-2.c:21
 1.2                         y   0x00007ffff7bd65de in foo at src/gdb/testsuite/gdb.base/msym-bp-shl-lib.c:21

gdb/ChangeLog:

* linespec.c (classify_mtype, compare_msyms): Delete.
(search_minsyms_for_name): Remove classification logic.  Instead
filter out trampoline symbols if we also found an external
function of the same name.

gdb/testsuite/ChangeLog:

* gdb.base/msym-bp-2.c: New.
* gdb.base/msym-bp-shl-lib.c: New file.
* gdb.base/msym-bp-shl-main-2.c: New file.
* gdb.base/msym-bp-shl-main.c: New file.
* gdb.base/msym-bp-shl.exp: New file.
* gdb.base/msym-bp.c: New file.
* gdb.base/msym-bp.exp: New file.

4 years agoRe: elf: Add -z unique-symbol
Alan Modra [Sun, 13 Sep 2020 08:26:52 +0000 (17:56 +0930)]
Re: elf: Add -z unique-symbol

PR 26391
* testsuite/ld-elf/pr26391.nd: Adjust to match powerpc64 function
descriptors.