Commit Graph

92369 Commits

Author SHA1 Message Date
Joel Brobecker 31432a672f fix typos in ada-lang.c comment
gdb/ChangeLog:

        * ada-lang.c: Fix some typos in the general command documenting
        how Ada expressions are being evaluated and how their result
        is printed.
2017-11-09 12:02:27 -08:00
Jim Wilson 52c6b71b65 Fix riscv dwarf2-10 gas testsuite failure.
gas/
	* testsuite/gas/elf/dwarf2-10.l: Accept optional line number in error.
2017-11-09 09:43:59 -08:00
Tamar Christina 981b557a48 Enable the Dot Product extension by default for Armv8.4-a.
include/

	* opcode/aarch64.h (AARCH64_ARCH_V8_4): Enable DOTPROD.

gas/testsuite

	* gas/aarch64/dotproduct_armv8_4.s: New.
	* gas/aarch64/dotproduct_armv8_4.d: New.
2017-11-09 16:29:31 +00:00
Tamar Christina 793a194839 Add assembler and disassembler support for the new Armv8.4-a registers for AArch64.
Some of these instructions have been back-ported as optional extensions to
Armv8.2-a and higher, but others are only available for Armv8.4-a.

opcodes/

	* aarch64-opc.c (aarch64_sys_regs): Add ARMv8.4-a registers;
	dit, vstcr_el2, vsttbr_el2, cnthvs_tval_el2, cnthvs_cval_el2,
	cnthvs_ctl_el2, cnthps_tval_el2, cnthps_cval_el2, cnthps_ctl_el2,
	sder32_el2, vncr_el2.
	(aarch64_sys_reg_supported_p): Likewise.
	(aarch64_pstatefields): Add dit register.
	(aarch64_pstatefield_supported_p): Likewise.
	(aarch64_sys_regs_tlbi): Add vmalle1os, vae1os, aside1os, vaae1os,
	vale1os, vaale1os, ipas2e1os, ipas2le1os, vae2os, vale2os, vmalls12e1os,
	vae3os, vale3os, alle2os, alle1os, alle3os, rvae1, rvaae1, rvale1,
	rvaale1, rvae1is, rvaae1is, rvale1is, rvaale1is, rvae1os, rvaae1os,
	rvale1os, rvaale1os, ripas2e1is, ripas2le1is, ripas2e1, ripas2le1,
	ripas2e1os, ripas2le1os, rvae2, rvale2, rvae2is, rvale2is, rvae2os,
	rvale2os, rvae3, rvale3, rvae3is, rvale3is, rvae3os, rvale3os.

gas/testsuite

	* gas/aarch64/armv8_4-a-registers-illegal.d: New.
	* gas/aarch64/armv8_4-a-registers-illegal.l: New.
	* gas/aarch64/armv8_4-a-registers-illegal.s: New.
	* gas/aarch64/armv8_4-a-registers.d: New.
	* gas/aarch64/armv8_4-a-registers.s: New.
2017-11-09 16:29:16 +00:00
Tamar Christina 1a7ed57c84 Add the operand encoding types for the new Armv8.2-a back-ported instructions. These are to be used later when the new instructions are added.
opcodes/
	* aarch64-tbl.h (QL_SHA512UPT, QL_V2SAME2D, QL_V3SAME2D): New.
	(QL_V4SAME16B, QL_V4SAME4S, QL_XAR, QL_SM3TT, QL_V3FML2S): New.
	(QL_V3FML4S, QL_V2FML2S, QL_V2FML4S, QL_RMIF, QL_SETF): New.
	(QL_STLW, QL_STLX): New.
2017-11-09 16:29:07 +00:00
Tamar Christina f42f1a1d6c Adds the new Fields and Operand types for the new instructions in Armv8.4-a.
gas/
	* config/tc-aarch64.c (process_omitted_operand):
	Add AARCH64_OPND_Va, AARCH64_OPND_SM3_IMM2
	and AARCH64_OPND_IMM_2.
	(parse_operands): Add AARCH64_OPND_Va, AARCH64_OPND_SM3_IMM2,
	AARCH64_OPND_IMM_2, AARCH64_OPND_MASK
	and AARCH64_OPND_ADDR_OFFSET.

include/
	* opcode/aarch64.h:
	(aarch64_opnd): Add AARCH64_OPND_Va, AARCH64_OPND_MASK,
	AARCH64_OPND_IMM_2, AARCH64_OPND_ADDR_OFFSET
	and AARCH64_OPND_SM3_IMM2.
	(aarch64_insn_class): Add cryptosm3 and cryptosm4.
	(arch64_feature_set): Make uint64_t.

opcodes/
	* aarch64-asm.h (ins_addr_offset): New.
	* aarch64-asm.c (aarch64_ins_reglane): Add cryptosm3.
	(aarch64_ins_addr_offset): New.
	* aarch64-asm-2.c: Regenerate.
	* aarch64-dis.h (ext_addr_offset): New.
	* aarch64-dis.c (aarch64_ext_reglane): Add cryptosm3.
	(aarch64_ext_addr_offset): New.
	* aarch64-dis-2.c: Regenerate.
	* aarch64-opc.h (aarch64_field_kind): Add FLD_imm6_2,
	FLD_imm4_2 and FLD_SM3_imm2.
	* aarch64-opc.c (fields): Add FLD_imm6_2,
	FLD_imm4_2 and FLD_SM3_imm2.
	(operand_general_constraint_met_p): Add AARCH64_OPND_ADDR_OFFSET.
	(aarch64_print_operand): Add AARCH64_OPND_Va, AARCH64_OPND_SM3_IMM2,
	AARCH64_OPND_MASK, AARCH64_OPND_IMM_2 and AARCH64_OPND_ADDR_OFFSET.
	* aarch64-opc-2.c (Va, MASK, IMM_2, ADDR_OFFSET, SM3_IMM2): New.
	* aarch64-tbl.h
	(aarch64_opcode_table): Add Va, MASK, IMM_2, ADDR_OFFSET, SM3_IMM2.
2017-11-09 16:29:04 +00:00
Tom Tromey e793c052f9 Simplify the psymbol hash function
This patch simplifies the psymbol_hash function, by changing it not to
examine the contents of the symbol's name.  This change just mirrors
what psymbol_compare already does -- it is checking for name equality,
which is ok because symbol names are interned in symbol_set_names.

This change speeds up psymbol reading.  "gdb -nx -batch gdb"
previously took ~1.8 seconds on my machine, and with this patch it now
takes ~1.7 seconds.

gdb/ChangeLog
2017-11-09  Tom Tromey  <tom@tromey.com>

	* psymtab.c (psymbol_hash): Do not hash string contents.
	(psymbol_compare): Add comment.
2017-11-09 08:31:40 -07:00
Tom Tromey 7e8835c5f4 Speed up dict_hash
This speeds up dict_hash a bit, by moving the "TKB" check into the
switch in the loop.

For "gdb -nx -readnow -batch gdb", this improves the time from ~9.8s
before to ~8.5s afterward.

gdb/ChangeLog
2017-11-09  Tom Tromey  <tom@tromey.com>

	* dictionary.c (dict_hash): Move "TKB" check into the "switch".
2017-11-09 08:31:40 -07:00
Tamar Christina b6b9ca0c3e Split the ARM Crypto ISA extensions for AES and SHA1+2 into their own options (+aes and +sha2). The reason for the split is because with the introduction of Armv8.4-a the implementation of AES has explicitly been made independent of the implementation of the other crypto extensions.
gas	* config/tc-aarch64.c (aarch64_arch_option_table): Add armv8.4-a.
	(aarch64_features):	Added SM4 and SHA3.

include	* opcode/aarch64.h:
	(AARCH64_FEATURE_V8_4, AARCH64_FEATURE_SM4): New.
	(AARCH64_ARCH_V8_4, AARCH64_FEATURE_SHA3): New.

opcodes	* aarch64-tbl.h
	(aarch64_feature_v8_4, aarch64_feature_crypto_v8_2): New.
	(aarch64_feature_sm4, aarch64_feature_sha3): New.
	(aarch64_feature_fp_16_v8_2): New.
	(ARMV8_4, SHA3, SM4, CRYPTO_V8_2, FP_F16_V8_2): New.
	(V8_4_INSN, CRYPTO_V8_2_INSN): New.
	(SHA3_INSN, SM4_INSN, FP16_V8_2_INSN): New.
2017-11-09 11:21:31 +00:00
Nick Clifton 21b81e67c7 Change the type of the aarch64_feature_set typedef to unsigned long long so that it will work on 32-bit hosts.
* opcode/aarch64.h (aarch64_feature_set): Change type to unsigned
	long long.
2017-11-09 10:28:32 +00:00
Joel Brobecker 286acbb5c2 local variable watchpoint not deleted after leaving scope
When debugging an Ada program, and inserting a watchpoint tracking
a local variable, the watchpoint doesn't get automatically deleted
upon leaving that variable's scope. This watchpoint then starts
creating problems later on, when trying to resume the program's
execution from a location outside of the watchpoint's scope:

    (gdb) c
    Continuing.

    Breakpoint 2, foo_p708_025 () at foo_p708_025.adb:7
    7	   Do_Nothing (Val);
    (gdb) n
    No frame is currently executing in block pck.get_val.
    Command aborted.
    (gdb) c
    Continuing.
    No frame is currently executing in block pck.get_val.
    Command aborted.

The expected output is the following:

  - The program's execution after the first continue should stop
    as soon as we reach the end of the watchpoint's scope, and
    the debugger should be deleting it.

  - Then we can continue until reaching breakpoint 2 above;

  - After which we should be able to do next/continue as usual.

The reason the watchpoint is not automatically deleted at scope exit
is because the watchpoint is not marked as being scope-specific
(b->exp_valid_block is equal NULL), and this is because the
symbol lookup for our local variable failed to set the innermost_block
global variable during the lookup.

More precisely, if we look at watch_command_1, we do the following:

  innermost_block = NULL;
  [...]
  exp = parse_exp_1 (&arg, 0, 0, 0);
  [...]
  exp_valid_block = innermost_block;

Currently, innermost_block stays NULL after the call to parse_exp_1.

Digging further, this innermost_block is typically set during symbol
lookup when the symbol is considered to have a frame-relative address.
For instance, in c-exp.y, we see some code like the following:

   if (symbol_read_needs_frame (sym.symbol))
     {
       if (innermost_block == 0
           || contained_in (sym.block,
                            innermost_block))
         innermost_block = sym.block;
     }

We actually have the exact same mechanism in ada-exp.y, except
that it vhas accidently been turned off. See write_var_from_sym,
where we start with:

   if (orig_left_context == NULL && symbol_read_needs_frame (sym))
     {
       if (innermost_block == 0
           || contained_in (block, innermost_block))
         innermost_block = block;
     }

In this case, orig_left_context is a parameter, and looking at
the point of call in write_var_or_type, we see:

          if (nsyms == 1)
            {
              write_var_from_sym (par_state, block, syms[0].block,
                                  syms[0].symbol);

In the call above, the paramater we are interested in is "block",
which is a parameter for write_var_or_type as well, except we
explicitly override its value at the beginning when found to be NULL:

  if (block == NULL)
    block = expression_context_block;

So the block we pass to write_var_from_sym is not NULL, and
we therefore don't set innermost_block, which leads to the watchpoint
no longer being marked as scope-specific.

The handling of orig_left_context in write_var_from_sym was there
to handle the case where a user writes an expression where the symbol
is qualified with a scope (Eg: "function::variable"). But it appears
that handling this is specifically here is no longer necessary,
so this patch simply removes that parameter and the associated check,
and then updates all the points of calls.

Interestingly, this also affects GDB/MI, and in particular varobjs,
because local variables are now properly reported as having a block,
which causes the associated varob to have a "thread-id" field.
This patch also adjusts a couple of Ada/gdb-mi tests.

gdb/ChangeLog:

        * ada-exp.y (write_var_from_sym): Remove parameter
        "orig_left_context".  Update all callers.

gdb/testsuite/ChangeLog:

        * gdb.ada/scoped_watch: New testcase.
        * gdb.ada/watch_arg.exp: Adjust expected behavior to the behavior
        which is actually correct.
        * gdb.ada/mi_interface.exp: Add missing thread-id in expected varobj.
        * gdb.ada/mi_var_array.exp: Add missing thread-id in expected varobj.
2017-11-08 19:52:28 -05:00
Simon Marchi b44ec61915 Make encode_actions_rsp use std::vector
Currently, encode_actions_rsp returns two malloc'ed arrays of malloc'ed
strings (char *) by pointer.  Change this to use
std::vector<std::string>.  This eliminates some cleanups in remote.c.

Regtested on the buildbot.

gdb/ChangeLog:

	* tracepoint.h (class collection_list) <stringify>: Return
	std::vector<std::string>.
	(encode_actions_rsp): Change parameters to
	std::vector<std::string> *.
	* tracepoint.c (collection_list::stringify): Return
	std::vector<std::string> and adjust accordingly.
	(encode_actions_rsp): Changee parameters to
	std::vector<std::string> and adjust accordingly.
	* remote.c (free_actions_list),
	free_actions_list_cleanup_wrapper): Remove.
	(remote_download_tracepoint): Adjust to std::vector.
2017-11-08 19:42:08 -05:00
H.J. Lu dc8d2d90da gold: Ignore def/ref from a dynamic object for special symbols
Since special symbol must be defined in a regular object, definition
from a dynamic object should be ignored.  If special symbol has the
hidden or internal visibility, reference from a dynamic object should
also be ignored.  Also __start and __stop symbols in a dynamic object
shouldn't be preempted.

	PR gold/22291
	* layout.cc (Layout::define_section_symbols): Use STV_PROTECTED
	for __start and __stop symbols.
	* symtab.cc (Symbol_table::define_special_symbol): Add an
	argument, visibility.  Ignore definition and reference from
	a dynamic object, depending on visibility.
	(Symbol_table::do_define_in_output_data): Pass visibility to
	define_special_symbol.
	(Symbol_table::do_define_in_output_segment): Likewise.
	(Symbol_table::do_define_as_constant): Likewise.
	(Symbol_table::add_undefined_symbol_from_command_line): Pass
	STV_DEFAULT to define_special_symbol.
	* symtab.h (Symbol_table::define_special_symbol): Add an
	argument, visibility.
2017-11-08 16:02:50 -08:00
GDB Administrator cb1a122cce Automatic date update in version.in 2017-11-09 00:00:11 +00:00
Pedro Alves 62d7ae9234 Avoid expensive complaint calls when complaints are disabled
Running perf on "gdb -nx -readnow -batch gdb", I'm seeing a lot of
time (24%.75!) spent in gettext, via complaints.  'perf report -g' shows:

 -   86.23%     0.00%  gdb      gdb                     [.] gdb_main
    - gdb_main
       - 85.60% catch_command_errors
            symbol_file_add_main_adapter
            symbol_file_add_main
            symbol_file_add_main_1
            symbol_file_add
          - symbol_file_add_with_addrs
             - 84.31% dw2_expand_all_symtabs
                - dw2_instantiate_symtab
                   - 83.79% dw2_do_instantiate_symtab
                      - 70.85% process_die
                         - 41.11% dwarf_decode_macros
                            - 41.09% dwarf_decode_macro_bytes
                               - 39.74% dwarf_decode_macro_bytes
   >>>>>>>>>>>>>>>>>>>>>>>        + 24.75% __dcigettext              <<<<<<<
                                  + 7.37% macro_define_object_internal
                                  + 3.16% macro_define_function
                                    0.77% splay_tree_insert
                                  + 0.76% savestring
                                  + 0.58% free
                                    0.53% read_indirect_string_at_offset_from
                                 0.54% macro_define_object_internal
                                 0.51% macro_start_file
                         + 25.57% process_die
                         + 4.07% dwarf_decode_lines
                      + 4.28% compute_delayed_physnames
                      + 3.85% end_symtab_from_static_block
                      + 3.38% load_cu
                      + 1.29% end_symtab_get_static_block
                   + 0.52% do_my_cleanups
             + 1.29% read_symbols
       + 0.54% gdb_init

The problem is that we're always computing the arguments to pass to
complaint, including passing the format strings through gettext, even
when complaints are disabled.  As seen above, gettext can be quite
expensive.

Fix this by wrapping complaint in a macro that skips the real
complaint call when complaints are disabled.

This improves "gdb -nx -readnow -batch gdb" from
 ~11.0s => ~7.8s with -O2 -g3, and
  ~6.0s => ~5.3s with -O2 -g.
w/ gcc 5.3.1, on x86_64, for me.

gdb/ChangeLog:
2017-11-08  Pedro Alves  <palves@redhat.com>

	* complaints.c (stop_whining): Make extern.
	(complaint): Rename to ...
	(complaint_internal): ... this.
	* complaints.h (complaint): Rename to ...
	(complaint_internal): ... this.
	(complaint): Reimplement as macro around complaint_internal.

gdb/testsuite/ChangeLog:
2017-11-08  Pedro Alves  <palves@redhat.com>

	* gdb.gdb/complaints.exp (test_initial_complaints)
	(test_serial_complaints, test_short_complaints): Call
	complaint_internal instead of complaint.
2017-11-08 23:42:11 +00:00
James Clarke 333d0055f6 Fix problems with -r.
The fix committed for PR gold/19291 ended up breaking other cases. The
commit added adjustment code to write_local_symbols, but in many cases
compute_final_local_value_internal had already subtracted the output
section's address. To fix this, all other adjustments are now removed, so
only the one in write_local_symbols is left.

gold/
	PR gold/22266
	* object.cc (Sized_relobj_file::compute_final_local_value_internal):
	Drop relocatable parameter and stop adjusting output value based on
	it.
	(Sized_relobj_file::compute_final_local_value): Stop passing
	relocatable to compute_final_local_value_internal.
	(Sized_relobj_file::do_finalize_local_symbols): Ditto.
	* object.h (Sized_relobj_file::compute_final_local_value_internal):
	Drop relocatable parameter.
2017-11-08 15:13:53 -08:00
Eric Christopher 08228b1155 Apply:
2017-11-08  Kyle Butt  <iteratee@google.com>

        * object.cc (do_find_special_sections): Fix a thinko with memmem return
        values and check for != NULL rather than == 0.
2017-11-08 14:03:55 -08:00
Djordje Todorovic 280ca31f4d Add test for fetching TLS from core file
A correct PID is needed by `libthread_db' library supplied with
glibc repository revisions before commit c579f48edba8 ("Remove
cached PID/TID in clone") or versions before 2.25 release for
GDB to fetch value of TLS variable from core file.  On MIPS
platforms it was omitted and fetching value of TLS variable was not
available.

This adds a new test in order to be sure if GDB on native platforms
can successfully fetch value of TLS variable.

gdb/testsuite:

	* gdb.threads/tls-core.c: New file.
	* gdb.threads/tls-core.exp: Likewise.
2017-11-08 21:19:05 +00:00
Djordje Todorovic c9ec0e8945 BFD: Extract PID from MIPS core dump file
On MIPS o32, n32 and n64 platforms, PID information was not
correctly propagated from core dump file to internal GDB
structures.  This patch fixes that behavior.

A correct PID is needed by `libthread_db' library supplied with
glibc repository revisions before commit c579f48edba8 ("Remove
cached PID/TID in clone") or released versions before 2.25 for
GDB to fetch value of TLS variable from core file.

bfd/ChangeLog:

	* elf32-mips.c (elf32_mips_grok_psinfo): Extract core->pid.
	* elf64-mips.c (elf64_mips_grok_psinfo): Likewise.
	* elfn32-mips.c (elf32_mips_grok_psinfo): Likewise.
2017-11-08 21:19:05 +00:00
Djordje Todorovic 9031cb4af0 BFD: Write Linux core PRSTATUS note into MIPS core file
On MIPS o32, n32 and n64 platforms information such as PID was not
correctly written into core file from GDB.

This fixes that behavior.

bfd/ChangeLog:

	* elf32-mips.c (elf32_mips_write_core_note): New function.
	(elf_backend_write_core_note): New macro.
	* elf64-mips.c (elf64_mips_write_core_note): New function.
	(elf_backend_write_core_note): New macro.
	* elfn32-mips.c (elf32_mips_write_core_note): New function.
	(elf_backend_write_core_note): New macro.
2017-11-08 21:19:05 +00:00
Tom Tromey 2f4732b0e6 Remove symbolp vector
This removes the symbolp typedef from dwarf2read.c and converts the
associated VEC uses to std::vector.  This fixes a latent possible
memory leak if an exception were thrown, because there were no
cleanups installed for these VECs.

Regression tested on the buildbot.

gdb/ChangeLog
2017-11-08  Tom Tromey  <tom@tromey.com>

	* dwarf2read.c (symbolp): Remove typedef.
	(read_func_scope): Use std::vector.
	(process_structure_scope): Use std::vector.
2017-11-08 11:20:14 -07:00
Pedro Alves f9d67a2239 Make the linespec/location completer ignore data symbols
Currently "b foo[TAB]" offers data symbols as completion candidates.
This doesn't make sense, since you can't set a breakpoint on data
symbols, only on code symbols.

 (gdb) b globa[TAB]
 (gdb) b global [ENTER]
 Function "global" not defined.
 Make breakpoint pending on future shared library load? (y or [n]) n
 (gdb) info symbol global
 global in section .rodata

So this patch makes linespec completion ignore data symbols.

gdb/ChangeLog:
2017-11-08  Pedro Alves  <palves@redhat.com>

	* ada-lang.c (ada_make_symbol_completion_list): Use
	completion_skip_symbol.
	* symtab.c (symbol_is_function_or_method(minimal_symbol*)): New.
	(symbol_is_function_or_method(symbol*)): New.
	(add_symtab_completions): Add complete_symbol_mode parameter.  Use
	completion_skip_symbol.
	(default_collect_symbol_completion_matches_break_on): Use
	completion_skip_symbol.  Pass down mode.
	(collect_file_symbol_completion_matches): Pass down mode.
	* symtab.h (symbol_is_function_or_method): New declarations.
	(completion_skip_symbol): New template function.
2017-11-08 16:06:25 +00:00
Pedro Alves 56d87ef769 Use search_domain::FUNCTIONS_DOMAIN when setting breakpoints
While working on C++ support for wild matching, I noticed that
attaching to my system's Firefox (which uses .gdb_index), setting a
break at main and bailing, like:

  $ gdb --batch -q -p `pidof firefox` -ex "b main"

would get substancially slower.  It'd take around 20s when currently
it takes 3s.

The problem is that gdb would expand more symtabs than currently,
because Firefox has symbols named like "nsHtml5Atoms::main",
"nsGkAtoms::main", etc., which given wild matching, match.

However, these are not function symbols, [they're "(nsIAtom *)"], so
it seems silly that they'd cause expansion in the first place.

The .gdb_index code (dwarf2read.c:dw2_expand_marked_cus) filters out
symbols matches based on search_domain:

  case VARIABLES_DOMAIN:
    if (symbol_kind != GDB_INDEX_SYMBOL_KIND_VARIABLE)
      continue;
    break;
  case FUNCTIONS_DOMAIN:
    if (symbol_kind != GDB_INDEX_SYMBOL_KIND_FUNCTION)
      continue;
    break;
  case TYPES_DOMAIN:
    if (symbol_kind != GDB_INDEX_SYMBOL_KIND_TYPE)
      continue;
    break;
  default:
    break;

however, we're currently passing down search_domain::ALL_DOMAIN when
we know we're looking for functions, for no good reason.  This patch
fixes that.

It seems like search_domain is underutilized throughout, but I'll
leave using it more for another pass.

gdb/ChangeLog:
2017-11-08  Pedro Alves  <palves@redhat.com>

	* linespec.c (iterate_over_all_matching_symtabs): Add
	search_domain parameter.  Pass it down to expand_symtabs_matching.
	(decode_objc): Request FUNCTIONS_DOMAIN symbols only.
	(lookup_prefix_sym): Adjust by passing ALL_DOMAIN as
	search_domain.
	(add_all_symbol_names_from_pspace): Add search_domain parameter.
	Pass it down.
	(find_method, find_function_symbols): Request FUNCTIONS_DOMAIN
	symbols.
	(add_matching_symbols_to_info): Add search_domain parameter.  Pass
	it down.
2017-11-08 16:05:46 +00:00
Pedro Alves 1b0261195e Simplify completion_list_add_name | remove sym_text / sym_text_len
sym_text_len existed to strip parameters out of the lookup name.  Now
that that's handled by the lookup_name_info objects, the
sym_text/sym_text_len parameters are no longer necessary.

gdb/ChangeLog:
2017-11-08  Pedro Alves  <palves@redhat.com>

	* ada-lang.c (ada_make_symbol_completion_list): Remove text and
	text_len locals and don't pass them down.
	* symtab.c (completion_list_add_name): Remove
	sym_text/sym_text_len parameters and adjust.
	(completion_list_add_symbol, completion_list_add_msymbol)
	(completion_list_objc_symbol, completion_list_add_fields)
	(add_symtab_completions): Likewise.
	(default_collect_symbol_completion_matches_break_on)
	(collect_file_symbol_completion_matches): Remove sym_text_len
	local and don't pass it down.
	* symtab.h (completion_list_add_name): Remove
	sym_text/sym_text_len parameters.
2017-11-08 16:05:45 +00:00
Pedro Alves c62446b12b lookup_name_info::make_ignore_params
A few places in the completion code look for a "(" to find a
function's parameter list, in order to strip it, because psymtabs (and
gdb index) don't include parameter info in the symbol names.

See compare_symbol_name and
default_collect_symbol_completion_matches_break_on.

This is too naive.  Consider:

 ns_overload2_test::([TAB]

We'd want to complete that to:
 ns_overload2_test::(anonymous namespace)::struct_overload2_test

Or:

 b (anonymous namespace)::[TAB]

That currently completes to:

 b (anonymous namespace)

Which is obviously broken.  This patch makes that work.

Also, the current compare_symbol_name hack means that while this
works:

 "b function([TAB]"  ->  "b function()"

This does not:

 "b function ([TAB]"

This patch fixes that.  Whitespace "ignoring" now Just Works, i.e.,
assuming a symbol named "function(int, long)", this:
 b function (   int , lon[TAB]
completes to:
 b function (   int , long)

To address all of this, this patch builds on top of the rest of the
series, and pushes the responsibility of stripping parameters from a
lookup name to the new lookup_name_info object, where we can apply
per-language rules.  Also note that we now only make a version of the
lookup name with parameters stripped out where it's actually required
to do that, in the psymtab and GDB index code.

For C++, the right way to strip parameters is with "cp_remove_params",
which uses a real parser (cp-name-parser.y) to split the name into a
component tree and then discards parameters.

The trouble for completion is that in that case we have an incomplete
name, like "foo::func(int" and thus cp_remove_params throws an error.

This patch sorts that by adding a cp_remove_params_if_any variant of
cp_remove_params that tries removing characters from the end of the
string until cp_remove_params works.  So cp_remove_params_if_any
behaves like this:

With a complete name:

   "foo::func(int)"  => foo::func(int)  # cp_remove_params_1 succeeds the first time.

With an incomplete name:

   "foo::func(int"  => NULL             # cp_remove_params fails the first time.
   "foo::func(in"   => NULL             # and again...
   "foo::func(i"    => NULL             # and again...
   "foo::func("     => NULL             # and again...
   "foo::func"      => "foo::func"      # success!

Note that even if this approach removes significant rightmost
characters, it's still OK, because this parameter stripping is only
necessary for psymtabs and gdb index, where we're determining whether
to expand a symbol table.  Say cp_remove_params_if_any returned
"foo::" above for "foo::func(int".  That'd cause us to expand more
symtabs than ideal (because we'd expand all symtabs with symbols that
start with "foo::", not just "foo::func"), but then when we actually
look for completion matches, we'd still use the original lookup name,
with parameter information ["foo::func(int"], and thus we'll return no
false positive to the user.  Whether the stripping works as intended
and doesn't strip too much is thus covered by a unit test instead of a
testsuite test.

The "if_any" part of the name refers to the fact that while
cp_remove_params returns NULL if the input name has no parameters in
the first place, like:

   "foo::func"      => NULL         # cp_remove_params

cp_remove_params_if_any still returns the function name:

   "foo::func"      => "foo::func"  # cp_remove_params_if_any

gdb/ChangeLog:
2017-11-08  Pedro Alves  <palves@redhat.com>

	* Makefile.in (SUBDIR_UNITTESTS_SRCS): Add
	unittests/lookup_name_info-selftests.c.
	(SUBDIR_UNITTESTS_OBS): Add lookup_name_info-selftests.o.
	* cp-support.c: Include "selftest.h".
	(cp_remove_params_1): Rename from cp_remove_params.  Add
	'require_param' parameter, and handle it.
	(cp_remove_params): Reimplement.
	(cp_remove_params_if_any): New.
	(selftests::quote): New.
	(selftests::check_remove_params): New.
	(selftests::test_cp_remove_params): New.
	(_initialize_cp_support): Install
	selftests::test_cp_remove_params.
	* cp-support.h (cp_remove_params_if_any): Declare.
	* dwarf2read.c :Include "selftest.h".
	(dw2_expand_symtabs_matching_symbol): Use
	lookup_name_info::make_ignore_params.
	(selftests::dw2_expand_symtabs_matching::mock_mapped_index)
	(selftests::dw2_expand_symtabs_matching::string_or_null)
	(selftests::dw2_expand_symtabs_matching::check_match)
	(selftests::dw2_expand_symtabs_matching::test_symbols)
	(selftests::dw2_expand_symtabs_matching::run_test): New.
	(_initialize_dwarf2_read): Register
	selftests::dw2_expand_symtabs_matching::run_test.
	* psymtab.c (psym_expand_symtabs_matching): Use
	lookup_name_info::make_ignore_params.
	* symtab.c (demangle_for_lookup_info::demangle_for_lookup_info):
	If the lookup name wants to ignore parameters, strip them.
	(compare_symbol_name): Remove sym_text/sym_text_len parameters and
	code handling '('.
	(completion_list_add_name): Don't pass down sym_text/sym_text_len.
	(default_collect_symbol_completion_matches_break_on): Don't try to
	strip parameters.
	* symtab.h (lookup_name_info::lookup_name_info): Add
	'ignore_parameters' parameter.
	(lookup_name_info::ignore_parameters)
	(lookup_name_info::make_ignore_params): New methods.
	(lookup_name_info::m_ignore_parameters): New field.
	* unittests/lookup_name_info-selftests.c: New file.
2017-11-08 16:02:24 +00:00
Pedro Alves 61920122ba Reorder/reindent dw2_expand_symtabs_matching & friends
The previous patch had added dw2_expand_symtabs_matching_symbol and
dw2_expand_marked_cus forward declarations and did not reindent
dw2_expand_marked_cus to avoid moving the code around while changing
it at the same time.

gdb/ChangeLog:
2017-11-08  Pedro Alves  <palves@redhat.com>

	* dwarf2read.c (dw2_expand_marked_cus)
	(dw2_expand_symtabs_matching_symbol): Remove forward declarations.
	(dw2_expand_symtabs_matching): Move further below.
	(dw2_expand_marked_cus): Reindent.
2017-11-08 16:02:24 +00:00
Pedro Alves 3f563c840a Optimize .gdb_index symbol name searching
As mentioned in the previous patch, .gdb_index name lookup got
significantly slower with the previous patch.

This patch addresses that, and in the process makes .gdb_index name
searching faster than what we had before the previous patch, even.
Using the same test:

 $ cat script.cmd
 set pagination off
 set $count = 0
 while $count < 400
   complete b string_prin
   printf "count = %d\n", $count
   set $count = $count + 1
 end

 $ time gdb --batch -q ./gdb-with-index -ex "source script.cmd"

I got, before the previous patch (-O2, x86-64):

 real    0m1.773s
 user    0m1.737s
 sys     0m0.040s

and after this patch:

 real    0m1.361s
 user    0m1.315s
 sys     0m0.040s

The basic idea here is simple: instead of always iterating over all
the symbol names in the index, we build an accelerator/sorted name
table and binary search names in it.

Later in the series, we'll want to support wild matching for C++ too,
so this mechanism already considers that.  For example, say that
you're looking up functions/methods named "func", no matter the
containing namespace/class.  If we sorted the table by qualified name,
then we obviously wouldn't be able to find those symbols with a binary
search:

  func
  ns1:🅰️🅱️:func
  ns1:🅱️:func
  ns2::func

(function symbol names in .gdb_index have no parameter info, like psymbols)

To address that out, we put an entry for each name component in the
sorted table.  something like this:

  Table Entry       Actual symbol
  ---------------------------------
  func              func

  func              ns1:🅰️🅱️:func
  b::func           ns1:🅰️🅱️:func
  a:🅱️:func        ns1:🅰️🅱️:func
  ns1:🅰️🅱️:func   ns1:🅰️🅱️:func

  func              ns1:🅱️:func
  b::func           ns1:🅱️:func
  ns1:🅱️:func      ns1:🅱️:func

  func              ns2::func
  ns2::func         ns2::func

Which sorted results in this:

  Table Entry       Actual symbol
  ---------------------------------
  a:🅱️:func        ns1:🅰️🅱️:func
  b::func           ns1:🅰️🅱️:func
  b::func           ns1:🅱️:func
  func              func
  func              ns1:🅰️🅱️:func
  func              ns1:🅱️:func
  func              ns2::func
  ns1:🅰️🅱️:func   ns1:🅰️🅱️:func
  ns1:🅱️:func      ns1:🅱️:func
  ns2::func         ns2::func

And we can binary search this.

Note that a binary search approach works for both completion and
regular lookup, while a name hashing approach only works for normal
symbol looking, since obviously "fun" and "func" have different
hashes.

At first I was a bit wary of these tables potentially growing GDB's
memory significantly.  But I did an experiment that convinced it's not
a worry at all.  I hacked gdb to count the total number of entries in
all the tables, attached that gdb to my system/Fedora's Firefox
(Fedora's debug packages uses .gdb_index), did "set max-completions
unlimited", and then hit "b [TAB]" to cause everything to expand.

That resulted in 1351355 name_components.  Each entry takes 8 bytes,
so that's 10810840 bytes (ignoring std::vector overhead), or ~10.3 MB.
That's IMO too small to worry about, given GDB was using over 7400MB
total at that point.  I.e., we're talking about 0.1% increase.

dw2_expand_symtabs_matching unit tests covering this will be added in
a follow up patch.

If the size of this table turns out to be a concern, I have an idea to
reduce the size of the table further at the expense of a bit more code
-- the vast majority of the name offsets are either 0 or fit in
8-bits:

 total name_component = 1351355, of which,
 name_component::name_offset instances need  0 bits = 679531
 name_component::name_offset instances need  8 bits = 669526
 name_component::name_offset instances need 16 bits = 2298
 name_component::name_offset instances need 32 bits = 0
 name_component::idx instances need 0 bits  = 51
 name_component::idx instances need 8 bits  = 8361
 name_component::idx instances need 16 bits = 280329
 name_component::idx instances need 32 bits = 1062614

so we could have separate tables for 0 name_offset, 8-bit name_offset
and 32-bit name_offset.  That'd give us roughly:

 679531 * 0 + 669526 * 1 + 2298 * 4 + 1062614 * 4 = 4929174, or ~4.7MB

with only 8-bit and 32-bit tables, that'd be:

 1349057 * 1 + 2298 * 4 + 4 * 1351355 = 6763669 bytes, or ~6.5MB.

I don't think we need to bother though.

I also timed:

 $ time gdb --batch -q -p `pidof firefox`
 $ time gdb --batch -q -p `pidof firefox` -ex "b main"
 $ time gdb --batch -q -p `pidof firefox` -ex "set max-completion unlimited" -ex "complete b "

and compared before previous patch vs this patch, and I didn't see a
significant difference, seemingly because time to read debug info
dominates.  The "complete b " variant of the test takes ~2min
currently...  (I have a follow up series that speeds that up
somewhat.)

gdb/ChangeLog:
2017-11-08  Pedro Alves  <palves@redhat.com>

	* dwarf2read.c (byte_swap, MAYBE_SWAP): Move higher up in file.
	(struct name_component): New.
	(mapped_index::name_components): New field.
	(mapped_index::symbol_name_at): New method.
	(dwarf2_read_index): Call mapped_index ctor.
	(dw2_map_matching_symbols): Add comment about name_components
	table.
	(dw2_expand_symtabs_matching): Factor part to...
	(dw2_expand_symtabs_matching_symbol): ... this new function.
	Build name components table, and lookup symbols in it before
	calling the name matcher.
	(dw2_expand_marked_cus): New, factored out from
	dw2_expand_symtabs_matching.
	(dwarf2_per_objfile_free): Call the mapped_index's dtor.
2017-11-08 16:02:24 +00:00
Pedro Alves b5ec771e60 Introduce lookup_name_info and generalize Ada's FULL/WILD name matching
Summary:
 - This is preparation for supporting wild name matching on C++ too.
 - This is also preparation for TAB-completion fixes.
 - Makes symbol name matching (think strcmp_iw) be based on a per-language method.
 - Merges completion and non-completion name comparison (think
   language_ops::la_get_symbol_name_cmp generalized).
 - Avoid re-hashing lookup name multiple times
 - Centralizes preparing a name for lookup (Ada name encoding / C++ Demangling),
   both completion and non-completion.
 - Fixes Ada latent bug with verbatim name matches in expressions
 - Makes ada-lang.c use common|symtab.c completion code a bit more.

Ada's wild matching basically means that

 "(gdb) break foo"

will find all methods named "foo" in all packages.  Translating to
C++, it's roughly the same as saying that "break klass::method" sets
breakpoints on all "klass::method" methods of all classes, no matter
the namespace.  A following patch will teach GDB about fullname vs
wild matching for C++ too.  This patch is preparatory work to get
there.

Another idea here is to do symbol name matching based on the symbol
language's algorithm.  I.e., avoid dependency on current language set.

This allows for example doing

  (gdb) b foo::bar< int > (<tab>

and having gdb name match the C++ symbols correctly even if the
current language is C or Assembly (or Rust, or Ada, or ...), which can
easily happen if you step into an Assembly/C runtime library frame.

By encapsulating all the information related to a lookup name in a
class, we can also cache hash computation for a given language in the
lookup name object, to avoid recomputing it over and over.

Similarly, because we don't really know upfront which languages the
lookup name will be matched against, for each language we store the
lookup name transformed into a search name.  E.g., for C++, that means
demangling the name.  But for Ada, it means encoding the name.  This
actually forces us to centralize all the different lookup name
encoding in a central place, resulting in clearer code, IMO.  See
e.g., the new ada_lookup_name_info class.

The lookup name -> symbol search name computation is also done only
once per language.

The old language->la_get_symbol_name_cmp / symbol_name_cmp_ftype are
generalized to work with both completion, and normal symbol look up.

At some point early on, I had separate completion vs non-completion
language vector entry points, but a single method ends up being better
IMO for simplifying things -- the more we merge the completion /
non-completion name lookup code paths, the less changes for bugs
causing completion vs normal lookup finding different symbols.

The ada-lex.l change is necessary because when doing

  (gdb) p <UpperCase>

then the name that is passed to write_ write_var_or_type ->
ada_lookup_symbol_list misses the "<>", i.e., it's just "UpperCase",
and we end up doing a wild match against "UpperCase" lowercased by
ada_lookup_name_info's constructor.  I.e., "uppercase" wouldn't ever
match "UpperCase", and the symbol lookup fails.

This wouldn't cause any regression in the testsuite, but I added a new
test that would pass before the patch and fail after, if it weren't
for that fix.

This is latent bug that happens to go unnoticed because that
particular path was inconsistent with the rest of Ada symbol lookup by
not lowercasing the lookup name.

Ada's symbol_completion_add is deleted, replaced by using common
code's completion_list_add_name.  To make the latter work for Ada, we
needed to add a new output parameter, because Ada wants to return back
a custom completion candidates that are not the symbol name.

With this patch, minimal symbol demangled name hashing is made
consistent with regular symbol hashing.  I.e., it now goes via the
language vector's search_name_hash method too, as I had suggested in a
previous patch.

dw2_expand_symtabs_matching / .gdb_index symbol names were a
challenge.  The problem is that we have no way to telling what is the
language of each symbol name found in the index, until we expand the
corresponding full symbol, which is off course what we're trying to
avoid.  Language information is simply not considered in the index
format...  Since the symbol name hashing and comparison routines are
per-language, we now have a problem.  The patch sorts this out by
matching each name against all languages.  This is inneficient, and
indeed slows down completion several times.  E.g., with:

 $ cat script.cmd
 set pagination off
 set $count = 0
 while $count < 400
   complete b string_prin
   printf "count = %d\n", $count
   set $count = $count + 1
 end

 $ time gdb --batch -q ./gdb-with-index -ex "source script-string_printf.cmd"

I get, before patch (-O2, x86-64):

 real    0m1.773s
 user    0m1.737s
 sys     0m0.040s

While after patch (-O2, x86-64):

 real    0m9.843s
 user    0m9.482s
 sys     0m0.034s

However, the following patch will optimize this, and will actually
make this use case faster compared to the "before patch" above:

 real    0m1.321s
 user    0m1.285s
 sys     0m0.039s

gdb/ChangeLog:
2017-11-08   Pedro Alves  <palves@redhat.com>

	* ada-lang.c (ada_encode): Rename to ..
	(ada_encode_1): ... this.  Add throw_errors parameter and handle
	it.
	(ada_encode): Reimplement.
	(match_name): Delete, folded into full_name.
	(resolve_subexp): No longer pass the encoded name to
	ada_lookup_symbol_list.
	(should_use_wild_match): Delete.
	(name_match_type_from_name): New.
	(ada_lookup_simple_minsym): Use lookup_name_info and the
	language's symbol_name_matcher_ftype.
	(add_symbols_from_enclosing_procs, ada_add_local_symbols)
	(ada_add_block_renamings): Adjust to use lookup_name_info.
	(ada_lookup_name): New.
	(add_nonlocal_symbols, ada_add_all_symbols)
	(ada_lookup_symbol_list_worker, ada_lookup_symbol_list)
	(ada_iterate_over_symbols): Adjust to use lookup_name_info.
	(ada_name_for_lookup): Delete.
	(ada_lookup_encoded_symbol): Construct a verbatim name.
	(wild_match): Reverse sense of return type.  Use bool.
	(full_match): Reverse sense of return type.  Inline bits of old
	match_name here.
	(ada_add_block_symbols): Adjust to use lookup_name_info.
	(symbol_completion_match): Delete, folded into...
	(ada_lookup_name_info::matches): ... .this new method.
	(symbol_completion_add): Delete.
	(ada_collect_symbol_completion_matches): Add name_match_type
	parameter.  Adjust to use lookup_name_info and
	completion_list_add_name.
	(get_var_value, ada_add_global_exceptions): Adjust to use
	lookup_name_info.
	(ada_get_symbol_name_cmp): Delete.
	(do_wild_match, do_full_match): New functions.
	(ada_lookup_name_info::ada_lookup_name_info): New method.
	(ada_symbol_name_matches, ada_get_symbol_name_matcher): New
	functions.
	(ada_language_defn): Install ada_get_symbol_name_matcher.
	* ada-lex.l (processId): If name starts with '<', copy it
	verbatim.
	* block.c (block_iter_match_step, block_iter_match_first)
	(block_iter_match_next, block_lookup_symbol)
	(block_lookup_symbol_primary, block_find_symbol): Adjust to use
	lookup_name_info.
	* block.h (block_iter_match_first, block_iter_match_next)
	(ALL_BLOCK_SYMBOLS_WITH_NAME): Adjust to use lookup_name_info.
	* c-lang.c (c_language_defn, cplus_language_defn)
	(asm_language_defn, minimal_language_defn): Adjust comments to
	refer to la_get_symbol_name_matcher.
	* completer.c (complete_files_symbols)
	(collect_explicit_location_matches, symbol_completer): Pass a
	symbol_name_match_type down.
	* completer.h (class completion_match, completion_match_result):
	New classes.
	(completion_tracker::reset_completion_match_result): New method.
	(completion_tracker::m_completion_match_result): New field.
	* cp-support.c (make_symbol_overload_list_block): Adjust to use
	lookup_name_info.
	(cp_fq_symbol_name_matches, cp_get_symbol_name_matcher): New
	functions.
	* cp-support.h (cp_get_symbol_name_matcher): New declaration.
	* d-lang.c: Adjust comments to refer to
	la_get_symbol_name_matcher.
	* dictionary.c (dict_vector) <iter_match_first, iter_match_next>:
	Adjust to use lookup_name_info.
	(dict_iter_match_first, dict_iter_match_next)
	(iter_match_first_hashed, iter_match_next_hashed)
	(iter_match_first_linear, iter_match_next_linear): Adjust to work
	with a lookup_name_info.
	* dictionary.h (dict_iter_match_first, dict_iter_match_next):
	Likewise.
	* dwarf2read.c (dw2_lookup_symbol): Adjust to use lookup_name_info.
	(dw2_map_matching_symbols): Adjust to use symbol_name_match_type.
	(gdb_index_symbol_name_matcher): New class.
	(dw2_expand_symtabs_matching) Adjust to use lookup_name_info and
	gdb_index_symbol_name_matcher.  Accept a NULL symbol_matcher.
	* f-lang.c (f_collect_symbol_completion_matches): Adjust to work
	with a symbol_name_match_type.
	(f_language_defn): Adjust comments to refer to
	la_get_symbol_name_matcher.
	* go-lang.c (go_language_defn): Adjust comments to refer to
	la_get_symbol_name_matcher.
	* language.c (default_symbol_name_matcher)
	(language_get_symbol_name_matcher): New functions.
	(unknown_language_defn, auto_language_defn): Adjust comments to
	refer to la_get_symbol_name_matcher.
	* language.h (symbol_name_cmp_ftype): Delete.
	(language_defn) <la_collect_symbol_completion_matches>: Add match
	type parameter.
	<la_get_symbol_name_cmp>: Delete field.
	<la_get_symbol_name_matcher>: New field.
	<la_iterate_over_symbols>: Adjust to use lookup_name_info.
	(default_symbol_name_matcher, language_get_symbol_name_matcher):
	Declare.
	* linespec.c (iterate_over_all_matching_symtabs)
	(iterate_over_file_blocks): Adjust to use lookup_name_info.
	(find_methods): Add language parameter, and use lookup_name_info
	and the language's symbol_name_matcher_ftype.
	(linespec_complete_function): Adjust.
	(lookup_prefix_sym): Use lookup_name_info.
	(add_all_symbol_names_from_pspace): Adjust.
	(find_superclass_methods): Add language parameter and pass it
	down.
	(find_method): Pass symbol language down.
	(find_linespec_symbols): Don't demangle or Ada encode here.
	(search_minsyms_for_name): Add lookup_name_info parameter.
	(add_matching_symbols_to_info): Add name_match_type parameter.
	Use lookup_name_info.
	* m2-lang.c (m2_language_defn): Adjust comments to refer to
	la_get_symbol_name_matcher.
	* minsyms.c: Include <algorithm>.
	(add_minsym_to_demangled_hash_table): Remove table parameter and
	add objfile parameter.  Use search_name_hash, and add language to
	demangled languages vector.
	(struct found_minimal_symbols): New struct.
	(lookup_minimal_symbol_mangled, lookup_minimal_symbol_demangled):
	New functions.
	(lookup_minimal_symbol): Adjust to use them.  Don't canonicalize
	input names here.  Use lookup_name_info instead.  Lookup up
	demangled names once for each language in the demangled names
	vector.
	(iterate_over_minimal_symbols): Use lookup_name_info.  Lookup up
	demangled names once for each language in the demangled names
	vector.
	(build_minimal_symbol_hash_tables): Adjust.
	* minsyms.h (iterate_over_minimal_symbols): Adjust to pass down a
	lookup_name_info.
	* objc-lang.c (objc_language_defn): Adjust comment to refer to
	la_get_symbol_name_matcher.
	* objfiles.h: Include <vector>.
	(objfile_per_bfd_storage) <demangled_hash_languages>: New field.
	* opencl-lang.c (opencl_language_defn): Adjust comment to refer to
	la_get_symbol_name_matcher.
	* p-lang.c (pascal_language_defn): Adjust comment to refer to
	la_get_symbol_name_matcher.
	* psymtab.c (psym_lookup_symbol): Use lookup_name_info.
	(match_partial_symbol): Use symbol_name_match_type,
	lookup_name_info and psymbol_name_matches.
	(lookup_partial_symbol): Use lookup_name_info.
	(map_block): Use symbol_name_match_type and lookup_name_info.
	(psym_map_matching_symbols): Use symbol_name_match_type.
	(psymbol_name_matches): New.
	(recursively_search_psymtabs): Use lookup_name_info and
	psymbol_name_matches.  Rename 'kind' parameter to 'domain'.
	(psym_expand_symtabs_matching): Use lookup_name_info.  Rename
	'kind' parameter to 'domain'.
	* rust-lang.c (rust_language_defn): Adjust comment to refer to
	la_get_symbol_name_matcher.
	* symfile-debug.c (debug_qf_map_matching_symbols)
	(debug_qf_map_matching_symbols): Use symbol_name_match_type.
	(debug_qf_expand_symtabs_matching): Use lookup_name_info.
	* symfile.c (expand_symtabs_matching): Use lookup_name_info.
	* symfile.h (quick_symbol_functions) <map_matching_symbols>:
	Adjust to use symbol_name_match_type.
	<expand_symtabs_matching>: Adjust to use lookup_name_info.
	(expand_symtabs_matching): Adjust to use lookup_name_info.
	* symmisc.c (maintenance_expand_symtabs): Use
	lookup_name_info::match_any ().
	* symtab.c (symbol_matches_search_name): New.
	(eq_symbol_entry): Adjust to use lookup_name_info and the
	language's matcher.
	(demangle_for_lookup_info::demangle_for_lookup_info): New.
	(lookup_name_info::match_any): New.
	(iterate_over_symbols, search_symbols): Use lookup_name_info.
	(compare_symbol_name): Add language, lookup_name_info and
	completion_match_result parameters, and use them.
	(completion_list_add_name): Make extern.  Add language and
	lookup_name_info parameters.  Use them.
	(completion_list_add_symbol, completion_list_add_msymbol)
	(completion_list_objc_symbol): Add lookup_name_info parameters and
	adjust.  Pass down language.
	(completion_list_add_fields): Add lookup_name_info parameters and
	adjust.  Pass down language.
	(add_symtab_completions): Add lookup_name_info parameters and
	adjust.
	(default_collect_symbol_completion_matches_break_on): Add
	name_match_type parameter, and use it.  Use lookup_name_info.
	(default_collect_symbol_completion_matches)
	(collect_symbol_completion_matches): Add name_match_type
	parameter, and pass it down.
	(collect_symbol_completion_matches_type): Adjust.
	(collect_file_symbol_completion_matches): Add name_match_type
	parameter, and use lookup_name_info.
	* symtab.h: Include <string> and "common/gdb_optional.h".
	(enum class symbol_name_match_type): New.
	(class ada_lookup_name_info): New.
	(struct demangle_for_lookup_info): New.
	(class lookup_name_info): New.
	(symbol_name_matcher_ftype): New.
	(SYMBOL_MATCHES_SEARCH_NAME): Use symbol_matches_search_name.
	(symbol_matches_search_name): Declare.
	(MSYMBOL_MATCHES_SEARCH_NAME): Delete.
	(default_collect_symbol_completion_matches)
	(collect_symbol_completion_matches)
	(collect_file_symbol_completion_matches): Add name_match_type
	parameter.
	(iterate_over_symbols): Use lookup_name_info.
	(completion_list_add_name): Declare.
	* utils.c (enum class strncmp_iw_mode): Moved to utils.h.
	(strncmp_iw_with_mode): Now extern.
	* utils.h (enum class strncmp_iw_mode): Moved from utils.c.
	(strncmp_iw_with_mode): Declare.

gdb/testsuite/ChangeLog:
2017-11-08   Pedro Alves  <palves@redhat.com>

	* gdb.ada/complete.exp (p <Exported_Capitalized>): New test.
	(p Exported_Capitalized): New test.
	(p exported_capitalized): New test.
2017-11-08 16:02:24 +00:00
Pedro Alves 5ffa079369 Per-language symbol name hashing algorithm
Currently, we have a mess of symbol name hashing/comparison routines.
There's msymbol_hash for mangled names, and dict_hash and
msymbol_hash_iw for demangled names.  Then there's strcmp_iw,
strcmp_iw_ordered and Ada's full_match/wild_match, which all have to
agree with the hashing routines.  That's why dict_hash is really about
Ada names.  From the inconsistency department, minimal symbol hashing
doesn't go via dict_hash, so Ada's wild matching can't ever work with
minimal symbols.

This patch starts fixing this, by doing two things:

#1 - adds a language vector method to let each language decide how to
     compute a symbol name hash.

#2 - makes dictionaries know the language of the symbols they hold,
     and then use the dictionaries language to decide which hashing
     method to use.

For now, this is just scaffolding, since all languages install the
default method.  The series will make C++ install its own hashing
method later on, and will add per-language symbol name comparison
routines too.

This patch was originally based on a patch that Keith wrote for the
libcc1/C++ WIP support.

gdb/ChangeLog:
2017-11-08  Keith Seitz  <keiths@redhat.com>
	    Pedro Alves  <palves@redhat.com>

	* ada-lang.c (ada_language_defn): Install
	default_search_name_hash.
	* buildsym.c (struct buildsym_compunit): <language>: New field.
	(finish_block_internal): Pass language when creating dictionaries.
	(start_buildsym_compunit, start_symtab): New language parameters.
	Use them.
	(restart_symtab): Pass down compilation unit's language.
	* buildsym.h (enum language): Forward declare.
	(start_symtab): New 'language' parameter.
	* c-lang.c (c_language_defn, cplus_language_defn)
	(asm_language_defn, minimal_language_defn): Install
	default_search_name_hash.
	* coffread.c (coff_start_symtab): Adjust.
	* d-lang.c (d_language_defn): Install default_search_name_hash.
	* dbxread.c (struct symloc): Add 'pst_language' field.
	(PST_LANGUAGE): Define.
	(start_psymtab, read_ofile_symtab): Use it.
	(process_one_symbol): New 'language' parameter.  Pass it down.
	* dictionary.c (struct dictionary) <language>: New field.
	(DICT_LANGUAGE): Define.
	(dict_create_hashed, dict_create_hashed_expandable)
	(dict_create_linear, dict_create_linear_expandable): New parameter
	'language'.  Set the dictionary's language.
	(iter_match_first_hashed): Adjust to rename.
	(insert_symbol_hashed): Assert we don't see mismatching
	languages.  Adjust to rename.
	(dict_hash): Rename to ...
	(default_search_name_hash): ... this and make extern.
	* dictionary.h (struct language_defn): Forward declare.
	(dict_create_hashed): New parameter 'language'.
	* dwarf2read.c (dwarf2_start_symtab): Pass down language.
	* f-lang.c (f_language_defn): Install default_search_name_hash.
	* go-lang.c (go_language_defn): Install default_search_name_hash.
	* jit.c (finalize_symtab): Pass compunit's language to dictionary
	creation.
	* language.c (unknown_language_defn, auto_language_defn):
	* language.h (language_defn::la_search_name_hash): New field.
	(default_search_name_hash): Declare.
	* m2-lang.c (m2_language_defn): Install default_search_name_hash.
	* mdebugread.c (new_block): New parameter 'language'.
	* mdebugread.c (parse_symbol): Pass symbol language to block
	allocation.
	(psymtab_to_symtab_1): Pass down language.
	(new_symtab): Pass compunit's language to block allocation.
	* objc-lang.c (objc_language_defn): Install
	default_search_name_hash.
	* opencl-lang.c (opencl_language_defn):
	* p-lang.c (pascal_language_defn): Install
	default_search_name_hash.
	* rust-lang.c (rust_language_defn): Install
	default_search_name_hash.
	* stabsread.h (enum language): Forward declare.
	(process_one_symbol): Add 'language' parameter.
	* symtab.c (search_name_hash): New function.
	* symtab.h (search_name_hash): Declare.
	* xcoffread.c (read_xcoff_symtab): Pass language to start_symtab.
2017-11-08 16:02:24 +00:00
Pedro Alves 2a1dde5da2 Fix "make test-cp-name-parser"
src/gdb/cp-name-parser.y: In function ‘int main(int, char**)’:
src/gdb/cp-name-parser.y:2132:30: error: ISO C++ forbids converting a string constant to ‘char*’ [-Werror=write-strings]
   char *str2, *extra_chars = "", c;
                              ^

Simply don't initialize the variable, it's not necessary.

gdb/ChangeLog:
2017-11-08  Pedro Alves  <palves@redhat.com>

	* cp-name-parser.y (main): Don't initialize extra_chars.
2017-11-08 15:28:50 +00:00
Nick Clifton 2841837fac Fix typo in changelog 2017-11-08 14:34:32 +00:00
Nick Clifton c0e7cef715 Split the AArch64 Crypto instructions for AES and SHA1+2 into their own options (+aes and +sha2).
The new options are:

	+aes: Enables the AES instructions of Armv8-a,
	      enabled by default with +crypto.

	+sha2: Enables the SHA1 and SHA2 instructions of Armv8-a,
	       enabled by default with +crypto.

These options have been turned on by default when +crypto
is used, as such no breakage is expected.

The reason for the split is because with the introduction of Armv8.4-a
the implementation of AES has explicitly been made independent of the
implementation of the other crypto extensions. Backporting the split does
not break any of the previous requirements and so is safe to do.

gas	* config/tc-aarch64.c
	(aarch64_features): Include AES and SHA2 in CRYPTO.
	Add SHA2 and AES.

include	* opcode/aarch64.h:
	(AARCH64_FEATURE_SHA2, AARCH64_FEATURE_AES): New.

opcodes	* aarch64-tbl.h (aarch64_feature_crypto): Add AES and SHA2.
	(aarch64_feature_sha2, aarch64_feature_aes): New.
	(SHA2, AES): New.
	(AES_INSN, SHA2_INSN): New.
	(pmull, pmull2, aese, aesd, aesmc, aesimc): Change to AES_INS.
	(sha1h, sha1su1, sha256su0, sha1c, sha1p,
	 sha1m, sha1su0, sha256h, sha256h2, sha256su1):
	Change to SHA2_INS.
2017-11-08 14:30:53 +00:00
Jiong Wang dec41383ff Adds command line support for Armv8.4-A, via the new command line option -march=armv8.4-a. Add support for "+dotprod" ARM feature (required for ARMv8.4-A). Add assembler and disassembler support for new FP16 instructions introduced in Armv8.4-A
gas	* config/tc-arm.c (arm_extensions):
	(arm_archs): New entry for "armv8.4-a".
	Add FPU_ARCH_DOTPROD_NEON_VFP_ARMV8.
	(arm_ext_v8_2): New variable.
	(enum arm_reg_type): New enumeration REG_TYPE_NSD.
	(reg_expected_msgs): New entry for REG_TYPE_NSD.
	(parse_typed_reg_or_scalar): Handle REG_TYPE_NSD.
	(parse_scalar): Support REG_TYPE_VFS.
	(enum operand_parse_code): New enumerations OP_RNSD and OP_RNSD_RNSC.
	(parse_operands): Handle OP_RNSD and OP_RNSD_RNSC.
	(NEON_SHAPE_DEF): New entries for DHH and DHS.
	(neon_scalar_for_fmac_fp16_long): New function to generate Rm encoding
	for new FP16 instructions in ARMv8.2-A.
	(do_neon_fmac_maybe_scalar_long): New function to encode new FP16
	instructions in ARMv8.2-A.
	(do_neon_vfmal): Wrapper function for vfmal.
	(do_neon_vfmsl): Wrapper function for vfmsl.
	(insns): New entries for vfmal and vfmsl.
	* doc/c-arm.texi (-march): Document "armv8.4-a".
	* testsuite/gas/arm/dotprod-mandatory.d: New test.
	* testsuite/gas/arm/armv8_2-a-fp16.s: New test source.
	* testsuite/gas/arm/armv8_2-a-fp16-illegal.s: New test source.
	* testsuite/gas/arm/armv8_2-a-fp16.d: New test.
	* testsuite/gas/arm/armv8_3-a-fp16.d: New test.
	* testsuite/gas/arm/armv8_4-a-fp16.d: New test.
	* testsuite/gas/arm/armv8_2-a-fp16-thumb2.d: New test.
	* testsuite/gas/arm/armv8_2-a-fp16-illegal.d: New test.
	* testsuite/gas/arm/armv8_2-a-fp16-illegal.l: New error file.

opcodes	* arm-dis.c (coprocessor_opcodes): New entries for ARMv8.2-A new
	FP16 instructions, including vfmal.f16 and vfmsl.f16.

include	* opcode/arm.h (ARM_AEXT2_V8_4A): Include Dot Product feature.
	(ARM_EXT2_V8_4A): New macro.
	(ARM_AEXT2_V8_4A): Likewise.
	(ARM_ARCH_V8_4A): Likewise.
2017-11-08 13:15:12 +00:00
Alan Modra 6e98b3428b xtensa message pluralization
* config/tc-xtensa.c (finish_vinsn): Properly pluralize error message.
2017-11-08 14:33:48 +10:30
GDB Administrator b346cb961f Automatic date update in version.in 2017-11-08 00:00:20 +00:00
Tom Tromey 95a6b0a106 Constify execute_command
This constifies execute_command and fixes up the callers.

gdb/ChangeLog
2017-11-07  Tom Tromey  <tom@tromey.com>

	* event-top.h (command_handler): Constify.
	* record-full.c (cmd_record_full_start): Update.
	* thread.c (thread_apply_all_command): Update.
	* printcmd.c (eval_command): Update.
	* mi/mi-main.c (mi_execute_cli_command): Update.
	(mi_execute_async_cli_command): Update.
	* tui/tui-stack.c (tui_update_command): Update.
	* cli/cli-interp.c (safe_execute_command): Constify.
	* record.c (record_start): Update.
	(record_start, record_stop, cmd_record_start): Update.
	* record-btrace.c (cmd_record_btrace_bts_start): Update.
	(cmd_record_btrace_pt_start): Update.
	(cmd_record_btrace_start): Update.
	(cmd_record_btrace_start): Update.
	* reverse.c (exec_reverse_once): Update.
	* python/python.c (execute_gdb_command): Don't copy the command.
	* event-top.c (command_line_handler): Update.
	(command_handler): Constify.
	* defs.h (deprecated_call_command_hook): Constify.
	* cli/cli-script.h (execute_user_command): Constify.
	* cli/cli-script.c (execute_user_command): Constify.
	(execute_cmd_pre_hook, execute_cmd_post_hook): Constify.
	(enum command_control_type): Update.
	* main.c (catch_command_errors): Remove non-const overload.
	(catch_command_errors_ftype): Remove.
	* python/py-cmd.c (cmdpy_function): Constify.
	* guile/scm-cmd.c (cmdscm_function): Constify.
	* cli/cli-dump.c (call_dump_func): Constify.
	* cli/cli-decode.c (do_const_cfunc): Constify.
	(do_sfunc): Constify.
	(cmd_func): Constify.
	* gdbcmd.h (execute_command, execute_command_to_string): Constify.
	* top.h (execute_command): Constify.
	* top.c (execute_command): Constify.
	(execute_command_to_string): Constify.
	(deprecated_call_command_hook): Constify.
	* command.h (cmd_func): Constify.
	* cli/cli-decode.h (struct cmd_list_element) <func>: Constify.
2017-11-07 13:59:09 -07:00
Tom Tromey eb4c3f4aaa Constify add_setshow_*
This constifies the add_setshow_* family of functions, and then fixes
up the fallout.  The bulk of this patch was written by script.

gdb/ChangeLog
2017-11-07  Tom Tromey  <tom@tromey.com>

	* ada-lang.c (catch_ada_exception_command): Constify.
	(catch_assert_command): Constify.
	* break-catch-throw.c (catch_catch_command, catch_throw_command)
	(catch_rethrow_command): Constify.
	(catch_exception_command_1): Constify.
	* breakpoint.h (add_catch_command): Constify.
	* break-catch-syscall.c (catch_syscall_command_1): Constify.
	(catch_syscall_split_args): Constify.
	* break-catch-sig.c (catch_signal_command): Constify.
	(catch_signal_split_args): Constify.
	* cli/cli-decode.h (struct cmd_list_element) <function>: Use
	cmd_const_sfunc_ftype.
	* cli/cli-decode.c (add_setshow_cmd_full): Constify.
	(add_setshow_enum_cmd, add_setshow_auto_boolean_cmd)
	(add_setshow_boolean_cmd, add_setshow_filename_cmd)
	(add_setshow_string_cmd, struct cmd_list_element)
	(add_setshow_optional_filename_cmd, add_setshow_integer_cmd)
	(add_setshow_uinteger_cmd, add_setshow_zinteger_cmd)
	(add_setshow_zuinteger_unlimited_cmd, add_setshow_zuinteger_cmd):
	Constify.
	(set_cmd_sfunc): Constify.
	(empty_sfunc): Constify.
	* command.h (add_setshow_enum_cmd, add_setshow_auto_boolean_cmd)
	(add_setshow_boolean_cmd, add_setshow_filename_cmd)
	(add_setshow_string_cmd, add_setshow_string_noescape_cmd)
	(add_setshow_optional_filename_cmd, add_setshow_integer_cmd)
	(add_setshow_uinteger_cmd, add_setshow_zinteger_cmd)
	(add_setshow_zuinteger_cmd, add_setshow_zuinteger_unlimited_cmd):
	Constify.
	(set_cmd_sfunc): Constify.
	(cmd_sfunc_ftype): Remove.
	* compile/compile.c (set_compile_args): Constify.
	* infrun.c (set_disable_randomization): Constify.
	* infcmd.c (set_args_command, set_cwd_command): Constify.
	* breakpoint.c (set_condition_evaluation_mode): Constify.
	(add_catch_command): Constify.
	(catch_fork_command_1, catch_exec_command_1)
	(catch_load_command_1, catch_unload_command_1): Constify.
	(catch_load_or_unload): Constify.
	* guile/scm-param.c (pascm_set_func): Constify.
	(add_setshow_generic): Constify.
	* python/py-param.c (get_set_value): Constify.
	* top.h (set_verbose): Constify.
	* tui/tui-win.c (tui_set_var_cmd): Constify.
	* mi/mi-main.c (set_mi_async_command): Constify.
	* cli/cli-logging.c (set_logging_overwrite)
	(set_logging_redirect): Constify.
	* value.c (set_max_value_size): Constify.
	* valprint.c (set_input_radix, set_output_radix): Constify.
	* utils.c (set_width_command, set_height_command): Constify.
	* typeprint.c (set_print_type_methods, set_print_type_typedefs): Constify.
	* tracepoint.c (set_disconnected_tracing)
	(set_circular_trace_buffer, set_trace_buffer_size)
	(set_trace_user, set_trace_notes, set_trace_stop_notes): Constify.
	* top.c (set_history_size_command, set_verbose, set_editing)
	(set_gdb_datadir, set_history_filename): Constify.
	* target.c (set_targetdebug, maint_set_target_async_command)
	(maint_set_target_non_stop_command, set_target_permissions)
	(set_write_memory_permission): Constify.
	(open_target): Constify.
	* target-descriptions.c (set_tdesc_filename_cmd): Constify.
	* target-dcache.c (set_stack_cache, set_code_cache): Constify.
	* symtab.c (set_symbol_cache_size_handler): Constify.
	* symfile.c (set_ext_lang_command): Constify.
	* symfile-debug.c (set_debug_symfile): Constify.
	* source.c (set_directories_command): Constify.
	* solib.c (reload_shared_libraries, gdb_sysroot_changed): Constify.
	* serial.c (set_parity): Constify.
	* rs6000-tdep.c (powerpc_set_soft_float, powerpc_set_vector_abi): Constify.
	* remote.c (set_remote_exec_file, set_remotebreak)
	(set_remote_protocol_Z_packet_cmd, set_range_stepping): Constify.
	* record.c (set_record_insn_history_size)
	(set_record_call_history_size): Constify.
	* record-full.c (set_record_full_insn_max_num): Constify.
	* proc-api.c (set_procfs_trace_cmd, set_procfs_file_cmd): Constify.
	* osabi.c (set_osabi): Constify.
	* mips-tdep.c (set_mips64_transfers_32bit_regs)
	(reinit_frame_cache_sfunc, mips_abi_update): Constify.
	* maint.c (maintenance_set_profile_cmd): Constify.
	* linux-thread-db.c (set_libthread_db_search_path): Constify.
	* language.c (set_language_command, set_range_command)
	(set_case_command): Constify.
	* infrun.c (set_non_stop, set_observer_mode)
	(set_stop_on_solib_events, set_schedlock_func)
	(set_exec_direction_func): Constify.
	* infcmd.c (set_inferior_tty_command): Constify.
	* disasm.c (set_disassembler_options_sfunc): Constify.
	* demangle.c (set_demangling_command): Constify.
	* dcache.c (set_dcache_size, set_dcache_line_size): Constify.
	* cris-tdep.c (set_cris_version, set_cris_mode)
	(set_cris_dwarf2_cfi): Constify.
	* corefile.c (set_gnutarget_command): Constify.
	* charset.c (set_host_charset_sfunc, set_target_charset_sfunc)
	(set_target_wide_charset_sfunc): Constify.
	* breakpoint.c (update_dprintf_commands): Constify.
	* auto-load.c (set_auto_load_dir, set_auto_load_safe_path): Constify.
	* arm-tdep.c (set_fp_model_sfunc, arm_set_abi)
	(set_disassembly_style_sfunc): Constify.
	* arch-utils.c (set_endian, set_architecture): Constify.
	* alpha-tdep.c (reinit_frame_cache_sfunc): Constify.
	* agent.c (set_can_use_agent): Constify.
2017-11-07 13:59:09 -07:00
Tom Tromey 5fed81ff35 Remove cmd_cfunc_ftype
This removes cmd_cfunc_ftype and the non-const overload of add_cmd;
then fixes up the fallout.

For the most part this patch is straightforward.  There are a few
files (go32-nat.c, windows-nat.c, and gnu-nat.c) that I could not
compile; so I made a best effort there.

gdb/ChangeLog
2017-11-07  Tom Tromey  <tom@tromey.com>

	* go32-nat.c (go32_sysinfo, go32_sldt, go32_sgdt, go32_sidt)
	(go32_pde, go32_pte, go32_pte_for_address): Constify.
	* gnu-nat.c (_parse_bool_arg, show_thread_default_pause_cmd)
	(set_thread_default_pause_cmd, set_thread_default_run_cmd)
	(show_thread_default_run_cmd, set_thread_default_detach_sc_cmd)
	(parse_int_arg, show_thread_default_detach_sc_cmd)
	(set_signals_cmd, show_signals_cmd, set_sig_thread_cmd)
	(show_sig_thread_cmd, set_stopped_cmd, show_stopped_cmd)
	(set_exceptions_cmd, show_exceptions_cmd, set_task_pause_cmd)
	(show_task_pause_cmd, set_task_detach_sc_cmd)
	(show_task_detach_sc_cmd, set_task_exc_port_cmd)
	(set_noninvasive_cmd, set_thread_pause_cmd)
	(show_thread_pause_cmd, set_thread_run_cmd, show_thread_run_cmd)
	(set_thread_detach_sc_cmd, show_thread_detach_sc_cmd)
	(set_thread_exc_port_cmd, thread_takeover_sc_cmd): Constify.
	* windows-nat.c (display_selectors): Constify.
	* cli/cli-decode.h (struct cmd_list_element) <function>: Remove
	non-const "cfunc".
	* cli/cli-decode.c (set_cmd_cfunc): Remove non-const overload.
	(cmd_cfunc_eq): Likewise.
	(struct cmd_list_element): Likewise.
	(do_cfunc): Remove.
	(cli_user_command_p): Update.
	* command.h (add_cmd): Remove non-const overload.
	(cmd_cfunc_ftype): Remove typedef.
	(cmd_cfunc_eq): Remove non-const overload.
	* value.c (show_values): Constify.
	* thread.c (thread_apply_all_command): Constify.
	* symfile.c (load_command): Constify.
	* source.c (directory_command): Constify.
	* maint.c (maintenance_internal_error)
	(maintenance_demangler_warning, maintenance_space_display)
	(maintenance_print_architecture, maintenance_translate_address)
	(maintenance_info_selftests, maintenance_internal_warning):
	Constify.
	* breakpoint.c (disable_trace_command, enable_trace_command):
	Constify.
	* auto-load.c (info_auto_load_local_gdbinit, add_auto_load_dir):
	Constify.
	(add_auto_load_safe_path): Constify.
	* guile/scm-auto-load.c (info_auto_load_guile_scripts): Constify.
	* top.h (show_commands): Constify.
	* linux-thread-db.c (info_auto_load_libthread_db): Constify.
	* sparc64-tdep.c (adi_examine_command): Constify.
	(adi_assign_command): Constify.
2017-11-07 13:59:09 -07:00
Tom Tromey 1d12d88f18 Constify add_info
This patch constifies add_info and updates all the info commands.  The
bulk of this patch was written using a script; and then I did a manual
pass to fix up the remaining compilation errors.

I could not compile every changed file; in particular nto-procfs.c,
gnu-nat.c, and darwin-nat-info.c; but I at least tried to check the
correctness by inspection.

gdb/ChangeLog
2017-11-07  Tom Tromey  <tom@tromey.com>

	* frame.h (info_locals_command, info_args_command): Constify.
	* auto-load.h (auto_load_info_scripts): Constify.
	* inferior.h (registers_info): Constify.
	* copying.c: Rebuild.
	* copying.awk: Constify generated commands.
	* auto-load.c (auto_load_info_scripts)
	(info_auto_load_gdb_scripts): Constify.
	* cli/cli-decode.c (struct cmd_list_element): Take a
	cmd_const_cfunc_ftype.
	* command.h (add_info): Take a cmd_const_cfunc_ftype.
	* tui/tui-win.c (tui_all_windows_info): Constify.
	* python/py-auto-load.c (info_auto_load_python_scripts):
	Constify.
	* cli/cli-cmds.c (show_command): Remove non-const overload.
	* tracepoint.c (info_tvariables_command, info_scope_command):
	Constify.
	(info_static_tracepoint_markers_command): Constify.
	* thread.c (info_threads_command): Constify.
	(print_thread_info_1): Constify.
	* target.c (info_target_command): Constify.
	* symtab.c (info_sources_command, info_functions_command)
	(info_types_command): Constify.
	(info_variables_command): Remove non-const overload.
	* symfile.c (info_ext_lang_command): Constify.
	* stack.c (info_frame_command, info_locals_command)
	(info_args_command): Constify.
	(backtrace_command): Remove non-const overload.
	* source.c (info_source_command, info_line_command): Constify.
	* solib.c (info_sharedlibrary_command): Constify.
	* skip.c (info_skip_command): Constify.
	* ser-go32.c (info_serial_command): Constify.
	* reverse.c (info_bookmarks_command): Constify.
	* printcmd.c (info_symbol_command, info_address_command)
	(info_display_command): Constify.
	* osdata.c (info_osdata_command): Constify.
	* objc-lang.c (info_selectors_command, info_classes_command):
	Constify.
	* nto-procfs.c (procfs_pidlist, procfs_meminfo): Constify.
	* memattr.c (info_mem_command): Constify.
	* macrocmd.c (info_macro_command, info_macros_command): Constify.
	* linux-fork.c (info_checkpoints_command): Constify.
	* infrun.c (info_signals_command): Constify.
	* inflow.c (info_terminal_command): Constify.
	* inferior.c (info_inferiors_command): Constify.
	(print_inferior): Constify.
	* infcmd.c (info_program_command, info_all_registers_command)
	(info_registers_command, info_vector_command)
	(info_float_command): Constify.
	(registers_info): Constify.
	* gnu-nat.c (info_send_rights_cmd, info_recv_rights_cmd)
	(info_port_sets_cmd, info_dead_names_cmd, info_port_rights_cmd):
	Constify.
	* f-valprint.c (info_common_command): Constify.
	* dcache.c (info_dcache_command): Constify.
	(dcache_info_1): Constify.
	* darwin-nat-info.c (info_mach_tasks_command)
	(info_mach_task_command, info_mach_ports_command)
	(info_mach_port_command, info_mach_threads_command)
	(info_mach_thread_command, info_mach_regions_command)
	(info_mach_regions_recurse_command, info_mach_region_command)
	(info_mach_exceptions_command): Constify.
	(get_task_from_args): Constify.
	* cp-support.c (info_vtbl_command): Constify.
	* breakpoint.c (info_watchpoints_command)
	(info_tracepoints_command): Constify.
	(info_breakpoints_command): Remove non-const overload.
	* avr-tdep.c (avr_io_reg_read_command): Constify.
	* auxv.c (info_auxv_command): Constify.
	* ada-tasks.c (info_tasks_command): Constify.
	(info_task): Constify.
	* ada-lang.c (info_exceptions_command): Constify.
2017-11-07 13:59:09 -07:00
Tom Tromey 0b39b52e6e Constify add_com
This changes add_com to take a cmd_const_cfunc_ftype, and then fixes
up all the command implementations.

In most cases this is trivial.

In a couple of places I had to again introduce a temporary non-const
overload.  These overloads will be removed when add_info is
constified.

gdb/ChangeLog
2017-11-07  Tom Tromey  <tom@tromey.com>

	* solib.h (no_shared_libraries): Constify.
	* frame.h (return_command): Constify.
	* cli/cli-cmds.h (quit_command): Constify.
	* top.h (quit_command, execute_command): Constify.
	* target.h (flash_erase_command): Constify.
	* inferior.h (set_inferior_args, attach_command): Constify.
	* tracepoint.h (start_tracing, stop_tracing): Constify.
	* breakpoint.h (break_command, tbreak_command)
	(hbreak_command_wrapper, thbreak_command_wrapper)
	(rbreak_command_wrapper, watch_command_wrapper)
	(awatch_command_wrapper, rwatch_command_wrapper)
	(get_tracepoint_by_number): Constify.
	* symtab.c (info_variables_command, rbreak_command)
	(symtab_symbol_info): Constify.
	(info_variables_command): Add non-const overload.
	* top.c (dont_repeat_command): Constify.
	* breakpoint.c (ignore_command, commands_command)
	(condition_command, tbreak_command, hbreak_command)
	(thbreak_command, clear_command, break_command)
	(info_breakpoints_command, watch_command, rwatch_command)
	(awatch_command, trace_command, ftrace_command, strace_command)
	(trace_pass_command, break_range_command, dprintf_command)
	(agent_printf_command, get_tracepoint_by_number)
	(watch_maybe_just_location, trace_pass_command): Constify.
	(info_breakpoints_command): Add non-const overload.
	* tracefile.c (tsave_command): Constify.
	* infcmd.c (attach_command, disconnect_command, signal_command)
	(queue_signal_command, stepi_command, nexti_command)
	(finish_command, next_command, step_command, until_command)
	(advance_command, jump_command, continue_command, run_command)
	(start_command, starti_command, interrupt_command)
	(run_command_1, set_inferior_args, step_1): Constify.
	* inferior.c (add_inferior_command, remove_inferior_command)
	(clone_inferior_command): Constify.
	* linux-fork.c (checkpoint_command, restart_command): Constify.
	* windows-nat.c (signal_event_command): Constify.
	* guile/guile.c (guile_repl_command, guile_command): Constify.
	* printcmd.c (x_command, display_command, printf_command)
	(output_command, set_command, call_command, print_command)
	(eval_command): Constify.
	(non_const_set_command): Remove.
	(_initialize_printcmd): Update.
	* source.c (forward_search_command, reverse_search_command):
	Constify.
	* jit.c (jit_reader_load_command, jit_reader_unload_command):
	Constify.
	* infrun.c (handle_command): Constify.
	* memattr.c (mem_command): Constify.
	* stack.c (return_command, up_command, up_silently_command)
	(down_command, down_silently_command, frame_command)
	(backtrace_command, func_command, backtrace_command_1): Constify.
	(backtrace_command): Add non-const overload.
	* remote-sim.c (simulator_command): Constify.
	* exec.c (set_section_command): Constify.
	* tracepoint.c (tdump_command, trace_variable_command)
	(tstatus_command, tstop_command, tstart_command)
	(end_actions_pseudocommand, while_stepping_pseudocommand)
	(collect_pseudocommand, teval_pseudocommand, actions_command)
	(start_tracing, stop_tracing): Constify.
	* value.c (init_if_undefined_command): Constify.
	* tui/tui-stack.c (tui_update_command): Constify.
	* tui/tui-win.c (tui_refresh_all_command)
	(tui_set_tab_width_command, tui_set_win_height_command)
	(tui_set_focus_command, tui_scroll_forward_command)
	(tui_scroll_backward_command, tui_scroll_left_command)
	(tui_scroll_right_command, parse_scrolling_args, tui_set_focus)
	(tui_set_win_height): Constify.
	* tui/tui-layout.c (tui_layout_command): Constify.
	* procfs.c (proc_trace_syscalls, proc_trace_sysentry_cmd)
	(proc_trace_sysexit_cmd, proc_untrace_sysentry_cmd)
	(proc_untrace_sysexit_cmd): Constify.
	* remote.c (threadlist_test_cmd, threadinfo_test_cmd)
	(threadset_test_cmd, threadlist_update_test_cmd)
	(threadalive_test): Constify.
	* objc-lang.c (print_object_command): Constify.
	* command.h (add_com): Constify.
	* cli/cli-dump.c (restore_command): Constify.
	* cli/cli-cmds.c (pwd_command, echo_command, quit_command)
	(help_command, complete_command, shell_command, edit_command)
	(list_command, disassemble_command, make_command)
	(apropos_command, alias_command): Constify.
	* cli/cli-script.c (document_command, define_command)
	(while_command, if_command, validate_comname): Constify.
	* cli/cli-decode.c (struct cmd_list_element): Change type of
	"fun".
	* target.c (do_monitor_command, flash_erase_command): Constify.
	* regcache.c (reg_flush_command): Constify.
	* reverse.c (reverse_step, reverse_next, reverse_stepi)
	(reverse_nexti, reverse_continue, reverse_finish)
	(save_bookmark_command, goto_bookmark_command)
	(exec_reverse_once): Constify.
	* python/python.c (python_interactive_command, python_command):
	Constify.
	* typeprint.c (ptype_command, whatis_command, whatis_exp):
	Constify.
	* solib.c (sharedlibrary_command, no_shared_libraries): Constify.
	* gcore.c (gcore_command): Constify.
2017-11-07 13:59:09 -07:00
Tom Tromey 85c4be7c83 Add set_repeat_arguments function
The "x", "list", and "show commands" commands have special repetition
behavior: repeating the command doesn't re-run it with the same
arguments

This is currently implemented by modifying the passed-in argument; but
that won't work properly with const arguments (and seems pretty
obscure besides).

This patch adds a new "set_repeat_arguments" function and changes the
relevant places to call it.

gdb/ChangeLog
2017-11-07  Tom Tromey  <tom@tromey.com>

	* printcmd.c (x_command): Call set_repeat_arguments.
	* cli/cli-cmds.c (list_command): Call set_repeat_arguments.
	* top.c (repeat_arguments): New global.
	(set_repeat_arguments): New function.
	(execute_command): Handle repeat_arguments.
	(show_commands): Calls set_repeat_arguments.
	* command.h (set_repeat_arguments): Declare.
2017-11-07 13:59:09 -07:00
Tom Tromey 022643b445 Remove cleanup from backtrace_command
This removes a cleanup from backtrace_command, replacing it with
std::string.  This patch temporarily changes backtrace_command so that
the parameter is named "args_in" and is immediately constified; this
is fixed again in the constification patch.

gdb/ChangeLog
2017-11-07  Tom Tromey  <tom@tromey.com>

	* stack.c (backtrace_command): Use std::string.
	(backtrace_command_1): Make "count_exp" const.
2017-11-07 13:59:09 -07:00
Tom Tromey 5614fb7720 Constify add_path and friends
This constifies add_path, mod_path, and directory_switch.

gdb/ChangeLog
2017-11-07  Tom Tromey  <tom@tromey.com>

	* source.c (directory_switch, mod_path, add_path): Constify.
	* defs.h (add_path, mod_path, directory_switch): Constify.
	* mi/mi-cmd-env.c (env_mod_path): Constify.
2017-11-07 13:59:09 -07:00
Tom Tromey 6be9a197d9 Make strip_bg_char return a unique_xmalloc_ptr
This changes strip_bg_char to return a unique_xmalloc_ptr and removes
several cleanups.

gdb/ChangeLog
2017-11-07  Tom Tromey  <tom@tromey.com>

	* infcmd.c (strip_bg_char): Return gdb::unique_xmalloc_ptr.
	(run_command_1, continue_command, step_1, jump_command)
	(signal_command, until_command, advance_command, finish_command)
	(attach_command): Update.
2017-11-07 13:59:09 -07:00
Tom Tromey c2252c0dd8 Make set_cmd_cfunc private
set_cmd_cfunc is only used in cli-decode.c, and I don't think there is
a good reason to expose it directly.  So, this patch makes it private.

gdb/ChangeLog
2017-11-07  Tom Tromey  <tom@tromey.com>

	* command.h (set_cmd_cfunc): Don't declare.
	* cli/cli-decode.c (set_cmd_cfunc): Now static.
2017-11-07 13:59:08 -07:00
Tom Tromey 1ee870c524 Constify add_com_suppress_notification
This constifies add_com_suppress_notification and fixes the one
caller.

gdb/ChangeLog
2017-11-07  Tom Tromey  <tom@tromey.com>

	* stack.c (select_frame_command): Constify.
	* cli/cli-decode.c (add_com_suppress_notification): Constify.
	* command.h (add_com_suppress_notification): Constify.
2017-11-07 13:59:08 -07:00
Tom Tromey ee7ddd7132 Constify add_abbrev_prefix_cmd
This changes add_abbrev_prefix_cmd to take a const-taking callback
function and then fixes the one caller.

gdb/ChangeLog
2017-11-07  Tom Tromey  <tom@tromey.com>

	* breakpoint.c (stop_command): Constify.
	* cli/cli-decode.c (struct cmd_list_element): Constify.
	* command.h (add_abbrev_prefix_cmd): Constify.
2017-11-07 13:59:08 -07:00
Andrew Burgess 52eab766df opcodes/arc: Fix incorrect insn_class for some nps insns
A small number of NPS400 instruction incorrectly used NONE as an
insn_class_t, which would trigger a build warning.  Fixed by changing to
MISC.

opcodes/ChangeLog:

	* arc-nps400-tbl.h: Change incorrect use of NONE to MISC.
2017-11-07 20:24:21 +00:00
Jim Wilson 016f5a3777 Fix typo in my email address.
binutils/
	* MAINTAINERS (RISC-V): Fix typo in my email address.
2017-11-07 09:43:18 -08:00
Palmer Dabbelt 180093c763 RISC-V: Add Jim Wilson as a maintainer, and clean up our entries
Jim has recently started working at SiFive, where he'll be contributing
to our binutils port.  Andrew and I would like him to be a maintainer.
My understanding is that this is right place to ask.

I've also changed my address to my SiFive one, where I also work -- it
seems cleaner to have everyone use our proper email address.  While I
was in there, I noticed a trailing space after Andrew's name so I went
ahead and removed it as well.

binutils/ChangeLog

2017-11-07  Palmer Dabbelt  <palmer@sifive.com>

        * MAINTAINERS (RISC-V): Add Jim Wilson as a maintainer.
        Clean up Andrew's entry (remove trailing space, add tabs).
        Change Palmer's email address, and clean up entry (add tabs).
2017-11-07 09:22:04 -08:00