Commit Graph

115 Commits

Author SHA1 Message Date
Tom Tromey 2e78302469 Use ui_out_emit_tuple
This patch changes various places to use ui_out_emit_tuple,
eliminating a number of cleanups.  This patch only tackles "easy"
cases, which are ones where the cleanups in question were
block-structured and did not involve any changes other than the
obvious replacement.

ChangeLog
2017-04-22  Tom Tromey  <tom@tromey.com>

	* record-btrace.c (record_btrace_insn_history)
	(record_btrace_insn_history_range, record_btrace_call_history)
	(record_btrace_call_history_range): Use ui_out_emit_tuple.
	* thread.c (do_captured_list_thread_ids, print_thread_info_1): Use
	ui_out_emit_tuple.
	* stack.c (print_frame_info): Use ui_out_emit_tuple.
	* solib.c (info_sharedlibrary_command): Use ui_out_emit_tuple.
	* skip.c (skip_info): Use ui_out_emit_tuple.
	* remote.c (show_remote_cmd): Use ui_out_emit_tuple.
	* progspace.c (print_program_space): Use ui_out_emit_tuple.
	* probe.c (info_probes_for_ops): Use ui_out_emit_tuple.
	* osdata.c (info_osdata): Use ui_out_emit_tuple.
	* mi/mi-symbol-cmds.c (mi_cmd_symbol_list_lines): Use
	ui_out_emit_tuple.
	* mi/mi-main.c (print_one_inferior, list_available_thread_groups)
	(output_register, mi_cmd_data_read_memory)
	(mi_cmd_data_read_memory_bytes, mi_load_progress)
	(mi_cmd_trace_frame_collected): Use ui_out_emit_tuple.
	* mi/mi-cmd-var.c (mi_cmd_var_list_children, varobj_update_one):
	Use ui_out_emit_tuple.
	* mi/mi-cmd-stack.c (mi_cmd_stack_list_args): Use
	ui_out_emit_tuple.
	* mi/mi-cmd-info.c (mi_cmd_info_ada_exceptions)
	(mi_cmd_info_gdb_mi_command): Use ui_out_emit_tuple.
	* linux-thread-db.c (info_auto_load_libthread_db): Use
	ui_out_emit_tuple.
	* inferior.c (print_inferior): Use ui_out_emit_tuple.
	* gdb_bfd.c (print_one_bfd): Use ui_out_emit_tuple.
	* disasm.c (do_mixed_source_and_assembly_deprecated)
	(do_mixed_source_and_assembly): Use ui_out_emit_tuple.
	* cp-abi.c (list_cp_abis): Use ui_out_emit_tuple.
	* cli/cli-setshow.c (cmd_show_list): Use ui_out_emit_tuple.
	* breakpoint.c (print_one_breakpoint_location)
	(print_one_breakpoint): Use ui_out_emit_tuple.
	* auto-load.c (print_script, info_auto_load_cmd): Use
	ui_out_emit_tuple.
	* ada-tasks.c (print_ada_task_info): Use ui_out_emit_tuple.
2017-04-22 09:46:58 -06:00
Pedro Alves 9b2eba3dcc -Wwrite-strings: execute_command calls with string literals
This is ugly, but it's just making the uglyness explicit.

All these places would better be calling some API function directly
instead of going through execute_command & friends...

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

	* event-top.c (command_line_handler): Add cast to execute_command
	call.
	* record-btrace.c (cmd_record_btrace_bts_start)
	(cmd_record_btrace_pt_start, cmd_record_btrace_start)
	(cmd_record_btrace_start): Add cast to execute_command call.
	* record-full.c (record_full_goto_insn):
	* record.c (record_start, record_stop): Add cast to
	execute_command_to_string calls.
	(cmd_record_start): Add cast to execute_command calls.
2017-04-05 19:21:36 +01:00
Simon Marchi bcc0c096d5 Use ptid from regcache in almost all remaining nat files
This patch contains almost all of the remaining changes needed to make
to_fetch_registers/to_store_registers/to_prepare_to_store independent of
inferior_ptid.  It contains only some "trivial" changes, the more
complicated ones are in separate patches.

gdb/ChangeLog:

	* i386-linux-nat.c (fetch_register, store_register,
	i386_linux_fetch_inferior_registers,
	i386_linux_store_inferior_registers): Use ptid from regcache.
	* ia64-linux-nat.c (ia64_linux_fetch_register,
	ia64_linux_store_register): Likewise.
	* inf-ptrace.c (inf_ptrace_fetch_register,
	inf_ptrace_store_register): Likewise.
	* m32r-linux-nat.c (m32r_linux_fetch_inferior_registers,
	m32r_linux_store_inferior_registers): Likewise.
	* m68k-bsd-nat.c (m68kbsd_fetch_inferior_registers,
	m68kbsd_store_inferior_registers): Likewise.
	* m68k-linux-nat.c (fetch_register, store_register,
	m68k_linux_fetch_inferior_registers,
	m68k_linux_store_inferior_registers): Likewise.
	* m88k-bsd-nat.c (m88kbsd_fetch_inferior_registers,
	m88kbsd_store_inferior_registers): Likewise.
	* mips-fbsd-nat.c (mips_fbsd_fetch_inferior_registers,
	mips_fbsd_store_inferior_registers): Likewise.
	* mips-linux-nat.c (mips64_linux_regsets_fetch_registers,
	mips64_linux_regsets_store_registers): Likewise.
	* mips-nbsd-nat.c (mipsnbsd_fetch_inferior_registers,
	mipsnbsd_store_inferior_registers): Likewise.
	* mips-obsd-nat.c (mips64obsd_fetch_inferior_registers,
	mips64obsd_store_inferior_registers): Likewise.
	* nto-procfs.c (procfs_fetch_registers, procfs_store_registers):
	Likewise.
	* ppc-fbsd-nat.c (ppcfbsd_fetch_inferior_registers,
	ppcfbsd_store_inferior_registers): Likewise.
	* ppc-linux-nat.c (ppc_linux_fetch_inferior_registers,
	ppc_linux_store_inferior_registers): Likewise.
	* ppc-nbsd-nat.c (ppcnbsd_fetch_inferior_registers,
	ppcnbsd_store_inferior_registers): Likewise.
	* ppc-obsd-nat.c (ppcobsd_fetch_registers,
	ppcobsd_store_registers): Likewise.
	* procfs.c (procfs_fetch_registers, procfs_store_registers):
	Likewise.
	* ravenscar-thread.c (ravenscar_fetch_registers,
	ravenscar_store_registers, ravenscar_prepare_to_store):
	Likewise.
	* record-btrace.c (record_btrace_fetch_registers,
	record_btrace_store_registers, record_btrace_prepare_to_store):
	Likewise.
	* remote-sim.c (gdbsim_fetch_register, gdbsim_store_register):
	Lookup inferior using ptid from regcache, instead of
	current_inferior.
	* remote.c (remote_fetch_registers, remote_store_registers): Use
	ptid from regcache.
	* rs6000-nat.c (fetch_register, store_register): Likewise.
	* s390-linux-nat.c (s390_linux_fetch_inferior_registers,
	s390_linux_store_inferior_registers): Likewise.
	* sh-nbsd-nat.c (shnbsd_fetch_inferior_registers,
	shnbsd_store_inferior_registers): Likewise.
	* sol-thread.c (sol_thread_fetch_registers,
	sol_thread_store_registers): Likewise.
	* sparc-nat.c (sparc_fetch_inferior_registers,
	sparc_store_inferior_registers): Likewise.
	* tilegx-linux-nat.c (fetch_inferior_registers,
	store_inferior_registers): Likewise.
	* vax-bsd-nat.c (vaxbsd_fetch_inferior_registers,
	vaxbsd_store_inferior_registers): Likewise.
	* xtensa-linux-nat.c (fetch_gregs, store_gregs, fetch_xtregs,
	store_xtregs): Likewise.
2017-03-20 17:37:36 -04:00
Tim Wiederhake b158a20f26 Add method to query current recording method to target_ops.
Signed-off-by: Tim Wiederhake <tim.wiederhake@intel.com>

gdb/ChangeLog

	* record-btrace.c (record_btrace_record_method): New function.
	(init_record_btrace_ops): Initialize to_record_method.
	* record-full.c (record_full_record_method): New function.
	(init_record_full_ops, init_record_full_core_ops): Add
	record_full_record_method.
	* record.h (enum record_method): New enum.
	* target-debug.h (target_debug_print_enum_record_method: New define.
	* target-delegates.c: Regenerate.
	* target.c (target_record_method): New function.
	* target.h: Include record.h.
	(struct target_ops) <to_record_method>: New field.
	(target_record_method): New export.

Change-Id: I05daa70e4e08a19901e848c731bb7d60cd87cc5a
2017-02-14 10:57:56 +01:00
Tim Wiederhake 508352a9bf btrace: Export btrace_decode_error function.
Signed-off-by: Tim Wiederhake <tim.wiederhake@intel.com>

gdb/ChangeLog:

	* record-btrace.c (btrace_ui_out_decode_error): Move most of it ...
	* btrace.c (btrace_decode_error): ... here.  New function.
	* btrace.h (btrace_decode_error): New export.

Change-Id: I2b4b43a55dbfd9f526a540d2ad52a6708f31feba
2017-02-14 10:57:56 +01:00
Tim Wiederhake 69090ceead btrace: Count gaps as one instruction explicitly.
This gives all instructions, including gaps, a unique number.  Add a function
to retrieve the error code if a btrace instruction iterator points to an
invalid instruction.

Signed-off-by: Tim Wiederhake <tim.wiederhake@intel.com>

gdb/ChangeLog:

	* btrace.c (ftrace_call_num_insn, btrace_insn_get_error): New function.
	(ftrace_new_function, btrace_insn_number, btrace_insn_cmp,
	btrace_find_insn_by_number): Remove special case for gaps.
	* btrace.h (btrace_insn_get_error): New export.
	(btrace_insn_number, btrace_find_insn_by_number): Adjust comment.
	* record-btrace.c (btrace_insn_history): Print number for gaps.
	(record_btrace_info, record_btrace_goto): Handle gaps.

Change-Id: I8eb0e48a95f4278522fea74ea13526bfe6898ecc
2017-02-14 10:57:56 +01:00
Pedro Alves 8b172ce7c9 Reuse buffers across gdb_pretty_print_insn calls
gdb_pretty_print_insn allocates and destroys a couple local buffers
each time it is called, which can be many times when disassembling a
region of memory.  Avoid that overhead by adding a new class that
holds the buffers and making gdb_pretty_print_insn a method of that
class, so that the buffers can be reused across calls.

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

	* disasm.c (gdb_pretty_print_insn): Rename to ...
	(gdb_pretty_print_disassembler::pretty_print_insn): ... this.
	Remove gdbarch parameter.  Adapt to clear the object's buffers
	instead of allocating new buffers, and to print using the object's
	gdb_disassembler instead of calling gdb_print_insn.
	(dump_insns): Use gdb_pretty_print_disassembler.
	* disasm.h (gdb_pretty_print_insn): Delete declaration.
	(gdb_pretty_print_disassembler): New class.
	* record-btrace.c (btrace_insn_history): Use
	gdb_pretty_print_disassembler.
2017-02-02 11:11:47 +00:00
Pedro Alves 187808b04f Add back gdb_pretty_print_insn
ui_file_rewind is a ui_file method that only really works with mem
buffer files, and is a nop on other ui_file types.  It'd be desirable
to eliminate it from the base ui_file interface, and move it to the
"mem_fileopen" subclass of ui_file instead.  A following patch does
just that.

Unfortunately, there are a couple references to ui_file_rewind inside
gdb_disassembler::pretty_print_insn that were made harder to eliminate
with the recent addition of the gdb_disassembler wrapper.

Before the gdb_disassembler wrapper was added, in commit
e47ad6c0bd ("Refactor disassembly code"), gdb_pretty_print_insn
used to be passed a ui_file pointer as argument, and it was simple to
adjust that pointer be a "mem_fileopen" ui_file pointer instead, since
there's only one gdb_pretty_print_insn caller.

That commit made gdb_pretty_print_insn be a method of
gdb_disassembler, and removed the method's ui_file parameter at the
same time, replaced by referencing the gdb_disassembler's stream
instead.  The trouble is that a gdb_disassembler can be instantiated
with a pointer any kind of ui_file.  Casting the gdb_disassembler's
stream to a mem_fileopen ui_file inside
gdb_disassembler::pretty_print_insn in order to call the reset method
would be gross hack.

The fix here is to:

 - make gdb_disassembler::pretty_print_insn a be free function again
   instead of a method of gdb_disassembler.  I.e., bring back
   gdb_pretty_print_insn.

 - but, don't add back the ui_file * parameter.  Instead, move the
   mem_fileopen allocation inside.  That is a better interface, given
   that the ui_file is only ever used as temporary scratch buffer as
   an implementation detail of gdb_pretty_print_insn.  The function's
   real "where to send output" parameter is the ui_out pointer.  (A
   following patch will add back buffer reuse across invocations
   differently).

 - don't add back a disassemble_info pointer either.  That used to be
   necessary for this bit:

	  err = m_di.read_memory_func (pc, &data, 1, &m_di);
	  if (err != 0)
	    m_di.memory_error_func (err, pc, &m_di);

   ... but AFAIK, it's not really necessary.  We can replace those
   three lines with a call to read_code.  This seems to fix a
   regression even, because before commit d8b49cf0c8 ("Don't throw
   exception in dis_asm_memory_error"), that memory_error_func call
   would throw an error/exception, but now it only records the error
   in the gdb_disassembler's m_err_memaddr field.  (read_code throws
   on error.)

With all these, gdb_pretty_print_insn is completely layered on top of
gdb_disassembler only using the latter's public API.

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

	* disasm.c (gdb_disassembler::pretty_print_insn): Rename to...
	(gdb_pretty_print_insn): ... this.  Now a free function.  Add back
	a 'gdbarch' parameter.  Allocate a mem_fileopen stream here.
	Adjust to call gdb_print_insn instead of
	gdb_disassembler::print_insn.
	(dump_insns, do_mixed_source_and_assembly_deprecated)
	(do_mixed_source_and_assembly, do_assembly_only): Add back a
	'gdbarch' parameter.  Remove gdb_disassembler parameter.
	(gdb_disassembly): Don't allocate a gdb_disassembler here.
	* disasm.h (gdb_disassembler::pretty_print_insn): Delete
	declaration.
	(gdb_pretty_print_insn): Re-add declaration.
	* record-btrace.c (btrace_insn_history): Don't allocate a
	gdb_disassembler here.  Adjust to call gdb_pretty_print_insn.
2017-02-02 11:11:47 +00:00
Markus Metzger cd4007e434 btrace: allow recording to be started (and stopped) for running threads
When recording is started for a running thread, GDB was able to start tracing
but then failed to read registers to insert the initial entry for the current
PC.  We don't really need that initial entry if we don't know where exactly we
started recording.  Skip that step to allow recording to be started while
threads are running.

If we do run into errors, we need to undo the tracing enable to not leak this
thread.  The operation did not complete so our caller won't clean up this
thread.

For the BTRACE_FORMAT_PT btrace format, we don't need that initial entry since
it will be recorded in the trace.  We can omit the call to btrace_add_pc.

gdb/
	* btrace.c (btrace_enable): Do not call btrace_add_pc for
	BTRACE_FORMAT_PT or if can_access_registers_ptid returns false.
	(btrace_fetch): Assert can_access_registers_ptid.
	* record-btrace.c (require_btrace_thread, record_btrace_info): Call
	validate_registers_access.

testsuite/
	* gdb.btrace/enable-running.c: New.
	* gdb.btrace/enable-running.exp: New.
2017-02-01 14:37:07 +01:00
Yao Qi e47ad6c0bd Refactor disassembly code
This patch addes class gdb_disassembler, and refactor
code to use it.  The gdb_disassembler object is saved
in disassember_info.application_data.  However,
disassember_info.application_data is already used by
gdb for arm, mips spu, and scm-disasm.  In arm and mips,
.application_data is gdbarch, but we can still get gdbarch
from gdb_disassember.

The use of application_data in spu is a little bit
complicated.  It creates its own disassemble_info, and
save spu_dis_asm_data in .application_data.  This will
overwrite the pointer to gdb_disassembler, so we need
to find another place to save spu_dis_asm_data.  I
extend disassemble_info, and put "id" there.

gdb:

2017-01-26  Pedro Alves  <palves@redhat.com>
	    Yao Qi  <yao.qi@linaro.org>

	* arm-tdep.c: Include "disasm.h".
	(gdb_print_insn_arm): Update code to get gdbarch.
	* disasm.c (dis_asm_read_memory): Change it to
	gdb_disassembler::dis_asm_read_memory.
	(dis_asm_memory_error): Likewise.
	(dis_asm_print_address): Likewise.
	(gdb_pretty_print_insn): Change it to
	gdb_disassembler::pretty_print_insn.
	(dump_insns): Add one argument gdb_disassemlber.  All
	callers updated.
	(do_mixed_source_and_assembly_deprecated): Likewise.
	(do_mixed_source_and_assembly): Likewise.
	(do_assembly_only): Likewise.
	(gdb_disassembler::gdb_disassembler): New.
	(gdb_disassembler::print_insn): New.
	* disasm.h (class gdb_disassembler): New.
	(gdb_pretty_print_insn): Remove declaration.
	(gdb_disassemble_info): Likewise.
	* guile/scm-disasm.c (class gdbscm_disassembler): New.
	(gdbscm_disasm_read_memory_worker): Update.
	(gdbscm_disasm_read_memory): Update.
	(gdbscm_disasm_memory_error): Remove.
	(gdbscm_disasm_print_address): Remove.
	(gdbscm_disassembler::gdbscm_disassembler): New.
	(gdbscm_print_insn_from_port): Update.
	* mips-tdep.c: Include disasm.h.
	(gdb_print_insn_mips): Update code to get gdbarch.
	* record-btrace.c (btrace_insn_history): Update.
	* spu-tdep.c: Include disasm.h.
	(struct spu_dis_asm_data): Remove.
	(struct spu_dis_asm_info): New.
	(spu_dis_asm_print_address): Use spu_dis_asm_info to get
	SPU id.
	(gdb_print_insn_spu): Cast disassemble_info to
	spu_dis_asm_info.
2017-01-26 14:29:19 +00:00
Joel Brobecker 61baf725ec update copyright year range in GDB files
This applies the second part of GDB's End of Year Procedure, which
updates the copyright year range in all of GDB's files.

gdb/ChangeLog:

        Update copyright year range in all GDB files.
2017-01-01 10:52:34 +04:00
Simon Marchi 112e8700a6 Class-ify ui_out
This patch finalizes the C++ conversion of the ui-out subsystem, by
turning the ui_out and ui_out_impl structures into a single class
hierarchy.  ui_out functions are turned into virtual methods of that new
class, so as a result there are a lot of call sites to update.

In the previous version of the patchset, there were separate ui_out and
ui_out_impl classes, but it wasn't really useful and added boilerplate.
In this version there is simply an ui_out base class that is
extended for CLI, TUI and MI.

It's a bit hard to maintain a ChangeLog for such a big patch, I did my
best but I'm sure there are some missing or outdated info in there...

gdb/ChangeLog:

    * ui-out.h (ui_out_begin, ui_out_end, ui_out_table_header,
    ui_out_table_body,  ui_out_field_int, ui_out_field_fmt_int,
    ui_out_field_core_addr, ui_out_field_string, ui_out_field_stream,
    ui_out_field_fmt, ui_out_field_skip, ui_out_spaces, ui_out_text,
    ui_out_message, ui_out_wrap_hint, ui_out_flush, ui_out_test_flags,
    ui_out_query_field, ui_out_is_mi_like_p, ui_out_redirect):
    Remove, replace with a method in class ui_out.
    (table_begin_ftype): Remove, replace with pure virtual method in
    class ui_out.
    (table_body_ftype): Likewise.
    (table_end_ftype): Likewise.
    (table_header_ftype): Likewise.
    (ui_out_begin_ftype): Likewise.
    (ui_out_end_ftype): Likewise.
    (field_int_ftype): Likewise.
    (field_skip_ftype): Likewise.
    (field_string_ftype): Likewise.
    (field_fmt_ftype): Likewise.
    (spaces_ftype): Likewise.
    (text_ftype): Likewise.
    (message_ftype): Likewise.
    (wrap_hint_ftype): Likewise.
    (flush_ftype): Likewise.
    (redirect_ftype): Likewise.
    (data_destroy_ftype): Likewise.
    (struct ui_out_impl): Remove, replace with class ui_out.
    (ui_out_new): Remove.
    (class ui_out): New class.
    * ui-out.c (struct ui_out): Remove, replaced with class ui_out.
    (current_level): Remove, replace with ui_out method.
    (push_level): Likewise.
    (pop_level): Likewise.
    (uo_table_begin, uo_table_body, uo_table_end, uo_table_header,
    uo_begin, uo_end, uo_field_int, uo_field_skip, uo_field_fmt,
    uo_spaces, uo_text, uo_message, uo_wrap_hint, uo_flush,
    uo_redirect, uo_field_string): Remove.
    (ui_out_table_begin): Replace with ...
    (ui_out::table_begin): ... this.
    (ui_out_table_body): Replace with ...
    (ui_out::table_body): ... this.
    (ui_out_table_end): Replace with ...
    (ui_out::table_end): ... this.
    (ui_out_table_header): Replace with ...
    (ui_out::table_header): ... this.
    (ui_out_begin): Replace with ...
    (ui_out::begin): ... this.
    (ui_out_end): Replace with ...
    (ui_out::end): ... this.
    (ui_out_field_int): Replace with ...
    (ui_out::field_int): ... this.
    (ui_out_field_fmt_int): Replace with ...
    (ui_out::field_fmt_int): ... this.
    (ui_out_field_core_addr): Replace with ...
    (ui_out::field_core_addr): ... this.
    (ui_out_field_stream): Replace with ...
    (ui_out::field_stream): ... this.
    (ui_out_field_skip): Replace with ...
    (ui_out::field_skip): ... this.
    (ui_out_field_string): Replace with ...
    (ui_out::field_string): ... this.
    (ui_out_field_fmt): Replace with ...
    (ui_out::field_fmt): ... this.
    (ui_out_spaces): Replace with ...
    (ui_out::spaces): ... this.
    (ui_out_text): Replace with ...
    (ui_out::text): ... this.
    (ui_out_message): Replace with ...
    (ui_out::message): ... this.
    (ui_out_wrap_hint): Replace with ...
    (ui_out::wrap_hint): ... this.
    (ui_out_flush): Replace with ...
    (ui_out::flush): ... this.
    (ui_out_redirect): Replace with ...
    (ui_out::redirect): ... this.
    (ui_out_test_flags): Replace with ...
    (ui_out::test_flags): ... this.
    (ui_out_is_mi_like_p): Replace with ...
    (ui_out::is_mi_like_p): ... this.
    (verify_field): Replace with ...
    (ui_out::verify_field): ... this.
    (ui_out_query_field): Replace with ...
    (ui_out::query_table_field): ... this.
    (ui_out_data): Remove.
    (ui_out_new): Remove, replace with ...
    (ui_out::ui_out): ... this constructor.
    (do_cleanup_table_end, make_cleanup_ui_out_tuple_begin_end,
    do_cleanup_end, make_cleanup_ui_out_tuple_begin_end,
    make_cleanup_ui_out_list_begin_end): Update fallouts of struct
    ui_out -> class ui_out change.
    * cli-out.c (cli_out_data): Remove.
    (cli_uiout_dtor): Remove.
    (cli_table_begin): Replace with ...
    (cli_ui_out::do_table_begin): ... this new method.
    (cli_table_body): Replace with ...
    (cli_ui_out::do_table_body): ... this new method.
    (cli_table_end): Replace with ...
    (cli_ui_out::do_table_end): ... this new method.
    (cli_table_header): Replace with ...
    (cli_ui_out::do_table_header): ... this new method.
    (cli_begin): Replace with ...
    (cli_ui_out::do_begin): ... this new method.
    (cli_end): Replace with ...
    (cli_ui_out::do_end): ... this new method.
    (cli_field_int): Replace with ...
    (cli_ui_out::do_field_int): ... this new method.
    (cli_field_skip): Replace with ...
    (cli_ui_out::do_field_skip): ... this new method.
    (cli_field_string): Replace with ...
    (cli_ui_out::do_field_string): ... this new method.
    (cli_field_fmt): Replace with ...
    (cli_ui_out::do_field_fmt): ... this new method.
    (cli_spaces): Replace with ...
    (cli_ui_out::do_spaces): ... this new method.
    (cli_text): Replace with ...
    (cli_ui_out::do_text): ... this new method.
    (cli_message): Replace with ...
    (cli_ui_out::do_message): ... this new method.
    (cli_wrap_hint): Replace with ...
    (cli_ui_out::do_wrap_hint): ... this new method.
    (cli_flush): Replace with ...
    (cli_ui_out::do_flush): ... this new method.
    (cli_redirect): Replace with ...
    (cli_ui_out::do_redirect): ... this new method.
    (out_field_fmt): Replace with ...
    (cli_ui_out::out_field_fmt): ... this new method.
    (field_separator): Replace with ...
    (cli_ui_out::field_separator): ... this new method.
    (cli_out_set_stream): Replace with ...
    (cli_ui_out::set_stream): ... this new method.
    (cli_ui_out_impl): Remove.
    (cli_out_data_ctor): Remove.
    (cli_ui_out_impl::cli_ui_out_impl): New constructor.
    (cli_ui_out_impl::~cli_ui_out_impl): New destructor.
    (cli_out_new): Change return type to cli_ui_out *, instantiate a
    cli_ui_out.
    * cli-out.h (cli_ui_out_data): Remove, replace with class
    cli_ui_out.
    (class cli_ui_out): New class.
    (cli_ui_out_impl): Remove.
    (cli_out_data_ctor): Remove.
    (cli_out_new): Change return type to cli_ui_out*.
    (cli_out_set_stream): Remove.
    * cli/cli-interp.c (struct cli_interp) <cli_uiout>: Change type
    to cli_ui_out*.
    (cli_interpreter_resume): Adapt.
    (cli_interpreter_exec): Adapt.
    * mi/mi-out.c (mi_ui_out_data, mi_out_data): Remove.
    (mi_ui_out_impl): Remove.
    (mi_table_begin): Replace with ...
    (mi_ui_out::do_table_begin): ... this.
    (mi_table_body): Replace with ...
    (mi_ui_out::do_table_body): ... this.
    (mi_table_end): Replace with ...
    (mi_ui_out::do_table_end): ... this.
    (mi_table_header): Replace with ...
    (mi_ui_out::do_table_header): ... this.
    (mi_begin): Replace with ...
    (mi_ui_out::do_begin): ... this.
    (mi_end): Replace with ...
    (mi_ui_out::do_end): ... this.
    (mi_field_int): Replace with ...
    (mi_ui_out::do_field_int): ... this.
    (mi_field_skip): Replace with ...
    (mi_ui_out::do_field_skip): ... this.
    (mi_field_string): Replace with ...
    (mi_ui_out::do_field_string): ... this.
    (mi_field_fmt): Replace with ...
    (mi_ui_out::do_field_fmt): ... this.
    (mi_spaces): Replace with ...
    (mi_ui_out::do_spaces): ... this.
    (mi_text): Replace with ...
    (mi_ui_out::do_text): ... this.
    (mi_message): Replace with ...
    (mi_ui_out::do_message): ... this.
    (mi_wrap_hint): Replace with ...
    (mi_ui_out::do_wrap_hint): ... this.
    (mi_flush): Replace with ...
    (mi_ui_out::do_flush): ... this.
    (mi_redirect): Replace with ...
    (mi_ui_out::do_redirect):
    (field_separator): Replace with ...
    (mi_ui_out::field_separator):
    (mi_open): Replace with ...
    (mi_ui_out::open): ... this.
    (mi_close): Replace with ...
    (mi_ui_out::close): ... this.
    (mi_out_rewind): Replace with ...
    (mi_ui_out::rewind): ... this.
    (mi_out_put): Replace with ...
    (mi_ui_out::put): ... this.
    (mi_version): Replace with ...
    (mi_ui_out::version): ... this.
    (mi_out_data_ctor): Replace with ...
    (mi_ui_out::mi_ui_out): ... this.
    (mi_out_data_dtor): Replace with ...
    (mi_ui_out::~mi_ui_out): ... this.
    (mi_out_new): Change return type to mi_ui_out*, instantiate
    an mi_ui_out object.
    (as_mi_ui_out): New function.
    (mi_version): Update fallouts of struct ui_out to class ui_out
    transition.
    (mi_out_put): Likewise.
    (mi_out_rewind): Likewise.
    * mi/mi-out.h (mi_out_new): Change return type to mi_ui_out*.
    * tui/tui-out.c (tui_ui_out_data, tui_out_data, tui_ui_out_impl):
    Remove.
    (tui_field_int): Replace with ...
    (tui_ui_out::do_field_int): ... this.
    (tui_field_string): Replace with ...
    (tui_ui_out::do_field_string): ... this.
    (tui_field_fmt): Replace with ...
    (tui_ui_out::do_field_fmt): ... this.
    (tui_text): Replace with ...
    (tui_ui_out::do_text): ... this.
    (tui_out_new): Change return type to tui_ui_out*, instantiate
    tui_ui_out object.
    (tui_ui_out::tui_ui_out): New.
    * tui/tui-out.h: New file.
    * tui/tui.h (tui_out_new): Move declaration to tui/tui-out.h.
    * tui/tui-io.c: Include tui/tui-out.h.
    (tui_old_uiout): Change type to cli_ui_out*.
    (tui_setup_io): Use dynamic_cast.
    * tui/tui-io.h (tui_old_uiout): Change type to cli_ui_out*.
    * tui/tui-interp.c (tui_resume): Adapt.
    * ada-lang.c (print_it_exception): Update fallouts of struct
    ui_out to class ui_out transition.
    (print_one_exception): Likewise.
    (print_mention_exception): Likewise.
    * ada-tasks.c (print_ada_task_info): Likewise.
    (info_task): Likewise.
    (task_command): Likewise.
    * auto-load.c (print_script): Likewise.
    (auto_load_info_scripts): Likewise.
    (info_auto_load_cmd): Likewise.
    * break-catch-sig.c (signal_catchpoint_print_one): Likewise.
    * break-catch-syscall.c (print_it_catch_syscall): Likewise.
    (print_one_catch_syscall): Likewise.
    * break-catch-throw.c (print_it_exception_catchpoint): Likewise.
    (print_one_exception_catchpoint): Likewise.
    (print_one_detail_exception_catchpoint): Likewise.
    (print_mention_exception_catchpoint): Likewise.
    * breakpoint.c (maybe_print_thread_hit_breakpoint): Likewise.
    (print_solib_event): Likewise.
    (watchpoint_check): Likewise.
    (wrap_indent_at_field): Likewise.
    (print_breakpoint_location): Likewise.
    (output_thread_groups): Likewise.
    (print_one_breakpoint_location): Likewise.
    (breakpoint_1): Likewise.
    (default_collect_info): Likewise.
    (watchpoints_info): Likewise.
    (print_it_catch_fork): Likewise.
    (print_one_catch_fork): Likewise.
    (print_it_catch_vfork): Likewise.
    (print_one_catch_vfork): Likewise.
    (print_it_catch_solib): Likewise.
    (print_one_catch_solib): Likewise.
    (print_it_catch_exec): Likewise.
    (print_one_catch_exec): Likewise.
    (mention): Likewise.
    (print_it_ranged_breakpoint): Likewise.
    (print_one_ranged_breakpoint): Likewise.
    (print_one_detail_ranged_breakpoint): Likewise.
    (print_mention_ranged_breakpoint): Likewise.
    (print_it_watchpoint): Likewise.
    (print_mention_watchpoint): Likewise.
    (print_it_masked_watchpoint): Likewise.
    (print_one_detail_masked_watchpoint): Likewise.
    (print_mention_masked_watchpoint): Likewise.
    (bkpt_print_it): Likewise.
    (tracepoint_print_one_detail): Likewise.
    (tracepoint_print_mention): Likewise.
    (update_static_tracepoint): Likewise.
    (tracepoints_info): Likewise.
    (save_breakpoints): Likewise.
    * cli/cli-cmds.c (complete_command): Likewise.
    * cli/cli-logging.c (set_logging_redirect): Likewise.
    (pop_output_files): Likewise.
    (handle_redirections): Likewise.
    * cli/cli-script.c (print_command_lines): Likewise.
    * cli/cli-setshow.c (do_show_command): Likewise.
    (cmd_show_list): Likewise.
    * cp-abi.c (list_cp_abis): Likewise.
    (show_cp_abi_cmd): Likewise.
    * darwin-nat-info.c (darwin_debug_regions_recurse): Likewise.
    * disasm.c (gdb_pretty_print_insn): Likewise.
    (do_mixed_source_and_assembly_deprecated): Likewise.
    (do_mixed_source_and_assembly): Likewise.
    * gdb_bfd.c (print_one_bfd): Likewise.
    (maintenance_info_bfds): Likewise.
    * guile/scm-breakpoint.c (gdbscm_breakpoint_commands): Likewise.
    * guile/scm-ports.c (ioscm_with_output_to_port_worker): Likewise.
    * i386-linux-tdep.c (i386_linux_handle_segmentation_fault): Likewise.
    * i386-tdep.c (i386_mpx_print_bounds): Likewise.
    * infcmd.c (run_command_1): Likewise.
    (print_return_value_1): Likewise.
    * inferior.c (print_selected_inferior): Likewise.
    (print_inferior): Likewise.
    * infrun.c (print_end_stepping_range_reason): Likewise.
    (print_signal_exited_reason): Likewise.
    (print_exited_reason): Likewise.
    (print_signal_received_reason): Likewise.
    (print_no_history_reason): Likewise.
    * interps.c (interp_set): Likewise.
    * linespec.c (decode_line_full): Likewise.
    * linux-thread-db.c (info_auto_load_libthread_db): Likewise.
    * mi/mi-cmd-env.c (mi_cmd_env_pwd): Likewise.
    (mi_cmd_env_path): Likewise.
    (mi_cmd_env_dir): Likewise.
    (mi_cmd_inferior_tty_show): Likewise.
    * mi/mi-cmd-file.c (mi_cmd_file_list_exec_source_file): Likewise.
    (print_partial_file_name): Likewise.
    (mi_cmd_file_list_exec_source_files): Likewise.
    * mi/mi-cmd-info.c (mi_cmd_info_ada_exceptions): Likewise.
    (mi_cmd_info_gdb_mi_command): Likewise.
    * mi/mi-cmd-stack.c (mi_cmd_stack_info_depth): Likewise.
    (mi_cmd_stack_list_args): Likewise.
    (list_arg_or_local): Likewise.
    * mi/mi-cmd-var.c (print_varobj): Likewise.
    (mi_cmd_var_create): Likewise.
    (mi_cmd_var_delete): Likewise.
    (mi_cmd_var_set_format): Likewise.
    (mi_cmd_var_show_format): Likewise.
    (mi_cmd_var_info_num_children): Likewise.
    (mi_cmd_var_list_children): Likewise.
    (mi_cmd_var_info_type): Likewise.
    (mi_cmd_var_info_path_expression): Likewise.
    (mi_cmd_var_info_expression): Likewise.
    (mi_cmd_var_show_attributes): Likewise.
    (mi_cmd_var_evaluate_expression): Likewise.
    (mi_cmd_var_assign): Likewise.
    (varobj_update_one): Likewise.
    * mi/mi-interp.c (as_mi_interp): Likewise.
    (mi_on_normal_stop_1): Likewise.
    (mi_tsv_modified): Likewise.
    (mi_breakpoint_created): Likewise.
    (mi_breakpoint_modified): Likewise.
    (mi_solib_loaded): Likewise.
    (mi_solib_unloaded): Likewise.
    (mi_command_param_changed): Likewise.
    (mi_memory_changed): Likewise.
    (mi_user_selected_context_changed): Likewise.
    * mi/mi-main.c (print_one_inferior): Likewise.
    (output_cores): Likewise.
    (list_available_thread_groups): Likewise.
    (mi_cmd_data_list_register_names): Likewise.
    (mi_cmd_data_list_changed_registers): Likewise.
    (output_register): Likewise.
    (mi_cmd_data_evaluate_expression): Likewise.
    (mi_cmd_data_read_memory): Likewise.
    (mi_cmd_data_read_memory_bytes): Likewise.
    (mi_cmd_list_features): Likewise.
    (mi_cmd_list_target_features): Likewise.
    (mi_cmd_add_inferior): Likewise.
    (mi_execute_command): Likewise.
    (mi_load_progress): Likewise.
    (print_variable_or_computed): Likewise.
    (mi_cmd_trace_frame_collected): Likewise.
    * mi/mi-symbol-cmds.c (mi_cmd_symbol_list_lines): Likewise.
    * osdata.c (info_osdata_command): Likewise.
    * probe.c (gen_ui_out_table_header_info): Likewise.
    (print_ui_out_not_applicables): Likewise.
    (print_ui_out_info): Likewise.
    (info_probes_for_ops): Likewise.
    (enable_probes_command): Likewise.
    (disable_probes_command): Likewise.
    * progspace.c (print_program_space): Likewise.
    * python/py-breakpoint.c (bppy_get_commands): Likewise.
    * python/py-framefilter.c (py_print_type): Likewise.
    (py_print_value): Likewise.
    (py_print_single_arg): Likewise.
    (enumerate_args): Likewise.
    (enumerate_locals): Likewise.
    (py_print_args): Likewise.
    (py_print_frame): Likewise.
    * record-btrace.c (btrace_ui_out_decode_error): Likewise.
    (btrace_call_history_insn_range): Likewise.
    (btrace_call_history_src_line): Likewise.
    (btrace_call_history): Likewise.
    * remote.c (show_remote_cmd): Likewise.
    * skip.c (skip_info): Likewise.
    * solib.c (info_sharedlibrary_command): Likewise.
    * source.c (print_source_lines_base): Likewise.
    * spu-tdep.c (info_spu_event_command): Likewise.
    (info_spu_signal_command): Likewise.
    (info_spu_mailbox_list): Likewise.
    (info_spu_dma_cmdlist): Likewise.
    (info_spu_dma_command): Likewise.
    (info_spu_proxydma_command): Likewise.
    * stack.c (print_stack_frame): Likewise.
    (print_frame_arg): Likewise.
    (read_frame_arg): Likewise.
    (print_frame_args): Likewise.
    (print_frame_info): Likewise.
    (print_frame): Likewise.
    * symfile.c (load_progress): Likewise.
    (generic_load): Likewise.
    (print_transfer_performance): Likewise.
    * thread.c (do_captured_list_thread_ids): Likewise.
    (print_thread_info_1): Likewise.
    (restore_selected_frame): Likewise.
    (do_captured_thread_select): Likewise.
    (print_selected_thread_frame): Likewise.
    * top.c (execute_command_to_string): Likewise.
    * tracepoint.c (tvariables_info_1): Likewise.
    (trace_status_mi): Likewise.
    (tfind_1): Likewise.
    (print_one_static_tracepoint_marker): Likewise.
    (info_static_tracepoint_markers_command): Likewise.
    * utils.c (do_ui_out_redirect_pop): Likewise.
    (fputs_maybe_filtered): Likewise.
2016-12-22 16:19:42 -05:00
Markus Metzger b61ce85cc5 btrace: allow leading trace gaps
GDB ignores trace gaps from decode errors or overflows at the beginning of the
trace.  There isn't really a gap in the trace; the trace just starts a bit
later than expected.

In cases where there is no trace at all or where the trace is smaller than
expected, this may hide the reason for the missing trace.

Allow leading trace gaps.  They will be shown as decode warnings and by the
record function-call-history command.

    (gdb) info record
    Active record target: record-btrace
    Recording format: Intel Processor Trace.
    Buffer size: 16kB.
    warning: Decode error (-6) at instruction 0 (offset = 0x58, pc = 0x0): unexpected packet context.
    warning: Decode error (-6) at instruction 0 (offset = 0xb0, pc = 0x0): unexpected packet context.
    warning: Decode error (-6) at instruction 0 (offset = 0x168, pc = 0x0): unexpected packet context.
    warning: Decode error (-6) at instruction 54205 (offset = 0xe08, pc = 0x0): unexpected packet context.
    warning: Decode error (-6) at instruction 54205 (offset = 0xe60, pc = 0x0): unexpected packet context.
    warning: Decode error (-6) at instruction 54205 (offset = 0xed8, pc = 0x0): unexpected packet context.
    Recorded 91582 instructions in 1111 functions (6 gaps) for thread 1 (process 15710).
    (gdb) record function-call-history /c 1
    1       [decode error (-6): unexpected packet context]
    2       [decode error (-6): unexpected packet context]
    3       [decode error (-6): unexpected packet context]
    4           _dl_addr
    5             ??
    6           _dl_addr
    7         ??
    8           ??
    9         ??
    10      ??

Leading trace gaps will not be shown by the record instruction-history command
without further changes.

gdb/
	* btrace.c (btrace_compute_ftrace_bts, ftrace_add_pt): Allow leading gaps.
	* record-btrace.c (record_btrace_single_step_forward)
	(record_btrace_single_step_backward): Jump back to last instruction if
	step ends at a gap.
	(record_btrace_goto_begin): Skip gaps.
2016-10-28 10:53:45 +02:00
Pedro Alves 85ad3aaf40 gdb: Coalesce/aggregate (async) vCont packets/actions
Currently, with "maint set target-non-stop on", that is, when gdb
connects with the non-stop/asynchronous variant of the remote
protocol, even with "set non-stop off", GDB always sends one vCont
packet per thread resumed.  This patch makes GDB aggregate and
coalesce vCont packets, so we send vCont packets like "vCont;s:p1.1;c"
in non-stop mode too.

Basically, this is done by:

  - Adding a new target method target_commit_resume that is called
    after calling target_resume one or more times.  When resuming a
    batch of threads, we'll only call target_commit_resume once after
    calling target_resume for all threads.

  - Making the remote target defer sending the actual vCont packet to
    target_commit_resume.

Special care must be taken to avoid sending a vCont action with a
"wildcard" thread-id (all threads of process / all threads) when that
would resume threads/processes that should not be resumed.  See
remote_commit_resume comments for details.

Unlike all-stop's remote_resume implementation, this handles the case
of too many actions resulting in a too-big vCont packet, by flushing
the vCont packet and starting a new one.

E.g., imagining that the "c" action in:

  vCont;s:1;c

overflows the packet buffer, we split the actions like:

  vCont;s:1
  vCont;c

Tested on x86_64 Fedora 20, with and without "maint set
target-non-stop on".

Also tested with a hack that makes remote_commit_resume flush the vCont
packet after every action appended (which caught a few bugs).

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

	* inferior.h (ALL_NON_EXITED_INFERIORS): New macro.
	* infrun.c (do_target_resume): Call target_commit_resume.
	(proceed): Defer target_commit_resume while looping over threads,
	resuming them.  Call target_commit_resume at the end.
	* record-btrace.c (record_btrace_commit_resume): New function.
	(init_record_btrace_ops): Install it as to_commit_resume method.
	* record-full.c (record_full_commit_resume): New function.
	(record_full_wait_1): Call the beneath target's to_commit_resume
	method.
	(init_record_full_ops): Install record_full_commit_resume as
	to_commit_resume method.
	* remote.c (struct private_thread_info) <last_resume_step,
	last_resume_sig, vcont_resumed>: New fields.
	(remote_add_thread): Set the new thread's vcont_resumed flag.
	(demand_private_info): Delete.
	(get_private_info_thread, get_private_info_ptid): New functions.
	(remote_update_thread_list): Adjust.
	(process_initial_stop_replies): Clear the thread's vcont_resumed
	flag.
	(remote_resume): If connected in non-stop mode, record the resume
	request and return early.
	(struct private_inferior): New.
	(struct vcont_builder): New.
	(vcont_builder_restart, vcont_builder_flush)
	(vcont_builder_push_action): New functions.
	(MAX_ACTION_SIZE): New macro.
	(remote_commit_resume): New function.
	(thread_pending_fork_status, is_pending_fork_parent_thread): New
	functions.
	(check_pending_event_prevents_wildcard_vcont_callback)
	(check_pending_events_prevent_wildcard_vcont): New functions.
	(process_stop_reply): Adjust.  Clear the thread's vcont_resumed
	flag.
	(init_remote_ops): Install remote_commit_resume.
	* target-delegates.c: Regenerate.
	* target.c (defer_target_commit_resume): New global.
	(target_commit_resume, make_cleanup_defer_target_commit_resume):
	New functions.
	* target.h (struct target_ops) <to_commit_resume>: New field.
	(target_resume): Update comments.
	(target_commit_resume): New declaration.
2016-10-26 16:22:50 +01:00
Pedro Alves 325fac504a gdb: Use std::min and std::max throughout
Otherwise including <string> or some other C++ header is broken.
E.g.:

  In file included from /opt/gcc/include/c++/7.0.0/bits/char_traits.h:39:0,
		   from /opt/gcc/include/c++/7.0.0/string:40,
		   from /home/pedro/gdb/mygit/cxx-convertion/src/gdb/infrun.c:68:
  /opt/gcc/include/c++/7.0.0/bits/stl_algobase.h:243:56: error: macro "min" passed 3 arguments, but takes just 2
       min(const _Tp& __a, const _Tp& __b, _Compare __comp)
							  ^
  /opt/gcc/include/c++/7.0.0/bits/stl_algobase.h:265:56: error: macro "max" passed 3 arguments, but takes just 2
       max(const _Tp& __a, const _Tp& __b, _Compare __comp)
							  ^
  In file included from .../src/gdb/infrun.c:21:0:

To the best of my grepping abilities, I believe I adjusted all min/max
calls.

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

	* defs.h (min, max): Delete.
	* aarch64-tdep.c: Include <algorithm> and use std::min and
	std::max throughout.
	* aarch64-tdep.c: Likewise.
	* alpha-tdep.c: Likewise.
	* amd64-tdep.c: Likewise.
	* amd64-windows-tdep.c: Likewise.
	* arm-tdep.c: Likewise.
	* avr-tdep.c: Likewise.
	* breakpoint.c: Likewise.
	* btrace.c: Likewise.
	* ctf.c: Likewise.
	* disasm.c: Likewise.
	* doublest.c: Likewise.
	* dwarf2loc.c: Likewise.
	* dwarf2read.c: Likewise.
	* environ.c: Likewise.
	* exec.c: Likewise.
	* f-exp.y: Likewise.
	* findcmd.c: Likewise.
	* ft32-tdep.c: Likewise.
	* gcore.c: Likewise.
	* hppa-tdep.c: Likewise.
	* i386-darwin-tdep.c: Likewise.
	* i386-tdep.c: Likewise.
	* linux-thread-db.c: Likewise.
	* lm32-tdep.c: Likewise.
	* m32r-tdep.c: Likewise.
	* m88k-tdep.c: Likewise.
	* memrange.c: Likewise.
	* minidebug.c: Likewise.
	* mips-tdep.c: Likewise.
	* moxie-tdep.c: Likewise.
	* nds32-tdep.c: Likewise.
	* nios2-tdep.c: Likewise.
	* nto-procfs.c: Likewise.
	* parse.c: Likewise.
	* ppc-sysv-tdep.c: Likewise.
	* probe.c: Likewise.
	* record-btrace.c: Likewise.
	* remote.c: Likewise.
	* rs6000-tdep.c: Likewise.
	* rx-tdep.c: Likewise.
	* s390-linux-nat.c: Likewise.
	* s390-linux-tdep.c: Likewise.
	* ser-tcp.c: Likewise.
	* sh-tdep.c: Likewise.
	* sh64-tdep.c: Likewise.
	* source.c: Likewise.
	* sparc-tdep.c: Likewise.
	* symfile.c: Likewise.
	* target-memory.c: Likewise.
	* target.c: Likewise.
	* tic6x-tdep.c: Likewise.
	* tilegx-tdep.c: Likewise.
	* tracefile-tfile.c: Likewise.
	* tracepoint.c: Likewise.
	* valprint.c: Likewise.
	* value.c: Likewise.
	* xtensa-tdep.c: Likewise.
	* cli/cli-cmds.c: Likewise.
	* compile/compile-object-load.c: Likewise.
2016-09-16 19:55:17 +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
Tim Wiederhake c0272db585 btrace: Resume recording after disconnect.
This patch allows gdbserver to continue recording after disconnect.  On
reconnect, the recorded data is accessible to gdb as if no disconnect happened.

A possible application for this feature is remotely examine bugs that occur
at irregular intervals, where maintaining a gdb connection is inconvenient.

This also fixes the issue mentioned here:
https://sourceware.org/ml/gdb-patches/2015-11/msg00424.html

Signed-off-by: Tim Wiederhake <tim.wiederhake@intel.com>

gdb/ChangeLog:
	* NEWS: Resume btrace on reconnect.
	* record-btrace.c: Added record-btrace.h include.
	(record_btrace_open): Split into this and ...
	(record_btrace_push_target): ... this.
	(record_btrace_disconnect): New function.
	(init_record_btrace_ops): Use record_btrace_disconnect.
	* record-btrace.h: New file.
	* remote.c: Added record-btrace.h include.
	(remote_start_remote): Check recording status.
	(remote_btrace_maybe_reopen): New function.

gdb/doc/ChangeLog:
	* gdb.texinfo: Resume btrace on reconnect.

gdb/testsuite/ChangeLog:

	* gdb.btrace/reconnect.c: New file.
	* gdb.btrace/reconnect.exp: New file.

Change-Id: I95e8b0ab8a89e58591aba0e63818cee82fd211bc
2016-07-25 11:03:43 +02:00
Simon Marchi 38b022b445 Add method/format information to =record-started
Eclipse CDT now supports enabling execution recording using two methods
(full and btrace) and both formats for btrace (bts and pt).  In the
event that recording is enabled behind the back of the GUI (by the user
on the command line, or a script), we need to know which method/format
are being used, so it can be correctly reflected in the interface.  This
patch adds this information to the =record-started async record.

Before:

  =record-started,thread-group="i1"

After:

  =record-started,thread-group="i1",method="btrace",format="bts"
  =record-started,thread-group="i1",method="btrace",format="pt"
  =record-started,thread-group="i1",method="full"

The "format" field is only present when the current method supports
multiple formats (only the btrace method as of now).

gdb/ChangeLog:

	* NEWS: Mention the new fields in =record-started.
	* common/btrace-common.h (btrace_format_short_string): New function
	declaration.
	* common/btrace-common.c (btrace_format_short_string): New
	function.
	* mi/mi-interp.c (mi_record_changed): Output method and format
	fields in the =record-started record.
	* record-btrace.c (record_btrace_open): Adapt record_changed
	notification.
	* record-full.c (record_full_open): Likewise.
	* record.c (cmd_record_stop): Likewise.

gdb/doc/ChangeLog:

	* gdb.texinfo (GDB/MI Async Records): Document method and
	format fields in =record-started.
	* observer.texi (record_changed): Add method and format
	parameters.

gdb/testsuite/ChangeLog:

	* gdb.mi/mi-record-changed.exp: Adjust =record-started output
	matching.
2016-06-06 17:10:18 -04:00
Pedro Alves 5d5658a1d3 Per-inferior/Inferior-qualified thread IDs
This commit changes GDB to track thread numbers per-inferior.  Then,
if you're debugging multiple inferiors, GDB displays
"inferior-num.thread-num" instead of just "thread-num" whenever it
needs to display a thread:

 (gdb) info inferiors
   Num  Description       Executable
   1    process 6022     /home/pedro/gdb/tests/threads
 * 2    process 6037     /home/pedro/gdb/tests/threads
 (gdb) info threads
   Id   Target Id         Frame
   1.1  Thread 0x7ffff7fc2740 (LWP 6022) "threads" (running)
   1.2  Thread 0x7ffff77c0700 (LWP 6028) "threads" (running)
   1.3  Thread 0x7ffff7fc2740 (LWP 6032) "threads" (running)
   2.1  Thread 0x7ffff7fc1700 (LWP 6037) "threads" (running)
   2.2  Thread 0x7ffff77c0700 (LWP 6038) "threads" (running)
 * 2.3  Thread 0x7ffff7fc2740 (LWP 6039) "threads" (running)
 (gdb)
...
 (gdb) thread 1.1
 [Switching to thread 1.1 (Thread 0x7ffff7fc2740 (LWP 8155))]
 (gdb)
...

etc.

You can still use "thread NUM", in which case GDB infers you're
referring to thread NUM of the current inferior.

The $_thread convenience var and Python's InferiorThread.num attribute
are remapped to the new per-inferior thread number.  It's a backward
compatibility break, but since it only matters when debugging multiple
inferiors, I think it's worth doing.

Because MI thread IDs need to be a single integer, we keep giving
threads a global identifier, _in addition_ to the per-inferior number,
and make MI always refer to the global thread IDs.  IOW, nothing
changes from a MI frontend's perspective.

Similarly, since Python's Breakpoint.thread and Guile's
breakpoint-thread/set-breakpoint-thread breakpoint methods need to
work with integers, those are adjusted to work with global thread IDs
too.  Follow up patches will provide convenient means to access
threads' global IDs.

To avoid potencially confusing users (which also avoids updating much
of the testsuite), if there's only one inferior and its ID is "1",
IOW, the user hasn't done anything multi-process/inferior related,
then the "INF." part of thread IDs is not shown.  E.g,.:

 (gdb) info inferiors
   Num  Description       Executable
 * 1    process 15275     /home/pedro/gdb/tests/threads
 (gdb) info threads
   Id   Target Id         Frame
 * 1    Thread 0x7ffff7fc1740 (LWP 15275) "threads" main () at threads.c:40
 (gdb) add-inferior
 Added inferior 2
 (gdb) info threads
   Id   Target Id         Frame
 * 1.1  Thread 0x7ffff7fc1740 (LWP 15275) "threads" main () at threads.c:40
 (gdb)

No regressions on x86_64 Fedora 20.

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

	* NEWS: Mention that thread IDs are now per inferior and global
	thread IDs.
	* Makefile.in (SFILES): Add tid-parse.c.
	(COMMON_OBS): Add tid-parse.o.
	(HFILES_NO_SRCDIR): Add tid-parse.h.
	* ada-tasks.c: Adjust to use ptid_to_global_thread_id.
	* breakpoint.c (insert_breakpoint_locations)
	(remove_threaded_breakpoints, bpstat_check_breakpoint_conditions)
	(print_one_breakpoint_location, set_longjmp_breakpoint)
	(check_longjmp_breakpoint_for_call_dummy)
	(set_momentary_breakpoint): Adjust to use global IDs.
	(find_condition_and_thread, watch_command_1): Use parse_thread_id.
	(until_break_command, longjmp_bkpt_dtor)
	(breakpoint_re_set_thread, insert_single_step_breakpoint): Adjust
	to use global IDs.
	* dummy-frame.c (pop_dummy_frame_bpt): Adjust to use
	ptid_to_global_thread_id.
	* elfread.c (elf_gnu_ifunc_resolver_stop): Likewise.
	* gdbthread.h (struct thread_info): Rename field 'num' to
	'global_num.  Add new fields 'per_inf_num' and 'inf'.
	(thread_id_to_pid): Rename thread_id_to_pid to
	global_thread_id_to_ptid.
	(pid_to_thread_id): Rename to ...
	(ptid_to_global_thread_id): ... this.
	(valid_thread_id): Rename to ...
	(valid_global_thread_id): ... this.
	(find_thread_id): Rename to ...
	(find_thread_global_id): ... this.
	(ALL_THREADS, ALL_THREADS_BY_INFERIOR): Declare.
	(print_thread_info): Add comment.
	* tid-parse.h: New file.
	* tid-parse.c: New file.
	* infcmd.c (step_command_fsm_prepare)
	(step_command_fsm_should_stop): Adjust to use the global thread
	ID.
	(until_next_command, until_next_command)
	(finish_command_fsm_should_stop): Adjust to use the global thread
	ID.
	(attach_post_wait): Adjust to check the inferior number too.
	* inferior.h (struct inferior) <highest_thread_num>: New field.
	* infrun.c (handle_signal_stop)
	(insert_exception_resume_breakpoint)
	(insert_exception_resume_from_probe): Adjust to use the global
	thread ID.
	* record-btrace.c (record_btrace_open): Use global thread IDs.
	* remote.c (process_initial_stop_replies): Also consider the
	inferior number.
	* target.c (target_pre_inferior): Clear the inferior's highest
	thread num.
	* thread.c (clear_thread_inferior_resources): Adjust to use the
	global thread ID.
	(new_thread): New inferior parameter.  Adjust to use it.  Set both
	the thread's global ID and the thread's per-inferior ID.
	(add_thread_silent): Adjust.
	(find_thread_global_id): New.
	(find_thread_id): Make static.  Adjust to rename.
	(valid_thread_id): Rename to ...
	(valid_global_thread_id): ... this.
	(pid_to_thread_id): Rename to ...
	(ptid_to_global_thread_id): ... this.
	(thread_id_to_pid): Rename to ...
	(global_thread_id_to_ptid): ... this.  Adjust.
	(first_thread_of_process): Adjust.
	(do_captured_list_thread_ids): Adjust to use global thread IDs.
	(should_print_thread): New function.
	(print_thread_info): Rename to ...
	(print_thread_info_1): ... this, and add new show_global_ids
	parameter.  Handle it.  Iterate over inferiors.
	(print_thread_info): Reimplement as wrapper around
	print_thread_info_1.
	(show_inferior_qualified_tids): New function.
	(print_thread_id): Use it.
	(tp_array_compar): Compare inferior numbers too.
	(thread_apply_command): Use tid_range_parser.
	(do_captured_thread_select): Use parse_thread_id.
	(thread_id_make_value): Adjust.
	(_initialize_thread): Adjust "info threads" help string.
	* varobj.c (struct varobj_root): Update comment.
	(varobj_create): Adjust to use global thread IDs.
	(value_of_root_1): Adjust to use global_thread_id_to_ptid.
	* windows-tdep.c (display_tib): No longer accept an argument.
	* cli/cli-utils.c (get_number_trailer): Make extern.
	* cli/cli-utils.h (get_number_trailer): Declare.
	(get_number_const): Adjust documentation.
	* mi/mi-cmd-var.c (mi_cmd_var_update_iter): Adjust to use global
	thread IDs.
	* mi/mi-interp.c (mi_new_thread, mi_thread_exit)
	(mi_on_normal_stop, mi_output_running_pid, mi_on_resume):
	* mi/mi-main.c (mi_execute_command, mi_cmd_execute): Likewise.
	* guile/scm-breakpoint.c (gdbscm_set_breakpoint_thread_x):
	Likewise.
	* python/py-breakpoint.c (bppy_set_thread): Likewise.
	* python/py-finishbreakpoint.c (bpfinishpy_init): Likewise.
	* python/py-infthread.c (thpy_get_num): Add comment and return the
	per-inferior thread ID.
	(thread_object_getset): Update comment of "num".

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

	* gdb.base/break.exp: Adjust to output changes.
	* gdb.base/hbreak2.exp: Likewise.
	* gdb.base/sepdebug.exp: Likewise.
	* gdb.base/watch_thread_num.exp: Likewise.
	* gdb.linespec/keywords.exp: Likewise.
	* gdb.multi/info-threads.exp: Likewise.
	* gdb.threads/thread-find.exp: Likewise.
	* gdb.multi/tids.c: New file.
	* gdb.multi/tids.exp: New file.

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

	* gdb.texinfo (Threads): Document per-inferior thread IDs,
	qualified thread IDs, global thread IDs and thread ID lists.
	(Set Watchpoints, Thread-Specific Breakpoints): Adjust to refer to
	thread IDs.
	(Convenience Vars): Document the $_thread convenience variable.
	(Ada Tasks): Adjust to refer to thread IDs.
	(GDB/MI Async Records, GDB/MI Thread Commands, GDB/MI Ada Tasking
	Commands, GDB/MI Variable Objects): Update to mention global
	thread IDs.
	* guile.texi (Breakpoints In Guile)
	<breakpoint-thread/set-breakpoint-thread breakpoint>: Mention
	global thread IDs instead of thread IDs.
	* python.texi (Threads In Python): Adjust documentation of
	InferiorThread.num.
	(Breakpoint.thread): Mention global thread IDs instead of thread
	IDs.
2016-01-13 10:59:43 +00:00
Pedro Alves 43792cf0de Centralize thread ID printing
Add a new function to print a thread ID, in the style of paddress,
plongest, etc. and adjust all CLI-reachable paths to use it.

This gives us a single place to tweak to print inferior-qualified
thread IDs later:

 - [Switching to thread 1 (Thread 0x7ffff7fc2740 (LWP 8155))]
 + [Switching to thread 1.1 (Thread 0x7ffff7fc2740 (LWP 8155))]

etc., though for now, this has no user-visible change.

No regressions on x86_64 Fedora 20.

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

	* breakpoint.c (remove_threaded_breakpoints)
	(print_one_breakpoint_location): Use print_thread_id.
	* btrace.c (btrace_enable, btrace_disable, btrace_teardown)
	(btrace_fetch, btrace_clear): Use print_thread_id.
	* common/print-utils.c (CELLSIZE): Delete.
	(get_cell): Rename to ...
	(get_print_cell): ... this and made extern.  Adjust call callers.
	Adjust to use PRINT_CELL_SIZE.
	* common/print-utils.h (get_print_cell): Declare.
	(PRINT_CELL_SIZE): New.
	* gdbthread.h (print_thread_id): Declare.
	* infcmd.c (signal_command): Use print_thread_id.
	* inferior.c (print_inferior): Use print_thread_id.
	* infrun.c (handle_signal_stop)
	(insert_exception_resume_breakpoint)
	(insert_exception_resume_from_probe)
	(print_signal_received_reason): Use print_thread_id.
	* record-btrace.c (record_btrace_info)
	(record_btrace_resume_thread, record_btrace_cancel_resume)
	(record_btrace_step_thread, record_btrace_wait): Use
	print_thread_id.
	* thread.c (thread_apply_all_command): Use print_thread_id.
	(print_thread_id): New function.
	(thread_apply_command): Use print_thread_id.
	(thread_command, thread_find_command, do_captured_thread_select):
	Use print_thread_id.
2016-01-13 10:59:14 +00:00
Pedro Alves bc504a3117 Remove trademark acknowledgements throughout
The GNU Coding Standards say:

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

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

	Remove use of the registered trademark symbol throughout.

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

	Remove use of the registered trademark symbol throughout.

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

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

        Update year range in copyright notice of all files.
2016-01-01 08:43:22 +04:00
Pedro Alves 8d297bbf60 Type-safe wrapper for enum flags
This patch fixes C++ build errors like this:

/home/pedro/gdb/mygit/cxx-convertion/src/gdb/linux-tdep.c:1126:35: error: invalid conversion from ‘int’ to ‘filterflags’ [-fpermissive]
       | COREFILTER_HUGETLB_PRIVATE);
                                   ^

This is a case of enums used as bit flags.  Unlike "regular" enums,
these values are supposed to be or'ed together.  However, in C++, the
type of "(ENUM1 | ENUM2)" is int, and you then can't assign an int to
an enum variable without a cast.  That means that this:

  enum foo_flags flags = 0;

  if (...)
    flags |= FOO_FLAG1;
  if (...)
    flags |= FOO_FLAG2;

... would have to be written as:

  enum foo_flags flags = (enum foo_flags) 0;

  if (...)
    flags = (enum foo_flags) (flags | FOO_FLAG1);
  if (...)
    flags = (enum foo_flags) (flags | FOO_FLAG2);

which is ... ugly.  Alternatively, we'd have to use an int for the
variable's type, which isn't ideal either.

This patch instead adds an "enum flags" class.  "enum flags" are
exactly the enums where the values are bits that are meant to be ORed
together.

This allows writing code like the below, while with raw enums this
would fail to compile without casts to enum type at the assignments to
'f':

  enum some_flag
  {
     flag_val1 = 1 << 1,
     flag_val2 = 1 << 2,
     flag_val3 = 1 << 3,
     flag_val4 = 1 << 4,
  };
  DEF_ENUM_FLAGS_TYPE(enum some_flag, some_flags)

  some_flags f = flag_val1 | flag_val2;
  f |= flag_val3;

It's also possible to assign literal zero to an enum flags variable
(meaning, no flags), dispensing either adding an awkward explicit "no
value" value to the enumeration or the cast to assignments from 0.
For example:

  some_flags f = 0;
  f |= flag_val3 | flag_val4;

Note that literal integers other than zero do fail to compile:

  some_flags f = 1; // error

C is still supported -- DEF_ENUM_FLAGS_TYPE is just a typedef in that
case.

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

	* btrace.h: Include common/enum-flags.h.
	(btrace_insn_flags): Define.
	(struct btrace_insn) <flags>: Change type.
	(btrace_function_flags): Define.
	(struct btrace_function) <flags>: Change type.
	(btrace_thread_flags): Define.
	(struct btrace_thread_info) <flags>: Change type.
	* c-exp.y (token_flags): Rename to ...
	(token_flag): ... this.
	(token_flags): Define.
	(struct token) <flags>: Change type.
	* common/enum-flags.h: New file.
	* compile/compile-c-types.c (convert_qualified): Change type of
	'quals' local.
	* compile/compile-internal.h: Include "common/enum-flags.h".
	(gcc_qualifiers_flags): Define.
	* completer.c (enum reg_completer_targets): Rename to ...
	(enum reg_completer_target): ... this.
	(reg_completer_targets): Define.
	(reg_or_group_completer_1): Change type of 'targets' parameter.
	* disasm.c (do_mixed_source_and_assembly_deprecated): Change type
	of 'psl_flags' local.
	(do_mixed_source_and_assembly): Change type of 'psl_flags' local.
	* infrun.c: Include "common/enum-flags.h".
	(enum step_over_what): Rename to ...
	(enum step_over_what_flag): ... this.
	(step_over_what): Change type.
	(start_step_over): Change type of 'step_what' local.
	(thread_still_needs_step_over): Now returns a step_over_what.
	Adjust.
	(keep_going_pass_signal): Change type of 'step_what' local.
	* linux-tdep.c: Include "common/enum-flags.h".
	(enum filterflags): Rename to ...
	(enum filter_flag): ... this.
	(filter_flags): Define.
	(dump_mapping_p): Change type of 'filterflags' parameter.
	(linux_find_memory_regions_full): Change type of 'filterflags'
	local.
	(linux_find_memory_regions_full): Pass the address of an unsigned
	int to sscanf instead of the address of an enum.
	* record-btrace.c (btrace_print_lines): Change type of local
	'psl_flags'.
	(btrace_call_history): Replace 'flags' parameter
	with 'int_flags' parameter.  Adjust.
	(record_btrace_call_history, record_btrace_call_history_range)
	(record_btrace_call_history_from): Rename 'flags' parameter to
	'int_flags'.  Use record_print_flags.
	* record.h: Include "common/enum-flags.h".
	(record_print_flags): Define.
	* source.c: Include "common/enum-flags.h".
	(print_source_lines_base, print_source_lines): Change type of
	flags parameter.
	* symtab.h: Include "common/enum-flags.h".
	(enum print_source_lines_flags): Rename to ...
	(enum print_source_lines_flag): ... this.
	(print_source_lines_flags): Define.
	(print_source_lines): Change prototype.
2015-11-17 13:31:29 +00:00
Markus Metzger f94cc8975c btrace: change record instruction-history /m
The /m modifier interleaves source lines with the disassembly of recorded
instructions.  This calls disasm.c's gdb_disassembly once for each recorded
instruction to be printed.

This doesn't really work because gdb_disassembly may choose not to print
anything in some situations.  And if it does print something, the output
interferes with btrace_insn_history's output around it.

It further results in a separate asm_insns list for each instruction in MI.
Even though there is no MI support for target record, yet, we fix this obvious
issue.

Change record instruction-history /m to use the new gdb_pretty_print_insn
function for printing a single instruction and interleave source lines as
appropriate.

We cannot reuse the new disasm.c do_mixed_source_and_assembly function without
significant changes to it.

gdb/
	* record-btrace.c (struct btrace_line_range): New.
	(btrace_mk_line_range, btrace_line_range_add)
	(btrace_line_range_is_empty, btrace_line_range_contains_range)
	(btrace_find_line_range, btrace_print_lines): New.
	(btrace_insn_history): Add source interleaving algorithm.
2015-11-04 09:14:17 +01:00
Markus Metzger 04c4fe8c59 btrace: fix void return
record_btrace_resume returns the void return from the to_resume method of the
target beneath.  Split this into calling to_resume and return.

gdb/
	* record-btrace.c (record_btrace_resume): Fix void return.
2015-10-08 09:00:57 +02:00
Simon Marchi 19ba03f495 Add some more casts (2/2)
See previous patch's description.

gdb/ChangeLog:

	* macrocmd.c (print_macro_callback): Add cast(s).
	* macrotab.c (macro_bcache_str): Likewise.
	(new_macro_definition): Likewise.
	* main.c (captured_main): Likewise.
	* maint.c (print_bfd_section_info): Likewise.
	* mdebugread.c (mdebug_build_psymtabs): Likewise.
	(basic_type): Likewise.
	* memattr.c (mem_region_cmp): Likewise.
	* memory-map.c (memory_map_start_memory): Likewise.
	(memory_map_end_memory): Likewise.
	(memory_map_start_property): Likewise.
	(memory_map_end_property): Likewise.
	(clear_result): Likewise.
	* memrange.c (compare_mem_ranges): Likewise.
	* mep-tdep.c (mep_analyze_frame_prologue): Likewise.
	* mi/mi-cmd-var.c (mi_cmd_var_update_iter): Likewise.
	* mi/mi-console.c (mi_console_file_delete): Likewise.
	(mi_console_file_fputs): Likewise.
	(mi_console_raw_packet): Likewise.
	(mi_console_file_flush): Likewise.
	(mi_console_set_raw): Likewise.
	* mi/mi-interp.c (mi_interpreter_resume): Likewise.
	(mi_new_thread): Likewise.
	(mi_thread_exit): Likewise.
	(mi_record_changed): Likewise.
	(mi_inferior_added): Likewise.
	(mi_inferior_appeared): Likewise.
	(mi_inferior_exit): Likewise.
	(mi_inferior_removed): Likewise.
	(mi_interp_data): Likewise.
	(mi_on_normal_stop): Likewise.
	(mi_traceframe_changed): Likewise.
	(mi_tsv_created): Likewise.
	(mi_tsv_deleted): Likewise.
	(mi_tsv_modified): Likewise.
	(mi_breakpoint_created): Likewise.
	(mi_breakpoint_deleted): Likewise.
	(mi_breakpoint_modified): Likewise.
	(mi_output_running_pid): Likewise.
	(mi_inferior_count): Likewise.
	(mi_solib_loaded): Likewise.
	(mi_solib_unloaded): Likewise.
	(mi_command_param_changed): Likewise.
	(mi_memory_changed): Likewise.
	(report_initial_inferior): Likewise.
	(mi_ui_out): Likewise.
	(mi_set_logging): Likewise.
	* mi/mi-main.c (collect_cores): Likewise.
	(print_one_inferior): Likewise.
	(free_vector_of_ints): Likewise.
	(free_splay_tree): Likewise.
	(mi_execute_command): Likewise.
	* mi/mi-out.c (mi_table_body): Likewise.
	(mi_table_end): Likewise.
	(mi_table_header): Likewise.
	(mi_begin): Likewise.
	(mi_end): Likewise.
	(mi_field_int): Likewise.
	(mi_field_string): Likewise.
	(mi_field_fmt): Likewise.
	(mi_flush): Likewise.
	(mi_redirect): Likewise.
	(field_separator): Likewise.
	(mi_open): Likewise.
	(mi_close): Likewise.
	(mi_out_buffered): Likewise.
	(mi_out_rewind): Likewise.
	(mi_out_put): Likewise.
	(mi_version): Likewise.
	(mi_out_data_dtor): Likewise.
	* mi/mi-parse.c (mi_parse_cleanup): Likewise.
	* microblaze-tdep.c (microblaze_frame_cache): Likewise.
	* minidebug.c (lzma_open): Likewise.
	(lzma_pread): Likewise.
	(lzma_close): Likewise.
	(lzma_stat): Likewise.
	* mips-linux-tdep.c (mips_linux_init_abi): Likewise.
	* mips-sde-tdep.c (mips_sde_frame_cache): Likewise.
	(mips_sde_elf_osabi_sniff_abi_tag_sections): Likewise.
	* mips-tdep.c (mips_insn16_frame_cache): Likewise.
	(mips_micro_frame_cache): Likewise.
	(mips_insn32_frame_cache): Likewise.
	(mips_stub_frame_cache): Likewise.
	(gdb_print_insn_mips): Likewise.
	(value_of_mips_user_reg): Likewise.
	(mips_gdbarch_init): Likewise.
	* mips64obsd-tdep.c (mips64obsd_supply_gregset): Likewise.
	* mipsnbsd-tdep.c (mipsnbsd_supply_fpregset): Likewise.
	(mipsnbsd_supply_gregset): Likewise.
	* mn10300-linux-tdep.c (am33_supply_fpregset_method): Likewise.
	(am33_collect_gregset_method): Likewise.
	(am33_collect_fpregset_method): Likewise.
	* mn10300-tdep.c (mn10300_analyze_frame_prologue): Likewise.
	* moxie-tdep.c (moxie_frame_cache): Likewise.
	* msp430-tdep.c (msp430_get_opcode_byte): Likewise.
	(msp430_analyze_frame_prologue): Likewise.
	* mt-tdep.c (mt_frame_unwind_cache): Likewise.
	* nios2-linux-tdep.c (nios2_supply_gregset): Likewise.
	(nios2_collect_gregset): Likewise.
	* nios2-tdep.c (nios2_frame_unwind_cache): Likewise.
	(nios2_stub_frame_cache): Likewise.
	* objc-lang.c (find_methods): Likewise.
	* objfiles.c (objfiles_pspace_data_cleanup): Likewise.
	(get_objfile_pspace_data): Likewise.
	(get_objfile_bfd_data): Likewise.
	(objfile_bfd_data_free): Likewise.
	(add_to_objfile_sections): Likewise.
	(do_free_objfile_cleanup): Likewise.
	(resume_section_map_updates_cleanup): Likewise.
	* opencl-lang.c (builtin_opencl_type): Likewise.
	* osabi.c (generic_elf_osabi_sniff_abi_tag_sections): Likewise.
	* osdata.c (osdata_start_osdata): Likewise.
	(osdata_start_item): Likewise.
	(osdata_start_column): Likewise.
	(osdata_end_column): Likewise.
	(clear_parsing_data): Likewise.
	(osdata_free_cleanup): Likewise.
	* parse.c (type_stack_cleanup): Likewise.
	(exp_uses_objfile_iter): Likewise.
	* ppc-linux-tdep.c (ppc_linux_supply_gregset): Likewise.
	(ppc_linux_collect_gregset): Likewise.
	(ppu2spu_prev_arch): Likewise.
	(ppu2spu_this_id): Likewise.
	(ppu2spu_prev_register): Likewise.
	(ppu2spu_unwind_register): Likewise.
	(ppu2spu_sniffer): Likewise.
	(ppu2spu_dealloc_cache): Likewise.
	(ppc_linux_init_abi): Likewise.
	* ppcfbsd-tdep.c (ppcfbsd_sigtramp_frame_cache): Likewise.
	* ppcobsd-tdep.c (ppcobsd_sigtramp_frame_cache): Likewise.
	* progspace.c (restore_program_space): Likewise.
	* psymtab.c (find_pc_sect_psymtab): Likewise.
	(compare_psymbols): Likewise.
	(psymbol_bcache_full): Likewise.
	(allocate_psymtab): Likewise.
	(discard_psymtabs_upto): Likewise.
	* python/py-block.c (set_block): Likewise.
	(del_objfile_blocks): Likewise.
	* python/py-breakpoint.c (build_bp_list): Likewise.
	* python/py-inferior.c (inferior_to_inferior_object): Likewise.
	(build_inferior_list): Likewise.
	(py_free_inferior): Likewise.
	* python/py-objfile.c (py_free_objfile): Likewise.
	(objfile_to_objfile_object): Likewise.
	* python/py-prettyprint.c (py_restore_tstate): Likewise.
	* python/py-progspace.c (py_free_pspace): Likewise.
	(pspace_to_pspace_object): Likewise.
	* python/py-symbol.c (set_symbol): Likewise.
	(del_objfile_symbols): Likewise.
	* python/py-symtab.c (set_sal): Likewise.
	(set_symtab): Likewise.
	(del_objfile_symtab): Likewise.
	(del_objfile_sal): Likewise.
	* python/py-type.c (save_objfile_types): Likewise.
	(set_type): Likewise.
	* python/py-unwind.c (pyuw_prev_register): Likewise.
	(pyuw_on_new_gdbarch): Likewise.
	* python/py-utils.c (py_decref): Likewise.
	(py_xdecref): Likewise.
	(gdb_py_generic_dict): Likewise.
	* python/py-xmethods.c (gdbpy_free_xmethod_worker_data): Likewise.
	(gdbpy_clone_xmethod_worker_data): Likewise.
	(gdbpy_get_xmethod_arg_types): Likewise.
	(gdbpy_get_xmethod_result_type): Likewise.
	(gdbpy_invoke_xmethod): Likewise.
	* python/python.c (gdbpy_apply_type_printers): Likewise.
	(gdbpy_free_type_printers): Likewise.
	* record-btrace.c (record_btrace_disable_callback): Likewise.
	(bfcache_hash): Likewise.
	(bfcache_eq): Likewise.
	(btrace_get_frame_function): Likewise.
	(record_btrace_frame_unwind_stop_reason): Likewise.
	(record_btrace_frame_this_id): Likewise.
	(record_btrace_frame_prev_register): Likewise.
	(record_btrace_frame_dealloc_cache): Likewise.
	* record-full.c (record_full_message_wrapper): Likewise.
	(record_full_save_cleanups): Likewise.
	* regcache.c (regcache_descr): Likewise.
	(do_regcache_xfree): Likewise.
	(do_regcache_invalidate): Likewise.
	(do_cooked_read): Likewise.
	(regcache_transfer_regset): Likewise.
	* reggroups.c (reggroup_add): Likewise.
	(reggroup_next): Likewise.
	(reggroup_prev): Likewise.
	* remote-fileio.c (do_remote_fileio_request): Likewise.
	* remote-notif.c (remote_async_get_pending_events_handler): Likewise.
	(do_notif_event_xfree): Likewise.
	* remote.c (get_remote_arch_state): Likewise.
	(remote_pspace_data_cleanup): Likewise.
	(get_remote_exec_file): Likewise.
	(set_pspace_remote_exec_file): Likewise.
	(compare_pnums): Likewise.
	(clear_threads_listing_context): Likewise.
	(remote_newthread_step): Likewise.
	(start_thread): Likewise.
	(end_thread): Likewise.
	(remove_child_of_pending_fork): Likewise.
	(remove_stop_reply_for_inferior): Likewise.
	(remove_stop_reply_of_remote_state): Likewise.
	(remote_notif_remove_once_on_match): Likewise.
	(stop_reply_match_ptid_and_ws): Likewise.
	(kill_child_of_pending_fork): Likewise.
	(register_remote_g_packet_guess): Likewise.
	(remote_read_description_p): Likewise.
	(remote_read_description): Likewise.
	(free_actions_list_cleanup_wrapper): Likewise.
	(remote_async_serial_handler): Likewise.
	* rl78-tdep.c (rl78_get_opcode_byte): Likewise.
	(rl78_analyze_frame_prologue): Likewise.
	* rs6000-tdep.c (ppc_supply_gregset): Likewise.
	(ppc_supply_fpregset): Likewise.
	(ppc_supply_vsxregset): Likewise.
	(ppc_supply_vrregset): Likewise.
	(ppc_collect_gregset): Likewise.
	(ppc_collect_fpregset): Likewise.
	(ppc_collect_vsxregset): Likewise.
	(ppc_collect_vrregset): Likewise.
	(e500_move_ev_register): Likewise.
	(do_regcache_raw_write): Likewise.
	(rs6000_frame_cache): Likewise.
	(rs6000_epilogue_frame_cache): Likewise.
	(rs6000_gdbarch_init): Likewise.
	* rx-tdep.c (rx_get_opcode_byte): Likewise.
	(rx_analyze_frame_prologue): Likewise.
	(rx_frame_type): Likewise.
	(rx_frame_sniffer_common): Likewise.
	* s390-linux-tdep.c (s390_check_for_saved): Likewise.
	(s390_frame_unwind_cache): Likewise.
	(s390_stub_frame_unwind_cache): Likewise.
	(s390_sigtramp_frame_unwind_cache): Likewise.
	* score-tdep.c (score_make_prologue_cache): Likewise.
	* sentinel-frame.c (sentinel_frame_prev_register): Likewise.
	(sentinel_frame_prev_arch): Likewise.
	* ser-base.c (fd_event): Likewise.
	(push_event): Likewise.
	(ser_base_write): Likewise.
	* ser-pipe.c (pipe_close): Likewise.
	* serial.c (serial_write): Likewise.
	* sh-tdep.c (sh_frame_cache): Likewise.
	(sh_stub_this_id): Likewise.
	* sh64-tdep.c (sh64_frame_cache): Likewise.
	* solib-aix.c (get_solib_aix_inferior_data): Likewise.
	(library_list_start_library): Likewise.
	(library_list_start_list): Likewise.
	(solib_aix_free_library_list): Likewise.
	* solib-darwin.c (get_darwin_info): Likewise.
	* solib-dsbt.c (get_dsbt_info): Likewise.
	* solib-spu.c (append_ocl_sos): Likewise.
	* solib-svr4.c (svr4_pspace_data_cleanup): Likewise.
	(get_svr4_info): Likewise.
	(library_list_start_library): Likewise.
	(svr4_library_list_start_list): Likewise.
	(hash_probe_and_action): Likewise.
	(equal_probe_and_action): Likewise.
	(svr4_update_solib_event_breakpoint): Likewise.
	(set_solib_svr4_fetch_link_map_offsets): Likewise.
	(svr4_fetch_link_map_offsets): Likewise.
	(svr4_have_link_map_offsets): Likewise.
	* solib-target.c (library_list_start_segment): Likewise.
	(library_list_start_section): Likewise.
	(library_list_start_library): Likewise.
	(library_list_end_library): Likewise.
	(library_list_start_list): Likewise.
	(solib_target_free_library_list): Likewise.
	* solib.c (solib_ops): Likewise.
	(set_solib_ops): Likewise.
	* sparc-sol2-tdep.c (sparc32_sol2_sigtramp_frame_cache): Likewise.
	* sparc-tdep.c (sparc_frame_cache): Likewise.
	(sparc32_frame_cache): Likewise.
	(sparc32_supply_gregset): Likewise.
	(sparc32_collect_gregset): Likewise.
	(sparc32_supply_fpregset): Likewise.
	(sparc32_collect_fpregset): Likewise.
	* sparc64-sol2-tdep.c (sparc64_sol2_sigtramp_frame_cache): Likewise.
	* sparc64-tdep.c (sparc64_supply_gregset): Likewise.
	(sparc64_collect_gregset): Likewise.
	(sparc64_supply_fpregset): Likewise.
	(sparc64_collect_fpregset): Likewise.
	* sparc64fbsd-tdep.c (sparc64fbsd_sigtramp_frame_cache): Likewise.
	* sparc64nbsd-tdep.c (sparc64nbsd_sigcontext_frame_cache): Likewise.
	* sparc64obsd-tdep.c (sparc64obsd_frame_cache): Likewise.
	(sparc64obsd_trapframe_cache): Likewise.
	* sparcnbsd-tdep.c (sparc32nbsd_sigcontext_frame_cache): Likewise.
	* sparcobsd-tdep.c (sparc32obsd_sigtramp_frame_cache): Likewise.
	* spu-multiarch.c (spu_gdbarch): Likewise.
	* spu-tdep.c (spu_frame_unwind_cache): Likewise.
	(spu2ppu_prev_arch): Likewise.
	(spu2ppu_this_id): Likewise.
	(spu2ppu_prev_register): Likewise.
	(spu2ppu_dealloc_cache): Likewise.
	(spu_dis_asm_print_address): Likewise.
	(gdb_print_insn_spu): Likewise.
	(spu_get_overlay_table): Likewise.
	* stabsread.c (rs6000_builtin_type): Likewise.
	* stack.c (do_print_variable_and_value): Likewise.
	* stap-probe.c (get_stap_base_address_1): Likewise.
	* symfile-debug.c (debug_qf_has_symbols): Likewise.
	(debug_qf_find_last_source_symtab): Likewise.
	(debug_qf_forget_cached_source_info): Likewise.
	(debug_qf_map_symtabs_matching_filename): Likewise.
	(debug_qf_lookup_symbol): Likewise.
	(debug_qf_print_stats): Likewise.
	(debug_qf_dump): Likewise.
	(debug_qf_relocate): Likewise.
	(debug_qf_expand_symtabs_for_function): Likewise.
	(debug_qf_expand_all_symtabs): Likewise.
	(debug_qf_expand_symtabs_with_fullname): Likewise.
	(debug_qf_map_matching_symbols): Likewise.
	(debug_qf_expand_symtabs_matching): Likewise.
	(debug_qf_find_pc_sect_compunit_symtab): Likewise.
	(debug_qf_map_symbol_filenames): Likewise.
	(debug_sym_get_probes): Likewise.
	(debug_sym_new_init): Likewise.
	(debug_sym_init): Likewise.
	(debug_sym_read): Likewise.
	(debug_sym_read_psymbols): Likewise.
	(debug_sym_finish): Likewise.
	(debug_sym_offsets): Likewise.
	(debug_sym_read_linetable): Likewise.
	(debug_sym_relocate): Likewise.
	(uninstall_symfile_debug_logging): Likewise.
	* symfile-mem.c (symbol_file_add_from_memory_wrapper): Likewise.
	* symfile.c (place_section): Likewise.
	(add_section_size_callback): Likewise.
	(load_progress): Likewise.
	(load_section_callback): Likewise.
	(clear_memory_write_data): Likewise.
	(allocate_symtab): Likewise.
	* symmisc.c (maintenance_expand_file_matcher): Likewise.
	* symtab.c (lookup_symtab_callback): Likewise.
	(hash_demangled_name_entry): Likewise.
	(eq_demangled_name_entry): Likewise.
	(get_symbol_cache): Likewise.
	(symbol_cache_cleanup): Likewise.
	(set_symbol_cache_size): Likewise.
	(symbol_cache_flush): Likewise.
	(maintenance_print_symbol_cache): Likewise.
	(maintenance_print_symbol_cache_statistics): Likewise.
	(delete_filename_seen_cache): Likewise.
	(output_partial_symbol_filename): Likewise.
	(search_symbols_file_matches): Likewise.
	(search_symbols_name_matches): Likewise.
	(do_free_completion_list): Likewise.
	(maybe_add_partial_symtab_filename): Likewise.
	(get_main_info): Likewise.
	(main_info_cleanup): Likewise.
	* target-dcache.c (target_dcache_cleanup): Likewise.
	(target_dcache_init_p): Likewise.
	(target_dcache_invalidate): Likewise.
	(target_dcache_get): Likewise.
	(target_dcache_get_or_init): Likewise.
	* target-descriptions.c (target_find_description): Likewise.
	(tdesc_find_type): Likewise.
	(tdesc_data_cleanup): Likewise.
	(tdesc_find_arch_register): Likewise.
	(tdesc_register_name): Likewise.
	(tdesc_register_type): Likewise.
	(tdesc_register_reggroup_p): Likewise.
	(set_tdesc_pseudo_register_name): Likewise.
	(set_tdesc_pseudo_register_type): Likewise.
	(set_tdesc_pseudo_register_reggroup_p): Likewise.
	(tdesc_use_registers): Likewise.
	(free_target_description): Likewise.
	* target-memory.c (compare_block_starting_address): Likewise.
	(cleanup_request_data): Likewise.
	(cleanup_write_requests_vector): Likewise.
	* target.c (open_target): Likewise.
	(cleanup_restore_target_terminal): Likewise.
	(free_memory_read_result_vector): Likewise.
	* thread.c (disable_thread_stack_temporaries): Likewise.
	(finish_thread_state_cleanup): Likewise.
	(do_restore_current_thread_cleanup): Likewise.
	(restore_current_thread_cleanup_dtor): Likewise.
	(set_thread_refcount): Likewise.
	(tp_array_compar): Likewise.
	(do_captured_thread_select): Likewise.
	* tic6x-tdep.c (tic6x_frame_unwind_cache): Likewise.
	(tic6x_stub_this_id): Likewise.
	* tilegx-tdep.c (tilegx_frame_cache): Likewise.
	* top.c (do_restore_instream_cleanup): Likewise.
	(gdb_readline_wrapper_cleanup): Likewise.
	(kill_or_detach): Likewise.
	(print_inferior_quit_action): Likewise.
	* tracefile-tfile.c (match_blocktype): Likewise.
	(build_traceframe_info): Likewise.
	* tracefile.c (trace_file_writer_xfree): Likewise.
	* tracepoint.c (memrange_cmp): Likewise.
	(do_collect_symbol): Likewise.
	(do_clear_collection_list): Likewise.
	(do_restore_current_traceframe_cleanup): Likewise.
	(restore_current_traceframe_cleanup_dtor): Likewise.
	(free_current_marker): Likewise.
	(traceframe_info_start_memory): Likewise.
	(traceframe_info_start_tvar): Likewise.
	(free_result): Likewise.
	* tramp-frame.c (tramp_frame_cache): Likewise.
	* tui/tui-file.c (tui_file_delete): Likewise.
	(tui_fileopen): Likewise.
	(tui_sfileopen): Likewise.
	(tui_file_isatty): Likewise.
	(tui_file_rewind): Likewise.
	(tui_file_put): Likewise.
	(tui_file_fputs): Likewise.
	(tui_file_get_strbuf): Likewise.
	(tui_file_adjust_strbuf): Likewise.
	(tui_file_flush): Likewise.
	* tui/tui-layout.c (make_command_window): Likewise.
	(make_data_window): Likewise.
	(show_source_disasm_command): Likewise.
	(show_data): Likewise.
	(make_source_or_disasm_window): Likewise.
	(show_source_or_disasm_and_command): Likewise.
	* tui/tui-out.c (tui_field_int): Likewise.
	(tui_field_string): Likewise.
	(tui_field_fmt): Likewise.
	(tui_text): Likewise.
	* typeprint.c (hash_typedef_field): Likewise.
	(eq_typedef_field): Likewise.
	(do_free_typedef_hash): Likewise.
	(copy_typedef_hash_element): Likewise.
	(do_free_global_table): Likewise.
	(find_global_typedef): Likewise.
	(find_typedef_in_hash): Likewise.
	* ui-file.c (ui_file_write_for_put): Likewise.
	(do_ui_file_xstrdup): Likewise.
	(mem_file_delete): Likewise.
	(mem_file_rewind): Likewise.
	(mem_file_put): Likewise.
	(mem_file_write): Likewise.
	(stdio_file_delete): Likewise.
	(stdio_file_flush): Likewise.
	(stdio_file_read): Likewise.
	(stdio_file_write): Likewise.
	(stdio_file_write_async_safe): Likewise.
	(stdio_file_fputs): Likewise.
	(stdio_file_isatty): Likewise.
	(stdio_file_fseek): Likewise.
	(tee_file_delete): Likewise.
	(tee_file_flush): Likewise.
	(tee_file_write): Likewise.
	(tee_file_fputs): Likewise.
	(tee_file_isatty): Likewise.
	* ui-out.c (do_cleanup_table_end): Likewise.
	(do_cleanup_end): Likewise.
	* user-regs.c (user_reg_add): Likewise.
	(user_reg_map_name_to_regnum): Likewise.
	(usernum_to_user_reg): Likewise.
	(maintenance_print_user_registers): Likewise.
	* utils.c (do_bfd_close_cleanup): Likewise.
	(do_fclose_cleanup): Likewise.
	(do_obstack_free): Likewise.
	(do_ui_file_delete): Likewise.
	(do_ui_out_redirect_pop): Likewise.
	(do_free_section_addr_info): Likewise.
	(restore_integer): Likewise.
	(do_unpush_target): Likewise.
	(do_htab_delete_cleanup): Likewise.
	(do_restore_ui_file): Likewise.
	(do_value_free): Likewise.
	(do_free_so): Likewise.
	(free_current_contents): Likewise.
	(do_regfree_cleanup): Likewise.
	(core_addr_hash): Likewise.
	(core_addr_eq): Likewise.
	(do_free_char_ptr_vec): Likewise.
	* v850-tdep.c (v850_frame_cache): Likewise.
	* varobj.c (do_free_variable_cleanup): Likewise.
	* vax-tdep.c (vax_supply_gregset): Likewise.
	(vax_frame_cache): Likewise.
	* vaxobsd-tdep.c (vaxobsd_sigtramp_frame_cache): Likewise.
	* xml-support.c (gdb_xml_body_text): Likewise.
	(gdb_xml_values_cleanup): Likewise.
	(gdb_xml_start_element): Likewise.
	(gdb_xml_start_element_wrapper): Likewise.
	(gdb_xml_end_element): Likewise.
	(gdb_xml_end_element_wrapper): Likewise.
	(gdb_xml_cleanup): Likewise.
	(gdb_xml_fetch_external_entity): Likewise.
	(gdb_xml_parse_attr_enum): Likewise.
	(xinclude_start_include): Likewise.
	(xinclude_end_include): Likewise.
	(xml_xinclude_default): Likewise.
	(xml_xinclude_start_doctype): Likewise.
	(xml_xinclude_end_doctype): Likewise.
	(xml_xinclude_cleanup): Likewise.
	(xml_fetch_content_from_file): Likewise.
	* xml-syscall.c (free_syscalls_info): Likewise.
	(syscall_start_syscall): Likewise.
	* xml-tdesc.c (tdesc_end_arch): Likewise.
	(tdesc_end_osabi): Likewise.
	(tdesc_end_compatible): Likewise.
	(tdesc_start_target): Likewise.
	(tdesc_start_feature): Likewise.
	(tdesc_start_reg): Likewise.
	(tdesc_start_union): Likewise.
	(tdesc_start_struct): Likewise.
	(tdesc_start_flags): Likewise.
	(tdesc_start_field): Likewise.
	(tdesc_start_vector): Likewise.
	(fetch_available_features_from_target): Likewise.
	* xstormy16-tdep.c (xstormy16_frame_cache): Likewise.
	* xtensa-tdep.c (xtensa_supply_gregset): Likewise.
	(xtensa_frame_cache): Likewise.
	(xtensa_frame_prev_register): Likewise.
	(xtensa_extract_return_value): Likewise.
2015-09-25 14:08:07 -04:00
Markus Metzger d2939ba2b4 btrace: honour scheduler-locking for all-stop targets
In all-stop mode, record btrace maintains the old behaviour of an implicit
scheduler-locking on.

Now that we added a scheduler-locking mode to model this old behaviour, we
don't need the respective code in record btrace anymore.  Remove it.

For all-stop targets, step inferior_ptid and continue other threads matching
the argument ptid.  Assert that inferior_ptid matches the argument ptid.

This should make record btrace honour scheduler-locking.

gdb/
	* record-btrace.c (record_btrace_resume): Honour scheduler-locking.

testsuite/
	* gdb.btrace/multi-thread-step.exp: Test scheduler-locking on, step,
	and replay.
2015-09-18 14:33:16 +02:00
Markus Metzger f2665db5f2 infrun: scheduler-locking replay
Record targets behave as if scheduler-locking were on in replay mode.  Add a
new scheduler-locking option "replay" to make this implicit behaviour explicit.
It behaves like "on" in replay mode and like "off" in record mode.

By making the current behaviour a scheduler-locking option, we allow the user
to change it.  Since it is the current behaviour, this new option is also
the new default.

One caveat is that when resuming a thread that is at the end of its execution
history, record btrace implicitly stops replaying other threads and resumes
the entire process.  This is a convenience feature to not require the user
to explicitly move all other threads to the end of their execution histories
before being able to resume the process.

We mimick this behaviour with scheduler-locking replay and move it from
record-btrace into infrun.  With all-stop on top of non-stop, we can't do
this in record-btrace anymore.

Record full does not really support multi-threading and is therefore not
impacted.  If it were extended to support multi-threading, it would 'benefit'
from this change.  The good thing is that all record targets will behave the
same with respect to scheduler-locking.

I put the code for this into clear_proceed_status.  It also sends the
about_to_proceed notification.

gdb/
	* NEWS: Announce new scheduler-locking mode.
	* infrun.c (schedlock_replay): New.
	(scheduler_enums): Add schedlock_replay.
	(scheduler_mode): Change default to schedlock_replay.
	(user_visible_resume_ptid): Handle schedlock_replay.
	(clear_proceed_status_thread): Stop replaying if resumed thread is
	not replaying.
	(schedlock_applies): Handle schedlock_replay.
	(_initialize_infrun): Document new scheduler-locking mode.
	* record-btrace.c (record_btrace_resume): Remove code to stop other
	threads when not replaying the resumed thread.

doc/
	* gdb.texinfo (All-Stop Mode): Describe new scheduler-locking mode.
2015-09-18 14:32:00 +02:00
Markus Metzger 7ff27e9bab target: add to_record_will_replay target method
Add a new target method to_record_will_replay to query if there is a record
target that will replay at least one thread matching the argument PTID if it
were executed in the argument execution direction.

gdb/
	* record-btrace.c ((record_btrace_will_replay): New.
	(init_record_btrace_ops): Initialize to_record_will_replay.
	* record-full.c ((record_full_will_replay): New.
	(init_record_full_ops): Initialize to_record_will_replay.
	* target-delegates.c: Regenerated.
	* target.c (target_record_will_replay): New.
	* target.h (struct target_ops) <to_record_will_replay>: New.
	(target_record_will_replay): New.

Signed-off-by: Markus Metzger <markus.t.metzger@intel.com>
2015-09-18 14:30:49 +02:00
Markus Metzger 797094dddf target: add to_record_stop_replaying target method
Add a new target method to_record_stop_replaying to stop replaying.

gdb/
	* record-btrace.c (record_btrace_resume): Call
	target_record_stop_replaying.
	(record_btrace_stop_replaying_all): New.
	(init_record_btrace_ops): Initialize to_record_stop_replaying.
	* record-full.c (record_full_stop_replaying): New.
	(init_record_full_ops ): Initialize to_record_stop_replaying.
	* target-delegates.c: Regenerated.
	* target.c (target_record_stop_replaying): New.
	* target.h (struct target_ops) <to_record_stop_replaying>: New.
	(target_record_stop_replaying): New.
2015-09-18 14:30:12 +02:00
Markus Metzger 4d10e986f4 btrace: allow full memory and register access for non-replaying threads
The record btrace target does not allow accessing memory and storing registers
while replaying.  For multi-threaded applications, this prevents those
accesses also for threads that are at the end of their execution history as
long as at least one thread is replaying.

Change this to only check if the selected thread is replaying.  This allows
threads that are at the end of their execution history to read and write
memory and to store registers.

Also change the error message to reflect this change.

gdb/
	* record-btrace.c (record_btrace_xfer_partial)
	(record_btrace_store_registers, record_btrace_prepare_to_store):
	Call record_btrace_is_replaying with inferior_ptid instead of
	minus_one_ptid.
	(record_btrace_store_registers): Change error message.
2015-09-18 14:29:22 +02:00
Markus Metzger a52eab4808 target, record: add PTID argument to to_record_is_replaying
The to_record_is_replaying target method is used to query record targets if
they are replaying.  This is currently interpreted as "is any thread being
replayed".

Add a PTID argument and change the interpretation to "is any thread matching
PTID being replayed".

Change all users to pass minus_one_ptid to preserve the old meaning.

The record full target does not really support multi-threading and ignores
the PTID argument.

gdb/
	* record-btrace.c (record_btrace_is_replaying): Add ptid argument.
	Update users to pass minus_one_ptid.
	* record-full.c (record_full_is_replaying): Add ptid argument (ignored).
	* record.c (cmd_record_delete): Pass inferior_ptid to
	target_record_is_replaying.
	* target-delegates.c: Regenerated.
	* target.c (target_record_is_replaying): Add ptid argument.
	* target.h (struct target_ops) <to_record_is_replaying>: Add ptid
	argument.
	(target_record_is_replaying): Add ptid argument.
2015-09-18 14:28:43 +02:00
Markus Metzger cbb55fa7a1 btrace: non-stop
Support non-stop mode in record btrace.

gdb/
	* record-btrace.c (record_btrace_open): Remove non_stop check.
	* NEWS: Announce that record btrace supports non-stop mode.

testsuite/
	* gdb.btrace/non-stop.c: New.
	* gdb.btrace/non-stop.exp: New.
2015-09-18 14:27:56 +02:00
Markus Metzger a6b5be76f9 btrace: async
The record btrace target runs synchronous with GDB.  That is, GDB steps
resumed threads in record btrace's to_wait method.  Without GDB calling
to_wait, nothing happens 'on the target'.

Check for further expected events in to_wait before reporting the current
event and mark record btrace's async event handler in async mode.

gdb/
	* record-btrace.c (record_btrace_maybe_mark_async_event): New.
	(record_btrace_wait): Call record_btrace_maybe_mark_async_event.
2015-09-18 14:25:39 +02:00
Markus Metzger ec71cc2fc6 btrace: temporarily set inferior_ptid in record_btrace_start_replaying
Get_current_frame uses inferior_ptid.  In record_btrace_start_replaying,
we need to get the current frame of the argument thread.  So far, this
has always been inferior_ptid.  With non-stop, this is not guaranteed.

Temporarily set inferior_ptid to the ptid of the argument thread.

We already temporarily set the argument thread's executing flag to false.

Move both into a new function get_thread_current_frame that does the temporary
adjustments, calls get_current_frame, and restores the previous values.

gdb/
	* record-btrace.c (get_thread_current_frame): New.
	(record_btrace_start_replaying): Call get_thread_current_frame.
2015-09-18 14:25:05 +02:00
Markus Metzger 0ca912dfef btrace: resume all requested threads
The record targets are implicitly schedlocked.  They only step the current
thread and keep other threads where they are.

Change record btrace to step all requested threads in to_resume.

For maintenance and debugging, we keep the old behaviour when the target below
is not non-stop.  Enable with "maint set target-non-stop on".

gdb/
	* record-btrace.c (record_btrace_resume_thread): A move request
	overwrites a previous move request.
	(record_btrace_find_resume_thread): Removed.
	(record_btrace_resume): Resume all requested threads.
2015-09-18 14:24:25 +02:00
Markus Metzger e3cfc1c76d btrace: lock-step
Record btrace's to_wait method picks a single thread to step.  When passed
minus_one_ptid, it picks the current thread.  All other threads remain where
they are.

Change this to step all resumed threads together, one step at a time, until
the first thread reports an event.

We do delay reporting NO_HISTORY events until there are no other events to
report to prevent threads at the end of their execution history from starving
other threads.

We keep threads at the end of their execution history moving and replaying
until we announce their stop in to_wait.  This shouldn't really be user-visible
but its a detail worth mentioning.

Since record btrace's to_resume method also picks only a single thread to
resume, there shouldn't be a difference with the current all-stop.

With non-stop or all-stop on top of non-stop, we will see differences.  The
behaviour should be more natural as we're moving all threads.

gdb/
	* record-btrace.c: Include vec.h.
	(record_btrace_find_thread_to_move): Removed.
	(btrace_step_no_resumed, btrace_step_again)
	(record_btrace_stop_replaying_at_end): New.
	(record_btrace_cancel_resume): Call record_btrace_stop_replaying_at_end.
	(record_btrace_single_step_forward): Remove calls to
	record_btrace_stop_replaying.
	(record_btrace_step_thread): Do only one step for BTHR_CONT and
	BTHR_RCONT.  Keep threads at the end of their history moving.
	(record_btrace_wait): Call record_btrace_step_thread for all threads
	until one reports an event.  Call record_btrace_stop_replaying_at_end
	for the eventing thread.
2015-09-18 14:23:38 +02:00
Markus Metzger cf8f8f0c42 btrace: add missing NO_HISTORY
If a single-step ended right at the end of the execution history, we forgot
to announce that.  Fix it.

gdb/
	* record-btrace.c (record_btrace_single_step_forward): Return
	NO_HISTORY if a step brings us to the end of the execution history.
2015-09-18 14:22:54 +02:00
Markus Metzger 011c71b6cb btrace: move breakpoint checking into stepping functions
Breakpoints are only checked for BTHR_CONT and BTHR_RCONT stepping requests.
A BTHR_STEP and BTHR_RSTEP request will always report stopped without reason.
Since breakpoints are reported correctly, I assume infrun is handling this.

Move the breakpoint check into the btrace single stepping functions.  This
will cause us to report breakpoint hits now also for single-step requests.

One thing to notice is that

  - when executing forwards, the breakpoint is checked before 'executing'
    the instruction, i.e. before moving the PC to the next instruction.

  - when executing backwards,  the breakpoint is checked after 'executing'
    the instruction, i.e. after moving the PC to the preceding instruction
    in the recorded execution.

There is code in infrun (see, for example proceed and adjust_pc_after_break)
that handles this and also depends on this behaviour.

gdb/
	* record-btrace.c (record_btrace_step_thread): Move breakpoint check
	to ...
	(record_btrace_single_step_forward): ... here and
	(record_btrace_single_step_backward): ... here.
2015-09-18 14:22:09 +02:00
Markus Metzger d825d24810 btrace: split record_btrace_step_thread
The code for BTHR_STEP and BTHR_CONT is fairly similar.  Extract the common
parts into a new function record_btrace_single_step_forward.  The function
returns TARGET_WAITKIND_SPURIOUS to indicate that the single-step completed
without triggering a trap.

Same for BTHR_RSTEP and BTHR_RCONT.

gdb/
	* record-btrace.c (btrace_step_spurious)
	(record_btrace_single_step_forward)
	(record_btrace_single_step_backward): New.
	(record_btrace_step_thread): Call record_btrace_single_step_forward
	and record_btrace_single_step_backward.
2015-09-18 14:21:31 +02:00
Markus Metzger 3c615f99d3 btrace: extract the breakpoint check from record_btrace_step_thread
There are two places where record_btrace_step_thread checks for a breakpoint
at the current replay position.  Move this code into its own function.

gdb/
	* record-btrace.c (record_btrace_replay_at_breakpoint): New.
	(record_btrace_step_thread): Call record_btrace_replay_at_breakpoint.
2015-09-18 14:20:44 +02:00
Markus Metzger 987e68b1a3 btrace: improve stepping debugging
gdb/
	* record-btrace.c (btrace_thread_flag_to_str)
	(record_btrace_cancel_resume): New.
	(record_btrace_step_thread): Call btrace_thread_flag_to_str.
	(record_btrace_resume): Print execution direction.
	(record_btrace_resume_thread): Call btrace_thread_flag_to_str.
	(record_btrace_wait): Call record_btrace_cancel_resume.
2015-09-18 14:20:04 +02:00
Markus Metzger 6e4879f0eb btrace: support to_stop
Add support for the to_stop target method to the btrace record target.

gdb/
	* btrace.h (enum btrace_thread_flag) <BTHR_STOP>: New.
	* record-btrace (record_btrace_resume_thread): Clear BTHR_STOP.
	(record_btrace_find_thread_to_move): Also accept threads that have
	BTHR_STOP set.
	(btrace_step_stopped_on_request, record_btrace_stop): New.
	(record_btrace_step_thread): Support BTHR_STOP.
	(record_btrace_wait): Also clear BTHR_STOP when stopping other threads.
	(init_record_btrace_ops): Initialize to_stop.
2015-09-18 14:19:02 +02:00
Markus Metzger 5953356cc4 btrace: fix non-stop check in to_wait
The record btrace target stops other threads in non-stop mode after stepping
the to-be-resumed thread.

The check is done on the non_stop variable.  It should rather be done on
target_is_non_stop_p ().  With all-stop on top of non-stop, infrun will
take care of stopping other threads.

gdb/
	* record-btrace.c (record_btrace_wait): Replace non_stop check with
	target_is_non_stop_p ().
2015-09-18 14:17:41 +02:00
Simon Marchi 8d7493201c Replace some xmalloc-family functions with XNEW-family ones
This patch is part of the make-gdb-buildable-in-C++ effort.  The idea is
to change some calls to the xmalloc family of functions to calls to the
equivalents in the XNEW family.  This avoids adding an explicit cast, so
it keeps the code a bit more readable.  Some of them also map relatively
well to a C++ equivalent (XNEW (struct foo) -> new foo), so it will be
possible to do scripted replacements if needed.

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

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

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

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

gdb/ChangeLog:

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

gdb/gdbserver/ChangeLog:

	* ax.c (gdb_parse_agent_expr): Likewise.
	(compile_bytecodes): Likewise.
	* dll.c (loaded_dll): Likewise.
	* event-loop.c (append_callback_event): Likewise.
	(create_file_handler): Likewise.
	(create_file_event): Likewise.
	* hostio.c (handle_open): Likewise.
	* inferiors.c (add_thread): Likewise.
	(add_process): Likewise.
	* linux-aarch64-low.c (aarch64_linux_new_process): Likewise.
	* linux-arm-low.c (arm_new_process): Likewise.
	(arm_new_thread): Likewise.
	* linux-low.c (add_to_pid_list): Likewise.
	(linux_add_process): Likewise.
	(handle_extended_wait): Likewise.
	(add_lwp): Likewise.
	(enqueue_one_deferred_signal): Likewise.
	(enqueue_pending_signal): Likewise.
	(linux_resume_one_lwp_throw): Likewise.
	(linux_resume_one_thread): Likewise.
	(linux_read_memory): Likewise.
	(linux_write_memory): Likewise.
	* linux-mips-low.c (mips_linux_new_process): Likewise.
	(mips_linux_new_thread): Likewise.
	(mips_add_watchpoint): Likewise.
	* linux-x86-low.c (initialize_low_arch): Likewise.
	* lynx-low.c (lynx_add_process): Likewise.
	* mem-break.c (set_raw_breakpoint_at): Likewise.
	(set_breakpoint): Likewise.
	(add_condition_to_breakpoint): Likewise.
	(add_commands_to_breakpoint): Likewise.
	(clone_agent_expr): Likewise.
	(clone_one_breakpoint): Likewise.
	* regcache.c (new_register_cache): Likewise.
	* remote-utils.c (look_up_one_symbol): Likewise.
	* server.c (queue_stop_reply): Likewise.
	(start_inferior): Likewise.
	(queue_stop_reply_callback): Likewise.
	(handle_target_event): Likewise.
	* spu-low.c (fetch_ppc_memory): Likewise.
	(store_ppc_memory): Likewise.
	* target.c (set_target_ops): Likewise.
	* thread-db.c (thread_db_load_search): Likewise.
	(try_thread_db_load_1): Likewise.
	* tracepoint.c (add_tracepoint): Likewise.
	(add_tracepoint_action): Likewise.
	(create_trace_state_variable): Likewise.
	(cmd_qtdpsrc): Likewise.
	(cmd_qtro): Likewise.
	(add_while_stepping_state): Likewise.
	* win32-low.c (child_add_thread): Likewise.
	(get_image_name): Likewise.
2015-08-26 17:18:12 -04:00
Markus Metzger da8c46d296 btrace: indicate speculative execution
Indicate speculatively executed instructions with a leading '?'.  We use the
space that is normally used for the PC prefix.  In the case where the
instruction at the current PC had been executed speculatively before, the PC
prefix will be partially overwritten resulting in "?> ".

As a side-effect, the /p modifier to omit the PC prefix in the "record
instruction-history" command now uses a 3-space PC prefix "   " in order to
have enough space for the speculative execution indication.

gdb/
	* btrace.c (btrace_compute_ftrace_bts): Clear insn flags.
	(pt_btrace_insn_flags): New.
	(ftrace_add_pt): Call pt_btrace_insn_flags.
	* btrace.h (btrace_insn_flag): New.
	(btrace_insn) <flags>: New.
	* record-btrace.c (btrace_insn_history): Print insn prefix.
	* NEWS: Announce it.

doc/
	* gdb.texinfo (Process Record and Replay): Document prefixing of
	speculatively executed instructions in the "record instruction-history"
	command.

testsuite/
	* gdb.btrace/instruction_history.exp: Update.
	* gdb.btrace/tsx.exp: New.
	* gdb.btrace/tsx.c: New.
	* lib/gdb.exp (skip_tsx_tests, skip_btrace_pt_tests): New.
2015-08-07 10:22:39 +02:00
Markus Metzger 485668e5b3 record: set stop_pc in "record goto" command
When navigating in the recorded execution trace via "record goto", we do not
set stop_pc.  This may trigger an internal error in infrun.c when stepping
from that location.  Set it.

(gdb) rec full
(gdb) c
Continuing.

Breakpoint 1, foo (void) at foo.c:42
42             x = y
(gdb) rn
foo (void)
    at foo.c:41
41             y = x
(gdb) rec go end
Go forward to insn number 98724
    at foo.c:42
42             x = y
(gdb) n
infrun.c:2382: internal-error: resume: Assertion `sig != GDB_SIGNAL_0' failed.
A problem internal to GDB has been detected,
further debugging may prove unreliable.
Quit this debugging session? (y or n)

This happens because there's a breakpoint at PC when the "next"
is issued, so that breapoint should be immediately stepped over.
That should have been detected/done by proceed, here:

  if (addr == (CORE_ADDR) -1)
    {
      if (pc == stop_pc
	  && breakpoint_here_p (aspace, pc) == ordinary_breakpoint_here
	  && execution_direction != EXEC_REVERSE)
	/* There is a breakpoint at the address we will resume at,
	   step one instruction before inserting breakpoints so that
	   we do not stop right away (and report a second hit at this
	   breakpoint).

	   Note, we don't do this in reverse, because we won't
	   actually be executing the breakpoint insn anyway.
	   We'll be (un-)executing the previous instruction.  */
	tp->stepping_over_breakpoint = 1;

But since stop_pc was stale, the pc == stop_pc check failed, and left the
breakpont at PC inserted.

gdb/
	* record-btrace.c (record_btrace_goto_begin, record_btrace_goto_end)
	record_btrace_goto): Move call to print_stack_frame ...
	(record_btrace_set_replay): ... here.  Set stop_pc.
	* record-full.c (record_full_goto_entry): Set stop_pc.

testsuite/
	* gdb.btrace/record_goto-step.exp: New.
2015-07-10 09:19:27 +02:00
Markus Metzger b20a652466 btrace: support Intel(R) Processor Trace
Adds a new command "record btrace pt" to configure the kernel to use
Intel(R) Processor Trace instead of Branch Trace Strore.

The "record btrace" command chooses the tracing format automatically.

Intel(R) Processor Trace support requires Linux 4.1 and libipt.

gdb/
	* NEWS: Announce new commands "record btrace pt" and "record pt".
	Announce new options "set|show record btrace pt buffer-size".
	* btrace.c: Include "rsp-low.h".
	Include "inttypes.h".
	(btrace_add_pc): Add forward declaration.
	(pt_reclassify_insn, ftrace_add_pt, btrace_pt_readmem_callback)
	(pt_translate_cpu_vendor, btrace_finalize_ftrace_pt)
	(btrace_compute_ftrace_pt): New.
	(btrace_compute_ftrace): Support BTRACE_FORMAT_PT.
	(check_xml_btrace_version): Update version check.
	(parse_xml_raw, parse_xml_btrace_pt_config_cpu)
	(parse_xml_btrace_pt_raw, parse_xml_btrace_pt)
	(btrace_pt_config_cpu_attributes, btrace_pt_config_children)
	(btrace_pt_children): New.
	(btrace_children): Add support for "pt".
	(parse_xml_btrace_conf_pt, btrace_conf_pt_attributes): New.
	(btrace_conf_children): Add support for "pt".
	* btrace.h: Include "intel-pt.h".
	(btrace_pt_error): New.
	* common/btrace-common.c (btrace_format_string, btrace_data_fini)
	(btrace_data_empty): Support BTRACE_FORMAT_PT.
	* common/btrace-common.h (btrace_format): Add BTRACE_FORMAT_PT.
	(struct btrace_config_pt): New.
	(struct btrace_config)<pt>: New.
	(struct btrace_data_pt_config, struct btrace_data_pt): New.
	(struct btrace_data)<pt>: New.
	* features/btrace-conf.dtd (btrace-conf)<pt>: New.
	(pt): New.
	* features/btrace.dtd (btrace)<pt>: New.
	(pt, pt-config, cpu): New.
	* nat/linux-btrace.c (perf_event_read, perf_event_read_all)
	(perf_event_pt_event_type, kernel_supports_pt)
	(linux_supports_pt): New.
	(linux_supports_btrace): Support BTRACE_FORMAT_PT.
	(linux_enable_bts): Free tinfo on error.
	(linux_enable_pt): New.
	(linux_enable_btrace): Support BTRACE_FORMAT_PT.
	(linux_disable_pt): New.
	(linux_disable_btrace): Support BTRACE_FORMAT_PT.
	(linux_fill_btrace_pt_config, linux_read_pt): New.
	(linux_read_btrace): Support BTRACE_FORMAT_PT.
	* nat/linux-btrace.h (struct btrace_tinfo_pt): New.
	(struct btrace_target_info)<pt>: New.
	* record-btrace.c (set_record_btrace_pt_cmdlist)
	(show_record_btrace_pt_cmdlist): New.
	(record_btrace_print_pt_conf): New.
	(record_btrace_print_conf): Support BTRACE_FORMAT_PT.
	(btrace_ui_out_decode_error): Support BTRACE_FORMAT_PT.
	(cmd_record_btrace_pt_start): New.
	(cmd_record_btrace_start): Support BTRACE_FORMAT_PT.
	(cmd_set_record_btrace_pt, cmd_show_record_btrace_pt): New.
	(_initialize_record_btrace): Add new commands.
	* remote.c (PACKET_Qbtrace_pt, PACKET_Qbtrace_conf_pt_size): New.
	(remote_protocol_features): Add "Qbtrace:pt".
	Add "Qbtrace-conf:pt:size".
	(remote_supports_btrace): Support BTRACE_FORMAT_PT.
	(btrace_sync_conf): Support PACKET_Qbtrace_conf_pt_size.
	(remote_enable_btrace): Support BTRACE_FORMAT_PT.
	(_initialize_remote): Add new commands.

gdbserver/
	* linux-low.c: Include "rsp-low.h"
	(linux_low_encode_pt_config, linux_low_encode_raw): New.
	(linux_low_read_btrace): Support BTRACE_FORMAT_PT.
	(linux_low_btrace_conf): Support BTRACE_FORMAT_PT.
	(handle_btrace_enable_pt): New.
	(handle_btrace_general_set): Support "pt".
	(handle_btrace_conf_general_set): Support "pt:size".

doc/
	* gdb.texinfo (Process Record and Replay): Spell out that variables
	and registers are not available during btrace replay.
	Describe the new "record btrace pt" command.
	Describe the new "set|show record btrace pt buffer-size" options.
	(General Query Packets): Describe the new Qbtrace:pt and
	Qbtrace-conf:pt:size packets.
	Expand "bts" to "Branch Trace Store".
	Update the branch trace DTD.
2015-07-02 12:49:32 +02:00
Pedro Alves 6a3753b34b Simplify target_async hook interface
All callers of target_async pass it the same callback
(inferior_event_handler).  Since both common code and target backends
need to be able to put the target in and out of target async mode at
any given time, there's really no way that a different callback could
be passed.  This commit simplifies things, and removes the indirection
altogether.  Bonus: with this, gdb's target_async method ends up with
the same signature as gdbserver's.

Tested on x86_64 Fedora 20, native and gdbserver.

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

	* target.h <to_async>: Replace 'callback' and 'context' parameters
	with boolean 'enable' parameter.
	(target_async): Replace CALLBACK and CONTEXT parameters with
	boolean ENABLE parameter.
	* inf-loop.c (inferior_event_handler): Adjust.
	* linux-nat.c (linux_nat_attach, linux_nat_resume)
	(linux_nat_resume): Adjust.
	(async_client_callback, async_client_context): Delete.
	(handle_target_event): Call inferior_event_handler directly.
	(linux_nat_async): Replace 'callback' and 'context' parameters
	with boolean 'enable' parameter.  Adjust.  Remove references to
	async_client_callback and async_client_context.
	(linux_nat_close): Adjust.
	* record-btrace.c (record_btrace_async): Replace 'callback' and
	'context' parameters with boolean 'enable' parameter.  Adjust.
	(record_btrace_resume): Adjust.
	* record-full.c (record_full_async): Replace 'callback' and
	'context' parameters with boolean 'enable' parameter.  Adjust.
	(record_full_resume, record_full_core_resume): Adjust.
	* remote.c (struct remote_state) <async_client_callback,
	async_client_context>: Delete fields.
	(remote_start_remote, extended_remote_attach_1, remote_resume)
	(extended_remote_create_inferior): Adjust.
	(remote_async_serial_handler): Call inferior_event_handler
	directly.
	(remote_async): Replace 'callback' and 'context' parameters with
	boolean 'enable' parameter.  Adjust.
	* top.c (gdb_readline_wrapper_cleanup, gdb_readline_wrapper):
	Adjust.
	* target-delegates.c: Regenerate.
2015-03-25 11:28:31 +00:00
Pedro Alves 6c63c96a22 more making TRY/CATCH callers look more like real C++ try/catch blocks
All these were caught by actually making TRY/CATCH use try/catch
behind the scenes, which then resulted in the build failing (on x86_64
Fedora 20) because there was code between the try and catch blocks.

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

	* breakpoint.c (save_breakpoints): Adjust to avoid code between
	TRY and CATCH.
	* gdbtypes.c (safe_parse_type): Remove empty line.
	(types_deeply_equal):
	* guile/scm-frame.c (gdbscm_frame_name):
	* linux-thread-db.c (find_new_threads_once):
	* python/py-breakpoint.c (bppy_get_commands):
	* record-btrace.c (record_btrace_insert_breakpoint)
	(record_btrace_remove_breakpoint, record_btrace_start_replaying)
	(record_btrace_start_replaying): Adjust to avoid code between TRY
	and CATCH.
2015-03-07 15:19:57 +00:00