Commit Graph

278 Commits

Author SHA1 Message Date
Pedro Alves 16c4d54a71 Don't memset non-POD types: struct breakpoint
Eh, struct breakpoint was made non-POD just today, with commit
d28cd78ad8 ("Change breakpoint event locations to
event_location_up").  :-)

  src/gdb/breakpoint.c: In function ‘void init_raw_breakpoint_without_location(breakpoint*, gdbarch*, bptype, const breakpoint_ops*)’:
  src/gdb/breakpoint.c:7447:28: error: use of deleted function ‘void* memset(T*, int, size_t) [with T = breakpoint; <template-parameter-1-2> = void; size_t = long unsigned int]’
     memset (b, 0, sizeof (*b));
			      ^
  In file included from src/gdb/common/common-defs.h:85:0,
		   from src/gdb/defs.h:28,
		   from src/gdb/breakpoint.c:20:
  src/gdb/common/poison.h:56:7: note: declared here
   void *memset (T *s, int c, size_t n) = delete;
	 ^

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

	* breakpoint.h (struct breakpoint): In-class initialize all
	fields.  Make boolean fields "bool".
	* breakpoint.c (init_raw_breakpoint_without_location): Remove
	memset call and initializations no longer necessary.
2017-04-25 01:45:21 +01:00
Pedro Alves 5625a28641 Don't memset non-POD types: struct bp_location
struct bp_location is not a POD, so we shouldn't be using memset to
initialize it.

Caught like this:

  src/gdb/breakpoint.c: In function ‘bp_location** get_first_locp_gte_addr(CORE_ADDR)’:
  src/gdb/breakpoint.c:950:53: error: use of deleted function ‘void* memset(T*, int, size_t) [with T = bp_location; <template-parameter-1-2> = void; size_t = long unsigned int]’
     memset (&dummy_loc, 0, sizeof (struct bp_location));
						       ^
  In file included from src/gdb/defs.h:28:0,
		   from src/gdb/breakpoint.c:20:
  src/gdb/common/common-defs.h:126:7: note: declared here
   void *memset (T *s, int c, size_t n) = delete;
	 ^

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

	* ada-lang.c (ada_catchpoint_location): Now a "class".  Remove
	"base" field and inherit from "bp_location" instead.  Add
	non-default ctor.
	(allocate_location_exception): Use new non-default ctor.
	* breakpoint.c (get_first_locp_gte_addr): Remove memset call.
	(init_bp_location): Convert to ...
	(bp_location::bp_location): ... this new ctor, and remove memset
	call.
	(base_breakpoint_allocate_location): Use the new non-default ctor.
	* breakpoint.h (bp_location): Now a class.  Declare default and
	non-default ctors.  In-class initialize all members.
	(init_bp_location): Remove declaration.
2017-04-25 01:43:06 +01:00
Pedro Alves bfb8cf9091 struct breakpoint: Fix indentation
I'm going to need to touch all these fields to add in-class
initialization anyway, might as well take the opportunity to finally
fix this...

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

	* breakpoint.h (struct breakpoint): Reindent.
2017-04-13 03:07:21 +01:00
Tom Tromey d28cd78ad8 Change breakpoint event locations to event_location_up
This is a follow-up to an earlier patch.  It changes breakpoint's
location and location_range_end members to be of type
event_location_up, then fixes up the users.

gdb/ChangeLog
2017-04-12  Tom Tromey  <tom@tromey.com>

	* remote.c (remote_download_tracepoint): Update.
	* python/py-breakpoint.c (bppy_get_location): Update.
	* guile/scm-breakpoint.c (bpscm_print_breakpoint_smob)
	(gdbscm_breakpoint_location): Update.
	* elfread.c (elf_gnu_ifunc_resolver_return_stop): Update.
	* breakpoint.h (struct breakpoint) <location, location_range_end>:
	Change type to event_location_up.
	* breakpoint.c (create_overlay_event_breakpoint)
	(create_longjmp_master_breakpoint)
	(create_std_terminate_master_breakpoint)
	(create_exception_master_breakpoint)
	(breakpoint_event_location_empty_p, print_breakpoint_location)
	(print_one_breakpoint_location, create_thread_event_breakpoint)
	(init_breakpoint_sal, create_breakpoint)
	(print_recreate_ranged_breakpoint, break_range_command)
	(init_ada_exception_breakpoint, say_where): Update.
	(base_breakpoint_dtor): Don't call delete_event_location.
	(bkpt_print_recreate, tracepoint_print_recreate)
	(dprintf_print_recreate, update_static_tracepoint)
	(breakpoint_re_set_default): Update.
2017-04-12 11:16:19 -06:00
Tom Tromey 93921405a4 Introduce command_line_up
This introduces command_line_up, a unique_ptr for command_line
objects, and changes many places to use it.  This removes a number of
cleanups.

Command lines are funny in that sometimes they are reference counted.
Once there is more C++-ification of some of the users, perhaps all of
these can be changed to use shared_ptr instead.

gdb/ChangeLog
2017-04-12  Tom Tromey  <tom@tromey.com>

	* tracepoint.c (actions_command): Update.
	* python/python.c (python_command, python_interactive_command):
	Update.
	* mi/mi-cmd-break.c (mi_cmd_break_commands): Update.
	* guile/guile.c (guile_command): Update.
	* defs.h (read_command_lines, read_command_lines_1): Return
	command_line_up.
	(command_lines_deleter): New struct.
	(command_line_up): New typedef.
	* compile/compile.c (compile_code_command)
	(compile_print_command): Update.
	* cli/cli-script.h (get_command_line, copy_command_lines): Return
	command_line_up.
	(make_cleanup_free_command_lines): Remove.
	* cli/cli-script.c (get_command_line, read_command_lines_1)
	(copy_command_lines): Return command_line_up.
	(while_command, if_command, read_command_lines, define_command)
	(document_command): Update.
	(do_free_command_lines_cleanup, make_cleanup_free_command_lines):
	Remove.
	* breakpoint.h (breakpoint_set_commands): Change type of
	"commands".
	* breakpoint.c (breakpoint_set_commands): Change type of
	"commands".  Update.
	(do_map_commands_command, update_dprintf_command_list)
	(create_tracepoint_from_upload): Update.
2017-04-12 11:16:17 -06: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
Pedro Alves 63160a4350 -Wwrite-strings: Some constification in gdb/breakpoint.c
The main motivation here is avoiding having to write a couple casts
like these:

     if (!arg)
  -    arg = "";
  +    arg = (char *) "";

in catch_exception_command_1 and catch_exec_command_1.

That requires making ep_parse_optional_if_clause and
check_for_argument take pointers to const strings.  I then tried
propagating the resulting constification all the way, but that was
spiraling out of control, so instead I settled for keeping const and
non-const overloads.

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

	* break-catch-throw.c (handle_gnu_v3_exceptions): Constify
	'cond_string' parameter.
	(extract_exception_regexp): Constify 'string' parameter.
	(catch_exception_command_1): Constify.
	* breakpoint.c (init_catchpoint)
	(create_fork_vfork_event_catchpoint): Constify 'cond_string'
	parameter.
	(ep_parse_optional_if_clause, catch_fork_command_1)
	(catch_exec_command_1): Constify.
	* breakpoint.h (init_catchpoint): Constify 'cond_string'
	parameter.
	(ep_parse_optional_if_clause): Constify.
	* cli/cli-utils.c (remove_trailing_whitespace)
	(check_for_argument): Constify.
	* cli/cli-utils.h (remove_trailing_whitespace): Constify and add
	non-const overload.
	(check_for_argument): Likewise.
2017-04-05 19:21:36 +01: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
Pedro Alves 3cde5c42d1 Eliminate agent_expr_p; VEC -> std::vector in struct bp_target_info
After the previous patch, we end up with these two types with quite
similar, and potentially confusing names:

  typedef gdb::unique_ptr<agent_expr> agent_expr_up;

  /* Pointer to an agent_expr structure.  */
  typedef struct agent_expr *agent_expr_p;

The latter is only necessary to put agent_expr pointers in VECs.  So
just eliminate it and use std::vector instead.

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

	* ax.h (agent_expr_p): Delete.
	(DEF_VEC_P (agent_expr_p)): Delete.
	* breakpoint.c (build_target_condition_list)
	(build_target_command_list): Adjust to use of std::vector.
	(bp_location_dtor): Remove now unnecessary VEC_free calls.
	* breakpoint.h: Include <vector>.
	(struct bp_target_info) <conditions, tcommands>: Now
	std::vector's.
	* remote.c (remote_add_target_side_condition): bp_tgt->conditions
	is now a std::vector; adjust.
	(remote_add_target_side_commands, remote_insert_breakpoint):
	bp_tgt->tcommands is now a std::vector; adjust.
2016-11-08 15:26:47 +00:00
Pedro Alves 833177a4a5 'struct agent_expr *' -> unique_ptr<agent_expr>
This patch makes the gen_* functions return a unique_ptr instead of
raw pointer:

  typedef gdb::unique_ptr<agent_expr> agent_expr_up;

and then adjusts the codebase throughout to stop using
make_cleanup_free_agent_expr.

The cond_bytecode and cmd_bytecode fields of struct bp_location are
owning pointers, so they're changed to be unique_ptr's instead of raw
pointers.

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

	* ax-gdb.c (is_nontrivial_conversion): Use agent_expr_up.
	(gen_trace_for_var, gen_trace_for_expr, gen_eval_for_expr)
	(gen_trace_for_return_address, gen_printf): Use and return an
	agent_expr_up.  Don't use make_cleanup_free_agent_expr.
	(agent_eval_command_one, maint_agent_printf_command): Use
	agent_expr_up.  Don't use make_cleanup_free_agent_expr.
	* ax-gdb.h (gen_trace_for_expr, gen_trace_for_var)
	(gen_trace_for_return_address, gen_eval_for_expr, gen_printf): Use
	agent_expr_up.
	* ax-general.c (new_agent_expr): Rename to ...
	(agent_expr::agent_expr): ... this, and now a constructor.
	(free_agent_expr): Rename to ...
	(agent_expr::~agent_exp): ... this, and now a destructor.
	(do_free_agent_expr_cleanup, make_cleanup_free_agent_expr):
	Delete.
	* ax.h (struct agent_expr): Add ctor/dtor.
	(agent_expr_up): New typedef.
	(new_agent_expr, free_agent_expr, make_cleanup_free_agent_expr):
	Delete declarations.
	* breakpoint.c (parse_cond_to_aexpr): Use and return an
	agent_expr_up.  Don't use make_cleanup_free_agent_expr.
	(build_target_condition_list): Adjust to use agent_expr_up.
	(parse_cmd_to_aexpr): Use and return an agent_expr_up.  Don't use
	make_cleanup_free_agent_expr.
	(build_target_command_list): Adjust to use agent_expr_up.
	(force_breakpoint_reinsertion): Adjust to use agent_expr_up.
	(bp_location_dtor): Remove unnecessary free_agent_expr and xfree
	calls.
	* breakpoint.h (struct bp_target_info) <cond_bytecode,
	cmd_bytecode>: Now agent_expr_up's.
	* remote.c (remote_download_tracepoint): Adjust to use
	agent_expr_up and remove use of make_cleanup_free_agent_expr.
	* tracepoint.c (validate_actionline, collect_symbol): Adjust to
	use agent_expr_up and remove uses of make_cleanup_free_agent_expr.
	(collection_list::~collection_list): Call delete instead of
	free_agent_expr.
	(encode_actions_1): Adjust to use agent_expr_up and remove uses of
	make_cleanup_free_agent_expr.
	(add_aexpr): Change parameter type to agent_expr_up; Return a raw
	agent_expr pointer.
2016-11-08 15:26:47 +00:00
Pedro Alves 4d01a485d2 'struct expression *' -> gdb::unique_xmalloc_ptr<expression>
This patch makes parse_expression and friends return a unique_ptr
instead of raw pointer [1]:

  typedef gdb::unique_malloc_ptr<expression> expression_up;

and then adjusts the codebase throughout to stop using cleanups to
manage lifetime of expression pointers.

Whenever I found a structure owning an expression pointer, I made it
store a unique_ptr instead of a raw pointer, which then requires using
new/delete of the holding structure, instead of XNEW/xfree.

[1] - I'd like to set the rule that types named with an "_up" suffix
      are unique_ptr typedefs.

Note I used gdb::unique_xmalloc_ptr instead of gdb::unique_ptr, simply
because we still use xmalloc instead of new to allocate expression
objects.  Once that's changed, all we need to do is change the
expression_up typedef and the smart pointer will then call delete
instead of xfree.

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

	* ada-lang.c (ada_read_renaming_var_value): Use expression_up.
	(struct ada_catchpoint_location) <excep_cond_expr>: Now an
	expression_up.
	(ada_catchpoint_location_dtor): Reset excep_cond_expr instead of
	using xfree.
	(create_excep_cond_exprs): Use expression_up and gdb::move.
	(allocate_location_exception): Use new instead of XNEW.
	(should_stop_exception): Likewise.  Adjust to use expression_up.
	(create_ada_exception_catchpoint): Use new instead of XNEW.
	* ax-gdb.c (agent_eval_command_one): Use expression_up instead of
	cleanups.
	(maint_agent_printf_command): Use expression_up.
	* break-catch-sig.c (create_signal_catchpoint): Use new instead of
	XNEW.
	* break-catch-syscall.c (create_syscall_event_catchpoint):
	Likewise.
	* break-catch-throw.c (handle_gnu_v3_exceptions): Use new instead
	of XCNEW.  Use gdb::unique_ptr instead of cleanups.
	* breakpoint.c (set_breakpoint_condition, update_watchpoint)
	(parse_cmd_to_aexpr, watchpoint_check)
	(bpstat_check_breakpoint_conditions, watchpoint_locations_match):
	Adjust to use expression_up.
	(init_bp_location): Adjust.
	(free_bp_location): Use delete instead of xfree.
	(set_raw_breakpoint_without_location, set_raw_breakpoint)
	(add_solib_catchpoint, create_fork_vfork_event_catchpoint)
	(new_single_step_breakpoint, create_breakpoint_sal): Use new
	instead of XNEW.
	(find_condition_and_thread): Adjust to use expression_up.
	(create_breakpoint): Use new instead of XNEW.
	(dtor_watchpoint): Don't xfree expression pointers, they're
	unique_ptr's now.
	(insert_watchpoint, remove_watchpoint): Adjust.
	(watch_command_1): Use expression_up.  Use new instead of XCNEW.
	(catch_exec_command_1): Use new instead of XNEW.
	(bp_location_dtor): Don't xfree expression pointers, they're
	unique_ptr's now.
	(base_breakpoint_allocate_location)
	(strace_marker_create_breakpoints_sal): Use new instead of XNEW.
	(delete_breakpoint): Use delete instead of xfree.
	* breakpoint.h (struct bp_location) <cond>: Now an
	unique_ptr<expression> instead of a raw pointer.
	(struct watchpoint) <exp, cond_exp>: Likewise.
	* cli/cli-script.c (execute_control_command): Use expression_up
	instead of cleanups.
	* dtrace-probe.c (dtrace_process_dof_probe): Use expression_up.
	* eval.c (parse_and_eval_address, parse_and_eval_long)
	(parse_and_eval, parse_to_comma_and_eval, parse_and_eval_type):
	Use expression_up instead of cleanups.
	* expression.h (expression_up): New typedef.
	(parse_expression, parse_expression_with_language, parse_exp_1):
	Change return type to expression_up.
	* mi/mi-main.c (mi_cmd_data_evaluate_expression)
	(print_variable_or_computed): Use expression_up.
	* objc-lang.c (print_object_command): Use expression_up instead of
	cleanups.
	* parse.c (parse_exp_1, parse_exp_in_context)
	(parse_exp_in_context_1, parse_expression)
	(parse_expression_with_language): Return an expression_up instead
	of a raw pointer.
	(parse_expression_for_completion): Use expression_up.
	* printcmd.c (struct display) <exp>: Now an expression_up instead
	of a raw pointer.
	(print_command_1, output_command_const, set_command, x_command):
	Use expression_up instead of cleanups.
	(display_command): Likewise.  Use new instead of XNEW.
	(free_display): Use delete instead of xfree.
	(do_one_display): Adjust to use expression_up.
	* remote.c (remote_download_tracepoint): Likewise.
	* stack.c (return_command): Likewise.
	* tracepoint.c (validate_actionline, encode_actions_1): Use
	expression_up instead of cleanups.
	* typeprint.c (whatis_exp, maintenance_print_type): Likewise.
	* value.c (init_if_undefined_command): Likewise.
	* varobj.c (struct varobj_root) <exp>: Now an expression_up
	instead of a raw pointer.
	(varobj_create): Adjust.
	(varobj_set_value): Use an expression_up instead of cleanups.
	(new_root_variable): Use new instead of XNEW.
	(free_variable): Use delete instead of xfree.
	(value_of_root_1): Use std::swap.
2016-11-08 15:26:43 +00:00
Pedro Alves 896b6bda69 breakpoint.c:commands_command_1 constification and cleanup
This is constification needed for next patch.  Adjust
commands_command_1 to use std::string too because the "arg" parameter
is currently overwritten and then passed to make_cleanup.  The
constification alone would trigger a compile error in the make_cleanup
call otherwise (passing const char * to void * parameter).  Using
std::string gets rid of the cleanup in the first place, resulting in
simpler code.

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

	* breakpoint.c (struct commands_info) <arg>: Constify.
	(commands_command_1): Constify 'arg' parameter.  Use std::string
	and string_printf.
	(commands_from_control_command): Constify 'arg' parameter.
	(map_breakpoint_numbers): Constify 'args' parameter.
	* breakpoint.h (commands_from_control_command): Constify 'arg'
	parameter.
2016-11-08 15:26:43 +00:00
Yao Qi 93f9a11fbd gdbarch software_single_step returns VEC (CORE_ADDR) *
This patch changes gdbarch method software_single_step to return a
vector of addresses on which GDB should insert breakpoints, and don't
insert breakpoints.  Instead, the caller of
gdbarch_software_single_step inserts breakpoints if the returned
vector is not NULL.

gdb:

2016-11-08  Yao Qi  <yao.qi@linaro.org>

	* aarch64-tdep.c (aarch64_software_single_step): Return
	VEC (CORE_ADDR) *.  Return NULL instead of 0.  Don't call
	insert_single_step_breakpoint.
	* alpha-tdep.c (alpha_deal_with_atomic_sequence): Likewise.
	(alpha_software_single_step): Likewise.
	* alpha-tdep.h (alpha_software_single_step): Update declaration.
	* arm-linux-tdep.c (arm_linux_software_single_step): Return
	VEC (CORE_ADDR) *.  Return NULL instead of 0.
	* arm-tdep.c (arm_software_single_step): Return NULL instead of	0.
	* arm-tdep.h (arm_software_single_step): Update declaration.
	* breakpoint.c (insert_single_step_breakpoints): New function.
	* breakpoint.h (insert_single_step_breakpoints): Declare.
	* cris-tdep.c (cris_software_single_step): Return
	VEC (CORE_ADDR) *.  Don't call insert_single_step_breakpoint.
	* gdbarch.sh (software_single_step): Change it to return
	VEC (CORE_ADDR) *.
	* gdbarch.c, gdbarch.h: Regenerated.
	* infrun.c (maybe_software_singlestep): Adjust.
	* mips-tdep.c (mips_deal_with_atomic_sequence): Return
	VEC (CORE_ADDR) *.  Don't call insert_single_step_breakpoint.
	(micromips_deal_with_atomic_sequence): Likewise.
	(deal_with_atomic_sequence): Likewise.
	(mips_software_single_step): Likewise.
	* mips-tdep.h (mips_software_single_step): Update declaration.
	* moxie-tdep.c (moxie_software_single_step): Likewise.
	* nios2-tdep.c (nios2_software_single_step): Likewise.
	* ppc-tdep.h (ppc_deal_with_atomic_sequence): Update
	declaration.
	* record-full.c (record_full_resume): Adjust.
	(record_full_wait_1): Likewise.
	* rs6000-aix-tdep.c (rs6000_software_single_step): Return
	VEC (CORE_ADDR) *.  Don't call insert_single_step_breakpoint.
	* rs6000-tdep.c	(ppc_deal_with_atomic_sequence): Return
	VEC (CORE_ADDR) *.  Don't call insert_single_step_breakpoint.
	* s390-linux-tdep.c (s390_software_single_step): Likewise.
	* sparc-tdep.c (sparc_software_single_step): Likewise.
	* spu-tdep.c (spu_software_single_step): Likewise.
	* tic6x-tdep.c (tic6x_software_single_step): Likewise.
2016-11-08 14:28:32 +00:00
Yao Qi 579c6ad983 Rename placed_size to kind
This patch renames placed_size to kind.

gdb:

2016-11-03  Yao Qi  <yao.qi@linaro.org>

	* breakpoint.h (struct bp_target_info) <placed_size>: Remove.
	<kind>: New field.
	Update all users.
2016-11-03 14:35:13 +00:00
Pedro Alves bfd282882d Convert tid_range_parser and get_number_or_range to classes
This converts tid_range_parser and get_number_or_range to be classes.
The various tid_range_parser_* and get_number_or_range_* functions
become methods on the respective classes.  Then it updates the users
to follow.

The rationale for the change is that this provides better
encapsulation.  For example, this forced me to think of a better
interface between tid_range_parser and get_number_or_range, since the
former peeked into the latter's internals a bit too much.  That ended
up resulting mostly in these two not-just-straight-1-1 changes:

  void
 -tid_range_parser_skip (struct tid_range_parser *parser)
 +tid_range_parser::skip_range ()
  {
 ...

 -  tid_range_parser_init (parser, parser->range_parser.end_ptr,
 -			 parser->default_inferior);
 +  m_range_parser.skip_range ();
 +  init (m_range_parser.string (), m_default_inferior);
  }

 and:

    /* If we successfully parsed a thread number or finished parsing a
       thread range, switch back to assuming the next TID is
       inferior-qualified.  */
 -  if (parser->range_parser.end_ptr == NULL
 -      || parser->range_parser.string == parser->range_parser.end_ptr)
 +  if (!m_range_parser.in_range ())
      {

For the same reason (encapsulation), this moves the enum
tid_range_state definition to within the tid_parser class's scope,
since that is private implementation detail.

While at it, switch to use "bool" for booleans.

gdb/ChangeLog:
2016-10-13  Pedro Alves  <palves@redhat.com>
	    Tom Tromey  <tom@tromey.com>

	* tid-parse.h (tid_range_parser): New class.
	(enum tid_range_state): Move into tid_range_parser's scope.
	Remove TID_RANGE_ prefix from all values.
	(tid_range_parser_get_tid, tid_range_parser_get_tid_range)
	(tid_range_parser_star_range, tid_range_parser_finished)
	(tid_range_parser_skip, tid_range_parser_qualified): Don't
	declare.
	(tid_is_in_list): Update comment.
	* tid-parse.c (tid_range_parser::tid_range_parser): New.
	(init, finished, get_string, skip, tid_is_qualified)
	(get_tid_or_range, get_tid_range, get_tid, star_range): Rename;
	turn into methods.
	(tid_is_in_list): Adjust.
	* cli/cli-utils.h (number_or_range_parser): New class.
	(init_number_or_range, get_number_or_range)
	(number_range_setup_range): Don't declare.
	* cli/cli-utils.c
	(number_or_range_parser::number_or_range_parser): New.
	(init_number_or_range, get_number_or_range)
	(number_range_setup_range): Rename; turn into methods.
	(number_is_in_list): Adjust.
	* breakpoint.c (map_breakpoint_numbers): Adjust.  Use bool.
	(trace_pass_command, get_tracepoint_by_number): Adjust.
	* breakpoint.h (get_tracepoint_by_number): Adjust.
	* inferior.c (detach_inferior_command, kill_inferior_command)
	(remove_inferior_command): Adjust.
	* linespec.c (decode_line_2): Adjust.
	* memattr.c (mem_enable_command, mem_disable_command)
	(mem_delete_command): Adjust.
	* printcmd.c (map_display_numbers): Adjust.
	* reverse.c (delete_bookmark_command, bookmarks_info): Adjust.
	* thread.c (thread_apply_command): Adjust.
2016-10-13 01:54:07 +01:00
Pedro Alves 7397181903 Plumb enum remove_bp_reason all the way to target_remove_breakpoint
So the target knows whether we're detaching breakpoints.
Nothing uses the parameter in this patch yet.

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

	PR gdb/19187
	* break-catch-sig.c (signal_catchpoint_remove_location): Adjust
	interface.
	* break-catch-syscall.c (remove_catch_syscall):
	* breakpoint.c (enum remove_bp_reason): Moved to breakpoint.h.
	(remove_breakpoint_1): Pass 'reason' down.
	(remove_catch_fork, remove_catch_vfork, remove_catch_solib)
	(remove_catch_exec, remove_watchpoint, remove_masked_watchpoint)
	(base_breakpoint_remove_location, bkpt_remove_location)
	(bkpt_probe_remove_location, bkpt_probe_remove_location): Adjust
	interface.
	* breakpoint.h (enum remove_bp_reason): Moved here from
	breakpoint.c.
	(struct breakpoint_ops) <remove_location>: Add 'reason' parameter.
	* corelow.c (core_remove_breakpoint): New function.
	(init_core_ops): Install it as to_remove_breakpoint method.
	* exec.c (exec_remove_breakpoint): New function.
	(init_exec_ops): Install it as to_remove_breakpoint method.
	* mem-break.c (memory_remove_breakpoint): Adjust interface.
	* record-btrace.c (record_btrace_remove_breakpoint): Adjust
	interface.
	* record-full.c (record_full_remove_breakpoint)
	(record_full_core_remove_breakpoint): Adjust interface.
	* remote.c (remote_remove_breakpoint): Adjust interface.
	* target-debug.h (target_debug_print_enum_remove_bp_reason): New
	macro.
	* target-delegates.c: Regenerate.
	* target.c (target_remove_breakpoint): Add 'reason' parameter.
	* target.h (struct target_ops) <to_remove_breakpoint>: Add
	'reason' parameter.
	(target_remove_breakpoint, memory_remove_breakpoint): Add 'reason'
	parameter.
2016-08-10 23:03:29 +01:00
Tom Tromey 93daf339a4 PR python/17698 - add Breakpoint.pending
This patch adds a "pending" attribute to gdb.Breakpoint.

Built and regtested on x86-64 Fedora 23.

2016-07-13  Tom Tromey  <tom@tromey.com>

	PR python/17698:
	* NEWS: Update.
	* python/py-breakpoint.c (bppy_get_pending): New function.
	(breakpoint_object_getset): Add entry for "pending".
	* breakpoint.h (pending_breakpoint_p): Declare.
	* breakpoint.c (pending_breakpoint_p): New function.

2016-07-13  Tom Tromey  <tom@tromey.com>

	PR python/17698:
	* python.texi (Breakpoints In Python): Document
	Breakpoint.pending.

2016-07-13  Tom Tromey  <tom@tromey.com>

	PR python/17698:
	* gdb.python/py-breakpoint.exp (test_bkpt_basic): Add "pending"
	test.
	(test_watchpoints): Likewise.
	(test_bkpt_pending): New proc.
2016-07-13 13:21:00 -06:00
Pedro Alves c2f4122d5c Limit breakpoint re-set to the current program space
Currently, we always re-set all locations of all breakpoints.  This
commit makes us re-set only locations of the current program space.

If we loaded symbols to a program space (e.g., "file" command or some
shared library was loaded), GDB must run through all breakpoints and
determine if any new locations need to be added to the breakpoint.
However, there's no reason to recreate locations for _other_ program
spaces, as those haven't changed.

Similarly, when we create a new inferior, through e.g., a fork, GDB
must run through all breakpoints and determine if any new locations
need to be added to the breakpoint.  There's no reason to destroy the
locations of the parent inferior and other inferiors.  We know those
won't change.

In addition to being inneficient, resetting breakpoints of inferiors
that are currently running is problematic, because:

 - some targets can't read memory while the inferior is running.

 - the inferior might exit while we're re-setting its breakpoints,
   which may confuse prologue skipping.

I went through all the places where we call breakpoint_re_set, and it
seems to me that all can be changed to only re-set locations of the
current program space.

The patch that reversed threads order in "info threads" etc. happened
to make gdb.threads/fork-plus-thread.exp expose this problem when
testing on x86/-m32.  The problem was latent and masked out by chance
by the code-cache:

 https://sourceware.org/ml/gdb-patches/2016-01/msg00213.html

Tested on x86-64 F20, native (-m64/-m32) and extended-remote
gdbserver.

Fixes the regression discussed in the url above with --target_board=unix/-m32:

 -FAIL: gdb.threads/fork-plus-threads.exp: detach-on-fork=off: inferior 1 exited
 +PASS: gdb.threads/fork-plus-threads.exp: detach-on-fork=off: inferior 1 exited
 -FAIL: gdb.threads/fork-plus-threads.exp: detach-on-fork=off: no threads left (timeout)
 -FAIL: gdb.threads/fork-plus-threads.exp: detach-on-fork=off: only inferior 1 left (the program exited)
 +PASS: gdb.threads/fork-plus-threads.exp: detach-on-fork=off: no threads left
 +PASS: gdb.threads/fork-plus-threads.exp: detach-on-fork=off: only inferior 1 left

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

	* ax-gdb.c (agent_command_1): Adjust call to decode_line_full.
	* break-catch-throw.c (re_set_exception_catchpoint): Pass the
	current program space down to linespec decoding and breakpoint
	location updating.
	* breakpoint.c (parse_breakpoint_sals): Adjust calls to
	decode_line_full.
	(until_break_command): Adjust calls to decode_line_1.
	(base_breakpoint_decode_location, bkpt_decode_location): Add
	'search_pspace' parameter.  Pass it along.
	(bkpt_probe_create_sals_from_location): Adjust calls to
	parse_probes.
	(tracepoint_decode_location, tracepoint_probe_decode_location)
	(strace_marker_decode_location): Add 'search_pspace' parameter.
	Pass it along.
	(all_locations_are_pending): Rewrite to take a breakpoint and
	program space as arguments instead.
	(hoist_existing_locations): New function.
	(update_breakpoint_locations): Add 'filter_pspace' parameter.  Use
	hoist_existing_locations instead of always removing all locations,
	and adjust to all_locations_are_pending change.
	(location_to_sals): Add 'search_pspace' parameter.  Pass it along.
	Don't disable the breakpoint if there are other locations in
	another program space.
	(breakpoint_re_set_default): Adjust to pass down the current
	program space as filter program space.
	(decode_location_default): Add 'search_pspace' parameter and pass
	it along.
	(prepare_re_set_context): Don't switch program space here.
	(breakpoint_re_set): Use save_current_space_and_thread instead of
	save_current_program_space.
	* breakpoint.h (struct breakpoint_ops) <decode_location>: Add
	'search_pspace' parameter.
	(update_breakpoint_locations): Add 'filter_pspace' parameter.
	* cli/cli-cmds.c (edit_command, list_command): Adjust calls to
	decode_line_1.
	* elfread.c (elf_gnu_ifunc_resolver_return_stop): Pass the current
	program space as filter program space.
	* linespec.c (struct linespec_state) <search_pspace>: New field.
	(create_sals_line_offset, convert_explicit_location_to_sals)
	(parse_linespec): Pass the search program space down.
	(linespec_state_constructor): Add 'search_pspace' parameter.
	Store it.
	(linespec_parser_new): Add 'search_pspace' parameter and pass it
	along.
	(linespec_lex_to_end): Adjust.
	(decode_line_full, decode_line_1): Add 'search_pspace' parameter
	and pass it along.
	(decode_line_with_last_displayed): Adjust.
	(collect_symtabs_from_filename, symtabs_from_filename): New
	'search_pspace' parameter.  Use it.
	(find_function_symbols): Pass the search program space down.
	* linespec.h (decode_line_1, decode_line_full): Add
	'search_pspace' parameter.
	* probe.c (parse_probes_in_pspace): New function, factored out
	from ...
	(parse_probes): ... this.  Add 'search_pspace' parameter and use
	it.
	* probe.h (parse_probes): Add pspace' parameter.
	* python/python.c (gdbpy_decode_line): Adjust.
	* tracepoint.c (scope_info): Adjust.
2016-01-19 12:18:14 +00:00
Pedro Alves f303dbd60d Fix PR threads/19422 - show which thread caused stop
This commit changes GDB like this:

 - Program received signal SIGINT, Interrupt.
 + Thread 1 "main" received signal SIGINT, Interrupt.

 - Breakpoint 1 at 0x40087a: file threads.c, line 87.
 + Thread 3 "bar" hit Breakpoint 1 at 0x40087a: file threads.c, line 87.

 ... once the program goes multi-threaded.  Until GDB sees a second
thread spawn, the output is still the same as before, per the
discussion back in 2012:

  https://www.sourceware.org/ml/gdb/2012-11/msg00010.html

This helps non-stop mode, where you can't easily tell which thread hit
a breakpoint or received a signal:

 (gdb) info threads
   Id   Target Id         Frame
 * 1    Thread 0x7ffff7fc1740 (LWP 19362) "main" (running)
   2    Thread 0x7ffff7fc0700 (LWP 19366) "foo" (running)
   3    Thread 0x7ffff77bf700 (LWP 19367) "bar" (running)
 (gdb)
 Program received signal SIGUSR1, User defined signal 1.
 0x0000003616a09237 in pthread_join (threadid=140737353877248, thread_return=0x7fffffffd5b8) at pthread_join.c:92
 92          lll_wait_tid (pd->tid);
 (gdb) b threads.c:87
 Breakpoint 1 at 0x40087a: file threads.c, line 87.
 (gdb)
 Breakpoint 1, thread_function1 (arg=0x1) at threads.c:87
 87              usleep (1);  /* Loop increment.  */

The best the user can do is run "info threads" and try to figure
things out.

It actually also affects all-stop mode, in case of "handle SIG print
nostop":

...
  Program received signal SIGUSR1, User defined signal 1.

  Program received signal SIGUSR1, User defined signal 1.

  Program received signal SIGUSR1, User defined signal 1.

  Program received signal SIGUSR1, User defined signal 1.
...

The above doesn't give any clue that these were different threads
getting the SIGUSR1 signal.

I initially thought of lowercasing "breakpoint" in

  "Thread 3 hit Breakpoint 1"

but then after trying it I realized that leaving "Breakpoint"
uppercase helps the eye quickly find the relevant information.  It's
also easier to implement not showing anything about threads until the
program goes multi-threaded this way.

Here's a larger example session in non-stop mode:

  (gdb) c -a&
  Continuing.
  (gdb) interrupt -a
  (gdb)
  Thread 1 "main" stopped.
  0x0000003616a09237 in pthread_join (threadid=140737353877248, thread_return=0x7fffffffd5b8) at pthread_join.c:92
  92          lll_wait_tid (pd->tid);

  Thread 2 "foo" stopped.
  0x0000003615ebc6ed in nanosleep () at ../sysdeps/unix/syscall-template.S:81
  81      T_PSEUDO (SYSCALL_SYMBOL, SYSCALL_NAME, SYSCALL_NARGS)

  Thread 3 "bar" stopped.
  0x0000003615ebc6ed in nanosleep () at ../sysdeps/unix/syscall-template.S:81
  81      T_PSEUDO (SYSCALL_SYMBOL, SYSCALL_NAME, SYSCALL_NARGS)
  b threads.c:87
  Breakpoint 4 at 0x40087a: file threads.c, line 87.
  (gdb) b threads.c:67
  Breakpoint 5 at 0x400811: file threads.c, line 67.
  (gdb) c -a&
  Continuing.
  (gdb)
  Thread 3 "bar" hit Breakpoint 4, thread_function1 (arg=0x1) at threads.c:87
  87              usleep (1);  /* Loop increment.  */

  Thread 2 "foo" hit Breakpoint 5, thread_function0 (arg=0x0) at threads.c:68
  68              (*myp) ++;
  info threads
    Id   Target Id         Frame
  * 1  Thread 0x7ffff7fc1740 (LWP 31957) "main" (running)
    2  Thread 0x7ffff7fc0700 (LWP 31961) "foo" thread_function0 (arg=0x0) at threads.c:68
    3  Thread 0x7ffff77bf700 (LWP 31962) "bar" thread_function1 (arg=0x1) at threads.c:87
  (gdb) shell kill -SIGINT 31957
  (gdb)
  Thread 1 "main" received signal SIGINT, Interrupt.
  0x0000003616a09237 in pthread_join (threadid=140737353877248, thread_return=0x7fffffffd5b8) at pthread_join.c:92
  92          lll_wait_tid (pd->tid);
  info threads
    Id   Target Id         Frame
  * 1  Thread 0x7ffff7fc1740 (LWP 31957) "main" 0x0000003616a09237 in pthread_join (threadid=140737353877248, thread_return=0x7fffffffd5b8) at pthread_join.c:92
    2  Thread 0x7ffff7fc0700 (LWP 31961) "foo" thread_function0 (arg=0x0) at threads.c:68
    3  Thread 0x7ffff77bf700 (LWP 31962) "bar" thread_function1 (arg=0x1) at threads.c:87
  (gdb) t 2
  [Switching to thread 2, Thread 0x7ffff7fc0700 (LWP 31961)]
  #0  thread_function0 (arg=0x0) at threads.c:68
  68              (*myp) ++;
  (gdb) catch syscall
  Catchpoint 6 (any syscall)
  (gdb) c&
  Continuing.
  (gdb)
  Thread 2 "foo" hit Catchpoint 6 (call to syscall nanosleep), 0x0000003615ebc6ed in nanosleep () at ../sysdeps/unix/syscall-template.S:81
  81      T_PSEUDO (SYSCALL_SYMBOL, SYSCALL_NAME, SYSCALL_NARGS)

I'll work on documentation next if this looks agreeable.

This patch applies on top of the star wildcards thread IDs series:

  https://sourceware.org/ml/gdb-patches/2016-01/msg00291.html

For convenience, I've pushed this to the
users/palves/show-which-thread-caused-stop branch.

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

	* gdb.texinfo (Threads): Mention that GDB displays the ID and name
	of the thread that hit a breakpoint or received a signal.

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

	* NEWS: Mention that GDB now displays the ID and name of the
	thread that hit a breakpoint or received a signal.
	* break-catch-sig.c (signal_catchpoint_print_it): Use
	maybe_print_thread_hit_breakpoint.
	* break-catch-syscall.c (print_it_catch_syscall): Likewise.
	* break-catch-throw.c (print_it_exception_catchpoint): Likewise.
	* breakpoint.c (maybe_print_thread_hit_breakpoint): New function.
	(print_it_catch_fork, print_it_catch_vfork, print_it_catch_solib)
	(print_it_catch_exec, print_it_ranged_breakpoint)
	(print_it_watchpoint, print_it_masked_watchpoint, bkpt_print_it):
	Use maybe_print_thread_hit_breakpoint.
	* breakpoint.h (maybe_print_thread_hit_breakpoint): Declare.
	* gdbthread.h (show_thread_that_caused_stop): Declare.
	* infrun.c (print_signal_received_reason): Print which thread
	received signal.
	* thread.c (show_thread_that_caused_stop): New function.

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

	* gdb.base/async-shell.exp: Adjust expected output.
	* gdb.base/dprintf-non-stop.exp: Adjust expected output.
	* gdb.base/siginfo-thread.exp: Adjust expected output.
	* gdb.base/watchpoint-hw-hit-once.exp: Adjust expected output.
	* gdb.java/jnpe.exp: Adjust expected output.
	* gdb.threads/clone-new-thread-event.exp: Adjust expected output.
	* gdb.threads/continue-pending-status.exp: Adjust expected output.
	* gdb.threads/leader-exit.exp: Adjust expected output.
	* gdb.threads/manythreads.exp: Adjust expected output.
	* gdb.threads/pthreads.exp: Adjust expected output.
	* gdb.threads/schedlock.exp: Adjust expected output.
	* gdb.threads/siginfo-threads.exp: Adjust expected output.
	* gdb.threads/signal-command-multiple-signals-pending.exp: Adjust
	expected output.
	* gdb.threads/signal-delivered-right-thread.exp: Adjust expected
	output.
	* gdb.threads/sigthread.exp: Adjust expected output.
	* gdb.threads/watchpoint-fork.exp: Adjust expected output.
2016-01-18 15:15:18 +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
Antoine Tremblay c2c2a31fdb Remove support for thread events without PTRACE_EVENT_CLONE in GDB
Before, on systems that did not support PTRACE_EVENT_CLONE, both GDB and
GDBServer coordinated with libthread_db.so to insert breakpoints at magic
locations in libpthread.so, in order to break at thread creation and
thread death.

Support for thread events was removed from GDBServer as patch:
https://sourceware.org/ml/gdb-patches/2015-11/msg00466.html

This patch removes support for thread events in GDB.

No regressions found on Ubuntu 14.04 x86_64.

gdb/ChangeLog:

	* breakpoint.c (remove_thread_event_breakpoints): Remove.
	* breakpoint.h (remove_thread_event_breakpoints): Remove
	declaration.
	* linux-nat.c (in_pid_list_p): Remove.
	(lin_lwp_attach_lwp): Remove.
	* linux-nat.h (lin_lwp_attach_lwp): Remove declaration.
	* linux-thread-db.c (thread_db_use_events): Remove.
	(struct thread_db_info) <td_create_bp_addr>: Remove.
	<td_death_bp_addr>: Likewise.
	<td_ta_event_addr_p>: Likewise.
	<td_ta_set_event_p>: Likewise.
	<td_ta_clear_event_p>: Likewise.
	<td_ta_event_getmsg_p>: Likewise.
	<td_thr_event_enable_p>: Likewise.
	(attach_thread): Likewise.
	(detach_thread): Likewise.
	(have_threads_callback): Likewise.
	(have_threads): Likewise.
	(enable_thread_event): Likewise.
	(enable_thread_event_reporting): Likewise.
	(try_thread_db_load_1): Remove td_ta_event_addr, td_ta_set_event,
	td_ta_clear_event, td_ta_event_getmsg, td_thr_event_enable
	initializations.
	(try_thread_db_load_1): Remove enable_thread_event_reporting call.
	(disable_thread_event_reporting): Remove.
	(record_thread): Adapt to thread_db_use_event removal.
	(detach_thread): Remove.
	(thread_db_detach): Adapt to thread_db_use_event removal.
	(check_event): Remove.
	(thread_db_wait): Adapt to thread events support removal.
	(thread_db_mourn_inferior): Likewise.
	(find_new_threads_callback): Likewise.
	(find_new_threads_once): Likewise.
	(thread_db_update_thread_list): Likewise.
2015-12-10 10:46:29 -05:00
Pedro Alves d35ae83384 Don't displaced step when there's a breakpoint in the scratch pad range
Assuming displaced stepping is enabled, and a breakpoint is set in the
memory region of the scratch pad, things break.  One of two cases can
happen:

#1 - The breakpoint wasn't inserted yet (all threads were stopped), so
     after setting up the displaced stepping scratch pad with the
     adjusted copy of the instruction we're trying to single-step, we
     insert the breakpoint, which corrupts the scratch pad, and the
     inferior executes the wrong instruction.  (Example below.)
     This is clearly unacceptable.

#2 - The breakpoint was already inserted, so setting up the displaced
     stepping scratch pad overwrites the breakpoint.  This is OK in
     the sense that we already assume that no thread is going to
     executes the code in the scratch pad range (after initial
     startup) anyway.

This commit addresses both cases by simply punting on displaced
stepping if we have a breakpoint in the scratch pad range.

The #1 case above explains a few regressions exposed by the AS/NS
series on x86:

 Running ./gdb.dwarf2/callframecfa.exp ...
 FAIL: gdb.dwarf2/callframecfa.exp: set display for call-frame-cfa
 FAIL: gdb.dwarf2/callframecfa.exp: step 1 for call-frame-cfa
 FAIL: gdb.dwarf2/callframecfa.exp: step 2 for call-frame-cfa
 FAIL: gdb.dwarf2/callframecfa.exp: step 3 for call-frame-cfa
 FAIL: gdb.dwarf2/callframecfa.exp: step 4 for call-frame-cfa
 Running ./gdb.dwarf2/typeddwarf.exp ...
 FAIL: gdb.dwarf2/typeddwarf.exp: continue to breakpoint: continue to typeddwarf.c:53
 FAIL: gdb.dwarf2/typeddwarf.exp: check value of x at typeddwarf.c:53
 FAIL: gdb.dwarf2/typeddwarf.exp: check value of y at typeddwarf.c:53
 FAIL: gdb.dwarf2/typeddwarf.exp: check value of z at typeddwarf.c:53
 FAIL: gdb.dwarf2/typeddwarf.exp: continue to breakpoint: continue to typeddwarf.c:73
 FAIL: gdb.dwarf2/typeddwarf.exp: check value of w at typeddwarf.c:73
 FAIL: gdb.dwarf2/typeddwarf.exp: check value of x at typeddwarf.c:73
 FAIL: gdb.dwarf2/typeddwarf.exp: check value of y at typeddwarf.c:73
 FAIL: gdb.dwarf2/typeddwarf.exp: check value of z at typeddwarf.c:73

Enabling "maint set target-non-stop on" implies displaced stepping
enabled as well, and it's the latter that's to blame here.  We can see
the same failures with "maint set target-non-stop off + set displaced
on".

Diffing (good/bad) gdb.log for callframecfa.exp shows:

 @@ -99,29 +99,29 @@ Breakpoint 2 at 0x80481b0: file q.c, lin
  continue
  Continuing.

 -Breakpoint 2, func (arg=77) at q.c:2
 +Breakpoint 2, func (arg=52301) at q.c:2
  2      in q.c
  (gdb) PASS: gdb.dwarf2/callframecfa.exp: continue to breakpoint: continue to breakpoint for call-frame-cfa
  display arg
 -1: arg = 77
 -(gdb) PASS: gdb.dwarf2/callframecfa.exp: set display for call-frame-cfa
 +1: arg = 52301
 +(gdb) FAIL: gdb.dwarf2/callframecfa.exp: set display for call-frame-cfa

The problem is here, when setting up the func call:

 Breakpoint 1, main (argc=-13345, argv=0x0) at q.c:7
 7       in q.c

 (gdb) disassemble
 Dump of assembler code for function main:
    0x080481bb <+0>:     push   %ebp
    0x080481bc <+1>:     mov    %esp,%ebp
    0x080481be <+3>:     sub    $0x4,%esp
 => 0x080481c1 <+6>:     movl   $0x4d,(%esp)
    0x080481c8 <+13>:    call   0x80481b0 <func>
    0x080481cd <+18>:    leave
    0x080481ce <+19>:    ret
 End of assembler dump.
 (gdb) disassemble /r
 Dump of assembler code for function main:
    0x080481bb <+0>:     55      push   %ebp
    0x080481bc <+1>:     89 e5   mov    %esp,%ebp
    0x080481be <+3>:     83 ec 04        sub    $0x4,%esp
 => 0x080481c1 <+6>:     c7 04 24 4d 00 00 00    movl   $0x4d,(%esp)
    0x080481c8 <+13>:    e8 e3 ff ff ff  call   0x80481b0 <func>
    0x080481cd <+18>:    c9      leave
    0x080481ce <+19>:    c3      ret
 End of assembler dump.

Note the breakpoint at main is set at 0x080481c1.  Right at the
instruction that sets up func's argument.  Executing that instruction
should write 0x4d to the address pointed at by $esp.  However, if we
stepi, the program manages to write 52301/0xcc4d there instead (0xcc
is int3, the x86 breakpoint instruction), because the breakpoint
address is 4 bytes inside the scratch pad location, which is
0x080481bd:

 (gdb) p 0x080481c1 - 0x080481bd
 $1 = 4

IOW, instead of executing:

  "c7 04 24 4d 00 00 00" [ movl $0x4d,(%esp) ]

the inferior executes:

  "c7 04 24 4d cc 00 00" [ movl $0xcc4d,(%esp) ]

gdb/ChangeLog:
2015-10-30  Pedro Alves  <palves@redhat.com>

	* breakpoint.c (breakpoint_in_range_p)
	(breakpoint_location_address_range_overlap): New functions.
	* breakpoint.h (breakpoint_in_range_p): New declaration.
	* infrun.c (displaced_step_prepare_throw): If there's a breakpoint
	in the scratch pad range, don't displaced step.
2015-10-30 16:00:43 +00:00
Pedro Alves 243a925328 Replace "struct continuation" mechanism by something more extensible
This adds an object oriented replacement for the "struct continuation"
mechanism, and converts the stepping commands (step, next, stepi,
nexti) and the "finish" commands to use it.

It adds a new thread "class" (struct thread_fsm) that contains the
necessary info and callbacks to manage the state machine of a thread's
execution command.

This allows getting rid of some hacks.  E.g., in fetch_inferior_event
and normal_stop we no longer need to know whether a thread is doing a
multi-step (e.g., step N).  This effectively makes the
intermediate_continuations unused -- they'll be garbage collected in a
separate patch.  (They were never a proper abstraction, IMO.  See how
fetch_inferior_event needs to check step_multi before knowing whether
to call INF_EXEC_CONTINUE or INF_EXEC_COMPLETE.)

The target async vs !async uiout hacks in mi_on_normal_stop go away
too.

print_stop_event is no longer called from normal_stop.  Instead it is
now called from within each interpreter's normal_stop observer.  This
clears the path to make each interpreter print a stop event the way it
sees fit.  Currently we have some hacks in common code to
differenciate CLI vs TUI vs MI around this area.

The "finish" command's FSM class stores the return value plus that
value's position in the value history, so that those can be printed to
both MI and CLI's streams.  This fixes the CLI "finish" command when
run from MI -- it now also includes the function's return value in the
CLI stream:

  (gdb)
  ~"callee3 (strarg=0x400730 \"A string argument.\") at src/gdb/testsuite/gdb.mi/basics.c:35\n"
  ~"35\t}\n"
 +~"Value returned is $1 = 0\n"
  *stopped,reason="function-finished",frame=...,gdb-result-var="$1",return-value="0",thread-id="1",stopped-threads="all",core="0"
 -FAIL: gdb.mi/mi-cli.exp: CLI finish: check CLI output
 +PASS: gdb.mi/mi-cli.exp: CLI finish: check CLI output

gdb/ChangeLog:
2015-09-09  Pedro Alves  <palves@redhat.com>

	* Makefile.in (COMMON_OBS): Add thread-fsm.o.
	* breakpoint.c (handle_jit_event): Print debug output.
	(bpstat_what): Split event callback handling to ...
	(bpstat_run_callbacks): ... this new function.
	(momentary_bkpt_print_it): No longer handle bp_finish here.
	* breakpoint.h (bpstat_run_callbacks): Declare.
	* gdbthread.h (struct thread_info) <step_multi>: Delete field.
	<thread_fsm>: New field.
	(thread_cancel_execution_command): Declare.
	* infcmd.c: Include thread-fsm.h.
	(struct step_command_fsm): New.
	(step_command_fsm_ops): New global.
	(new_step_command_fsm, step_command_fsm_prepare): New functions.
	(step_1): Adjust to use step_command_fsm_prepare and
	prepare_one_step.
	(struct step_1_continuation_args): Delete.
	(step_1_continuation): Delete.
	(step_command_fsm_should_stop): New function.
	(step_once): Delete.
	(step_command_fsm_clean_up, step_command_fsm_async_reply_reason)
	(prepare_one_step): New function, based on step_once.
	(until_next_command): Remove step_multi reference.
	(struct return_value_info): New.
	(print_return_value): Rename to ...
	(print_return_value_1): ... this.  New struct return_value_info
	parameter.  Adjust.
	(print_return_value): Reimplement as wrapper around
	print_return_value_1.
	(struct finish_command_fsm): New.
	(finish_command_continuation): Delete.
	(finish_command_fsm_ops): New global.
	(new_finish_command_fsm, finish_command_fsm_should_stop): New
	functions.
	(finish_command_fsm_clean_up, finish_command_fsm_return_value):
	New.
	(finish_command_continuation_free_arg): Delete.
	(finish_command_fsm_async_reply_reason): New.
	(finish_backward, finish_forward): Change symbol parameter to a
	finish_command_fsm.  Adjust.
	(finish_command): Create a finish_command_fsm.  Adjust.
	* infrun.c: Include "thread-fsm.h".
	(clear_proceed_status_thread): Delete the thread's FSM.
	(infrun_thread_stop_requested_callback): Cancel the thread's
	execution command.
	(clean_up_just_stopped_threads_fsms): New function.
	(fetch_inferior_event): Handle the event_thread's should_stop
	method saying the command isn't done yet.
	(process_event_stop_test): Run breakpoint callbacks here.
	(print_stop_event): Rename to ...
	(print_stop_location): ... this.
	(restore_current_uiout_cleanup): New function.
	(print_stop_event): Reimplement.
	(normal_stop): No longer notify the end_stepping_range observers
	here handle "step N" nor "finish" here.  No longer call
	print_stop_event here.
	* infrun.h (struct return_value_info): Forward declare.
	(print_return_value): Declare.
	(print_stop_event): Change prototype.
	* thread-fsm.c: New file.
	* thread-fsm.h: New file.
	* thread.c: Include "thread-fsm.h".
	(thread_cancel_execution_command): New function.
	(clear_thread_inferior_resources): Call it.
	* cli/cli-interp.c (cli_on_normal_stop): New function.
	(cli_interpreter_init): Install cli_on_normal_stop as normal_stop
	observer.
	* mi/mi-interp.c: Include "thread-fsm.h".
	(restore_current_uiout_cleanup): Delete.
	(mi_on_normal_stop): If the thread has an FSM associated, and it
	finished, ask it for the async-reply-reason to print.  Always call
	print_stop_event here, regardless of the top-level interpreter.
	Check bpstat_what to tell whether an asynchronous breakpoint hit
	triggered.
	* tui/tui-interp.c (tui_on_normal_stop): New function.
	(tui_init): Install tui_on_normal_stop as normal_stop observer.

gdb/testsuite/ChangeLog:
2015-09-09  Pedro Alves  <palves@redhat.com>

	* gdb.mi/mi-cli.exp: Add CLI finish tests.
2015-09-09 18:24:00 +01:00
Keith Seitz f00aae0f7b Explicit locations: use new location API
This patch converts the code base to use the new struct event_location
API being introduced. This patch preserves the current functionality and
adds no new features.

The "big picture" API usage introduced by this patch may be illustrated
with a simple exmaple. Where previously developers would write:

void
my_command (char *arg, int from_tty)
{
   create_breakpoint (..., arg, ...);
   ...
}

one now uses:

void
my_command (char *arg, int from_tty)
{
   struct event_locaiton *location;
   struct cleanup *back_to;

   location = string_to_event_locaiton (&arg, ...);
   back_to = make_cleanup_delete_event_location (location);
   create_breakpoint (..., location, ...);
   do_cleanups (back_to);
}

Linespec-decoding functions (now called location-decoding) such as
decode_line_full no longer skip argument pointers over processed input.
That functionality has been moved into string_to_event_location as
demonstrated above.

gdb/ChangeLog

	* ax-gdb.c: Include location.h.
	(agent_command_1) Use linespec location instead of address
	string.
	* break-catch-throw.c: Include location.h.
	(re_set_exception_catchpoint): Use linespec locations instead
	of address strings.
	* breakpoint.c: Include location.h.
	(create_overlay_event_breakpoint, create_longjmp_master_breakpoint)
	(create_std_terminate_master_breakpoint)
	(create_exception_master_breakpoint, update_breakpoints_after_exec):
	Use linespec location instead of address string.
	(print_breakpoint_location):  Use locations and
	event_location_to_string.
	Print extra_string for pending locations for non-MI streams.
	(print_one_breakpoint_location): Use locations and
	event_location_to_string.
	(init_raw_breakpoint_without_location): Initialize b->location.
	(create_thread_event_breakpoint): Use linespec location instead of
	address string.
	(init_breakpoint_sal): Likewise.
	Only save extra_string if it is non-NULL and not the empty string.
	Use event_location_to_string instead of `addr_string'.
	Constify `p' and `endp'.
	Use skip_spaces_const/skip_space_const instead of non-const versions.
	Copy the location into the breakpoint.
	If LOCATION is NULL, save the breakpoint address as a linespec location
	instead of an address string.
	(create_breakpoint_sal): Change `addr_string' parameter to a struct
	event_location. All uses updated.
	(create_breakpoints_sal): Likewise for local variable `addr_string'.
	(parse_breakpoint_sals): Use locations instead of address strings.
	Remove check for empty linespec with conditional.
	Refactor.
	(decode_static_tracepoint_spec): Make argument const and update
	function.
	(create_breakpoint): Change `arg' to a struct event_location and
	rename.
	Remove `copy_arg' and `addr_start'.
	If EXTRA_STRING is empty, set it to NULL.
	Don't populate `canonical' for pending breakpoints.
	Pass `extra_string' to find_condition_and_thread.
	Clear `extra_string' if `rest' was NULL.
	Do not error with "garbage after location" if setting a dprintf
	breakpoint.
	Copy the location into the breakpoint instead of an address string.
	(break_command_1): Use string_to_event_location and pass this to
	create_breakpoint instead of an address string.
	Check against `arg_cp' for a probe linespec.
	(dprintf_command): Use string_to_event_location and pass this to
	create_breakpoint instead of an address string.
	Throw an exception if no format string was specified.
	(print_recreate_ranged_breakpoint): Use event_location_to_string
	instead of address strings.
	(break_range_command, until_break_command)
	(init_ada_exception_breakpoint): Use locations instead
	of address strings.
	(say_where): Print out extra_string for pending locations.
	(base_breakpoint_dtor): Delete `location' and `location_range_end' of
	the breakpoint.
	(base_breakpoint_create_sals_from_location): Use struct event_location
	instead of address string.
	Remove `addr_start' and `copy_arg' parameters.
	(base_breakpoint_decode_location): Use struct event_location instead of
	address string.
	(bkpt_re_set): Use locations instead of address strings.
	Use event_location_empty_p to check for unset location.
	(bkpt_print_recreate): Use event_location_to_string instead of
	an address string.
	Print out extra_string for pending locations.
	(bkpt_create_sals_from_location, bkpt_decode_location)
 	(bkpt_probe_create_sals_from_location): Use struct event_location
	instead of address string.
	(bkpt_probe_decode_location): Use struct event_location instead of
	address string.
	(tracepoint_print_recreate): Use event_location_to_string to
	recreate the tracepoint.
	(tracepoint_create_sals_from_location, tracepoint_decode_location)
	(tracepoint_probe_create_sals_from_location)
	(tracepoint_probe_decode_location): Use struct event_location
	instead of address string.
	(dprintf_print_recreate): Use event_location_to_string to recreate
	the dprintf.
	(dprintf_re_set): Remove check for valid/missing format string.
	(strace_marker_create_sals_from_location)
	(strace_marker_create_breakpoints_sal, strace_marker_decode_location)
	(update_static_tracepoint): Use struct event_location instead of
	address string.
	(location_to_sals): Likewise.
	Pass `extra_string' to find_condition_and_thread.
	For newly resolved pending breakpoint locations, clear the location's
	string representation.
	Assert that the breakpoint's condition string is NULL when
	condition_not_parsed.
	(breakpoint_re_set_default, create_sals_from_location_default)
	(decode_location_default, trace_command, ftrace_command)
	(strace_command, create_tracepoint_from_upload): Use locations
	instead of address strings.
	* breakpoint.h (struct breakpoint_ops) <create_sals_from_location>:
	Use struct event_location instead of address string.
	Update all uses.
	<decode_location>: Likewise.
	(struct breakpoint) <addr_string>: Change to struct event_location
	and rename `location'.
	<addr_string_range_end>: Change to struct event_location and rename
	`location_range_end'.
	(create_breakpoint): Use struct event_location instead of address
	string.
	* cli/cli-cmds.c: Include location.h.
	(edit_command, list_command): Use locations instead of address strings.
	* elfread.c: Include location.h.
	(elf_gnu_ifunc_resolver_return_stop): Use event_location_to_string.
	* guile/scm-breakpoint.c: Include location.h.
	(bpscm_print_breakpoint_smob): Use event_location_to_string.
	(gdbscm_register_breakpoint): Use locations instead of address
	strings.
	* linespec.c: Include location.h.
	(struct ls_parser) <stream>: Change to const char *.
	(PARSER_STREAM): Update.
	(lionespec_lexer_lex_keyword): According to find_condition_and_thread,
	keywords must be followed by whitespace.
	(canonicalize_linespec): Save a linespec location into `canonical'.
	Save a canonical linespec into `canonical'.
	(parse_linespec): Change `argptr' to const char * and rename `arg'.
	All uses updated.
	Update function description.
	(linespec_parser_new): Initialize `parser'.
	Update initialization of  parsing stream.
	(event_location_to_sals): New function.
	(decode_line_full): Change `argptr' to a struct event_location and
	rename it `location'.
	Use locations instead of address strings.
	Call event_location_to_sals instead of parse_linespec.
	(decode_line_1): Likewise.
	(decode_line_with_current_source, decode_line_with_last_displayed)
	Use locations instead of address strings.
	(decode_objc): Likewise.
	Change `argptr' to const char * and rename `arg'.
	(destroy_linespec_result): Delete the linespec result's location
	instead of freeing the address string.
	* linespec.h (struct linespec_result) <addr_string>: Change to
	struct event_location and rename to ...
	<location>: ... this.
	(decode_line_1, decode_line_full): Change `argptr' to struct
	event_location.  All callers updated.
	* mi/mi-cmd-break.c: Include language.h, location.h, and linespec.h.
	(mi_cmd_break_insert_1): Use locations instead of address strings.
	Throw an error if there was "garbage" at the end of the specified
	linespec.
	* probe.c: Include location.h.
	(parse_probes): Change `argptr' to struct event_location.
	Use event locations instead of address strings.
	* probe.h (parse_probes): Change `argptr' to struct event_location.
	* python/py-breakpoint.c: Include location.h.
	(bppy_get_location): Constify local variable `str'.
	Use event_location_to_string.
	(bppy_init): Use locations instead of address strings.
	* python/py-finishbreakpoint.c: Include location.h.
	(bpfinishpy_init): Remove local variable `addr_str'.
	Use locations instead of address strings.
	* python/python.c: Include location.h.
	(gdbpy_decode_line): Use locations instead of address strings.
	* remote.c: Include location.h.
	(remote_download_tracepoint): Use locations instead of address
	strings.
	* spu-tdep.c: Include location.h.
	(spu_catch_start): Remove local variable `buf'.
	Use locations instead of address strings.
	* tracepoint.c: Include location.h.
	(scope_info): Use locations instead of address strings.
	(encode_source_string): Constify parameter `src'.
	* tracepoint.h (encode_source_string): Likewise.

gdb/testsuite/ChangeLog

	* gdb.base/dprintf-pending.exp: Update dprintf "without format"
	test.
	Add tests for missing ",FMT" and ",".
2015-08-11 17:09:35 -07:00
Keith Seitz 5f700d83f7 Explicit locations: rename "address string"/"addr_string" to "location"
This patch renames all occurrances of "addr_string" and "address
string" in the breakpoint/linespec APIs.  This will emphasize the
change from address strings used in setting breakpoints (et al) to the
new locations-based API introduced in subsequent patches.

gdb/ChangeLog:

	* breakpoint.h (struct breakpoint_ops) <create_sals_from_address>:
	Renamed to create_sals_from_location.
	<decode_linespec>: Renamed to decode_location.
	Update all callers.
	* breakpoint.c (create_sals_from_address_default): Renamed to ...
	(create_sals_from_location_default): ... this.
	(addr_string_to_sals): Renamed to ...
	(location_to_sals): ... this.
	(decode_linespec_default): Renamed to ...
	(decode_location_default): ... this.
	(base_breakpoint_create_sals_from_address): Renamed to ...
	(base_breakpoint_create_sals_from_location): ... this.
	(bkpt_create_sals_from_address): Renamed to ...
	(bkpt_create_sals_from_location): ... this.
	(bkpt_decode_linespec): Renamed to ...
	(bkpt_decode_location): ... this.
	(bkpt_probe_create_sals_from_address): Renamed to ...
	(bkpt_probe_create_sals_from_location): ... this.
	(tracepoint_create_sals_from_address): Renamed to ...
	(tracepoint_create_sals_from_location): ... this.
	(tracepoint_decode_linespec): Renamed to ...
	(tracepoint_decode_location): ... this.
	(tracepoint_probe_create_sals_from_address): Renamed to ...
	(tracepoint_probe_create_sals_from_location): ... this.
	(tracepoint_probe_decode_linespec): Renamed to ...
	(tracepoint_probe_decode_location): ... this.
	(strace_marker_create_sals_from_address): Renamed to ...
	(strace_marker_create_sals_from_location): ... this.
	(decode_linespec_default): Renamed to ...
	(decode_location_default): ... this.
2015-08-11 17:09:35 -07:00
Luis Machado da4616f69f Remove unused function make_breakpoint_permanent.
make_breakpoint_permanent is no longer used anywhere and can be
safely removed.

gdb/ChangeLog:

2015-06-17  Luis Machado  <lgustavo@codesourcery.com>

	* breakpoint.c (make_breakpoint_permanent): Remove unused
	function.
	* breakpoint.h (make_breakpoint_permanent): Remove declaration.
2015-06-17 16:09:24 -03:00
Pedro Alves 7a26bd4d83 constify set_breakpoint_condition
gdb:

2015-03-20  Pedro Alves  <palves@redhat.com>

	* breakpoint.c (set_breakpoint_condition): Make argument "exp" const.
	* breakpoint.h (set_breakpoint_condition): Update declaration.
2015-03-20 17:39:24 +00:00
Sergio Durigan Junior badd37cec8 Implement breakpoint_find_if
This commit implements the 'breakpoint_find_if' function, which allows
code external to gdb/breakpoint.c to iterate through the list of
'struct breakpoint *'.  This is needed in order to create the
'gdb/break-catch-syscall.c' file, because one of its functions
(catching_syscall_number) needs to do this iteration.

My first thought was to share the ALL_BREAKPOINTS* macros on
gdb/breakpoint.h, but they use a global variable local to
gdb/breakpoint.c, and I did not want to share that variable.  So, in
order to keep the minimal separation, I decided to implement this
way of iterating through the existing 'struct breakpoint *'.

This function was based on BFD's bfd_sections_find_if.  If the
user-provided function returns 0, the iteration proceeds.  Otherwise,
the iteration stops and the function returns the 'struct breakpoint *'
that is being processed.  This means that the return value of this
function can be either NULL or a pointer to a 'struct breakpoint'.

gdb/ChangeLog:
2015-03-11  Sergio Durigan Junior  <sergiodj@redhat.com>

	* breakpoint.c (breakpoint_find_if): New function.
	* breakpoint.h (breakpoint_find_if): New prototype.
2015-03-11 14:13:49 -04:00
Pedro Alves 1cf4d9513a Teach GDB about targets that can tell whether a trap is a breakpoint event
The moribund locations heuristics are problematic.  This patch teaches
GDB about targets that can reliably tell whether a trap was caused by
a software or hardware breakpoint, and thus don't need moribund
locations, thus bypassing all the problems that mechanism has.

The non-stop-fair-events.exp test is frequently failing currently.
E.g., see https://sourceware.org/ml/gdb-testers/2015-q1/msg03148.html.

The root cause is a fundamental problem with moribund locations.  For
example, the stepped_breakpoint logic added by af48d08f breaks in this
case (which is what happens with that test):

 - Step thread A, no breakpoint is set at PC.

 - The kernel doesn't schedule thread A yet.

 - Insert breakpoint at A's PC, for some reason (e.g., a step-resume
   breakpoint for thread B).

 - Kernel finally schedules thread A.

 - thread A's stepped_breakpoint flag is not set, even though it now
   stepped a breakpoint instruction.

 - adjust_pc_after_break gets the PC wrong, because PC == PREV_PC, but
   stepped_breakpoint is not set.

We needed the stepped_breakpoint logic to workaround moribund
locations, because otherwise adjust_pc_after_break could apply an
adjustment when it shouldn't just because there _used_ to be a
breakpoint at PC (a moribund breakpoint location).  For example, on
x86, that's wrong if the thread really hasn't executed an int3, but
instead executed some other 1-byte long instruction.  Getting the PC
adjustment wrong of course leads to the inferior executing the wrong
instruction.

Other problems with moribund locations are:

 - if a true SIGTRAP happens to be raised when the program is
   executing the PC that used to have a breakpoint, GDB will assume
   that is a trap for a breakpoint that has recently been removed, and
   thus we miss reporting the random signal to the user.

 - to minimize that, we get rid of moribund location after a while.
   That while is defined as just a certain number of events being
   processed.  That number of events sometimes passes by before a
   delayed breakpoint is processed, and GDB confuses the trap for a
   random signal, thus reporting the random trap.  Once the user
   resumes the thread, the program crashes because the PC was not
   adjusted...

The fix for all this is to bite the bullet and get rid of heuristics
and instead rely on the target knowing accurately what caused the
SIGTRAP.  The target/kernel/stub is in the best position to know what
that, because it can e.g. consult priviledged CPU flags GDB has no
access to, or by knowing which exception vector entry was called when
the instruction trapped, etc.  Most debug APIs I've seen to date
report breakpoint hits as a distinct event in some fashion.  For
example, on the Linux kernel, whether a breakpoint was executed is
exposed to userspace in the si_code field of the SIGTRAP's siginfo.
On Windows, the debug API reports a EXCEPTION_BREAKPOINT exception
code.

We needed to keep around deleted breakpoints in an on-the-side list
(the moribund locations) for two main reasons:

  - Know that a SIGTRAP actually is a delayed event for a hit of a
    breakpoint that was removed before the event was processed, and
    thus should not be reported as a random signal.

  - So we still do the decr_pc_after_break adjustment in that case, so
    that the thread is resumed at the correct address.

In the new model, if GDB processes an event the target tells is a
breakpoint trap, and GDB doesn't find the corresponding breakpoint in
its breakpoint tables, it means that event is a delayed event for a
breakpoint that has since been removed, and thus the event should be
ignored.

For the decr_pc_after_after issue, it ends up being much simpler that
on targets that can reliably tell whether a breakpoint trapped, for
the breakpoint trap to present the PC already adjusted.  Proper
multi-threading support already implies that targets needs to be doing
decr_pc_after_break adjustment themselves, otherwise for example, in
all-stop if two threads hit a breakpoint simultaneously, and the user
does "info threads", he'll see the non-event thread that hit the
breakpoint stopped at the wrong PC.

This way (target adjusts) also ends up eliminating the need for some
awkward re-incrementing of the PC in the record-full and Linux targets
that we do today, and the need for the target_decr_pc_after_break
hook.

If the target always adjusts, then there's a case where GDB needs to
re-increment the PC.  Say, on x86, an "int3" instruction that was
explicitly written in the program traps.  In this case, GDB should
report a random SIGTRAP signal to the user, with the PC pointing at
the instruction past the int3, just like if GDB was not debugging the
program.  The user may well decide to pass the SIGTRAP to the program
because the program being debugged has a SIGTRAP handler that handles
its own breakpoints, and expects the PC to be unadjusted.

Tested on x86-64 Fedora 20.

gdb/ChangeLog:
2015-03-04  Pedro Alves  <palves@redhat.com>

	* breakpoint.c (need_moribund_for_location_type): New function.
	(bpstat_stop_status): Don't skipping checking moribund locations
	of breakpoint types which the target tell caused a stop.
	(program_breakpoint_here_p): New function, factored out from ...
	(bp_loc_is_permanent): ... this.
	(update_global_location_list): Don't create a moribund location if
	the target supports reporting stops of the type of the removed
	breakpoint.
	* breakpoint.h (program_breakpoint_here_p): New declaration.
	* infrun.c (adjust_pc_after_break): Return early if the target has
	already adjusted the PC.  Add comments.
	(handle_signal_stop): If nothing explains a signal, and the target
	tells us the stop was caused by a software breakpoint, check if
	there's a breakpoint instruction in the memory.  If so, adjust the
	PC before presenting the stop to the user.  Otherwise, ignore the
	trap.  If nothing explains a signal, and the target tells us the
	stop was caused by a hardware breakpoint, ignore the trap.
	* target.h (struct target_ops) <to_stopped_by_sw_breakpoint,
	to_supports_stopped_by_sw_breakpoint, to_stopped_by_hw_breakpoint,
	to_supports_stopped_by_hw_breakpoint>: New fields.
	(target_stopped_by_sw_breakpoint)
	(target_supports_stopped_by_sw_breakpoint)
	(target_stopped_by_hw_breakpoint)
	(target_supports_stopped_by_hw_breakpoint): Define.
	* target-delegates.c: Regenerate.
2015-03-04 20:41:15 +00:00
Pedro Alves 64166036b3 breakpoint.h: move enum ‘print_stop_action’
Building GDB in C++, we get:

  src/gdb/breakpoint.h:529:8: error: use of enum ‘print_stop_action’ without previous declaration

We can't forward declare enums in C++.

gdb/ChangeLog:
2015-02-27  Pedro Alves  <palves@redhat.com>

	* breakpoint.h (enum print_stop_action): Move further up in the
	file.
2015-02-27 17:40:35 +00:00
Pedro Alves 9c02b52532 linux-nat.c: better starvation avoidance, handle non-stop mode too
Running the testsuite with a series that reimplements user-visible
all-stop behavior on top of a target running in non-stop mode revealed
problems related to event starvation avoidance.

For example, I see
gdb.threads/signal-while-stepping-over-bp-other-thread.exp failing.
What happens is that GDB core never gets to see the signal event.  It
ends up processing the events for the same threads over an over,
because Linux's waitpid(-1, ...) returns that first task in the task
list that has an event, starving threads on the tail of the task list.

So I wrote a non-stop mode test originally inspired by
signal-while-stepping-over-bp-other-thread.exp, to stress this
independently of all-stop on top of non-stop.  Fixing it required the
changes described below.  The test will be added in a following
commit.

1) linux-nat.c has code in place that picks an event LWP at random out
of all that have had events.  This is because on the kernel side,
"waitpid(-1, ...)"  just walks the task list linearly looking for the
first that had an event.  But, this code is currently only used in
all-stop mode.  So with a multi-threaded program that has multiple
events triggering debug events in parallel, GDB ends up starving some
threads.

To make the event randomization work in non-stop mode too, the patch
makes us pull out all the already pending events on the kernel side,
with waitpid, before deciding which LWP to report to the core.

There's some code in linux_wait that takes care of leaving events
pending if they were for LWPs the caller is not interested in.  The
patch moves that to linux_nat_filter_event, so that we only have one
place that leaves events pending.  With that in place, conceptually,
the flow is simpler and more normalized:

 #1 - walk the LWP list looking for an LWP with a pending event to report.
 #2 - if no pending event, pull events out of the kernel, and store
      them in the LWP structures as pending.
 #3- goto #1.

2) Then, currently the event randomization code only considers SIGTRAP
(or trap-like) events.  That means that if e.g., have have multiple
threads stepping in parallel that hit a breakpoint that needs stepping
over, and one gets a signal, the signal may end up never getting
processed, because GDB will always be giving priority to the SIGTRAPs.
The patch fixes this by making the randomization code consider all
kinds of pending events.

3) If multiple threads hit a breakpoint, we report one of those, and
"cancel" the others.  Cancelling means decrementing the PC, and
discarding the event.  If the next time the LWP is resumed the
breakpoint is still installed, the LWP should hit it again, and we'll
report the hit then.  The problem I found is that this delays threads
from advancing too much, with the kernel potentially ending up
scheduling the same threads over and over, and others not advancing.
So the patch switches away from cancelling the breakpoints, and
instead remembering that the LWP had stopped for a breakpoint.  If on
resume the breakpoint is still installed, we report it.  If it's no
longer installed, we discard the pending event then.  This is actually
how GDBserver used to handle this before d50171e4 (Teach linux
gdbserver to step-over-breakpoints), but with the difference that back
then we'd delay adjusting the PC until resuming, which made it so that
"info threads" could wrongly see threads with unadjusted PCs.

gdb/
2015-01-09  Pedro Alves  <palves@redhat.com>

	* breakpoint.c (hardware_breakpoint_inserted_here_p): New
	function.
	* breakpoint.h (hardware_breakpoint_inserted_here_p): New
	declaration.
	* linux-nat.c (linux_nat_status_is_event): Move higher up in file.
	(linux_resume_one_lwp): Store the thread's PC.  Adjust to clear
	stop_reason.
	(check_stopped_by_watchpoint): New function.
	(save_sigtrap): Reimplement.
	(linux_nat_stopped_by_watchpoint): Adjust.
	(linux_nat_lp_status_is_event): Delete.
	(stop_wait_callback): Only call save_sigtrap after storing the
	pending status.
	(status_callback): If the thread had been stopped for a breakpoint
	that has since been removed, discard the event and resume the LWP.
	(count_events_callback, select_event_lwp_callback): Use
	lwp_status_pending_p instead of linux_nat_lp_status_is_event.
	(cancel_breakpoint): Rename to ...
	(check_stopped_by_breakpoint): ... this.  Record whether the LWP
	stopped for a software breakpoint or hardware breakpoint.
	(select_event_lwp): Only give preference to the stepping LWP in
	all-stop mode.  Adjust comments.
	(stop_and_resume_callback): Remove references to new_pending_p.
	(linux_nat_filter_event): Likewise.  Leave exit events of the
	leader thread pending here.  Handle signal short circuiting here.
	Only call save_sigtrap after storing the pending waitstatus.
	(linux_nat_wait_1): Remove 'retry' label.  Remove references to
	new_pending.  Don't handle leaving events the caller is not
	interested in pending here, nor handle signal short-circuiting
	here.  Also give equal priority to all LWPs that have had events
	in non-stop mode.  If reporting a software breakpoint event,
	unadjust the LWP's PC.
	* linux-nat.h (enum lwp_stop_reason): New.
	(struct lwp_info) <stop_pc>: New field.
	(struct lwp_info) <stopped_by_watchpoint>: Delete field.
	(struct lwp_info) <stop_reason>: New field.
	* x86-linux-nat.c (x86_linux_prepare_to_resume): Adjust.
2015-01-09 14:42:03 +00:00
Joel Brobecker 32d0add0a6 Update year range in copyright notice of all files owned by the GDB project.
gdb/ChangeLog:

        Update year range in copyright notice of all files.
2015-01-01 13:32:14 +04:00
Pedro Alves 1a853c5224 make "permanent breakpoints" per location and disableable
"permanent"-ness is currently a property of the breakpoint.  But, it
should actually be an implementation detail of a _location_.  Consider
this bit in infrun.c:

  /* Normally, by the time we reach `resume', the breakpoints are either
     removed or inserted, as appropriate.  The exception is if we're sitting
     at a permanent breakpoint; we need to step over it, but permanent
     breakpoints can't be removed.  So we have to test for it here.  */
  if (breakpoint_here_p (aspace, pc) == permanent_breakpoint_here)
    {
      if (gdbarch_skip_permanent_breakpoint_p (gdbarch))
	gdbarch_skip_permanent_breakpoint (gdbarch, regcache);
      else
	error (_("\
The program is stopped at a permanent breakpoint, but GDB does not know\n\
how to step past a permanent breakpoint on this architecture.  Try using\n\
a command like `return' or `jump' to continue execution."));
    }

This will wrongly skip a non-breakpoint instruction if we have a
multiple location breakpoint where the whole breakpoint was set to
"permanent" because one of the locations happened to be permanent,
even if the one GDB is resuming from is not.

Related, because the permanent breakpoints are only marked as such in
init_breakpoint_sal, we currently miss marking momentary breakpoints
as permanent.  A test added by a following patch trips on that.
Making permanent-ness be per-location, and marking locations as such
in add_location_to_breakpoint, the natural place to do this, fixes
this issue...

... and then exposes a latent issue with mark_breakpoints_out.  It's
clearing the inserted flag of permanent breakpoints.  This results in
assertions failing like this:

 Breakpoint 1, main () at testsuite/gdb.base/callexit.c:32
 32        return 0;
 (gdb) call callexit()
 [Inferior 1 (process 15849) exited normally]
 gdb/breakpoint.c:12854: internal-error: allegedly permanent breakpoint is not actually inserted
 A problem internal to GDB has been detected,
 further debugging may prove unreliable.

The call dummy breakpoint, which is a momentary breakpoint, is set on
top of a manually inserted breakpoint instruction, and so is now
rightfully marked as a permanent breakpoint.  See "Write a legitimate
instruction at the point where the infcall breakpoint is going to be
inserted." comment in infcall.c.

Re. make_breakpoint_permanent.  That's only called by solib-pa64.c.
Permanent breakpoints were actually originally invented for HP-UX [1].
I believe that that call (the only one in the tree) is unnecessary
nowadays, given that nowadays the core breakpoints code analyzes the
instruction under the breakpoint to automatically detect whether it's
setting a breakpoint on top of a breakpoint instruction in the
program.  I know close to nothing about HP-PA/HP-UX, though.

[1] https://sourceware.org/ml/gdb-patches/1999-q3/msg00245.html, and
    https://sourceware.org/ml/gdb-patches/1999-q3/msg00242.html

In addition to the per-location issue, "permanent breakpoints" are
currently always displayed as enabled=='n':

 (gdb) b main
 Breakpoint 3 at 0x40053c: file ../../../src/gdb/testsuite/gdb.arch/i386-permbkpt.S, line 29.
 (gdb) info breakpoints
 Num     Type           Disp Enb Address            What
 3       breakpoint     keep n   0x000000000040053c ../../../src/gdb/testsuite/gdb.arch/i386-permbkpt.S:29

But OTOH they're always enabled; there's no way to disable them...

In turn, this means that if one adds commands to such a breakpoint,
they're _always_ run:

 (gdb) start
 Starting program: /home/pedro/gdb/mygit/build/gdb/testsuite/gdb.arch/i386-permbkpt
 ...
 Temporary breakpoint 1, main () at ../../../src/gdb/testsuite/gdb.arch/i386-permbkpt.S:29
 29              int3
 (gdb) b main
 Breakpoint 2 at 0x40053c: file ../../../src/gdb/testsuite/gdb.arch/i386-permbkpt.S, line 29.
 (gdb) info breakpoints
 Num     Type           Disp Enb Address            What
 2       breakpoint     keep n   0x000000000040053c ../../../src/gdb/testsuite/gdb.arch/i386-permbkpt.S:29
 (gdb) commands
 Type commands for breakpoint(s) 2, one per line.
 End with a line saying just "end".
 >echo "hello!"
 >end
 (gdb) disable 2
 (gdb) start
 The program being debugged has been started already.
 Start it from the beginning? (y or n) y
 Temporary breakpoint 3 at 0x40053c: file ../../../src/gdb/testsuite/gdb.arch/i386-permbkpt.S, line 29.
 Starting program: /home/pedro/gdb/mygit/build/gdb/testsuite/gdb.arch/i386-permbkpt

 Breakpoint 2, main () at ../../../src/gdb/testsuite/gdb.arch/i386-permbkpt.S:29
 29              int3
 "hello!"(gdb)

IMO, one should be able to disable such a breakpoint, and GDB should
then behave just like if the user hadn't created the breakpoint in the
first place (that is, report a SIGTRAP).

By making permanent-ness a property of the location, and eliminating
the bp_permanent enum enable_state state ends up fixing that as well.

No tests are added for these changes yet; they'll be added in a follow
up patch, as skipping permanent breakpoints is currently broken and
trips on an assertion in infrun.

Tested on x86_64 Fedora 20, native and gdbserver.

gdb/ChangeLog:
2014-11-12  Pedro Alves  <palves@redhat.com>

	Mark locations as permanent, not the whole breakpoint.
	* breakpoint.c (remove_breakpoint_1, remove_breakpoint): Adjust.
	(mark_breakpoints_out): Don't mark permanent breakpoints as
	uninserted.
	(breakpoint_init_inferior): Use mark_breakpoints_out.
	(breakpoint_here_p): Adjust.
	(bpstat_stop_status, describe_other_breakpoints): Remove handling
	of permanent breakpoints.
	(make_breakpoint_permanent): Mark each location as permanent,
	instead of marking the breakpoint.
	(add_location_to_breakpoint): If the location is permanent, mark
	it as such, and as inserted.
	(init_breakpoint_sal): Don't make the breakpoint permanent here.
	(bp_location_compare, update_global_location_list): Adjust.
	(update_breakpoint_locations): Don't make the breakpoint permanent
	here.
	(disable_breakpoint, enable_breakpoint_disp): Don't skip permanent
	breakpoints.
	* breakpoint.h (enum enable_state) <bp_permanent>: Delete field.
	(struct bp_location) <permanent>: New field.
	* guile/scm-breakpoint.c (bpscm_enable_state_to_string): Remove
	reference to bp_permanent.
2014-11-12 10:37:57 +00:00
Pedro Alves 441ef17f09 garbage collect gdb/breakpoint.c:breakpoint_thread_match
Used to be necessary for the thread-hop code, but that's gone now.
Nothing uses this anymore.

gdb/
2014-11-04  Pedro Alves  <palves@redhat.com>

	* breakpoint.c (breakpoint_thread_match): Delete function.
	* breakpoint.h (breakpoint_thread_match): Delete declaration.
2014-11-04 18:42:28 +00:00
Pedro Alves 34b7e8a6ad Make single-step breakpoints be per-thread
This patch finally makes each thread have its own set of single-step
breakpoints.  This paves the way to have multiple threads software
single-stepping, though this patch doesn't flip that switch on yet.
That'll be done on a subsequent patch.

gdb/
2014-10-15  Pedro Alves  <palves@redhat.com>

	* breakpoint.c (single_step_breakpoints): Delete global.
	(insert_single_step_breakpoint): Adjust to store the breakpoint
	pointer in the current thread.
	(single_step_breakpoints_inserted, remove_single_step_breakpoints)
	(cancel_single_step_breakpoints): Delete functions.
	(breakpoint_has_location_inserted_here): Make extern.
	(single_step_breakpoint_inserted_here_p): Adjust to walk the
	breakpoint list.
	* breakpoint.h (breakpoint_has_location_inserted_here): New
	declaration.
	(single_step_breakpoints_inserted, remove_single_step_breakpoints)
	(cancel_single_step_breakpoints): Remove declarations.
	* gdbthread.h (struct thread_control_state)
	<single_step_breakpoints>: New field.
	(delete_single_step_breakpoints)
	(thread_has_single_step_breakpoints_set)
	(thread_has_single_step_breakpoint_here): New declarations.
	* infrun.c (follow_exec): Also clear the single-step breakpoints.
	(singlestep_breakpoints_inserted_p, singlestep_ptid)
	(singlestep_pc): Delete globals.
	(infrun_thread_ptid_changed): Remove references to removed
	globals.
	(resume_cleanups): Delete the current thread's single-step
	breakpoints.
	(maybe_software_singlestep): Remove references to removed globals.
	(resume): Adjust to use thread_has_single_step_breakpoints_set and
	delete_single_step_breakpoints.
	(init_wait_for_inferior): Remove references to removed globals.
	(delete_thread_infrun_breakpoints): Delete the thread's
	single-step breakpoints too.
	(delete_just_stopped_threads_infrun_breakpoints): Don't delete
	single-step breakpoints here.
	(delete_stopped_threads_single_step_breakpoints): New function.
	(adjust_pc_after_break): Adjust to use
	thread_has_single_step_breakpoints_set.
	(handle_inferior_event): Remove references to removed globals.
	Use delete_stopped_threads_single_step_breakpoints.
	(handle_signal_stop): Adjust to per-thread single-step
	breakpoints.  Swap test order to do cheaper tests first.
	(switch_back_to_stepped_thread): Extend debug output.  Remove
	references to removed globals.
	* record-full.c (record_full_wait_1): Adjust to per-thread
	single-step breakpoints.
	* thread.c (delete_single_step_breakpoints)
	(thread_has_single_step_breakpoints_set)
	(thread_has_single_step_breakpoint_here): New functions.
	(clear_thread_inferior_resources): Also delete the thread's
	single-step breakpoints.
2014-10-15 20:18:32 +01:00
Pedro Alves a1fd2fa599 Remove deprecated_insert_raw_breakpoint and friends
There are no users of deprecated_{insert,remove}_raw_breakpoint left.

gdb/
2014-10-15  Pedro Alves  <palves@redhat.com>

	* breakpoint.c (regular_breakpoint_inserted_here_p): Inline ...
	(breakpoint_inserted_here_p): ... here.  Remove special case for
	software single-step breakpoints.
	(find_non_raw_software_breakpoint_inserted_here): Inline ...
	(software_breakpoint_inserted_here_p): ... here.  Remove special
	case for software single-step breakpoints.
	(bp_target_info_copy_insertion_state)
	(deprecated_insert_raw_breakpoint)
	(deprecated_remove_raw_breakpoint): Delete functions.
	* breakpoint.h (deprecated_insert_raw_breakpoint)
	(deprecated_remove_raw_breakpoint): Remove declarations.
2014-10-15 20:18:31 +01:00
Pedro Alves 7c16b83e05 Put single-step breakpoints on the bp_location chain
This patch makes single-step breakpoints "real" breakpoints on the
global location list.

There are several benefits to this:

- It removes the currently limitation that only 2 single-step
  breakpoints can be inserted.  See an example here of a discussion
  around a case that wants more than 2, possibly unbounded:

  https://sourceware.org/ml/gdb-patches/2014-03/msg00663.html

- makes software single-step work on read-only code regions.

  The logic to convert a software breakpoint to a hardware breakpoint
  if the memory map says the breakpoint address is in read only memory
  is in insert_bp_location.  Because software single-step breakpoints
  bypass all that go and straight to target_insert_breakpoint, we
  can't software single-step over read only memory.  This patch
  removes that limitation, and adds a test that makes sure that works,
  by forcing a code region to read-only with "mem LOW HIGH ro" and
  then stepping through that.

- Fixes PR breakpoints/9649

  This is an assertion failure in insert_single_step_breakpoint in
  breakpoint.c, because we may leave stale single-step breakpoints
  behind on error.

  The tests for stepping through read-only regions exercise the root
  cause of the bug, which is that we leave single-step breakpoints
  behind if we fail to insert any single-step breakpoint.  Deleting
  the single-step breakpoints in resume_cleanups,
  delete_just_stopped_threads_infrun_breakpoints, and
  fetch_inferior_event fixes this.  Without that, we'd no longer hit
  the assertion, as that code is deleted, but we'd instead run into
  errors/warnings trying to insert/remove the stale breakpoints on
  next resume.

- Paves the way to have multiple threads software single-stepping at
  the same time, leaving update_global_location_list to worry about
  duplicate locations.

- Makes the moribund location machinery aware of software single-step
  breakpoints, paving the way to enable software single-step on
  non-stop, instead of forcing serialized displaced stepping for all
  single steps.

- It's generaly cleaner.

  We no longer have to play games with single-step breakpoints
  inserted at the same address as regular breakpoints, like we
  recently had to do for 7.8.  See this discussion:

  https://sourceware.org/ml/gdb-patches/2014-06/msg00052.html.

Tested on x86_64 Fedora 20, on top of my 'single-step breakpoints on
x86' series.

gdb/
2014-10-15  Pedro Alves  <palves@redhat.com>

	PR breakpoints/9649
	* breakpoint.c (single_step_breakpoints, single_step_gdbarch):
	Delete array globals.
	(single_step_breakpoints): New global.
	(breakpoint_xfer_memory): Remove special handling for single-step
	breakpoints.
	(update_breakpoints_after_exec): Delete bp_single_step
	breakpoints.
	(detach_breakpoints): Remove special handling for single-step
	breakpoints.
	(breakpoint_init_inferior): Delete bp_single_step breakpoints.
	(bpstat_stop_status): Add comment.
	(bpstat_what, bptype_string, print_one_breakpoint_location)
	(adjust_breakpoint_address, init_bp_location): Handle
	bp_single_step.
	(new_single_step_breakpoint): New function.
	(set_momentary_breakpoint, bkpt_remove_location): Remove special
	handling for single-step breakpoints.
	(insert_single_step_breakpoint, single_step_breakpoints_inserted)
	(remove_single_step_breakpoints, cancel_single_step_breakpoints):
	Rewrite.
	(detach_single_step_breakpoints, find_single_step_breakpoint):
	Delete functions.
	(breakpoint_has_location_inserted_here): New function.
	(single_step_breakpoint_inserted_here_p): Rewrite.
	* breakpoint.h: Remove FIXME.
	(enum bptype) <bp_single_step>: New enum value.
	(insert_single_step_breakpoint): Update comment.
	* infrun.c (resume_cleanups)
	(delete_step_thread_step_resume_breakpoint): Remove single-step
	breakpoints.
	(fetch_inferior_event): Install a cleanup that removes infrun
	breakpoints.
	(switch_back_to_stepped_thread) <expect thread advanced also>:
	Clear step-over info.

gdb/testsuite/
2014-10-15  Pedro Alves  <palves@redhat.com>

	PR breakpoints/9649
	* gdb.base/breakpoint-in-ro-region.c (main): Add more instructions.
	* gdb.base/breakpoint-in-ro-region.exp
	(probe_target_hardware_step): New procedure.
	(top level): Probe hardware stepping and hardware breakpoint
	support.  Test stepping through a read-only region, with both
	"breakpoint auto-hw" on and off and both "always-inserted" on and
	off.
2014-10-15 20:18:31 +01:00
Maciej W. Rozycki 0d5ed15352 Avoid software breakpoint's instruction shadow inconsistency
This change:

commit b775012e84
Author: Luis Machado <luisgpm@br.ibm.com>
Date:   Fri Feb 24 15:10:59 2012 +0000

    2012-02-24  Luis Machado  <lgustavo@codesourcery.com>

	* remote.c (remote_supports_cond_breakpoints): New forward
	declaration.
[...]

changed the way breakpoints are inserted and removed such that
`insert_bp_location' can now be called with the breakpoint being handled
already in place, while previously the call was only ever made for
breakpoints that have not been put in place.  This in turn caused an
issue for software breakpoints and targets for which a breakpoint's
`placed_address' may not be the same as the original requested address.

The issue is `insert_bp_location' overwrites the previously adjusted
value in `placed_address' with the original address, that is only
replaced back with the correct adjusted address later on when
`gdbarch_breakpoint_from_pc' is called.  Meanwhile there's a window
where the value in `placed_address' does not correspond to data stored
in `shadow_contents', leading to incorrect instruction bytes being
supplied when `one_breakpoint_xfer_memory' is called to supply the
instruction overlaid by the breakpoint.

And this is exactly what happens on the MIPS target with software
breakpoints placed in microMIPS code.  In this case not only
`placed_address' is not the original address because of the ISA bit, but
`mips_breakpoint_from_pc' has to read the original instruction to
determine which one of the two software breakpoint instruction encodings
to choose as well.  The 16-bit encoding is used to replace 16-bit
instructions and similarly the 32-bit one is used with 32-bit
instructions, to satisfy branch delay slot size requirements.

The mismatch between `placed_address' and the address data in
`shadow_contents' has been obtained from leads to the wrong encoding
being used in some cases, which in the case of a 32-bit software
breakpoint instruction replacing a 16-bit instruction causes corruption
to the adjacent following instruction and leads the debug session astray
if execution reaches there e.g. with a jump.

To address this problem I made the change below, that adds a
`reqstd_address' field to `struct bp_target_info' and leaves
`placed_address' unchanged once it has been set.  This ensures data in
`shadow_contents' is always consistent with `placed_address'.

This approach also has this good side effect that all the places that
examine the breakpoint's address see a consistent value, either
`reqstd_address' or `placed_address', as required.  Currently some
places see either the original or the adjusted address in
`placed_address', depending on whether they have been called before
`gdbarch_remote_breakpoint_from_pc' or afterwards.  This is in
particular true for subsequent calls to
`gdbarch_remote_breakpoint_from_pc' itself, e.g. from
`one_breakpoint_xfer_memory'.  This is also important for places like
`find_single_step_breakpoint' where a breakpoint's address is compared
to the raw value of $pc.

	* breakpoint.h (bp_target_info): Add `reqstd_address' member,
	update comments.
	* breakpoint.c (one_breakpoint_xfer_memory): Use `reqstd_address'
	for the breakpoint's address.  Don't preinitialize `placed_size'.
	(insert_bp_location): Set `reqstd_address' rather than
	`placed_address'.
	(bp_target_info_copy_insertion_state): Also copy `placed_address'.
	(bkpt_insert_location): Use `reqstd_address' for the breakpoint's
	address.
	(bkpt_remove_location): Likewise.
	(deprecated_insert_raw_breakpoint): Likewise.
	(deprecated_remove_raw_breakpoint): Likewise.
	(find_single_step_breakpoint): Likewise.
	* mem-break.c (default_memory_insert_breakpoint): Use
	`reqstd_address' for the breakpoint's address.  Don't set
	`placed_address' or `placed_size' if breakpoint contents couldn't
	have been determined.
	* remote.c (remote_insert_breakpoint): Use `reqstd_address' for
	the breakpoint's address.
	(remote_insert_hw_breakpoint): Likewise.  Don't set
	`placed_address' or `placed_size' if breakpoint couldn't have been
	set.
	* aarch64-linux-nat.c (aarch64_linux_insert_hw_breakpoint): Use
	`reqstd_address' for the breakpoint's address.
	* arm-linux-nat.c (arm_linux_hw_breakpoint_initialize): Likewise.
	* ia64-tdep.c (ia64_memory_insert_breakpoint): Likewise.
	* m32r-tdep.c (m32r_memory_insert_breakpoint): Likewise.
	* microblaze-linux-tdep.c
	(microblaze_linux_memory_remove_breakpoint): Likewise.
	* monitor.c (monitor_insert_breakpoint): Likewise.
	* nto-procfs.c (procfs_insert_breakpoint): Likewise.
	(procfs_insert_hw_breakpoint): Likewise.
	* ppc-linux-nat.c (ppc_linux_insert_hw_breakpoint): Likewise.
	* ppc-linux-tdep.c (ppc_linux_memory_remove_breakpoint): Likewise.
	* remote-m32r-sdi.c (m32r_insert_breakpoint): Likewise.
	* remote-mips.c (mips_insert_breakpoint): Likewise.
	* x86-nat.c (x86_insert_hw_breakpoint): Likewise.
2014-10-03 12:54:34 +01:00
Pedro Alves b57bacecd5 Fix non-stop regressions caused by "breakpoints always-inserted off" changes
Commit a25a5a45 (Fix "breakpoint always-inserted off"; remove
"breakpoint always-inserted auto") regressed non-stop remote
debugging.

This was exposed by mi-nsintrall.exp intermittently failing with a
spurious SIGTRAP.

The problem is that when debugging with "target remote", new threads
the target has spawned but have never reported a stop aren't visible
to GDB until it explicitly resyncs its thread list with the target's.

For example, in a program like this:

 int
 main (void)
 {
   pthread_t child_thread;
   pthread_create (&child_thread, NULL, child_function, NULL);
   return 0;  <<<< set breakpoint here
 }

If the user sets a breakpoint at the "return" statement, and runs the
program, when that breakpoint hit is reported, GDB is only aware of
the main thread.  So if we base the decision to remove or insert
breakpoints from the target based on whether all the threads we know
about are stopped, we'll miss that child_thread is running, and thus
we'll remove breakpoints from the target, even through they should
still remain inserted, otherwise child_thread will miss them.

The break-while-running.exp test actually should also be exposing this
thread-list-out-of-synch problem.  That test sets a breakpoint while
the main thread is stopped, but other threads are running.  Because
other threads are running, the breakpoint is supposed to be inserted
immediately.  But, unless something forces a refetch of the thread
list, like, e.g., "info threads", GDB won't be aware of the other
threads that had been spawned by the main thread, and so won't insert
new or old breakpoints in the target.  And it turns out that the test
is exactly doing an explicit "info threads", masking out the
problem...  This commit adjust the test to exercise the case of not
issuing "info threads".  The test then fails without the GDB fix.

In the ni-nsintrall.exp case, what happens is that several threads hit
the same breakpoint, and when the first thread reports the stop,
because GDB wasn't aware other threads exist, all threads known to GDB
are found stopped, so GDB removes the breakpoints from the target.
The other threads follow up with SIGTRAPs too for that same
breakpoint, which has already been removed.  For the first few
threads, the moribund breakpoints machinery suppresses the SIGTRAPs,
but after a few events (precisely '3 * thread_count () + 1' at the
time the breakpoint was removed, see update_global_location_list), the
moribund breakpoint machinery is no longer aware of the removed
breakpoint, and the SIGTRAP is reported as a spurious stop.

The fix is naturally then to stop assuming that if no thread in the
list is executing, then the target is fully stopped.  We can't know
that until we fully sync the thread list.  Because updating the thread
list on every stop would be too much RSP traffic, I chose instead to
update it whenever we're about to present a stop to the user.

Actually updating the thread list at that point happens to be an item
I had added to the local/remote parity wiki page a while ago:

  Native GNU/Linux debugging adds new threads to the thread list as
  the program creates them "The [New Thread foo] messages". Remote
  debugging can't do that, and it's arguable whether we shouldn't even
  stop native debugging from doing that, as it hinders inferior
  performance. However, a related issue is that with remote targets
  (and gdbserver), even after the program stops, the user still needs
  to do "info threads" to pull an updated thread list. This, should
  most likely be addressed, so that GDB pulls the list itself, perhaps
  just before presenting a stop to the user.

With that in place, the need to delay "Program received signal FOO"
was actually caught by the manythreads.exp test.  Without that bit, I
was getting:

  [Thread 0x7ffff7f13700 (LWP 4499) exited]
  [New Thread 0x7ffff7f0b700 (LWP 4500)]
  ^C
  Program received signal SIGINT, Interrupt.
  [New Thread 0x7ffff7f03700 (LWP 4501)]           <<< new output
  [Switching to Thread 0x7ffff7f0b700 (LWP 4500)]
  __GI___nptl_death_event () at events.c:31
  31      {
  (gdb) FAIL: gdb.threads/manythreads.exp: stop threads 1

That is, I was now getting "New Thread" lines after the "Program
received signal" line, and the test doesn't expect them.  As the
number of new threads discovered before and after the "Program
received signal" output is unbounded, it's much nicer to defer
"Program received signal" until after synching the thread list, thus
close to the "switching to thread" output and "current frame/source"
info:

  [Thread 0x7ffff7863700 (LWP 7647) exited]
  ^C[New Thread 0x7ffff786b700 (LWP 7648)]

  Program received signal SIGINT, Interrupt.
  [Switching to Thread 0x7ffff7fc4740 (LWP 6243)]
  __GI___nptl_create_event () at events.c:25
  25      {
  (gdb) PASS: gdb.threads/manythreads.exp: stop threads 1

Tested on x86_64 Fedora 20, native and gdbserver.

gdb/
2014-10-02  Pedro Alves  <palves@redhat.com>

	* breakpoint.c (breakpoints_should_be_inserted_now): Use
	threads_are_executing.
	* breakpoint.h (breakpoints_should_be_inserted_now): Add
	describing comment.
	* gdbthread.h (threads_are_executing): Declare.
	(handle_signal_stop) <random signals>: Don't print about the
	signal here if stopping.
	(end_stepping_range): Don't notify observers here.
	(normal_stop): Update the thread list.  If stopped by a random
	signal or a stepping range ended, notify observers.
	* thread.c (threads_executing): New global.
	(init_thread_list): Clear 'threads_executing'.
	(set_executing): Set or clear 'threads_executing'.
	(threads_are_executing): New function.
	(update_threads_executing): New function.
	(update_thread_list): Use it.

gdb/testsuite/
2014-10-02  Pedro Alves  <palves@redhat.com>

	* gdb.threads/break-while-running.exp (test): Add new
	'update_thread_list' argument.  Skip "info threads" if false.
	(top level): Add new 'update_thread_list' axis.
2014-10-02 10:08:00 +01:00
Pedro Alves a25a5a45ef Fix "breakpoint always-inserted off"; remove "breakpoint always-inserted auto"
By default, GDB removes all breakpoints from the target when the
target stops and the prompt is given back to the user.  This is useful
in case GDB crashes while the user is interacting, as otherwise,
there's a higher chance breakpoints would be left planted on the
target.

But, as long as any thread is running free, we need to make sure to
keep breakpoints inserted, lest a thread misses a breakpoint.  With
that in mind, in preparation for non-stop mode, we added a "breakpoint
always-inserted on" mode.  This traded off the extra crash protection
for never having threads miss breakpoints, and in addition is more
efficient if there's a ton of breakpoints to remove/insert at each
user command (e.g., at each "step").

When we added non-stop mode, and for a period, we required users to
manually set "always-inserted on" when they enabled non-stop mode, as
otherwise GDB removes all breakpoints from the target as soon as any
thread stops, which means the other threads still running will miss
breakpoints.  The test added by this patch exercises this.

That soon revealed a nuisance, and so later we added an extra
"breakpoint always-inserted auto" mode, that made GDB behave like
"always-inserted on" when non-stop was enabled, and "always-inserted
off" when non-stop was disabled.  "auto" was made the default at the
same time.

In hindsight, this "auto" setting was unnecessary, and not the ideal
solution.  Non-stop mode does depends on breakpoints always-inserted
mode, but only as long as any thread is running.  If no thread is
running, no breakpoint can be missed.  The same is true for all-stop
too.  E.g., if, in all-stop mode, and the user does:

 (gdb) c&
 (gdb) b foo

That breakpoint at "foo" should be inserted immediately, but it
currently isn't -- currently it'll end up inserted only if the target
happens to trip on some event, and is re-resumed, e.g., an internal
breakpoint triggers that doesn't cause a user-visible stop, and so we
end up in keep_going calling insert_breakpoints.  The test added by
this patch also covers this.

IOW, no matter whether in non-stop or all-stop, if the target fully
stops, we can remove breakpoints.  And no matter whether in all-stop
or non-stop, if any thread is running in the target, then we need
breakpoints to be immediately inserted.  And then, if the target has
global breakpoints, we need to keep breakpoints even when the target
is stopped.

So with that in mind, and aiming at reducing all-stop vs non-stop
differences for all-stop-on-stop-of-non-stop, this patch fixes
"breakpoint always-inserted off" to not remove breakpoints from the
target until it fully stops, and then removes the "auto" setting as
unnecessary.  I propose removing it straight away rather than keeping
it as an alias, unless someone complains they have scripts that need
it and that can't adjust.

Tested on x86_64 Fedora 20.

gdb/
2014-09-22  Pedro Alves  <palves@redhat.com>

	* NEWS: Mention merge of "breakpoint always-inserted" modes "off"
	and "auto" merged.
	* breakpoint.c (enum ugll_insert_mode): New enum.
	(always_inserted_mode): Now a plain boolean.
	(show_always_inserted_mode): No longer handle AUTO_BOOLEAN_AUTO.
	(breakpoints_always_inserted_mode): Delete.
	(breakpoints_should_be_inserted_now): New function.
	(insert_breakpoints): Pass UGLL_INSERT to
	update_global_location_list instead of calling
	insert_breakpoint_locations manually.
	(create_solib_event_breakpoint_1): New, factored out from ...
	(create_solib_event_breakpoint): ... this.
	(create_and_insert_solib_event_breakpoint): Use
	create_solib_event_breakpoint_1 instead of calling
	insert_breakpoint_locations manually.
	(update_global_location_list): Change parameter type from boolean
	to enum ugll_insert_mode.  All callers adjusted.  Adjust to use
	breakpoints_should_be_inserted_now and handle UGLL_INSERT.
	(update_global_location_list_nothrow): Change parameter type from
	boolean to enum ugll_insert_mode.
	(_initialize_breakpoint): "breakpoint always-inserted" option is
	now a boolean command.  Update help text.
	* breakpoint.h (breakpoints_always_inserted_mode): Delete declaration.
	(breakpoints_should_be_inserted_now): New declaration.
	* infrun.c (handle_inferior_event) <TARGET_WAITKIND_LOADED>:
	Remove breakpoints_always_inserted_mode check.
	(normal_stop): Adjust to use breakpoints_should_be_inserted_now.
	* remote.c (remote_start_remote): Likewise.

gdb/doc/
2014-09-22  Pedro Alves  <palves@redhat.com>

	* gdb.texinfo (Set Breaks): Document that "set breakpoint
	always-inserted off" is the default mode now.  Delete
	documentation of "set breakpoint always-inserted auto".

gdb/testsuite/
2014-09-22  Pedro Alves  <palves@redhat.com>

	* gdb.threads/break-while-running.exp: New file.
	* gdb.threads/break-while-running.c: New file.
2014-09-22 10:07:04 +01:00
Patrick Palka bb9d5f81c3 Fix PR12526: -location watchpoints for bitfield arguments
PR 12526 reports that -location watchpoints against bitfield arguments
trigger false positives when bits around the bitfield, but not the
bitfield itself, are modified.

This happens because -location watchpoints naturally operate at the
byte level, not at the bit level.  When the address of a bitfield
lvalue is taken, information about the bitfield (i.e. its offset and
size) is lost in the process.

This information must first be retained throughout the lifetime of the
-location watchpoint.  This patch achieves this by adding two new
fields to the watchpoint struct: val_bitpos and val_bitsize.  These
fields are set when a watchpoint is first defined in watch_command_1.
They are both equal to zero if the watchpoint is not a -location
watchpoint or if the argument is not a bitfield.

Then these bitfield parameters are used inside update_watchpoint and
watchpoint_check to extract the actual value of the bitfield from the
watchpoint address, with the help of a local helper function
extract_bitfield_from_watchpoint_value.

Finally when creating a HW breakpoint pointing to a bitfield, we
optimize the address and length of the breakpoint.  By skipping over
the bytes that don't cover the bitfield, this step reduces the
frequency at which a read watchpoint for the bitfield is triggered.
It also reduces the number of times a false-positive call to
check_watchpoint is triggered for a write watchpoint.

gdb/
	PR breakpoints/12526
	* breakpoint.h (struct watchpoint): New fields val_bitpos and
	val_bitsize.
	* breakpoint.c (watch_command_1): Use these fields to retain
	bitfield information.
	(extract_bitfield_from_watchpoint_value): New function.
	(watchpoint_check): Use it.
	(update_watchpoint): Use it.  Optimize the address and length of a
	HW watchpoint pointing to a bitfield.
	* value.h (unpack_value_bitfield): New prototype.
	* value.c (unpack_value_bitfield): Make extern.

gdb/testsuite/
	PR breakpoints/12526
	* gdb.base/watch-bitfields.exp: New file.
	* gdb.base/watch-bitfields.c: New file.
2014-09-16 17:40:06 +01:00
Pedro Alves f37f681c2b [IRIX] eliminate deprecated_insert_raw_breakpoint uses
The IRIX support wants to set a breakpoint to be hit when the startup
phase is complete, which is where shared libraries have been mapped
in.  AFAIU, for most IRIX ports, that location is the entry point.

For MIPS IRIX however, GDB needs to set a breakpoint earlier, in
__dbx_link, as explained by:

 #ifdef SYS_syssgi
   /* On mips-irix, we need to stop the inferior early enough during
      the startup phase in order to be able to load the shared library
      symbols and insert the breakpoints that are located in these shared
      libraries.  Stopping at the program entry point is not good enough
      because the -init code is executed before the execution reaches
      that point.

      So what we need to do is to insert a breakpoint in the runtime
      loader (rld), more precisely in __dbx_link().  This procedure is
      called by rld once all shared libraries have been mapped, but before
      the -init code is executed.  Unfortuantely, this is not straightforward,
      as rld is not part of the executable we are running, and thus we need
      the inferior to run until rld itself has been mapped in memory.

      For this, we trace all syssgi() syscall exit events.  Each time
      we detect such an event, we iterate over each text memory maps,
      get its associated fd, and scan the symbol table for __dbx_link().
      When found, we know that rld has been mapped, and that we can insert
      the breakpoint at the symbol address.  Once the dbx_link() breakpoint
      has been inserted, the syssgi() notifications are no longer necessary,
      so they should be canceled.  */
   proc_trace_syscalls_1 (pi, SYS_syssgi, PR_SYSEXIT, FLAG_SET, 0);
 #endif

The loop in irix_solib_create_inferior_hook then runs until whichever
breakpoint is hit first, the one set by solib-irix.c or the one set by
procfs.c.

Note the comment in disable_break talks about __dbx_init, but I think
that's a typo for __dbx_link:

 -  /* Note that it is possible that we have stopped at a location that
 -     is different from the location where we inserted our breakpoint.
 -     On mips-irix, we can actually land in __dbx_init(), so we should
 -     not check the PC against our breakpoint address here.  See procfs.c
 -     for more details.  */

This looks very much like referring to the loop in
irix_solib_create_inferior_hook stopping at __dbx_link instead of at
the entry point.

What this patch does is convert these deprecated raw breakpoints to
standard solib_event breakpoints.  When the first solib-event
breakpoint is hit, we delete all solib-event breakpoints.  We do that
in the so_ops->handle_event hook.

This allows getting rid of the loop in irix_solib_create_inferior_hook
completely, which should allow properly handling signals and other
events in the early startup phase, like in SVR4.

Built on x86_64 Fedora 20 with --enable-targets=all (builds
solib-irix.c).

Joel tested that with an earlier version of this patch "info shared"
after starting a program gave the same list of shared libraries as
before.

gdb/ChangeLog:
2014-09-12  Pedro Alves  <palves@redhat.com>

	* breakpoint.c (remove_solib_event_breakpoints_at_next_stop)
	(create_and_insert_solib_event_breakpoint): New functions.
	* breakpoint.h (create_and_insert_solib_event_breakpoint)
	(remove_solib_event_breakpoints_at_next_stop): New declarations.
	* procfs.c (dbx_link_bpt_addr, dbx_link_bpt): Delete globals.
	(remove_dbx_link_breakpoint): Delete function.
	(insert_dbx_link_bpt_in_file): Use
	create_and_insert_solib_event_breakpoint instead of
	deprecated_insert_raw_breakpoint.
	(procfs_wait): Don't check whether we hit __dbx_link here.
	(procfs_mourn_inferior): Don't delete the __dbx_link breakpoint
	here.
	* solib-irix.c (base_breakpoint): Delete global.
	(disable_break): Delete function.
	(enable_break): Use create_solib_event_breakpoint
	instead of deprecated_insert_raw_breakpoint.
	(irix_solib_handle_event): New function.
	(irix_solib_create_inferior_hook): Don't run the target or disable
	the mapping-complete breakpoint here.
	(_initialize_irix_solib): Install irix_solib_handle_event as
	so_ops->handle_event hook.
2014-09-12 20:02:01 +01:00
Tom Tromey 82ae6c8d79 use cmd_sfunc_ftype and cmd_cfunc_ftype more
This patch changes a few more spots to use either cmd_sfunc_ftype or
cmd_cfunc_ftype, as appropriate.  This is a bit cleaner.

Tested by rebuilding.

2014-07-01  Tom Tromey  <tromey@redhat.com>

	* breakpoint.c (add_catch_command): Use cmd_sfunc_ftype.
	* breakpoint.h (add_catch_command): Use cmd_sfunc_ftype.
	* cli/cli-decode.c (cmd_cfunc_eq, add_cmd, add_prefix_cmd)
	(add_abbrev_prefix_cmd, add_info, add_com): Use cmd_cfunc_ftype.
	* command.h (cmd_cfunc_ftype): Move earlier.
	(add_cmd, add_prefix_cmd, add_abbrev_prefix_cmd, cmd_cfunc_eq)
	(add_com, add_info): Use cmd_cfunc_ftype.
2014-07-01 10:21:10 -06:00
Yao Qi b67a2c6fd4 Associate dummy_frame with ptid
This patch is to add ptid into dummy_frame and extend frame_id to
dummy_frame_id (which has a ptid field).  With this change, GDB uses
dummy_frame_id (thread ptid and frame_id) to find the dummy frames.

Currently, dummy frames are looked up by frame_id, which isn't
accurate in non-stop or multi-process mode.  The test case
gdb.multi/dummy-frame-restore.exp shows the problem and this patch can
fix it.

Test dummy-frame-restore.exp makes two inferiors stop at
different functions, say, inferior 1 stops at f1 while inferior 2
stops at f2.  Set a breakpoint to a function, do the inferior call
in two inferiors, and GDB has two dummy frames of the same frame_id.
When the inferior call is finished, GDB will look up a dummy frame
from its stack/list and restore the inferior's regcache.  Two
inferiors are finished in different orders, the inferiors' states are
restored differently, which is wrong.  Running dummy-frame-restore.exp
under un-patched GDB, we'll get two fails:

FAIL: gdb.multi/dummy-frame-restore.exp: inf 2 first: after infcall: bt in inferior 2
FAIL: gdb.multi/dummy-frame-restore.exp: inf 2 first: after infcall: bt in inferior 1

With this patch applied, GDB will choose the correct dummy_frame to
restore for a given inferior, because ptid is considered when looking up
dummy frames.  Two fails above are fixed.

Regression tested on x86_64-linux, both native and gdbserver.

gdb:

2014-06-27  Yao Qi  <yao@codesourcery.com>

	* breakpoint.c (check_longjmp_breakpoint_for_call_dummy):
	Change parameter type to 'struct thread_info *'.  Caller
	updated.
	* breakpoint.h (check_longjmp_breakpoint_for_call_dummy):
	Update declaration.
	* dummy-frame.c (struct dummy_frame_id): New.
	(dummy_frame_id_eq): New function.
	(struct dummy_frame) <id>: Change its type to 'struct
	dummy_frame_id'.
	(dummy_frame_push): Add parameter ptid and save it in
	dummy_frame_id.
	(pop_dummy_frame_bpt): Use ptid of dummy_frame instead of
	inferior_ptid.
	(pop_dummy_frame): Assert that the ptid of dummy_frame equals
	to inferior_ptid.
	(lookup_dummy_frame): Change parameter type to 'struct
	dummy_frame_id *'.  Callers updated.  Call dummy_frame_id_eq
	instead of frame_id_eq.
	(dummy_frame_pop): Add parameter ptid.  Callers updated.
	Update comments.  Compose dummy_frame_id and pass it to
	lookup_dummy_frame.
	(dummy_frame_discard): Add parameter ptid.
	(dummy_frame_sniffer): Compose dummy_frame_id and call
	dummy_frame_id_eq instead of frame_id_eq.
	(fprint_dummy_frames): Print ptid.
	* dummy-frame.h: Remove comments.
	(dummy_frame_push): Add ptid in declaration.
	(dummy_frame_pop, dummy_frame_discard): Likewise.

gdb/testsuite:

2014-06-27  Yao Qi  <yao@codesourcery.com>

	* gdb.multi/dummy-frame-restore.exp: New.
	* gdb.multi/dummy-frame-restore.c: New.

gdb/doc:

2014-06-27  Yao Qi  <yao@codesourcery.com>

	* gdb.texinfo (Maintenance Commands): Update the output of
	'maint print dummy-frames' command.
2014-06-27 20:06:56 +08:00
Pedro Alves 2adfaa28b5 Fix for even more missed events; eliminate thread-hop code.
Even with deferred_step_ptid out of the way, GDB can still lose
watchpoints.

If a watchpoint triggers and the PC points to an address where a
thread-specific breakpoint for another thread is set, the thread-hop
code triggers, and we lose the watchpoint:

  if (ecs->event_thread->suspend.stop_signal == GDB_SIGNAL_TRAP)
    {
      int thread_hop_needed = 0;
      struct address_space *aspace =
	get_regcache_aspace (get_thread_regcache (ecs->ptid));

      /* Check if a regular breakpoint has been hit before checking
         for a potential single step breakpoint.  Otherwise, GDB will
         not see this breakpoint hit when stepping onto breakpoints.  */
      if (regular_breakpoint_inserted_here_p (aspace, stop_pc))
	{
	  if (!breakpoint_thread_match (aspace, stop_pc, ecs->ptid))
	    thread_hop_needed = 1;
	    ^^^^^^^^^^^^^^^^^^^^^
	}

And on software single-step targets, even without a thread-specific
breakpoint in the way, here in the thread-hop code:

      else if (singlestep_breakpoints_inserted_p)
	{
...
	  if (!ptid_equal (singlestep_ptid, ecs->ptid)
	      && in_thread_list (singlestep_ptid))
	    {
	      /* If the PC of the thread we were trying to single-step
		 has changed, discard this event (which we were going
		 to ignore anyway), and pretend we saw that thread
		 trap.  This prevents us continuously moving the
		 single-step breakpoint forward, one instruction at a
		 time.  If the PC has changed, then the thread we were
		 trying to single-step has trapped or been signalled,
		 but the event has not been reported to GDB yet.

		 There might be some cases where this loses signal
		 information, if a signal has arrived at exactly the
		 same time that the PC changed, but this is the best
		 we can do with the information available.  Perhaps we
		 should arrange to report all events for all threads
		 when they stop, or to re-poll the remote looking for
		 this particular thread (i.e. temporarily enable
		 schedlock).  */

	     CORE_ADDR new_singlestep_pc
	       = regcache_read_pc (get_thread_regcache (singlestep_ptid));

	     if (new_singlestep_pc != singlestep_pc)
	       {
		 enum gdb_signal stop_signal;

		 if (debug_infrun)
		   fprintf_unfiltered (gdb_stdlog, "infrun: unexpected thread,"
				       " but expected thread advanced also\n");

		 /* The current context still belongs to
		    singlestep_ptid.  Don't swap here, since that's
		    the context we want to use.  Just fudge our
		    state and continue.  */
                 stop_signal = ecs->event_thread->suspend.stop_signal;
                 ecs->event_thread->suspend.stop_signal = GDB_SIGNAL_0;
                 ecs->ptid = singlestep_ptid;
                 ecs->event_thread = find_thread_ptid (ecs->ptid);
                 ecs->event_thread->suspend.stop_signal = stop_signal;
                 stop_pc = new_singlestep_pc;
               }
             else
	       {
		 if (debug_infrun)
		   fprintf_unfiltered (gdb_stdlog,
				       "infrun: unexpected thread\n");

		 thread_hop_needed = 1;
		 stepping_past_singlestep_breakpoint = 1;
		 saved_singlestep_ptid = singlestep_ptid;
	       }
	    }
	}

we either end up with thread_hop_needed, ignoring the watchpoint
SIGTRAP, or switch to the stepping thread, again ignoring that the
SIGTRAP could be for some other event.

The new test added by this patch exercises both paths.

So the fix is similar to the deferred_step_ptid fix -- defer the
thread hop to _after_ the SIGTRAP had a change of passing through the
regular bpstat handling.  If the wrong thread hits a breakpoint, we'll
just end up with BPSTAT_WHAT_SINGLE, and if nothing causes a stop,
keep_going starts a step-over.

Most of the stepping_past_singlestep_breakpoint mechanism is really
not necessary -- setting the thread to step over a breakpoint with
thread->trap_expected is sufficient to keep all other threads locked.
It's best to still keep the flag in some form though, because when we
get to keep_going, the software single-step breakpoint we need to step
over is already gone -- an optimization done by a follow up patch will
check whether a step-over is still be necessary by looking to see
whether the breakpoint is still there, and would find the thread no
longer needs a step-over, while we still want it.

Special care is still needed to handle the case of PC of the thread we
were trying to single-step having changed, like in the old code.  We
can't just keep_going and re-step it, as in that case we can over-step
the thread (if it was already done with the step, but hasn't reported
it yet, we'd ask it to step even further).  That's now handled in
switch_back_to_stepped_thread.  As bonus, we're now using a technique
that doesn't lose signals, unlike the old code -- we now insert a
breakpoint at PC, and resume, which either reports the breakpoint
immediately, or any pending signal.

Tested on x86_64 Fedora 17, against pristine mainline, and against a
branch that implements software single-step on x86.

gdb/
2014-03-20  Pedro Alves  <palves@redhat.com>

	* breakpoint.c (single_step_breakpoint_inserted_here_p): Make
	extern.
	* breakpoint.h (single_step_breakpoint_inserted_here_p): Declare.
	* infrun.c (saved_singlestep_ptid)
	(stepping_past_singlestep_breakpoint): Delete.
	(resume): Remove stepping_past_singlestep_breakpoint handling.
	(proceed): Store the prev_pc of the stepping thread too.
	(init_wait_for_inferior): Adjust.  Clear singlestep_ptid and
	singlestep_pc.
	(enum infwait_states): Delete infwait_thread_hop_state.
	(struct execution_control_state) <hit_singlestep_breakpoint>: New
	field.
	(handle_inferior_event): Adjust.
	(handle_signal_stop): Delete stepping_past_singlestep_breakpoint
	handling and the thread-hop code.  Before removing single-step
	breakpoints, check whether the thread hit a single-step breakpoint
	of another thread.  If it did, the trap is not a random signal.
	(switch_back_to_stepped_thread): If the event thread hit a
	single-step breakpoint, unblock it before switching to the
	stepping thread.  Handle the case of the stepped thread having
	advanced already.
	(keep_going): Handle the case of the current thread moving past a
	single-step breakpoint.

gdb/testsuite/
2014-03-20  Pedro Alves  <palves@redhat.com>

	* gdb.threads/step-over-trips-on-watchpoint.c: New file.
	* gdb.threads/step-over-trips-on-watchpoint.exp: New file.
2014-03-20 13:42:23 +00:00
Pedro Alves 31e77af205 PR breakpoints/7143 - Watchpoint does not trigger when first set
Say the program is stopped at a breakpoint, and the user sets a
watchpoint.  When the program is next resumed, GDB will first step
over the breakpoint, as explained in the manual:

  @value {GDBN} normally ignores breakpoints when it resumes
  execution, until at least one instruction has been executed.  If it
  it did not do this, you would be unable to proceed past a breakpoint
  without first disabling the breakpoint.  This rule applies whether
  or not the breakpoint already existed when your program stopped.

However, GDB currently also removes watchpoints, catchpoints, etc.,
and that means that the first instruction off the breakpoint does not
trigger the watchpoint, catchpoint, etc.

testsuite/gdb.base/watchpoint.exp has a kfail for this.

The PR proposes installing watchpoints only when stepping over a
breakpoint, but that misses catchpoints, etc.

A better fix would instead work from the opposite direction -- remove
only real breakpoints, leaving all other kinds of breakpoints
inserted.

But, going further, it's really a waste to constantly remove/insert
all breakpoints when stepping over a single breakpoint (generating a
pair of RSP z/Z packets for each breakpoint), so the fix goes a step
further and makes GDB remove _only_ the breakpoint being stepped over,
leaving all others installed.  This then has the added benefit of
reducing breakpoint-related RSP traffic substancialy when there are
many breakpoints set.

gdb/
2014-03-20  Pedro Alves  <palves@redhat.com>

	PR breakpoints/7143
	* breakpoint.c (should_be_inserted): Don't insert breakpoints that
	are being stepped over.
	(breakpoint_address_match): Make extern.
	* breakpoint.h (breakpoint_address_match): New declaration.
	* inferior.h (stepping_past_instruction_at): New declaration.
	* infrun.c (struct step_over_info): New type.
	(step_over_info): New global.
	(set_step_over_info, clear_step_over_info)
	(stepping_past_instruction_at): New functions.
	(handle_inferior_event): Clear the step-over info when
	trap_expected is cleared.
	(resume): Remove now stale comment.
	(clear_proceed_status): Clear step-over info.
	(proceed): Adjust step-over handling to set or clear the step-over
	info instead of removing all breakpoints.
	(handle_signal_stop): When setting up a thread-hop, don't remove
	breakpoints here.
	(stop_stepping): Clear step-over info.
	(keep_going): Adjust step-over handling to set or clear step-over
	info and then always inserting breakpoints, instead of removing
	all breakpoints when stepping over one.

gdb/testsuite/
2014-03-20  Pedro Alves  <palves@redhat.com>

	PR breakpoints/7143
	* gdb.base/watchpoint.exp: Mention bugzilla bug number instead of
	old gnats gdb/38.  Remove kfail.  Adjust to use gdb_test instead
	of gdb_test_multiple.
	* gdb.cp/annota2.exp: Remove kfail for gdb/38.
	* gdb.cp/annota3.exp: Remove kfail for gdb/38.
2014-03-20 13:41:08 +00:00
Yao Qi 5fa1d40e97 Remove argument optional_p from get_tracepoint_by_number
This patch is to remove parameter optional_p as it is always true,
in order to simplify get_tracepoint_by_number.

'optional_p' was added by this change,

1999-11-18  Tom Tromey  <tromey@cygnus.com>

	* tracepoint.h (get_tracepoint_by_number): Updated
	declaration.
	* tracepoint.c (trace_pass_command): Better error message.
	Fixed logic when `all' not specified.
	(get_tracepoint_by_number): Added `optional_p' argument.  Fixed
	all callers.

but after this patch,

 FYI: remove `static's from cli-utils.c
 https://sourceware.org/ml/gdb-patches/2011-03/msg00636.html

'optional_p' passed to get_tracepoint_by_number become always true.

gdb:

2014-03-06  Yao Qi  <yao@codesourcery.com>

	* breakpoint.c (get_tracepoint_by_number): Remove argument
	optional_p.  All callers updated.  Adjust comments.  Update
	output message.
	* breakpoint.h (get_tracepoint_by_number): Update declaration.
2014-03-06 15:03:38 +08:00
Tom Tromey 729662a522 change probes to be program-space-independent
This changes the probes to be independent of the program space.

After this, when a probe's address is needed, it is determined by
applying offsets at the point of use.

This introduces a bound_probe object, similar to bound minimal
symbols.  Objects of this type are used when it's necessary to pass a
probe and its corresponding objfile.

This removes the backlink from probe to objfile, which was primarily
used to fetch the architecture to use.

This adds a get_probe_address function which calls a probe method to
compute the probe's relocated address.  Similarly, it adds an objfile
parameter to the semaphore methods so they can do the relocation
properly as well.

2014-03-03  Tom Tromey  <tromey@redhat.com>

	* break-catch-throw.c (fetch_probe_arguments): Use bound probes.
	* breakpoint.c (create_longjmp_master_breakpoint): Use
	get_probe_address.
	(add_location_to_breakpoint, bkpt_probe_insert_location)
	(bkpt_probe_remove_location): Update.
	* breakpoint.h (struct bp_location) <probe>: Now a bound_probe.
	* elfread.c (elf_symfile_relocate_probe): Remove.
	(elf_probe_fns): Update.
	(insert_exception_resume_breakpoint): Change type of "probe"
	parameter to bound_probe.
	(check_exception_resume): Update.
	* objfiles.c (objfile_relocate1): Don't relocate probes.
	* probe.c (bound_probe_s): New typedef.
	(parse_probes): Use get_probe_address.  Set sal's objfile.
	(find_probe_by_pc): Return a bound_probe.
	(collect_probes): Return a VEC(bound_probe_s).
	(compare_probes): Update.
	(gen_ui_out_table_header_info): Change type of "probes"
	parameter.  Update.
	(info_probes_for_ops): Update.
	(get_probe_address): New function.
	(probe_safe_evaluate_at_pc): Update.
	* probe.h (struct probe_ops) <get_probe_address>: New field.
	<set_semaphore, clear_semaphore>: Add objfile parameter.
	(struct probe) <objfile>: Remove field.
	<arch>: New field.
	<address>: Update comment.
	(struct bound_probe): New.
	(find_probe_by_pc): Return a bound_probe.
	(get_probe_address): Declare.
	* solib-svr4.c (struct probe_and_action) <address>: New field.
	(hash_probe_and_action, equal_probe_and_action): Update.
	(register_solib_event_probe): Add address parameter.
	(solib_event_probe_at): Update.
	(svr4_create_probe_breakpoints): Add objfile parameter.  Use
	get_probe_address.
	* stap-probe.c (struct stap_probe) <sem_addr>: Update comment.
	(stap_get_probe_address): New function.
	(stap_can_evaluate_probe_arguments, compute_probe_arg)
	(compile_probe_arg): Update.
	(stap_set_semaphore, stap_clear_semaphore): Compute semaphore's
	address.
	(handle_stap_probe): Don't relocate the probe.
	(stap_relocate): Remove.
	(stap_gen_info_probes_table_values): Update.
	(stap_probe_ops): Remove stap_relocate.
	* symfile-debug.c (debug_sym_relocate_probe): Remove.
	(debug_sym_probe_fns): Update.
	* symfile.h (struct sym_probe_fns) <sym_relocate_probe>: Remove.
	* symtab.c (init_sal): Use memset.
	* symtab.h (struct symtab_and_line) <objfile>: New field.
	* tracepoint.c (start_tracing, stop_tracing): Update.
2014-03-03 12:47:20 -07:00
Doug Evans ed3ef33944 Add Guile as an extension language.
* NEWS: Mention Guile scripting.
	* Makefile.in (SUBDIR_GUILE_OBS): New variable.
	(SUBDIR_GUILE_SRCS, SUBDIR_GUILE_DEPS): New variables
	(SUBDIR_GUILE_LDFLAGS, SUBDIR_GUILE_CFLAGS): New variables.
	(INTERNAL_CPPFLAGS): Add GUILE_CPPFLAGS.
	(CLIBS): Add GUILE_LIBS.
	(install-guile): New rule.
	(guile.o): New rule.
	(scm-arch.o, scm-auto-load.o, scm-block.o): New rules.
	(scm-breakpoint.o, scm-disasm.o, scm-exception.o): New rules.
	(scm-frame.o, scm-iterator.o, scm-lazy-string.o): New rules.
	(scm-math.o, scm-objfile.o, scm-ports.o): New rules.
	(scm-pretty-print.o, scm-safe-call.o, scm-gsmob.o): New rules.
	(scm-string.o, scm-symbol.o, scm-symtab.o): New rules.
	(scm-type.o, scm-utils.o, scm-value.o): New rules.
	* configure.ac: New option --with-guile.
	* configure: Regenerate.
	* config.in: Regenerate.
	* auto-load.c: Remove #include "python/python.h".  Add #include
	"gdb/section-scripts.h".
	(source_section_scripts): Handle Guile scripts.
	(_initialize_auto_load): Add name of Guile objfile script to
	scripts-directory help text.
	* breakpoint.c (condition_command): Tweak comment to include Scheme.
	* breakpoint.h (gdbscm_breakpoint_object): Add forward decl.
	(struct breakpoint): New member scm_bp_object.
	* defs.h (enum command_control_type): New value guile_control.
	* cli/cli-cmds.c: Remove #include "python/python.h".  Add #include
	"extension.h".
	(show_user): Update comment.
	(_initialize_cli_cmds): Update help text for "show user".  Update help
	text for max-user-call-depth.
	* cli/cli-script.c: Remove #include "python/python.h".  Add #include
	"extension.h".
	(multi_line_command_p): Add guile_control.
	(print_command_lines): Handle guile_control.
	(execute_control_command, recurse_read_control_structure): Ditto.
	(process_next_line): Recognize "guile" commands.
	* disasm.c (gdb_disassemble_info): Make non-static.
	* disasm.h: #include "dis-asm.h".
	(struct gdbarch): Add forward decl.
	(gdb_disassemble_info): Declare.
	* extension.c: #include "guile/guile.h".
	(extension_languages): Add guile.
	(get_ext_lang_defn): Handle EXT_LANG_GDB.
	* extension.h (enum extension_language): New value EXT_LANG_GUILE.
	* gdbtypes.c (get_unsigned_type_max): New function.
	(get_signed_type_minmax): New function.
	* gdbtypes.h (get_unsigned_type_max): Declare.
	(get_signed_type_minmax): Declare.
	* guile/README: New file.
	* guile/guile-internal.h: New file.
	* guile/guile.c: New file.
	* guile/guile.h: New file.
	* guile/scm-arch.c: New file.
	* guile/scm-auto-load.c: New file.
	* guile/scm-block.c: New file.
	* guile/scm-breakpoint.c: New file.
	* guile/scm-disasm.c: New file.
	* guile/scm-exception.c: New file.
	* guile/scm-frame.c: New file.
	* guile/scm-gsmob.c: New file.
	* guile/scm-iterator.c: New file.
	* guile/scm-lazy-string.c: New file.
	* guile/scm-math.c: New file.
	* guile/scm-objfile.c: New file.
	* guile/scm-ports.c: New file.
	* guile/scm-pretty-print.c: New file.
	* guile/scm-safe-call.c: New file.
	* guile/scm-string.c: New file.
	* guile/scm-symbol.c: New file.
	* guile/scm-symtab.c: New file.
	* guile/scm-type.c: New file.
	* guile/scm-utils.c: New file.
	* guile/scm-value.c: New file.
	* guile/lib/gdb.scm: New file.
	* guile/lib/gdb/boot.scm: New file.
	* guile/lib/gdb/experimental.scm: New file.
	* guile/lib/gdb/init.scm: New file.
	* guile/lib/gdb/iterator.scm: New file.
	* guile/lib/gdb/printing.scm: New file.
	* guile/lib/gdb/types.scm: New file.
	* data-directory/Makefile.in (GUILE_SRCDIR): New variable.
	(VPATH): Add $(GUILE_SRCDIR).
	(GUILE_DIR): New variable.
	(GUILE_INSTALL_DIR, GUILE_FILES): New variables.
	(all): Add stamp-guile dependency.
	(stamp-guile): New rule.
	(clean-guile, install-guile, uninstall-guile): New rules.
	(install-only): Add install-guile dependency.
	(uninstall): Add uninstall-guile dependency.
	(clean): Add clean-guile dependency.

	doc/
	* Makefile.in (GDB_DOC_FILES): Add guile.texi.
	* gdb.texinfo (Auto-loading): Add set/show auto-load guile-scripts.
	(Extending GDB): New menu entries Guile, Multiple Extension Languages.
	(Guile docs): Include guile.texi.
	(objfile-gdbdotext file): Add objfile-gdb.scm.
	(dotdebug_gdb_scripts section): Mention Guile scripts.
	(Multiple Extension Languages): New node.
	* guile.texi: New file.

	testsuite/
	* configure.ac (AC_OUTPUT): Add gdb.guile.
	* configure: Regenerate.
	* lib/gdb-guile.exp: New file.
	* lib/gdb.exp (get_target_charset): New function.
	* gdb.base/help.exp: Update expected output from "apropos apropos".
	* gdb.guile/Makefile.in: New file.
	* gdb.guile/guile.exp: New file.
	* gdb.guile/scm-arch.c: New file.
	* gdb.guile/scm-arch.exp: New file.
	* gdb.guile/scm-block.c: New file.
	* gdb.guile/scm-block.exp: New file.
	* gdb.guile/scm-breakpoint.c: New file.
	* gdb.guile/scm-breakpoint.exp: New file.
	* gdb.guile/scm-disasm.c: New file.
	* gdb.guile/scm-disasm.exp: New file.
	* gdb.guile/scm-equal.c: New file.
	* gdb.guile/scm-equal.exp: New file.
	* gdb.guile/scm-error.exp: New file.
	* gdb.guile/scm-error.scm: New file.
	* gdb.guile/scm-frame-args.c: New file.
	* gdb.guile/scm-frame-args.exp: New file.
	* gdb.guile/scm-frame-args.scm: New file.
	* gdb.guile/scm-frame-inline.c: New file.
	* gdb.guile/scm-frame-inline.exp: New file.
	* gdb.guile/scm-frame.c: New file.
	* gdb.guile/scm-frame.exp: New file.
	* gdb.guile/scm-generics.exp: New file.
	* gdb.guile/scm-gsmob.exp: New file.
	* gdb.guile/scm-iterator.c: New file.
	* gdb.guile/scm-iterator.exp: New file.
	* gdb.guile/scm-math.c: New file.
	* gdb.guile/scm-math.exp: New file.
	* gdb.guile/scm-objfile-script-gdb.in: New file.
	* gdb.guile/scm-objfile-script.c: New file.
	* gdb.guile/scm-objfile-script.exp: New file.
	* gdb.guile/scm-objfile.c: New file.
	* gdb.guile/scm-objfile.exp: New file.
	* gdb.guile/scm-ports.exp: New file.
	* gdb.guile/scm-pretty-print.c: New file.
	* gdb.guile/scm-pretty-print.exp: New file.
	* gdb.guile/scm-pretty-print.scm: New file.
	* gdb.guile/scm-section-script.c: New file.
	* gdb.guile/scm-section-script.exp: New file.
	* gdb.guile/scm-section-script.scm: New file.
	* gdb.guile/scm-symbol.c: New file.
	* gdb.guile/scm-symbol.exp: New file.
	* gdb.guile/scm-symtab-2.c: New file.
	* gdb.guile/scm-symtab.c: New file.
	* gdb.guile/scm-symtab.exp: New file.
	* gdb.guile/scm-type.c: New file.
	* gdb.guile/scm-type.exp: New file.
	* gdb.guile/scm-value-cc.cc: New file.
	* gdb.guile/scm-value-cc.exp: New file.
	* gdb.guile/scm-value.c: New file.
	* gdb.guile/scm-value.exp: New file.
	* gdb.guile/source2.scm: New file.
	* gdb.guile/types-module.cc: New file.
	* gdb.guile/types-module.exp: New file.
2014-02-09 19:40:01 -08:00
Joel Brobecker ecd75fc8ee Update Copyright year range in all files maintained by GDB. 2014-01-01 07:54:24 +04:00