Commit Graph

148 Commits

Author SHA1 Message Date
Simon Marchi f076f0349c x86-dregs: Print debug registers one per line
This get around this warning given by clang...

  /home/emaisin/src/binutils-gdb/gdb/nat/x86-dregs.c:209:7: error: variable 'i' is incremented both in the loop header and in the loop body [-Werror,-Wfor-loop-analysis]
        i++;
        ^
  /home/emaisin/src/binutils-gdb/gdb/nat/x86-dregs.c:199:32: note: incremented here
    ALL_DEBUG_ADDRESS_REGISTERS (i)
                               ^

... I decided in the end to simply print the debug registers one per
line.  I don't think it particularly helps readability to have them two
per line anyway.

gdb/ChangeLog:

	* nat/x86-dregs.c (x86_show_dr): Print registers one per line.
2017-06-25 12:40:10 +02:00
Thomas Petazzoni ffce45d224 nat/linux-ptrace.c: add missing gdb_byte* cast
On noMMU platforms, the following code gets compiled:

  child_stack = xmalloc (STACK_SIZE * 4);

Where child_stack is a gdb_byte*, and xmalloc() returns a void*. While
the lack of cast is valid in C, it is not in C++, causing the
following build failure:

../nat/linux-ptrace.c: In function 'int linux_fork_to_function(gdb_byte*, int (*)(void*))':
../nat/linux-ptrace.c:273:29: error: invalid conversion from 'void*' to 'gdb_byte* {aka unsigned char*}' [-fpermissive]
       child_stack = xmalloc (STACK_SIZE * 4);

Therefore, this commit adds the appropriate cast.

gdb/ChangeLog:

	* nat/linux-ptrace.c (linux_fork_to_function): Add cast to
	gdb_byte*.

Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
2017-06-18 23:29:03 +02:00
Simon Marchi 1d4fbac99e Add ATTRIBUTE_PRINTF to trace_start_error
clang complains that the fmt passed to vwarning in trace_start_error is
not a literal.  This looks like a fair warning, which can be removed by
adding ATTRIBUTE_PRINTF to the declaration of trace_start_error.

gdb/ChangeLog:

	* nat/fork-inferior.h (trace_start_error): Add ATTRIBUTE_PRINTF.
2017-06-17 23:19:25 +02:00
Sergio Durigan Junior 2090129c36 Share fork_inferior et al with gdbserver
This is the most important (and the biggest, sorry) patch of the
series.  It moves fork_inferior from gdb/fork-child.c to
nat/fork-inferior.c and makes all the necessary adjustments to both
GDB and gdbserver to make sure everything works OK.

There is no "most important change" with this patch; all changes are
made in a progressive way, making sure that gdbserver had the
necessary features while not breaking GDB at the same time.

I decided to go ahead and implement a partial support for starting the
inferior with a shell on gdbserver, although the full feature comes in
the next patch.  The user won't have the option to disable the
startup-with-shell, and also won't be able to change which shell
gdbserver will use (other than setting the $SHELL environment
variable, that is).

Everything is working as expected, and no regressions were present
during the tests.

gdb/ChangeLog:
2017-06-07  Sergio Durigan Junior  <sergiodj@redhat.com>
	    Pedro Alves  <palves@redhat.com>

	* Makefile.in (HFILES_NO_SRCDIR): Add "common/common-inferior.h"
	and "nat/fork-inferior.h".
	* common/common-inferior.h: New file, with contents from
	"gdb/inferior.h".
	* commom/common-utils.c: Include "common-utils.h".
	(stringify_argv): New function.
	* common/common-utils.h (stringify_argv): New prototype.
	* configure.nat: Add "fork-inferior.o" as a dependency for
	"*linux*", "fbsd*" and "nbsd*" hosts.
	* corefile.c (get_exec_file): Update comment.
	* darwin-nat.c (darwin_ptrace_him): Call "gdb_startup_inferior"
	instead of "startup_inferior".
	(darwin_create_inferior): Call "add_thread_silent" after
	"fork_inferior".
	* fork-child.c: Cleanup unnecessary includes.
	(SHELL_FILE): Move to "common/common-fork-child.c".
	(environ): Likewise.
	(exec_wrapper): Initialize.
	(get_exec_wrapper): New function.
	(breakup_args): Move to "common/common-fork-child.c"; rename to
	"breakup_args_for_exec".
	(escape_bang_in_quoted_argument): Move to
	"common/common-fork-child.c".
	(saved_ui): New variable.
	(prefork_hook): New function.
	(postfork_hook): Likewise.
	(postfork_child_hook): Likewise.
	(gdb_startup_inferior): Likewise.
	(fork_inferior): Move to "common/common-fork-child.c".  Update
	function to support gdbserver.
	(startup_inferior): Likewise.
	* gdbcore.h (get_exec_file): Remove declaration.
	* gnu-nat.c (gnu_create_inferior): Call "gdb_startup_inferior"
	instead of "startup_inferior".  Call "add_thread_silent" after
	"fork_inferior".
	* inf-ptrace.c: Include "nat/fork-inferior.h" and "utils.h".
	(inf_ptrace_create_inferior): Call "gdb_startup_inferior"
	instead of "startup_inferior".  Call "add_thread_silent" after
	"fork_inferior".
	* inferior.h: Include "common-inferior.h".
	(trace_start_error): Move to "common/common-utils.h".
	(trace_start_error_with_name): Likewise.
	(fork_inferior): Move prototype to "nat/fork-inferior.h".
	(startup_inferior): Likewise.
	(gdb_startup_inferior): New prototype.
	* nat/fork-inferior.c: New file, with contents from "fork-child.c".
	* nat/fork-inferior.h: New file.
	* procfs.c (procfs_init_inferior): Call "gdb_startup_inferior"
	instead of "startup_inferior".  Call "add_thread_silent" after
	"fork_inferior".
	* target.h (target_terminal_init): Move prototype to
	"target/target.h".
	(target_terminal_inferior): Likewise.
	(target_terminal_ours): Likewise.
	* target/target.h (target_terminal_init): New prototype, moved
	from "target.h".
	(target_terminal_inferior): Likewise.
	(target_terminal_ours): Likewise.
	* utils.c (gdb_flush_out_err): New function.

gdb/gdbserver/ChangeLog:
2017-06-07  Sergio Durigan Junior  <sergiodj@redhat.com>
	    Pedro Alves  <palves@redhat.com>

	* Makefile.in (SFILES): Add "nat/fork-inferior.o".
	* configure: Regenerate.
	* configure.srv (srv_linux_obj): Add "fork-child.o" and
	"fork-inferior.o".
	(i[34567]86-*-lynxos*): Likewise.
	(spu*-*-*): Likewise.
	* fork-child.c: New file.
	* linux-low.c: Include "common-inferior.h", "nat/fork-inferior.h"
	and "environ.h".
	(linux_ptrace_fun): New function.
	(linux_create_inferior): Adjust function prototype to reflect
	change on "target.h".  Adjust function code to use
	"fork_inferior".
	(linux_request_interrupt): Delete "signal_pid".
	* lynx-low.c: Include "common-inferior.h" and "nat/fork-inferior.h".
	(lynx_ptrace_fun): New function.
	(lynx_create_inferior): Adjust function prototype to reflect
	change on "target.h".  Adjust function code to use
	"fork_inferior".
	* nto-low.c (nto_create_inferior): Adjust function prototype and
	code to reflect change on "target.h".  Update comments.
	* server.c: Include "common-inferior.h", "nat/fork-inferior.h",
	"common-terminal.h" and "environ.h".
	(terminal_fd): Moved to fork-child.c.
	(old_foreground_pgrp): Likewise.
	(restore_old_foreground_pgrp): Likewise.
	(last_status): Make it global.
	(last_ptid): Likewise.
	(our_environ): New variable.
	(startup_with_shell): Likewise.
	(program_name): Likewise.
	(program_argv): Rename to...
	(program_args): ...this.
	(wrapper_argv): New variable.
	(start_inferior): Delete function.
	(get_exec_wrapper): New function.
	(get_exec_file): Likewise.
	(get_environ): Likewise.
	(prefork_hook): Likewise.
	(post_fork_inferior): Likewise.
	(postfork_hook): Likewise.
	(postfork_child_hook): Likewise.
	(handle_v_run): Update code to deal with arguments coming from the
	remote host.  Update calls from "start_inferior" to
	"create_inferior".
	(captured_main): Likewise.  Initialize environment variable.  Call
	"have_job_control".
	* server.h (post_fork_inferior): New prototype.
	(get_environ): Likewise.
	(last_status): Declare.
	(last_ptid): Likewise.
	(signal_pid): Likewise.
	* spu-low.c: Include "common-inferior.h" and "nat/fork-inferior.h".
	(spu_ptrace_fun): New function.
	(spu_create_inferior): Adjust function prototype to reflect change
	on "target.h".  Adjust function code to use "fork_inferior".
	* target.c (target_terminal_init): New function.
	(target_terminal_inferior): Likewise.
	(target_terminal_ours): Likewise.
	* target.h: Include <vector>.
	(struct target_ops) <create_inferior>: Update prototype.
	(create_inferior): Update macro.
	* utils.c (gdb_flush_out_err): New function.
	* win32-low.c (win32_create_inferior): Adjust function prototype
	and code to reflect change on "target.h".

gdb/testsuite/ChangeLog:
2017-06-07  Sergio Durigan Junior  <sergiodj@redhat.com>

	* gdb.server/non-existing-program.exp: Update regex in order to
	reflect the fact that gdbserver is now using fork_inferior (with a
	shell) to startup the inferior.
2017-06-07 19:56:09 -04:00
Pedro Alves a121b7c1ac -Wwrite-strings: The Rest
This is the remainder boring constification that all looks more of less
borderline obvious IMO.

gdb/ChangeLog:
2017-04-05  Pedro Alves  <palves@redhat.com>

	* ada-exp.y (yyerror): Constify.
	* ada-lang.c (bound_name, get_selections)
	(ada_variant_discrim_type)
	(ada_variant_discrim_name, ada_value_struct_elt)
	(ada_lookup_struct_elt_type, is_unchecked_variant)
	(ada_which_variant_applies, standard_exc, ada_get_next_arg)
	(catch_ada_exception_command_split)
	(catch_ada_assert_command_split, catch_assert_command)
	(ada_op_name): Constify.
	* ada-lang.h (ada_yyerror, get_selections)
	(ada_variant_discrim_name, ada_value_struct_elt): Constify.
	* arc-tdep.c (arc_print_frame_cache): Constify.
	* arm-tdep.c (arm_skip_stub): Constify.
	* ax-gdb.c (gen_binop, gen_struct_ref_recursive, gen_struct_ref)
	(gen_aggregate_elt_ref): Constify.
	* bcache.c (print_bcache_statistics): Constify.
	* bcache.h (print_bcache_statistics): Constify.
	* break-catch-throw.c (catch_exception_command_1):
	* breakpoint.c (struct ep_type_description::description):
	Constify.
	(add_solib_catchpoint): Constify.
	(catch_fork_command_1): Add cast.
	(add_catch_command): Constify.
	* breakpoint.h (add_catch_command, add_solib_catchpoint):
	Constify.
	* bsd-uthread.c (bsd_uthread_state): Constify.
	* buildsym.c (patch_subfile_names): Constify.
	* buildsym.h (next_symbol_text_func, patch_subfile_names):
	Constify.
	* c-exp.y (yyerror): Constify.
	(token::oper): Constify.
	* c-lang.h (c_yyerror, cp_print_class_member): Constify.
	* c-varobj.c (cplus_describe_child): Constify.
	* charset.c (find_charset_names): Add cast.
	(find_charset_names): Constify array and add const_cast.
	* cli/cli-cmds.c (complete_command, cd_command): Constify.
	(edit_command): Constify.
	* cli/cli-decode.c (lookup_cmd): Constify.
	* cli/cli-dump.c (dump_memory_command, dump_value_command):
	Constify.
	(struct dump_context): Constify.
	(add_dump_command, restore_command): Constify.
	* cli/cli-script.c (get_command_line): Constify.
	* cli/cli-script.h (get_command_line): Constify.
	* cli/cli-utils.c (check_for_argument): Constify.
	* cli/cli-utils.h (check_for_argument): Constify.
	* coff-pe-read.c (struct read_pe_section_data): Constify.
	* command.h (lookup_cmd): Constify.
	* common/print-utils.c (decimal2str): Constify.
	* completer.c (gdb_print_filename): Constify.
	* corefile.c (set_gnutarget): Constify.
	* cp-name-parser.y (yyerror): Constify.
	* cp-valprint.c (cp_print_class_member): Constify.
	* cris-tdep.c (cris_register_name, crisv32_register_name):
	Constify.
	* d-exp.y (yyerror): Constify.
	(struct token::oper): Constify.
	* d-lang.h (d_yyerror): Constify.
	* dbxread.c (struct header_file_location::name): Constify.
	(add_old_header_file, add_new_header_file, last_function_name)
	(dbx_next_symbol_text, add_bincl_to_list)
	(find_corresponding_bincl_psymtab, set_namestring)
	(find_stab_function_addr, read_dbx_symtab, start_psymtab)
	(dbx_end_psymtab, read_ofile_symtab, process_one_symbol):
	* defs.h (command_line_input, print_address_symbolic)
	(deprecated_readline_begin_hook): Constify.
	* dwarf2read.c (anonymous_struct_prefix, dwarf_bool_name):
	Constify.
	* event-top.c (handle_line_of_input): Constify and add cast.
	* exceptions.c (catch_errors): Constify.
	* exceptions.h (catch_errors): Constify.
	* expprint.c (print_subexp_standard, op_string, op_name)
	(op_name_standard, dump_raw_expression, dump_raw_expression):
	* expression.h (op_name, op_string, dump_raw_expression):
	Constify.
	* f-exp.y (yyerror): Constify.
	(struct token::oper): Constify.
	(struct f77_boolean_val::name): Constify.
	* f-lang.c (f_word_break_characters): Constify.
	* f-lang.h (f_yyerror): Constify.
	* fork-child.c (fork_inferior): Add cast.
	* frv-tdep.c (struct gdbarch_tdep::register_names): Constify.
	(new_variant): Constify.
	* gdbarch.sh (pstring_ptr, pstring_list): Constify.
	* gdbarch.c: Regenerate.
	* gdbcore.h (set_gnutarget): Constify.
	* go-exp.y (yyerror): Constify.
	(token::oper): Constify.
	* go-lang.h (go_yyerror): Constify.
	* go32-nat.c (go32_sysinfo): Constify.
	* guile/scm-breakpoint.c (gdbscm_breakpoint_expression): Constify.
	* guile/scm-cmd.c (cmdscm_function): Constify.
	* guile/scm-param.c (pascm_param_value): Constify.
	* h8300-tdep.c (h8300_register_name, h8300s_register_name)
	(h8300sx_register_name): Constify.
	* hppa-tdep.c (hppa32_register_name, hppa64_register_name):
	Constify.
	* ia64-tdep.c (ia64_register_names): Constify.
	* infcmd.c (construct_inferior_arguments): Constify.
	(path_command, attach_post_wait): Constify.
	* language.c (show_range_command, show_case_command)
	(unk_lang_error): Constify.
	* language.h (language_defn::la_error)
	(language_defn::la_name_of_this): Constify.
	* linespec.c (decode_line_2): Constify.
	* linux-thread-db.c (thread_db_err_str): Constify.
	* lm32-tdep.c (lm32_register_name): Constify.
	* m2-exp.y (yyerror): Constify.
	* m2-lang.h (m2_yyerror): Constify.
	* m32r-tdep.c (m32r_register_names): Constify and make static.
	* m68hc11-tdep.c (m68hc11_register_names): Constify.
	* m88k-tdep.c (m88k_register_name): Constify.
	* macroexp.c (appendmem): Constify.
	* mdebugread.c (fdr_name, add_data_symbol, parse_type)
	(upgrade_type, parse_external, parse_partial_symbols)
	(mdebug_next_symbol_text, cross_ref, mylookup_symbol, new_psymtab)
	(new_symbol): Constify.
	* memattr.c (mem_info_command): Constify.
	* mep-tdep.c (register_name_from_keyword): Constify.
	* mi/mi-cmd-env.c (mi_cmd_env_path, _initialize_mi_cmd_env):
	Constify.
	* mi/mi-cmd-stack.c (list_args_or_locals): Constify.
	* mi/mi-cmd-var.c (mi_cmd_var_show_attributes): Constify.
	* mi/mi-main.c (captured_mi_execute_command): Constify and add
	cast.
	(mi_execute_async_cli_command): Constify.
	* mips-tdep.c (mips_register_name): Constify.
	* mn10300-tdep.c (register_name, mn10300_generic_register_name)
	(am33_register_name, am33_2_register_name)
	* moxie-tdep.c (moxie_register_names): Constify.
	* nat/linux-osdata.c (osdata_type): Constify fields.
	* nto-tdep.c (nto_parse_redirection): Constify.
	* objc-lang.c (lookup_struct_typedef, lookup_objc_class)
	(lookup_child_selector): Constify.
	(objc_methcall::name): Constify.
	* objc-lang.h (lookup_objc_class, lookup_child_selector)
	(lookup_struct_typedef): Constify.
	* objfiles.c (pc_in_section): Constify.
	* objfiles.h (pc_in_section): Constify.
	* p-exp.y (struct token::oper): Constify.
	(yyerror): Constify.
	* p-lang.h (pascal_yyerror): Constify.
	* parser-defs.h (op_name_standard): Constify.
	(op_print::string): Constify.
	(exp_descriptor::op_name): Constify.
	* printcmd.c (print_address_symbolic): Constify.
	* psymtab.c (print_partial_symbols): Constify.
	* python/py-breakpoint.c (stop_func): Constify.
	(bppy_get_expression): Constify.
	* python/py-cmd.c (cmdpy_completer::name): Constify.
	(cmdpy_function): Constify.
	* python/py-event.c (evpy_add_attribute)
	(gdbpy_initialize_event_generic): Constify.
	* python/py-event.h (evpy_add_attribute)
	(gdbpy_initialize_event_generic): Constify.
	* python/py-evts.c (add_new_registry): Constify.
	* python/py-finishbreakpoint.c (outofscope_func): Constify.
	* python/py-framefilter.c (get_py_iter_from_func): Constify.
	* python/py-inferior.c (get_buffer): Add cast.
	* python/py-param.c (parm_constant::name): Constify.
	* python/py-unwind.c (fprint_frame_id): Constify.
	* python/python.c (gdbpy_parameter_value): Constify.
	* remote-fileio.c (remote_fio_func_map): Make 'name' const.
	* remote.c (memory_packet_config::name): Constify.
	(show_packet_config_cmd, remote_write_bytes)
	(remote_buffer_add_string):
	* reverse.c (exec_reverse_once): Constify.
	* rs6000-tdep.c (variant::name, variant::description): Constify.
	* rust-exp.y (rustyyerror): Constify.
	* rust-lang.c (rust_op_name): Constify.
	* rust-lang.h (rustyyerror): Constify.
	* serial.h (serial_ops::name): Constify.
	* sh-tdep.c (sh_sh_register_name, sh_sh3_register_name)
	(sh_sh3e_register_name, sh_sh2e_register_name)
	(sh_sh2a_register_name, sh_sh2a_nofpu_register_name)
	(sh_sh_dsp_register_name, sh_sh3_dsp_register_name)
	(sh_sh4_register_name, sh_sh4_nofpu_register_name)
	(sh_sh4al_dsp_register_name): Constify.
	* sh64-tdep.c (sh64_register_name): Constify.
	* solib-darwin.c (lookup_symbol_from_bfd): Constify.
	* spu-tdep.c (spu_register_name, info_spu_dma_cmdlist): Constify.
	* stabsread.c (patch_block_stabs, read_type_number)
	(ref_map::stabs, ref_add, process_reference)
	(symbol_reference_defined, define_symbol, define_symbol)
	(error_type, read_type, read_member_functions, read_cpp_abbrev)
	(read_one_struct_field, read_struct_fields, read_baseclasses)
	(read_tilde_fields, read_struct_type, read_array_type)
	(read_enum_type, read_sun_builtin_type, read_sun_floating_type)
	(read_huge_number, read_range_type, read_args, common_block_start)
	(find_name_end): Constify.
	* stabsread.h (common_block_start, define_symbol)
	(process_one_symbol, symbol_reference_defined, ref_add):
	* symfile.c (get_section_index, add_symbol_file_command):
	* symfile.h (get_section_index): Constify.
	* target-descriptions.c (tdesc_type::name): Constify.
	(tdesc_free_type): Add cast.
	* target.c (find_default_run_target):
	(add_deprecated_target_alias, find_default_run_target)
	(target_announce_detach): Constify.
	(do_option): Constify.
	* target.h (add_deprecated_target_alias): Constify.
	* thread.c (print_thread_info_1): Constify.
	* top.c (deprecated_readline_begin_hook, command_line_input):
	Constify.
	(init_main): Add casts.
	* top.h (handle_line_of_input): Constify.
	* tracefile-tfile.c (tfile_write_uploaded_tsv): Constify.
	* tracepoint.c (tvariables_info_1, trace_status_mi): Constify.
	(tfind_command): Rename to ...
	(tfind_command_1): ... this and constify.
	(tfind_command): New function.
	(tfind_end_command, tfind_start_command): Adjust.
	(encode_source_string): Constify.
	* tracepoint.h (encode_source_string): Constify.
	* tui/tui-data.c (tui_partial_win_by_name): Constify.
	* tui/tui-data.h (tui_partial_win_by_name): Constify.
	* tui/tui-source.c (tui_set_source_content_nil): Constify.
	* tui/tui-source.h (tui_set_source_content_nil): Constify.
	* tui/tui-win.c (parse_scrolling_args): Constify.
	* tui/tui-windata.c (tui_erase_data_content): Constify.
	* tui/tui-windata.h (tui_erase_data_content): Constify.
	* tui/tui-winsource.c (tui_erase_source_content): Constify.
	* tui/tui.c (tui_enable): Add cast.
	* utils.c (defaulted_query): Constify.
	(init_page_info): Add cast.
	(puts_debug, subset_compare): Constify.
	* utils.h (subset_compare): Constify.
	* varobj.c (varobj_format_string): Constify.
	* varobj.h (varobj_format_string): Constify.
	* vax-tdep.c (vax_register_name): Constify.
	* windows-nat.c (windows_detach): Constify.
	* xcoffread.c (process_linenos, xcoff_next_symbol_text): Constify.
	* xml-support.c (gdb_xml_end_element): Constify.
	* xml-tdesc.c (tdesc_start_reg): Constify.
	* xstormy16-tdep.c (xstormy16_register_name): Constify.
	* xtensa-tdep.c (xtensa_find_register_by_name): Constify.
	* xtensa-tdep.h (xtensa_register_t::name): Constify.

gdb/gdbserver/ChangeLog:
2017-04-05  Pedro Alves  <palves@redhat.com>

	* gdbreplay.c (sync_error): Constify.
	* linux-x86-low.c (push_opcode): Constify.
2017-04-05 19:21:37 +01:00
Michael Sturm 1f85ef5042 Sync up x86-gcc-cpuid.h with cpuid.h from gcc-6 branch.
Pedro suggested a separate patch synching with GCCs cpuid.h
instead of just adding new bits for PKU feature.

 gdb/Changelog:
     2016-11-14  Michael Sturm  <michael.sturm@intel.com>

          * nat/x86-gcc-cpuid.h: Replace with copy of cpuid.h
            from gcc-6 branch.

Change-Id: I16f8f7f2d0aa7c2e815701d15ed831a6c6b33d21
Signed-off-by: Michael Sturm <michael.sturm@intel.com>
2017-02-17 11:43:39 +01:00
Joel Brobecker 2132fe8503 fix gdbserver build in nat/linux-ptrace.c on arm-android
The following change replaced an include of gregset.h by
an include of <sys/procfs.h>:

    commit 39b2247157
    Date:   Thu Aug 11 12:01:22 2016 +0100
    Subject: Fix fallout from gdb/20413's fix
             (x32: linux_ptrace_test_ret_to_nx: Cannot PTRACE_PEEKUSER)

Unfortunately, this broke gdbserver on Android, because that file
does not exist on this platform.  This patch fixes the issue by
conditionalizing its include with HAVE_SYS_PROCFS_H (which we check
both in gdb/configure and gdbserver/configure).

gdb/ChangeLog:

        * nat/linux-ptrace.c: Only include <sys/procfs.h> if
        HAVE_SYS_PROCFS_H is defined.

Tested by rebuilding gdbserver on arm-android and GNU/Linux.
2017-01-20 03:47:16 -05:00
Yao Qi 1ca8f924a4 Include signal.h in nat/amd64-linux-siginfo.h
$ make check-headers CHECK_HEADERS="nat/amd64-linux-siginfo.h"
....
../../binutils-gdb/gdb/nat/amd64-linux-siginfo.h:52:39: error: 'siginfo_t' was not declared in this scope
 int amd64_linux_siginfo_fixup_common (siginfo_t *native, gdb_byte *inf,
                                       ^
gdb:

2017-01-06  Yao Qi  <yao.qi@linaro.org>

	* nat/amd64-linux-siginfo.h: Include signal.h.
2017-01-06 14:33:01 +00:00
Yao Qi bc3008c48f Include break-common.h in nat/aarch64-linux-hw-point.h
$ make check-headers CHECK_HEADERS="nat/aarch64-linux-hw-point.h"
...
../../binutils-gdb/gdb/nat/aarch64-linux-hw-point.h:169:37: error: use of enum 'target_hw_bp_type' without previous declaration
 int aarch64_handle_breakpoint (enum target_hw_bp_type type, CORE_ADDR addr,
                                     ^
gdb:

2017-01-06  Yao Qi  <yao.qi@linaro.org>

	* nat/aarch64-linux-hw-point.h: Include break-common.h.
2017-01-06 14:33:01 +00:00
Joel Brobecker 61baf725ec update copyright year range in GDB files
This applies the second part of GDB's End of Year Procedure, which
updates the copyright year range in all of GDB's files.

gdb/ChangeLog:

        Update copyright year range in all GDB files.
2017-01-01 10:52:34 +04:00
Markus Metzger db58b3735f btrace: read entire aux buffer
The data_head of a perf event data buffer grows indefinitely.  Users are
expected to compute data_head % data_size to find the location inside the perf
event data buffer.

The aux_head of a perf event aux buffer wraps around and always stays within the
perf event aux buffer.

Well, at least that's the behaviour for BTS and PT - where BTS uses the data
buffer and PT the aux buffer.

GDB does not read beyond data_head or aux_head.  This is OK for BTS but wrong
for PT.  It causes only a portion of the trace to be considered by GDB.  In the
extreme case, the buffer may appear (almost) empty.

Thanks to Tim Wiederhake  <tim.wiederhake@intel.com> for reporting the anomaly.

Change it to read the entire aux buffer for PT.  The buffer is initially zero so
any extra zeroes we read before aux_head wraps around the first time will be
ignored when searching for the first PSB packet in order to synchronize onto the
trace stream.

gdb/
	* nat/linux-btrace.c (perf_event_read): Allow data_head < size.
	* nat/linux-btrace.c (perf_event_read_all): Do not adjust size.

Change-Id: If4f8049a2080a5f16f336309450b32a3eb1e3ec9
2016-11-14 10:15:42 +01:00
Markus Metzger afb1110bfa btrace: remove leftover comment
Remove a leftover comment on a function that was removed with commit
0568462bbf.
2016-10-14 09:31:20 +02:00
Yao Qi 97e64e5ab1 Replace sprintf with xsnprintf in nat/linux-osdata.c
I see the following build warning when I build GDB with GCC trunk.

../../binutils-gdb/gdb/nat/linux-osdata.c: In function ‘LONGEST linux_xfer_osdata_fds(gdb_byte*, ULONGEST, ULONGEST)’:
../../binutils-gdb/gdb/nat/linux-osdata.c:767:1: error: ‘%s’ directive writing between 0 and 255 bytes into a region of size 11 [-Werror=format-length=]
 linux_xfer_osdata_fds (gdb_byte *readbuf,
 ^~~~~~~~~~~~~~~~~~~~~
../../binutils-gdb/gdb/nat/linux-osdata.c:800:51: note: format output between 7 and 262 bytes into a destination of size 17
        sprintf (procentry, "/proc/%s", dp->d_name);
                                                   ^
../../binutils-gdb/gdb/nat/linux-osdata.c: In function ‘LONGEST linux_xfer_osdata_threads(gdb_byte*, ULONGEST, ULONGEST)’:
../../binutils-gdb/gdb/nat/linux-osdata.c:555:1: error: ‘%s’ directive writing between 0 and 255 bytes into a region of size 11 [-Werror=format-length=]
 linux_xfer_osdata_threads (gdb_byte *readbuf,
 ^~~~~~~~~~~~~~~~~~~~~~~~~
../../binutils-gdb/gdb/nat/linux-osdata.c:588:51: note: format output between 7 and 262 bytes into a destination of size 17
        sprintf (procentry, "/proc/%s", dp->d_name);
                                                   ^
cc1plus: all warnings being treated as errors

The warning is a false positive, but we can workaround it by replacing
sprintf with xsnprintf.  On the other hand, it is always preferred to
use xsnprintf.

gdb:

2016-09-23  Yao Qi  <yao.qi@linaro.org>

	* nat/linux-osdata.c (linux_xfer_osdata_threads): Replace
	sprintf with xsnprintf.
	(linux_xfer_osdata_fds): Likewise.
2016-09-23 17:27:26 +01:00
Andreas Arnez 0e00e962c5 linux-nat: Add function lwp_is_stepping
Add the function lwp_is_stepping which indicates whether the given LWP
is currently single-stepping.  This is a common interface, usable from
native GDB as well as from gdbserver.

gdb/gdbserver/ChangeLog:

	* linux-low.c (lwp_is_stepping): New function.

gdb/ChangeLog:

	* nat/linux-nat.h (lwp_is_stepping): New declaration.
	* linux-nat.c (lwp_is_stepping): New function.
2016-09-16 19:25:55 +02:00
Adhemerval Zanella 754653a7c0 Sync proc_service definition with GLIBC
GLIBC BZ#20311 [1] proc_service.h install patch also remove 'const'
attributes from ps_get_thread_area and comment #15 discuss why to remove
the const attribute (basically since it a callback with the struct
ps_prochandle owned by the client it should be able to modify it if
it the case).

On default build this is not the issue and current g++ does not trigger
any issue with this mismatch declaration.  However, on some bootstrap
build configuration where gdbserver is build with gcc instead this
triggers:

error: conflicting types for 'ps_get_thread_area'

This patch fixes it by syncing the declaration with GLIBC.

[1] https://sourceware.org/bugzilla/show_bug.cgi?id=20311

gdb/ChangeLog:

2016-08-25  Adhemerval Zanella  <adhemerval.zanella@linaro.org>

	* aarch64-linux-nat.c (ps_get_thread_area): Remove const from
	struct ps_prochandle.
	* amd64-linux-nat.c (ps_get_thread_area): Likewise.
	* arm-linux-nat.c (ps_get_thread_area): Likewise.
	* gdb_proc_service.h (ps_get_thread_area): Likewise.
	* i386-linux-nat.c (ps_get_thread_area): Likewise.
	* m68klinux-nat.c (ps_get_thread_area): Likewise.
	* mips-linux-nat.c (ps_get_thread_area): Likewise.
	* nat/aarch64-linux.c (aarch64_ps_get_thread_area): Likewise.
	* nat/aarch64-linux.h (aarch64_ps_get_thread_area): Likewise.
	* xtensa-linux-nat.c (ps_get_thread_area): Likewise.

gdb/gdbserver/ChangeLog:

2016-08-25  Adhemerval Zanella  <adhemerval.zanella@linaro.org>

	PR server/20491
	* gdb_proc_service.h (ps_get_thread_area): Remove const from struct
	ps_prochandle.
	* linux-aarch64-low.c (ps_get_thread_area): Likewise.
	* linux-arm-low.c (ps_get_thread_area): Likewise.
	* linux-crisv32-low.c (ps_get_thread_area): Likewise.
	* linux-m68k-low.c (ps_get_thread_area): Likewise.
	* linux-mips-low.c (ps_get_thread_area): Likewise.
	* linux-nios2-low.c (ps_get_thread_area): Likewise.
	* linux-tic6x-low.c (ps_get_thread_area): Likewise.
	* linux-x86-low.c (ps_get_thread_area): Likewise.
	* linux-xtensa-low.c (ps_get_thread_area): Likewise.
2016-08-25 08:42:03 +01:00
Pedro Alves 39b2247157 Fix fallout from gdb/20413's fix (x32: linux_ptrace_test_ret_to_nx: Cannot PTRACE_PEEKUSER)
Fixes, on NIOS GNU/Linux:

  In file included from
  /scratch/mbilal/nois-lite/src/gdb-trunk/gdb/gdbserver/../nat/linux-ptrace.c:26:0:
  /scratch/mbilal/nois-lite/src/gdb-trunk/gdb/gdbserver/../gregset.h:27:23:
  error: unknown type name 'gregset_t'
   #define GDB_GREGSET_T gregset_t
			 ^

Fix this by including sys/procfs.h directly.  We shouldn't really be
including a gdb-only header in a gdb/nat/ file, anyway.  Whoops.

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

	PR gdb/20413
	* nat/linux-ptrace.c: Include <sys/procfs.h> instead of
	"gregset.h".
2016-08-11 12:01:22 +01:00
Pedro Alves 40c31709c6 Fix PR gdb/20413 - x32: linux_ptrace_test_ret_to_nx: Cannot PTRACE_PEEKUSER
An x32 gdb always issues this warning:

 (gdb) start
 Temporary breakpoint 1 at 0x4043e9: file foo.c, line 25.
 Starting program: a.out
 warning: linux_ptrace_test_ret_to_nx: Cannot PTRACE_PEEKUSER: Input/output error

 Temporary breakpoint 1, main (argc=1, argv=0xffffd544) at foo.c:25
 25      {
 (gdb)

As described in Linux commit 55283e253771 (x32: Add ptrace for x32):

    [...] PTRACE_PEEKUSR and PTRACE_POKEUSR are only allowed to access
    segment and debug registers. [...]

The fix is to use PTRACE_GETREGS instead.

gdb/ChangeLog:
2016-07-26  Pedro Alves  <palves@redhat.com>

	* nat/linux-ptrace.c: Include "gregset.h".
	(linux_ptrace_test_ret_to_nx): Use PTRACE_GETREGS instead of
	PTRACE_PEEKUSER.
2016-07-26 19:38:13 +01:00
Pedro Alves 9cf12d57c5 Fix PR gdb/20287 - x32 and "gdb_static_assert (sizeof (nat_siginfo_t) == sizeof (siginfo_t))"
Building an x32 gdb trips on a static assertion:

  In file included from .../src/gdb/common/common-defs.h:71:0,
		   from .../src/gdb/nat/amd64-linux-siginfo.c:21:
  .../src/gdb/common/gdb_assert.h:26:66: error: size of array ‘never_defined_just_used_for_checking’ is negative
     extern int never_defined_just_used_for_checking[(expr) ? 1 : -1]
								    ^
  .../src/gdb/nat/amd64-linux-siginfo.c:113:1: note: in expansion of macro ‘gdb_static_assert’
   gdb_static_assert (sizeof (nat_siginfo_t) == sizeof (siginfo_t));
   ^

The problem is that the way nat_siginfo_t is defined, it can only
match the host's siginfo_t object when gdb is built as a 64-bit
program.

Several bits of nat_siginfo_t are off:

- nat_siginfo_t's _pad field's definition is:

   int _pad[((128 / sizeof (int)) - 4)];

  while /usr/include/bits/siginfo.h has:

   # define __SI_MAX_SIZE     128
   # if __WORDSIZE == 64
   #  define __SI_PAD_SIZE     ((__SI_MAX_SIZE / sizeof (int)) - 4)
   # else
   #  define __SI_PAD_SIZE     ((__SI_MAX_SIZE / sizeof (int)) - 3)
   # endif

  and __WORDSIZE == 32 for x32.  This is what causes the size of
  nat_siginfo_t to be wrong and the assertion to fail.

- the nat_clock_t type is incorrect for 64-bit.  We have this:

   /* For native 64-bit, clock_t in _sigchld is 64bit aligned at 4 bytes.  */
   typedef long __attribute__ ((__aligned__ (4))) nat_clock_t;

  however, /usr/include/bits/siginfo.h has:

   # if defined __x86_64__ && __WORDSIZE == 32
   /* si_utime and si_stime must be 4 byte aligned for x32 to match the
      kernel.  We align siginfo_t to 8 bytes so that si_utime and si_stime
      are actually aligned to 8 bytes since their offsets are multiple of
      8 bytes.  */
   typedef __clock_t __attribute__ ((__aligned__ (4))) __sigchld_clock_t;
   #  define __SI_ALIGNMENT __attribute__ ((__aligned__ (8)))
   # else
   typedef __clock_t __sigchld_clock_t;
   #  define __SI_ALIGNMENT
   # endif

  So we're currently forcing 4-byte alignment on clock_t, when it
  should only be so for x32, not 64-bit.

The fix:

 - Leaves nat_siginfo_t strictly for the 64-bit ABI.

 - Adds a new typedef for the siginfo type that ptrace uses
   (ptrace_siginfo_t).  An x32 gdb always gets/sets an x32 siginfo_t
   type with PTRACE_GETSIGINFO/PTRACE_SETSIGINFO.

 - Uses this new ptrace_siginfo_t type instead of nat_siginfo_t as the
   intermediate conversion type.

gdb/ChangeLog:
2016-07-26  Pedro Alves  <palves@redhat.com>

	* amd64-linux-nat.c (amd64_linux_siginfo_fixup): Rename 'native'
	parameter to 'ptrace'.
	* nat/amd64-linux-siginfo.c (GDB_SI_SIZE): New define.
	(nat_uptr_t): New an unsigned long.
	(nat_clock_t): Remove attribute __aligned__.
	(struct nat_timeval): Delete.
	(nat_siginfo_t): Remove attribute __aligned__.
	(ptrace_siginfo_t): Define.
	(compat_siginfo_from_siginfo, siginfo_from_compat_siginfo)
	(compat_x32_siginfo_from_siginfo)
	(siginfo_from_compat_x32_siginfo): Make 'from' parameter const.
	Convert through a ptrace_siginfo_t instead of a nat_siginfo_t.
	Remove casts.
	(amd64_linux_siginfo_fixup_common): Rename 'native' parameter to
	'ptrace'.  Remove static assertions.
	(top level): New static assertions.

gdb/gdbserver/ChangeLog:
2016-07-26  Pedro Alves  <palves@redhat.com>

	* linux-x86-low.c (x86_siginfo_fixup): Rename 'native' parameter
	to 'ptrace'.
2016-07-26 19:35:40 +01:00
Pedro Alves 0e1a6a5169 linux-procfs: Handle lowercase "t (tracing stop)" state
Since Linux 2.6.33, /proc/PID/status shows "t (tracing stop)", with
lowercase 't'.  Because GDB is only expecting "T (tracing stop)", GDB
can incorrectly suppress errors in check_ptrace_stopped_lwp_gone:

 1578          if (!check_ptrace_stopped_lwp_gone (lp))
 1579            throw_exception (ex);

Ref: https://sourceware.org/ml/gdb-patches/2016-06/msg00072.html

2016-07-25  Pedro Alves  <palves@redhat.com>
	    Jan Kratochvil  <jan.kratochvil@redhat.com>

	* nat/linux-procfs.c (parse_proc_status_state): Handle lowercase
	't'.
2016-07-25 12:58:38 +01:00
Pedro Alves d617208bb0 linux-procfs: Introduce enum proc_state
Parse the process's /proc/PID/status state into an enum instead of the
current scheme of passing state strings around.

gdb/ChangeLog:
2016-07-25  Pedro Alves  <palves@redhat.com>

	* nat/linux-procfs.c (enum proc_state): New enum.
	(parse_proc_status_state): New function.
	(linux_proc_pid_get_state): Replace output string buffer parameter
	with an output proc_state parameter.  Use parse_proc_status_state.
	(linux_proc_pid_is_gone): Adjust to use proc_state values.
	(linux_proc_pid_has_state): Change type of 'state' parameter; now
	an enum proc_state.  Adjust to linux_proc_pid_get_state interface
	change.
	(linux_proc_pid_is_stopped)
	(linux_proc_pid_is_trace_stopped_nowarn)
	(linux_proc_pid_is_zombie_maybe_warn): Adjust to
	linux_proc_pid_get_state interface change.
2016-07-25 12:42:17 +01:00
Andrew Pinski 49ecef2a7d Fix ARMv8.1/v8.2 for hw watchpoint and breakpoint
The problem here is ARMv8.1 (and ARMv8.2) define a
different debug version than ARMv8 (7 and 8 respectively).
This fixes hw watchpoints and breakpoints by checking
for those debug versions too.

Committed as obvious after a test on aarch64-linux-gnu
(on a ThunderX machine which has ARMv8.1 support enabled).

ChangeLog:
	* nat/aarch64-linux-hw-point.c
	(aarch64_linux_get_debug_reg_capacity): Handle
	ARMv8.1 and ARMv8.2 debug versions.
	* nat/aarch64-linux-hw-point.h
	(AARCH64_DEBUG_ARCH_V8_1): New define.
	(AARCH64_DEBUG_ARCH_V8_2): New define.

Signed-off-by: Andrew Pinski <apinski@cavium.com>
2016-07-23 10:10:32 -07:00
Gary Benson d0571b9934 Remove unused libthread_db td_thr_validate reference
Native GDB looks up the function td_thr_validate from libthread_db.so
on Linux, but the value is never used.  This commit removes this dead
code.

gdb/ChangeLog:

	* nat/gdb_thread_db.h (td_thr_validate_ftype): Remove typedef.
	* linux-thread-db.c (struct thread_db_info) <td_thr_validate_p>:
	Remove field.
	(try_thread_db_load_1): Remove td_thr_validate initialization.
2016-05-23 13:26:47 +01:00
Pedro Alves 77770d8321 MIPS/Linux: Also recognize TRAP_BRKPT and TRAP_HWBKPT
This makes the MIPS Linux backends recognize TRAP_BRKPT and
TRAP_HWBKPT in siginfo.si_code in addition to SI_KERNEL, since Linux
4.6 now reports the finer-grained si_code values too.

Refs:
 https://sourceware.org/ml/gdb-patches/2016-02/msg00756.html
 https://sourceware.org/ml/gdb-patches/2016-04/msg00090.html

On kernels that report SI_KERNEL (<= 4.5), we'll enter the "ambiguous"
path of save_stop_reason:

	  if (GDB_ARCH_IS_TRAP_BRKPT (siginfo.si_code)
	      && GDB_ARCH_IS_TRAP_HWBKPT (siginfo.si_code))
	    {
	      /* The si_code is ambiguous on this arch -- check debug
		 registers.  */
	      if (!check_stopped_by_watchpoint (lp))
		lp->stop_reason = TARGET_STOPPED_BY_SW_BREAKPOINT;
	    }

while on kernels that report the finer-grained si_code values (>= 4.6),
we'll enter the corresponding branches:

	  else if (GDB_ARCH_IS_TRAP_BRKPT (siginfo.si_code))
	    {
	    }
	  else if (GDB_ARCH_IS_TRAP_HWBKPT (siginfo.si_code))
	    {
	      ...

gdb/ChangeLog:
2016-04-15  Pedro Alves  <palves@redhat.com>

	* nat/linux-ptrace.h [__mips__] (GDB_ARCH_IS_TRAP_BRKPT): Also
	accept TRAP_BRKPT.
	 [__mips__] (GDB_ARCH_IS_TRAP_HWBKPT): Also accept TRAP_HWBKPT.
2016-04-15 23:52:00 +01:00
Pedro Alves e7ad2f145c Handle MIPS Linux SIGTRAP siginfo.si_code values
This unbreaks pending/delayed breakpoints handling, as well as
hardware watchpoints, on MIPS.

Ref: https://sourceware.org/ml/gdb-patches/2016-02/msg00681.html

The MIPS kernel reports SI_KERNEL for all kernel generated traps,
instead of TRAP_BRKPT / TRAP_HWBKPT, but GDB isn't aware of this.

Basically, this commit:

- Folds watchpoints logic into check_stopped_by_breakpoint, and
  renames it to save_stop_reason.

- Adds GDB_ARCH_IS_TRAP_HWBKPT.

- Makes MIPS set both GDB_ARCH_IS_TRAP_BRPT and
  GDB_ARCH_IS_TRAP_HWBKPT to SI_KERNEL.  In save_stop_reason, we
  handle the case of the same si_code returning true for both
  TRAP_BRPT and TRAP_HWBKPT by looking at what the debug registers
  say.

Tested on x86-64 Fedora 20, native and gdbserver.

gdb/ChangeLog:
2016-02-24  Pedro Alves  <palves@redhat.com>

	* linux-nat.c (save_sigtrap) Delete.
	(stop_wait_callback): Call save_stop_reason instead of
	save_sigtrap.
	(check_stopped_by_breakpoint): Rename to ...
	(save_stop_reason): ... this.  Bits of save_sigtrap folded here.
	Use GDB_ARCH_IS_TRAP_HWBKPT and handle ambiguous
	GDB_ARCH_IS_TRAP_BRKPT / GDB_ARCH_IS_TRAP_HWBKPT.  Factor out
	common code between the USE_SIGTRAP_SIGINFO and
	!USE_SIGTRAP_SIGINFO blocks.
	(linux_nat_filter_event): Call save_stop_reason instead of
	save_sigtrap.
	* nat/linux-ptrace.h: Check for both SI_KERNEL and TRAP_BRKPT
	si_code for MIPS.
	* nat/linux-ptrace.h: Fix "TRAP_HWBPT" typo in x86 table.  Add
	comments on MIPS behavior.
	(GDB_ARCH_IS_TRAP_HWBKPT): Define for all archs.

gdb/gdbserver/ChangeLog:
2016-02-24  Pedro Alves  <palves@redhat.com>

	* linux-low.c (check_stopped_by_breakpoint): Rename to ...
	(save_stop_reason): ... this.  Use GDB_ARCH_IS_TRAP_HWBKPT and
	handle ambiguous GDB_ARCH_IS_TRAP_BRKPT / GDB_ARCH_IS_TRAP_HWBKPT.
	Factor out common code between the USE_SIGTRAP_SIGINFO and
	!USE_SIGTRAP_SIGINFO blocks.
	(linux_low_filter_event): Call save_stop_reason instead of
	check_stopped_by_breakpoint and check_stopped_by_watchpoint.
	Update comments.
	(linux_wait_1): Update comments.
2016-02-24 22:52:06 +00:00
Walfred Tedeschi 3f2f6cb5e8 Adaptation of siginfo fixup for the new bnd fields
New bnds fields will be always present for x86 architecture.
Fixup for compatibility layer 32bits has to be fixed.

It was added the nat_siginfo to serving as intermediate step
between kernel provided siginfo and the fix up routine.

When executing compat_siginfo_from_siginfo or
compat_x32_siginfo_from_siginfo first the buffer read from the kernel are
converted into the nat_signfo for homogenization, then the fields of
nat_siginfo are use to set the compat and compat_x32 siginfo fields.

In other to make this conversion independent of the system where gdb
is compiled the most complete version of the siginfo, named as native
siginfo, is used internally as an intermediate step.

Conversion using nat_siginfo is exemplified below:

compat_siginfo_from_siginfo or compat_x32_siginfo_from_siginfo:

buffer (from the kernel) -> nat_siginfo -> 32 / X32 siginfo
                      (memcpy)       (field by field)

siginfo_from_compat_x32_siginfo or siginfo_from_compat_siginfo:

32 / X32 siginfo -> nat_siginfo -> buffer (to the kernel)
          (field by field)    (memcpy)

Caveat: No support for MPX on x32.

2016-02-02  Walfred Tedeschi  <walfred.tedeschi@intel.com>

gdb/ChangeLog:

	* amd64-linux-siginfo.c (nat_siginfo_t, nat_sigval_t, nat_timeval):
	New types.
	(compat_siginfo): New bound fields added.
	(compat_x32_siginfo): New field added.
	(cpt_si_addr_lsb): New define.
	(compat_siginfo_from_siginfo): Use nat_siginfo.
	(siginfo_from_compat_siginfo): Use nat_siginfo.
	(compat_x32_siginfo_from_siginfo): Likewise.
	(siginfo_from_compat_x32_siginfo): Likewise.
2016-02-02 12:02:16 +01:00
Walfred Tedeschi 93813b37c8 Merge gdb and gdbserver implementations for siginfo
Extract the compatible siginfo handling from amd64-linux-nat.c and
gdbserver/linux-x86-low to a new file nat/amd64-linux-siginfo.c.

2016-02-02  Walfred Tedeschi  <walfred.tedeschi@intel.com>

gdb/ChangeLog:

	* nat/amd64-linux-siginfo.c: New file.
	* nat/amd64-linux-siginfo.h: New file.
	* Makefile.in (HFILES_NO_SRCDIR): Add nat/amd64-linux-siginfo.h.
	(amd64-linux-siginfo.o): New rule.
	* config/i386/linux64.mh (NATDEPFILES): Add amd64-linux-siginfo.o.
	* amd64-linux-nat.c (nat/amd64-linux-siginfo.h): New include.
	(compat_siginfo_from_siginfo, siginfo_from_compat_siginfo)
	(compat_x32_siginfo_from_siginfo, siginfo_from_compat_x32_siginfo)
	(compat_timeval, compat_sigval, compat_x32_clock, cpt_si_pid)
	(cpt_si_uid, cpt_si_timerid, cpt_si_overrun, cpt_si_status)
	(cpt_si_utime, cpt_si_stime, cpt_si_ptr, cpt_si_addr, cpt_si_band)
	(cpt_si_fd, si_timerid, si_overrun): Move to nat/amd64-linux-siginfo.c.

gdb/gdbserver/ChangeLog:

	* configure.srv (x86_64-*-linux*): Add amd64-linux-siginfo.o
	to srv_tgtobj.
	(i[34567]86-*-linux*): Add amd64-linux-siginfo.o
	to srv_tgtobj.
	* linux-x86-low.c [__x86_64__]: Include
	"nat/amd64-linux-siginfo.h".
	(compat_siginfo_from_siginfo, siginfo_from_compat_siginfo)
	(compat_x32_siginfo_from_siginfo, siginfo_from_compat_x32_siginfo)
	(compat_timeval, compat_sigval, compat_x32_clock, cpt_si_pid)
	(cpt_si_uid, cpt_si_timerid, cpt_si_overrun, cpt_si_status)
	(cpt_si_utime, cpt_si_stime, cpt_si_ptr, cpt_si_addr, cpt_si_band)
	(cpt_si_fd, si_timerid, si_overrun): Move from
	nat/amd64-linux-siginfo.c.
	* Makefile.in (amd64-linux-siginfo.o:): New rule.
2016-02-02 11:42:56 +01:00
Gary Benson eb0edac83f Fix gdbserver build failure on targets without fork
This commit fixes nat/linux-namespaces.c to build correctly on
targets without fork.

gdb/ChangeLog:

	* nat/linux-namespaces.c (do_fork): New function.
	(linux_mntns_get_helper): Use the above.

gdb/gdbserver/ChangeLog:

	* configure.ac (AC_FUNC_FORK): New check.
	* config.in: Regenerate.
	* configure: Likewise.
2016-01-18 11:39:42 +00:00
Yao Qi d18547d8b0 Fix invalid conversion from void * to gdb_byte *
This patch fixes the following GDB build error in C++ mode.

gdb/nat/linux-ptrace.c: In function 'int linux_child_function(void*)':
gdb/nat/linux-ptrace.c:323:65: error: invalid conversion from 'void*' to 'gdb_byte* {aka unsigned char*}' [-fpermissive]
   linux_fork_to_function (child_stack, linux_grandchild_function);
                                                                 ^

gdb:

2016-01-12  Yao Qi  <yao.qi@linaro.org>

	* nat/linux-ptrace.c (linux_child_function): Cast child_stack
	to gdb_byte * and pass to linux_fork_to_function.
2016-01-12 16:29:30 +00:00
Yao Qi ba4dd7c4a1 Change function signature passed to clone
I see the following compile error with an old bfin-uclinux gcc to
build GDBserver,

 cc1: warnings being treated as errors
 gdb/gdbserver/../nat/linux-ptrace.c: In function 'linux_fork_to_function':
 gdb/gdbserver/../nat/linux-ptrace.c:283: error: passing argument 1 of 'clone' from incompatible pointer type

in glibc, clone's prototype is like this, and in uClibc, it is the same,

       int clone(int (*fn)(void *), void *child_stack,
                 int flags, void *arg, ...
                 /* pid_t *ptid, struct user_desc *tls, pid_t *ctid */ );

so this patch changes function signature from 'void (*function) (gdb_byte *)'
to 'int (*function) (void *)'.

Note that I find Pedro advised to change argument type from 'void *'
to 'gdb_byte *' during the patch review
https://sourceware.org/ml/gdb-patches/2013-08/msg00611.html  however,
I think fix compile error can justify the change back to 'void *'.

gdb:

2016-01-12  Yao Qi  <yao.qi@linaro.org>

	* nat/linux-ptrace.c (linux_fork_to_function): Change type
	of argument 'function'.
	(linux_grandchild_function): Change return type to 'int'.
	Change child_stack's type to 'void *'.
	(linux_child_function): Likewise.
2016-01-12 15:18:09 +00:00
Pedro Alves bc504a3117 Remove trademark acknowledgements throughout
The GNU Coding Standards say:

  "Please do not include any trademark acknowledgements in GNU
  software packages or documentation."

gdb/ChangeLog:
2016-01-12  Pedro Alves  <palves@redhat.com>

	Remove use of the registered trademark symbol throughout.

gdb/gdbserver/ChangeLog:
2016-01-12  Pedro Alves  <palves@redhat.com>

	Remove use of the registered trademark symbol throughout.

gdb/doc/ChangeLog:
2016-01-12  Pedro Alves  <palves@redhat.com>

	Remove use of the registered trademark symbol throughout.
2016-01-12 15:03:11 +00:00
Joel Brobecker 618f726fcb GDB copyright headers update after running GDB's copyright.py script.
gdb/ChangeLog:

        Update year range in copyright notice of all files.
2016-01-01 08:43:22 +04:00
Pedro Alves 4a6ed09b0f Remove support for LinuxThreads and vendor 2.4 kernels w/ backported NPTL
Since we now rely on PTRACE_EVENT_CLONE being available (added in
Linux 2.5.46), we're relying on NPTL.

This commit removes the support for older LinuxThreads, as well as the
workarounds for vendor 2.4 kernels with NPTL backported.

 - Rely on tkill being available.

 - Assume gdb doesn't get cancel signals.

 - Remove code that checks the LinuxThreads restart and cancel signals
   in the inferior.

 - Assume that __WALL is available.

 - Assume that non-leader threads report WIFEXITED.

 - Thus, no longer need to send signal 0 to check whether threads are
   still alive.

 - Update comments throughout.

Tested on x86_64 Fedora 20, native and gdbserver.

gdb/ChangeLog:

	* configure.ac: Remove tkill checks.
	* configure, config.in: Regenerate.
	* linux-nat.c: Remove HAVE_TKILL_SYSCALL check.  Update top level
	comments.
	(linux_nat_post_attach_wait): Remove 'cloned' parameter.  Use
	__WALL.
	(attach_proc_task_lwp_callback): Don't set the cloned flag.
	(linux_nat_attach): Adjust.
	(kill_lwp): Remove HAVE_TKILL_SYSCALL check.  No longer fall back
	to 'kill'.
	(linux_handle_extended_wait): Use __WALL.  Don't set the cloned
	flag.
	(wait_lwp): Use __WALL.  Update comments.
	(running_callback, stop_and_resume_callback): Delete.
	(linux_nat_filter_event): Don't stop and resume all lwps. Don't
	check if the event LWP has previously exited.
	(check_zombie_leaders): Update comments.
	(linux_nat_wait_1): Use __WALL.
	(kill_wait_callback): Don't handle clone processes separately.
	Use __WALL instead.
	(linux_thread_alive): Delete.
	(linux_nat_thread_alive): Return true as long as the LWP is in the
	LWP list.
	(linux_nat_update_thread_list): Assume the kernel supports
	PTRACE_EVENT_CLONE.
	(get_signo): Delete.
	(lin_thread_get_thread_signals): Remove LinuxThreads references.
	No longer check __pthread_sig_restart / __pthread_sig_cancel in
	the inferior.
	* linux-nat.h (struct lwp_info) <cloned>: Delete field.
	* linux-thread-db.c: Update comments.
	(_initialize_thread_db): Remove LinuxThreads references.
	* nat/linux-waitpid.c (my_waitpid): No longer emulate __WALL.
	Pass down flags unmodified.
	* linux-waitpid.h (my_waitpid): Update documentation.

gdb/gdbserver/ChangeLog:

	* linux-low.c (linux_kill_one_lwp): Remove references to
	LinuxThreads.
	(kill_lwp): Remove HAVE_TKILL_SYSCALL check.  No longer fall back
	to 'kill'.
	(linux_init_signals): Delete.
	(initialize_low): Adjust.
	* thread-db.c (thread_db_init): Remove LinuxThreads reference.
2015-12-17 14:20:51 +00:00
Yao Qi 805035d70c [AArch64] Only check breakpoint alignment on inserting
This patch fixes the GDB internal error on AArch64 when running
watchpoint-fork.exp

 top?bt 15
 internal_error (file=file@entry=0x79d558 "../../binutils-gdb/gdb/linux-nat.c", line=line@entry=4866, fmt=0x793b20 "%s: Assertion `%s' failed.")
    at ../../binutils-gdb/gdb/common/errors.c:51
 #1  0x0000000000495bc4 in linux_nat_thread_address_space (t=<optimized out>, ptid=<error reading variable: Cannot access memory at address 0x1302>)
    at ../../binutils-gdb/gdb/linux-nat.c:4866
 #2  0x00000000005db2c8 in delegate_thread_address_space (self=<optimized out>, arg1=<error reading variable: Cannot access memory at address 0x1302>)
    at ../../binutils-gdb/gdb/target-delegates.c:2447
 #3  0x00000000005e8c7c in target_thread_address_space (ptid=<error reading variable: Cannot access memory at address 0x1302>)
    at ../../binutils-gdb/gdb/target.c:2727
 #4  0x000000000054eef8 in get_thread_arch_regcache (ptid=..., gdbarch=0xad51e0) at ../../binutils-gdb/gdb/regcache.c:529
 #5  0x000000000054efcc in get_thread_regcache (ptid=...) at ../../binutils-gdb/gdb/regcache.c:546
 #6  0x000000000054f120 in get_thread_regcache_for_ptid (ptid=...) at ../../binutils-gdb/gdb/regcache.c:560
 #7  0x00000000004a2278 in aarch64_point_is_aligned (is_watchpoint=0, addr=34168, len=2) at ../../binutils-gdb/gdb/nat/aarch64-linux-hw-point.c:122
 #8  0x00000000004a2e68 in aarch64_handle_breakpoint (type=hw_execute, addr=34168, len=2, is_insert=0, state=0xae8880)
    at ../../binutils-gdb/gdb/nat/aarch64-linux-hw-point.c:465
 #9  0x000000000048edf0 in aarch64_linux_remove_hw_breakpoint (self=<optimized out>, gdbarch=<optimized out>, bp_tgt=<optimized out>)
    at ../../binutils-gdb/gdb/aarch64-linux-nat.c:657
 #10 0x00000000005da8dc in delegate_remove_hw_breakpoint (self=<optimized out>, arg1=<optimized out>, arg2=<optimized out>)
    at ../../binutils-gdb/gdb/target-delegates.c:492
 #11 0x0000000000536a24 in bkpt_remove_location (bl=<optimized out>) at ../../binutils-gdb/gdb/breakpoint.c:13065
 #12 0x000000000053351c in remove_breakpoint_1 (bl=0xb3fe70, is=is@entry=mark_inserted) at ../../binutils-gdb/gdb/breakpoint.c:4026
 #13 0x000000000053ccc0 in detach_breakpoints (ptid=...) at ../../binutils-gdb/gdb/breakpoint.c:3930
 #14 0x00000000005a3ac0 in handle_inferior_event_1 (ecs=0x7ffffff048) at ../../binutils-gdb/gdb/infrun.c:5042

After the fork, GDB will physically remove the breakpoints from the child
process (in frame #14), but at that time, GDB doesn't create an inferior
yet for child, but inferior_ptid is set to child's ptid (in frame #13).
In aarch64_point_is_aligned, we'll get the regcache of current_lwp_ptid
to determine if the current process is 32-bit or 64-bit, so the inferior
can't be found, and the internal error is caused.

I don't find a better fix other than not checking alignment on removing
breakpoint.

gdb:

2015-11-27  Yao Qi  <yao.qi@linaro.org>

	* nat/aarch64-linux-hw-point.c (aarch64_dr_state_remove_one_point):
	Don't assert on alignment.
	(aarch64_handle_breakpoint): Only check alignment when IS_INSERT
	is true.
2015-11-27 14:53:32 +00:00
Simon Marchi 79efa585c5 Display names of remote threads
This patch adds support for thread names in the remote protocol, and
updates gdb/gdbserver to use it.  The information is added to the XML
description sent in response to the qXfer:threads:read packet.

gdb/ChangeLog:

	* linux-nat.c (linux_nat_thread_name): Replace implementation by call
	to linux_proc_tid_get_name.
	* nat/linux-procfs.c (linux_proc_tid_get_name): New function,
	implementation inspired by linux_nat_thread_name.
	* nat/linux-procfs.h (linux_proc_tid_get_name): New declaration.
	* remote.c (struct private_thread_info) <name>: New field.
	(free_private_thread_info): Free name field.
	(remote_thread_name): New function.
	(thread_item_t) <name>: New field.
	(clear_threads_listing_context): Free name field.
	(start_thread): Get name xml attribute.
	(thread_attributes): Add "name" attribute.
	(remote_update_thread_list): Copy name field.
	(init_remote_ops): Assign remote_thread_name callback.
	* target.h (target_thread_name): Update comment.
	* NEWS: Mention remote thread name support.

gdb/gdbserver/ChangeLog:

	* linux-low.c (linux_target_ops): Use linux_proc_tid_get_name.
	* server.c (handle_qxfer_threads_worker): Refactor to include thread
	name in reply.
	* target.h (struct target_ops) <thread_name>: New field.
	(target_thread_name): New macro.

gdb/doc/ChangeLog:

	* gdb.texinfo (Thread List Format): Mention thread names.
2015-11-26 10:50:08 -05:00
Simon Marchi bb82e93484 Fix iov_len calculation in aarch64_linux_set_debug_regs
There is this build failure when building in C++:

/home/simark/src/binutils-gdb/gdb/nat/aarch64-linux-hw-point.c: In function ‘void aarch64_linux_set_debug_regs(const aarch64_debug_reg_state*, int, int)’:
/home/simark/src/binutils-gdb/gdb/nat/aarch64-linux-hw-point.c:564:64: error: ‘count’ cannot appear in a constant-expression
   iov.iov_len = (offsetof (struct user_hwdebug_state, dbg_regs[count - 1])
                                                                ^
We can simplify the computation and make g++ happy at the same time by
formulating as:

  size of fixed part + size of variable part

thus...

  size of fixed part + count * size of one variable part element

thus...

  offsetof (struct user_hwdebug_state, dbg_regs) + count * sizeof (regs.dbg_reg[0]);

gdb/ChangeLog:

	* nat/aarch64-linux-hw-point.c (aarch64_linux_set_debug_regs): Change
	form of iov_len computation.
2015-11-19 10:17:46 -05:00
Doug Evans 682b25469e Move __SIGRTMIN.
gdb/ChangeLog:

	* nat/linux-nat.h (__SIGRTMIN): Move here from gdbserver/linux-low.c.

gdb/gdbserver/ChangeLog:

	* linux-low.c (__SIGRTMIN): Move to nat/linux-nat.h.
2015-10-26 13:30:57 -07:00
Simon Marchi 55e5bf59f0 Replace (void *) cast with (gdb_byte *)
Fixes:

/home/simark/src/binutils-gdb/gdb/nat/linux-ptrace.c:207:6: error: invalid conversion from ‘void*’ to ‘gdb_byte* {aka unsigned char*}’ [-fpermissive]
   pc = (void *) (uintptr_t) l;
         ^

gdb/ChangeLog:

	* nat/linux-ptrace.c (linux_ptrace_test_ret_to_nx): Replace
	(void *) cast with (gdb_byte *).
2015-10-24 18:36:26 -04:00
Simon Marchi a55515eecb Add mmap casts in linux-btrace.c
gdb/ChangeLog:

	* linux-btrace.c (linux_enable_pt): Add cast to mmap return.
2015-10-23 19:54:09 -04:00
Yao Qi 8d689ee570 aarch64 multi-arch part 6: HW breakpoint on unaligned address
Nowadays, both aarch64 GDB and linux kernel assumes that address for
setting breakpoint should be 4-byte aligned.  However that is not true
after we support multi-arch, because thumb instruction can be at 2-byte
aligned address.  Patch http://lists.infradead.org/pipermail/linux-arm-kernel/2015-October/375141.html
to linux kernel is to teach kernel to handle 2-byte aligned address for
HW breakpoint, while this patch is to teach aarch64 GDB handle 2-byte
aligned address.

First of all, we call gdbarch_breakpoint_from_pc to get the instruction
length rather than using hard-coded 4.  Secondly, in GDBserver, we set
length back to 2 if it is 3, because GDB encode 3 in it to indicate it
is a 32-bit thumb breakpoint.  Then we relax the address alignment
check from 4-byte aligned to 2-byte aligned.

This patch enables some tests (such as gdb.base/break-idempotent.exp,
gdb.base/cond-eval-mode.exp, gdb.base/watchpoint-reuse-slot.exp,) and
fixes many fails (such as gdb.base/hbreak2.exp) when the program is
compiled in thumb mode on aarch64.

Regression tested on aarch64-linux, both native and gdbserver.  This
is the last patch of multi-arch work.

gdb:

2015-10-15  Yao Qi  <yao.qi@linaro.org>

	* aarch64-linux-nat.c (aarch64_linux_insert_hw_breakpoint):
	Call gdbarch_breakpoint_from_pc to instruction length.
	(aarch64_linux_remove_hw_breakpoint): Likewise.
	* common/common-regcache.h (regcache_register_size): Declare.
	* nat/aarch64-linux-hw-point.c: Include "common-regcache.h".
	(aarch64_point_is_aligned): Set alignment to 2 for breakpoint if
	the process is 32bit, otherwise set alignment to 4.
	(aarch64_handle_breakpoint): Update comments.
	* regcache.c (regcache_register_size): New function.

gdb/gdbserver:

2015-10-15  Yao Qi  <yao.qi@linaro.org>

	* linux-aarch64-low.c (aarch64_insert_point): Set len to 2
	if it is 3.
	(aarch64_remove_point): Likewise.
	* regcache.c (regcache_register_size): New function.
2015-10-15 15:05:10 +01:00
Simon Marchi 224c3ddb89 Add casts to memory allocation related calls
Most allocation functions (if not all) return a void* pointing to the
allocated memory.  In C++, we need to add an explicit cast when
assigning the result to a pointer to another type (which is the case
more often than not).

The content of this patch is taken from Pedro's branch, from commit
"(mostly) auto-generated patch to insert casts needed for C++".  I
validated that the changes make sense and manually reflowed the code to
make it respect the coding style.  I also found multiple places where I
could use XNEW/XNEWVEC/XRESIZEVEC/etc.

Thanks a lot to whoever did that automated script to insert casts, doing
it completely by hand would have taken a ridiculous amount of time.

Only files built on x86 with --enable-targets=all are modified.  This
means that all other -nat.c files are untouched and will have to be
dealt with later by using appropiate compilers.  Or maybe we can try to
build them with a regular g++ just to know where to add casts, I don't
know.

I built-tested this with --enable-targets=all and reg-tested.

Here's the changelog entry, which was not too bad to make despite the
size, thanks to David Malcom's script.  I fixed some bits by hand, but
there might be some wrong parts left (hopefully not).

gdb/ChangeLog:

	* aarch64-linux-tdep.c (aarch64_stap_parse_special_token): Add cast
	to allocation result assignment.
	* ada-exp.y (write_object_renaming): Likewise.
	(write_ambiguous_var): Likewise.
	(ada_nget_field_index): Likewise.
	(write_var_or_type): Likewise.
	* ada-lang.c (ada_decode_symbol): Likewise.
	(ada_value_assign): Likewise.
	(value_pointer): Likewise.
	(cache_symbol): Likewise.
	(add_nonlocal_symbols): Likewise.
	(ada_name_for_lookup): Likewise.
	(symbol_completion_add): Likewise.
	(ada_to_fixed_type_1): Likewise.
	(ada_get_next_arg): Likewise.
	(defns_collected): Likewise.
	* ada-lex.l (processId): Likewise.
	(processString): Likewise.
	* ada-tasks.c (read_known_tasks_array): Likewise.
	(read_known_tasks_list): Likewise.
	* ada-typeprint.c (decoded_type_name): Likewise.
	* addrmap.c (addrmap_mutable_create_fixed): Likewise.
	* amd64-tdep.c (amd64_push_arguments): Likewise.
	(amd64_displaced_step_copy_insn): Likewise.
	(amd64_classify_insn_at): Likewise.
	(amd64_relocate_instruction): Likewise.
	* amd64obsd-tdep.c (amd64obsd_sigtramp_p): Likewise.
	* arch-utils.c (simple_displaced_step_copy_insn): Likewise.
	(initialize_current_architecture): Likewise.
	* arm-linux-tdep.c (arm_stap_parse_special_token): Likewise.
	* arm-symbian-tdep.c (arm_symbian_osabi_sniffer): Likewise.
	* arm-tdep.c (arm_exidx_new_objfile): Likewise.
	(arm_push_dummy_call): Likewise.
	(extend_buffer_earlier): Likewise.
	(arm_adjust_breakpoint_address): Likewise.
	(arm_skip_stub): Likewise.
	* auto-load.c (filename_is_in_pattern): Likewise.
	(maybe_add_script_file): Likewise.
	(maybe_add_script_text): Likewise.
	(auto_load_objfile_script_1): Likewise.
	* auxv.c (ld_so_xfer_auxv): Likewise.
	* ax-general.c (new_agent_expr): Likewise.
	(grow_expr): Likewise.
	(ax_reg_mask): Likewise.
	* bcache.c (bcache_full): Likewise.
	* breakpoint.c (program_breakpoint_here_p): Likewise.
	* btrace.c (parse_xml_raw): Likewise.
	* build-id.c (build_id_to_debug_bfd): Likewise.
	* buildsym.c (end_symtab_with_blockvector): Likewise.
	* c-exp.y (string_exp): Likewise.
	(qualified_name): Likewise.
	(write_destructor_name): Likewise.
	(operator_stoken): Likewise.
	(parse_number): Likewise.
	(scan_macro_expansion): Likewise.
	(yylex): Likewise.
	(c_print_token): Likewise.
	* c-lang.c (c_get_string): Likewise.
	(emit_numeric_character): Likewise.
	* charset.c (wchar_iterate): Likewise.
	* cli/cli-cmds.c (complete_command): Likewise.
	(make_command): Likewise.
	* cli/cli-dump.c (restore_section_callback): Likewise.
	(restore_binary_file): Likewise.
	* cli/cli-interp.c (cli_interpreter_exec): Likewise.
	* cli/cli-script.c (execute_control_command): Likewise.
	* cli/cli-setshow.c (do_set_command): Likewise.
	* coff-pe-read.c (add_pe_forwarded_sym): Likewise.
	(read_pe_exported_syms): Likewise.
	* coffread.c (coff_read_struct_type): Likewise.
	(coff_read_enum_type): Likewise.
	* common/btrace-common.c (btrace_data_append): Likewise.
	* common/buffer.c (buffer_grow): Likewise.
	* common/filestuff.c (gdb_fopen_cloexec): Likewise.
	* common/format.c (parse_format_string): Likewise.
	* common/gdb_vecs.c (delim_string_to_char_ptr_vec_append): Likewise.
	* common/xml-utils.c (xml_escape_text): Likewise.
	* compile/compile-object-load.c (copy_sections): Likewise.
	(compile_object_load): Likewise.
	* compile/compile-object-run.c (compile_object_run): Likewise.
	* completer.c (filename_completer): Likewise.
	* corefile.c (read_memory_typed_address): Likewise.
	(write_memory_unsigned_integer): Likewise.
	(write_memory_signed_integer): Likewise.
	(complete_set_gnutarget): Likewise.
	* corelow.c (get_core_register_section): Likewise.
	* cp-name-parser.y (d_grab): Likewise.
	(allocate_info): Likewise.
	(cp_new_demangle_parse_info): Likewise.
	* cp-namespace.c (cp_scan_for_anonymous_namespaces): Likewise.
	(cp_lookup_symbol_in_namespace): Likewise.
	(lookup_namespace_scope): Likewise.
	(find_symbol_in_baseclass): Likewise.
	(cp_lookup_nested_symbol): Likewise.
	(cp_lookup_transparent_type_loop): Likewise.
	* cp-support.c (copy_string_to_obstack): Likewise.
	(make_symbol_overload_list): Likewise.
	(make_symbol_overload_list_namespace): Likewise.
	(make_symbol_overload_list_adl_namespace): Likewise.
	(first_component_command): Likewise.
	* cp-valprint.c (cp_print_value): Likewise.
	* ctf.c (ctf_xfer_partial): Likewise.
	* d-exp.y (StringExp): Likewise.
	* d-namespace.c (d_lookup_symbol_in_module): Likewise.
	(lookup_module_scope): Likewise.
	(find_symbol_in_baseclass): Likewise.
	(d_lookup_nested_symbol): Likewise.
	* dbxread.c (find_stab_function_addr): Likewise.
	(read_dbx_symtab): Likewise.
	(dbx_end_psymtab): Likewise.
	(cp_set_block_scope): Likewise.
	* dcache.c (dcache_alloc): Likewise.
	* demangle.c (_initialize_demangler): Likewise.
	* dicos-tdep.c (dicos_load_module_p): Likewise.
	* dictionary.c (dict_create_hashed_expandable): Likewise.
	(dict_create_linear_expandable): Likewise.
	(expand_hashtable): Likewise.
	(add_symbol_linear_expandable): Likewise.
	* dwarf2-frame.c (add_cie): Likewise.
	(add_fde): Likewise.
	(dwarf2_build_frame_info): Likewise.
	* dwarf2expr.c (dwarf_expr_grow_stack): Likewise.
	(dwarf_expr_fetch_address): Likewise.
	(add_piece): Likewise.
	(execute_stack_op): Likewise.
	* dwarf2loc.c (chain_candidate): Likewise.
	(dwarf_entry_parameter_to_value): Likewise.
	(read_pieced_value): Likewise.
	(write_pieced_value): Likewise.
	* dwarf2read.c (dwarf2_read_section): Likewise.
	(add_type_unit): Likewise.
	(read_comp_units_from_section): Likewise.
	(fixup_go_packaging): Likewise.
	(dwarf2_compute_name): Likewise.
	(dwarf2_physname): Likewise.
	(create_dwo_unit_in_dwp_v1): Likewise.
	(create_dwo_unit_in_dwp_v2): Likewise.
	(read_func_scope): Likewise.
	(read_call_site_scope): Likewise.
	(dwarf2_attach_fields_to_type): Likewise.
	(process_structure_scope): Likewise.
	(mark_common_block_symbol_computed): Likewise.
	(read_common_block): Likewise.
	(abbrev_table_read_table): Likewise.
	(guess_partial_die_structure_name): Likewise.
	(fixup_partial_die): Likewise.
	(add_file_name): Likewise.
	(dwarf2_const_value_data): Likewise.
	(dwarf2_const_value_attr): Likewise.
	(build_error_marker_type): Likewise.
	(guess_full_die_structure_name): Likewise.
	(anonymous_struct_prefix): Likewise.
	(typename_concat): Likewise.
	(dwarf2_canonicalize_name): Likewise.
	(dwarf2_name): Likewise.
	(write_constant_as_bytes): Likewise.
	(dwarf2_fetch_constant_bytes): Likewise.
	(copy_string): Likewise.
	(parse_macro_definition): Likewise.
	* elfread.c (elf_symfile_segments): Likewise.
	(elf_rel_plt_read): Likewise.
	(elf_gnu_ifunc_resolve_by_cache): Likewise.
	(elf_gnu_ifunc_resolve_by_got): Likewise.
	(elf_read_minimal_symbols): Likewise.
	(elf_gnu_ifunc_record_cache): Likewise.
	* event-top.c (top_level_prompt): Likewise.
	(command_line_handler): Likewise.
	* exec.c (resize_section_table): Likewise.
	* expprint.c (print_subexp_standard): Likewise.
	* fbsd-tdep.c (fbsd_collect_regset_section_cb): Likewise.
	* findcmd.c (parse_find_args): Likewise.
	* findvar.c (address_from_register): Likewise.
	* frame.c (get_prev_frame_always): Likewise.
	* gdb_bfd.c (gdb_bfd_ref): Likewise.
	(get_section_descriptor): Likewise.
	* gdb_obstack.c (obconcat): Likewise.
	(obstack_strdup): Likewise.
	* gdbtypes.c (lookup_function_type_with_arguments): Likewise.
	(create_set_type): Likewise.
	(lookup_unsigned_typename): Likewise.
	(lookup_signed_typename): Likewise.
	(resolve_dynamic_union): Likewise.
	(resolve_dynamic_struct): Likewise.
	(add_dyn_prop): Likewise.
	(copy_dynamic_prop_list): Likewise.
	(arch_flags_type): Likewise.
	(append_composite_type_field_raw): Likewise.
	* gdbtypes.h (INIT_FUNC_SPECIFIC): Likewise.
	* gnu-v3-abi.c (gnuv3_rtti_type): Likewise.
	* go-exp.y (string_exp): Likewise.
	* go-lang.c (go_demangle): Likewise.
	* guile/guile.c (compute_scheme_string): Likewise.
	* guile/scm-cmd.c (gdbscm_parse_command_name): Likewise.
	(gdbscm_canonicalize_command_name): Likewise.
	* guile/scm-ports.c (ioscm_init_stdio_buffers): Likewise.
	(ioscm_init_memory_port): Likewise.
	(ioscm_reinit_memory_port): Likewise.
	* guile/scm-utils.c (gdbscm_gc_xstrdup): Likewise.
	(gdbscm_gc_dup_argv): Likewise.
	* h8300-tdep.c (h8300_push_dummy_call): Likewise.
	* hppa-tdep.c (internalize_unwinds): Likewise.
	(read_unwind_info): Likewise.
	* i386-cygwin-tdep.c (core_process_module_section): Likewise.
	(windows_core_xfer_shared_libraries): Likewise.
	* i386-tdep.c (i386_displaced_step_copy_insn): Likewise.
	(i386_stap_parse_special_token_triplet): Likewise.
	(i386_stap_parse_special_token_three_arg_disp): Likewise.
	* i386obsd-tdep.c (i386obsd_sigtramp_p): Likewise.
	* inf-child.c (inf_child_fileio_readlink): Likewise.
	* inf-ptrace.c (inf_ptrace_fetch_register): Likewise.
	(inf_ptrace_store_register): Likewise.
	* infrun.c (follow_exec): Likewise.
	(displaced_step_prepare_throw): Likewise.
	(save_stop_context): Likewise.
	(save_infcall_suspend_state): Likewise.
	* jit.c (jit_read_descriptor): Likewise.
	(jit_read_code_entry): Likewise.
	(jit_symtab_line_mapping_add_impl): Likewise.
	(finalize_symtab): Likewise.
	(jit_unwind_reg_get_impl): Likewise.
	* jv-exp.y (QualifiedName): Likewise.
	* jv-lang.c (get_java_utf8_name): Likewise.
	(type_from_class): Likewise.
	(java_demangle_type_signature): Likewise.
	(java_class_name_from_physname): Likewise.
	* jv-typeprint.c (java_type_print_base): Likewise.
	* jv-valprint.c (java_value_print): Likewise.
	* language.c (add_language): Likewise.
	* linespec.c (add_sal_to_sals_basic): Likewise.
	(add_sal_to_sals): Likewise.
	(decode_objc): Likewise.
	(find_linespec_symbols): Likewise.
	* linux-fork.c (fork_save_infrun_state): Likewise.
	* linux-nat.c (linux_nat_detach): Likewise.
	(linux_nat_fileio_readlink): Likewise.
	* linux-record.c (record_linux_sockaddr): Likewise.
	(record_linux_msghdr): Likewise.
	(Do): Likewise.
	* linux-tdep.c (linux_core_info_proc_mappings): Likewise.
	(linux_collect_regset_section_cb): Likewise.
	(linux_get_siginfo_data): Likewise.
	* linux-thread-db.c (try_thread_db_load_from_pdir_1): Likewise.
	(try_thread_db_load_from_dir): Likewise.
	(thread_db_load_search): Likewise.
	(info_auto_load_libthread_db): Likewise.
	* m32c-tdep.c (m32c_m16c_address_to_pointer): Likewise.
	(m32c_m16c_pointer_to_address): Likewise.
	* m68hc11-tdep.c (m68hc11_pseudo_register_write): Likewise.
	* m68k-tdep.c (m68k_get_longjmp_target): Likewise.
	* machoread.c (macho_check_dsym): Likewise.
	* macroexp.c (resize_buffer): Likewise.
	(gather_arguments): Likewise.
	(maybe_expand): Likewise.
	* macrotab.c (new_macro_key): Likewise.
	(new_source_file): Likewise.
	(new_macro_definition): Likewise.
	* mdebugread.c (parse_symbol): Likewise.
	(parse_type): Likewise.
	(parse_partial_symbols): Likewise.
	(psymtab_to_symtab_1): Likewise.
	* mem-break.c (default_memory_insert_breakpoint): Likewise.
	* mi/mi-cmd-break.c (mi_argv_to_format): Likewise.
	* mi/mi-main.c (mi_cmd_data_read_memory): Likewise.
	(mi_cmd_data_read_memory_bytes): Likewise.
	(mi_cmd_data_write_memory_bytes): Likewise.
	(mi_cmd_trace_frame_collected): Likewise.
	* mi/mi-parse.c (mi_parse_argv): Likewise.
	(mi_parse): Likewise.
	* minidebug.c (lzma_open): Likewise.
	(lzma_pread): Likewise.
	* mips-tdep.c (mips_read_fp_register_single): Likewise.
	(mips_print_fp_register): Likewise.
	* mipsnbsd-tdep.c (mipsnbsd_get_longjmp_target): Likewise.
	* mipsread.c (read_alphacoff_dynamic_symtab): Likewise.
	* mt-tdep.c (mt_register_name): Likewise.
	(mt_registers_info): Likewise.
	(mt_push_dummy_call): Likewise.
	* namespace.c (add_using_directive): Likewise.
	* nat/linux-btrace.c (perf_event_read): Likewise.
	(linux_enable_bts): Likewise.
	* nat/linux-osdata.c (linux_common_core_of_thread): Likewise.
	* nat/linux-ptrace.c (linux_ptrace_test_ret_to_nx): Likewise.
	* nto-tdep.c (nto_find_and_open_solib): Likewise.
	(nto_parse_redirection): Likewise.
	* objc-lang.c (objc_demangle): Likewise.
	(find_methods): Likewise.
	* objfiles.c (get_objfile_bfd_data): Likewise.
	(set_objfile_main_name): Likewise.
	(allocate_objfile): Likewise.
	(objfile_relocate): Likewise.
	(update_section_map): Likewise.
	* osabi.c (generic_elf_osabi_sniff_abi_tag_sections): Likewise.
	* p-exp.y (exp): Likewise.
	(yylex): Likewise.
	* p-valprint.c (pascal_object_print_value): Likewise.
	* parse.c (initialize_expout): Likewise.
	(mark_completion_tag): Likewise.
	(copy_name): Likewise.
	(parse_float): Likewise.
	(type_stack_reserve): Likewise.
	* ppc-linux-tdep.c (ppc_stap_parse_special_token): Likewise.
	(ppu2spu_prev_register): Likewise.
	* ppc-ravenscar-thread.c (supply_register_at_address): Likewise.
	* printcmd.c (printf_wide_c_string): Likewise.
	(printf_pointer): Likewise.
	* probe.c (parse_probes): Likewise.
	* python/py-cmd.c (gdbpy_parse_command_name): Likewise.
	(cmdpy_init): Likewise.
	* python/py-gdb-readline.c (gdbpy_readline_wrapper): Likewise.
	* python/py-symtab.c (set_sal): Likewise.
	* python/py-unwind.c (pyuw_sniffer): Likewise.
	* python/python.c (python_interactive_command): Likewise.
	(compute_python_string): Likewise.
	* ravenscar-thread.c (get_running_thread_id): Likewise.
	* record-full.c (record_full_exec_insn): Likewise.
	(record_full_core_open_1): Likewise.
	* regcache.c (regcache_raw_read_signed): Likewise.
	(regcache_raw_read_unsigned): Likewise.
	(regcache_cooked_read_signed): Likewise.
	(regcache_cooked_read_unsigned): Likewise.
	* remote-fileio.c (remote_fileio_func_open): Likewise.
	(remote_fileio_func_rename): Likewise.
	(remote_fileio_func_unlink): Likewise.
	(remote_fileio_func_stat): Likewise.
	(remote_fileio_func_system): Likewise.
	* remote-mips.c (mips_xfer_memory): Likewise.
	(mips_load_srec): Likewise.
	(pmon_end_download): Likewise.
	* remote.c (new_remote_state): Likewise.
	(map_regcache_remote_table): Likewise.
	(remote_register_number_and_offset): Likewise.
	(init_remote_state): Likewise.
	(get_memory_packet_size): Likewise.
	(remote_pass_signals): Likewise.
	(remote_program_signals): Likewise.
	(remote_start_remote): Likewise.
	(remote_check_symbols): Likewise.
	(remote_query_supported): Likewise.
	(extended_remote_attach): Likewise.
	(process_g_packet): Likewise.
	(store_registers_using_G): Likewise.
	(putpkt_binary): Likewise.
	(read_frame): Likewise.
	(compare_sections_command): Likewise.
	(remote_hostio_pread): Likewise.
	(remote_hostio_readlink): Likewise.
	(remote_file_put): Likewise.
	(remote_file_get): Likewise.
	(remote_pid_to_exec_file): Likewise.
	(_initialize_remote): Likewise.
	* rs6000-aix-tdep.c (rs6000_aix_ld_info_to_xml): Likewise.
	(rs6000_aix_core_xfer_shared_libraries_aix): Likewise.
	* rs6000-tdep.c (ppc_displaced_step_copy_insn): Likewise.
	(bfd_uses_spe_extensions): Likewise.
	* s390-linux-tdep.c (s390_displaced_step_copy_insn): Likewise.
	* score-tdep.c (score7_malloc_and_get_memblock): Likewise.
	* solib-dsbt.c (decode_loadmap): Likewise.
	(fetch_loadmap): Likewise.
	(scan_dyntag): Likewise.
	(enable_break): Likewise.
	(dsbt_relocate_main_executable): Likewise.
	* solib-frv.c (fetch_loadmap): Likewise.
	(enable_break2): Likewise.
	(frv_relocate_main_executable): Likewise.
	* solib-spu.c (spu_relocate_main_executable): Likewise.
	(spu_bfd_open): Likewise.
	* solib-svr4.c (lm_info_read): Likewise.
	(read_program_header): Likewise.
	(find_program_interpreter): Likewise.
	(scan_dyntag): Likewise.
	(elf_locate_base): Likewise.
	(open_symbol_file_object): Likewise.
	(read_program_headers_from_bfd): Likewise.
	(svr4_relocate_main_executable): Likewise.
	* solib-target.c (solib_target_relocate_section_addresses): Likewise.
	* solib.c (solib_find_1): Likewise.
	(exec_file_find): Likewise.
	(solib_find): Likewise.
	* source.c (openp): Likewise.
	(print_source_lines_base): Likewise.
	(forward_search_command): Likewise.
	* sparc-ravenscar-thread.c (supply_register_at_address): Likewise.
	* spu-tdep.c (spu2ppu_prev_register): Likewise.
	(spu_get_overlay_table): Likewise.
	* stabsread.c (patch_block_stabs): Likewise.
	(define_symbol): Likewise.
	(again:): Likewise.
	(read_member_functions): Likewise.
	(read_one_struct_field): Likewise.
	(read_enum_type): Likewise.
	(common_block_start): Likewise.
	* stack.c (read_frame_arg): Likewise.
	(backtrace_command): Likewise.
	* stap-probe.c (stap_parse_register_operand): Likewise.
	* symfile.c (syms_from_objfile_1): Likewise.
	(find_separate_debug_file): Likewise.
	(load_command): Likewise.
	(load_progress): Likewise.
	(load_section_callback): Likewise.
	(reread_symbols): Likewise.
	(add_filename_language): Likewise.
	(allocate_compunit_symtab): Likewise.
	(read_target_long_array): Likewise.
	(simple_read_overlay_table): Likewise.
	* symtab.c (symbol_set_names): Likewise.
	(resize_symbol_cache): Likewise.
	(rbreak_command): Likewise.
	(completion_list_add_name): Likewise.
	(completion_list_objc_symbol): Likewise.
	(add_filename_to_list): Likewise.
	* target-descriptions.c (maint_print_c_tdesc_cmd): Likewise.
	* target-memory.c (target_write_memory_blocks): Likewise.
	* target.c (target_read_string): Likewise.
	(read_whatever_is_readable): Likewise.
	(target_read_alloc_1): Likewise.
	(simple_search_memory): Likewise.
	(target_fileio_read_alloc_1): Likewise.
	* tilegx-tdep.c (tilegx_push_dummy_call): Likewise.
	* top.c (command_line_input): Likewise.
	* tracefile-tfile.c (tfile_fetch_registers): Likewise.
	* tracefile.c (tracefile_fetch_registers): Likewise.
	* tracepoint.c (add_memrange): Likewise.
	(init_collection_list): Likewise.
	(add_aexpr): Likewise.
	(trace_dump_actions): Likewise.
	(parse_trace_status): Likewise.
	(parse_tracepoint_definition): Likewise.
	(parse_tsv_definition): Likewise.
	(parse_static_tracepoint_marker_definition): Likewise.
	* tui/tui-file.c (tui_sfileopen): Likewise.
	(tui_file_adjust_strbuf): Likewise.
	* tui/tui-io.c (tui_expand_tabs): Likewise.
	* tui/tui-source.c (tui_set_source_content): Likewise.
	* typeprint.c (find_global_typedef): Likewise.
	* ui-file.c (do_ui_file_xstrdup): Likewise.
	(ui_file_obsavestring): Likewise.
	(mem_file_write): Likewise.
	* utils.c (make_hex_string): Likewise.
	(get_regcomp_error): Likewise.
	(puts_filtered_tabular): Likewise.
	(gdb_realpath_keepfile): Likewise.
	(ldirname): Likewise.
	(gdb_bfd_errmsg): Likewise.
	(substitute_path_component): Likewise.
	* valops.c (search_struct_method): Likewise.
	(find_oload_champ_namespace_loop): Likewise.
	* valprint.c (print_decimal_chars): Likewise.
	(read_string): Likewise.
	(generic_emit_char): Likewise.
	* varobj.c (varobj_delete): Likewise.
	(varobj_value_get_print_value): Likewise.
	* vaxobsd-tdep.c (vaxobsd_sigtramp_sniffer): Likewise.
	* windows-tdep.c (display_one_tib): Likewise.
	* xcoffread.c (read_xcoff_symtab): Likewise.
	(process_xcoff_symbol): Likewise.
	(swap_sym): Likewise.
	(scan_xcoff_symtab): Likewise.
	(xcoff_initial_scan): Likewise.
	* xml-support.c (gdb_xml_end_element): Likewise.
	(xml_process_xincludes): Likewise.
	(xml_fetch_content_from_file): Likewise.
	* xml-syscall.c (xml_list_of_syscalls): Likewise.
	* xstormy16-tdep.c (xstormy16_push_dummy_call): Likewise.

gdb/gdbserver/ChangeLog:

	* ax.c (gdb_parse_agent_expr): Add cast to allocation result
	assignment.
	(gdb_unparse_agent_expr): Likewise.
	* hostio.c (require_data): Likewise.
	(handle_pread): Likewise.
	* linux-low.c (disable_regset): Likewise.
	(fetch_register): Likewise.
	(store_register): Likewise.
	(get_dynamic): Likewise.
	(linux_qxfer_libraries_svr4): Likewise.
	* mem-break.c (delete_fast_tracepoint_jump): Likewise.
	(set_fast_tracepoint_jump): Likewise.
	(uninsert_fast_tracepoint_jumps_at): Likewise.
	(reinsert_fast_tracepoint_jumps_at): Likewise.
	(validate_inserted_breakpoint): Likewise.
	(clone_agent_expr): Likewise.
	* regcache.c (init_register_cache): Likewise.
	* remote-utils.c (putpkt_binary_1): Likewise.
	(decode_M_packet): Likewise.
	(decode_X_packet): Likewise.
	(look_up_one_symbol): Likewise.
	(relocate_instruction): Likewise.
	(monitor_output): Likewise.
	* server.c (handle_search_memory): Likewise.
	(handle_qxfer_exec_file): Likewise.
	(handle_qxfer_libraries): Likewise.
	(handle_qxfer): Likewise.
	(handle_query): Likewise.
	(handle_v_cont): Likewise.
	(handle_v_run): Likewise.
	(captured_main): Likewise.
	* target.c (write_inferior_memory): Likewise.
	* thread-db.c (try_thread_db_load_from_dir): Likewise.
	* tracepoint.c (init_trace_buffer): Likewise.
	(add_tracepoint_action): Likewise.
	(add_traceframe): Likewise.
	(add_traceframe_block): Likewise.
	(cmd_qtdpsrc): Likewise.
	(cmd_qtdv): Likewise.
	(cmd_qtstatus): Likewise.
	(response_source): Likewise.
	(response_tsv): Likewise.
	(cmd_qtnotes): Likewise.
	(gdb_collect): Likewise.
	(initialize_tracepoint): Likewise.
2015-09-25 14:08:06 -04:00
Yao Qi a0cc84cd15 aarch64 multi-arch (part 3): get thread area
With the kernle fix <http://lists.infradead.org/pipermail/linux-arm-kernel/2015-July/356511.html>,
aarch64 GDB is able to read the base of thread area of 32-bit arm
program through NT_ARM_TLS.

This patch is to teach both GDB and GDBserver to read the base of
thread area correctly in the multi-arch case.  A new function
aarch64_ps_get_thread_area is added, and is shared between GDB and
GDBserver.

With this patch applied, the following fails in multi-arch testing
(GDB is aarch64 but the test cases are arm) are fixed,

 -FAIL: gdb.threads/tls-nodebug.exp: thread local storage
 -FAIL: gdb.threads/tls-shared.exp: print thread local storage variable
 -FAIL: gdb.threads/tls-so_extern.exp: print thread local storage variable
 -FAIL: gdb.threads/tls-var.exp: print tls_var
 -FAIL: gdb.threads/tls.exp: first thread local storage
 -FAIL: gdb.threads/tls.exp: first another thread local storage
 -FAIL: gdb.threads/tls.exp: p a_thread_local
 -FAIL: gdb.threads/tls.exp: p file2_thread_local
 -FAIL: gdb.threads/tls.exp: p a_thread_local second time

gdb:

2015-09-18  Yao Qi  <yao.qi@linaro.org>

	* nat/aarch64-linux.c: Include elf/common.h,
	nat/gdb_ptrace.h, asm/ptrace.h and sys/uio.h.
	(aarch64_ps_get_thread_area): New function.
	* nat/aarch64-linux.h: Include gdb_proc_service.h.
	(aarch64_ps_get_thread_area): Declare.
	* aarch64-linux-nat.c (ps_get_thread_area): Call
	aarch64_ps_get_thread_area.

gdb/gdbserver:

2015-09-18  Yao Qi  <yao.qi@linaro.org>

	* linux-aarch64-low.c: Don't include sys/uio.h.
	(ps_get_thread_area): Call aarch64_ps_get_thread_area.
2015-09-18 13:59:42 +01:00
Yao Qi ade90bdeb7 aarch64 multi-arch support (part 2): siginfo fixup
This patch is to fixup the siginfo_t when aarch64 gdb or gdbserver
read from or write to the arm inferior.  It is to convert the
"struct siginfo_t" between aarch64 and arm, which is quite mechanical.

gdb/gdbserver:

2015-09-15  Yao Qi  <yao.qi@linaro.org>

	* linux-aarch64-low.c (aarch64_linux_siginfo_fixup): New
	function.
	(struct linux_target_ops the_low_target): Install
	aarch64_linux_siginfo_fixup.

gdb:

2015-09-15  Yao Qi  <yao.qi@linaro.org>

	* aarch64-linux-nat.c (aarch64_linux_siginfo_fixup): New function.
	(_initialize_aarch64_linux_nat): Call linux_nat_set_siginfo_fixup.
	* nat/aarch64-linux.c (aarch64_compat_siginfo_from_siginfo):
	New function.
	(aarch64_siginfo_from_compat_siginfo): New function.
	* nat/aarch64-linux.h: Include signal.h.
	(compat_int_t, compat_uptr_t, compat_time_t): Typedef.
	(compat_timer_t, compat_clock_t): Likewise.
	(struct compat_timeval): New.
	(union compat_sigval): New.
	(struct compat_siginfo): New.
	(cpt_si_pid, cpt_si_uid, cpt_si_timerid): New macros.
	(cpt_si_overrun, cpt_si_status, cpt_si_utime): Likewise.
	(cpt_si_stime, cpt_si_ptr, cpt_si_addr): Likewise.
	(cpt_si_band, cpt_si_fd): Likewise.
2015-09-15 10:25:51 +01:00
Don Breazeal 94585166df Extended-remote follow-exec
This patch implements support for exec events on extended-remote Linux
targets.  Follow-exec-mode and rerun behave as expected.  Catchpoints and
test updates are implemented in subsequent patches.

This patch was derived from a patch posted last October:
https://sourceware.org/ml/gdb-patches/2014-10/msg00877.html.
It was originally based on some work done by Luis Machado in 2013.

IMPLEMENTATION
----------------
Exec events are enabled via ptrace options.

When an exec event is detected by gdbserver, the existing process
data, along with all its associated lwp and thread data, is deleted
and replaced by data for a new single-threaded process.  The new
process data is initialized with the appropriate parts of the state
of the execing process.  This approach takes care of several potential
pitfalls, including:

 * deleting the data for an execing non-leader thread before any
   wait/sigsuspend occurs
 * correctly initializing the architecture of the execed process

We then report the exec event using a new RSP stop reason, "exec".

When GDB receives an "exec" event, it saves the status in the event
structure's target_waitstatus field, like what is done for remote fork
events.  Because the original and execed programs may have different
architectures, we skip parsing the section of the stop reply packet
that contains register data.  The register data will be retrieved
later after the inferior's architecture has been set up by
infrun.c:follow_exec.

At that point the exec event is handled by the existing event handling
in GDB.  However, a few changes were necessary so that
infrun.c:follow_exec could accommodate the remote target.

 * Where follow-exec-mode "new" is handled, we now call
   add_inferior_with_spaces instead of add_inferior with separate calls
   to set up the program and address spaces.  The motivation for this
   is that add_inferior_with_spaces also sets up the initial architecture
   for the inferior, which is needed later by target_find_description
   when it calls target_gdbarch.

 * We call a new target function, target_follow_exec.  This function
   allows us to store the execd_pathname in the inferior, instead of
   using the static string remote_exec_file from remote.c.  The static
   string didn't work for follow-exec-mode "new", since once you switched
   to the execed program, the original remote exec-file was lost.  The
   execd_pathname is now stored in the inferior's program space as a
   REGISTRY field.  All of the requisite mechanisms for this are
   defined in remote.c.

gdb/gdbserver/ChangeLog:

	* linux-low.c (linux_mourn): Static declaration.
	(linux_arch_setup): Move in front of
	handle_extended_wait.
	(linux_arch_setup_thread): New function.
	(handle_extended_wait): Handle exec events.  Call
	linux_arch_setup_thread.  Make event_lwp argument a
	pointer-to-a-pointer.
	(check_zombie_leaders): Do not check stopped threads.
	(linux_low_ptrace_options): Add PTRACE_O_TRACEEXEC.
	(linux_low_filter_event): Add lwp and thread for exec'ing
	non-leader thread if leader thread has been deleted.
	Refactor code into linux_arch_setup_thread and call it.
	Pass child lwp pointer by reference to handle_extended_wait.
	(linux_wait_for_event_filtered): Update comment.
	(linux_wait_1): Prevent clobbering exec event status.
	(linux_supports_exec_events): New function.
	(linux_target_ops) <supports_exec_events>: Initialize new member.
	* lynx-low.c (lynx_target_ops) <supports_exec_events>: Initialize
	new member.
	* remote-utils.c (prepare_resume_reply): New stop reason 'exec'.
	* server.c (report_exec_events): New global variable.
	(handle_query): Handle qSupported query for exec-events feature.
	(captured_main): Initialize report_exec_events.
	* server.h (report_exec_events): Declare new global variable.
	* target.h (struct target_ops) <supports_exec_events>: New
	member.
	(target_supports_exec_events): New macro.
	* win32-low.c (win32_target_ops) <supports_exec_events>:
	Initialize new member.

gdb/ChangeLog:

	* infrun.c (follow_exec): Use process-style ptid for
	exec message.  Call add_inferior_with_spaces and
	target_follow_exec.
	* nat/linux-ptrace.c (linux_supports_traceexec): New function.
	* nat/linux-ptrace.h (linux_supports_traceexec): Declare.
	* remote.c (remote_pspace_data): New static variable.
	(remote_pspace_data_cleanup): New function.
	(get_remote_exec_file): New function.
	(set_remote_exec_file_1): New function.
	(set_remote_exec_file): New function.
	(show_remote_exec_file): New function.
	(remote_exec_file): Delete static variable.
	(anonymous enum) <PACKET_exec_event_feature> New
	enumeration constant.
	(remote_protocol_features): Add entry for exec-events feature.
	(remote_query_supported): Add client side of qSupported query
	for exec-events feature.
	(remote_follow_exec): New function.
	(remote_parse_stop_reply): Handle 'exec' stop reason.
	(extended_remote_run, extended_remote_create_inferior): Call
	get_remote_exec_file and set_remote_exec_file_1.
	(init_extended_remote_ops) <to_follow_exec>: Initialize new
	member.
	(_initialize_remote): Call
	register_program_space_data_with_cleanup.  Call
	add_packet_config_cmd for remote exec-events feature.
	Modify call to add_setshow_string_noescape_cmd for exec-file
	to use new functions set_remote_exec_file and
	show_remote_exec_file.
	* target-debug.h, target-delegates.c: Regenerated.
	* target.c (target_follow_exec): New function.
	* target.h (struct target_ops) <to_follow_exec>: New member.
	(target_follow_exec): Declare new function.
2015-09-11 11:12:46 -07:00
Markus Metzger 0568462bbf btrace: kernel address filtering
For the BTS recording format, we sometimes get a FROM->TO record where the
FROM address lies in the kernel and the TO address lies in user space at
whatever address the user process was resumed.

GDB has a heuristic to filter out such records based on looking at the most
significant bit in the PC.  This works fine for 64-bit systems but it doesn't
always work for 32-bit systems.  Libraries that are loaded at fairly high
addresses might be mistaken for kernel code and branches inside the library
are filtered out.

Change the heuristic to (again heuristically) try to determine the lowest
address in kernel space.  Any PC that is smaller than that should be in
user space.

On today's systems, there should be a symbol "_text" at that address.
Read /proc/kallsyms and search for that symbol.

It is not guaranteed that /proc/kallsyms is readable on all systems.  On
64-bit systems, we fall back to check the most significant bit.  On 32-bit
systems, we refrain from filtering out addresses.

The filtering should really be done by the kernel.  And it soon will be:
https://lkml.org/lkml/2015/8/31/212.

gdb/
	* nat/linux-btrace.h (struct btrace_target_info) <ptr_bits>: Remove.
	* nat/linux-btrace.c: Include filestuff.h and inttypes.h.
	Remove include of sys/utsname.h.
	(linux_determine_kernel_ptr_bits): Remove.
	(linux_determine_kernel_start): New.
	(perf_event_is_kernel_addr): Remove tinfo argument.  Update users.
	Update check.
	(perf_event_skip_bts_record): Remove tinfo argument.  Update users.
	(linux_enable_bts, linux_enable_pt): Remove tinfo->ptr_bits
	initialization.
	* x86-linux-nat.c (x86_linux_enable_btrace): Remove ptr_bits
	assignment.

gdbserver/
	* linux-low.c (linux_low_enable_btrace): Remove.
	(linux_target_ops): Replace linux_low_enable_btrace with
	linux_enable_btrace.
2015-09-09 10:35:35 +02:00
Yao Qi 39edd165f4 [aarch64] Check region OK for HW watchpoint in GDBserver
Nowadays, if user requests HW watchpoint to monitor a large memory area
or unaligned area, aarch64 GDB will split into multiple aligned areas,
and use multiple debugging registers to watch them.  However, the
registers are not updated in a transaction way.  GDBserver doesn't revert
updates in previous iterations if some debugging registers fail to update
due to some reason, like no free debugging registers available, in the
latter iteration.  For example, if we have a char buf[34], and watch buf
in gdb,

(gdb) watch buf
Hardware watchpoint 2: buf
(gdb) c
Continuing.
infrun: clear_proceed_status_thread (Thread 13466)
infrun: proceed (addr=0xffffffffffffffff, signal=GDB_SIGNAL_DEFAULT)
infrun: step-over queue now empty
infrun: resuming [Thread 13466] for step-over
Sending packet: $m410838,22#35...Packet received: 00000000000000000000000000000000000000000000000000000000000000000000
infrun: skipping breakpoint: stepping past insn at: 0x400524
infrun: skipping breakpoint: stepping past insn at: 0x400524
Sending packet: $Z2,410838,22#80...Packet received: E01 <----- [1]
Packet Z2 (write-watchpoint) is supported
Sending packet: $Z0,7fb7fe0a8c,4#43...Packet received: OK
Warning:
Could not insert hardware watchpoint 2.
Could not insert hardware breakpoints:
You may have requested too many hardware breakpoints/watchpoints.

GDB receives E01 for Z2 packet [1] but GDBserver updates the debugging
register status,

insert_point (addr=0x00410838, len=34, type=hw-write-watchpoint):
	BREAKPOINTs:
	BP0: addr=0x0, ctrl=0x00000000, ref.count=0
	BP1: addr=0x0, ctrl=0x00000000, ref.count=0
	BP2: addr=0x0, ctrl=0x00000000, ref.count=0
	BP3: addr=0x0, ctrl=0x00000000, ref.count=0
	BP4: addr=0x0, ctrl=0x00000000, ref.count=0
	BP5: addr=0x0, ctrl=0x00000000, ref.count=0
	WATCHPOINTs:
	WP0: addr=0x410850, ctrl=0x00001ff5, ref.count=1
	WP1: addr=0x410848, ctrl=0x00001ff5, ref.count=1
	WP2: addr=0x410840, ctrl=0x00001ff5, ref.count=1
	WP3: addr=0x410838, ctrl=0x00001ff5, ref.count=1

four debugging registers can not monitor 34-byte long area, so the last
iteration of updating debugging register state fails but previous
iterations succeed.  This makes GDB think no HW watchpoint is inserted
but some debugging registers are used.

This problem was exposed by "watch buf" gdb.base/watchpoint.exp with
aarch64 GDBserver debugging arm 32-bit program.  The buf is 30-byte long
but 4-byte aligned, and four debugging registers can't cover 34-byte
(extend 4 bytes to be 8-byte aligned) area.  However, this problem
does exist on non-multi-arch debugging scenario as well.

This patch moves code in aarch64_linux_region_ok_for_hw_watchpoint to
aarch64_linux_region_ok_for_watchpoint in nat/aarch64-linux-hw-point.c.
Then, checks with aarch64_linux_region_ok_for_watchpoint, like what we
are doing in GDB.  If the region is OK, call aarch64_handle_watchpoint.

Regression tested on aarch64 with both 64-bit program and 32-bit
program.  Some fails in gdb.base/watchpoint.exp are fixed.

gdb:

2015-09-03  Yao Qi  <yao.qi@linaro.org>

	* aarch64-linux-nat.c (aarch64_linux_region_ok_for_hw_watchpoint):
	Move code to aarch64_linux_region_ok_for_watchpoint.  Call
	aarch64_linux_region_ok_for_watchpoint.
	* nat/aarch64-linux-hw-point.c (aarch64_linux_region_ok_for_watchpoint):
	New function.
	* nat/aarch64-linux-hw-point.h (aarch64_linux_region_ok_for_watchpoint):
	Declare it.

gdb/gdbserver:

2015-09-03  Yao Qi  <yao.qi@linaro.org>

	* linux-aarch64-low.c (aarch64_insert_point): Call
	aarch64_handle_watchpoint if aarch64_linux_region_ok_for_watchpoint
	returns true.
2015-09-03 14:01:49 +01:00
Ulrich Weigand 1db33b5a02 Detect SW breakpoints in Cell/B.E. combined debugging
The Linux target and gdbserver now check the siginfo si_code
reported on a SIGTRAP to detect whether the trap indicates
a software breakpoint was hit.

Unfortunately, on Cell/B.E., the kernel uses an si_code value
of TRAP_BRKPT when a SW breakpoint was hit in PowerPC code,
but a si_code value of SI_KERNEL when a SW breakpoint was
hit in SPU code.

This patch updates Linux target and gdbserver to accept both
si_code values to indicate SW breakpoint on PowerPC.

ChangeLog:

	* nat/linux-ptrace.h (GDB_ARCH_TRAP_BRKPT): Replace by ...
	(GDB_ARCH_IS_TRAP_BRKPT): ... this.  Add __powerpc__ case.
	* linux-nat.c (check_stopped_by_breakpoint): Use
	GDB_ARCH_IS_TRAP_BRKPT instead of GDB_ARCH_TRAP_BRKPT.

gdbserver/ChangeLog:

	* linux-low.c (check_stopped_by_breakpoint): Use
	GDB_ARCH_IS_TRAP_BRKPT instead of GDB_ARCH_TRAP_BRKPT.
2015-08-27 19:26:31 +02:00
Simon Marchi 8d7493201c Replace some xmalloc-family functions with XNEW-family ones
This patch is part of the make-gdb-buildable-in-C++ effort.  The idea is
to change some calls to the xmalloc family of functions to calls to the
equivalents in the XNEW family.  This avoids adding an explicit cast, so
it keeps the code a bit more readable.  Some of them also map relatively
well to a C++ equivalent (XNEW (struct foo) -> new foo), so it will be
possible to do scripted replacements if needed.

I only changed calls that were obviously allocating memory for one or
multiple "objects".  Allocation of variable sizes (such as strings or
buffer handling) will be for later (and won't use XNEW).

  - xmalloc (sizeof (struct foo)) -> XNEW (struct foo)
  - xmalloc (num * sizeof (struct foo)) -> XNEWVEC (struct foo, num)
  - xcalloc (1, sizeof (struct foo)) -> XCNEW (struct foo)
  - xcalloc (num, sizeof (struct foo)) -> XCNEWVEC (struct foo, num)
  - xrealloc (p, num * sizeof (struct foo) -> XRESIZEVEC (struct foo, p, num)
  - obstack_alloc (ob, sizeof (struct foo)) -> XOBNEW (ob, struct foo)
  - obstack_alloc (ob, num * sizeof (struct foo)) -> XOBNEWVEC (ob, struct foo, num)
  - alloca (sizeof (struct foo)) -> XALLOCA (struct foo)
  - alloca (num * sizeof (struct foo)) -> XALLOCAVEC (struct foo, num)

Some instances of xmalloc followed by memset to zero the buffer were
replaced by XCNEW or XCNEWVEC.

I regtested on x86-64, Ubuntu 14.04, but the patch touches many
architecture-specific files.  For those I'll have to rely on the
buildbot or people complaining that I broke their gdb.

gdb/ChangeLog:

	* aarch64-linux-nat.c (aarch64_add_process): Likewise.
	* aarch64-tdep.c (aarch64_gdbarch_init): Likewise.
	* ada-exp.y (write_ambiguous_var): Likewise.
	* ada-lang.c (resolve_subexp): Likewise.
	(user_select_syms): Likewise.
	(assign_aggregate): Likewise.
	(ada_evaluate_subexp): Likewise.
	(cache_symbol): Likewise.
	* addrmap.c (allocate_key): Likewise.
	(addrmap_create_mutable): Likewise.
	* aix-thread.c (sync_threadlists): Likewise.
	* alpha-tdep.c (alpha_push_dummy_call): Likewise.
	(alpha_gdbarch_init): Likewise.
	* amd64-windows-tdep.c (amd64_windows_push_arguments): Likewise.
	* arm-linux-nat.c (arm_linux_add_process): Likewise.
	* arm-linux-tdep.c (arm_linux_displaced_step_copy_insn): Likewise.
	* arm-tdep.c (push_stack_item): Likewise.
	(arm_displaced_step_copy_insn): Likewise.
	(arm_gdbarch_init): Likewise.
	(_initialize_arm_tdep): Likewise.
	* avr-tdep.c (push_stack_item): Likewise.
	* ax-general.c (new_agent_expr): Likewise.
	* block.c (block_initialize_namespace): Likewise.
	* breakpoint.c (alloc_counted_command_line): Likewise.
	(update_dprintf_command_list): Likewise.
	(parse_breakpoint_sals): Likewise.
	(decode_static_tracepoint_spec): Likewise.
	(until_break_command): Likewise.
	(clear_command): Likewise.
	(update_global_location_list): Likewise.
	(get_breakpoint_objfile_data) Likewise.
	* btrace.c (ftrace_new_function): Likewise.
	(btrace_set_insn_history): Likewise.
	(btrace_set_call_history): Likewise.
	* buildsym.c (add_symbol_to_list): Likewise.
	(record_pending_block): Likewise.
	(start_subfile): Likewise.
	(start_buildsym_compunit): Likewise.
	(push_subfile): Likewise.
	(end_symtab_get_static_block): Likewise.
	(buildsym_init): Likewise.
	* cli/cli-cmds.c (source_command): Likewise.
	* cli/cli-decode.c (add_cmd): Likewise.
	* cli/cli-script.c (build_command_line): Likewise.
	(setup_user_args): Likewise.
	(realloc_body_list): Likewise.
	(process_next_line): Likewise.
	(copy_command_lines): Likewise.
	* cli/cli-setshow.c (do_set_command): Likewise.
	* coff-pe-read.c (read_pe_exported_syms): Likewise.
	* coffread.c (coff_locate_sections): Likewise.
	(coff_symtab_read): Likewise.
	(coff_read_struct_type): Likewise.
	* common/cleanups.c (make_my_cleanup2): Likewise.
	* common/common-exceptions.c (throw_it): Likewise.
	* common/filestuff.c (make_cleanup_close): Likewise.
	* common/format.c (parse_format_string): Likewise.
	* common/queue.h (DEFINE_QUEUE_P): Likewise.
	* compile/compile-object-load.c (munmap_list_add): Likewise.
	(compile_object_load): Likewise.
	* compile/compile-object-run.c (compile_object_run): Likewise.
	* compile/compile.c (append_args): Likewise.
	* corefile.c (specify_exec_file_hook): Likewise.
	* cp-support.c (make_symbol_overload_list): Likewise.
	* cris-tdep.c (push_stack_item): Likewise.
	(cris_gdbarch_init): Likewise.
	* ctf.c (ctf_trace_file_writer_new): Likewise.
	* dbxread.c (init_header_files): Likewise.
	(add_new_header_file): Likewise.
	(init_bincl_list): Likewise.
	(dbx_end_psymtab): Likewise.
	(start_psymtab): Likewise.
	(dbx_end_psymtab): Likewise.
	* dcache.c (dcache_init): Likewise.
	* dictionary.c (dict_create_hashed): Likewise.
	(dict_create_hashed_expandable): Likewise.
	(dict_create_linear): Likewise.
	(dict_create_linear_expandable): Likewise.
	* dtrace-probe.c (dtrace_process_dof_probe): Likewise.
	* dummy-frame.c (register_dummy_frame_dtor): Likewise.
	* dwarf2-frame-tailcall.c (cache_new_ref1): Likewise.
	* dwarf2-frame.c (dwarf2_build_frame_info): Likewise.
	(decode_frame_entry_1): Likewise.
	* dwarf2expr.c (new_dwarf_expr_context): Likewise.
	* dwarf2loc.c (dwarf2_compile_expr_to_ax): Likewise.
	* dwarf2read.c (dwarf2_has_info): Likewise.
	(create_signatured_type_table_from_index): Likewise.
	(dwarf2_read_index): Likewise.
	(dw2_get_file_names_reader): Likewise.
	(create_all_type_units): Likewise.
	(read_cutu_die_from_dwo): Likewise.
	(init_tu_and_read_dwo_dies): Likewise.
	(init_cutu_and_read_dies): Likewise.
	(create_all_comp_units): Likewise.
	(queue_comp_unit): Likewise.
	(inherit_abstract_dies): Likewise.
	(read_call_site_scope): Likewise.
	(dwarf2_add_field): Likewise.
	(dwarf2_add_typedef): Likewise.
	(dwarf2_add_member_fn): Likewise.
	(attr_to_dynamic_prop): Likewise.
	(abbrev_table_alloc_abbrev): Likewise.
	(abbrev_table_read_table): Likewise.
	(add_include_dir): Likewise.
	(add_file_name): Likewise.
	(dwarf_decode_line_header): Likewise.
	(dwarf2_const_value_attr): Likewise.
	(dwarf_alloc_block): Likewise.
	(parse_macro_definition): Likewise.
	(set_die_type): Likewise.
	(write_psymtabs_to_index): Likewise.
	(create_cus_from_index): Likewise.
	(dwarf2_create_include_psymtab): Likewise.
	(process_psymtab_comp_unit_reader): Likewise.
	(build_type_psymtab_dependencies): Likewise.
	(read_comp_units_from_section): Likewise.
	(compute_compunit_symtab_includes): Likewise.
	(create_dwo_unit_in_dwp_v1): Likewise.
	(create_dwo_unit_in_dwp_v2): Likewise.
	(read_func_scope): Likewise.
	(process_structure_scope): Likewise.
	(mark_common_block_symbol_computed): Likewise.
	(load_partial_dies): Likewise.
	(dwarf2_symbol_mark_computed): Likewise.
	* elfread.c (elf_symfile_segments): Likewise.
	(elf_read_minimal_symbols): Likewise.
	* environ.c (make_environ): Likewise.
	* eval.c (evaluate_subexp_standard): Likewise.
	* event-loop.c (create_file_handler): Likewise.
	(create_async_signal_handler): Likewise.
	(create_async_event_handler): Likewise.
	(create_timer): Likewise.
	* exec.c (build_section_table): Likewise.
	* fbsd-nat.c (fbsd_remember_child): Likewise.
	* fork-child.c (fork_inferior): Likewise.
	* frv-tdep.c (new_variant): Likewise.
	* gdbarch.sh (gdbarch_alloc): Likewise.
	(append_name): Likewise.
	* gdbtypes.c (rank_function): Likewise.
	(copy_type_recursive): Likewise.
	(add_dyn_prop): Likewise.
	* gnu-nat.c (make_proc): Likewise.
	(make_inf): Likewise.
	(gnu_write_inferior): Likewise.
	* gnu-v3-abi.c (build_gdb_vtable_type): Likewise.
	(build_std_type_info_type): Likewise.
	* guile/scm-param.c (compute_enum_list): Likewise.
	* guile/scm-utils.c (gdbscm_parse_function_args): Likewise.
	* guile/scm-value.c (gdbscm_value_call): Likewise.
	* h8300-tdep.c (h8300_gdbarch_init): Likewise.
	* hppa-tdep.c (hppa_init_objfile_priv_data): Likewise.
	(read_unwind_info): Likewise.
	* ia64-tdep.c (ia64_gdbarch_init): Likewise.
	* infcall.c (dummy_frame_context_saver_setup): Likewise.
	(call_function_by_hand_dummy): Likewise.
	* infcmd.c (step_once): Likewise.
	(finish_forward): Likewise.
	(attach_command): Likewise.
	(notice_new_inferior): Likewise.
	* inferior.c (add_inferior_silent): Likewise.
	* infrun.c (add_displaced_stepping_state): Likewise.
	(save_infcall_control_state): Likewise.
	(save_inferior_ptid): Likewise.
	(_initialize_infrun): Likewise.
	* jit.c (bfd_open_from_target_memory): Likewise.
	(jit_gdbarch_data_init): Likewise.
	* language.c (add_language): Likewise.
	* linespec.c (decode_line_2): Likewise.
	* linux-nat.c (add_to_pid_list): Likewise.
	(add_initial_lwp): Likewise.
	* linux-thread-db.c (add_thread_db_info): Likewise.
	(record_thread): Likewise.
	(info_auto_load_libthread_db): Likewise.
	* m32c-tdep.c (m32c_gdbarch_init): Likewise.
	* m68hc11-tdep.c (m68hc11_gdbarch_init): Likewise.
	* m68k-tdep.c (m68k_gdbarch_init): Likewise.
	* m88k-tdep.c (m88k_analyze_prologue): Likewise.
	* macrocmd.c (macro_define_command): Likewise.
	* macroexp.c (gather_arguments): Likewise.
	* macroscope.c (sal_macro_scope): Likewise.
	* macrotab.c (new_macro_table): Likewise.
	* mdebugread.c (push_parse_stack): Likewise.
	(parse_partial_symbols): Likewise.
	(parse_symbol): Likewise.
	(psymtab_to_symtab_1): Likewise.
	(new_block): Likewise.
	(new_psymtab): Likewise.
	(mdebug_build_psymtabs): Likewise.
	(add_pending): Likewise.
	(elfmdebug_build_psymtabs): Likewise.
	* mep-tdep.c (mep_gdbarch_init): Likewise.
	* mi/mi-main.c (mi_execute_command): Likewise.
	* mi/mi-parse.c (mi_parse_argv): Likewise.
	* minidebug.c (lzma_open): Likewise.
	* minsyms.c (terminate_minimal_symbol_table): Likewise.
	* mips-linux-nat.c (mips_linux_insert_watchpoint): Likewise.
	* mips-tdep.c (mips_gdbarch_init): Likewise.
	* mn10300-tdep.c (mn10300_gdbarch_init): Likewise.
	* msp430-tdep.c (msp430_gdbarch_init): Likewise.
	* mt-tdep.c (mt_registers_info): Likewise.
	* nat/aarch64-linux.c (aarch64_linux_new_thread): Likewise.
	* nat/linux-btrace.c (linux_enable_bts): Likewise.
	(linux_enable_pt): Likewise.
	* nat/linux-osdata.c (linux_xfer_osdata_processes): Likewise.
	(linux_xfer_osdata_processgroups): Likewise.
	* nios2-tdep.c (nios2_gdbarch_init): Likewise.
	* nto-procfs.c (procfs_meminfo): Likewise.
	* objc-lang.c (start_msglist): Likewise.
	(selectors_info): Likewise.
	(classes_info): Likewise.
	(find_methods): Likewise.
	* objfiles.c (allocate_objfile): Likewise.
	(update_section_map): Likewise.
	* osabi.c (gdbarch_register_osabi): Likewise.
	(gdbarch_register_osabi_sniffer): Likewise.
	* parse.c (start_arglist): Likewise.
	* ppc-linux-nat.c (hwdebug_find_thread_points_by_tid): Likewise.
	(hwdebug_insert_point): Likewise.
	* printcmd.c (display_command): Likewise.
	(ui_printf): Likewise.
	* procfs.c (create_procinfo): Likewise.
	(load_syscalls): Likewise.
	(proc_get_LDT_entry): Likewise.
	(proc_update_threads): Likewise.
	* prologue-value.c (make_pv_area): Likewise.
	(pv_area_store): Likewise.
	* psymtab.c (extend_psymbol_list): Likewise.
	(init_psymbol_list): Likewise.
	(allocate_psymtab): Likewise.
	* python/py-inferior.c (add_thread_object): Likewise.
	* python/py-param.c (compute_enum_values): Likewise.
	* python/py-value.c (valpy_call): Likewise.
	* python/py-varobj.c (py_varobj_iter_next): Likewise.
	* python/python.c (ensure_python_env): Likewise.
	* record-btrace.c (record_btrace_start_replaying): Likewise.
	* record-full.c (record_full_reg_alloc): Likewise.
	(record_full_mem_alloc): Likewise.
	(record_full_end_alloc): Likewise.
	(record_full_core_xfer_partial): Likewise.
	* regcache.c (get_thread_arch_aspace_regcache): Likewise.
	* remote-fileio.c (remote_fileio_init_fd_map): Likewise.
	* remote-notif.c (remote_notif_state_allocate): Likewise.
	* remote.c (demand_private_info): Likewise.
	(remote_notif_stop_alloc_reply): Likewise.
	(remote_enable_btrace): Likewise.
	* reverse.c (save_bookmark_command): Likewise.
	* rl78-tdep.c (rl78_gdbarch_init): Likewise.
	* rx-tdep.c (rx_gdbarch_init): Likewise.
	* s390-linux-nat.c (s390_insert_watchpoint): Likewise.
	* ser-go32.c (dos_get_tty_state): Likewise.
	(dos_copy_tty_state): Likewise.
	* ser-mingw.c (ser_windows_open): Likewise.
	(ser_console_wait_handle): Likewise.
	(ser_console_get_tty_state): Likewise.
	(make_pipe_state): Likewise.
	(net_windows_open): Likewise.
	* ser-unix.c (hardwire_get_tty_state): Likewise.
	(hardwire_copy_tty_state): Likewise.
	* solib-aix.c (solib_aix_new_lm_info): Likewise.
	* solib-dsbt.c (dsbt_current_sos): Likewise.
	(dsbt_relocate_main_executable): Likewise.
	* solib-frv.c (frv_current_sos): Likewise.
	(frv_relocate_main_executable): Likewise.
	* solib-spu.c (spu_bfd_fopen): Likewise.
	* solib-svr4.c (lm_info_read): Likewise.
	(svr4_copy_library_list): Likewise.
	(svr4_default_sos): Likewise.
	* source.c (find_source_lines): Likewise.
	(line_info): Likewise.
	(add_substitute_path_rule): Likewise.
	* spu-linux-nat.c (spu_bfd_open): Likewise.
	* spu-tdep.c (info_spu_dma_cmdlist): Likewise.
	* stabsread.c (dbx_lookup_type): Likewise.
	(read_type): Likewise.
	(read_member_functions): Likewise.
	(read_struct_fields): Likewise.
	(read_baseclasses): Likewise.
	(read_args): Likewise.
	(_initialize_stabsread): Likewise.
	* stack.c (func_command): Likewise.
	* stap-probe.c (handle_stap_probe): Likewise.
	* symfile.c (addrs_section_sort): Likewise.
	(addr_info_make_relative): Likewise.
	(load_section_callback): Likewise.
	(add_symbol_file_command): Likewise.
	(init_filename_language_table): Likewise.
	* symtab.c (create_filename_seen_cache): Likewise.
	(sort_search_symbols_remove_dups): Likewise.
	(search_symbols): Likewise.
	* target.c (make_cleanup_restore_target_terminal): Likewise.
	* thread.c (new_thread): Likewise.
	(enable_thread_stack_temporaries): Likewise.
	(make_cleanup_restore_current_thread): Likewise.
	(thread_apply_all_command): Likewise.
	* tic6x-tdep.c (tic6x_gdbarch_init): Likewise.
	* top.c (gdb_readline_wrapper): Likewise.
	* tracefile-tfile.c (tfile_trace_file_writer_new): Likewise.
	* tracepoint.c (trace_find_line_command): Likewise.
	(all_tracepoint_actions_and_cleanup): Likewise.
	(make_cleanup_restore_current_traceframe): Likewise.
	(get_uploaded_tp): Likewise.
	(get_uploaded_tsv): Likewise.
	* tui/tui-data.c (tui_alloc_generic_win_info): Likewise.
	(tui_alloc_win_info): Likewise.
	(tui_alloc_content): Likewise.
	(tui_add_content_elements): Likewise.
	* tui/tui-disasm.c (tui_find_disassembly_address): Likewise.
	(tui_set_disassem_content): Likewise.
	* ui-file.c (ui_file_new): Likewise.
	(stdio_file_new): Likewise.
	(tee_file_new): Likewise.
	* utils.c (make_cleanup_restore_integer): Likewise.
	(add_internal_problem_command): Likewise.
	* v850-tdep.c (v850_gdbarch_init): Likewise.
	* valops.c (find_oload_champ): Likewise.
	* value.c (allocate_value_lazy): Likewise.
	(record_latest_value): Likewise.
	(create_internalvar): Likewise.
	* varobj.c (install_variable): Likewise.
	(new_variable): Likewise.
	(new_root_variable): Likewise.
	(cppush): Likewise.
	(_initialize_varobj): Likewise.
	* windows-nat.c (windows_make_so): Likewise.
	* x86-nat.c (x86_add_process): Likewise.
	* xcoffread.c (arrange_linetable): Likewise.
	(allocate_include_entry): Likewise.
	(process_linenos): Likewise.
	(SYMBOL_DUP): Likewise.
	(xcoff_start_psymtab): Likewise.
	(xcoff_end_psymtab): Likewise.
	* xml-support.c (gdb_xml_parse_attr_ulongest): Likewise.
	* xtensa-tdep.c (xtensa_register_type): Likewise.
	* gdbarch.c: Regenerate.
	* gdbarch.h: Regenerate.

gdb/gdbserver/ChangeLog:

	* ax.c (gdb_parse_agent_expr): Likewise.
	(compile_bytecodes): Likewise.
	* dll.c (loaded_dll): Likewise.
	* event-loop.c (append_callback_event): Likewise.
	(create_file_handler): Likewise.
	(create_file_event): Likewise.
	* hostio.c (handle_open): Likewise.
	* inferiors.c (add_thread): Likewise.
	(add_process): Likewise.
	* linux-aarch64-low.c (aarch64_linux_new_process): Likewise.
	* linux-arm-low.c (arm_new_process): Likewise.
	(arm_new_thread): Likewise.
	* linux-low.c (add_to_pid_list): Likewise.
	(linux_add_process): Likewise.
	(handle_extended_wait): Likewise.
	(add_lwp): Likewise.
	(enqueue_one_deferred_signal): Likewise.
	(enqueue_pending_signal): Likewise.
	(linux_resume_one_lwp_throw): Likewise.
	(linux_resume_one_thread): Likewise.
	(linux_read_memory): Likewise.
	(linux_write_memory): Likewise.
	* linux-mips-low.c (mips_linux_new_process): Likewise.
	(mips_linux_new_thread): Likewise.
	(mips_add_watchpoint): Likewise.
	* linux-x86-low.c (initialize_low_arch): Likewise.
	* lynx-low.c (lynx_add_process): Likewise.
	* mem-break.c (set_raw_breakpoint_at): Likewise.
	(set_breakpoint): Likewise.
	(add_condition_to_breakpoint): Likewise.
	(add_commands_to_breakpoint): Likewise.
	(clone_agent_expr): Likewise.
	(clone_one_breakpoint): Likewise.
	* regcache.c (new_register_cache): Likewise.
	* remote-utils.c (look_up_one_symbol): Likewise.
	* server.c (queue_stop_reply): Likewise.
	(start_inferior): Likewise.
	(queue_stop_reply_callback): Likewise.
	(handle_target_event): Likewise.
	* spu-low.c (fetch_ppc_memory): Likewise.
	(store_ppc_memory): Likewise.
	* target.c (set_target_ops): Likewise.
	* thread-db.c (thread_db_load_search): Likewise.
	(try_thread_db_load_1): Likewise.
	* tracepoint.c (add_tracepoint): Likewise.
	(add_tracepoint_action): Likewise.
	(create_trace_state_variable): Likewise.
	(cmd_qtdpsrc): Likewise.
	(cmd_qtro): Likewise.
	(add_while_stepping_state): Likewise.
	* win32-low.c (child_add_thread): Likewise.
	(get_image_name): Likewise.
2015-08-26 17:18:12 -04:00
Yao Qi dfe7f77c4a Print tid in debug output of debug_reg_change_callback
In debug_reg_change_callback, we change debug registers of each LWP.
It makes more sense to print LWP's pid rather than group leader's pid.

gdb:

2015-08-25  Yao Qi  <yao.qi@linaro.org>

	* nat/aarch64-linux-hw-point.c (debug_reg_change_callback):
	Rename local variable pid to tid, and get lwpid of lwp.  Update
	debug output.
2015-08-25 14:45:54 +01:00
Yao Qi ed8b7b421c Move aarch64_linux_new_thread to nat/aarch64-linux.c
This patch moves aarch64_linux_new_thread in GDB and GDBserver to
nat/aarch64-linux.c.

gdb:

2015-08-25  Yao Qi  <yao.qi@linaro.org>

	* aarch64-linux-nat.c (aarch64_linux_new_thread): Move it to ...
	* nat/aarch64-linux.c (aarch64_linux_new_thread): ... here.
	* nat/aarch64-linux.h (aarch64_linux_new_thread): Declare.

gdb/gdbserver:

2015-08-25  Yao Qi  <yao.qi@linaro.org>

	* linux-aarch64-low.c (aarch64_linux_new_thread): Remove.
2015-08-25 11:39:14 +01:00
Yao Qi db3cb7cb3e Move aarch64_linux_prepare_to_resume to nat/aarch64-linux.c
gdb:

2015-08-25  Yao Qi  <yao.qi@linaro.org>

	* Makefile.in (aarch64-liunx.o): New rule.
	(HFILES_NO_SRCDIR): Add aarch64-linux.h.
	* config/aarch64/linux.mh (NAT_FILE): Add aarch64-linux.o.
	* aarch64-linux-nat.c: Include nat/aarch64-linux.h.
	* aarch64-linux-nat.c (aarch64_get_debug_reg_state): Make it
	extern.
	(aarch64_linux_prepare_to_resume): Move it nat/aarch64-linux.c.
	* nat/aarch64-linux-hw-point.h (aarch64_debug_reg_state): Declare
	* nat/aarch64-linux.c: New file.
	* nat/aarch64-linux.h: New file.

gdb/gdbserver:

2015-08-25  Yao Qi  <yao.qi@linaro.org>

	* Makefile.in (aarch64-linux.o): New rule.
	* configure.srv (aarch64*-*-linux*): Append aarch64-linux.o to
	srv_tgtobj.
	* linux-aarch64-low.c: Include nat/aarch64-linux.h.
	(aarch64_init_debug_reg_state): Make it extern.
	(aarch64_linux_prepare_to_resume): Remove.
2015-08-25 11:39:14 +01:00