gdb/gdbserver/
2010-06-01 Pedro Alves <pedro@codesourcery.com>
Stan Shebs <stan@codesourcery.com>
* Makefile.in (IPA_DEPFILES, extra_libraries): New.
(all): Depend on $(extra_libraries).
(install-only): Install the IPA.
(IPA_OBJS, IPA_LIB): New.
(clean): Remove the IPA lib.
(IPAGENT_CFLAGS): New.
(tracepoint-ipa.o, utils-ipa.o, remote-utils-ipa.o)
(regcache-ipa.o, i386-linux-ipa.o, linux-i386-ipa.o)
(linux-amd64-ipa.o, amd64-linux-ipa.o): New rules.
* linux-amd64-ipa.c, linux-i386-ipa.c: New files.
* configure.ac: Check for atomic builtins support in the compiler.
(IPA_DEPFILES, extra_libraries): Define.
* configure.srv (ipa_obj): Add description.
(ipa_i386_linux_regobj, ipa_amd64_linux_regobj): Define.
(i[34567]86-*-linux*): Set ipa_obj.
(x86_64-*-linux*): Set ipa_obj.
* linux-low.c (stabilizing_threads): New.
(supports_fast_tracepoints): New.
(linux_detach): Stabilize threads before detaching.
(handle_tracepoints): Handle internal tracing breakpoints. Assert
the lwp is either not stabilizing, or is moving out of a jump pad.
(linux_fast_tracepoint_collecting): New.
(maybe_move_out_of_jump_pad): New.
(enqueue_one_deferred_signal): New.
(dequeue_one_deferred_signal): New.
(linux_wait_for_event_1): If moving out of a jump pad, defer
pending signals to later.
(linux_stabilize_threads): New.
(linux_wait_1): Check if threads need moving out of jump pads, and
do it if so.
(stuck_in_jump_pad_callback): New.
(move_out_of_jump_pad_callback): New.
(lwp_running): New.
(linux_resume_one_lwp): Handle moving out of jump pads.
(linux_set_resume_request): Dequeue deferred signals.
(need_step_over_p): Also step over fast tracepoint jumps.
(start_step_over): Also uninsert fast tracepoint jumps.
(finish_step_over): Also reinsert fast tracepoint jumps.
(linux_install_fast_tracepoint_jump): New.
(linux_target_ops): Install linux_stabilize_threads and
linux_install_fast_tracepoint_jump_pad.
* linux-low.h (linux_target_ops) <get_thread_area,
install_fast_tracepoint_jump_pad>: New fields.
(struct lwp_info) <collecting_fast_tracepoint,
pending_signals_to_report, exit_jump_pad_bkpt>: New fields.
(linux_get_thread_area): Declare.
* linux-x86-low.c (jump_insn): New.
(x86_get_thread_area): New.
(append_insns): New.
(push_opcode): New.
(amd64_install_fast_tracepoint_jump_pad): New.
(i386_install_fast_tracepoint_jump_pad): New.
(x86_install_fast_tracepoint_jump_pad): New.
(the_low_target): Install x86_get_thread_area and
x86_install_fast_tracepoint_jump_pad.
* mem-break.c (set_raw_breakpoint_at): Use read_inferior_memory.
(struct fast_tracepoint_jump): New.
(fast_tracepoint_jump_insn): New.
(fast_tracepoint_jump_shadow): New.
(find_fast_tracepoint_jump_at): New.
(fast_tracepoint_jump_here): New.
(delete_fast_tracepoint_jump): New.
(set_fast_tracepoint_jump): New.
(uninsert_fast_tracepoint_jumps_at): New.
(reinsert_fast_tracepoint_jumps_at): New.
(set_breakpoint_at): Use write_inferior_memory.
(uninsert_raw_breakpoint): Use write_inferior_memory.
(check_mem_read): Mask out fast tracepoint jumps.
(check_mem_write): Mask out fast tracepoint jumps.
* mem-break.h (struct fast_tracepoint_jump): Forward declare.
(set_fast_tracepoint_jump): Declare.
(delete_fast_tracepoint_jump)
(fast_tracepoint_jump_here, uninsert_fast_tracepoint_jumps_at)
(reinsert_fast_tracepoint_jumps_at): Declare.
* regcache.c: Don't compile many functions when building the
in-process agent library.
(init_register_cache) [IN_PROCESS_AGENT]: Don't allow allocating
the register buffer in the heap.
(free_register_cache): If the register buffer isn't owned by the
regcache, don't free it.
(set_register_cache) [IN_PROCESS_AGENT]: Don't re-alocate
pre-existing register caches.
* remote-utils.c (convert_int_to_ascii): Constify `from' parameter
type.
(convert_ascii_to_int): : Constify `from' parameter type.
(decode_M_packet, decode_X_packet): Replace the `to' parameter by
a `to_p' pointer to pointer parameter. If TO_P is NULL, malloc
the needed buffer in-place.
(relocate_instruction): New.
* server.c (handle_query) <qSymbols>: If the target supports
tracepoints, give it a chance of looking up symbols. Report
support for fast tracepoints.
(handle_status): Stabilize threads.
(process_serial_event): Adjust.
* server.h (struct fast_tracepoint_jump): Forward declare.
(struct process_info) <fast_tracepoint_jumps>: New field.
(convert_ascii_to_int, convert_int_to_ascii): Adjust.
(decode_X_packet, decode_M_packet): Adjust.
(relocate_instruction): Declare.
(in_process_agent_loaded): Declare.
(tracepoint_look_up_symbols): Declare.
(struct fast_tpoint_collect_status): Declare.
(fast_tracepoint_collecting): Declare.
(force_unlock_trace_buffer): Declare.
(handle_tracepoint_bkpts): Declare.
(initialize_low_tracepoint)
(supply_fast_tracepoint_registers) [IN_PROCESS_AGENT]: Declare.
* target.h (struct target_ops) <stabilize_threads,
install_fast_tracepoint_jump_pad>: New fields.
(stabilize_threads, install_fast_tracepoint_jump_pad): New.
* tracepoint.c [HAVE_MALLOC_H]: Include malloc.h.
[HAVE_STDINT_H]: Include stdint.h.
(trace_debug_1): Rename to ...
(trace_vdebug): ... this.
(trace_debug): Rename to ...
(trace_debug_1): ... this. Add `level' parameter.
(trace_debug): New.
(ATTR_USED, ATTR_NOINLINE): New.
(IP_AGENT_EXPORT): New.
(gdb_tp_heap_buffer, gdb_jump_pad_buffer, gdb_jump_pad_buffer_end)
(collecting, gdb_collect, stop_tracing, flush_trace_buffer)
(about_to_request_buffer_space, trace_buffer_is_full)
(stopping_tracepoint, expr_eval_result, error_tracepoint)
(tracepoints, tracing, trace_buffer_ctrl, trace_buffer_ctrl_curr)
(trace_buffer_lo, trace_buffer_hi, traceframe_read_count)
(traceframe_write_count, traceframes_created)
(trace_state_variables)
New renaming defines.
(struct ipa_sym_addresses): New.
(STRINGIZE_1, STRINGIZE, IPA_SYM): New.
(symbol_list): New.
(ipa_sym_addrs): New.
(all_tracepoint_symbols_looked_up): New.
(in_process_agent_loaded): New.
(write_e_ipa_not_loaded): New.
(maybe_write_ipa_not_loaded): New.
(tracepoint_look_up_symbols): New.
(debug_threads) [IN_PROCESS_AGENT]: New.
(read_inferior_memory) [IN_PROCESS_AGENT]: New.
(UNKNOWN_SIDE_EFFECTS): New.
(stop_tracing): New.
(flush_trace_buffer): New.
(stop_tracing_bkpt): New.
(flush_trace_buffer_bkpt): New.
(read_inferior_integer): New.
(read_inferior_uinteger): New.
(read_inferior_data_pointer): New.
(write_inferior_data_pointer): New.
(write_inferior_integer): New.
(write_inferior_uinteger): New.
(struct collect_static_trace_data_action): Delete.
(enum tracepoint_type): New.
(struct tracepoint) <type>: New field `type'.
<actions_str, step_actions, step_actions_str>: Only include in GDBserver.
<orig_size, obj_addr_on_target, adjusted_insn_addr>
<adjusted_insn_addr_end, jump_pad, jump_pad_end>: New fields.
(tracepoints): Use IP_AGENT_EXPORT.
(last_tracepoint): Don't include in the IPA.
(stopping_tracepoint): Use IP_AGENT_EXPORT.
(trace_buffer_is_full): Use IP_AGENT_EXPORT.
(alloced_trace_state_variables): New.
(trace_state_variables): Use IP_AGENT_EXPORT.
(traceframe_t): Delete unused variable.
(circular_trace_buffer): Don't include in the IPA.
(trace_buffer_start): Delete.
(struct trace_buffer_control): New.
(trace_buffer_free): Delete.
(struct ipa_trace_buffer_control): New.
(GDBSERVER_FLUSH_COUNT_MASK, GDBSERVER_FLUSH_COUNT_MASK_PREV)
(GDBSERVER_FLUSH_COUNT_MASK_CURR, GDBSERVER_UPDATED_FLUSH_COUNT_BIT):
New.
(trace_buffer_ctrl): New.
(TRACE_BUFFER_CTRL_CURR): New.
(trace_buffer_start, trace_buffer_free, trace_buffer_end_free):
Reimplement as macros.
(trace_buffer_wrap): Delete.
(traceframe_write_count, traceframe_read_count)
(traceframes_created, tracing): Use IP_AGENT_EXPORT.
(struct tracepoint_hit_ctx) <type>: New field.
(struct fast_tracepoint_ctx): New.
(memory_barrier): New.
(cmpxchg): New.
(record_tracepoint_error): Update atomically in the IPA.
(clear_inferior_trace_buffer): New.
(about_to_request_buffer_space): New.
(trace_buffer_alloc): Handle GDBserver and inferior simulatenous
updating the same buffer.
(add_tracepoint): Default the tracepoint's type to trap
tracepoint, and orig_size to -1.
(get_trace_state_variable) [IN_PROCESS_AGENT]: Handle allocated
internal variables.
(create_trace_state_variable): New parameter `gdb'. Handle it.
(clear_installed_tracepoints): Clear fast tracepoint jumps.
(cmd_qtdp): Handle fast tracepoints.
(cmd_qtdv): Adjust.
(max_jump_pad_size): New.
(gdb_jump_pad_head): New.
(get_jump_space_head): New.
(claim_jump_space): New.
(sort_tracepoints): New.
(MAX_JUMP_SIZE): New.
(cmd_qtstart): Handle fast tracepoints. Sync tracepoints with the
IPA.
(stop_tracing) [IN_PROCESS_AGENT]: Don't include the tdisconnected
support. Upload fast traceframes, and delete internal IPA
breakpoints.
(stop_tracing_handler): New.
(flush_trace_buffer_handler): New.
(cmd_qtstop): Upload fast tracepoints.
(response_tracepoint): Handle fast tracepoints.
(tracepoint_finished_step): Upload fast traceframes. Set the
tracepoint hit context's tracepoint type.
(handle_tracepoint_bkpts): New.
(tracepoint_was_hit): Set the tracepoint hit context's tracepoint
type. Add comment about fast tracepoints.
(collect_data_at_tracepoint) [IN_PROCESS_AGENT]: Don't access the
non-existing action_str field.
(get_context_regcache): Handle fast tracepoints.
(do_action_at_tracepoint) [!IN_PROCESS_AGENT]: Don't write the PC
to the regcache.
(fast_tracepoint_from_jump_pad_address): New.
(fast_tracepoint_from_ipa_tpoint_address): New.
(collecting_t): New.
(force_unlock_trace_buffer): New.
(fast_tracepoint_collecting): New.
(collecting): New.
(gdb_collect): New.
(write_inferior_data_ptr): New.
(target_tp_heap): New.
(target_malloc): New.
(download_agent_expr): New.
(UALIGN): New.
(download_tracepoints): New.
(download_trace_state_variables): New.
(upload_fast_traceframes): New.
(IPA_FIRST_TRACEFRAME): New.
(IPA_NEXT_TRACEFRAME_1): New.
(IPA_NEXT_TRACEFRAME): New.
[IN_PROCESS_AGENT]: Include sys/mman.h and fcntl.h.
[IN_PROCESS_AGENT] (gdb_tp_heap_buffer, gdb_jump_pad_buffer)
(gdb_jump_pad_buffer_end): New.
[IN_PROCESS_AGENT] (initialize_tracepoint_ftlib): New.
(initialize_tracepoint): Adjust.
[IN_PROCESS_AGENT]: Allocate the IPA heap, and jump pad scratch
buffer. Initialize the low module.
* utils.c (PREFIX, TOOLNAME): New.
(malloc_failure): Use PREFIX.
(error): In the IPA, an error causes an exit.
(fatal, warning): Use PREFIX.
(internal_error): Use TOOLNAME.
(NUMCELLS): Increase to 10.
* configure, config.in: Regenerate.
gdb/
2010-06-01 Pedro Alves <pedro@codesourcery.com>
* NEWS: Mention gdbserver fast tracepoints support.
gdb/doc/
2010-06-01 Pedro Alves <pedro@codesourcery.com>
* gdb.texinfo (Set Tracepoints): Mention tracepoints support in
gdbserver, and add cross reference.
(Tracepoints support in gdbserver): New subsection.
2010-06-01 21:20:52 +08:00
|
|
|
/* GNU/Linux/x86-64 specific low level interface, for the in-process
|
|
|
|
agent library for GDB.
|
|
|
|
|
2024-01-12 23:30:44 +08:00
|
|
|
Copyright (C) 2010-2024 Free Software Foundation, Inc.
|
gdb/gdbserver/
2010-06-01 Pedro Alves <pedro@codesourcery.com>
Stan Shebs <stan@codesourcery.com>
* Makefile.in (IPA_DEPFILES, extra_libraries): New.
(all): Depend on $(extra_libraries).
(install-only): Install the IPA.
(IPA_OBJS, IPA_LIB): New.
(clean): Remove the IPA lib.
(IPAGENT_CFLAGS): New.
(tracepoint-ipa.o, utils-ipa.o, remote-utils-ipa.o)
(regcache-ipa.o, i386-linux-ipa.o, linux-i386-ipa.o)
(linux-amd64-ipa.o, amd64-linux-ipa.o): New rules.
* linux-amd64-ipa.c, linux-i386-ipa.c: New files.
* configure.ac: Check for atomic builtins support in the compiler.
(IPA_DEPFILES, extra_libraries): Define.
* configure.srv (ipa_obj): Add description.
(ipa_i386_linux_regobj, ipa_amd64_linux_regobj): Define.
(i[34567]86-*-linux*): Set ipa_obj.
(x86_64-*-linux*): Set ipa_obj.
* linux-low.c (stabilizing_threads): New.
(supports_fast_tracepoints): New.
(linux_detach): Stabilize threads before detaching.
(handle_tracepoints): Handle internal tracing breakpoints. Assert
the lwp is either not stabilizing, or is moving out of a jump pad.
(linux_fast_tracepoint_collecting): New.
(maybe_move_out_of_jump_pad): New.
(enqueue_one_deferred_signal): New.
(dequeue_one_deferred_signal): New.
(linux_wait_for_event_1): If moving out of a jump pad, defer
pending signals to later.
(linux_stabilize_threads): New.
(linux_wait_1): Check if threads need moving out of jump pads, and
do it if so.
(stuck_in_jump_pad_callback): New.
(move_out_of_jump_pad_callback): New.
(lwp_running): New.
(linux_resume_one_lwp): Handle moving out of jump pads.
(linux_set_resume_request): Dequeue deferred signals.
(need_step_over_p): Also step over fast tracepoint jumps.
(start_step_over): Also uninsert fast tracepoint jumps.
(finish_step_over): Also reinsert fast tracepoint jumps.
(linux_install_fast_tracepoint_jump): New.
(linux_target_ops): Install linux_stabilize_threads and
linux_install_fast_tracepoint_jump_pad.
* linux-low.h (linux_target_ops) <get_thread_area,
install_fast_tracepoint_jump_pad>: New fields.
(struct lwp_info) <collecting_fast_tracepoint,
pending_signals_to_report, exit_jump_pad_bkpt>: New fields.
(linux_get_thread_area): Declare.
* linux-x86-low.c (jump_insn): New.
(x86_get_thread_area): New.
(append_insns): New.
(push_opcode): New.
(amd64_install_fast_tracepoint_jump_pad): New.
(i386_install_fast_tracepoint_jump_pad): New.
(x86_install_fast_tracepoint_jump_pad): New.
(the_low_target): Install x86_get_thread_area and
x86_install_fast_tracepoint_jump_pad.
* mem-break.c (set_raw_breakpoint_at): Use read_inferior_memory.
(struct fast_tracepoint_jump): New.
(fast_tracepoint_jump_insn): New.
(fast_tracepoint_jump_shadow): New.
(find_fast_tracepoint_jump_at): New.
(fast_tracepoint_jump_here): New.
(delete_fast_tracepoint_jump): New.
(set_fast_tracepoint_jump): New.
(uninsert_fast_tracepoint_jumps_at): New.
(reinsert_fast_tracepoint_jumps_at): New.
(set_breakpoint_at): Use write_inferior_memory.
(uninsert_raw_breakpoint): Use write_inferior_memory.
(check_mem_read): Mask out fast tracepoint jumps.
(check_mem_write): Mask out fast tracepoint jumps.
* mem-break.h (struct fast_tracepoint_jump): Forward declare.
(set_fast_tracepoint_jump): Declare.
(delete_fast_tracepoint_jump)
(fast_tracepoint_jump_here, uninsert_fast_tracepoint_jumps_at)
(reinsert_fast_tracepoint_jumps_at): Declare.
* regcache.c: Don't compile many functions when building the
in-process agent library.
(init_register_cache) [IN_PROCESS_AGENT]: Don't allow allocating
the register buffer in the heap.
(free_register_cache): If the register buffer isn't owned by the
regcache, don't free it.
(set_register_cache) [IN_PROCESS_AGENT]: Don't re-alocate
pre-existing register caches.
* remote-utils.c (convert_int_to_ascii): Constify `from' parameter
type.
(convert_ascii_to_int): : Constify `from' parameter type.
(decode_M_packet, decode_X_packet): Replace the `to' parameter by
a `to_p' pointer to pointer parameter. If TO_P is NULL, malloc
the needed buffer in-place.
(relocate_instruction): New.
* server.c (handle_query) <qSymbols>: If the target supports
tracepoints, give it a chance of looking up symbols. Report
support for fast tracepoints.
(handle_status): Stabilize threads.
(process_serial_event): Adjust.
* server.h (struct fast_tracepoint_jump): Forward declare.
(struct process_info) <fast_tracepoint_jumps>: New field.
(convert_ascii_to_int, convert_int_to_ascii): Adjust.
(decode_X_packet, decode_M_packet): Adjust.
(relocate_instruction): Declare.
(in_process_agent_loaded): Declare.
(tracepoint_look_up_symbols): Declare.
(struct fast_tpoint_collect_status): Declare.
(fast_tracepoint_collecting): Declare.
(force_unlock_trace_buffer): Declare.
(handle_tracepoint_bkpts): Declare.
(initialize_low_tracepoint)
(supply_fast_tracepoint_registers) [IN_PROCESS_AGENT]: Declare.
* target.h (struct target_ops) <stabilize_threads,
install_fast_tracepoint_jump_pad>: New fields.
(stabilize_threads, install_fast_tracepoint_jump_pad): New.
* tracepoint.c [HAVE_MALLOC_H]: Include malloc.h.
[HAVE_STDINT_H]: Include stdint.h.
(trace_debug_1): Rename to ...
(trace_vdebug): ... this.
(trace_debug): Rename to ...
(trace_debug_1): ... this. Add `level' parameter.
(trace_debug): New.
(ATTR_USED, ATTR_NOINLINE): New.
(IP_AGENT_EXPORT): New.
(gdb_tp_heap_buffer, gdb_jump_pad_buffer, gdb_jump_pad_buffer_end)
(collecting, gdb_collect, stop_tracing, flush_trace_buffer)
(about_to_request_buffer_space, trace_buffer_is_full)
(stopping_tracepoint, expr_eval_result, error_tracepoint)
(tracepoints, tracing, trace_buffer_ctrl, trace_buffer_ctrl_curr)
(trace_buffer_lo, trace_buffer_hi, traceframe_read_count)
(traceframe_write_count, traceframes_created)
(trace_state_variables)
New renaming defines.
(struct ipa_sym_addresses): New.
(STRINGIZE_1, STRINGIZE, IPA_SYM): New.
(symbol_list): New.
(ipa_sym_addrs): New.
(all_tracepoint_symbols_looked_up): New.
(in_process_agent_loaded): New.
(write_e_ipa_not_loaded): New.
(maybe_write_ipa_not_loaded): New.
(tracepoint_look_up_symbols): New.
(debug_threads) [IN_PROCESS_AGENT]: New.
(read_inferior_memory) [IN_PROCESS_AGENT]: New.
(UNKNOWN_SIDE_EFFECTS): New.
(stop_tracing): New.
(flush_trace_buffer): New.
(stop_tracing_bkpt): New.
(flush_trace_buffer_bkpt): New.
(read_inferior_integer): New.
(read_inferior_uinteger): New.
(read_inferior_data_pointer): New.
(write_inferior_data_pointer): New.
(write_inferior_integer): New.
(write_inferior_uinteger): New.
(struct collect_static_trace_data_action): Delete.
(enum tracepoint_type): New.
(struct tracepoint) <type>: New field `type'.
<actions_str, step_actions, step_actions_str>: Only include in GDBserver.
<orig_size, obj_addr_on_target, adjusted_insn_addr>
<adjusted_insn_addr_end, jump_pad, jump_pad_end>: New fields.
(tracepoints): Use IP_AGENT_EXPORT.
(last_tracepoint): Don't include in the IPA.
(stopping_tracepoint): Use IP_AGENT_EXPORT.
(trace_buffer_is_full): Use IP_AGENT_EXPORT.
(alloced_trace_state_variables): New.
(trace_state_variables): Use IP_AGENT_EXPORT.
(traceframe_t): Delete unused variable.
(circular_trace_buffer): Don't include in the IPA.
(trace_buffer_start): Delete.
(struct trace_buffer_control): New.
(trace_buffer_free): Delete.
(struct ipa_trace_buffer_control): New.
(GDBSERVER_FLUSH_COUNT_MASK, GDBSERVER_FLUSH_COUNT_MASK_PREV)
(GDBSERVER_FLUSH_COUNT_MASK_CURR, GDBSERVER_UPDATED_FLUSH_COUNT_BIT):
New.
(trace_buffer_ctrl): New.
(TRACE_BUFFER_CTRL_CURR): New.
(trace_buffer_start, trace_buffer_free, trace_buffer_end_free):
Reimplement as macros.
(trace_buffer_wrap): Delete.
(traceframe_write_count, traceframe_read_count)
(traceframes_created, tracing): Use IP_AGENT_EXPORT.
(struct tracepoint_hit_ctx) <type>: New field.
(struct fast_tracepoint_ctx): New.
(memory_barrier): New.
(cmpxchg): New.
(record_tracepoint_error): Update atomically in the IPA.
(clear_inferior_trace_buffer): New.
(about_to_request_buffer_space): New.
(trace_buffer_alloc): Handle GDBserver and inferior simulatenous
updating the same buffer.
(add_tracepoint): Default the tracepoint's type to trap
tracepoint, and orig_size to -1.
(get_trace_state_variable) [IN_PROCESS_AGENT]: Handle allocated
internal variables.
(create_trace_state_variable): New parameter `gdb'. Handle it.
(clear_installed_tracepoints): Clear fast tracepoint jumps.
(cmd_qtdp): Handle fast tracepoints.
(cmd_qtdv): Adjust.
(max_jump_pad_size): New.
(gdb_jump_pad_head): New.
(get_jump_space_head): New.
(claim_jump_space): New.
(sort_tracepoints): New.
(MAX_JUMP_SIZE): New.
(cmd_qtstart): Handle fast tracepoints. Sync tracepoints with the
IPA.
(stop_tracing) [IN_PROCESS_AGENT]: Don't include the tdisconnected
support. Upload fast traceframes, and delete internal IPA
breakpoints.
(stop_tracing_handler): New.
(flush_trace_buffer_handler): New.
(cmd_qtstop): Upload fast tracepoints.
(response_tracepoint): Handle fast tracepoints.
(tracepoint_finished_step): Upload fast traceframes. Set the
tracepoint hit context's tracepoint type.
(handle_tracepoint_bkpts): New.
(tracepoint_was_hit): Set the tracepoint hit context's tracepoint
type. Add comment about fast tracepoints.
(collect_data_at_tracepoint) [IN_PROCESS_AGENT]: Don't access the
non-existing action_str field.
(get_context_regcache): Handle fast tracepoints.
(do_action_at_tracepoint) [!IN_PROCESS_AGENT]: Don't write the PC
to the regcache.
(fast_tracepoint_from_jump_pad_address): New.
(fast_tracepoint_from_ipa_tpoint_address): New.
(collecting_t): New.
(force_unlock_trace_buffer): New.
(fast_tracepoint_collecting): New.
(collecting): New.
(gdb_collect): New.
(write_inferior_data_ptr): New.
(target_tp_heap): New.
(target_malloc): New.
(download_agent_expr): New.
(UALIGN): New.
(download_tracepoints): New.
(download_trace_state_variables): New.
(upload_fast_traceframes): New.
(IPA_FIRST_TRACEFRAME): New.
(IPA_NEXT_TRACEFRAME_1): New.
(IPA_NEXT_TRACEFRAME): New.
[IN_PROCESS_AGENT]: Include sys/mman.h and fcntl.h.
[IN_PROCESS_AGENT] (gdb_tp_heap_buffer, gdb_jump_pad_buffer)
(gdb_jump_pad_buffer_end): New.
[IN_PROCESS_AGENT] (initialize_tracepoint_ftlib): New.
(initialize_tracepoint): Adjust.
[IN_PROCESS_AGENT]: Allocate the IPA heap, and jump pad scratch
buffer. Initialize the low module.
* utils.c (PREFIX, TOOLNAME): New.
(malloc_failure): Use PREFIX.
(error): In the IPA, an error causes an exit.
(fatal, warning): Use PREFIX.
(internal_error): Use TOOLNAME.
(NUMCELLS): Increase to 10.
* configure, config.in: Regenerate.
gdb/
2010-06-01 Pedro Alves <pedro@codesourcery.com>
* NEWS: Mention gdbserver fast tracepoints support.
gdb/doc/
2010-06-01 Pedro Alves <pedro@codesourcery.com>
* gdb.texinfo (Set Tracepoints): Mention tracepoints support in
gdbserver, and add cross reference.
(Tracepoints support in gdbserver): New subsection.
2010-06-01 21:20:52 +08:00
|
|
|
|
|
|
|
This file is part of GDB.
|
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
the Free Software Foundation; either version 3 of the License, or
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
|
|
|
|
2016-03-13 07:30:11 +08:00
|
|
|
#include <sys/mman.h>
|
2013-09-06 18:58:11 +08:00
|
|
|
#include "tracepoint.h"
|
Rename common to gdbsupport
This is the next patch in the ongoing series to move gdbsever to the
top level.
This patch just renames the "common" directory. The idea is to do
this move in two parts: first rename the directory (this patch), then
move the directory to the top. This approach makes the patches a bit
more tractable.
I chose the name "gdbsupport" for the directory. However, as this
patch was largely written by sed, we could pick a new name without too
much difficulty.
Tested by the buildbot.
gdb/ChangeLog
2019-07-09 Tom Tromey <tom@tromey.com>
* contrib/ari/gdb_ari.sh: Change common to gdbsupport.
* configure: Rebuild.
* configure.ac: Change common to gdbsupport.
* gdbsupport: Rename from common.
* acinclude.m4: Change common to gdbsupport.
* Makefile.in (CONFIG_SRC_SUBDIR, COMMON_SFILES)
(HFILES_NO_SRCDIR, stamp-version, ALLDEPFILES): Change common to
gdbsupport.
* aarch64-tdep.c, ada-lang.c, ada-lang.h, agent.c, alloc.c,
amd64-darwin-tdep.c, amd64-dicos-tdep.c, amd64-fbsd-nat.c,
amd64-fbsd-tdep.c, amd64-linux-nat.c, amd64-linux-tdep.c,
amd64-nbsd-tdep.c, amd64-obsd-tdep.c, amd64-sol2-tdep.c,
amd64-tdep.c, amd64-windows-tdep.c, arch-utils.c,
arch/aarch64-insn.c, arch/aarch64.c, arch/aarch64.h, arch/amd64.c,
arch/amd64.h, arch/arm-get-next-pcs.c, arch/arm-linux.c,
arch/arm.c, arch/i386.c, arch/i386.h, arch/ppc-linux-common.c,
arch/riscv.c, arch/riscv.h, arch/tic6x.c, arm-tdep.c, auto-load.c,
auxv.c, ax-gdb.c, ax-general.c, ax.h, breakpoint.c, breakpoint.h,
btrace.c, btrace.h, build-id.c, build-id.h, c-lang.h, charset.c,
charset.h, cli/cli-cmds.c, cli/cli-cmds.h, cli/cli-decode.c,
cli/cli-dump.c, cli/cli-option.h, cli/cli-script.c,
coff-pe-read.c, command.h, compile/compile-c-support.c,
compile/compile-c.h, compile/compile-cplus-symbols.c,
compile/compile-cplus-types.c, compile/compile-cplus.h,
compile/compile-loc2c.c, compile/compile.c, completer.c,
completer.h, contrib/ari/gdb_ari.sh, corefile.c, corelow.c,
cp-support.c, cp-support.h, cp-valprint.c, csky-tdep.c, ctf.c,
darwin-nat.c, debug.c, defs.h, disasm-selftests.c, disasm.c,
disasm.h, dtrace-probe.c, dwarf-index-cache.c,
dwarf-index-cache.h, dwarf-index-write.c, dwarf2-frame.c,
dwarf2expr.c, dwarf2loc.c, dwarf2read.c, event-loop.c,
event-top.c, exceptions.c, exec.c, extension.h, fbsd-nat.c,
features/aarch64-core.c, features/aarch64-fpu.c,
features/aarch64-pauth.c, features/aarch64-sve.c,
features/i386/32bit-avx.c, features/i386/32bit-avx512.c,
features/i386/32bit-core.c, features/i386/32bit-linux.c,
features/i386/32bit-mpx.c, features/i386/32bit-pkeys.c,
features/i386/32bit-segments.c, features/i386/32bit-sse.c,
features/i386/64bit-avx.c, features/i386/64bit-avx512.c,
features/i386/64bit-core.c, features/i386/64bit-linux.c,
features/i386/64bit-mpx.c, features/i386/64bit-pkeys.c,
features/i386/64bit-segments.c, features/i386/64bit-sse.c,
features/i386/x32-core.c, features/riscv/32bit-cpu.c,
features/riscv/32bit-csr.c, features/riscv/32bit-fpu.c,
features/riscv/64bit-cpu.c, features/riscv/64bit-csr.c,
features/riscv/64bit-fpu.c, features/tic6x-c6xp.c,
features/tic6x-core.c, features/tic6x-gp.c, filename-seen-cache.h,
findcmd.c, findvar.c, fork-child.c, gcore.c, gdb_bfd.c, gdb_bfd.h,
gdb_proc_service.h, gdb_regex.c, gdb_select.h, gdb_usleep.c,
gdbarch-selftests.c, gdbthread.h, gdbtypes.h, gnu-nat.c,
go32-nat.c, guile/guile.c, guile/scm-ports.c,
guile/scm-safe-call.c, guile/scm-type.c, i386-fbsd-nat.c,
i386-fbsd-tdep.c, i386-go32-tdep.c, i386-linux-nat.c,
i386-linux-tdep.c, i386-tdep.c, i387-tdep.c,
ia64-libunwind-tdep.c, ia64-linux-nat.c, inf-child.c,
inf-ptrace.c, infcall.c, infcall.h, infcmd.c, inferior-iter.h,
inferior.c, inferior.h, inflow.c, inflow.h, infrun.c, infrun.h,
inline-frame.c, language.h, linespec.c, linux-fork.c, linux-nat.c,
linux-tdep.c, linux-thread-db.c, location.c, machoread.c,
macrotab.h, main.c, maint.c, maint.h, memattr.c, memrange.h,
mi/mi-cmd-break.h, mi/mi-cmd-env.c, mi/mi-cmd-stack.c,
mi/mi-cmd-var.c, mi/mi-interp.c, mi/mi-main.c, mi/mi-parse.h,
minsyms.c, mips-linux-tdep.c, namespace.h,
nat/aarch64-linux-hw-point.c, nat/aarch64-linux-hw-point.h,
nat/aarch64-linux.c, nat/aarch64-sve-linux-ptrace.c,
nat/amd64-linux-siginfo.c, nat/fork-inferior.c,
nat/linux-btrace.c, nat/linux-btrace.h, nat/linux-namespaces.c,
nat/linux-nat.h, nat/linux-osdata.c, nat/linux-personality.c,
nat/linux-procfs.c, nat/linux-ptrace.c, nat/linux-ptrace.h,
nat/linux-waitpid.c, nat/mips-linux-watch.c,
nat/mips-linux-watch.h, nat/ppc-linux.c, nat/x86-dregs.c,
nat/x86-dregs.h, nat/x86-linux-dregs.c, nat/x86-linux.c,
nto-procfs.c, nto-tdep.c, objfile-flags.h, objfiles.c, objfiles.h,
obsd-nat.c, observable.h, osdata.c, p-valprint.c, parse.c,
parser-defs.h, ppc-linux-nat.c, printcmd.c, probe.c, proc-api.c,
procfs.c, producer.c, progspace.h, psymtab.h,
python/py-framefilter.c, python/py-inferior.c, python/py-ref.h,
python/py-type.c, python/python.c, record-btrace.c, record-full.c,
record.c, record.h, regcache-dump.c, regcache.c, regcache.h,
remote-fileio.c, remote-fileio.h, remote-sim.c, remote.c,
riscv-tdep.c, rs6000-aix-tdep.c, rust-exp.y, s12z-tdep.c,
selftest-arch.c, ser-base.c, ser-event.c, ser-pipe.c, ser-tcp.c,
ser-unix.c, skip.c, solib-aix.c, solib-target.c, solib.c,
source-cache.c, source.c, source.h, sparc-nat.c, spu-linux-nat.c,
stack.c, stap-probe.c, symfile-add-flags.h, symfile.c, symfile.h,
symtab.c, symtab.h, target-descriptions.c, target-descriptions.h,
target-memory.c, target.c, target.h, target/waitstatus.c,
target/waitstatus.h, thread-iter.h, thread.c, tilegx-tdep.c,
top.c, top.h, tracefile-tfile.c, tracefile.c, tracepoint.c,
tracepoint.h, tui/tui-io.c, ui-file.c, ui-out.h,
unittests/array-view-selftests.c,
unittests/child-path-selftests.c, unittests/cli-utils-selftests.c,
unittests/common-utils-selftests.c,
unittests/copy_bitwise-selftests.c, unittests/environ-selftests.c,
unittests/format_pieces-selftests.c,
unittests/function-view-selftests.c,
unittests/lookup_name_info-selftests.c,
unittests/memory-map-selftests.c, unittests/memrange-selftests.c,
unittests/mkdir-recursive-selftests.c,
unittests/observable-selftests.c,
unittests/offset-type-selftests.c, unittests/optional-selftests.c,
unittests/parse-connection-spec-selftests.c,
unittests/ptid-selftests.c, unittests/rsp-low-selftests.c,
unittests/scoped_fd-selftests.c,
unittests/scoped_mmap-selftests.c,
unittests/scoped_restore-selftests.c,
unittests/string_view-selftests.c, unittests/style-selftests.c,
unittests/tracepoint-selftests.c, unittests/unpack-selftests.c,
unittests/utils-selftests.c, unittests/xml-utils-selftests.c,
utils.c, utils.h, valarith.c, valops.c, valprint.c, value.c,
value.h, varobj.c, varobj.h, windows-nat.c, x86-linux-nat.c,
xml-support.c, xml-support.h, xml-tdesc.h, xstormy16-tdep.c,
xtensa-linux-nat.c, dwarf2read.h: Change common to gdbsupport.
gdb/gdbserver/ChangeLog
2019-07-09 Tom Tromey <tom@tromey.com>
* configure: Rebuild.
* configure.ac: Change common to gdbsupport.
* acinclude.m4: Change common to gdbsupport.
* Makefile.in (SFILES, OBS, GDBREPLAY_OBS, IPA_OBJS)
(version-generated.c, gdbsupport/%-ipa.o, gdbsupport/%.o): Change
common to gdbsupport.
* ax.c, event-loop.c, fork-child.c, gdb_proc_service.h,
gdbreplay.c, gdbthread.h, hostio-errno.c, hostio.c, i387-fp.c,
inferiors.c, inferiors.h, linux-aarch64-tdesc-selftest.c,
linux-amd64-ipa.c, linux-i386-ipa.c, linux-low.c,
linux-tic6x-low.c, linux-x86-low.c, linux-x86-tdesc-selftest.c,
linux-x86-tdesc.c, lynx-i386-low.c, lynx-low.c, mem-break.h,
nto-x86-low.c, regcache.c, regcache.h, remote-utils.c, server.c,
server.h, spu-low.c, symbol.c, target.h, tdesc.c, tdesc.h,
thread-db.c, tracepoint.c, win32-i386-low.c, win32-low.c: Change
common to gdbsupport.
2019-05-06 10:29:24 +08:00
|
|
|
#include "gdbsupport/x86-xstate.h"
|
gdb/gdbserver: share some code relating to target description creation
This commit is part of a series to share more of the x86 target
description creation code between GDB and gdbserver.
Unlike previous commits which were mostly refactoring, this commit is
the first that makes a real change, though that change should mostly
be for gdbserver; I've largely adopted the "GDB" way of doing things
for gdbserver, and this fixes a real gdbserver bug.
On a x86-64 Linux target, running the test:
gdb.server/connect-with-no-symbol-file.exp
results in two core files being created. Both of these core files are
from the inferior process, created after gdbserver has detached.
In this test a gdbserver process is started and then, after gdbserver
has started, but before GDB attaches, we either delete the inferior
executable, or change its permissions so it can't be read. Only after
doing this do we attempt to connect with GDB.
As GDB connects to gdbserver, gdbserver attempts to figure out the
target description so that it can send the description to GDB, this
involves a call to x86_linux_read_description.
In x86_linux_read_description one of the first things we do is try to
figure out if the process is 32-bit or 64-bit. To do this we look up
the executable via the thread-id, and then attempt to read the
architecture size from the executable. This isn't going to work if
the executable has been deleted, or is no longer readable.
And so, as we can't read the executable, we default to an i386 target
and use an i386 target description.
A consequence of using an i386 target description is that addresses
are assumed to be 32-bits. Here's an example session that shows the
problems this causes. This is run on an x86-64 machine, and the test
binary (xx.x) is a standard 64-bit x86-64 binary:
shell_1$ gdbserver --once localhost :54321 /tmp/xx.x
shell_2$ gdb -q
(gdb) set sysroot
(gdb) shell chmod 000 /tmp/xx.x
(gdb) target remote :54321
Remote debugging using :54321
warning: /tmp/xx.x: Permission denied.
0xf7fd3110 in ?? ()
(gdb) show architecture
The target architecture is set to "auto" (currently "i386").
(gdb) p/x $pc
$1 = 0xf7fd3110
(gdb) info proc mappings
process 2412639
Mapped address spaces:
Start Addr End Addr Size Offset Perms objfile
0x400000 0x401000 0x1000 0x0 r--p /tmp/xx.x
0x401000 0x402000 0x1000 0x1000 r-xp /tmp/xx.x
0x402000 0x403000 0x1000 0x2000 r--p /tmp/xx.x
0x403000 0x405000 0x2000 0x2000 rw-p /tmp/xx.x
0xf7fcb000 0xf7fcf000 0x4000 0x0 r--p [vvar]
0xf7fcf000 0xf7fd1000 0x2000 0x0 r-xp [vdso]
0xf7fd1000 0xf7fd3000 0x2000 0x0 r--p /usr/lib64/ld-2.30.so
0xf7fd3000 0xf7ff3000 0x20000 0x2000 r-xp /usr/lib64/ld-2.30.so
0xf7ff3000 0xf7ffb000 0x8000 0x22000 r--p /usr/lib64/ld-2.30.so
0xf7ffc000 0xf7ffe000 0x2000 0x2a000 rw-p /usr/lib64/ld-2.30.so
0xf7ffe000 0xf7fff000 0x1000 0x0 rw-p
0xfffda000 0xfffff000 0x25000 0x0 rw-p [stack]
0xff600000 0xff601000 0x1000 0x0 r-xp [vsyscall]
(gdb) info inferiors
Num Description Connection Executable
* 1 process 2412639 1 (remote :54321)
(gdb) shell cat /proc/2412639/maps
00400000-00401000 r--p 00000000 fd:03 45907133 /tmp/xx.x
00401000-00402000 r-xp 00001000 fd:03 45907133 /tmp/xx.x
00402000-00403000 r--p 00002000 fd:03 45907133 /tmp/xx.x
00403000-00405000 rw-p 00002000 fd:03 45907133 /tmp/xx.x
7ffff7fcb000-7ffff7fcf000 r--p 00000000 00:00 0 [vvar]
7ffff7fcf000-7ffff7fd1000 r-xp 00000000 00:00 0 [vdso]
7ffff7fd1000-7ffff7fd3000 r--p 00000000 fd:00 143904 /usr/lib64/ld-2.30.so
7ffff7fd3000-7ffff7ff3000 r-xp 00002000 fd:00 143904 /usr/lib64/ld-2.30.so
7ffff7ff3000-7ffff7ffb000 r--p 00022000 fd:00 143904 /usr/lib64/ld-2.30.so
7ffff7ffc000-7ffff7ffe000 rw-p 0002a000 fd:00 143904 /usr/lib64/ld-2.30.so
7ffff7ffe000-7ffff7fff000 rw-p 00000000 00:00 0
7ffffffda000-7ffffffff000 rw-p 00000000 00:00 0 [stack]
ffffffffff600000-ffffffffff601000 r-xp 00000000 00:00 0 [vsyscall]
(gdb)
Notice the difference between the mappings reported via GDB and those
reported directly from the kernel via /proc/PID/maps, the addresses of
every mapping is clamped to 32-bits for GDB, while the kernel reports
real 64-bit addresses.
Notice also that the $pc value is a 32-bit value. It appears to be
within one of the mappings reported by GDB, but is outside any of the
mappings reported from the kernel.
And this is where the problem arises. When gdbserver detaches from
the inferior we pass the inferior the address from which it should
resume. Due to the 32/64 bit confusion we tell the inferior to resume
from the 32-bit $pc value, which is not within any valid mapping, and
so, as soon as the inferior resumes, it segfaults.
If we look at how GDB (not gdbserver) figures out its target
description then we see an interesting difference. GDB doesn't try to
read the executable. Instead GDB uses ptrace to query the thread's
state, and uses this to figure out the if the thread is 32 or 64 bit.
If we update gdbserver to do it the "GDB" way then the above problem
is resolved, gdbserver now sees the process as 64-bit, and when we
detach from the inferior we give it the correct 64-bit address, and
the inferior no longer segfaults.
Now, I could just update the gdbserver code, but better, I think, to
share one copy of the code between GDB and gdbserver in gdb/nat/.
That is what this commit does.
The cores of x86_linux_read_description from gdbserver and
x86_linux_nat_target::read_description from GDB are moved into a new
file gdb/nat/x86-linux-tdesc.c and combined into a single function
x86_linux_tdesc_for_tid which is called from each location.
This new function does things mostly the GDB way, some changes are
needed to allow for the sharing; we now take some pointers for where
the shared code can cache the xcr0 and xsave layout values.
Another thing to note about this commit is how the functions
i386_linux_read_description and amd64_linux_read_description are
handled. For now I've left these function as implemented separately
in GDB and gdbserver. I've moved the declarations of these functions
into gdb/arch/{i386,amd64}-linux-tdesc.h, but the implementations are
left where they are.
A later commit in this series will make these functions shared too,
but doing this is not trivial, so I've left that for a separate
commit. Merging the declarations as I've done here ensures that
everyone implements the function to the same API, and once these
functions are shared (in a later commit) we'll want a shared
declaration anyway.
Reviewed-By: Felix Willgerodt <felix.willgerodt@intel.com>
Acked-By: John Baldwin <jhb@FreeBSD.org>
2024-01-25 22:25:57 +08:00
|
|
|
#include "arch/amd64-linux-tdesc.h"
|
gdb/gdbserver: share x86/linux tdesc caching
This commit builds on the previous series of commits to share the
target description caching code between GDB and gdbserver for
x86/Linux targets.
The objective of this commit is to move the four functions (2 each of)
i386_linux_read_description and amd64_linux_read_description into the
gdb/arch/ directory and combine them so we have just a single copy of
each. Then GDB, gdbserver, and the in-process-agent (IPA) will link
against these shared functions.
One curiosity with this patch is the function
x86_linux_post_init_tdesc. On the gdbserver side the two functions
amd64_linux_read_description and i386_linux_read_description have some
functionality that is not present on the GDB side, there is some
additional configuration that is performed as each target description
is created, to setup the expedited registers.
To support this I've added the function x86_linux_post_init_tdesc.
This function is called from the two *_linux_read_description
functions, but is implemented separately for GDB and gdbserver.
An alternative approach that avoids adding x86_linux_post_init_tdesc
would be to have x86_linux_tdesc_for_tid return a non-const target
description, then in x86_target::low_arch_setup we could inspect the
target description to figure out if it is 64-bit or not, and modify
the target description as needed. In the end I think that adding the
x86_linux_post_init_tdesc function is the simpler solution.
The contents of gdbserver/linux-x86-low.cc have moved to
gdb/arch/x86-linux-tdesc-features.c, and gdbserver/linux-x86-tdesc.h
has moved to gdb/arch/x86-linux-tdesc-features.h, this change leads to
some updates in the #includes in the gdbserver/ directory.
This commit also changes how target descriptions are cached.
Previously both GDB and gdbserver used static C-style arrays to act as
the tdesc cache. This was fine, except for two problems. Either the
C-style arrays would need to be placed in x86-linux-tdesc-features.c,
which would allow us to use the x86_linux_*_tdesc_count_1() functions
to size the arrays for us, or we'd need to hard code the array sizes
using separate #defines, which we'd then have to keep in sync with the
rest of the code in x86-linux-tdesc-features.c.
Given both of these problems I decided a better solution would be to
just switch to using a std::unordered_map to act as the cache. This
will resize automatically, and we can use the xcr0 value as the key.
At first inspection, using xcr0 might seem to be a problem; after all
the {i386,amd64}_create_target_description functions take more than
just the xcr0 value. However, this patch is only for x86/Linux
targets, and for x86/Linux all of the other flags passed to the tdesc
creation functions have constant values and so are irrelevant when we
consider tdesc caching.
For testing I've done the following:
- Built on x86-64 GNU/Linux for all targets, and just for the native
target,
- Build on i386 GNU/Linux for all targets, and just for the native
target,
- Build on a 64-bit, non-x86 GNU/Linux for all targets, just for the
native target, and for targets x86_64-*-linux and i386-*-linux.
Approved-By: Felix Willgerodt <felix.willgerodt@intel.com>
2024-01-30 23:37:23 +08:00
|
|
|
#include "arch/x86-linux-tdesc-features.h"
|
gdb/gdbserver/
2010-06-01 Pedro Alves <pedro@codesourcery.com>
Stan Shebs <stan@codesourcery.com>
* Makefile.in (IPA_DEPFILES, extra_libraries): New.
(all): Depend on $(extra_libraries).
(install-only): Install the IPA.
(IPA_OBJS, IPA_LIB): New.
(clean): Remove the IPA lib.
(IPAGENT_CFLAGS): New.
(tracepoint-ipa.o, utils-ipa.o, remote-utils-ipa.o)
(regcache-ipa.o, i386-linux-ipa.o, linux-i386-ipa.o)
(linux-amd64-ipa.o, amd64-linux-ipa.o): New rules.
* linux-amd64-ipa.c, linux-i386-ipa.c: New files.
* configure.ac: Check for atomic builtins support in the compiler.
(IPA_DEPFILES, extra_libraries): Define.
* configure.srv (ipa_obj): Add description.
(ipa_i386_linux_regobj, ipa_amd64_linux_regobj): Define.
(i[34567]86-*-linux*): Set ipa_obj.
(x86_64-*-linux*): Set ipa_obj.
* linux-low.c (stabilizing_threads): New.
(supports_fast_tracepoints): New.
(linux_detach): Stabilize threads before detaching.
(handle_tracepoints): Handle internal tracing breakpoints. Assert
the lwp is either not stabilizing, or is moving out of a jump pad.
(linux_fast_tracepoint_collecting): New.
(maybe_move_out_of_jump_pad): New.
(enqueue_one_deferred_signal): New.
(dequeue_one_deferred_signal): New.
(linux_wait_for_event_1): If moving out of a jump pad, defer
pending signals to later.
(linux_stabilize_threads): New.
(linux_wait_1): Check if threads need moving out of jump pads, and
do it if so.
(stuck_in_jump_pad_callback): New.
(move_out_of_jump_pad_callback): New.
(lwp_running): New.
(linux_resume_one_lwp): Handle moving out of jump pads.
(linux_set_resume_request): Dequeue deferred signals.
(need_step_over_p): Also step over fast tracepoint jumps.
(start_step_over): Also uninsert fast tracepoint jumps.
(finish_step_over): Also reinsert fast tracepoint jumps.
(linux_install_fast_tracepoint_jump): New.
(linux_target_ops): Install linux_stabilize_threads and
linux_install_fast_tracepoint_jump_pad.
* linux-low.h (linux_target_ops) <get_thread_area,
install_fast_tracepoint_jump_pad>: New fields.
(struct lwp_info) <collecting_fast_tracepoint,
pending_signals_to_report, exit_jump_pad_bkpt>: New fields.
(linux_get_thread_area): Declare.
* linux-x86-low.c (jump_insn): New.
(x86_get_thread_area): New.
(append_insns): New.
(push_opcode): New.
(amd64_install_fast_tracepoint_jump_pad): New.
(i386_install_fast_tracepoint_jump_pad): New.
(x86_install_fast_tracepoint_jump_pad): New.
(the_low_target): Install x86_get_thread_area and
x86_install_fast_tracepoint_jump_pad.
* mem-break.c (set_raw_breakpoint_at): Use read_inferior_memory.
(struct fast_tracepoint_jump): New.
(fast_tracepoint_jump_insn): New.
(fast_tracepoint_jump_shadow): New.
(find_fast_tracepoint_jump_at): New.
(fast_tracepoint_jump_here): New.
(delete_fast_tracepoint_jump): New.
(set_fast_tracepoint_jump): New.
(uninsert_fast_tracepoint_jumps_at): New.
(reinsert_fast_tracepoint_jumps_at): New.
(set_breakpoint_at): Use write_inferior_memory.
(uninsert_raw_breakpoint): Use write_inferior_memory.
(check_mem_read): Mask out fast tracepoint jumps.
(check_mem_write): Mask out fast tracepoint jumps.
* mem-break.h (struct fast_tracepoint_jump): Forward declare.
(set_fast_tracepoint_jump): Declare.
(delete_fast_tracepoint_jump)
(fast_tracepoint_jump_here, uninsert_fast_tracepoint_jumps_at)
(reinsert_fast_tracepoint_jumps_at): Declare.
* regcache.c: Don't compile many functions when building the
in-process agent library.
(init_register_cache) [IN_PROCESS_AGENT]: Don't allow allocating
the register buffer in the heap.
(free_register_cache): If the register buffer isn't owned by the
regcache, don't free it.
(set_register_cache) [IN_PROCESS_AGENT]: Don't re-alocate
pre-existing register caches.
* remote-utils.c (convert_int_to_ascii): Constify `from' parameter
type.
(convert_ascii_to_int): : Constify `from' parameter type.
(decode_M_packet, decode_X_packet): Replace the `to' parameter by
a `to_p' pointer to pointer parameter. If TO_P is NULL, malloc
the needed buffer in-place.
(relocate_instruction): New.
* server.c (handle_query) <qSymbols>: If the target supports
tracepoints, give it a chance of looking up symbols. Report
support for fast tracepoints.
(handle_status): Stabilize threads.
(process_serial_event): Adjust.
* server.h (struct fast_tracepoint_jump): Forward declare.
(struct process_info) <fast_tracepoint_jumps>: New field.
(convert_ascii_to_int, convert_int_to_ascii): Adjust.
(decode_X_packet, decode_M_packet): Adjust.
(relocate_instruction): Declare.
(in_process_agent_loaded): Declare.
(tracepoint_look_up_symbols): Declare.
(struct fast_tpoint_collect_status): Declare.
(fast_tracepoint_collecting): Declare.
(force_unlock_trace_buffer): Declare.
(handle_tracepoint_bkpts): Declare.
(initialize_low_tracepoint)
(supply_fast_tracepoint_registers) [IN_PROCESS_AGENT]: Declare.
* target.h (struct target_ops) <stabilize_threads,
install_fast_tracepoint_jump_pad>: New fields.
(stabilize_threads, install_fast_tracepoint_jump_pad): New.
* tracepoint.c [HAVE_MALLOC_H]: Include malloc.h.
[HAVE_STDINT_H]: Include stdint.h.
(trace_debug_1): Rename to ...
(trace_vdebug): ... this.
(trace_debug): Rename to ...
(trace_debug_1): ... this. Add `level' parameter.
(trace_debug): New.
(ATTR_USED, ATTR_NOINLINE): New.
(IP_AGENT_EXPORT): New.
(gdb_tp_heap_buffer, gdb_jump_pad_buffer, gdb_jump_pad_buffer_end)
(collecting, gdb_collect, stop_tracing, flush_trace_buffer)
(about_to_request_buffer_space, trace_buffer_is_full)
(stopping_tracepoint, expr_eval_result, error_tracepoint)
(tracepoints, tracing, trace_buffer_ctrl, trace_buffer_ctrl_curr)
(trace_buffer_lo, trace_buffer_hi, traceframe_read_count)
(traceframe_write_count, traceframes_created)
(trace_state_variables)
New renaming defines.
(struct ipa_sym_addresses): New.
(STRINGIZE_1, STRINGIZE, IPA_SYM): New.
(symbol_list): New.
(ipa_sym_addrs): New.
(all_tracepoint_symbols_looked_up): New.
(in_process_agent_loaded): New.
(write_e_ipa_not_loaded): New.
(maybe_write_ipa_not_loaded): New.
(tracepoint_look_up_symbols): New.
(debug_threads) [IN_PROCESS_AGENT]: New.
(read_inferior_memory) [IN_PROCESS_AGENT]: New.
(UNKNOWN_SIDE_EFFECTS): New.
(stop_tracing): New.
(flush_trace_buffer): New.
(stop_tracing_bkpt): New.
(flush_trace_buffer_bkpt): New.
(read_inferior_integer): New.
(read_inferior_uinteger): New.
(read_inferior_data_pointer): New.
(write_inferior_data_pointer): New.
(write_inferior_integer): New.
(write_inferior_uinteger): New.
(struct collect_static_trace_data_action): Delete.
(enum tracepoint_type): New.
(struct tracepoint) <type>: New field `type'.
<actions_str, step_actions, step_actions_str>: Only include in GDBserver.
<orig_size, obj_addr_on_target, adjusted_insn_addr>
<adjusted_insn_addr_end, jump_pad, jump_pad_end>: New fields.
(tracepoints): Use IP_AGENT_EXPORT.
(last_tracepoint): Don't include in the IPA.
(stopping_tracepoint): Use IP_AGENT_EXPORT.
(trace_buffer_is_full): Use IP_AGENT_EXPORT.
(alloced_trace_state_variables): New.
(trace_state_variables): Use IP_AGENT_EXPORT.
(traceframe_t): Delete unused variable.
(circular_trace_buffer): Don't include in the IPA.
(trace_buffer_start): Delete.
(struct trace_buffer_control): New.
(trace_buffer_free): Delete.
(struct ipa_trace_buffer_control): New.
(GDBSERVER_FLUSH_COUNT_MASK, GDBSERVER_FLUSH_COUNT_MASK_PREV)
(GDBSERVER_FLUSH_COUNT_MASK_CURR, GDBSERVER_UPDATED_FLUSH_COUNT_BIT):
New.
(trace_buffer_ctrl): New.
(TRACE_BUFFER_CTRL_CURR): New.
(trace_buffer_start, trace_buffer_free, trace_buffer_end_free):
Reimplement as macros.
(trace_buffer_wrap): Delete.
(traceframe_write_count, traceframe_read_count)
(traceframes_created, tracing): Use IP_AGENT_EXPORT.
(struct tracepoint_hit_ctx) <type>: New field.
(struct fast_tracepoint_ctx): New.
(memory_barrier): New.
(cmpxchg): New.
(record_tracepoint_error): Update atomically in the IPA.
(clear_inferior_trace_buffer): New.
(about_to_request_buffer_space): New.
(trace_buffer_alloc): Handle GDBserver and inferior simulatenous
updating the same buffer.
(add_tracepoint): Default the tracepoint's type to trap
tracepoint, and orig_size to -1.
(get_trace_state_variable) [IN_PROCESS_AGENT]: Handle allocated
internal variables.
(create_trace_state_variable): New parameter `gdb'. Handle it.
(clear_installed_tracepoints): Clear fast tracepoint jumps.
(cmd_qtdp): Handle fast tracepoints.
(cmd_qtdv): Adjust.
(max_jump_pad_size): New.
(gdb_jump_pad_head): New.
(get_jump_space_head): New.
(claim_jump_space): New.
(sort_tracepoints): New.
(MAX_JUMP_SIZE): New.
(cmd_qtstart): Handle fast tracepoints. Sync tracepoints with the
IPA.
(stop_tracing) [IN_PROCESS_AGENT]: Don't include the tdisconnected
support. Upload fast traceframes, and delete internal IPA
breakpoints.
(stop_tracing_handler): New.
(flush_trace_buffer_handler): New.
(cmd_qtstop): Upload fast tracepoints.
(response_tracepoint): Handle fast tracepoints.
(tracepoint_finished_step): Upload fast traceframes. Set the
tracepoint hit context's tracepoint type.
(handle_tracepoint_bkpts): New.
(tracepoint_was_hit): Set the tracepoint hit context's tracepoint
type. Add comment about fast tracepoints.
(collect_data_at_tracepoint) [IN_PROCESS_AGENT]: Don't access the
non-existing action_str field.
(get_context_regcache): Handle fast tracepoints.
(do_action_at_tracepoint) [!IN_PROCESS_AGENT]: Don't write the PC
to the regcache.
(fast_tracepoint_from_jump_pad_address): New.
(fast_tracepoint_from_ipa_tpoint_address): New.
(collecting_t): New.
(force_unlock_trace_buffer): New.
(fast_tracepoint_collecting): New.
(collecting): New.
(gdb_collect): New.
(write_inferior_data_ptr): New.
(target_tp_heap): New.
(target_malloc): New.
(download_agent_expr): New.
(UALIGN): New.
(download_tracepoints): New.
(download_trace_state_variables): New.
(upload_fast_traceframes): New.
(IPA_FIRST_TRACEFRAME): New.
(IPA_NEXT_TRACEFRAME_1): New.
(IPA_NEXT_TRACEFRAME): New.
[IN_PROCESS_AGENT]: Include sys/mman.h and fcntl.h.
[IN_PROCESS_AGENT] (gdb_tp_heap_buffer, gdb_jump_pad_buffer)
(gdb_jump_pad_buffer_end): New.
[IN_PROCESS_AGENT] (initialize_tracepoint_ftlib): New.
(initialize_tracepoint): Adjust.
[IN_PROCESS_AGENT]: Allocate the IPA heap, and jump pad scratch
buffer. Initialize the low module.
* utils.c (PREFIX, TOOLNAME): New.
(malloc_failure): Use PREFIX.
(error): In the IPA, an error causes an exit.
(fatal, warning): Use PREFIX.
(internal_error): Use TOOLNAME.
(NUMCELLS): Increase to 10.
* configure, config.in: Regenerate.
gdb/
2010-06-01 Pedro Alves <pedro@codesourcery.com>
* NEWS: Mention gdbserver fast tracepoints support.
gdb/doc/
2010-06-01 Pedro Alves <pedro@codesourcery.com>
* gdb.texinfo (Set Tracepoints): Mention tracepoints support in
gdbserver, and add cross reference.
(Tracepoints support in gdbserver): New subsection.
2010-06-01 21:20:52 +08:00
|
|
|
|
|
|
|
/* fast tracepoints collect registers. */
|
|
|
|
|
|
|
|
#define FT_CR_RIP 0
|
|
|
|
#define FT_CR_EFLAGS 1
|
|
|
|
#define FT_CR_R8 2
|
|
|
|
#define FT_CR_R9 3
|
|
|
|
#define FT_CR_R10 4
|
|
|
|
#define FT_CR_R11 5
|
|
|
|
#define FT_CR_R12 6
|
|
|
|
#define FT_CR_R13 7
|
|
|
|
#define FT_CR_R14 8
|
|
|
|
#define FT_CR_R15 9
|
|
|
|
#define FT_CR_RAX 10
|
|
|
|
#define FT_CR_RBX 11
|
|
|
|
#define FT_CR_RCX 12
|
|
|
|
#define FT_CR_RDX 13
|
|
|
|
#define FT_CR_RSI 14
|
|
|
|
#define FT_CR_RDI 15
|
|
|
|
#define FT_CR_RBP 16
|
|
|
|
#define FT_CR_RSP 17
|
|
|
|
|
|
|
|
static const int x86_64_ft_collect_regmap[] = {
|
|
|
|
FT_CR_RAX * 8, FT_CR_RBX * 8, FT_CR_RCX * 8, FT_CR_RDX * 8,
|
|
|
|
FT_CR_RSI * 8, FT_CR_RDI * 8, FT_CR_RBP * 8, FT_CR_RSP * 8,
|
|
|
|
FT_CR_R8 * 8, FT_CR_R9 * 8, FT_CR_R10 * 8, FT_CR_R11 * 8,
|
|
|
|
FT_CR_R12 * 8, FT_CR_R13 * 8, FT_CR_R14 * 8, FT_CR_R15 * 8,
|
|
|
|
FT_CR_RIP * 8, FT_CR_EFLAGS * 8
|
|
|
|
};
|
|
|
|
|
|
|
|
#define X86_64_NUM_FT_COLLECT_GREGS \
|
|
|
|
(sizeof (x86_64_ft_collect_regmap) / sizeof(x86_64_ft_collect_regmap[0]))
|
|
|
|
|
|
|
|
void
|
|
|
|
supply_fast_tracepoint_registers (struct regcache *regcache,
|
|
|
|
const unsigned char *buf)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
|
|
|
for (i = 0; i < X86_64_NUM_FT_COLLECT_GREGS; i++)
|
|
|
|
supply_register (regcache, i,
|
|
|
|
((char *) buf) + x86_64_ft_collect_regmap[i]);
|
|
|
|
}
|
|
|
|
|
2016-03-11 22:51:29 +08:00
|
|
|
ULONGEST
|
|
|
|
get_raw_reg (const unsigned char *raw_regs, int regnum)
|
gdb/
2010-06-14 Pedro Alves <pedro@codesourcery.com>
* NEWS: Mention GDBserver's JIT compilation of tracepoint
bytecode.
gdb/gdbserver/
2010-06-14 Stan Shebs <stan@codesourcery.com>
Pedro Alves <pedro@codesourcery.com>
Bytecode compiler.
* linux-x86-low.c: Include limits.h.
(add_insns): New.
(always_true): New.
(EMIT_ASM): New.
(EMIT_ASM32): New.
(amd64_emit_prologue, amd64_emit_epilogue, amd64_emit_add)
(amd64_emit_sub, amd64_emit_mul, amd64_emit_lsh)
(amd64_emit_rsh_signed, amd64_emit_rsh_unsigned, amd64_emit_ext,
(amd64_emit_log_not, amd64_emit_bit_and, amd64_emit_bit_or)
(amd64_emit_bit_xor, amd64_emit_bit_not, amd64_emit_equal,
(amd64_emit_less_signed, amd64_emit_less_unsigned, amd64_emit_ref,
(amd64_emit_if_goto, amd64_emit_goto, amd64_write_goto_address)
(amd64_emit_const, amd64_emit_call, amd64_emit_reg)
(amd64_emit_pop, amd64_emit_stack_flush, amd64_emit_zero_ext)
(amd64_emit_swap, amd64_emit_stack_adjust, amd64_emit_int_call_1)
(amd64_emit_void_call_2): New.
(amd64_emit_ops): New.
(i386_emit_prologue, i386_emit_epilogue, i386_emit_add)
(i386_emit_sub,i386_emit_mul, i386_emit_lsh, i386_emit_rsh_signed)
(i386_emit_rsh_unsigned, i386_emit_ext, i386_emit_log_not)
(i386_emit_bit_and, i386_emit_bit_or, i386_emit_bit_xor)
(i386_emit_bit_not, i386_emit_equal, i386_emit_less_signed)
(i386_emit_less_unsigned, i386_emit_ref, i386_emit_if_goto)
(i386_emit_goto, i386_write_goto_address, i386_emit_const)
(i386_emit_call, i386_emit_reg, i386_emit_pop)
(i386_emit_stack_flush, i386_emit_zero_ext, i386_emit_swap)
(i386_emit_stack_adjust, i386_emit_int_call_1)
(i386_emit_void_call_2): New.
(i386_emit_ops): New.
(x86_emit_ops): New.
(the_low_target): Install x86_emit_ops.
* server.h (struct emit_ops): New.
(get_raw_reg_func_addr): Declare.
(current_insn_ptr, emit_error): Declare.
* tracepoint.c (get_raw_reg, get_trace_state_variable_value)
(set_trace_state_variable_value): New defines.
(struct ipa_sym_addresses): New fields addr_get_raw_reg,
addr_get_trace_state_variable_value and
addr_set_trace_state_variable_value.
(symbol_list): New fields for get_raw_reg,
get_trace_state_variable_value and set_trace_state_variable_value.
(condfn): New typedef.
(struct tracepoint): New field `compiled_cond'.
(do_action_at_tracepoint): Clear compiled_cond.
(get_trace_state_variable_value, set_trace_state_variable_value):
Export in the IPA.
(condition_true_at_tracepoint): If there's a compiled condition,
run that.
(current_insn_ptr, emit_error): New globals.
(struct bytecode_address): New.
(get_raw_reg_func_addr): New.
(emit_prologue, emit_epilogue, emit_add, emit_sub, emit_mul)
(emit_lsh, emit_rsh_signed, emit_rsh_unsigned, emit_ext)
(emit_log_not, emit_bit_and, emit_bit_or, emit_bit_xor)
(emit_bit_not, emit_equal, emit_less_signed, emit_less_unsigned)
(emit_ref, emit_if_goto, emit_goto, write_goto_address, emit_const)
(emit_reg, emit_pop, emit_stack_flush, emit_zero_ext, emit_swap)
(emit_stack_adjust, emit_int_call_1, emit_void_call_2): New.
(compile_tracepoint_condition, compile_bytecodes): New.
* target.h (emit_ops): Forward declare.
(struct target_ops): New field emit_ops.
(target_emit_ops): New.
* linux-amd64-ipa.c (gdb_agent_get_raw_reg): New.
* linux-i386-ipa.c (gdb_agent_get_raw_reg): New.
* linux-low.c (linux_emit_ops): New.
(linux_target_ops): Install it.
* linux-low.h (struct linux_target_ops): New field emit_ops.
2010-06-15 06:16:09 +08:00
|
|
|
{
|
2011-02-28 05:18:14 +08:00
|
|
|
if (regnum >= X86_64_NUM_FT_COLLECT_GREGS)
|
gdb/
2010-06-14 Pedro Alves <pedro@codesourcery.com>
* NEWS: Mention GDBserver's JIT compilation of tracepoint
bytecode.
gdb/gdbserver/
2010-06-14 Stan Shebs <stan@codesourcery.com>
Pedro Alves <pedro@codesourcery.com>
Bytecode compiler.
* linux-x86-low.c: Include limits.h.
(add_insns): New.
(always_true): New.
(EMIT_ASM): New.
(EMIT_ASM32): New.
(amd64_emit_prologue, amd64_emit_epilogue, amd64_emit_add)
(amd64_emit_sub, amd64_emit_mul, amd64_emit_lsh)
(amd64_emit_rsh_signed, amd64_emit_rsh_unsigned, amd64_emit_ext,
(amd64_emit_log_not, amd64_emit_bit_and, amd64_emit_bit_or)
(amd64_emit_bit_xor, amd64_emit_bit_not, amd64_emit_equal,
(amd64_emit_less_signed, amd64_emit_less_unsigned, amd64_emit_ref,
(amd64_emit_if_goto, amd64_emit_goto, amd64_write_goto_address)
(amd64_emit_const, amd64_emit_call, amd64_emit_reg)
(amd64_emit_pop, amd64_emit_stack_flush, amd64_emit_zero_ext)
(amd64_emit_swap, amd64_emit_stack_adjust, amd64_emit_int_call_1)
(amd64_emit_void_call_2): New.
(amd64_emit_ops): New.
(i386_emit_prologue, i386_emit_epilogue, i386_emit_add)
(i386_emit_sub,i386_emit_mul, i386_emit_lsh, i386_emit_rsh_signed)
(i386_emit_rsh_unsigned, i386_emit_ext, i386_emit_log_not)
(i386_emit_bit_and, i386_emit_bit_or, i386_emit_bit_xor)
(i386_emit_bit_not, i386_emit_equal, i386_emit_less_signed)
(i386_emit_less_unsigned, i386_emit_ref, i386_emit_if_goto)
(i386_emit_goto, i386_write_goto_address, i386_emit_const)
(i386_emit_call, i386_emit_reg, i386_emit_pop)
(i386_emit_stack_flush, i386_emit_zero_ext, i386_emit_swap)
(i386_emit_stack_adjust, i386_emit_int_call_1)
(i386_emit_void_call_2): New.
(i386_emit_ops): New.
(x86_emit_ops): New.
(the_low_target): Install x86_emit_ops.
* server.h (struct emit_ops): New.
(get_raw_reg_func_addr): Declare.
(current_insn_ptr, emit_error): Declare.
* tracepoint.c (get_raw_reg, get_trace_state_variable_value)
(set_trace_state_variable_value): New defines.
(struct ipa_sym_addresses): New fields addr_get_raw_reg,
addr_get_trace_state_variable_value and
addr_set_trace_state_variable_value.
(symbol_list): New fields for get_raw_reg,
get_trace_state_variable_value and set_trace_state_variable_value.
(condfn): New typedef.
(struct tracepoint): New field `compiled_cond'.
(do_action_at_tracepoint): Clear compiled_cond.
(get_trace_state_variable_value, set_trace_state_variable_value):
Export in the IPA.
(condition_true_at_tracepoint): If there's a compiled condition,
run that.
(current_insn_ptr, emit_error): New globals.
(struct bytecode_address): New.
(get_raw_reg_func_addr): New.
(emit_prologue, emit_epilogue, emit_add, emit_sub, emit_mul)
(emit_lsh, emit_rsh_signed, emit_rsh_unsigned, emit_ext)
(emit_log_not, emit_bit_and, emit_bit_or, emit_bit_xor)
(emit_bit_not, emit_equal, emit_less_signed, emit_less_unsigned)
(emit_ref, emit_if_goto, emit_goto, write_goto_address, emit_const)
(emit_reg, emit_pop, emit_stack_flush, emit_zero_ext, emit_swap)
(emit_stack_adjust, emit_int_call_1, emit_void_call_2): New.
(compile_tracepoint_condition, compile_bytecodes): New.
* target.h (emit_ops): Forward declare.
(struct target_ops): New field emit_ops.
(target_emit_ops): New.
* linux-amd64-ipa.c (gdb_agent_get_raw_reg): New.
* linux-i386-ipa.c (gdb_agent_get_raw_reg): New.
* linux-low.c (linux_emit_ops): New.
(linux_target_ops): Install it.
* linux-low.h (struct linux_target_ops): New field emit_ops.
2010-06-15 06:16:09 +08:00
|
|
|
return 0;
|
|
|
|
|
|
|
|
return *(ULONGEST *) (raw_regs + x86_64_ft_collect_regmap[regnum]);
|
|
|
|
}
|
|
|
|
|
Static tracepoints support, and UST integration.
gdb/gdbserver/
* configure.ac: Handle --with-ust. substitute ustlibs and ustinc.
* mem-break.c (uninsert_all_breakpoints)
(reinsert_all_breakpoints): New.
* mem-break.h (reinsert_all_breakpoints, uninsert_all_breakpoints):
* tracepoint.c (ust_loaded, helper_thread_id, cmd_buf): New.
(gdb_agent_ust_loaded, helper_thread_id)
(gdb_agent_helper_thread_id): New macros.
(struct ipa_sym_addresses): Add addr_ust_loaded,
addr_helper_thread_id, addr_cmd_buf.
(symbol_list): Add ust_loaded, helper_thread_id, cmd_buf.
(in_process_agent_loaded_ust): New.
(write_e_ust_not_loaded): New.
(maybe_write_ipa_ust_not_loaded): New.
(struct collect_static_trace_data_action): New.
(enum tracepoint_type) <static_tracepoint>: New.
(struct tracepoint) <handle>: Mention static tracepoints.
(struct static_tracepoint_ctx): New.
(CMD_BUF_SIZE): New.
(add_tracepoint_action): Handle static tracepoint actions.
(unprobe_marker_at): New.
(clear_installed_tracepoints): Handle static tracepoints.
(cmd_qtdp): Handle static tracepoints.
(probe_marker_at): New.
(cmd_qtstart): Handle static tracepoints.
(response_tracepoint): Handle static tracepoints.
(cmd_qtfstm, cmd_qtsstm, cmd_qtstmat): New.
(handle_tracepoint_query): Handle qTfSTM, qTsSTM and qTSTMat.
(get_context_regcache): Handle static tracepoints.
(do_action_at_tracepoint): Handle static tracepoint actions.
(traceframe_find_block_type): Handle static trace data blocks.
(traceframe_read_sdata): New.
(download_tracepoints): Download static tracepoint actions.
[HAVE_UST] Include ust/ust.h, dlfcn.h, sys/socket.h, and sys/un.h.
(GDB_PROBE_NAME): New.
(ust_ops): New.
(GET_UST_SYM): New.
(USTF): New.
(dlsym_ust): New.
(ust_marker_to_static_tracepoint): New.
(gdb_probe): New.
(collect_ust_data_at_tracepoint): New.
(gdb_ust_probe): New.
(UNIX_PATH_MAX, SOCK_DIR): New.
(gdb_ust_connect_sync_socket): New.
(resume_thread, stop_thread): New.
(run_inferior_command): New.
(init_named_socket): New.
(gdb_ust_socket_init): New.
(cstr_to_hexstr): New.
(next_st): New.
(first_marker, next_marker): New.
(response_ust_marker): New.
(cmd_qtfstm, cmd_qtsstm): New.
(unprobe_marker_at, probe_marker_at): New.
(cmd_qtstmat, gdb_ust_thread): New.
(gdb_ust_init): New.
(initialize_tracepoint_ftlib): Call gdb_ust_init.
* linux-amd64-ipa.c [HAVE_UST]: Include ust/processor.h
(ST_REGENTRY): New.
(x86_64_st_collect_regmap): New.
(X86_64_NUM_ST_COLLECT_GREGS): New.
(AMD64_RIP_REGNUM): New.
(supply_static_tracepoint_registers): New.
* linux-i386-ipa.c [HAVE_UST]: Include ust/processor.h
(ST_REGENTRY): New.
(i386_st_collect_regmap): New.
(i386_NUM_ST_COLLECT_GREGS): New.
(supply_static_tracepoint_registers): New.
* server.c (handle_query): Handle qXfer:statictrace:read.
<qSupported>: Report support for StaticTracepoints, and
qXfer:statictrace:read features.
* server.h (traceframe_read_sdata)
(supply_static_tracepoint_registers): Declare.
* remote-utils.c (convert_int_to_ascii, hexchars, ishex, tohex)
(unpack_varlen_hex): Include in IPA build.
* Makefile.in (ustlibs, ustinc): New.
(IPA_OBJS): Add remote-utils-ipa.o.
($(IPA_LIB)): Link -ldl and -lpthread.
(UST_CFLAGS): New.
(IPAGENT_CFLAGS): Add UST_CFLAGS.
* config.in, configure: Regenerate.
gdb/
* NEWS: Mention new support for static tracepoints.
(New packets): Mention qTfSTM, qTsSTM, qTSTMat and
qXfer:statictrace:read.
(New features in the GDB remote stub, GDBserver): Mention static
tracepoints support using an UST based backend.
(New commands): Mention "info static-tracepoint-markers" and
"strace".
* breakpoint.c (is_marker_spec): New.
(is_tracepoint): Handle static tracepoints.
(validate_commands_for_breakpoint): Static tracepoints can't do
while-stepping.
(static_tracepoints_here): New.
(bpstat_what): Handle static tracepoints.
(print_one_breakpoint_location, allocate_bp_location, mention):
Ditto.
(create_breakpoint_sal): Ditto.
(decode_static_tracepoint_spec): New.
(create_breakpoint): Replace `hardwareflag', and `traceflag' with
`type_wanted'. Adjust. Handle static tracepoint marker
locations.
(break_command_1): Adjust.
(update_static_tracepoint): New.
(update_breakpoint_locations): Handle static tracepoints.
(breakpoint_re_set_one): Handle static tracepoint marker
locations.
(disable_command, enable_command): Handle static tracepoints.
(trace_command, ftrace_command): Adjust.
(strace_command): New.
(create_tracepoint_from_upload): Adjust.
(save_breakpoints): Handle static tracepoints.
(_initialize_breakpoint): Install the "strace" command.
* breakpoint.h (enum bptype): New bp_static_tracepoint type.
(struct breakpoint): New fields static_trace_marker_id and
static_trace_marker_id_idx.
(breakpoints_here_p): Declare.
(create_breakpoint): Adjust.
(static_tracepoints_here): Declare.
* remote.c (struct remote_state) <static_tracepoints>: New field.
(PACKET_qXfer_statictrace_read, PACKET_StaticTracepoints): New.
(remote_static_tracepoint_marker_at): New.
(remote_static_tracepoint_markers_by_strid): New.
(remote_static_tracepoint_feature): New.
(remote_disconnected_tracing_feature): Handle "StaticTracepoints".
(remote_xfer_partial): Handle TARGET_OBJECT_STATIC_TRACE_DATA.
(remote_supports_static_tracepoints): New.
(remote_download_tracepoint): Download static tracepoints.
(init_remote_ops): Install remote_static_tracepoint_marker_at and
remote_static_tracepoint_markers_by_strid.
(_initialize_remote): Install set|show remote static-tracepoints,
and set|show remote read-sdata-object commands.
* target.c (update_current_target): Inherit and default
to_static_tracepoint_marker_at, and
to_static_tracepoint_markers_by_strid.
* target.h (static_tracepoint_marker): Forward declare.
(enum target_object): New object TARGET_OBJECT_STATIC_TRACE_DATA.
(static_tracepoint_marker_p): New typedef.
(DEF_VEC_P(static_tracepoint_marker_p)): New VEC type.
(struct target_ops): New fields to_static_tracepoint_marker_at and
to_static_tracepoint_markers_by_strid.
(target_static_tracepoint_marker_at)
(target_static_tracepoint_markers_by_strid): New.
* tracepoint.c: Include source.h.
(validate_actionline): Handle $_sdata.
(struct collection_list): New field strace_data.
(add_static_trace_data): New.
(clear_collection_list): Clear strace_data.
(stringify_collection_list): Account for a possible static trace
data collection.
(encode_actions_1): Encode an $_sdata collection.
(parse_tracepoint_definition): Handle static tracepoints.
(parse_static_tracepoint_marker_definition): New.
(release_static_tracepoint_marker): New.
(print_one_static_tracepoint_marker): New.
(info_static_tracepoint_markers_command): New.
(sdata_make_value): New.
(_initialize_tracepoint): Create the $_sdata convenience variable.
Add the "info static-tracepoint-markers" command.
Mention $_sdata in the "collect" command's help output.
* tracepoint.h (struct static_tracepoint_marker): New.
(parse_static_tracepoint_marker_definition)
(release_static_tracepoint_marker): Declare.
* mi/mi-cmd-break.c (mi_cmd_break_insert): Adjust.
* python/py-breakpoint.c (bppy_new): Adjust.
doc/
* gdb.texinfo (Convenience Variables): Document $_sdata.
(Commands to Set Tracepoints): Describe static tracepoints. Add
`Listing Static Tracepoint Markers' menu entry. Document
"strace".
(Tracepoint Action Lists): Document collecting $_sdata.
(Listing Static Tracepoint Markers): New subsection.
(Tracepoints support in gdbserver): Mention static tracepoints.
(remote packets, enabling and disabling): Mention
read-sdata-object.
(General Query Packets) <qSupported>: Document qXfer:sdata:read
and StaticTracepoint.
Mention qTfSTM, qTsSTM and qTSTMat as tracepoint packets.
Document qXfer:sdata:read.
(Tracepoint packets): Document qTfSTM, qTsSTM and qTSTMat.
2010-07-01 18:36:12 +08:00
|
|
|
#ifdef HAVE_UST
|
|
|
|
|
|
|
|
#include <ust/processor.h>
|
|
|
|
|
|
|
|
/* "struct registers" is the UST object type holding the registers at
|
|
|
|
the time of the static tracepoint marker call. This doesn't
|
|
|
|
contain RIP, but we know what it must have been (the marker
|
|
|
|
address). */
|
|
|
|
|
|
|
|
#define ST_REGENTRY(REG) \
|
|
|
|
{ \
|
|
|
|
offsetof (struct registers, REG), \
|
|
|
|
sizeof (((struct registers *) NULL)->REG) \
|
|
|
|
}
|
|
|
|
|
|
|
|
static struct
|
|
|
|
{
|
|
|
|
int offset;
|
|
|
|
int size;
|
|
|
|
} x86_64_st_collect_regmap[] =
|
|
|
|
{
|
|
|
|
ST_REGENTRY(rax),
|
|
|
|
ST_REGENTRY(rbx),
|
|
|
|
ST_REGENTRY(rcx),
|
|
|
|
ST_REGENTRY(rdx),
|
|
|
|
ST_REGENTRY(rsi),
|
|
|
|
ST_REGENTRY(rdi),
|
|
|
|
ST_REGENTRY(rbp),
|
|
|
|
ST_REGENTRY(rsp),
|
|
|
|
ST_REGENTRY(r8),
|
|
|
|
ST_REGENTRY(r9),
|
|
|
|
ST_REGENTRY(r10),
|
|
|
|
ST_REGENTRY(r11),
|
|
|
|
ST_REGENTRY(r12),
|
|
|
|
ST_REGENTRY(r13),
|
|
|
|
ST_REGENTRY(r14),
|
|
|
|
ST_REGENTRY(r15),
|
|
|
|
{ -1, 0 },
|
|
|
|
ST_REGENTRY(rflags),
|
|
|
|
ST_REGENTRY(cs),
|
|
|
|
ST_REGENTRY(ss),
|
|
|
|
};
|
|
|
|
|
|
|
|
#define X86_64_NUM_ST_COLLECT_GREGS \
|
|
|
|
(sizeof (x86_64_st_collect_regmap) / sizeof (x86_64_st_collect_regmap[0]))
|
|
|
|
|
|
|
|
/* GDB's RIP register number. */
|
|
|
|
#define AMD64_RIP_REGNUM 16
|
|
|
|
|
|
|
|
void
|
|
|
|
supply_static_tracepoint_registers (struct regcache *regcache,
|
|
|
|
const unsigned char *buf,
|
|
|
|
CORE_ADDR pc)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
unsigned long newpc = pc;
|
|
|
|
|
|
|
|
supply_register (regcache, AMD64_RIP_REGNUM, &newpc);
|
|
|
|
|
|
|
|
for (i = 0; i < X86_64_NUM_ST_COLLECT_GREGS; i++)
|
|
|
|
if (x86_64_st_collect_regmap[i].offset != -1)
|
|
|
|
{
|
|
|
|
switch (x86_64_st_collect_regmap[i].size)
|
|
|
|
{
|
|
|
|
case 8:
|
|
|
|
supply_register (regcache, i,
|
|
|
|
((char *) buf)
|
|
|
|
+ x86_64_st_collect_regmap[i].offset);
|
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
{
|
|
|
|
unsigned long reg
|
|
|
|
= * (short *) (((char *) buf)
|
|
|
|
+ x86_64_st_collect_regmap[i].offset);
|
|
|
|
reg &= 0xffff;
|
|
|
|
supply_register (regcache, i, ®);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
default:
|
internal_error: remove need to pass __FILE__/__LINE__
Currently, every internal_error call must be passed __FILE__/__LINE__
explicitly, like:
internal_error (__FILE__, __LINE__, "foo %d", var);
The need to pass in explicit __FILE__/__LINE__ is there probably
because the function predates widespread and portable variadic macros
availability. We can use variadic macros nowadays, and in fact, we
already use them in several places, including the related
gdb_assert_not_reached.
So this patch renames the internal_error function to something else,
and then reimplements internal_error as a variadic macro that expands
__FILE__/__LINE__ itself.
The result is that we now should call internal_error like so:
internal_error ("foo %d", var);
Likewise for internal_warning.
The patch adjusts all calls sites. 99% of the adjustments were done
with a perl/sed script.
The non-mechanical changes are in gdbsupport/errors.h,
gdbsupport/gdb_assert.h, and gdb/gdbarch.py.
Approved-By: Simon Marchi <simon.marchi@efficios.com>
Change-Id: Ia6f372c11550ca876829e8fd85048f4502bdcf06
2022-10-18 00:12:20 +08:00
|
|
|
internal_error ("unhandled register size: %d",
|
Static tracepoints support, and UST integration.
gdb/gdbserver/
* configure.ac: Handle --with-ust. substitute ustlibs and ustinc.
* mem-break.c (uninsert_all_breakpoints)
(reinsert_all_breakpoints): New.
* mem-break.h (reinsert_all_breakpoints, uninsert_all_breakpoints):
* tracepoint.c (ust_loaded, helper_thread_id, cmd_buf): New.
(gdb_agent_ust_loaded, helper_thread_id)
(gdb_agent_helper_thread_id): New macros.
(struct ipa_sym_addresses): Add addr_ust_loaded,
addr_helper_thread_id, addr_cmd_buf.
(symbol_list): Add ust_loaded, helper_thread_id, cmd_buf.
(in_process_agent_loaded_ust): New.
(write_e_ust_not_loaded): New.
(maybe_write_ipa_ust_not_loaded): New.
(struct collect_static_trace_data_action): New.
(enum tracepoint_type) <static_tracepoint>: New.
(struct tracepoint) <handle>: Mention static tracepoints.
(struct static_tracepoint_ctx): New.
(CMD_BUF_SIZE): New.
(add_tracepoint_action): Handle static tracepoint actions.
(unprobe_marker_at): New.
(clear_installed_tracepoints): Handle static tracepoints.
(cmd_qtdp): Handle static tracepoints.
(probe_marker_at): New.
(cmd_qtstart): Handle static tracepoints.
(response_tracepoint): Handle static tracepoints.
(cmd_qtfstm, cmd_qtsstm, cmd_qtstmat): New.
(handle_tracepoint_query): Handle qTfSTM, qTsSTM and qTSTMat.
(get_context_regcache): Handle static tracepoints.
(do_action_at_tracepoint): Handle static tracepoint actions.
(traceframe_find_block_type): Handle static trace data blocks.
(traceframe_read_sdata): New.
(download_tracepoints): Download static tracepoint actions.
[HAVE_UST] Include ust/ust.h, dlfcn.h, sys/socket.h, and sys/un.h.
(GDB_PROBE_NAME): New.
(ust_ops): New.
(GET_UST_SYM): New.
(USTF): New.
(dlsym_ust): New.
(ust_marker_to_static_tracepoint): New.
(gdb_probe): New.
(collect_ust_data_at_tracepoint): New.
(gdb_ust_probe): New.
(UNIX_PATH_MAX, SOCK_DIR): New.
(gdb_ust_connect_sync_socket): New.
(resume_thread, stop_thread): New.
(run_inferior_command): New.
(init_named_socket): New.
(gdb_ust_socket_init): New.
(cstr_to_hexstr): New.
(next_st): New.
(first_marker, next_marker): New.
(response_ust_marker): New.
(cmd_qtfstm, cmd_qtsstm): New.
(unprobe_marker_at, probe_marker_at): New.
(cmd_qtstmat, gdb_ust_thread): New.
(gdb_ust_init): New.
(initialize_tracepoint_ftlib): Call gdb_ust_init.
* linux-amd64-ipa.c [HAVE_UST]: Include ust/processor.h
(ST_REGENTRY): New.
(x86_64_st_collect_regmap): New.
(X86_64_NUM_ST_COLLECT_GREGS): New.
(AMD64_RIP_REGNUM): New.
(supply_static_tracepoint_registers): New.
* linux-i386-ipa.c [HAVE_UST]: Include ust/processor.h
(ST_REGENTRY): New.
(i386_st_collect_regmap): New.
(i386_NUM_ST_COLLECT_GREGS): New.
(supply_static_tracepoint_registers): New.
* server.c (handle_query): Handle qXfer:statictrace:read.
<qSupported>: Report support for StaticTracepoints, and
qXfer:statictrace:read features.
* server.h (traceframe_read_sdata)
(supply_static_tracepoint_registers): Declare.
* remote-utils.c (convert_int_to_ascii, hexchars, ishex, tohex)
(unpack_varlen_hex): Include in IPA build.
* Makefile.in (ustlibs, ustinc): New.
(IPA_OBJS): Add remote-utils-ipa.o.
($(IPA_LIB)): Link -ldl and -lpthread.
(UST_CFLAGS): New.
(IPAGENT_CFLAGS): Add UST_CFLAGS.
* config.in, configure: Regenerate.
gdb/
* NEWS: Mention new support for static tracepoints.
(New packets): Mention qTfSTM, qTsSTM, qTSTMat and
qXfer:statictrace:read.
(New features in the GDB remote stub, GDBserver): Mention static
tracepoints support using an UST based backend.
(New commands): Mention "info static-tracepoint-markers" and
"strace".
* breakpoint.c (is_marker_spec): New.
(is_tracepoint): Handle static tracepoints.
(validate_commands_for_breakpoint): Static tracepoints can't do
while-stepping.
(static_tracepoints_here): New.
(bpstat_what): Handle static tracepoints.
(print_one_breakpoint_location, allocate_bp_location, mention):
Ditto.
(create_breakpoint_sal): Ditto.
(decode_static_tracepoint_spec): New.
(create_breakpoint): Replace `hardwareflag', and `traceflag' with
`type_wanted'. Adjust. Handle static tracepoint marker
locations.
(break_command_1): Adjust.
(update_static_tracepoint): New.
(update_breakpoint_locations): Handle static tracepoints.
(breakpoint_re_set_one): Handle static tracepoint marker
locations.
(disable_command, enable_command): Handle static tracepoints.
(trace_command, ftrace_command): Adjust.
(strace_command): New.
(create_tracepoint_from_upload): Adjust.
(save_breakpoints): Handle static tracepoints.
(_initialize_breakpoint): Install the "strace" command.
* breakpoint.h (enum bptype): New bp_static_tracepoint type.
(struct breakpoint): New fields static_trace_marker_id and
static_trace_marker_id_idx.
(breakpoints_here_p): Declare.
(create_breakpoint): Adjust.
(static_tracepoints_here): Declare.
* remote.c (struct remote_state) <static_tracepoints>: New field.
(PACKET_qXfer_statictrace_read, PACKET_StaticTracepoints): New.
(remote_static_tracepoint_marker_at): New.
(remote_static_tracepoint_markers_by_strid): New.
(remote_static_tracepoint_feature): New.
(remote_disconnected_tracing_feature): Handle "StaticTracepoints".
(remote_xfer_partial): Handle TARGET_OBJECT_STATIC_TRACE_DATA.
(remote_supports_static_tracepoints): New.
(remote_download_tracepoint): Download static tracepoints.
(init_remote_ops): Install remote_static_tracepoint_marker_at and
remote_static_tracepoint_markers_by_strid.
(_initialize_remote): Install set|show remote static-tracepoints,
and set|show remote read-sdata-object commands.
* target.c (update_current_target): Inherit and default
to_static_tracepoint_marker_at, and
to_static_tracepoint_markers_by_strid.
* target.h (static_tracepoint_marker): Forward declare.
(enum target_object): New object TARGET_OBJECT_STATIC_TRACE_DATA.
(static_tracepoint_marker_p): New typedef.
(DEF_VEC_P(static_tracepoint_marker_p)): New VEC type.
(struct target_ops): New fields to_static_tracepoint_marker_at and
to_static_tracepoint_markers_by_strid.
(target_static_tracepoint_marker_at)
(target_static_tracepoint_markers_by_strid): New.
* tracepoint.c: Include source.h.
(validate_actionline): Handle $_sdata.
(struct collection_list): New field strace_data.
(add_static_trace_data): New.
(clear_collection_list): Clear strace_data.
(stringify_collection_list): Account for a possible static trace
data collection.
(encode_actions_1): Encode an $_sdata collection.
(parse_tracepoint_definition): Handle static tracepoints.
(parse_static_tracepoint_marker_definition): New.
(release_static_tracepoint_marker): New.
(print_one_static_tracepoint_marker): New.
(info_static_tracepoint_markers_command): New.
(sdata_make_value): New.
(_initialize_tracepoint): Create the $_sdata convenience variable.
Add the "info static-tracepoint-markers" command.
Mention $_sdata in the "collect" command's help output.
* tracepoint.h (struct static_tracepoint_marker): New.
(parse_static_tracepoint_marker_definition)
(release_static_tracepoint_marker): Declare.
* mi/mi-cmd-break.c (mi_cmd_break_insert): Adjust.
* python/py-breakpoint.c (bppy_new): Adjust.
doc/
* gdb.texinfo (Convenience Variables): Document $_sdata.
(Commands to Set Tracepoints): Describe static tracepoints. Add
`Listing Static Tracepoint Markers' menu entry. Document
"strace".
(Tracepoint Action Lists): Document collecting $_sdata.
(Listing Static Tracepoint Markers): New subsection.
(Tracepoints support in gdbserver): Mention static tracepoints.
(remote packets, enabling and disabling): Mention
read-sdata-object.
(General Query Packets) <qSupported>: Document qXfer:sdata:read
and StaticTracepoint.
Mention qTfSTM, qTsSTM and qTSTMat as tracepoint packets.
Document qXfer:sdata:read.
(Tracepoint packets): Document qTfSTM, qTsSTM and qTSTMat.
2010-07-01 18:36:12 +08:00
|
|
|
x86_64_st_collect_regmap[i].size);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif /* HAVE_UST */
|
|
|
|
|
[PR gdb/13808] gdb.trace: Pass tdesc selected in gdbserver to IPA.
If gdbserver and IPA are using different tdesc, they will disagree
about 'R' trace packet size. This results in mangled traces.
To make sure they pick the same tdesc, gdbserver pokes the tdesc
(specified as an index in a target-specific list) into a global
variable in IPA. In theory, IPA could find out the tdesc on its
own, but that may be complex (in particular, I don't know how to
tell whether we have LAST_BREAK on s390 without messing with ptrace),
and we'd have to duplicate the logic.
Tested on i386 and x86_64. On i386, it fixes two FAILs in ftrace.exp.
On x86_64, these failures have been KFAILed - one of them works now,
but the other now fails due to an unrelated reason (ugh).
gdb/gdbserver/ChangeLog:
PR gdb/13808
* Makefile.in: Add i386-*-linux-ipa.o and amd64-*-linux-ipa.o.
* configure.srv: Ditto.
* linux-aarch64-ipa.c (get_ipa_tdesc): New function.
(initialize_low_tracepoint): Remove ipa_tdesc assignment.
* linux-amd64-ipa.c: Add "linux-x86-tdesc.h" include.
(init_registers_amd64_linux): Remove prototype.
(tdesc_amd64_linux): Remove declaration.
(get_ipa_tdesc): New function.
(initialize_low_tracepoint): Remove ipa_tdesc assignment,
initialize remaining tdescs.
* linux-i386-ipa.c: Add "linux-x86-tdesc.h" include.
(init_registers_i386_linux): Remove prototype.
(tdesc_i386_linux): Remove declaration.
(get_ipa_tdesc): New function.
(initialize_low_tracepoint): Remove ipa_tdesc assignment,
initialize remaining tdescs.
* linux-low.c (linux_get_ipa_tdesc_idx): New function.
(linux_target_ops): wire in linux_get_ipa_tdesc_idx.
* linux-low.h (struct linux_target_ops): Add get_ipa_tdesc_idx.
* linux-x86-low.c: Move tdesc declarations to linux-x86-tdesc.h.
(x86_get_ipa_tdesc_idx): New function.
(the_low_target): Wire in x86_get_ipa_tdesc_idx.
* linux-x86-tdesc.h: New file.
* target.h (struct target_ops): Add get_ipa_tdesc_idx.
(target_get_ipa_tdesc_idx): New macro.
* tracepoint.c (ipa_tdesc_idx): New macro.
(struct ipa_sym_addresses): Add addr_ipa_tdesc_idx.
(symbol_list): Add ipa_tdesc_idx.
(cmd_qtstart): Write ipa_tdesc_idx in the target.
(ipa_tdesc): Remove.
(ipa_tdesc_idx): New variable.
(get_context_regcache): Use get_ipa_tdesc.
(gdb_collect): Ditto.
(gdb_probe): Ditto.
* tracepoint.h (get_ipa_tdesc): New prototype.
(ipa_tdesc): Remove.
gdb/testsuite/ChangeLog:
PR gdb/13808
* gdb.trace/ftrace.exp (test_fast_tracepoints): Remove kfail.
2016-02-22 04:44:48 +08:00
|
|
|
/* Return target_desc to use for IPA, given the tdesc index passed by
|
|
|
|
gdbserver. */
|
|
|
|
|
|
|
|
const struct target_desc *
|
|
|
|
get_ipa_tdesc (int idx)
|
|
|
|
{
|
gdbserver: update target description creation for x86/linux
This commit is part of a series which aims to share more of the target
description creation between GDB and gdbserver for x86/Linux.
After some refactoring earlier in this series the shared
x86_linux_tdesc_for_tid function was added into nat/x86-linux-tdesc.c.
However, this function still relies on amd64_linux_read_description
and i386_linux_read_description which are implemented separately for
both gdbserver and GDB. Given that at their core, all these functions
do is:
1. take an xcr0 value as input,
2. mask out some feature bits,
3. look for a cached pre-generated target description and return it
if found,
4. if no cached target description is found then call either
amd64_create_target_description or
i386_create_target_description to create a new target
description, which is then added to the cache. Return the newly
created target description.
The inner functions amd64_create_target_description and
i386_create_target_description are already shared between GDB and
gdbserver (in the gdb/arch/ directory), so the only thing that
the *_read_description functions really do is add the caching layer,
and it feels like this really could be shared.
However, we have a small problem.
Despite using the same {amd64,i386}_create_target_description
functions in both GDB and gdbserver to create the target descriptions,
on the gdbserver side we cache target descriptions based on a reduced
set of xcr0 feature bits.
What this means is that, in theory, different xcr0 values can map to
the same cache entry, which could result in the wrong target
description being used.
However, I'm not sure if this can actually happen in reality. Within
gdbserver we already split the target description cache based on i386,
amd64, and x32. I suspect within a given gdbserver session we'll only
see at most one target description for each of these.
The cache conflicting problem is caused by xcr0_to_tdesc_idx, which
maps an xcr0 value to a enum x86_linux_tdesc value, and there are only
7 usable values in enum x86_linux_tdesc.
In contrast, on the GDB side there are 64, 32, and 16 cache slots for
i386, amd64, and x32 respectively.
On the GDB side it is much more important to cache things correctly as
a single GDB session might connect to multiple different remote
targets, each of which might have slightly different x86
architectures.
And so, if we want to merge the target description caching between GDB
and gdbserver, then we need to first update gdbserver so that it
caches in the same way as GDB, that is, it needs to adopt a mechanism
that allows for the same number of cache slots of each of i386, amd64,
and x32. In this way, when the caching is shared, GDB's behaviour
will not change.
Unfortunately it's a little more complex than that due to the in
process agent (IPA).
When the IPA is in use, gdbserver sends a target description index to
the IPA, and the IPA uses this to find the correct target description
to use, the IPA having first generated every possible target
description.
Interestingly, there is certainly a bug here which results from only
having 7 values in enum x86_linux_tdesc. As multiple possible target
descriptions in gdbserver map to the same enum x86_linux_tdesc value,
then, when the enum x86_linux_tdesc value is sent to the IPA there is
no way for gdbserver to know that the IPA will select the correct
target description. This bug will get fixed by this commit.
** START OF AN ASIDE **
Back in the day I suspect this approach of sending a target
description index made perfect sense. However since this commit:
commit a8806230241d201f808d856eaae4d44088117b0c
Date: Thu Dec 7 17:07:01 2017 +0000
Initialize target description early in IPA
I think that passing an index was probably a bad idea.
We used to pass the index, and then use that index to lookup which
target description to instantiate and use, the target description was
not generated until the index arrived.
However, the above commit fixed an issue where we can't call malloc()
within (certain parts of) the IPA (apparently), so instead we now
pre-compute _every_ possible target description within the IPA. The
index is only used to lookup which of the (many) pre-computed target
descriptions to use.
It would (I think) have been easier all around if the IPA just
self-inspected, figured out its own xcr0 value, and used that to
create the one target description that is required. So long as the
xcr0 to target description code is shared (at compile time) with
gdbserver, then we can be sure that the IPA will derive the same
target description as gdbserver, and we would avoid all this index
passing business, which has made this commit so very, very painful.
I did look at how a process might derive its own xcr0 value, but I
don't believe this is actually that simple, so for now I've just
doubled down on the index passing approach.
While reviewing earlier iterations of this patch there has been
discussion about the possibility of removing the IPA from GDB. That
would certainly make all of the code touched in this patch much
simpler, but I don't really want to do that as part of this series.
** END OF AN ASIDE **
Currently then for x86/linux, gdbserver sends a number between 0 and 7
to the IPA, and the IPA uses this to create a target description.
However, I am proposing that gdbserver should now create one of (up
to) 64 different target descriptions for i386, so this 0 to 7 index
isn't going to be good enough any more (amd64 and x32 have slightly
fewer possible target descriptions, but still more than 8, so the
problem is the same).
For a while I wondered if I was going to have to try and find some
backward compatible solution for this mess. But after seeing how
lightly the IPA is actually documented, I wonder if it is not the case
that there is a tight coupling between a version of gdbserver and a
version of the IPA? At least I'm hoping so, and that's what I've
assumed in this commit.
In this commit I have thrown out the old IPA target description index
numbering scheme, and switched to a completely new numbering scheme.
Instead of the index that is passed being arbitrary, the index is
instead calculated from the set of xcr0 features that are present on
the target. Within the IPA we can then reverse this logic to recreate
the xcr0 value based on the index, and from the xcr0 value we can
choose the correct target description.
With the gdbserver to IPA numbering scheme issue resolved I have then
update the gdbserver versions of amd64_linux_read_description and
i386_linux_read_description so that they cache target descriptions
using the same set of xcr0 features as GDB itself.
After this gdbserver should now always come up with the same target
description as GDB does on any x86/Linux target.
This commit does not introduce any new code sharing between GDB and
gdbserver as previous commits in this series have done. Instead this
commit is all about bringing GDB and gdbserver into alignment
functionally so that the next commit(s) can merge the GDB and
gdbserver versions of these functions.
Notes On The Implementation
---------------------------
Previously, within gdbserver, target descriptions were cached within
arrays. These arrays were sized based on enum x86_linux_tdesc and
xcr0_to_tdesc_idx returned the array (cache) index.
Now we need different array lengths for each of i386, amd64, and x32.
And the index to use within each array is calculated based on which
xcr0 bits are set and valid for a particular target type.
I really wanted to avoid having fixed array sizes, or having the set
of relevant xcr0 bits encoded in multiple places.
The solution I came up with was to create a single data structure
which would contain a list of xcr0 bits along with flags to indicate
which of the i386, amd64, and x32 targets the bit is relevant for. By
making the table constexpr, and adding some constexpr helper
functions, it is possible to calculate the sizes for the cache arrays
at compile time, as well as the bit masks needed to each target type.
During review it was pointed out[1] that possibly the failure to check
the SSE and X87 bits for amd64/x32 targets might be an error, however,
if this is the case then this is an issue that existed long before
this patch. I'd really like to keep this patch focused on reworking
the existing code and try to avoid changing how target descriptions
are actually created, mostly out of fear that I'll break something.
[1] https://inbox.sourceware.org/gdb-patches/MN2PR11MB4566070607318EE7E669A5E28E1B2@MN2PR11MB4566.namprd11.prod.outlook.com
Approved-By: John Baldwin <jhb@FreeBSD.org>
Approved-By: Felix Willgerodt <felix.willgerodt@intel.com>
2024-01-31 19:18:34 +08:00
|
|
|
uint64_t xcr0 = x86_linux_tdesc_idx_to_xcr0 (idx);
|
2017-09-05 16:54:54 +08:00
|
|
|
|
2016-08-19 19:07:44 +08:00
|
|
|
#if defined __ILP32__
|
gdbserver: update target description creation for x86/linux
This commit is part of a series which aims to share more of the target
description creation between GDB and gdbserver for x86/Linux.
After some refactoring earlier in this series the shared
x86_linux_tdesc_for_tid function was added into nat/x86-linux-tdesc.c.
However, this function still relies on amd64_linux_read_description
and i386_linux_read_description which are implemented separately for
both gdbserver and GDB. Given that at their core, all these functions
do is:
1. take an xcr0 value as input,
2. mask out some feature bits,
3. look for a cached pre-generated target description and return it
if found,
4. if no cached target description is found then call either
amd64_create_target_description or
i386_create_target_description to create a new target
description, which is then added to the cache. Return the newly
created target description.
The inner functions amd64_create_target_description and
i386_create_target_description are already shared between GDB and
gdbserver (in the gdb/arch/ directory), so the only thing that
the *_read_description functions really do is add the caching layer,
and it feels like this really could be shared.
However, we have a small problem.
Despite using the same {amd64,i386}_create_target_description
functions in both GDB and gdbserver to create the target descriptions,
on the gdbserver side we cache target descriptions based on a reduced
set of xcr0 feature bits.
What this means is that, in theory, different xcr0 values can map to
the same cache entry, which could result in the wrong target
description being used.
However, I'm not sure if this can actually happen in reality. Within
gdbserver we already split the target description cache based on i386,
amd64, and x32. I suspect within a given gdbserver session we'll only
see at most one target description for each of these.
The cache conflicting problem is caused by xcr0_to_tdesc_idx, which
maps an xcr0 value to a enum x86_linux_tdesc value, and there are only
7 usable values in enum x86_linux_tdesc.
In contrast, on the GDB side there are 64, 32, and 16 cache slots for
i386, amd64, and x32 respectively.
On the GDB side it is much more important to cache things correctly as
a single GDB session might connect to multiple different remote
targets, each of which might have slightly different x86
architectures.
And so, if we want to merge the target description caching between GDB
and gdbserver, then we need to first update gdbserver so that it
caches in the same way as GDB, that is, it needs to adopt a mechanism
that allows for the same number of cache slots of each of i386, amd64,
and x32. In this way, when the caching is shared, GDB's behaviour
will not change.
Unfortunately it's a little more complex than that due to the in
process agent (IPA).
When the IPA is in use, gdbserver sends a target description index to
the IPA, and the IPA uses this to find the correct target description
to use, the IPA having first generated every possible target
description.
Interestingly, there is certainly a bug here which results from only
having 7 values in enum x86_linux_tdesc. As multiple possible target
descriptions in gdbserver map to the same enum x86_linux_tdesc value,
then, when the enum x86_linux_tdesc value is sent to the IPA there is
no way for gdbserver to know that the IPA will select the correct
target description. This bug will get fixed by this commit.
** START OF AN ASIDE **
Back in the day I suspect this approach of sending a target
description index made perfect sense. However since this commit:
commit a8806230241d201f808d856eaae4d44088117b0c
Date: Thu Dec 7 17:07:01 2017 +0000
Initialize target description early in IPA
I think that passing an index was probably a bad idea.
We used to pass the index, and then use that index to lookup which
target description to instantiate and use, the target description was
not generated until the index arrived.
However, the above commit fixed an issue where we can't call malloc()
within (certain parts of) the IPA (apparently), so instead we now
pre-compute _every_ possible target description within the IPA. The
index is only used to lookup which of the (many) pre-computed target
descriptions to use.
It would (I think) have been easier all around if the IPA just
self-inspected, figured out its own xcr0 value, and used that to
create the one target description that is required. So long as the
xcr0 to target description code is shared (at compile time) with
gdbserver, then we can be sure that the IPA will derive the same
target description as gdbserver, and we would avoid all this index
passing business, which has made this commit so very, very painful.
I did look at how a process might derive its own xcr0 value, but I
don't believe this is actually that simple, so for now I've just
doubled down on the index passing approach.
While reviewing earlier iterations of this patch there has been
discussion about the possibility of removing the IPA from GDB. That
would certainly make all of the code touched in this patch much
simpler, but I don't really want to do that as part of this series.
** END OF AN ASIDE **
Currently then for x86/linux, gdbserver sends a number between 0 and 7
to the IPA, and the IPA uses this to create a target description.
However, I am proposing that gdbserver should now create one of (up
to) 64 different target descriptions for i386, so this 0 to 7 index
isn't going to be good enough any more (amd64 and x32 have slightly
fewer possible target descriptions, but still more than 8, so the
problem is the same).
For a while I wondered if I was going to have to try and find some
backward compatible solution for this mess. But after seeing how
lightly the IPA is actually documented, I wonder if it is not the case
that there is a tight coupling between a version of gdbserver and a
version of the IPA? At least I'm hoping so, and that's what I've
assumed in this commit.
In this commit I have thrown out the old IPA target description index
numbering scheme, and switched to a completely new numbering scheme.
Instead of the index that is passed being arbitrary, the index is
instead calculated from the set of xcr0 features that are present on
the target. Within the IPA we can then reverse this logic to recreate
the xcr0 value based on the index, and from the xcr0 value we can
choose the correct target description.
With the gdbserver to IPA numbering scheme issue resolved I have then
update the gdbserver versions of amd64_linux_read_description and
i386_linux_read_description so that they cache target descriptions
using the same set of xcr0 features as GDB itself.
After this gdbserver should now always come up with the same target
description as GDB does on any x86/Linux target.
This commit does not introduce any new code sharing between GDB and
gdbserver as previous commits in this series have done. Instead this
commit is all about bringing GDB and gdbserver into alignment
functionally so that the next commit(s) can merge the GDB and
gdbserver versions of these functions.
Notes On The Implementation
---------------------------
Previously, within gdbserver, target descriptions were cached within
arrays. These arrays were sized based on enum x86_linux_tdesc and
xcr0_to_tdesc_idx returned the array (cache) index.
Now we need different array lengths for each of i386, amd64, and x32.
And the index to use within each array is calculated based on which
xcr0 bits are set and valid for a particular target type.
I really wanted to avoid having fixed array sizes, or having the set
of relevant xcr0 bits encoded in multiple places.
The solution I came up with was to create a single data structure
which would contain a list of xcr0 bits along with flags to indicate
which of the i386, amd64, and x32 targets the bit is relevant for. By
making the table constexpr, and adding some constexpr helper
functions, it is possible to calculate the sizes for the cache arrays
at compile time, as well as the bit masks needed to each target type.
During review it was pointed out[1] that possibly the failure to check
the SSE and X87 bits for amd64/x32 targets might be an error, however,
if this is the case then this is an issue that existed long before
this patch. I'd really like to keep this patch focused on reworking
the existing code and try to avoid changing how target descriptions
are actually created, mostly out of fear that I'll break something.
[1] https://inbox.sourceware.org/gdb-patches/MN2PR11MB4566070607318EE7E669A5E28E1B2@MN2PR11MB4566.namprd11.prod.outlook.com
Approved-By: John Baldwin <jhb@FreeBSD.org>
Approved-By: Felix Willgerodt <felix.willgerodt@intel.com>
2024-01-31 19:18:34 +08:00
|
|
|
bool is_x32 = true;
|
2016-08-19 19:07:44 +08:00
|
|
|
#else
|
gdbserver: update target description creation for x86/linux
This commit is part of a series which aims to share more of the target
description creation between GDB and gdbserver for x86/Linux.
After some refactoring earlier in this series the shared
x86_linux_tdesc_for_tid function was added into nat/x86-linux-tdesc.c.
However, this function still relies on amd64_linux_read_description
and i386_linux_read_description which are implemented separately for
both gdbserver and GDB. Given that at their core, all these functions
do is:
1. take an xcr0 value as input,
2. mask out some feature bits,
3. look for a cached pre-generated target description and return it
if found,
4. if no cached target description is found then call either
amd64_create_target_description or
i386_create_target_description to create a new target
description, which is then added to the cache. Return the newly
created target description.
The inner functions amd64_create_target_description and
i386_create_target_description are already shared between GDB and
gdbserver (in the gdb/arch/ directory), so the only thing that
the *_read_description functions really do is add the caching layer,
and it feels like this really could be shared.
However, we have a small problem.
Despite using the same {amd64,i386}_create_target_description
functions in both GDB and gdbserver to create the target descriptions,
on the gdbserver side we cache target descriptions based on a reduced
set of xcr0 feature bits.
What this means is that, in theory, different xcr0 values can map to
the same cache entry, which could result in the wrong target
description being used.
However, I'm not sure if this can actually happen in reality. Within
gdbserver we already split the target description cache based on i386,
amd64, and x32. I suspect within a given gdbserver session we'll only
see at most one target description for each of these.
The cache conflicting problem is caused by xcr0_to_tdesc_idx, which
maps an xcr0 value to a enum x86_linux_tdesc value, and there are only
7 usable values in enum x86_linux_tdesc.
In contrast, on the GDB side there are 64, 32, and 16 cache slots for
i386, amd64, and x32 respectively.
On the GDB side it is much more important to cache things correctly as
a single GDB session might connect to multiple different remote
targets, each of which might have slightly different x86
architectures.
And so, if we want to merge the target description caching between GDB
and gdbserver, then we need to first update gdbserver so that it
caches in the same way as GDB, that is, it needs to adopt a mechanism
that allows for the same number of cache slots of each of i386, amd64,
and x32. In this way, when the caching is shared, GDB's behaviour
will not change.
Unfortunately it's a little more complex than that due to the in
process agent (IPA).
When the IPA is in use, gdbserver sends a target description index to
the IPA, and the IPA uses this to find the correct target description
to use, the IPA having first generated every possible target
description.
Interestingly, there is certainly a bug here which results from only
having 7 values in enum x86_linux_tdesc. As multiple possible target
descriptions in gdbserver map to the same enum x86_linux_tdesc value,
then, when the enum x86_linux_tdesc value is sent to the IPA there is
no way for gdbserver to know that the IPA will select the correct
target description. This bug will get fixed by this commit.
** START OF AN ASIDE **
Back in the day I suspect this approach of sending a target
description index made perfect sense. However since this commit:
commit a8806230241d201f808d856eaae4d44088117b0c
Date: Thu Dec 7 17:07:01 2017 +0000
Initialize target description early in IPA
I think that passing an index was probably a bad idea.
We used to pass the index, and then use that index to lookup which
target description to instantiate and use, the target description was
not generated until the index arrived.
However, the above commit fixed an issue where we can't call malloc()
within (certain parts of) the IPA (apparently), so instead we now
pre-compute _every_ possible target description within the IPA. The
index is only used to lookup which of the (many) pre-computed target
descriptions to use.
It would (I think) have been easier all around if the IPA just
self-inspected, figured out its own xcr0 value, and used that to
create the one target description that is required. So long as the
xcr0 to target description code is shared (at compile time) with
gdbserver, then we can be sure that the IPA will derive the same
target description as gdbserver, and we would avoid all this index
passing business, which has made this commit so very, very painful.
I did look at how a process might derive its own xcr0 value, but I
don't believe this is actually that simple, so for now I've just
doubled down on the index passing approach.
While reviewing earlier iterations of this patch there has been
discussion about the possibility of removing the IPA from GDB. That
would certainly make all of the code touched in this patch much
simpler, but I don't really want to do that as part of this series.
** END OF AN ASIDE **
Currently then for x86/linux, gdbserver sends a number between 0 and 7
to the IPA, and the IPA uses this to create a target description.
However, I am proposing that gdbserver should now create one of (up
to) 64 different target descriptions for i386, so this 0 to 7 index
isn't going to be good enough any more (amd64 and x32 have slightly
fewer possible target descriptions, but still more than 8, so the
problem is the same).
For a while I wondered if I was going to have to try and find some
backward compatible solution for this mess. But after seeing how
lightly the IPA is actually documented, I wonder if it is not the case
that there is a tight coupling between a version of gdbserver and a
version of the IPA? At least I'm hoping so, and that's what I've
assumed in this commit.
In this commit I have thrown out the old IPA target description index
numbering scheme, and switched to a completely new numbering scheme.
Instead of the index that is passed being arbitrary, the index is
instead calculated from the set of xcr0 features that are present on
the target. Within the IPA we can then reverse this logic to recreate
the xcr0 value based on the index, and from the xcr0 value we can
choose the correct target description.
With the gdbserver to IPA numbering scheme issue resolved I have then
update the gdbserver versions of amd64_linux_read_description and
i386_linux_read_description so that they cache target descriptions
using the same set of xcr0 features as GDB itself.
After this gdbserver should now always come up with the same target
description as GDB does on any x86/Linux target.
This commit does not introduce any new code sharing between GDB and
gdbserver as previous commits in this series have done. Instead this
commit is all about bringing GDB and gdbserver into alignment
functionally so that the next commit(s) can merge the GDB and
gdbserver versions of these functions.
Notes On The Implementation
---------------------------
Previously, within gdbserver, target descriptions were cached within
arrays. These arrays were sized based on enum x86_linux_tdesc and
xcr0_to_tdesc_idx returned the array (cache) index.
Now we need different array lengths for each of i386, amd64, and x32.
And the index to use within each array is calculated based on which
xcr0 bits are set and valid for a particular target type.
I really wanted to avoid having fixed array sizes, or having the set
of relevant xcr0 bits encoded in multiple places.
The solution I came up with was to create a single data structure
which would contain a list of xcr0 bits along with flags to indicate
which of the i386, amd64, and x32 targets the bit is relevant for. By
making the table constexpr, and adding some constexpr helper
functions, it is possible to calculate the sizes for the cache arrays
at compile time, as well as the bit masks needed to each target type.
During review it was pointed out[1] that possibly the failure to check
the SSE and X87 bits for amd64/x32 targets might be an error, however,
if this is the case then this is an issue that existed long before
this patch. I'd really like to keep this patch focused on reworking
the existing code and try to avoid changing how target descriptions
are actually created, mostly out of fear that I'll break something.
[1] https://inbox.sourceware.org/gdb-patches/MN2PR11MB4566070607318EE7E669A5E28E1B2@MN2PR11MB4566.namprd11.prod.outlook.com
Approved-By: John Baldwin <jhb@FreeBSD.org>
Approved-By: Felix Willgerodt <felix.willgerodt@intel.com>
2024-01-31 19:18:34 +08:00
|
|
|
bool is_x32 = false;
|
2016-08-19 19:07:44 +08:00
|
|
|
#endif
|
|
|
|
|
gdbserver: update target description creation for x86/linux
This commit is part of a series which aims to share more of the target
description creation between GDB and gdbserver for x86/Linux.
After some refactoring earlier in this series the shared
x86_linux_tdesc_for_tid function was added into nat/x86-linux-tdesc.c.
However, this function still relies on amd64_linux_read_description
and i386_linux_read_description which are implemented separately for
both gdbserver and GDB. Given that at their core, all these functions
do is:
1. take an xcr0 value as input,
2. mask out some feature bits,
3. look for a cached pre-generated target description and return it
if found,
4. if no cached target description is found then call either
amd64_create_target_description or
i386_create_target_description to create a new target
description, which is then added to the cache. Return the newly
created target description.
The inner functions amd64_create_target_description and
i386_create_target_description are already shared between GDB and
gdbserver (in the gdb/arch/ directory), so the only thing that
the *_read_description functions really do is add the caching layer,
and it feels like this really could be shared.
However, we have a small problem.
Despite using the same {amd64,i386}_create_target_description
functions in both GDB and gdbserver to create the target descriptions,
on the gdbserver side we cache target descriptions based on a reduced
set of xcr0 feature bits.
What this means is that, in theory, different xcr0 values can map to
the same cache entry, which could result in the wrong target
description being used.
However, I'm not sure if this can actually happen in reality. Within
gdbserver we already split the target description cache based on i386,
amd64, and x32. I suspect within a given gdbserver session we'll only
see at most one target description for each of these.
The cache conflicting problem is caused by xcr0_to_tdesc_idx, which
maps an xcr0 value to a enum x86_linux_tdesc value, and there are only
7 usable values in enum x86_linux_tdesc.
In contrast, on the GDB side there are 64, 32, and 16 cache slots for
i386, amd64, and x32 respectively.
On the GDB side it is much more important to cache things correctly as
a single GDB session might connect to multiple different remote
targets, each of which might have slightly different x86
architectures.
And so, if we want to merge the target description caching between GDB
and gdbserver, then we need to first update gdbserver so that it
caches in the same way as GDB, that is, it needs to adopt a mechanism
that allows for the same number of cache slots of each of i386, amd64,
and x32. In this way, when the caching is shared, GDB's behaviour
will not change.
Unfortunately it's a little more complex than that due to the in
process agent (IPA).
When the IPA is in use, gdbserver sends a target description index to
the IPA, and the IPA uses this to find the correct target description
to use, the IPA having first generated every possible target
description.
Interestingly, there is certainly a bug here which results from only
having 7 values in enum x86_linux_tdesc. As multiple possible target
descriptions in gdbserver map to the same enum x86_linux_tdesc value,
then, when the enum x86_linux_tdesc value is sent to the IPA there is
no way for gdbserver to know that the IPA will select the correct
target description. This bug will get fixed by this commit.
** START OF AN ASIDE **
Back in the day I suspect this approach of sending a target
description index made perfect sense. However since this commit:
commit a8806230241d201f808d856eaae4d44088117b0c
Date: Thu Dec 7 17:07:01 2017 +0000
Initialize target description early in IPA
I think that passing an index was probably a bad idea.
We used to pass the index, and then use that index to lookup which
target description to instantiate and use, the target description was
not generated until the index arrived.
However, the above commit fixed an issue where we can't call malloc()
within (certain parts of) the IPA (apparently), so instead we now
pre-compute _every_ possible target description within the IPA. The
index is only used to lookup which of the (many) pre-computed target
descriptions to use.
It would (I think) have been easier all around if the IPA just
self-inspected, figured out its own xcr0 value, and used that to
create the one target description that is required. So long as the
xcr0 to target description code is shared (at compile time) with
gdbserver, then we can be sure that the IPA will derive the same
target description as gdbserver, and we would avoid all this index
passing business, which has made this commit so very, very painful.
I did look at how a process might derive its own xcr0 value, but I
don't believe this is actually that simple, so for now I've just
doubled down on the index passing approach.
While reviewing earlier iterations of this patch there has been
discussion about the possibility of removing the IPA from GDB. That
would certainly make all of the code touched in this patch much
simpler, but I don't really want to do that as part of this series.
** END OF AN ASIDE **
Currently then for x86/linux, gdbserver sends a number between 0 and 7
to the IPA, and the IPA uses this to create a target description.
However, I am proposing that gdbserver should now create one of (up
to) 64 different target descriptions for i386, so this 0 to 7 index
isn't going to be good enough any more (amd64 and x32 have slightly
fewer possible target descriptions, but still more than 8, so the
problem is the same).
For a while I wondered if I was going to have to try and find some
backward compatible solution for this mess. But after seeing how
lightly the IPA is actually documented, I wonder if it is not the case
that there is a tight coupling between a version of gdbserver and a
version of the IPA? At least I'm hoping so, and that's what I've
assumed in this commit.
In this commit I have thrown out the old IPA target description index
numbering scheme, and switched to a completely new numbering scheme.
Instead of the index that is passed being arbitrary, the index is
instead calculated from the set of xcr0 features that are present on
the target. Within the IPA we can then reverse this logic to recreate
the xcr0 value based on the index, and from the xcr0 value we can
choose the correct target description.
With the gdbserver to IPA numbering scheme issue resolved I have then
update the gdbserver versions of amd64_linux_read_description and
i386_linux_read_description so that they cache target descriptions
using the same set of xcr0 features as GDB itself.
After this gdbserver should now always come up with the same target
description as GDB does on any x86/Linux target.
This commit does not introduce any new code sharing between GDB and
gdbserver as previous commits in this series have done. Instead this
commit is all about bringing GDB and gdbserver into alignment
functionally so that the next commit(s) can merge the GDB and
gdbserver versions of these functions.
Notes On The Implementation
---------------------------
Previously, within gdbserver, target descriptions were cached within
arrays. These arrays were sized based on enum x86_linux_tdesc and
xcr0_to_tdesc_idx returned the array (cache) index.
Now we need different array lengths for each of i386, amd64, and x32.
And the index to use within each array is calculated based on which
xcr0 bits are set and valid for a particular target type.
I really wanted to avoid having fixed array sizes, or having the set
of relevant xcr0 bits encoded in multiple places.
The solution I came up with was to create a single data structure
which would contain a list of xcr0 bits along with flags to indicate
which of the i386, amd64, and x32 targets the bit is relevant for. By
making the table constexpr, and adding some constexpr helper
functions, it is possible to calculate the sizes for the cache arrays
at compile time, as well as the bit masks needed to each target type.
During review it was pointed out[1] that possibly the failure to check
the SSE and X87 bits for amd64/x32 targets might be an error, however,
if this is the case then this is an issue that existed long before
this patch. I'd really like to keep this patch focused on reworking
the existing code and try to avoid changing how target descriptions
are actually created, mostly out of fear that I'll break something.
[1] https://inbox.sourceware.org/gdb-patches/MN2PR11MB4566070607318EE7E669A5E28E1B2@MN2PR11MB4566.namprd11.prod.outlook.com
Approved-By: John Baldwin <jhb@FreeBSD.org>
Approved-By: Felix Willgerodt <felix.willgerodt@intel.com>
2024-01-31 19:18:34 +08:00
|
|
|
return amd64_linux_read_description (xcr0, is_x32);
|
[PR gdb/13808] gdb.trace: Pass tdesc selected in gdbserver to IPA.
If gdbserver and IPA are using different tdesc, they will disagree
about 'R' trace packet size. This results in mangled traces.
To make sure they pick the same tdesc, gdbserver pokes the tdesc
(specified as an index in a target-specific list) into a global
variable in IPA. In theory, IPA could find out the tdesc on its
own, but that may be complex (in particular, I don't know how to
tell whether we have LAST_BREAK on s390 without messing with ptrace),
and we'd have to duplicate the logic.
Tested on i386 and x86_64. On i386, it fixes two FAILs in ftrace.exp.
On x86_64, these failures have been KFAILed - one of them works now,
but the other now fails due to an unrelated reason (ugh).
gdb/gdbserver/ChangeLog:
PR gdb/13808
* Makefile.in: Add i386-*-linux-ipa.o and amd64-*-linux-ipa.o.
* configure.srv: Ditto.
* linux-aarch64-ipa.c (get_ipa_tdesc): New function.
(initialize_low_tracepoint): Remove ipa_tdesc assignment.
* linux-amd64-ipa.c: Add "linux-x86-tdesc.h" include.
(init_registers_amd64_linux): Remove prototype.
(tdesc_amd64_linux): Remove declaration.
(get_ipa_tdesc): New function.
(initialize_low_tracepoint): Remove ipa_tdesc assignment,
initialize remaining tdescs.
* linux-i386-ipa.c: Add "linux-x86-tdesc.h" include.
(init_registers_i386_linux): Remove prototype.
(tdesc_i386_linux): Remove declaration.
(get_ipa_tdesc): New function.
(initialize_low_tracepoint): Remove ipa_tdesc assignment,
initialize remaining tdescs.
* linux-low.c (linux_get_ipa_tdesc_idx): New function.
(linux_target_ops): wire in linux_get_ipa_tdesc_idx.
* linux-low.h (struct linux_target_ops): Add get_ipa_tdesc_idx.
* linux-x86-low.c: Move tdesc declarations to linux-x86-tdesc.h.
(x86_get_ipa_tdesc_idx): New function.
(the_low_target): Wire in x86_get_ipa_tdesc_idx.
* linux-x86-tdesc.h: New file.
* target.h (struct target_ops): Add get_ipa_tdesc_idx.
(target_get_ipa_tdesc_idx): New macro.
* tracepoint.c (ipa_tdesc_idx): New macro.
(struct ipa_sym_addresses): Add addr_ipa_tdesc_idx.
(symbol_list): Add ipa_tdesc_idx.
(cmd_qtstart): Write ipa_tdesc_idx in the target.
(ipa_tdesc): Remove.
(ipa_tdesc_idx): New variable.
(get_context_regcache): Use get_ipa_tdesc.
(gdb_collect): Ditto.
(gdb_probe): Ditto.
* tracepoint.h (get_ipa_tdesc): New prototype.
(ipa_tdesc): Remove.
gdb/testsuite/ChangeLog:
PR gdb/13808
* gdb.trace/ftrace.exp (test_fast_tracepoints): Remove kfail.
2016-02-22 04:44:48 +08:00
|
|
|
}
|
|
|
|
|
2016-08-19 19:07:45 +08:00
|
|
|
/* Allocate buffer for the jump pads. The branch instruction has a
|
|
|
|
reach of +/- 31-bit, and the executable is loaded at low addresses.
|
|
|
|
|
|
|
|
64-bit: Use MAP_32BIT to allocate in the first 2GB. Shared
|
|
|
|
libraries, being allocated at the top, are unfortunately out of
|
|
|
|
luck.
|
|
|
|
|
|
|
|
x32: Since MAP_32BIT is 64-bit only, do the placement manually.
|
|
|
|
Try allocating at '0x80000000 - SIZE' initially, decreasing until
|
|
|
|
we hit a free area. This ensures the executable is fully covered,
|
|
|
|
and is as close as possible to the shared libraries, which are
|
|
|
|
usually mapped at the top of the first 4GB of the address space.
|
|
|
|
*/
|
2016-03-13 07:30:11 +08:00
|
|
|
|
|
|
|
void *
|
|
|
|
alloc_jump_pad_buffer (size_t size)
|
|
|
|
{
|
2016-08-19 19:07:45 +08:00
|
|
|
#if __ILP32__
|
|
|
|
uintptr_t addr;
|
|
|
|
int pagesize;
|
|
|
|
|
|
|
|
pagesize = sysconf (_SC_PAGE_SIZE);
|
|
|
|
if (pagesize == -1)
|
|
|
|
perror_with_name ("sysconf");
|
|
|
|
|
|
|
|
addr = 0x80000000 - size;
|
|
|
|
|
|
|
|
/* size should already be page-aligned, but this can't hurt. */
|
|
|
|
addr &= ~(pagesize - 1);
|
|
|
|
|
|
|
|
/* Search for a free area. If we hit 0, we're out of luck. */
|
|
|
|
for (; addr; addr -= pagesize)
|
|
|
|
{
|
|
|
|
void *res;
|
|
|
|
|
|
|
|
/* No MAP_FIXED - we don't want to zap someone's mapping. */
|
|
|
|
res = mmap ((void *) addr, size,
|
|
|
|
PROT_READ | PROT_WRITE | PROT_EXEC,
|
|
|
|
MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
|
|
|
|
|
|
|
|
/* If we got what we wanted, return. */
|
|
|
|
if ((uintptr_t) res == addr)
|
|
|
|
return res;
|
|
|
|
|
|
|
|
/* If we got a mapping, but at a wrong address, undo it. */
|
|
|
|
if (res != MAP_FAILED)
|
|
|
|
munmap (res, size);
|
|
|
|
}
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
#else
|
2016-03-13 07:30:11 +08:00
|
|
|
void *res = mmap (NULL, size, PROT_READ | PROT_WRITE | PROT_EXEC,
|
|
|
|
MAP_PRIVATE | MAP_ANONYMOUS | MAP_32BIT, -1, 0);
|
|
|
|
|
|
|
|
if (res == MAP_FAILED)
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
return res;
|
2016-08-19 19:07:45 +08:00
|
|
|
#endif
|
2016-03-13 07:30:11 +08:00
|
|
|
}
|
|
|
|
|
gdb/gdbserver/
2010-06-01 Pedro Alves <pedro@codesourcery.com>
Stan Shebs <stan@codesourcery.com>
* Makefile.in (IPA_DEPFILES, extra_libraries): New.
(all): Depend on $(extra_libraries).
(install-only): Install the IPA.
(IPA_OBJS, IPA_LIB): New.
(clean): Remove the IPA lib.
(IPAGENT_CFLAGS): New.
(tracepoint-ipa.o, utils-ipa.o, remote-utils-ipa.o)
(regcache-ipa.o, i386-linux-ipa.o, linux-i386-ipa.o)
(linux-amd64-ipa.o, amd64-linux-ipa.o): New rules.
* linux-amd64-ipa.c, linux-i386-ipa.c: New files.
* configure.ac: Check for atomic builtins support in the compiler.
(IPA_DEPFILES, extra_libraries): Define.
* configure.srv (ipa_obj): Add description.
(ipa_i386_linux_regobj, ipa_amd64_linux_regobj): Define.
(i[34567]86-*-linux*): Set ipa_obj.
(x86_64-*-linux*): Set ipa_obj.
* linux-low.c (stabilizing_threads): New.
(supports_fast_tracepoints): New.
(linux_detach): Stabilize threads before detaching.
(handle_tracepoints): Handle internal tracing breakpoints. Assert
the lwp is either not stabilizing, or is moving out of a jump pad.
(linux_fast_tracepoint_collecting): New.
(maybe_move_out_of_jump_pad): New.
(enqueue_one_deferred_signal): New.
(dequeue_one_deferred_signal): New.
(linux_wait_for_event_1): If moving out of a jump pad, defer
pending signals to later.
(linux_stabilize_threads): New.
(linux_wait_1): Check if threads need moving out of jump pads, and
do it if so.
(stuck_in_jump_pad_callback): New.
(move_out_of_jump_pad_callback): New.
(lwp_running): New.
(linux_resume_one_lwp): Handle moving out of jump pads.
(linux_set_resume_request): Dequeue deferred signals.
(need_step_over_p): Also step over fast tracepoint jumps.
(start_step_over): Also uninsert fast tracepoint jumps.
(finish_step_over): Also reinsert fast tracepoint jumps.
(linux_install_fast_tracepoint_jump): New.
(linux_target_ops): Install linux_stabilize_threads and
linux_install_fast_tracepoint_jump_pad.
* linux-low.h (linux_target_ops) <get_thread_area,
install_fast_tracepoint_jump_pad>: New fields.
(struct lwp_info) <collecting_fast_tracepoint,
pending_signals_to_report, exit_jump_pad_bkpt>: New fields.
(linux_get_thread_area): Declare.
* linux-x86-low.c (jump_insn): New.
(x86_get_thread_area): New.
(append_insns): New.
(push_opcode): New.
(amd64_install_fast_tracepoint_jump_pad): New.
(i386_install_fast_tracepoint_jump_pad): New.
(x86_install_fast_tracepoint_jump_pad): New.
(the_low_target): Install x86_get_thread_area and
x86_install_fast_tracepoint_jump_pad.
* mem-break.c (set_raw_breakpoint_at): Use read_inferior_memory.
(struct fast_tracepoint_jump): New.
(fast_tracepoint_jump_insn): New.
(fast_tracepoint_jump_shadow): New.
(find_fast_tracepoint_jump_at): New.
(fast_tracepoint_jump_here): New.
(delete_fast_tracepoint_jump): New.
(set_fast_tracepoint_jump): New.
(uninsert_fast_tracepoint_jumps_at): New.
(reinsert_fast_tracepoint_jumps_at): New.
(set_breakpoint_at): Use write_inferior_memory.
(uninsert_raw_breakpoint): Use write_inferior_memory.
(check_mem_read): Mask out fast tracepoint jumps.
(check_mem_write): Mask out fast tracepoint jumps.
* mem-break.h (struct fast_tracepoint_jump): Forward declare.
(set_fast_tracepoint_jump): Declare.
(delete_fast_tracepoint_jump)
(fast_tracepoint_jump_here, uninsert_fast_tracepoint_jumps_at)
(reinsert_fast_tracepoint_jumps_at): Declare.
* regcache.c: Don't compile many functions when building the
in-process agent library.
(init_register_cache) [IN_PROCESS_AGENT]: Don't allow allocating
the register buffer in the heap.
(free_register_cache): If the register buffer isn't owned by the
regcache, don't free it.
(set_register_cache) [IN_PROCESS_AGENT]: Don't re-alocate
pre-existing register caches.
* remote-utils.c (convert_int_to_ascii): Constify `from' parameter
type.
(convert_ascii_to_int): : Constify `from' parameter type.
(decode_M_packet, decode_X_packet): Replace the `to' parameter by
a `to_p' pointer to pointer parameter. If TO_P is NULL, malloc
the needed buffer in-place.
(relocate_instruction): New.
* server.c (handle_query) <qSymbols>: If the target supports
tracepoints, give it a chance of looking up symbols. Report
support for fast tracepoints.
(handle_status): Stabilize threads.
(process_serial_event): Adjust.
* server.h (struct fast_tracepoint_jump): Forward declare.
(struct process_info) <fast_tracepoint_jumps>: New field.
(convert_ascii_to_int, convert_int_to_ascii): Adjust.
(decode_X_packet, decode_M_packet): Adjust.
(relocate_instruction): Declare.
(in_process_agent_loaded): Declare.
(tracepoint_look_up_symbols): Declare.
(struct fast_tpoint_collect_status): Declare.
(fast_tracepoint_collecting): Declare.
(force_unlock_trace_buffer): Declare.
(handle_tracepoint_bkpts): Declare.
(initialize_low_tracepoint)
(supply_fast_tracepoint_registers) [IN_PROCESS_AGENT]: Declare.
* target.h (struct target_ops) <stabilize_threads,
install_fast_tracepoint_jump_pad>: New fields.
(stabilize_threads, install_fast_tracepoint_jump_pad): New.
* tracepoint.c [HAVE_MALLOC_H]: Include malloc.h.
[HAVE_STDINT_H]: Include stdint.h.
(trace_debug_1): Rename to ...
(trace_vdebug): ... this.
(trace_debug): Rename to ...
(trace_debug_1): ... this. Add `level' parameter.
(trace_debug): New.
(ATTR_USED, ATTR_NOINLINE): New.
(IP_AGENT_EXPORT): New.
(gdb_tp_heap_buffer, gdb_jump_pad_buffer, gdb_jump_pad_buffer_end)
(collecting, gdb_collect, stop_tracing, flush_trace_buffer)
(about_to_request_buffer_space, trace_buffer_is_full)
(stopping_tracepoint, expr_eval_result, error_tracepoint)
(tracepoints, tracing, trace_buffer_ctrl, trace_buffer_ctrl_curr)
(trace_buffer_lo, trace_buffer_hi, traceframe_read_count)
(traceframe_write_count, traceframes_created)
(trace_state_variables)
New renaming defines.
(struct ipa_sym_addresses): New.
(STRINGIZE_1, STRINGIZE, IPA_SYM): New.
(symbol_list): New.
(ipa_sym_addrs): New.
(all_tracepoint_symbols_looked_up): New.
(in_process_agent_loaded): New.
(write_e_ipa_not_loaded): New.
(maybe_write_ipa_not_loaded): New.
(tracepoint_look_up_symbols): New.
(debug_threads) [IN_PROCESS_AGENT]: New.
(read_inferior_memory) [IN_PROCESS_AGENT]: New.
(UNKNOWN_SIDE_EFFECTS): New.
(stop_tracing): New.
(flush_trace_buffer): New.
(stop_tracing_bkpt): New.
(flush_trace_buffer_bkpt): New.
(read_inferior_integer): New.
(read_inferior_uinteger): New.
(read_inferior_data_pointer): New.
(write_inferior_data_pointer): New.
(write_inferior_integer): New.
(write_inferior_uinteger): New.
(struct collect_static_trace_data_action): Delete.
(enum tracepoint_type): New.
(struct tracepoint) <type>: New field `type'.
<actions_str, step_actions, step_actions_str>: Only include in GDBserver.
<orig_size, obj_addr_on_target, adjusted_insn_addr>
<adjusted_insn_addr_end, jump_pad, jump_pad_end>: New fields.
(tracepoints): Use IP_AGENT_EXPORT.
(last_tracepoint): Don't include in the IPA.
(stopping_tracepoint): Use IP_AGENT_EXPORT.
(trace_buffer_is_full): Use IP_AGENT_EXPORT.
(alloced_trace_state_variables): New.
(trace_state_variables): Use IP_AGENT_EXPORT.
(traceframe_t): Delete unused variable.
(circular_trace_buffer): Don't include in the IPA.
(trace_buffer_start): Delete.
(struct trace_buffer_control): New.
(trace_buffer_free): Delete.
(struct ipa_trace_buffer_control): New.
(GDBSERVER_FLUSH_COUNT_MASK, GDBSERVER_FLUSH_COUNT_MASK_PREV)
(GDBSERVER_FLUSH_COUNT_MASK_CURR, GDBSERVER_UPDATED_FLUSH_COUNT_BIT):
New.
(trace_buffer_ctrl): New.
(TRACE_BUFFER_CTRL_CURR): New.
(trace_buffer_start, trace_buffer_free, trace_buffer_end_free):
Reimplement as macros.
(trace_buffer_wrap): Delete.
(traceframe_write_count, traceframe_read_count)
(traceframes_created, tracing): Use IP_AGENT_EXPORT.
(struct tracepoint_hit_ctx) <type>: New field.
(struct fast_tracepoint_ctx): New.
(memory_barrier): New.
(cmpxchg): New.
(record_tracepoint_error): Update atomically in the IPA.
(clear_inferior_trace_buffer): New.
(about_to_request_buffer_space): New.
(trace_buffer_alloc): Handle GDBserver and inferior simulatenous
updating the same buffer.
(add_tracepoint): Default the tracepoint's type to trap
tracepoint, and orig_size to -1.
(get_trace_state_variable) [IN_PROCESS_AGENT]: Handle allocated
internal variables.
(create_trace_state_variable): New parameter `gdb'. Handle it.
(clear_installed_tracepoints): Clear fast tracepoint jumps.
(cmd_qtdp): Handle fast tracepoints.
(cmd_qtdv): Adjust.
(max_jump_pad_size): New.
(gdb_jump_pad_head): New.
(get_jump_space_head): New.
(claim_jump_space): New.
(sort_tracepoints): New.
(MAX_JUMP_SIZE): New.
(cmd_qtstart): Handle fast tracepoints. Sync tracepoints with the
IPA.
(stop_tracing) [IN_PROCESS_AGENT]: Don't include the tdisconnected
support. Upload fast traceframes, and delete internal IPA
breakpoints.
(stop_tracing_handler): New.
(flush_trace_buffer_handler): New.
(cmd_qtstop): Upload fast tracepoints.
(response_tracepoint): Handle fast tracepoints.
(tracepoint_finished_step): Upload fast traceframes. Set the
tracepoint hit context's tracepoint type.
(handle_tracepoint_bkpts): New.
(tracepoint_was_hit): Set the tracepoint hit context's tracepoint
type. Add comment about fast tracepoints.
(collect_data_at_tracepoint) [IN_PROCESS_AGENT]: Don't access the
non-existing action_str field.
(get_context_regcache): Handle fast tracepoints.
(do_action_at_tracepoint) [!IN_PROCESS_AGENT]: Don't write the PC
to the regcache.
(fast_tracepoint_from_jump_pad_address): New.
(fast_tracepoint_from_ipa_tpoint_address): New.
(collecting_t): New.
(force_unlock_trace_buffer): New.
(fast_tracepoint_collecting): New.
(collecting): New.
(gdb_collect): New.
(write_inferior_data_ptr): New.
(target_tp_heap): New.
(target_malloc): New.
(download_agent_expr): New.
(UALIGN): New.
(download_tracepoints): New.
(download_trace_state_variables): New.
(upload_fast_traceframes): New.
(IPA_FIRST_TRACEFRAME): New.
(IPA_NEXT_TRACEFRAME_1): New.
(IPA_NEXT_TRACEFRAME): New.
[IN_PROCESS_AGENT]: Include sys/mman.h and fcntl.h.
[IN_PROCESS_AGENT] (gdb_tp_heap_buffer, gdb_jump_pad_buffer)
(gdb_jump_pad_buffer_end): New.
[IN_PROCESS_AGENT] (initialize_tracepoint_ftlib): New.
(initialize_tracepoint): Adjust.
[IN_PROCESS_AGENT]: Allocate the IPA heap, and jump pad scratch
buffer. Initialize the low module.
* utils.c (PREFIX, TOOLNAME): New.
(malloc_failure): Use PREFIX.
(error): In the IPA, an error causes an exit.
(fatal, warning): Use PREFIX.
(internal_error): Use TOOLNAME.
(NUMCELLS): Increase to 10.
* configure, config.in: Regenerate.
gdb/
2010-06-01 Pedro Alves <pedro@codesourcery.com>
* NEWS: Mention gdbserver fast tracepoints support.
gdb/doc/
2010-06-01 Pedro Alves <pedro@codesourcery.com>
* gdb.texinfo (Set Tracepoints): Mention tracepoints support in
gdbserver, and add cross reference.
(Tracepoints support in gdbserver): New subsection.
2010-06-01 21:20:52 +08:00
|
|
|
void
|
|
|
|
initialize_low_tracepoint (void)
|
|
|
|
{
|
Initialize target description early in IPA
Target descriptions are allocated lazily, that is fine in GDBserver,
but it is not safe to call malloc in gdb_collect in IPA, because we
can set a fast tracepoint in malloc, and when the tracepoint is hit,
gdb_collect/malloc is called, deadlock or memory corruption may be
triggered.
#0 0xf7cfc200 in malloc ()
#1 0xf7efdc07 in operator new(unsigned int) ()
#2 0xf7ef7636 in allocate_target_description() ()
#3 0xf7efcbe1 in i386_create_target_description(unsigned long long, bool) ()
#4 0xf7efb474 in i386_linux_read_description(unsigned long long) ()
#5 0xf7efb190 in get_ipa_tdesc(int) ()
#6 0xf7ef9baa in gdb_collect ()
The fix is to initialize all target descriptions earlier, when the
IPA is loaded. In order to guarantee malloc is not called in IPA
in gdb_collect, I change the test to set a breakpoint on malloc, if
IPA gdb_collect calls malloc, program will hit the breakpoint, and
test fail.
continue
Continuing.
Thread 1 "" hit Breakpoint 5, 0xf7cfc200 in malloc ()
(gdb) FAIL: gdb.trace/ftrace.exp: advance through tracing
gdb/gdbserver:
2017-12-07 Yao Qi <yao.qi@linaro.org>
* linux-aarch64-ipa.c (initialize_low_tracepoint): Call
aarch64_linux_read_description.
* linux-amd64-ipa.c (idx2mask): New array.
(get_ipa_tdesc): Move idx2mask out.
(initialize_low_tracepoint): Initialize target descriptions.
* linux-i386-ipa.c (idx2mask): New array.
(get_ipa_tdesc): Move idx2mask out.
(initialize_low_tracepoint): Initialize target descriptions.
gdb/testsuite:
2017-12-07 Yao Qi <yao.qi@linaro.org>
* gdb.trace/ftrace.exp (run_trace_experiment): Set breakpoint on
malloc and catch syscall.
2017-12-08 01:07:01 +08:00
|
|
|
#if defined __ILP32__
|
gdbserver: update target description creation for x86/linux
This commit is part of a series which aims to share more of the target
description creation between GDB and gdbserver for x86/Linux.
After some refactoring earlier in this series the shared
x86_linux_tdesc_for_tid function was added into nat/x86-linux-tdesc.c.
However, this function still relies on amd64_linux_read_description
and i386_linux_read_description which are implemented separately for
both gdbserver and GDB. Given that at their core, all these functions
do is:
1. take an xcr0 value as input,
2. mask out some feature bits,
3. look for a cached pre-generated target description and return it
if found,
4. if no cached target description is found then call either
amd64_create_target_description or
i386_create_target_description to create a new target
description, which is then added to the cache. Return the newly
created target description.
The inner functions amd64_create_target_description and
i386_create_target_description are already shared between GDB and
gdbserver (in the gdb/arch/ directory), so the only thing that
the *_read_description functions really do is add the caching layer,
and it feels like this really could be shared.
However, we have a small problem.
Despite using the same {amd64,i386}_create_target_description
functions in both GDB and gdbserver to create the target descriptions,
on the gdbserver side we cache target descriptions based on a reduced
set of xcr0 feature bits.
What this means is that, in theory, different xcr0 values can map to
the same cache entry, which could result in the wrong target
description being used.
However, I'm not sure if this can actually happen in reality. Within
gdbserver we already split the target description cache based on i386,
amd64, and x32. I suspect within a given gdbserver session we'll only
see at most one target description for each of these.
The cache conflicting problem is caused by xcr0_to_tdesc_idx, which
maps an xcr0 value to a enum x86_linux_tdesc value, and there are only
7 usable values in enum x86_linux_tdesc.
In contrast, on the GDB side there are 64, 32, and 16 cache slots for
i386, amd64, and x32 respectively.
On the GDB side it is much more important to cache things correctly as
a single GDB session might connect to multiple different remote
targets, each of which might have slightly different x86
architectures.
And so, if we want to merge the target description caching between GDB
and gdbserver, then we need to first update gdbserver so that it
caches in the same way as GDB, that is, it needs to adopt a mechanism
that allows for the same number of cache slots of each of i386, amd64,
and x32. In this way, when the caching is shared, GDB's behaviour
will not change.
Unfortunately it's a little more complex than that due to the in
process agent (IPA).
When the IPA is in use, gdbserver sends a target description index to
the IPA, and the IPA uses this to find the correct target description
to use, the IPA having first generated every possible target
description.
Interestingly, there is certainly a bug here which results from only
having 7 values in enum x86_linux_tdesc. As multiple possible target
descriptions in gdbserver map to the same enum x86_linux_tdesc value,
then, when the enum x86_linux_tdesc value is sent to the IPA there is
no way for gdbserver to know that the IPA will select the correct
target description. This bug will get fixed by this commit.
** START OF AN ASIDE **
Back in the day I suspect this approach of sending a target
description index made perfect sense. However since this commit:
commit a8806230241d201f808d856eaae4d44088117b0c
Date: Thu Dec 7 17:07:01 2017 +0000
Initialize target description early in IPA
I think that passing an index was probably a bad idea.
We used to pass the index, and then use that index to lookup which
target description to instantiate and use, the target description was
not generated until the index arrived.
However, the above commit fixed an issue where we can't call malloc()
within (certain parts of) the IPA (apparently), so instead we now
pre-compute _every_ possible target description within the IPA. The
index is only used to lookup which of the (many) pre-computed target
descriptions to use.
It would (I think) have been easier all around if the IPA just
self-inspected, figured out its own xcr0 value, and used that to
create the one target description that is required. So long as the
xcr0 to target description code is shared (at compile time) with
gdbserver, then we can be sure that the IPA will derive the same
target description as gdbserver, and we would avoid all this index
passing business, which has made this commit so very, very painful.
I did look at how a process might derive its own xcr0 value, but I
don't believe this is actually that simple, so for now I've just
doubled down on the index passing approach.
While reviewing earlier iterations of this patch there has been
discussion about the possibility of removing the IPA from GDB. That
would certainly make all of the code touched in this patch much
simpler, but I don't really want to do that as part of this series.
** END OF AN ASIDE **
Currently then for x86/linux, gdbserver sends a number between 0 and 7
to the IPA, and the IPA uses this to create a target description.
However, I am proposing that gdbserver should now create one of (up
to) 64 different target descriptions for i386, so this 0 to 7 index
isn't going to be good enough any more (amd64 and x32 have slightly
fewer possible target descriptions, but still more than 8, so the
problem is the same).
For a while I wondered if I was going to have to try and find some
backward compatible solution for this mess. But after seeing how
lightly the IPA is actually documented, I wonder if it is not the case
that there is a tight coupling between a version of gdbserver and a
version of the IPA? At least I'm hoping so, and that's what I've
assumed in this commit.
In this commit I have thrown out the old IPA target description index
numbering scheme, and switched to a completely new numbering scheme.
Instead of the index that is passed being arbitrary, the index is
instead calculated from the set of xcr0 features that are present on
the target. Within the IPA we can then reverse this logic to recreate
the xcr0 value based on the index, and from the xcr0 value we can
choose the correct target description.
With the gdbserver to IPA numbering scheme issue resolved I have then
update the gdbserver versions of amd64_linux_read_description and
i386_linux_read_description so that they cache target descriptions
using the same set of xcr0 features as GDB itself.
After this gdbserver should now always come up with the same target
description as GDB does on any x86/Linux target.
This commit does not introduce any new code sharing between GDB and
gdbserver as previous commits in this series have done. Instead this
commit is all about bringing GDB and gdbserver into alignment
functionally so that the next commit(s) can merge the GDB and
gdbserver versions of these functions.
Notes On The Implementation
---------------------------
Previously, within gdbserver, target descriptions were cached within
arrays. These arrays were sized based on enum x86_linux_tdesc and
xcr0_to_tdesc_idx returned the array (cache) index.
Now we need different array lengths for each of i386, amd64, and x32.
And the index to use within each array is calculated based on which
xcr0 bits are set and valid for a particular target type.
I really wanted to avoid having fixed array sizes, or having the set
of relevant xcr0 bits encoded in multiple places.
The solution I came up with was to create a single data structure
which would contain a list of xcr0 bits along with flags to indicate
which of the i386, amd64, and x32 targets the bit is relevant for. By
making the table constexpr, and adding some constexpr helper
functions, it is possible to calculate the sizes for the cache arrays
at compile time, as well as the bit masks needed to each target type.
During review it was pointed out[1] that possibly the failure to check
the SSE and X87 bits for amd64/x32 targets might be an error, however,
if this is the case then this is an issue that existed long before
this patch. I'd really like to keep this patch focused on reworking
the existing code and try to avoid changing how target descriptions
are actually created, mostly out of fear that I'll break something.
[1] https://inbox.sourceware.org/gdb-patches/MN2PR11MB4566070607318EE7E669A5E28E1B2@MN2PR11MB4566.namprd11.prod.outlook.com
Approved-By: John Baldwin <jhb@FreeBSD.org>
Approved-By: Felix Willgerodt <felix.willgerodt@intel.com>
2024-01-31 19:18:34 +08:00
|
|
|
for (int i = 0; i < x86_linux_x32_tdesc_count (); i++)
|
|
|
|
amd64_linux_read_description (x86_linux_tdesc_idx_to_xcr0 (i), true);
|
Initialize target description early in IPA
Target descriptions are allocated lazily, that is fine in GDBserver,
but it is not safe to call malloc in gdb_collect in IPA, because we
can set a fast tracepoint in malloc, and when the tracepoint is hit,
gdb_collect/malloc is called, deadlock or memory corruption may be
triggered.
#0 0xf7cfc200 in malloc ()
#1 0xf7efdc07 in operator new(unsigned int) ()
#2 0xf7ef7636 in allocate_target_description() ()
#3 0xf7efcbe1 in i386_create_target_description(unsigned long long, bool) ()
#4 0xf7efb474 in i386_linux_read_description(unsigned long long) ()
#5 0xf7efb190 in get_ipa_tdesc(int) ()
#6 0xf7ef9baa in gdb_collect ()
The fix is to initialize all target descriptions earlier, when the
IPA is loaded. In order to guarantee malloc is not called in IPA
in gdb_collect, I change the test to set a breakpoint on malloc, if
IPA gdb_collect calls malloc, program will hit the breakpoint, and
test fail.
continue
Continuing.
Thread 1 "" hit Breakpoint 5, 0xf7cfc200 in malloc ()
(gdb) FAIL: gdb.trace/ftrace.exp: advance through tracing
gdb/gdbserver:
2017-12-07 Yao Qi <yao.qi@linaro.org>
* linux-aarch64-ipa.c (initialize_low_tracepoint): Call
aarch64_linux_read_description.
* linux-amd64-ipa.c (idx2mask): New array.
(get_ipa_tdesc): Move idx2mask out.
(initialize_low_tracepoint): Initialize target descriptions.
* linux-i386-ipa.c (idx2mask): New array.
(get_ipa_tdesc): Move idx2mask out.
(initialize_low_tracepoint): Initialize target descriptions.
gdb/testsuite:
2017-12-07 Yao Qi <yao.qi@linaro.org>
* gdb.trace/ftrace.exp (run_trace_experiment): Set breakpoint on
malloc and catch syscall.
2017-12-08 01:07:01 +08:00
|
|
|
#else
|
gdbserver: update target description creation for x86/linux
This commit is part of a series which aims to share more of the target
description creation between GDB and gdbserver for x86/Linux.
After some refactoring earlier in this series the shared
x86_linux_tdesc_for_tid function was added into nat/x86-linux-tdesc.c.
However, this function still relies on amd64_linux_read_description
and i386_linux_read_description which are implemented separately for
both gdbserver and GDB. Given that at their core, all these functions
do is:
1. take an xcr0 value as input,
2. mask out some feature bits,
3. look for a cached pre-generated target description and return it
if found,
4. if no cached target description is found then call either
amd64_create_target_description or
i386_create_target_description to create a new target
description, which is then added to the cache. Return the newly
created target description.
The inner functions amd64_create_target_description and
i386_create_target_description are already shared between GDB and
gdbserver (in the gdb/arch/ directory), so the only thing that
the *_read_description functions really do is add the caching layer,
and it feels like this really could be shared.
However, we have a small problem.
Despite using the same {amd64,i386}_create_target_description
functions in both GDB and gdbserver to create the target descriptions,
on the gdbserver side we cache target descriptions based on a reduced
set of xcr0 feature bits.
What this means is that, in theory, different xcr0 values can map to
the same cache entry, which could result in the wrong target
description being used.
However, I'm not sure if this can actually happen in reality. Within
gdbserver we already split the target description cache based on i386,
amd64, and x32. I suspect within a given gdbserver session we'll only
see at most one target description for each of these.
The cache conflicting problem is caused by xcr0_to_tdesc_idx, which
maps an xcr0 value to a enum x86_linux_tdesc value, and there are only
7 usable values in enum x86_linux_tdesc.
In contrast, on the GDB side there are 64, 32, and 16 cache slots for
i386, amd64, and x32 respectively.
On the GDB side it is much more important to cache things correctly as
a single GDB session might connect to multiple different remote
targets, each of which might have slightly different x86
architectures.
And so, if we want to merge the target description caching between GDB
and gdbserver, then we need to first update gdbserver so that it
caches in the same way as GDB, that is, it needs to adopt a mechanism
that allows for the same number of cache slots of each of i386, amd64,
and x32. In this way, when the caching is shared, GDB's behaviour
will not change.
Unfortunately it's a little more complex than that due to the in
process agent (IPA).
When the IPA is in use, gdbserver sends a target description index to
the IPA, and the IPA uses this to find the correct target description
to use, the IPA having first generated every possible target
description.
Interestingly, there is certainly a bug here which results from only
having 7 values in enum x86_linux_tdesc. As multiple possible target
descriptions in gdbserver map to the same enum x86_linux_tdesc value,
then, when the enum x86_linux_tdesc value is sent to the IPA there is
no way for gdbserver to know that the IPA will select the correct
target description. This bug will get fixed by this commit.
** START OF AN ASIDE **
Back in the day I suspect this approach of sending a target
description index made perfect sense. However since this commit:
commit a8806230241d201f808d856eaae4d44088117b0c
Date: Thu Dec 7 17:07:01 2017 +0000
Initialize target description early in IPA
I think that passing an index was probably a bad idea.
We used to pass the index, and then use that index to lookup which
target description to instantiate and use, the target description was
not generated until the index arrived.
However, the above commit fixed an issue where we can't call malloc()
within (certain parts of) the IPA (apparently), so instead we now
pre-compute _every_ possible target description within the IPA. The
index is only used to lookup which of the (many) pre-computed target
descriptions to use.
It would (I think) have been easier all around if the IPA just
self-inspected, figured out its own xcr0 value, and used that to
create the one target description that is required. So long as the
xcr0 to target description code is shared (at compile time) with
gdbserver, then we can be sure that the IPA will derive the same
target description as gdbserver, and we would avoid all this index
passing business, which has made this commit so very, very painful.
I did look at how a process might derive its own xcr0 value, but I
don't believe this is actually that simple, so for now I've just
doubled down on the index passing approach.
While reviewing earlier iterations of this patch there has been
discussion about the possibility of removing the IPA from GDB. That
would certainly make all of the code touched in this patch much
simpler, but I don't really want to do that as part of this series.
** END OF AN ASIDE **
Currently then for x86/linux, gdbserver sends a number between 0 and 7
to the IPA, and the IPA uses this to create a target description.
However, I am proposing that gdbserver should now create one of (up
to) 64 different target descriptions for i386, so this 0 to 7 index
isn't going to be good enough any more (amd64 and x32 have slightly
fewer possible target descriptions, but still more than 8, so the
problem is the same).
For a while I wondered if I was going to have to try and find some
backward compatible solution for this mess. But after seeing how
lightly the IPA is actually documented, I wonder if it is not the case
that there is a tight coupling between a version of gdbserver and a
version of the IPA? At least I'm hoping so, and that's what I've
assumed in this commit.
In this commit I have thrown out the old IPA target description index
numbering scheme, and switched to a completely new numbering scheme.
Instead of the index that is passed being arbitrary, the index is
instead calculated from the set of xcr0 features that are present on
the target. Within the IPA we can then reverse this logic to recreate
the xcr0 value based on the index, and from the xcr0 value we can
choose the correct target description.
With the gdbserver to IPA numbering scheme issue resolved I have then
update the gdbserver versions of amd64_linux_read_description and
i386_linux_read_description so that they cache target descriptions
using the same set of xcr0 features as GDB itself.
After this gdbserver should now always come up with the same target
description as GDB does on any x86/Linux target.
This commit does not introduce any new code sharing between GDB and
gdbserver as previous commits in this series have done. Instead this
commit is all about bringing GDB and gdbserver into alignment
functionally so that the next commit(s) can merge the GDB and
gdbserver versions of these functions.
Notes On The Implementation
---------------------------
Previously, within gdbserver, target descriptions were cached within
arrays. These arrays were sized based on enum x86_linux_tdesc and
xcr0_to_tdesc_idx returned the array (cache) index.
Now we need different array lengths for each of i386, amd64, and x32.
And the index to use within each array is calculated based on which
xcr0 bits are set and valid for a particular target type.
I really wanted to avoid having fixed array sizes, or having the set
of relevant xcr0 bits encoded in multiple places.
The solution I came up with was to create a single data structure
which would contain a list of xcr0 bits along with flags to indicate
which of the i386, amd64, and x32 targets the bit is relevant for. By
making the table constexpr, and adding some constexpr helper
functions, it is possible to calculate the sizes for the cache arrays
at compile time, as well as the bit masks needed to each target type.
During review it was pointed out[1] that possibly the failure to check
the SSE and X87 bits for amd64/x32 targets might be an error, however,
if this is the case then this is an issue that existed long before
this patch. I'd really like to keep this patch focused on reworking
the existing code and try to avoid changing how target descriptions
are actually created, mostly out of fear that I'll break something.
[1] https://inbox.sourceware.org/gdb-patches/MN2PR11MB4566070607318EE7E669A5E28E1B2@MN2PR11MB4566.namprd11.prod.outlook.com
Approved-By: John Baldwin <jhb@FreeBSD.org>
Approved-By: Felix Willgerodt <felix.willgerodt@intel.com>
2024-01-31 19:18:34 +08:00
|
|
|
for (int i = 0; i < x86_linux_amd64_tdesc_count (); i++)
|
|
|
|
amd64_linux_read_description (x86_linux_tdesc_idx_to_xcr0 (i), false);
|
Initialize target description early in IPA
Target descriptions are allocated lazily, that is fine in GDBserver,
but it is not safe to call malloc in gdb_collect in IPA, because we
can set a fast tracepoint in malloc, and when the tracepoint is hit,
gdb_collect/malloc is called, deadlock or memory corruption may be
triggered.
#0 0xf7cfc200 in malloc ()
#1 0xf7efdc07 in operator new(unsigned int) ()
#2 0xf7ef7636 in allocate_target_description() ()
#3 0xf7efcbe1 in i386_create_target_description(unsigned long long, bool) ()
#4 0xf7efb474 in i386_linux_read_description(unsigned long long) ()
#5 0xf7efb190 in get_ipa_tdesc(int) ()
#6 0xf7ef9baa in gdb_collect ()
The fix is to initialize all target descriptions earlier, when the
IPA is loaded. In order to guarantee malloc is not called in IPA
in gdb_collect, I change the test to set a breakpoint on malloc, if
IPA gdb_collect calls malloc, program will hit the breakpoint, and
test fail.
continue
Continuing.
Thread 1 "" hit Breakpoint 5, 0xf7cfc200 in malloc ()
(gdb) FAIL: gdb.trace/ftrace.exp: advance through tracing
gdb/gdbserver:
2017-12-07 Yao Qi <yao.qi@linaro.org>
* linux-aarch64-ipa.c (initialize_low_tracepoint): Call
aarch64_linux_read_description.
* linux-amd64-ipa.c (idx2mask): New array.
(get_ipa_tdesc): Move idx2mask out.
(initialize_low_tracepoint): Initialize target descriptions.
* linux-i386-ipa.c (idx2mask): New array.
(get_ipa_tdesc): Move idx2mask out.
(initialize_low_tracepoint): Initialize target descriptions.
gdb/testsuite:
2017-12-07 Yao Qi <yao.qi@linaro.org>
* gdb.trace/ftrace.exp (run_trace_experiment): Set breakpoint on
malloc and catch syscall.
2017-12-08 01:07:01 +08:00
|
|
|
#endif
|
gdb/gdbserver/
2010-06-01 Pedro Alves <pedro@codesourcery.com>
Stan Shebs <stan@codesourcery.com>
* Makefile.in (IPA_DEPFILES, extra_libraries): New.
(all): Depend on $(extra_libraries).
(install-only): Install the IPA.
(IPA_OBJS, IPA_LIB): New.
(clean): Remove the IPA lib.
(IPAGENT_CFLAGS): New.
(tracepoint-ipa.o, utils-ipa.o, remote-utils-ipa.o)
(regcache-ipa.o, i386-linux-ipa.o, linux-i386-ipa.o)
(linux-amd64-ipa.o, amd64-linux-ipa.o): New rules.
* linux-amd64-ipa.c, linux-i386-ipa.c: New files.
* configure.ac: Check for atomic builtins support in the compiler.
(IPA_DEPFILES, extra_libraries): Define.
* configure.srv (ipa_obj): Add description.
(ipa_i386_linux_regobj, ipa_amd64_linux_regobj): Define.
(i[34567]86-*-linux*): Set ipa_obj.
(x86_64-*-linux*): Set ipa_obj.
* linux-low.c (stabilizing_threads): New.
(supports_fast_tracepoints): New.
(linux_detach): Stabilize threads before detaching.
(handle_tracepoints): Handle internal tracing breakpoints. Assert
the lwp is either not stabilizing, or is moving out of a jump pad.
(linux_fast_tracepoint_collecting): New.
(maybe_move_out_of_jump_pad): New.
(enqueue_one_deferred_signal): New.
(dequeue_one_deferred_signal): New.
(linux_wait_for_event_1): If moving out of a jump pad, defer
pending signals to later.
(linux_stabilize_threads): New.
(linux_wait_1): Check if threads need moving out of jump pads, and
do it if so.
(stuck_in_jump_pad_callback): New.
(move_out_of_jump_pad_callback): New.
(lwp_running): New.
(linux_resume_one_lwp): Handle moving out of jump pads.
(linux_set_resume_request): Dequeue deferred signals.
(need_step_over_p): Also step over fast tracepoint jumps.
(start_step_over): Also uninsert fast tracepoint jumps.
(finish_step_over): Also reinsert fast tracepoint jumps.
(linux_install_fast_tracepoint_jump): New.
(linux_target_ops): Install linux_stabilize_threads and
linux_install_fast_tracepoint_jump_pad.
* linux-low.h (linux_target_ops) <get_thread_area,
install_fast_tracepoint_jump_pad>: New fields.
(struct lwp_info) <collecting_fast_tracepoint,
pending_signals_to_report, exit_jump_pad_bkpt>: New fields.
(linux_get_thread_area): Declare.
* linux-x86-low.c (jump_insn): New.
(x86_get_thread_area): New.
(append_insns): New.
(push_opcode): New.
(amd64_install_fast_tracepoint_jump_pad): New.
(i386_install_fast_tracepoint_jump_pad): New.
(x86_install_fast_tracepoint_jump_pad): New.
(the_low_target): Install x86_get_thread_area and
x86_install_fast_tracepoint_jump_pad.
* mem-break.c (set_raw_breakpoint_at): Use read_inferior_memory.
(struct fast_tracepoint_jump): New.
(fast_tracepoint_jump_insn): New.
(fast_tracepoint_jump_shadow): New.
(find_fast_tracepoint_jump_at): New.
(fast_tracepoint_jump_here): New.
(delete_fast_tracepoint_jump): New.
(set_fast_tracepoint_jump): New.
(uninsert_fast_tracepoint_jumps_at): New.
(reinsert_fast_tracepoint_jumps_at): New.
(set_breakpoint_at): Use write_inferior_memory.
(uninsert_raw_breakpoint): Use write_inferior_memory.
(check_mem_read): Mask out fast tracepoint jumps.
(check_mem_write): Mask out fast tracepoint jumps.
* mem-break.h (struct fast_tracepoint_jump): Forward declare.
(set_fast_tracepoint_jump): Declare.
(delete_fast_tracepoint_jump)
(fast_tracepoint_jump_here, uninsert_fast_tracepoint_jumps_at)
(reinsert_fast_tracepoint_jumps_at): Declare.
* regcache.c: Don't compile many functions when building the
in-process agent library.
(init_register_cache) [IN_PROCESS_AGENT]: Don't allow allocating
the register buffer in the heap.
(free_register_cache): If the register buffer isn't owned by the
regcache, don't free it.
(set_register_cache) [IN_PROCESS_AGENT]: Don't re-alocate
pre-existing register caches.
* remote-utils.c (convert_int_to_ascii): Constify `from' parameter
type.
(convert_ascii_to_int): : Constify `from' parameter type.
(decode_M_packet, decode_X_packet): Replace the `to' parameter by
a `to_p' pointer to pointer parameter. If TO_P is NULL, malloc
the needed buffer in-place.
(relocate_instruction): New.
* server.c (handle_query) <qSymbols>: If the target supports
tracepoints, give it a chance of looking up symbols. Report
support for fast tracepoints.
(handle_status): Stabilize threads.
(process_serial_event): Adjust.
* server.h (struct fast_tracepoint_jump): Forward declare.
(struct process_info) <fast_tracepoint_jumps>: New field.
(convert_ascii_to_int, convert_int_to_ascii): Adjust.
(decode_X_packet, decode_M_packet): Adjust.
(relocate_instruction): Declare.
(in_process_agent_loaded): Declare.
(tracepoint_look_up_symbols): Declare.
(struct fast_tpoint_collect_status): Declare.
(fast_tracepoint_collecting): Declare.
(force_unlock_trace_buffer): Declare.
(handle_tracepoint_bkpts): Declare.
(initialize_low_tracepoint)
(supply_fast_tracepoint_registers) [IN_PROCESS_AGENT]: Declare.
* target.h (struct target_ops) <stabilize_threads,
install_fast_tracepoint_jump_pad>: New fields.
(stabilize_threads, install_fast_tracepoint_jump_pad): New.
* tracepoint.c [HAVE_MALLOC_H]: Include malloc.h.
[HAVE_STDINT_H]: Include stdint.h.
(trace_debug_1): Rename to ...
(trace_vdebug): ... this.
(trace_debug): Rename to ...
(trace_debug_1): ... this. Add `level' parameter.
(trace_debug): New.
(ATTR_USED, ATTR_NOINLINE): New.
(IP_AGENT_EXPORT): New.
(gdb_tp_heap_buffer, gdb_jump_pad_buffer, gdb_jump_pad_buffer_end)
(collecting, gdb_collect, stop_tracing, flush_trace_buffer)
(about_to_request_buffer_space, trace_buffer_is_full)
(stopping_tracepoint, expr_eval_result, error_tracepoint)
(tracepoints, tracing, trace_buffer_ctrl, trace_buffer_ctrl_curr)
(trace_buffer_lo, trace_buffer_hi, traceframe_read_count)
(traceframe_write_count, traceframes_created)
(trace_state_variables)
New renaming defines.
(struct ipa_sym_addresses): New.
(STRINGIZE_1, STRINGIZE, IPA_SYM): New.
(symbol_list): New.
(ipa_sym_addrs): New.
(all_tracepoint_symbols_looked_up): New.
(in_process_agent_loaded): New.
(write_e_ipa_not_loaded): New.
(maybe_write_ipa_not_loaded): New.
(tracepoint_look_up_symbols): New.
(debug_threads) [IN_PROCESS_AGENT]: New.
(read_inferior_memory) [IN_PROCESS_AGENT]: New.
(UNKNOWN_SIDE_EFFECTS): New.
(stop_tracing): New.
(flush_trace_buffer): New.
(stop_tracing_bkpt): New.
(flush_trace_buffer_bkpt): New.
(read_inferior_integer): New.
(read_inferior_uinteger): New.
(read_inferior_data_pointer): New.
(write_inferior_data_pointer): New.
(write_inferior_integer): New.
(write_inferior_uinteger): New.
(struct collect_static_trace_data_action): Delete.
(enum tracepoint_type): New.
(struct tracepoint) <type>: New field `type'.
<actions_str, step_actions, step_actions_str>: Only include in GDBserver.
<orig_size, obj_addr_on_target, adjusted_insn_addr>
<adjusted_insn_addr_end, jump_pad, jump_pad_end>: New fields.
(tracepoints): Use IP_AGENT_EXPORT.
(last_tracepoint): Don't include in the IPA.
(stopping_tracepoint): Use IP_AGENT_EXPORT.
(trace_buffer_is_full): Use IP_AGENT_EXPORT.
(alloced_trace_state_variables): New.
(trace_state_variables): Use IP_AGENT_EXPORT.
(traceframe_t): Delete unused variable.
(circular_trace_buffer): Don't include in the IPA.
(trace_buffer_start): Delete.
(struct trace_buffer_control): New.
(trace_buffer_free): Delete.
(struct ipa_trace_buffer_control): New.
(GDBSERVER_FLUSH_COUNT_MASK, GDBSERVER_FLUSH_COUNT_MASK_PREV)
(GDBSERVER_FLUSH_COUNT_MASK_CURR, GDBSERVER_UPDATED_FLUSH_COUNT_BIT):
New.
(trace_buffer_ctrl): New.
(TRACE_BUFFER_CTRL_CURR): New.
(trace_buffer_start, trace_buffer_free, trace_buffer_end_free):
Reimplement as macros.
(trace_buffer_wrap): Delete.
(traceframe_write_count, traceframe_read_count)
(traceframes_created, tracing): Use IP_AGENT_EXPORT.
(struct tracepoint_hit_ctx) <type>: New field.
(struct fast_tracepoint_ctx): New.
(memory_barrier): New.
(cmpxchg): New.
(record_tracepoint_error): Update atomically in the IPA.
(clear_inferior_trace_buffer): New.
(about_to_request_buffer_space): New.
(trace_buffer_alloc): Handle GDBserver and inferior simulatenous
updating the same buffer.
(add_tracepoint): Default the tracepoint's type to trap
tracepoint, and orig_size to -1.
(get_trace_state_variable) [IN_PROCESS_AGENT]: Handle allocated
internal variables.
(create_trace_state_variable): New parameter `gdb'. Handle it.
(clear_installed_tracepoints): Clear fast tracepoint jumps.
(cmd_qtdp): Handle fast tracepoints.
(cmd_qtdv): Adjust.
(max_jump_pad_size): New.
(gdb_jump_pad_head): New.
(get_jump_space_head): New.
(claim_jump_space): New.
(sort_tracepoints): New.
(MAX_JUMP_SIZE): New.
(cmd_qtstart): Handle fast tracepoints. Sync tracepoints with the
IPA.
(stop_tracing) [IN_PROCESS_AGENT]: Don't include the tdisconnected
support. Upload fast traceframes, and delete internal IPA
breakpoints.
(stop_tracing_handler): New.
(flush_trace_buffer_handler): New.
(cmd_qtstop): Upload fast tracepoints.
(response_tracepoint): Handle fast tracepoints.
(tracepoint_finished_step): Upload fast traceframes. Set the
tracepoint hit context's tracepoint type.
(handle_tracepoint_bkpts): New.
(tracepoint_was_hit): Set the tracepoint hit context's tracepoint
type. Add comment about fast tracepoints.
(collect_data_at_tracepoint) [IN_PROCESS_AGENT]: Don't access the
non-existing action_str field.
(get_context_regcache): Handle fast tracepoints.
(do_action_at_tracepoint) [!IN_PROCESS_AGENT]: Don't write the PC
to the regcache.
(fast_tracepoint_from_jump_pad_address): New.
(fast_tracepoint_from_ipa_tpoint_address): New.
(collecting_t): New.
(force_unlock_trace_buffer): New.
(fast_tracepoint_collecting): New.
(collecting): New.
(gdb_collect): New.
(write_inferior_data_ptr): New.
(target_tp_heap): New.
(target_malloc): New.
(download_agent_expr): New.
(UALIGN): New.
(download_tracepoints): New.
(download_trace_state_variables): New.
(upload_fast_traceframes): New.
(IPA_FIRST_TRACEFRAME): New.
(IPA_NEXT_TRACEFRAME_1): New.
(IPA_NEXT_TRACEFRAME): New.
[IN_PROCESS_AGENT]: Include sys/mman.h and fcntl.h.
[IN_PROCESS_AGENT] (gdb_tp_heap_buffer, gdb_jump_pad_buffer)
(gdb_jump_pad_buffer_end): New.
[IN_PROCESS_AGENT] (initialize_tracepoint_ftlib): New.
(initialize_tracepoint): Adjust.
[IN_PROCESS_AGENT]: Allocate the IPA heap, and jump pad scratch
buffer. Initialize the low module.
* utils.c (PREFIX, TOOLNAME): New.
(malloc_failure): Use PREFIX.
(error): In the IPA, an error causes an exit.
(fatal, warning): Use PREFIX.
(internal_error): Use TOOLNAME.
(NUMCELLS): Increase to 10.
* configure, config.in: Regenerate.
gdb/
2010-06-01 Pedro Alves <pedro@codesourcery.com>
* NEWS: Mention gdbserver fast tracepoints support.
gdb/doc/
2010-06-01 Pedro Alves <pedro@codesourcery.com>
* gdb.texinfo (Set Tracepoints): Mention tracepoints support in
gdbserver, and add cross reference.
(Tracepoints support in gdbserver): New subsection.
2010-06-01 21:20:52 +08:00
|
|
|
}
|