Age | Commit message (Collapse) | Author | Files | Lines |
|
This changes target_read_stralloc to return a unique_xmalloc_ptr, and
then fixes all the callers. unique_xmalloc_ptr is used, rather than
std::string, because target_read_stralloc gives a special meaning to a
NULL return.
ChangeLog
2017-10-16 Tom Tromey <tom@tromey.com>
* xml-syscall.c (xml_init_syscalls_info): Update.
* xml-support.c (xinclude_start_include): Update.
(xml_fetch_content_from_file): Return unique_xmalloc_ptr.
* xml-support.h (xml_fetch_another): Return unique_xmalloc_ptr.
(xml_fetch_content_from_file): Likewise.
* osdata.c (get_osdata): Update.
* target.h (target_read_stralloc, target_get_osdata): Return
unique_xmalloc_ptr.
* solib-aix.c (solib_aix_get_library_list): Update.
* solib-target.c (solib_target_current_sos): Update.
* solib-svr4.c (svr4_current_sos_via_xfer_libraries): Update.
* xml-tdesc.c (fetch_available_features_from_target): Update.
(target_fetch_description_xml): Update.
(file_read_description_xml): Update.
* remote.c (remote_get_threads_with_qxfer, remote_memory_map)
(remote_traceframe_info, btrace_read_config, remote_read_btrace)
(remote_pid_to_exec_file): Update.
* target.c (target_read_stralloc): Return unique_xmalloc_ptr.
(target_get_osdata): Likewise.
|
|
Since this target method returns an allocated object, return a
unique_ptr. It allows getting rid a some cleanups here and there.
I had to shuffle the includes around. First, target.h now needs to
include tracepoint.h, to get the definition of traceframe_info_up.
However, the definition of enum trace_find_type was later in target, so
I had to move it to tracepoint.h, so that the declaration of tfind_1
could know about it. I then had to remove the include of target.h from
tracepoint.h, which caused a circular dependency (it was probably
included to get enum trace_find_type in the first place anyway).
Regression tested on the buildbot.
gdb/ChangeLog:
* target.h: Include tracepoint.h.
(enum trace_find_type): Move to tracepoint.h.
(struct target_ops) <to_traceframe_info>: Return a unique ptr.
* tracepoint.h: Don't include target.h
(enum trace_find_type): Move from target.h.
(parse_traceframe_info): Return a unique ptr.
* tracepoint.c (current_traceframe_info): Change type to unique
ptr.
(free_traceframe_info): Remove.
(clear_traceframe_info): Don't manually free
current_traceframe_info.
(free_result): Remove.
(parse_traceframe_info): Return a unique ptr.
(get_traceframe_info): Adjust to unique ptr.
* ctf.c (ctf_traceframe_info): Return a unique ptr.
* remote.c (remote_traceframe_info): Return a unique ptr.
* tracefile-tfile.c (tfile_traceframe_info): Return a unique
ptr.
* target-debug.h (target_debug_print_traceframe_info_up): New
macro.
* target-delegates.c: Regenerate.
|
|
This changes read_memory_robust to return a std::vector, allowing the
removal of free_memory_read_result_vector and associated cleanups.
This patch also changes the functions it touches to be a bit more
robust with regards to deallocation; it's perhaps possible that
read_memory_robust could have leaked in some situations.
This patch is based on my earlier series to remove some MI cleanups.
Regression tested by the buildbot.
gdb/ChangeLog
2017-09-29 Tom Tromey <tom@tromey.com>
* target.c (read_whatever_is_readable): Change type of "result".
Update.
(free_memory_read_result_vector): Remove.
(read_memory_robust): Change return type. Update.
* mi/mi-main.c (mi_cmd_data_read_memory_bytes): Update. Use
bin2hex, std::string.
* target.h (memory_read_result_s): Remove typedef.
(free_memory_read_result_vector): Remove.
(read_memory_robust): Return std::vector.
|
|
This removes make_cleanup_defer_target_commit_resume in favor of using
scoped_restore.
gdb/ChangeLog
2017-09-29 Tom Tromey <tom@tromey.com>
* target.h (make_scoped_defer_target_commit_resume): Update.
* target.c (make_scoped_defer_target_commit_resume): Rename from
make_cleanup_defer_target_commit_resume. Return a
scoped_restore.
* infrun.c (proceed): Use make_scoped_defer_target_commit_resume.
|
|
This patch adds a target method named `to_thread_handle_to_thread_info'.
It is intended to map a thread library specific thread handle (such as
pthread_t for the pthread library) to the corresponding GDB internal
thread_info struct (pointer).
An implementation is provided for Linux pthreads; see linux-thread-db.c.
gdb/ChangeLog:
* target.h (struct target_ops): Add to_thread_handle_to_thread_info.
(target_thread_handle_to_thread_info): Declare.
* target.c (target_thread_handle_to_thread_info): New function.
* target-delegates.c: Regenerate.
* gdbthread.h (find_thread_by_handle): Declare.
* thread.c (find_thread_by_handle): New function.
* linux-thread-db.c (thread_db_thread_handle_to_thread_info): New
function.
(init_thread_db_ops): Register thread_db_thread_handle_to_thread_info.
|
|
This removes make_cleanup_restore_target_terminal and generally
C++-ifies target terminal handling. It changes all target_terminal_*
functions to be static members of a new target_terminal class and
changes the cleanup to be a scoped_* class.
make_cleanup_override_quit_handler is also removed in favor of simply
using scoped_restore.
Note that there are some files in this patch that I could not compile.
Considering that some of the rewrites were automated, and that none of
these files involed cleanups, I feel that this is relatively safe.
Regression tested by the buildbot.
gdb/ChangeLog
2017-09-20 Tom Tromey <tom@tromey.com>
* windows-nat.c (get_windows_debug_event, windows_wait)
(do_initial_windows_stuff, windows_attach): Update.
* utils.c (vwarning, internal_vproblem): Update.
(ui_unregister_input_event_handler_cleanup)
(prepare_to_handle_input): Remove.
(class scoped_input_handler): New.
(defaulted_query, prompt_for_continue): Update.
* tui/tui-hooks.c (tui_refresh_frame_and_register_information):
Update.
* top.c (undo_terminal_modifications_before_exit): Update.
* target/target.h (target_terminal_init, target_terminal_inferior)
(target_terminal_ours): Don't declare.
(class target_terminal): New.
* target.h (target_terminal_is_inferior, target_terminal_is_ours)
(target_terminal_ours_for_output)
(make_cleanup_restore_target_terminal): Don't declare.
(target_terminal_info): Remove.
* target.c (enum terminal_state, terminal_state): Remove.
(target_terminal::terminal_state): Define.
(target_terminal::init): Rename from target_terminal_init.
(target_terminal::inferior): Rename from
target_terminal_inferior.
(target_terminal::ours): Rename from target_terminal_ours.
(target_terminal::ours_for_output): Rename from
target_terminal_ours_for_output.
(target_terminal::info): New method.
(cleanup_restore_target_terminal)
(make_cleanup_restore_target_terminal): Remove.
* solib.c (handle_solib_event): Update.
* remote.c (remote_serial_quit_handler): Update.
(remote_terminal_inferior, remote_wait_as): Update.
* record-full.c (record_full_wait_1): Update.
* nto-procfs.c (procfs_create_inferior): Update.
* nat/fork-inferior.c (startup_inferior): Update.
* mi/mi-interp.c (mi_new_thread, mi_thread_exit)
(mi_record_changed, mi_inferior_added, mi_inferior_appeared)
(mi_inferior_exit, mi_inferior_removed, mi_traceframe_changed)
(mi_tsv_created, mi_tsv_deleted, mi_tsv_modified)
(mi_breakpoint_created, mi_breakpoint_deleted)
(mi_breakpoint_modified, mi_on_resume, mi_solib_loaded)
(mi_solib_unloaded, mi_command_param_changed, mi_memory_changed)
(mi_user_selected_context_changed, report_initial_inferior):
Update.
* linux-nat.c (linux_nat_attach, linux_nat_terminal_ours)
(linux_nat_terminal_inferior): Update.
* infrun.c (follow_fork_inferior)
(handle_vfork_child_exec_or_exit, do_target_resume)
(check_curr_ui_sync_execution_done, handle_inferior_event_1)
(handle_signal_stop, maybe_remove_breakpoints, normal_stop):
Update.
* inflow.c (child_terminal_init, info_terminal_command): Update.
* infcmd.c (post_create_inferior, continue_1, prepare_one_step)
(attach_command): Update.
* infcall.c (call_thread_fsm_should_stop): Update.
* gnu-nat.c (gnu_attach): Update.
* extension.c (struct active_ext_lang_state)
(restore_active_ext_lang): Update.
* exceptions.c (print_flush): Update.
* event-top.c (async_enable_stdin, default_quit_handler): Update.
(struct quit_handler_cleanup_data, restore_quit_handler)
(restore_quit_handler_dtor, make_cleanup_override_quit_handler):
Remove.
* cp-support.c (gdb_demangle): Update.
* breakpoint.c (update_inserted_breakpoint_locations)
(insert_breakpoint_locations, handle_jit_event)
(disable_breakpoints_in_unloaded_shlib): Update.
* annotate.c (annotate_breakpoints_invalid)
(annotate_frames_invalid): Update.
gdb/gdbserver/ChangeLog
2017-09-20 Tom Tromey <tom@tromey.com>
* target.c (target_terminal::terminal_state): Define.
(target_terminal::init): Rename from target_terminal_init.
(target_terminal::inferior): Rename from
target_terminal_inferior.
(target_terminal::ours): Rename from target_terminal_ours.
(target_terminal::ours_for_output, target_terminal::info): New.
|
|
This removes make_show_memory_breakpoints_cleanup, replacing it with
make_scoped_restore_show_memory_breakpoints and updating all callers.
ChangeLog
2017-09-11 Tom Tromey <tom@tromey.com>
* breakpoint.c (program_breakpoint_here_p): Update.
* target.c (make_scoped_restore_show_memory_breakpoints): Rename
from make_show_memory_breakpoints_cleanup. Return a
scoped_restore_tmpl<int>.
(restore_show_memory_breakpoints): Remove.
* ppc-linux-tdep.c (ppc_linux_memory_remove_breakpoint): Update.
* mem-break.c (memory_validate_breakpoint): Update.
* ia64-tdep.c (ia64_memory_insert_breakpoint): Update.
(ia64_memory_remove_breakpoint): Update.
(ia64_breakpoint_from_pc): Update.
* target.h (make_scoped_restore_show_memory_breakpoints): Rename
from make_show_memory_breakpoints_cleanup.
|
|
For some reason I ended up staring at some of the "int flags" in
btrace-related code, and I got confused because I had no clue what the
flags where supposed to indicate.
Fix that by using enum_flags, so that:
#1 - it's clear from the type what the flags are about, and
#2 - the compiler can catch mismatching mistakes
gdb/ChangeLog:
2017-09-04 Pedro Alves <palves@redhat.com>
* cli/cli-cmds.c (print_disassembly, disassemble_current_function)
(disassemble_command): Use gdb_disassembly_flags instead of bare
int.
* disasm.c (gdb_pretty_print_disassembler::pretty_print_insn)
(dump_insns, do_mixed_source_and_assembly_deprecated)
(do_mixed_source_and_assembly, do_assembly_only, gdb_disassembly):
Use gdb_disassembly_flags instead of bare int.
* disasm.h (DISASSEMBLY_SOURCE_DEPRECATED, DISASSEMBLY_RAW_INSN)
(DISASSEMBLY_OMIT_FNAME, DISASSEMBLY_FILENAME)
(DISASSEMBLY_OMIT_PC, DISASSEMBLY_SOURCE)
(DISASSEMBLY_SPECULATIVE): No longer macros. Instead they're...
(enum gdb_disassembly_flag): ... values of this new enumeration.
(gdb_disassembly_flags): Define.
(gdb_disassembly)
(gdb_pretty_print_disassembler::pretty_print_insn): Use it.
* mi/mi-cmd-disas.c (mi_cmd_disassemble): Use
gdb_disassembly_flags instead of bare int.
* record-btrace.c (btrace_insn_history)
(record_btrace_insn_history, record_btrace_insn_history_range)
(record_btrace_insn_history_from): Use gdb_disassembly_flags
instead of bare int.
* record.c (get_insn_history_modifiers, cmd_record_insn_history):
Use gdb_disassembly_flags instead of bare int.
* target-debug.h (target_debug_print_gdb_disassembly_flags):
Define.
* target-delegates.c: Regenerate.
* target.c (target_insn_history, target_insn_history_from)
(target_insn_history_range): Use gdb_disassembly_flags instead of
bare int.
* target.h: Include "disasm.h".
(struct target_ops) <to_insn_history, to_insn_history_from,
to_insn_history_range>: Use gdb_disassembly_flags instead of bare
int.
(target_insn_history, target_insn_history_from)
(target_insn_history_range): Use gdb_disassembly_flags instead of
bare int.
|
|
A quite straightforward change. It does "fix" leaks in record-btrace.c,
although since this is only used in debug printing code, it has no real
world impact.
gdb/ChangeLog:
* target/waitstatus.h (target_waitstatus_to_string): Change
return type to std::string.
* target/waitstatus.c (target_waitstatus_to_string): Return
std::string.
* target.h (target_waitstatus_to_string): Remove declaration.
* infrun.c (resume, clear_proceed_status_thread,
print_target_wait_results, do_target_wait, save_waitstatus,
stop_all_threads): Adjust.
* record-btrace.c (record_btrace_wait): Adjust.
* target-debug.h
(target_debug_print_struct_target_waitstatus_p): Adjust.
gdb/gdbserver/ChangeLog:
* linux-low.c (linux_wait_1): Adjust.
* server.c (queue_stop_reply_callback): Adjust.
|
|
The commit
d309493 target: consider addressable unit size when reading/writing memory
introduced the possibility of reading memory of targets with
non-8-bit-bytes (e.g. memories that store 16 bits at each address).
The documentation of target_read and target_write was updated
accordingly, but to_xfer_partial, which is very related, wasn't updated.
This commit fixes that.
gdb/ChangeLog:
* target.h (struct target_ops) <to_xfer_partial>: Update doc to
talk about addressable units instead of bytes.
|
|
This is the most important (and the biggest, sorry) patch of the
series. It moves fork_inferior from gdb/fork-child.c to
nat/fork-inferior.c and makes all the necessary adjustments to both
GDB and gdbserver to make sure everything works OK.
There is no "most important change" with this patch; all changes are
made in a progressive way, making sure that gdbserver had the
necessary features while not breaking GDB at the same time.
I decided to go ahead and implement a partial support for starting the
inferior with a shell on gdbserver, although the full feature comes in
the next patch. The user won't have the option to disable the
startup-with-shell, and also won't be able to change which shell
gdbserver will use (other than setting the $SHELL environment
variable, that is).
Everything is working as expected, and no regressions were present
during the tests.
gdb/ChangeLog:
2017-06-07 Sergio Durigan Junior <sergiodj@redhat.com>
Pedro Alves <palves@redhat.com>
* Makefile.in (HFILES_NO_SRCDIR): Add "common/common-inferior.h"
and "nat/fork-inferior.h".
* common/common-inferior.h: New file, with contents from
"gdb/inferior.h".
* commom/common-utils.c: Include "common-utils.h".
(stringify_argv): New function.
* common/common-utils.h (stringify_argv): New prototype.
* configure.nat: Add "fork-inferior.o" as a dependency for
"*linux*", "fbsd*" and "nbsd*" hosts.
* corefile.c (get_exec_file): Update comment.
* darwin-nat.c (darwin_ptrace_him): Call "gdb_startup_inferior"
instead of "startup_inferior".
(darwin_create_inferior): Call "add_thread_silent" after
"fork_inferior".
* fork-child.c: Cleanup unnecessary includes.
(SHELL_FILE): Move to "common/common-fork-child.c".
(environ): Likewise.
(exec_wrapper): Initialize.
(get_exec_wrapper): New function.
(breakup_args): Move to "common/common-fork-child.c"; rename to
"breakup_args_for_exec".
(escape_bang_in_quoted_argument): Move to
"common/common-fork-child.c".
(saved_ui): New variable.
(prefork_hook): New function.
(postfork_hook): Likewise.
(postfork_child_hook): Likewise.
(gdb_startup_inferior): Likewise.
(fork_inferior): Move to "common/common-fork-child.c". Update
function to support gdbserver.
(startup_inferior): Likewise.
* gdbcore.h (get_exec_file): Remove declaration.
* gnu-nat.c (gnu_create_inferior): Call "gdb_startup_inferior"
instead of "startup_inferior". Call "add_thread_silent" after
"fork_inferior".
* inf-ptrace.c: Include "nat/fork-inferior.h" and "utils.h".
(inf_ptrace_create_inferior): Call "gdb_startup_inferior"
instead of "startup_inferior". Call "add_thread_silent" after
"fork_inferior".
* inferior.h: Include "common-inferior.h".
(trace_start_error): Move to "common/common-utils.h".
(trace_start_error_with_name): Likewise.
(fork_inferior): Move prototype to "nat/fork-inferior.h".
(startup_inferior): Likewise.
(gdb_startup_inferior): New prototype.
* nat/fork-inferior.c: New file, with contents from "fork-child.c".
* nat/fork-inferior.h: New file.
* procfs.c (procfs_init_inferior): Call "gdb_startup_inferior"
instead of "startup_inferior". Call "add_thread_silent" after
"fork_inferior".
* target.h (target_terminal_init): Move prototype to
"target/target.h".
(target_terminal_inferior): Likewise.
(target_terminal_ours): Likewise.
* target/target.h (target_terminal_init): New prototype, moved
from "target.h".
(target_terminal_inferior): Likewise.
(target_terminal_ours): Likewise.
* utils.c (gdb_flush_out_err): New function.
gdb/gdbserver/ChangeLog:
2017-06-07 Sergio Durigan Junior <sergiodj@redhat.com>
Pedro Alves <palves@redhat.com>
* Makefile.in (SFILES): Add "nat/fork-inferior.o".
* configure: Regenerate.
* configure.srv (srv_linux_obj): Add "fork-child.o" and
"fork-inferior.o".
(i[34567]86-*-lynxos*): Likewise.
(spu*-*-*): Likewise.
* fork-child.c: New file.
* linux-low.c: Include "common-inferior.h", "nat/fork-inferior.h"
and "environ.h".
(linux_ptrace_fun): New function.
(linux_create_inferior): Adjust function prototype to reflect
change on "target.h". Adjust function code to use
"fork_inferior".
(linux_request_interrupt): Delete "signal_pid".
* lynx-low.c: Include "common-inferior.h" and "nat/fork-inferior.h".
(lynx_ptrace_fun): New function.
(lynx_create_inferior): Adjust function prototype to reflect
change on "target.h". Adjust function code to use
"fork_inferior".
* nto-low.c (nto_create_inferior): Adjust function prototype and
code to reflect change on "target.h". Update comments.
* server.c: Include "common-inferior.h", "nat/fork-inferior.h",
"common-terminal.h" and "environ.h".
(terminal_fd): Moved to fork-child.c.
(old_foreground_pgrp): Likewise.
(restore_old_foreground_pgrp): Likewise.
(last_status): Make it global.
(last_ptid): Likewise.
(our_environ): New variable.
(startup_with_shell): Likewise.
(program_name): Likewise.
(program_argv): Rename to...
(program_args): ...this.
(wrapper_argv): New variable.
(start_inferior): Delete function.
(get_exec_wrapper): New function.
(get_exec_file): Likewise.
(get_environ): Likewise.
(prefork_hook): Likewise.
(post_fork_inferior): Likewise.
(postfork_hook): Likewise.
(postfork_child_hook): Likewise.
(handle_v_run): Update code to deal with arguments coming from the
remote host. Update calls from "start_inferior" to
"create_inferior".
(captured_main): Likewise. Initialize environment variable. Call
"have_job_control".
* server.h (post_fork_inferior): New prototype.
(get_environ): Likewise.
(last_status): Declare.
(last_ptid): Likewise.
(signal_pid): Likewise.
* spu-low.c: Include "common-inferior.h" and "nat/fork-inferior.h".
(spu_ptrace_fun): New function.
(spu_create_inferior): Adjust function prototype to reflect change
on "target.h". Adjust function code to use "fork_inferior".
* target.c (target_terminal_init): New function.
(target_terminal_inferior): Likewise.
(target_terminal_ours): Likewise.
* target.h: Include <vector>.
(struct target_ops) <create_inferior>: Update prototype.
(create_inferior): Update macro.
* utils.c (gdb_flush_out_err): New function.
* win32-low.c (win32_create_inferior): Adjust function prototype
and code to reflect change on "target.h".
gdb/testsuite/ChangeLog:
2017-06-07 Sergio Durigan Junior <sergiodj@redhat.com>
* gdb.server/non-existing-program.exp: Update regex in order to
reflect the fact that gdbserver is now using fork_inferior (with a
shell) to startup the inferior.
|
|
As a preparation for the next patch, which will move fork_inferior
from GDB to common/ (and therefore share it with gdbserver), it is
interesting to convert a few functions to C++.
This patch touches functions related to parsing command-line arguments
to the inferior (see gdb/fork-child.c:breakup_args), the way the
arguments are stored on fork_inferior (using std::vector instead of
char **), and the code responsible for dealing with argv also on
gdbserver.
I've taken this opportunity and decided to constify a few arguments to
fork_inferior/create_inferior as well, in order to make the code
cleaner. And now, on gdbserver, we're using xstrdup everywhere and
aren't checking for memory allocation failures anymore, as requested
by Pedro:
<https://sourceware.org/ml/gdb-patches/2017-03/msg00191.html>
Message-Id: <025ebdb9-90d9-d54a-c055-57ed2406b812@redhat.com>
Pedro Alves wrote:
> On the "== NULL" check: IIUC, the old NULL check was there to
> handle strdup returning NULL due to out-of-memory.
> See NULL checks and comments further above in this function.
> Now that you're using a std::vector, that doesn't work or make
> sense any longer, since if push_back fails to allocate space for
> its internal buffer (with operator new), our operator new replacement
> (common/new-op.c) calls malloc_failure, which aborts gdbserver.
>
> Not sure it makes sense to handle out-of-memory specially in
> the gdb/rsp-facing functions nowadays (maybe git blame/log/patch
> submission for that code shows some guidelines). Maybe (or, probably)
> it's OK to stop caring about it, but then we should consistently remove
> left over code, by using xstrdup instead and remove the NULL checks.
IMO this refactoring was very good to increase the readability of the
code as well, because some parts of the argument handling were
unnecessarily confusing before.
gdb/ChangeLog:
2017-04-12 Sergio Durigan Junior <sergiodj@redhat.com>
* common/common-utils.c (free_vector_argv): New function.
* common/common-utils.h: Include <vector>.
(free_vector_argv): New prototype.
* darwin-nat.c (darwin_create_inferior): Rewrite function
prototype in order to constify "exec_file" and accept a
"std::string" for "allargs".
* fork-child.c: Include <vector>.
(breakup_args): Rewrite function, using C++.
(fork_inferior): Rewrite function header, constify "exec_file_arg"
and accept "std::string" for "allargs". Update the code to
calculate "argv" based on "allargs". Update calls to "exec_fun"
and "execvp".
* gnu-nat.c (gnu_create_inferior): Rewrite function prototype in
order to constify "exec_file" and accept a "std::string" for
"allargs".
* go32-nat.c (go32_create_inferior): Likewise.
* inf-ptrace.c (inf_ptrace_create_inferior): Likewise.
* infcmd.c (run_command_1): Constify "exec_file". Use
"std::string" for inferior arguments.
* inferior.h (fork_inferior): Update prototype.
* linux-nat.c (linux_nat_create_inferior): Rewrite function
prototype in order to constify "exec_file" and accept a
"std::string" for "allargs".
* nto-procfs.c (procfs_create_inferior): Likewise.
* procfs.c (procfs_create_inferior): Likewise.
* remote-sim.c (gdbsim_create_inferior): Likewise.
* remote.c (extended_remote_run): Update code to accept
"std::string" as argument.
(extended_remote_create_inferior): Rewrite function prototype in
order to constify "exec_file" and accept a "std::string" for
"allargs".
* rs6000-nat.c (super_create_inferior): Likewise.
(rs6000_create_inferior): Likewise.
* target.h (struct target_ops) <to_create_inferior>: Likewise.
* windows-nat.c (windows_create_inferior): Likewise.
gdb/gdbserver/ChangeLog:
2017-04-12 Sergio Durigan Junior <sergiodj@redhat.com>
* server.c: Include <vector>.
<program_argv, wrapper_argv>: Convert to std::vector.
(start_inferior): Rewrite function to use C++.
(handle_v_run): Likewise. Update code that calculates the argv
based on the vRun packet; use C++.
(captured_main): Likewise.
|
|
This is the remainder boring constification that all looks more of less
borderline obvious IMO.
gdb/ChangeLog:
2017-04-05 Pedro Alves <palves@redhat.com>
* ada-exp.y (yyerror): Constify.
* ada-lang.c (bound_name, get_selections)
(ada_variant_discrim_type)
(ada_variant_discrim_name, ada_value_struct_elt)
(ada_lookup_struct_elt_type, is_unchecked_variant)
(ada_which_variant_applies, standard_exc, ada_get_next_arg)
(catch_ada_exception_command_split)
(catch_ada_assert_command_split, catch_assert_command)
(ada_op_name): Constify.
* ada-lang.h (ada_yyerror, get_selections)
(ada_variant_discrim_name, ada_value_struct_elt): Constify.
* arc-tdep.c (arc_print_frame_cache): Constify.
* arm-tdep.c (arm_skip_stub): Constify.
* ax-gdb.c (gen_binop, gen_struct_ref_recursive, gen_struct_ref)
(gen_aggregate_elt_ref): Constify.
* bcache.c (print_bcache_statistics): Constify.
* bcache.h (print_bcache_statistics): Constify.
* break-catch-throw.c (catch_exception_command_1):
* breakpoint.c (struct ep_type_description::description):
Constify.
(add_solib_catchpoint): Constify.
(catch_fork_command_1): Add cast.
(add_catch_command): Constify.
* breakpoint.h (add_catch_command, add_solib_catchpoint):
Constify.
* bsd-uthread.c (bsd_uthread_state): Constify.
* buildsym.c (patch_subfile_names): Constify.
* buildsym.h (next_symbol_text_func, patch_subfile_names):
Constify.
* c-exp.y (yyerror): Constify.
(token::oper): Constify.
* c-lang.h (c_yyerror, cp_print_class_member): Constify.
* c-varobj.c (cplus_describe_child): Constify.
* charset.c (find_charset_names): Add cast.
(find_charset_names): Constify array and add const_cast.
* cli/cli-cmds.c (complete_command, cd_command): Constify.
(edit_command): Constify.
* cli/cli-decode.c (lookup_cmd): Constify.
* cli/cli-dump.c (dump_memory_command, dump_value_command):
Constify.
(struct dump_context): Constify.
(add_dump_command, restore_command): Constify.
* cli/cli-script.c (get_command_line): Constify.
* cli/cli-script.h (get_command_line): Constify.
* cli/cli-utils.c (check_for_argument): Constify.
* cli/cli-utils.h (check_for_argument): Constify.
* coff-pe-read.c (struct read_pe_section_data): Constify.
* command.h (lookup_cmd): Constify.
* common/print-utils.c (decimal2str): Constify.
* completer.c (gdb_print_filename): Constify.
* corefile.c (set_gnutarget): Constify.
* cp-name-parser.y (yyerror): Constify.
* cp-valprint.c (cp_print_class_member): Constify.
* cris-tdep.c (cris_register_name, crisv32_register_name):
Constify.
* d-exp.y (yyerror): Constify.
(struct token::oper): Constify.
* d-lang.h (d_yyerror): Constify.
* dbxread.c (struct header_file_location::name): Constify.
(add_old_header_file, add_new_header_file, last_function_name)
(dbx_next_symbol_text, add_bincl_to_list)
(find_corresponding_bincl_psymtab, set_namestring)
(find_stab_function_addr, read_dbx_symtab, start_psymtab)
(dbx_end_psymtab, read_ofile_symtab, process_one_symbol):
* defs.h (command_line_input, print_address_symbolic)
(deprecated_readline_begin_hook): Constify.
* dwarf2read.c (anonymous_struct_prefix, dwarf_bool_name):
Constify.
* event-top.c (handle_line_of_input): Constify and add cast.
* exceptions.c (catch_errors): Constify.
* exceptions.h (catch_errors): Constify.
* expprint.c (print_subexp_standard, op_string, op_name)
(op_name_standard, dump_raw_expression, dump_raw_expression):
* expression.h (op_name, op_string, dump_raw_expression):
Constify.
* f-exp.y (yyerror): Constify.
(struct token::oper): Constify.
(struct f77_boolean_val::name): Constify.
* f-lang.c (f_word_break_characters): Constify.
* f-lang.h (f_yyerror): Constify.
* fork-child.c (fork_inferior): Add cast.
* frv-tdep.c (struct gdbarch_tdep::register_names): Constify.
(new_variant): Constify.
* gdbarch.sh (pstring_ptr, pstring_list): Constify.
* gdbarch.c: Regenerate.
* gdbcore.h (set_gnutarget): Constify.
* go-exp.y (yyerror): Constify.
(token::oper): Constify.
* go-lang.h (go_yyerror): Constify.
* go32-nat.c (go32_sysinfo): Constify.
* guile/scm-breakpoint.c (gdbscm_breakpoint_expression): Constify.
* guile/scm-cmd.c (cmdscm_function): Constify.
* guile/scm-param.c (pascm_param_value): Constify.
* h8300-tdep.c (h8300_register_name, h8300s_register_name)
(h8300sx_register_name): Constify.
* hppa-tdep.c (hppa32_register_name, hppa64_register_name):
Constify.
* ia64-tdep.c (ia64_register_names): Constify.
* infcmd.c (construct_inferior_arguments): Constify.
(path_command, attach_post_wait): Constify.
* language.c (show_range_command, show_case_command)
(unk_lang_error): Constify.
* language.h (language_defn::la_error)
(language_defn::la_name_of_this): Constify.
* linespec.c (decode_line_2): Constify.
* linux-thread-db.c (thread_db_err_str): Constify.
* lm32-tdep.c (lm32_register_name): Constify.
* m2-exp.y (yyerror): Constify.
* m2-lang.h (m2_yyerror): Constify.
* m32r-tdep.c (m32r_register_names): Constify and make static.
* m68hc11-tdep.c (m68hc11_register_names): Constify.
* m88k-tdep.c (m88k_register_name): Constify.
* macroexp.c (appendmem): Constify.
* mdebugread.c (fdr_name, add_data_symbol, parse_type)
(upgrade_type, parse_external, parse_partial_symbols)
(mdebug_next_symbol_text, cross_ref, mylookup_symbol, new_psymtab)
(new_symbol): Constify.
* memattr.c (mem_info_command): Constify.
* mep-tdep.c (register_name_from_keyword): Constify.
* mi/mi-cmd-env.c (mi_cmd_env_path, _initialize_mi_cmd_env):
Constify.
* mi/mi-cmd-stack.c (list_args_or_locals): Constify.
* mi/mi-cmd-var.c (mi_cmd_var_show_attributes): Constify.
* mi/mi-main.c (captured_mi_execute_command): Constify and add
cast.
(mi_execute_async_cli_command): Constify.
* mips-tdep.c (mips_register_name): Constify.
* mn10300-tdep.c (register_name, mn10300_generic_register_name)
(am33_register_name, am33_2_register_name)
* moxie-tdep.c (moxie_register_names): Constify.
* nat/linux-osdata.c (osdata_type): Constify fields.
* nto-tdep.c (nto_parse_redirection): Constify.
* objc-lang.c (lookup_struct_typedef, lookup_objc_class)
(lookup_child_selector): Constify.
(objc_methcall::name): Constify.
* objc-lang.h (lookup_objc_class, lookup_child_selector)
(lookup_struct_typedef): Constify.
* objfiles.c (pc_in_section): Constify.
* objfiles.h (pc_in_section): Constify.
* p-exp.y (struct token::oper): Constify.
(yyerror): Constify.
* p-lang.h (pascal_yyerror): Constify.
* parser-defs.h (op_name_standard): Constify.
(op_print::string): Constify.
(exp_descriptor::op_name): Constify.
* printcmd.c (print_address_symbolic): Constify.
* psymtab.c (print_partial_symbols): Constify.
* python/py-breakpoint.c (stop_func): Constify.
(bppy_get_expression): Constify.
* python/py-cmd.c (cmdpy_completer::name): Constify.
(cmdpy_function): Constify.
* python/py-event.c (evpy_add_attribute)
(gdbpy_initialize_event_generic): Constify.
* python/py-event.h (evpy_add_attribute)
(gdbpy_initialize_event_generic): Constify.
* python/py-evts.c (add_new_registry): Constify.
* python/py-finishbreakpoint.c (outofscope_func): Constify.
* python/py-framefilter.c (get_py_iter_from_func): Constify.
* python/py-inferior.c (get_buffer): Add cast.
* python/py-param.c (parm_constant::name): Constify.
* python/py-unwind.c (fprint_frame_id): Constify.
* python/python.c (gdbpy_parameter_value): Constify.
* remote-fileio.c (remote_fio_func_map): Make 'name' const.
* remote.c (memory_packet_config::name): Constify.
(show_packet_config_cmd, remote_write_bytes)
(remote_buffer_add_string):
* reverse.c (exec_reverse_once): Constify.
* rs6000-tdep.c (variant::name, variant::description): Constify.
* rust-exp.y (rustyyerror): Constify.
* rust-lang.c (rust_op_name): Constify.
* rust-lang.h (rustyyerror): Constify.
* serial.h (serial_ops::name): Constify.
* sh-tdep.c (sh_sh_register_name, sh_sh3_register_name)
(sh_sh3e_register_name, sh_sh2e_register_name)
(sh_sh2a_register_name, sh_sh2a_nofpu_register_name)
(sh_sh_dsp_register_name, sh_sh3_dsp_register_name)
(sh_sh4_register_name, sh_sh4_nofpu_register_name)
(sh_sh4al_dsp_register_name): Constify.
* sh64-tdep.c (sh64_register_name): Constify.
* solib-darwin.c (lookup_symbol_from_bfd): Constify.
* spu-tdep.c (spu_register_name, info_spu_dma_cmdlist): Constify.
* stabsread.c (patch_block_stabs, read_type_number)
(ref_map::stabs, ref_add, process_reference)
(symbol_reference_defined, define_symbol, define_symbol)
(error_type, read_type, read_member_functions, read_cpp_abbrev)
(read_one_struct_field, read_struct_fields, read_baseclasses)
(read_tilde_fields, read_struct_type, read_array_type)
(read_enum_type, read_sun_builtin_type, read_sun_floating_type)
(read_huge_number, read_range_type, read_args, common_block_start)
(find_name_end): Constify.
* stabsread.h (common_block_start, define_symbol)
(process_one_symbol, symbol_reference_defined, ref_add):
* symfile.c (get_section_index, add_symbol_file_command):
* symfile.h (get_section_index): Constify.
* target-descriptions.c (tdesc_type::name): Constify.
(tdesc_free_type): Add cast.
* target.c (find_default_run_target):
(add_deprecated_target_alias, find_default_run_target)
(target_announce_detach): Constify.
(do_option): Constify.
* target.h (add_deprecated_target_alias): Constify.
* thread.c (print_thread_info_1): Constify.
* top.c (deprecated_readline_begin_hook, command_line_input):
Constify.
(init_main): Add casts.
* top.h (handle_line_of_input): Constify.
* tracefile-tfile.c (tfile_write_uploaded_tsv): Constify.
* tracepoint.c (tvariables_info_1, trace_status_mi): Constify.
(tfind_command): Rename to ...
(tfind_command_1): ... this and constify.
(tfind_command): New function.
(tfind_end_command, tfind_start_command): Adjust.
(encode_source_string): Constify.
* tracepoint.h (encode_source_string): Constify.
* tui/tui-data.c (tui_partial_win_by_name): Constify.
* tui/tui-data.h (tui_partial_win_by_name): Constify.
* tui/tui-source.c (tui_set_source_content_nil): Constify.
* tui/tui-source.h (tui_set_source_content_nil): Constify.
* tui/tui-win.c (parse_scrolling_args): Constify.
* tui/tui-windata.c (tui_erase_data_content): Constify.
* tui/tui-windata.h (tui_erase_data_content): Constify.
* tui/tui-winsource.c (tui_erase_source_content): Constify.
* tui/tui.c (tui_enable): Add cast.
* utils.c (defaulted_query): Constify.
(init_page_info): Add cast.
(puts_debug, subset_compare): Constify.
* utils.h (subset_compare): Constify.
* varobj.c (varobj_format_string): Constify.
* varobj.h (varobj_format_string): Constify.
* vax-tdep.c (vax_register_name): Constify.
* windows-nat.c (windows_detach): Constify.
* xcoffread.c (process_linenos, xcoff_next_symbol_text): Constify.
* xml-support.c (gdb_xml_end_element): Constify.
* xml-tdesc.c (tdesc_start_reg): Constify.
* xstormy16-tdep.c (xstormy16_register_name): Constify.
* xtensa-tdep.c (xtensa_find_register_by_name): Constify.
* xtensa-tdep.h (xtensa_register_t::name): Constify.
gdb/gdbserver/ChangeLog:
2017-04-05 Pedro Alves <palves@redhat.com>
* gdbreplay.c (sync_error): Constify.
* linux-x86-low.c (push_opcode): Constify.
|
|
-Wwrite-strings flagged a missing cast for example here:
static char *
ravenscar_extra_thread_info (struct target_ops *self, struct thread_info *tp)
{
return "Ravenscar task";
Since callers are not supposed to free the string returned by these
methods, change the methods' signature to return const strings.
gdb/ChangeLog:
2017-04-05 Pedro Alves <palves@redhat.com>
* aix-thread.c (aix_thread_pid_to_str)
(aix_thread_extra_thread_info): Constify.
* bsd-kvm.c (bsd_kvm_pid_to_str): Constify.
* bsd-uthread.c (bsd_uthread_extra_thread_info)
(bsd_uthread_pid_to_str): Constify.
* corelow.c (core_pid_to_str): Constify.
* darwin-nat.c (darwin_pid_to_str): Constify.
* fbsd-nat.c (fbsd_pid_to_str): Constify.
* fbsd-tdep.c (fbsd_core_pid_to_str, gdbarch_core_pid_to_str):
Constify.
* gnu-nat.c (gnu_pid_to_str): Constify.
* go32-nat.c (go32_pid_to_str): Constify.
* i386-cygwin-tdep.c (i386_windows_core_pid_to_str): Constify.
* inf-ptrace.c (inf_ptrace_pid_to_str): Constify.
* inferior.c (inferior_pid_to_str): Constify.
* linux-nat.c (linux_nat_pid_to_str): Constify.
* linux-tdep.c (linux_core_pid_to_str): Constify.
* linux-thread-db.c (thread_db_pid_to_str)
(thread_db_extra_thread_info): Constify.
* nto-tdep.c (nto_extra_thread_info): Constify.
* nto-tdep.h (nto_extra_thread_info): Constify.
* obsd-nat.c (obsd_pid_to_str): Constify.
* procfs.c (procfs_pid_to_str): Constify.
* ravenscar-thread.c (ravenscar_extra_thread_info)
(ravenscar_pid_to_str): Constify.
* remote-sim.c (gdbsim_pid_to_str): Constify.
* remote.c (remote_threads_extra_info, remote_pid_to_str):
Constify.
* sol-thread.c (solaris_pid_to_str): Constify.
* sol2-tdep.c (sol2_core_pid_to_str): Constify.
* sol2-tdep.h (sol2_core_pid_to_str): Constify.
* target.c (default_pid_to_str, target_pid_to_str)
(normal_pid_to_str, default_pid_to_str): Constify.
* target.h (target_ops::to_pid_to_str)
(target_ops::to_extra_thread_info): Constify.
(target_pid_to_str, normal_pid_to_str): Constify.
* windows-nat.c (windows_pid_to_str): Constify.
* gdbarch.sh (core_pid_to_str): Constify.
* target-delegates.c: Regenerate.
* gdbarch.h, gdbarch.c: Regenerate.
|
|
Signed-off-by: Tim Wiederhake <tim.wiederhake@intel.com>
gdb/ChangeLog
* record-btrace.c (record_btrace_record_method): New function.
(init_record_btrace_ops): Initialize to_record_method.
* record-full.c (record_full_record_method): New function.
(init_record_full_ops, init_record_full_core_ops): Add
record_full_record_method.
* record.h (enum record_method): New enum.
* target-debug.h (target_debug_print_enum_record_method: New define.
* target-delegates.c: Regenerate.
* target.c (target_record_method): New function.
* target.h: Include record.h.
(struct target_ops) <to_record_method>: New field.
(target_record_method): New export.
Change-Id: I05daa70e4e08a19901e848c731bb7d60cd87cc5a
|
|
Changes in v4:
- Replaced phex call with hex_string.
Changes in v3:
- Addressed comments by Pedro.
- Output of memory region size now in hex format.
- Misc formatting fixups.
- Addressed Simon's comments on formatting.
- Adjusted command text in the manual entry.
- Fixed up ChangeLog.
- Renamed flash_erase_all_command to flash_erase_command.
Changes in v2:
- Added NEWS entry.
- Fixed long lines.
- Address printing with paddress.
Years ago we contributed flash programming patches upstream. The following
patch is a leftover one that complements that functionality by adding a new
command to erase all reported flash memory blocks.
The command is most useful when we're dealing with flash-enabled targets
(mostly bare-metal) and we need to reset the board for some reason.
The wiping out of flash memory regions should help the target come up with a
known clean state from which the user can load a new image and resume
debugging. It is convenient enough to do this from the debugger, and there is
also an MI command to expose this functionality to the IDE's.
gdb/doc/ChangeLog:
2017-01-20 Mike Wrighton <mike_wrighton@codesourcery.com>
Luis Machado <lgustavo@codesourcery.com>
* gdb.texinfo (-target-flash-erase): New MI command description.
(flash-erase): New CLI command description.
gdb/ChangeLog:
2017-01-20 Mike Wrighton <mike_wrighton@codesourcery.com>
Luis Machado <lgustavo@codesourcery.com>
* NEWS (New commands): Mention flash-erase.
(New MI commands): Mention target-flash-erase.
* mi/mi-cmds.c (mi_cmd_target_flash_erase): Add target-flash-erase MI
command.
* mi/mi-cmds.h (mi_cmd_target_flash_erase): New declaration.
* mi/mi-main.c (mi_cmd_target_flash_erase): New function.
* target.c (flash_erase_command): New function.
(initialize_targets): Add new flash-erase command.
* target.h (flash_erase_command): New declaration.
|
|
This applies the second part of GDB's End of Year Procedure, which
updates the copyright year range in all of GDB's files.
gdb/ChangeLog:
Update copyright year range in all GDB files.
|
|
Currently, with "maint set target-non-stop on", that is, when gdb
connects with the non-stop/asynchronous variant of the remote
protocol, even with "set non-stop off", GDB always sends one vCont
packet per thread resumed. This patch makes GDB aggregate and
coalesce vCont packets, so we send vCont packets like "vCont;s:p1.1;c"
in non-stop mode too.
Basically, this is done by:
- Adding a new target method target_commit_resume that is called
after calling target_resume one or more times. When resuming a
batch of threads, we'll only call target_commit_resume once after
calling target_resume for all threads.
- Making the remote target defer sending the actual vCont packet to
target_commit_resume.
Special care must be taken to avoid sending a vCont action with a
"wildcard" thread-id (all threads of process / all threads) when that
would resume threads/processes that should not be resumed. See
remote_commit_resume comments for details.
Unlike all-stop's remote_resume implementation, this handles the case
of too many actions resulting in a too-big vCont packet, by flushing
the vCont packet and starting a new one.
E.g., imagining that the "c" action in:
vCont;s:1;c
overflows the packet buffer, we split the actions like:
vCont;s:1
vCont;c
Tested on x86_64 Fedora 20, with and without "maint set
target-non-stop on".
Also tested with a hack that makes remote_commit_resume flush the vCont
packet after every action appended (which caught a few bugs).
gdb/ChangeLog:
2016-10-26 Pedro Alves <palves@redhat.com>
* inferior.h (ALL_NON_EXITED_INFERIORS): New macro.
* infrun.c (do_target_resume): Call target_commit_resume.
(proceed): Defer target_commit_resume while looping over threads,
resuming them. Call target_commit_resume at the end.
* record-btrace.c (record_btrace_commit_resume): New function.
(init_record_btrace_ops): Install it as to_commit_resume method.
* record-full.c (record_full_commit_resume): New function.
(record_full_wait_1): Call the beneath target's to_commit_resume
method.
(init_record_full_ops): Install record_full_commit_resume as
to_commit_resume method.
* remote.c (struct private_thread_info) <last_resume_step,
last_resume_sig, vcont_resumed>: New fields.
(remote_add_thread): Set the new thread's vcont_resumed flag.
(demand_private_info): Delete.
(get_private_info_thread, get_private_info_ptid): New functions.
(remote_update_thread_list): Adjust.
(process_initial_stop_replies): Clear the thread's vcont_resumed
flag.
(remote_resume): If connected in non-stop mode, record the resume
request and return early.
(struct private_inferior): New.
(struct vcont_builder): New.
(vcont_builder_restart, vcont_builder_flush)
(vcont_builder_push_action): New functions.
(MAX_ACTION_SIZE): New macro.
(remote_commit_resume): New function.
(thread_pending_fork_status, is_pending_fork_parent_thread): New
functions.
(check_pending_event_prevents_wildcard_vcont_callback)
(check_pending_events_prevent_wildcard_vcont): New functions.
(process_stop_reply): Adjust. Clear the thread's vcont_resumed
flag.
(init_remote_ops): Install remote_commit_resume.
* target-delegates.c: Regenerate.
* target.c (defer_target_commit_resume): New global.
(target_commit_resume, make_cleanup_defer_target_commit_resume):
New functions.
* target.h (struct target_ops) <to_commit_resume>: New field.
(target_resume): Update comments.
(target_commit_resume): New declaration.
|
|
This simple commit consolidates the API of
target_supports_multi_process. Since both GDB and gdbserver use the
same function prototype, all that was needed was to move create this
prototype on gdb/target/target.h and turn the macros declared on
gdb/{,gdbserver/}target.h into actual functions.
Regtested (clean pass) on the BuildBot.
gdb/ChangeLog:
2016-10-06 Sergio Durigan Junior <sergiodj@redhat.com>
* target.c (target_supports_multi_process): New function, moved
from...
* target.h (target_supports_multi_process): ... here. Remove
macro.
* target/target.h (target_supports_multi_process): New prototype.
gdb/gdbserver/ChangeLog:
2016-10-06 Sergio Durigan Junior <sergiodj@redhat.com>
* target.c (target_supports_multi_process): New function, moved
from...
* target.h (target_supports_multi_process): ... here. Remove
macro.
|
|
This patch consolidates the API of target_mourn_inferior between GDB
and gdbserver, in my continuing efforts to make sharing the
fork_inferior function possible between both.
GDB's version of the function did not care about the inferior's ptid
being mourned, but gdbserver's needed to know this information. Since
it actually makes sense to pass the ptid as an argument, instead of
depending on a global value directly (which GDB's version did), I
decided to make the generic API to accept it. I then went on and
extended all calls being made on GDB to include a ptid argument (which
ended up being inferior_ptid most of the times, anyway), and now we
have a more sane interface.
On GDB's side, after talking to Pedro a bit about it, we decided that
just an assertion to make sure that the ptid being passed is equal to
inferior_ptid would be enough for now, on the GDB side. We can remove
the assertion and perform more operations later if we ever pass
anything different than inferior_ptid.
Regression tested on our BuildBot, everything OK.
I'd appreciate a special look at gdb/windows-nat.c's modification
because I wasn't really sure what to do there. It seemed to me that
maybe I should build a ptid out of the process information there, but
then I am almost sure the assertion on GDB's side would trigger.
gdb/ChangeLog:
2016-09-19 Sergio Durigan Junior <sergiodj@redhat.com>
* darwin-nat.c (darwin_kill_inferior): Adjusting call to
target_mourn_inferior to include ptid_t argument.
* fork-child.c (startup_inferior): Likewise.
* gnu-nat.c (gnu_kill_inferior): Likewise.
* inf-ptrace.c (inf_ptrace_kill): Likewise.
* infrun.c (handle_inferior_event_1): Likewise.
* linux-nat.c (linux_nat_attach): Likewise.
(linux_nat_kill): Likewise.
* nto-procfs.c (interrupt_query): Likewise.
(procfs_interrupt): Likewise.
(procfs_kill_inferior): Likewise.
* procfs.c (procfs_kill_inferior): Likewise.
* record.c (record_mourn_inferior): Likewise.
* remote-sim.c (gdbsim_kill): Likewise.
* remote.c (remote_detach_1): Likewise.
(remote_kill): Likewise.
* target.c (target_mourn_inferior): Change declaration to accept
new ptid_t argument; use gdb_assert on it.
* target.h (target_mourn_inferior): Move function prototype from
here...
* target/target.h (target_mourn_inferior): ... to here. Adjust it
to accept new ptid_t argument.
* windows-nat.c (get_windows_debug_event): Adjusting call to
target_mourn_inferior to include ptid_t argument.
gdb/gdbserver/ChangeLog:
2016-09-19 Sergio Durigan Junior <sergiodj@redhat.com>
* server.c (start_inferior): Call target_mourn_inferior instead of
mourn_inferior; pass ptid_t argument to it.
(resume): Likewise.
(handle_target_event): Likewise.
* target.c (target_mourn_inferior): New function.
* target.h (mourn_inferior): Delete macro.
|
|
This commit moves the target_wait prototype from the GDB-specific
target.h header to the common target/target.h header. Then, it
creates a compatible implementation of target_wait on gdbserver using
the_target->wait, and adjusts the (only) caller (mywait function).
Pretty straightforward, no regressions introduced.
gdb/gdbserver/ChangeLog:
2016-09-01 Sergio Durigan Junior <sergiodj@redhat.com>
* target.c (mywait): Call target_wait instead of
the_target->wait.
(target_wait): New function.
gdb/ChangeLog:
2016-09-01 Sergio Durigan Junior <sergiodj@redhat.com>
* target.c (target_wait): Mention that the function's prototype
can be found at target/target.h.
* target.h (target_wait): Move prototype from here...
* target/target.h (target_wait): ... to here.
|
|
So the target knows whether we're detaching breakpoints.
Nothing uses the parameter in this patch yet.
gdb/ChangeLog:
2016-08-10 Pedro Alves <palves@redhat.com>
PR gdb/19187
* break-catch-sig.c (signal_catchpoint_remove_location): Adjust
interface.
* break-catch-syscall.c (remove_catch_syscall):
* breakpoint.c (enum remove_bp_reason): Moved to breakpoint.h.
(remove_breakpoint_1): Pass 'reason' down.
(remove_catch_fork, remove_catch_vfork, remove_catch_solib)
(remove_catch_exec, remove_watchpoint, remove_masked_watchpoint)
(base_breakpoint_remove_location, bkpt_remove_location)
(bkpt_probe_remove_location, bkpt_probe_remove_location): Adjust
interface.
* breakpoint.h (enum remove_bp_reason): Moved here from
breakpoint.c.
(struct breakpoint_ops) <remove_location>: Add 'reason' parameter.
* corelow.c (core_remove_breakpoint): New function.
(init_core_ops): Install it as to_remove_breakpoint method.
* exec.c (exec_remove_breakpoint): New function.
(init_exec_ops): Install it as to_remove_breakpoint method.
* mem-break.c (memory_remove_breakpoint): Adjust interface.
* record-btrace.c (record_btrace_remove_breakpoint): Adjust
interface.
* record-full.c (record_full_remove_breakpoint)
(record_full_core_remove_breakpoint): Adjust interface.
* remote.c (remote_remove_breakpoint): Adjust interface.
* target-debug.h (target_debug_print_enum_remove_bp_reason): New
macro.
* target-delegates.c: Regenerate.
* target.c (target_remove_breakpoint): Add 'reason' parameter.
* target.h (struct target_ops) <to_remove_breakpoint>: Add
'reason' parameter.
(target_remove_breakpoint, memory_remove_breakpoint): Add 'reason'
parameter.
|
|
When executing commands on a secondary UI running the MI interpreter,
some commands that should be synchronous are not. MI incorrectly
continues processing input right after the synchronous command is
sent, before the target stops.
The problem happens when we emit MI async events (=library-loaded,
etc.), and we go about restoring the previous terminal state, we end
up calling target_terminal_ours, which incorrectly always installs the
current UI's input_fd in the event loop... That is, code like this:
old_chain = make_cleanup_restore_target_terminal ();
target_terminal_ours_for_output ();
fprintf_unfiltered (mi->event_channel, "library-loaded");
...
do_cleanups (old_chain);
The fix is to move the add_file_handler/delete_file_handler calls out
of target_terminal_$foo, making these completely no-ops unless called
with the main UI as current UI.
gdb/ChangeLog:
2016-08-09 Pedro Alves <palves@redhat.com>
PR gdb/20418
* event-top.c (ui_register_input_event_handler)
(ui_unregister_input_event_handler): New functions.
(async_enable_stdin): Register input in the event loop.
(async_disable_stdin): Unregister input from the event loop.
(gdb_setup_readline): Register input in the event loop.
* infrun.c (check_curr_ui_sync_execution_done): Register input in
the event loop.
* target.c (target_terminal_inferior): Don't unregister input from
the event loop.
(target_terminal_ours): Don't register input in the event loop.
* target.h (target_terminal_inferior)
(target_terminal_ours_for_output, target_terminal_ours): Update
comments.
* top.h (ui_register_input_event_handler)
(ui_unregister_input_event_handler): New declarations.
* utils.c (ui_unregister_input_event_handler_cleanup)
(prepare_to_handle_input): New functions.
(defaulted_query, prompt_for_continue): Use
prepare_to_handle_input.
gdb/testsuite/ChangeLog:
2016-08-09 Pedro Alves <palves@redhat.com>
Simon Marchi <simon.marchi@ericsson.com>
PR gdb/20418
* gdb.mi/new-ui-mi-sync.c, gdb.mi/new-ui-mi-sync.exp: New files.
* lib/mi-support.exp (mi_expect_interrupt): Remove anchors.
|
|
Some analysis we did here showed that increasing the cap on the
transfer size in target.c:memory_xfer_partial could give 20% or more
improvement in remote load across JTAG. Transfer sizes were capped
to 4K bytes because of performance problems encountered with the
restore command, documented here:
https://sourceware.org/ml/gdb-patches/2013-07/msg00611.html
and in commit 67c059c29e1f ("Improve performance of large restore
commands").
The 4K cap was introduced because in a case where the restore command
requested a 100MB transfer, memory_xfer_partial would repeatedy
allocate and copy an entire 100MB buffer in order to properly handle
breakpoint shadow instructions, even though memory_xfer_partial would
actually only write a small portion of the buffer contents.
A couple of alternative solutions were suggested:
* change the algorithm for handling the breakpoint shadow instructions
* throttle the transfer size up or down based on the previous actual
transfer size
I tried implementing the throttling approach, and my implementation
reduced the performance in some cases.
This patch implements a new target function that returns that target's
limit on memory transfer size. It defaults to ULONGEST_MAX bytes,
because for native targets there is no marshaling and thus no limit is
needed. For remote targets it uses get_memory_write_packet_size.
gdb/ChangeLog:
* remote.c (remote_get_memory_xfer_limit): New function.
* target-delegates.c: Regenerate.
* target.c (memory_xfer_partial): Call
target_ops.to_get_memory_xfer_limit.
* target.h (struct target_ops)
<to_get_memory_xfer_limit>: New member.
|
|
Several targets have a copy of the same code that prints
"Detaching from program ..."
in their target_detach implementation. Factor that out to a common
function.
(For now, I left the couple targets that print this a bit differently
alone. Maybe this could be further pulled out into infcmd.c. If we
did that, and those targets want to continue printing differently,
this new function could be converted to a target method.)
gdb/ChangeLog:
2016-07-01 Pedro Alves <palves@redhat.com>
* darwin-nat.c (darwin_detach): Use target_announce_detach.
* inf-ptrace.c (inf_ptrace_detach): Likewise.
* nto-procfs.c (procfs_detach): Likewise.
* remote.c (remote_detach_1): Likewise.
* target.c (target_announce_detach): New function.
* target.h (target_announce_detach): New declaration.
|
|
This is no longer called anywhere.
gdb/ChangeLog:
2016-04-12 Pedro Alves <palves@redhat.com>
* target.c (target_check_pending_interrupt): Delete.
* target.h (struct target_ops) <to_check_pending_interrupt>:
Remove method.
(target_check_pending_interrupt): Remove declaration.
* target-delegates.c: Regenerate.
|
|
If the user presses Ctrl-C immediately before target_terminal_inferior
is called and the target is resumed, instead of after, the Ctrl-C ends
up pending in the quit flag until the target next stops.
remote.c has this bit to handle this:
if (!target_is_async_p ())
{
ofunc = signal (SIGINT, sync_remote_interrupt);
/* If the user hit C-c before this packet, or between packets,
pretend that it was hit right here. */
if (check_quit_flag ())
sync_remote_interrupt (SIGINT);
}
But that's only reachable if async is off, while async is on by
default nowadays. It's also obviously not reacheable on native
targets.
This patch generalizes that to all targets.
We can't remove that remote.c bit yet, until we get rid of the sync
SIGINT handler though. That'll be done later in the series.
gdb/ChangeLog:
2016-04-12 Pedro Alves <palves@redhat.com>
* remote.c (remote_pass_ctrlc): New function.
(init_remote_ops): Install it.
* target.c (target_terminal_inferior): Pass pending Ctrl-C to the
target.
(target_pass_ctrlc, default_target_pass_ctrlc): New functions.
* target.h (struct target_ops) <to_pass_ctrlc>: New method.
(target_pass_ctrlc, default_target_pass_ctrlc): New declarations.
* target-delegates.c: Regenerate.
|
|
gdb/ChangeLog
2016-03-09 Jose E. Marchesi <jose.marchesi@oracle.com>
* target.h: Fix doc string of target_can_use_hardware_watchpoint.
|
|
I see a timeout in gdb.base/random-signal.exp,
Continuing.^M
PASS: gdb.base/random-signal.exp: continue
^CPython Exception <type 'exceptions.KeyboardInterrupt'> <type
exceptions.KeyboardInterrupt'>: ^M
FAIL: gdb.base/random-signal.exp: stop with control-c (timeout)
it can be reproduced by running random-signal.exp with native-gdbserver
in a loop, like this, and the fail will be shown in about 20 runs,
$ (set -e; while true; do make check RUNTESTFLAGS="--target_board=native-gdbserver random-signal.exp"; done)
In the test, the program is being single-stepped for software watchpoint,
and in each internal stop, python unwinder sniffer is used,
#0 pyuw_sniffer (self=<optimised out>, this_frame=<optimised out>, cache_ptr=0xd554f8) at /home/yao/SourceCode/gnu/gdb/git/gdb/python/py-unwind.c:608
#1 0x00000000006a10ae in frame_unwind_try_unwinder (this_frame=this_frame@entry=0xd554e0, this_cache=this_cache@entry=0xd554f8, unwinder=0xecd540)
at /home/yao/SourceCode/gnu/gdb/git/gdb/frame-unwind.c:107
#2 0x00000000006a143f in frame_unwind_find_by_frame (this_frame=this_frame@entry=0xd554e0, this_cache=this_cache@entry=0xd554f8)
at /home/yao/SourceCode/gnu/gdb/git/gdb/frame-unwind.c:163
#3 0x000000000069dc6b in compute_frame_id (fi=0xd554e0) at /home/yao/SourceCode/gnu/gdb/git/gdb/frame.c:454
#4 get_prev_frame_if_no_cycle (this_frame=this_frame@entry=0xd55410) at /home/yao/SourceCode/gnu/gdb/git/gdb/frame.c:1781
#5 0x000000000069fdb9 in get_prev_frame_always_1 (this_frame=0xd55410) at /home/yao/SourceCode/gnu/gdb/git/gdb/frame.c:1955
#6 get_prev_frame_always (this_frame=this_frame@entry=0xd55410) at /home/yao/SourceCode/gnu/gdb/git/gdb/frame.c:1971
#7 0x00000000006a04b1 in get_prev_frame (this_frame=this_frame@entry=0xd55410) at /home/yao/SourceCode/gnu/gdb/git/gdb/frame.c:2213
when GDB goes to python extension, or other language extension, the
SIGINT handler is changed, and is restored when GDB leaves extension
language. GDB only stays in extension language for a very short period
in this case, but if ctrl-c is pressed at that moment, python extension
will handle the SIGINT, and exceptions.KeyboardInterrupt is shown.
Language extension is used in GDB side rather than inferior side,
so GDB should only change SIGINT handler for extension language when
the terminal is ours (not inferior's). This is what this patch does.
With this patch applied, I run random-signal.exp in a loop for 18
hours, and no fail is shown.
gdb:
2016-01-08 Yao Qi <yao.qi@linaro.org>
* extension.c: Include target.h.
(set_active_ext_lang): Only call install_gdb_sigint_handler,
check_quit_flag, and set_quit_flag if target_terminal_is_ours
returns false.
(restore_active_ext_lang): Likewise.
* target.c (target_terminal_is_ours): New function.
* target.h (target_terminal_is_ours): Declare.
|
|
gdb/ChangeLog:
Update year range in copyright notice of all files.
|
|
When testing with "maint set target-non-stop on", a few
threading-related tests expose an issue that requires new RSP packets.
Say there are 3 threads running, 1-3. If GDB tries to stop thread 1,
2 and 3, and then waits for their stops, but meanwhile say, thread 2
exits, GDB hangs forever waiting for a stop for thread 2 that won't
ever happen.
This patch fixes the issue by adding support for thread exit events to
the protocol. However, we don't want these always enabled, as they're
useless most of the time, and would slow down remote debugging. So I
made it so that GDB can enable/disable them, and then made gdb do that
around the cases that need it, which currently is only
infrun.c:stop_all_threads.
In turn, if we have thread exit events, then the extra "thread x
exited" traffic slows down attach-many-short-lived-threads.exp enough
that gdb has trouble keeping up with new threads that are spawned
while gdb tries to stop existing ones. To fix that I added support
for the counterpart thread created events too. Enabling those when we
try to stop threads ensures that new threads never get a chance to
themselves start new threads, killing the race.
gdb/doc/ChangeLog:
2015-11-30 Pedro Alves <palves@redhat.com>
* gdb.texinfo (Remote Configuration): List "set/show remote
thread-events" command in configuration table.
(Stop Reply Packets): Document "T05 create" stop
reason and 'w' stop reply.
(General Query Packets): Document QThreadEvents packet. Document
QThreadEvents qSupported feature.
gdb/gdbserver/ChangeLog:
2015-11-30 Pedro Alves <palves@redhat.com>
* linux-low.c (handle_extended_wait): Assert that the LWP's
waitstatus is TARGET_WAITKIND_IGNORE. If GDB wants to hear about
thread create events, leave the new child's status pending.
(linux_low_filter_event): If GDB wants to hear about thread exit
events, leave the LWP marked dead and don't delete it.
(linux_wait_for_event_filtered): Don't check for thread exit.
(filter_exit_event): New function.
(linux_wait_1): Use it, when returning an exit event.
(linux_resume_one_lwp_throw): Assert that the LWP's
waitstatus is TARGET_WAITKIND_IGNORE.
* remote-utils.c (prepare_resume_reply): Handle
TARGET_WAITKIND_THREAD_CREATED and TARGET_WAITKIND_THREAD_EXITED.
* server.c (report_thread_events): New global.
(handle_general_set): Handle QThreadEvents.
(handle_query) <qSupported>: Handle and report QThreadEvents+;
(handle_target_event): Handle TARGET_WAITKIND_THREAD_CREATED and
TARGET_WAITKIND_THREAD_EXITED.
* server.h (report_thread_events): Declare.
gdb/ChangeLog:
2015-11-30 Pedro Alves <palves@redhat.com>
* NEWS (New commands): Mention "set/show remote thread-events"
commands.
(New remote packets): Mention thread created/exited stop reasons
and QThreadEvents packet.
* infrun.c (disable_thread_events): New function.
(stop_all_threads): Disable/enable thread create/exit events.
Handle TARGET_WAITKIND_THREAD_EXITED.
(handle_inferior_event_1): Handle TARGET_WAITKIND_THREAD_CREATED
and TARGET_WAITKIND_THREAD_EXITED.
* remote.c (remove_child_of_pending_fork): Also remove threads of
threads that have TARGET_WAITKIND_THREAD_EXITED events.
(remote_parse_stop_reply): Handle "create" magic register. Handle
'w' stop reply.
(initialize_remote): Install remote_thread_events as
to_thread_events target hook.
(remote_thread_events): New function.
* target-delegates.c: Regenerate.
* target.c (target_thread_events): New function.
* target.h (struct target_ops) <to_thread_events>: New field.
(target_thread_events): Declare.
* target/waitstatus.c (target_waitstatus_to_string): Handle
TARGET_WAITKIND_THREAD_CREATED and TARGET_WAITKIND_THREAD_EXITED.
* target/waitstatus.h (enum target_waitkind)
<TARGET_WAITKIND_THREAD_CREATED, TARGET_WAITKIND_THREAD_EXITED):
New values.
|
|
This patch adds support for thread names in the remote protocol, and
updates gdb/gdbserver to use it. The information is added to the XML
description sent in response to the qXfer:threads:read packet.
gdb/ChangeLog:
* linux-nat.c (linux_nat_thread_name): Replace implementation by call
to linux_proc_tid_get_name.
* nat/linux-procfs.c (linux_proc_tid_get_name): New function,
implementation inspired by linux_nat_thread_name.
* nat/linux-procfs.h (linux_proc_tid_get_name): New declaration.
* remote.c (struct private_thread_info) <name>: New field.
(free_private_thread_info): Free name field.
(remote_thread_name): New function.
(thread_item_t) <name>: New field.
(clear_threads_listing_context): Free name field.
(start_thread): Get name xml attribute.
(thread_attributes): Add "name" attribute.
(remote_update_thread_list): Copy name field.
(init_remote_ops): Assign remote_thread_name callback.
* target.h (target_thread_name): Update comment.
* NEWS: Mention remote thread name support.
gdb/gdbserver/ChangeLog:
* linux-low.c (linux_target_ops): Use linux_proc_tid_get_name.
* server.c (handle_qxfer_threads_worker): Refactor to include thread
name in reply.
* target.h (struct target_ops) <thread_name>: New field.
(target_thread_name): New macro.
gdb/doc/ChangeLog:
* gdb.texinfo (Thread List Format): Mention thread names.
|
|
Since this code path returns a string owned by the target (we don't know how
it's allocated, could be a static read-only string), it's safer if we return
a constant string. If, for some reasons, the caller wishes to modify the
string, it should make itself a copy.
gdb/ChangeLog:
* linux-nat.c (linux_nat_thread_name): Constify return value.
* target.h (struct target_ops) <to_thread_name>: Likewise.
(target_thread_name): Likewise.
* target.c (target_thread_name): Likewise.
* target-delegates.c (debug_thread_name): Regenerate.
* python/py-infthread.c (thpy_get_name): Constify local variables.
* thread.c (print_thread_info): Likewise.
(thread_find_command): Likewise.
|
|
Fixes:
src/gdb/remote.c: In function ‘void remote_unpush_target()’:
src/gdb/remote.c:4610:45: error: invalid conversion from ‘int’ to ‘strata’ [-fpermissive]
pop_all_targets_above (process_stratum - 1);
^
In file included from src/gdb/inferior.h:38:0,
from src/gdb/remote.c:25:
src/gdb/target.h:2299:13: error: initializing argument 1 of ‘void pop_all_targets_above(strata)’ [-fpermissive]
extern void pop_all_targets_above (enum strata above_stratum);
^
I used to carry a patch in the C++ branch that just did:
- pop_all_targets_above (process_stratum - 1);
+ pop_all_targets_above ((enum strata) (process_stratum - 1));
But then thought that maybe adding a routine that does exactly what we
need results in clearer code. This is the result.
gdb/ChangeLog:
2015-11-19 Pedro Alves <palves@redhat.com>
* remote.c (remote_unpush_target): Use
pop_all_targets_at_and_above instead of pop_all_targets_above.
* target.c (unpush_target_and_assert): New function, factored out
from ...
(pop_all_targets_above): ... here.
(pop_all_targets_at_and_above): New function.
* target.h (pop_all_targets_at_and_above): Declare.
|
|
Fixes:
/home/simark/src/binutils-gdb/gdb/ppc-linux-nat.c: In function ‘int ppc_linux_insert_mask_watchpoint(target_ops*, CORE_ADDR, CORE_ADDR, int)’:
/home/simark/src/binutils-gdb/gdb/ppc-linux-nat.c:1730:40: error: invalid conversion from ‘int’ to ‘target_hw_bp_type’ [-fpermissive]
p.trigger_type = get_trigger_type (rw);
^
gdb/ChangeLog:
* ppc-linux-nat.c (ppc_linux_insert_mask_watchpoint): Change
type of rw to enum target_hw_bp_type.
(ppc_linux_remove_mask_watchpoint): Likewise.
* target.c (target_insert_mask_watchpoint): Likewise.
(target_remove_mask_watchpoint): Likewise.
* target.h (target_insert_mask_watchpoint): Likewise.
(target_remove_mask_watchpoint): Likewise.
(struct target_ops) <to_insert_mask_watchpoint>: Likewise.
(struct target_ops) <to_remove_mask_watchpoint>: Likewise.
* target-delegates.c: Regenerate.
|
|
Add a new target method to_record_will_replay to query if there is a record
target that will replay at least one thread matching the argument PTID if it
were executed in the argument execution direction.
gdb/
* record-btrace.c ((record_btrace_will_replay): New.
(init_record_btrace_ops): Initialize to_record_will_replay.
* record-full.c ((record_full_will_replay): New.
(init_record_full_ops): Initialize to_record_will_replay.
* target-delegates.c: Regenerated.
* target.c (target_record_will_replay): New.
* target.h (struct target_ops) <to_record_will_replay>: New.
(target_record_will_replay): New.
Signed-off-by: Markus Metzger <markus.t.metzger@intel.com>
|
|
Add a new target method to_record_stop_replaying to stop replaying.
gdb/
* record-btrace.c (record_btrace_resume): Call
target_record_stop_replaying.
(record_btrace_stop_replaying_all): New.
(init_record_btrace_ops): Initialize to_record_stop_replaying.
* record-full.c (record_full_stop_replaying): New.
(init_record_full_ops ): Initialize to_record_stop_replaying.
* target-delegates.c: Regenerated.
* target.c (target_record_stop_replaying): New.
* target.h (struct target_ops) <to_record_stop_replaying>: New.
(target_record_stop_replaying): New.
|
|
The to_record_is_replaying target method is used to query record targets if
they are replaying. This is currently interpreted as "is any thread being
replayed".
Add a PTID argument and change the interpretation to "is any thread matching
PTID being replayed".
Change all users to pass minus_one_ptid to preserve the old meaning.
The record full target does not really support multi-threading and ignores
the PTID argument.
gdb/
* record-btrace.c (record_btrace_is_replaying): Add ptid argument.
Update users to pass minus_one_ptid.
* record-full.c (record_full_is_replaying): Add ptid argument (ignored).
* record.c (cmd_record_delete): Pass inferior_ptid to
target_record_is_replaying.
* target-delegates.c: Regenerated.
* target.c (target_record_is_replaying): Add ptid argument.
* target.h (struct target_ops) <to_record_is_replaying>: Add ptid
argument.
(target_record_is_replaying): Add ptid argument.
|
|
Nowadays, GDB only knows whether architecture supports hardware single
step or software single step (through gdbarch hook software_single_step),
and for a given instruction or instruction sequence, GDB knows how to
do single step (hardware or software). However, GDB doesn't know whether
the target supports hardware single step. It is possible that the
architecture doesn't support hardware single step, such as arm, but
the target supports, such as simulator. This was discussed in this
thread https://www.sourceware.org/ml/gdb/2009-12/msg00033.html before.
I encounter this problem for aarch64 multi-arch support. When aarch64
debugs arm program, gdbarch is arm, so software single step is still
used. However, the underneath linux kernel does support hardware
single step, so IWBN to use it.
This patch is to add a new target_ops hook to_can_do_single_step, and
only use it in arm_linux_software_single_step to decide whether or not
to use hardware single step. On the native aarch64 linux target, 1 is
returned. On other targets, -1 is returned. On the remote target, if
the target supports s and S actions in the vCont? reply, then target
can do single step. However, old GDBserver will send s and S in the
reply to vCont?, which will confuse new GDB. For example, old GDBserver
on arm-linux will send s and S in the reply to vCont?, but it doesn't
support hardware single step. On the other hand, new GDBserver, on
arm-linux for example, will not send s and S in the reply to vCont?,
but old GDB thinks it doesn't support vCont packet at all. In order
to address this problem, I add a new qSupported feature vContSupported,
which indicates GDB wants to know the supported actions in the reply
to vCont?, and qSupported response contains vContSupported if the
stub is able tell supported vCont actions in the reply of vCont?.
If the patched GDB talks with patched GDBserver on x86, the RSP traffic
is like this:
-> $qSupported:...+;vContSupported+
<- ...+;vContSupported+
...
-> $vCont?
<- vCont;c;C;t;s;S;r
then, GDB knows the stub can do single step, and may stop using software
single step even the architecture doesn't support hardware single step.
If the patched GDB talks with patched GDBserver on arm, the last vCont?
reply will become:
<- vCont;c;C;t
GDB thinks the target doesn't support single step, so it will use software
single step.
If the patched GDB talks with unpatched GDBserver, the RSP traffic is like
this:
-> $qSupported:...+;vContSupported+
<- ...+
...
-> $vCont?
<- vCont;c;C;t;s;S;r
although GDBserver returns s and S, GDB still thinks GDBserver may not
support single step because it doesn't support vContSupported.
If the unpatched GDB talks with patched GDBserver on x86, the RSP traffic
is like:
-> $qSupported:...+;
<- ...+;vContSupported+
...
-> $vCont?
<- vCont;c;C;t;s;S;r
Since GDB doesn't sent vContSupported in the qSupported feature, GDBserver
sends s and S regardless of the support of hardware single step.
gdb:
2015-09-15 Yao Qi <yao.qi@linaro.org>
* aarch64-linux-nat.c (aarch64_linux_can_do_single_step): New
function.
(_initialize_aarch64_linux_nat): Install it to to_can_do_single_step.
* arm-linux-tdep.c (arm_linux_software_single_step): Return 0
if target_can_do_single_step returns 1.
* remote.c (struct vCont_action_support) <s, S>: New fields.
(PACKET_vContSupported): New enum.
(remote_protocol_features): New element for vContSupported.
(remote_query_supported): Append "vContSupported+".
(remote_vcont_probe): Remove support_s and support_S, use
rs->supports_vCont.s and rs->supports_vCont.S instead. Disable
vCont packet if c and C actions are not supported.
(remote_can_do_single_step): New function.
(init_remote_ops): Install it to to_can_do_single_step.
(_initialize_remote): Call add_packet_config_cmd.
* target.h (struct target_ops) <to_can_do_single_step>: New field.
(target_can_do_single_step): New macro.
* target-delegates.c: Re-generated.
gdb/gdbserver:
2015-09-15 Yao Qi <yao.qi@linaro.org>
* server.c (vCont_supported): New global variable.
(handle_query): Set vCont_supported to 1 if "vContSupported+"
matches. Append ";vContSupported+" to own_buf.
(handle_v_requests): Append ";s;S" to own_buf if target supports
hardware single step or vCont_supported is false.
(capture_main): Set vCont_supported to zero.
gdb/doc:
2015-09-15 Yao Qi <yao.qi@linaro.org>
* gdb.texinfo (General Query Packets): Add vContSupported to
tables of 'gdbfeatures' and 'stub features' supported in the
qSupported packet, as well as to the list containing stub
feature details.
|
|
This patch implements support for exec events on extended-remote Linux
targets. Follow-exec-mode and rerun behave as expected. Catchpoints and
test updates are implemented in subsequent patches.
This patch was derived from a patch posted last October:
https://sourceware.org/ml/gdb-patches/2014-10/msg00877.html.
It was originally based on some work done by Luis Machado in 2013.
IMPLEMENTATION
----------------
Exec events are enabled via ptrace options.
When an exec event is detected by gdbserver, the existing process
data, along with all its associated lwp and thread data, is deleted
and replaced by data for a new single-threaded process. The new
process data is initialized with the appropriate parts of the state
of the execing process. This approach takes care of several potential
pitfalls, including:
* deleting the data for an execing non-leader thread before any
wait/sigsuspend occurs
* correctly initializing the architecture of the execed process
We then report the exec event using a new RSP stop reason, "exec".
When GDB receives an "exec" event, it saves the status in the event
structure's target_waitstatus field, like what is done for remote fork
events. Because the original and execed programs may have different
architectures, we skip parsing the section of the stop reply packet
that contains register data. The register data will be retrieved
later after the inferior's architecture has been set up by
infrun.c:follow_exec.
At that point the exec event is handled by the existing event handling
in GDB. However, a few changes were necessary so that
infrun.c:follow_exec could accommodate the remote target.
* Where follow-exec-mode "new" is handled, we now call
add_inferior_with_spaces instead of add_inferior with separate calls
to set up the program and address spaces. The motivation for this
is that add_inferior_with_spaces also sets up the initial architecture
for the inferior, which is needed later by target_find_description
when it calls target_gdbarch.
* We call a new target function, target_follow_exec. This function
allows us to store the execd_pathname in the inferior, instead of
using the static string remote_exec_file from remote.c. The static
string didn't work for follow-exec-mode "new", since once you switched
to the execed program, the original remote exec-file was lost. The
execd_pathname is now stored in the inferior's program space as a
REGISTRY field. All of the requisite mechanisms for this are
defined in remote.c.
gdb/gdbserver/ChangeLog:
* linux-low.c (linux_mourn): Static declaration.
(linux_arch_setup): Move in front of
handle_extended_wait.
(linux_arch_setup_thread): New function.
(handle_extended_wait): Handle exec events. Call
linux_arch_setup_thread. Make event_lwp argument a
pointer-to-a-pointer.
(check_zombie_leaders): Do not check stopped threads.
(linux_low_ptrace_options): Add PTRACE_O_TRACEEXEC.
(linux_low_filter_event): Add lwp and thread for exec'ing
non-leader thread if leader thread has been deleted.
Refactor code into linux_arch_setup_thread and call it.
Pass child lwp pointer by reference to handle_extended_wait.
(linux_wait_for_event_filtered): Update comment.
(linux_wait_1): Prevent clobbering exec event status.
(linux_supports_exec_events): New function.
(linux_target_ops) <supports_exec_events>: Initialize new member.
* lynx-low.c (lynx_target_ops) <supports_exec_events>: Initialize
new member.
* remote-utils.c (prepare_resume_reply): New stop reason 'exec'.
* server.c (report_exec_events): New global variable.
(handle_query): Handle qSupported query for exec-events feature.
(captured_main): Initialize report_exec_events.
* server.h (report_exec_events): Declare new global variable.
* target.h (struct target_ops) <supports_exec_events>: New
member.
(target_supports_exec_events): New macro.
* win32-low.c (win32_target_ops) <supports_exec_events>:
Initialize new member.
gdb/ChangeLog:
* infrun.c (follow_exec): Use process-style ptid for
exec message. Call add_inferior_with_spaces and
target_follow_exec.
* nat/linux-ptrace.c (linux_supports_traceexec): New function.
* nat/linux-ptrace.h (linux_supports_traceexec): Declare.
* remote.c (remote_pspace_data): New static variable.
(remote_pspace_data_cleanup): New function.
(get_remote_exec_file): New function.
(set_remote_exec_file_1): New function.
(set_remote_exec_file): New function.
(show_remote_exec_file): New function.
(remote_exec_file): Delete static variable.
(anonymous enum) <PACKET_exec_event_feature> New
enumeration constant.
(remote_protocol_features): Add entry for exec-events feature.
(remote_query_supported): Add client side of qSupported query
for exec-events feature.
(remote_follow_exec): New function.
(remote_parse_stop_reply): Handle 'exec' stop reason.
(extended_remote_run, extended_remote_create_inferior): Call
get_remote_exec_file and set_remote_exec_file_1.
(init_extended_remote_ops) <to_follow_exec>: Initialize new
member.
(_initialize_remote): Call
register_program_space_data_with_cleanup. Call
add_packet_config_cmd for remote exec-events feature.
Modify call to add_setshow_string_noescape_cmd for exec-file
to use new functions set_remote_exec_file and
show_remote_exec_file.
* target-debug.h, target-delegates.c: Regenerated.
* target.c (target_follow_exec): New function.
* target.h (struct target_ops) <to_follow_exec>: New member.
(target_follow_exec): Declare new function.
|
|
Nothing ever uses this.
gdb/ChangeLog:
2015-09-09 Pedro Alves <palves@redhat.com>
* inf-loop.c (inferior_event_handler): Delete INF_TIMER case.
* target.h (enum inferior_event_type) <INF_TIMER>: Delete.
|
|
Nothing uses thread continuations anymore.
(inferior continuations are still used by the attach command.)
gdb/ChangeLog:
2015-09-09 Pedro Alves <palves@redhat.com>
* continuations.c (add_continuation, restore_thread_cleanup)
(do_all_continuations_ptid, do_all_continuations_thread_callback)
(do_all_continuations_thread, do_all_continuations)
(discard_all_continuations_thread_callback)
(discard_all_continuations_thread, discard_all_continuations)
(add_intermediate_continuation)
(do_all_intermediate_continuations_thread_callback)
(do_all_intermediate_continuations_thread)
(do_all_intermediate_continuations)
(discard_all_intermediate_continuations_thread_callback)
(discard_all_intermediate_continuations_thread)
(discard_all_intermediate_continuations): Delete.
* continuations.h (add_continuation, do_all_continuations)
(do_all_continuations_thread, discard_all_continuations)
(discard_all_continuations_thread, add_intermediate_continuation)
(do_all_intermediate_continuations)
(do_all_intermediate_continuations_thread)
(discard_all_intermediate_continuations)
(discard_all_intermediate_continuations_thread): Delete
declarations.
* event-top.c (stdin_event_handler): Delete references to
continuations.
* gdbthread.h (struct thread_info): Delete continuations and
intermediate_continuations fields.
* inf-loop.c (inferior_event_handler): Remove references to
continuations.
* infrun.c (infrun_thread_stop_requested_callback): Remove
references to continuations.
* target.h (enum inferior_event_type) <INF_EXEC_CONTINUE>: Delete.
* thread.c: Don't include "continuations.h".
(clear_thread_inferior_resources): Remove references to
continuations.
|
|
This patch makes the execution control code use largely the same
mechanisms in both sync- and async-capable targets. This means using
continuations and use the event loop to react to target events on sync
targets as well. The trick is to immediately mark infrun's event loop
source after resume instead of calling wait_for_inferior. Then
fetch_inferior_event is adjusted to do a blocking wait on sync
targets.
Tested on x86_64 Fedora 20, native and gdbserver, with and without
"maint set target-async off".
gdb/ChangeLog:
2015-09-09 Pedro Alves <palves@redhat.com>
* breakpoint.c (bpstat_do_actions_1, until_break_command): Don't
check whether the target can async.
* inf-loop.c (inferior_event_handler): Only call target_async if
the target can async.
* infcall.c: Include top.h and interps.h.
(run_inferior_call): For the interpreter to sync mode while
running the infcall. Call wait_sync_command_done instead of
wait_for_inferior plus normal_stop.
* infcmd.c (prepare_execution_command): Don't check whether the
target can async when running in the foreground.
(step_1): Delete synchronous case handling.
(step_once): Always install a continuation, even in sync mode.
(until_next_command, finish_forward): Don't check whether the
target can async.
(attach_command_post_wait, notice_new_inferior): Always install a
continuation, even in sync mode.
* infrun.c (mark_infrun_async_event_handler): New function.
(proceed): In sync mode, mark infrun's event source instead of
waiting for events here.
(fetch_inferior_event): If the target can't async, do a blocking
wait.
(prepare_to_wait): In sync mode, mark infrun's event source.
(infrun_async_inferior_event_handler): No longer bail out if the
target can't async.
* infrun.h (mark_infrun_async_event_handler): New declaration.
* linux-nat.c (linux_nat_wait_1): Remove calls to
set_sigint_trap/clear_sigint_trap.
(linux_nat_terminal_inferior): No longer check whether the target
can async.
* mi/mi-interp.c (mi_on_sync_execution_done): Update and simplify
comment.
(mi_execute_command_input_handler): No longer check whether the
target is async. Update and simplify comment.
* target.c (default_target_wait): New function.
* target.h (struct target_ops) <to_wait>: Now defaults to
default_target_wait.
(default_target_wait): Declare.
* top.c (wait_sync_command_done): New function, factored out from
...
(maybe_wait_sync_command_done): ... this.
* top.h (wait_sync_command_done): Declare.
* target-delegates.c: Regenerate.
|
|
Currently, when remote debugging, if you type Ctrl-C just while the
target stopped for an internal event, and GDB is busy doing something
that takes a while (e.g., fetching chunks of a shared library off of
the target, with vFile, to process ELF headers and debug info), the
Ctrl-C is lost.
The patch hooks up the QUIT macro to a new target method that lets the
target react to the double-Ctrl-C before the event loop is reached,
which allows reacting to a double-Ctrl-C even when GDB is busy doing
some long operation and not waiting for a stop reply. That end result
is:
(gdb) c
Continuing.
^C
^C
Interrupted while waiting for the program.
Give up waiting? (y or n) y
Quit
(gdb) info threads
Id Target Id Frame
* 1 Thread 11673 0x00007ffff7deb240 in _dl_debug_state () from target:/lib64/ld-linux-x86-64.so.2
(gdb)
If, however, GDB is waiting for a stop reply (because the target has
been resumed, with e.g., vCont;c), but the target isn't responding, we
now get:
(gdb) c
Continuing.
^C
^C
The target is not responding to interrupt requests.
Stop debugging it? (y or n) y
Disconnected from target.
(gdb) info threads
No threads.
This offers to disconnect, because when we're waiting for a stop
reply, there's nothing else we can send the target other than an
interrupt request. And if that doesn't work, there's nothing else we
can do.
The Ctrl-C is presently lost because until we get to a user-visible
stop, the SIGINT handler that is installed is the one that forwards
the interrupt to the remote side, with the \003 "packet" [1]. But,
gdbserver ignores an interrupt request if the program is stopped.
Still, even if it didn't, the server can only report back a
stop-because-of-SIGINT when the program is next resumed. And it may
take a while to actually re-resume the target.
[1] - In the old sync days, the remote target would react to a
double-Ctrl-C by asking users whether they wanted to give up waiting
and disconnect. The code is still there, but it it isn't reacheable
on most hosts, which support serial connections in async mode
(probably only DJGPP doesn't). Even then, in sync mode, remote.c's
SIGINT handler is only installed while the target is resumed, and is
removed as soon as the target sends back a stop reply. That means
that a Ctrl-C just while GDB is processing an internal event can end
up with an odd "Quit" at the prompt instead of "Program stopped by
SIGINT". In contrast, in async mode, remote.c's SIGINT handler is set
up as long as target_terminal_inferior or
target_terminal_ours_for_output are in effect (IOW, until we get a
user-visible stop and call target_terminal_ours), so the user
shouldn't get back a spurious Quit. However, it's still desirable to
be able to interrupt a long-running GDB operation, if GDB takes a
while to re-resume the target or get back to the event loop.
Tested on x86_64 Fedora 20.
gdb/ChangeLog:
2015-08-24 Pedro Alves <palves@redhat.com>
* defs.h (maybe_quit): Declare.
(QUIT): Now calls maybe_quit.
* event-loop.c (clear_async_signal_handler)
(async_signal_handler_is_marked): New functions.
* event-loop.h (async_signal_handler_is_marked)
(clear_async_signal_handler): New declarations.
* remote.c (remote_check_pending_interrupt): New function.
(interrupt_query): Use make_cleanup_restore_target_terminal. No
longer check whether the target is async. If waiting for a stop
reply, and a Ctrl-C as been sent to the target, offer to
disconnect, and throw TARGET_CLOSE_ERROR instead of a quit.
Otherwise do not disconnect and throw a quit.
(_initialize_remote): Install remote_check_pending_interrupt as
to_check_pending_interrupt.
* target.c (target_check_pending_interrupt): New function.
* target.h (struct target_ops) <to_check_pending_interrupt>: New
field.
(target_check_pending_interrupt): New declaration.
* utils.c (maybe_quit): New function.
* target-delegates.c: Regenerate.
|
|
GDB provides no indicator of progress during file operations, and can
appear to have locked up during slow remote transfers. This commit
updates GDB to print a warning each time a file is accessed over RSP.
An additional message detailing how to avoid remote transfers is
printed for the first transfer only.
gdb/ChangeLog:
* target.h (struct target_ops) <to_fileio_open>: New argument
warn_if_slow. Update comment. All implementations updated.
(target_fileio_open_warn_if_slow): New declaration.
* target.c (target_fileio_open): Renamed as...
(target_fileio_open_1): ...this. New argument warn_if_slow.
Pass warn_if_slow to implementation. Update debug printing.
(target_fileio_open): New function.
(target_fileio_open_warn_if_slow): Likewise.
* gdb_bfd.c (gdb_bfd_iovec_fileio_open): Use new function
target_fileio_open_warn_if_slow.
gdb/testsuite/ChangeLog:
* gdb.trace/pending.exp: Cope with remote transfer warnings.
|
|
With "maint set target-non-stop on" we get:
@@ -66,13 +66,16 @@ Continuing.
interrupt
(gdb) PASS: gdb.base/interrupt-noterm.exp: interrupt
-Program received signal SIGINT, Interrupt.
-PASS: gdb.base/interrupt-noterm.exp: inferior received SIGINT
-testcase src/gdb/testsuite/gdb.base/interrupt-noterm.exp completed in 0 seconds
+[process 12119] #1 stopped.
+0x0000003615ebc6d0 in __nanosleep_nocancel () at ../sysdeps/unix/syscall-template.S:81
+81 T_PSEUDO (SYSCALL_SYMBOL, SYSCALL_NAME, SYSCALL_NARGS)
+FAIL: gdb.base/interrupt-noterm.exp: inferior received SIGINT (timeout)
+testcase src/gdb/testsuite/gdb.base/interrupt-noterm.exp completed in 10 seconds
That is, we get "[$thread] #1 stopped" instead of SIGINT.
The issue is that we don't currently distinguish send
"interrupt/ctrl-c" to target terminal vs "stop/pause" thread well;
both cases go through "target_stop".
And then, the native Linux backend (linux-nat.c) implements
target_stop with SIGSTOP in non-stop mode, and SIGINT in all-stop
mode. Since "maint set target-non-stop on" forces the backend to be
always running in non-stop mode, even though the user-visible behavior
is "set non-stop" is "off", "interrupt" causes a SIGSTOP instead of
the SIGINT the test expects.
Fix this by introducing a target_interrupt method to use in the
"interrupt/ctrl-c" case, so "set non-stop off" can always work the
same irrespective of "maint set target-non-stop on/off". I'm
explictly considering changing the "set non-stop on" behavior as out
of scope here.
Most of the patch is an across-the-board rename of to_stop hook
implementations to to_interrupt. The only targets where something
more than a rename is being done are linux-nat.c and remote.c, which
are the only targets that support async, and thus are the only ones
the core side calls target_stop on.
gdb/ChangeLog:
2015-08-07 Pedro Alves <palves@redhat.com>
* darwin-nat.c (darwin_stop): Rename to ...
(darwin_interrupt): ... this.
(_initialize_darwin_inferior): Adjust.
* gnu-nat.c (gnu_stop): Delete.
(gnu_target): Don't install gnu_stop.
* inf-ptrace.c (inf_ptrace_stop): Rename to ...
(inf_ptrace_interrupt): ... this.
(inf_ptrace_target): Adjust.
* infcmd.c (interrupt_target_1): Use target_interrupt instead of
target_stop.
* linux-nat (linux_nat_stop): Rename to ...
(linux_nat_interrupt): ... this.
(linux_nat_stop): Reimplement.
(linux_nat_add_target): Install linux_nat_interrupt.
* nto-procfs.c (nto_interrupt_twice): Rename to ...
(nto_handle_sigint_twice): ... this.
(nto_interrupt): Rename to ...
(nto_handle_sigint): ... this. Call target_interrupt instead of
target_stop.
(procfs_wait): Adjust.
(procfs_stop): Rename to ...
(procfs_interrupt): ... this.
(init_procfs_targets): Adjust.
* procfs.c (procfs_stop): Rename to ...
(procfs_interrupt): ... this.
(procfs_target): Adjust.
* remote-m32r-sdi.c (m32r_stop): Rename to ...
(m32r_interrupt): ... this.
(init_m32r_ops): Adjust.
* remote-sim.c (gdbsim_stop_inferior): Rename to ...
(gdbsim_interrupt_inferior): ... this.
(gdbsim_stop): Rename to ...
(gdbsim_interrupt): ... this.
(gdbsim_cntrl_c): Adjust.
(init_gdbsim_ops): Adjust.
* remote.c (sync_remote_interrupt): Adjust comments.
(remote_stop_as): Rename to ...
(remote_interrupt_as): ... this.
(remote_stop): Adjust comment.
(remote_interrupt): New function.
(init_remote_ops): Install remote_interrupt.
* target.c (target_interrupt): New function.
* target.h (struct target_ops) <to_interrupt>: New field.
(target_interrupt): New declaration.
* windows-nat.c (windows_stop): Rename to ...
(windows_interrupt): ... this.
* target-delegates.c: Regenerate.
|
|
This finally implements user-visible all-stop mode running with the
target_ops backend always in non-stop mode. This is a stepping stone
towards finer-grained control of threads, being able to do interesting
things like thread groups, associating groups with breakpoints, etc.
From the user's perspective, all-stop mode is really just a special
case of being able to stop and resume specific sets of threads, so it
makes sense to do this step first.
With this, even in all-stop, the target is no longer in charge of
stopping all threads before reporting an event to the core -- the core
takes care of it when it sees fit. For example, when "next"- or
"step"-ing, we can avoid stopping and resuming all threads at each
internal single-step, and instead only stop all threads when we're
about to present the stop to the user.
The implementation is almost straight forward, as the heavy lifting
has been done already in previous patches. Basically, we replace
checks for "set non-stop on/off" (the non_stop global), with calls to
a new target_is_non_stop_p function. In a few places, if "set
non-stop off", we stop all threads explicitly, and in a few other
places we resume all threads explicitly, making use of existing
methods that were added for teaching non-stop to step over breakpoints
without displaced stepping.
This adds a new "maint set target-non-stop on/off/auto" knob that
allows both disabling the feature if we find problems, and
force-enable it for development (useful when teaching a target about
this. The default is "auto", which means the feature is enabled if a
new target method says it should be enabled. The patch implements the
method in linux-nat.c, just for illustration, because it still returns
false. We'll need a few follow up fixes before turning it on by
default. This is a separate target method from indicating regular
non-stop support, because e.g., while e.g., native linux-nat.c is
close to regression free with all-stop-non-stop (with following
patches will fixing the remaining regressions), remote.c+gdbserver
will still need more fixing, even though it supports "set non-stop
on".
Tested on x86_64 Fedora 20, native, with and without "set displaced
off", and with and without "maint set target-non-stop on"; and also
against gdbserver.
gdb/ChangeLog:
2015-08-07 Pedro Alves <palves@redhat.com>
* NEWS: Mention "maint set/show target-non-stop".
* breakpoint.c (update_global_location_list): Check
target_is_non_stop_p instead of non_stop.
* infcmd.c (attach_command_post_wait, attach_command): Likewise.
* infrun.c (show_can_use_displaced_stepping)
(can_use_displaced_stepping_p, start_step_over_inferior):
Likewise.
(internal_resume_ptid): New function.
(resume): Use it.
(proceed): Check target_is_non_stop_p instead of non_stop. If in
all-stop mode but the target is always in non-stop mode, start all
the other threads that are implicitly resumed too.
(for_each_just_stopped_thread, fetch_inferior_event)
(adjust_pc_after_break, stop_all_threads): Check
target_is_non_stop_p instead of non_stop.
(handle_inferior_event): Likewise. Handle detach-fork in all-stop
with the target always in non-stop mode.
(handle_signal_stop) <random signal>: Check target_is_non_stop_p
instead of non_stop.
(switch_back_to_stepped_thread): Check target_is_non_stop_p
instead of non_stop.
(keep_going_stepped_thread): Use internal_resume_ptid.
(stop_waiting): If in all-stop mode, and the target is in non-stop
mode, stop all threads.
(keep_going_pass): Likewise, when starting a new in-line step-over
sequence.
* linux-nat.c (get_pending_status, select_event_lwp)
(linux_nat_filter_event, linux_nat_wait_1, linux_nat_wait): Check
target_is_non_stop_p instead of non_stop.
(linux_nat_always_non_stop_p): New function.
(linux_nat_stop): Check target_is_non_stop_p instead of non_stop.
(linux_nat_add_target): Install linux_nat_always_non_stop_p.
* target-delegates.c: Regenerate.
* target.c (target_is_non_stop_p): New function.
(target_non_stop_enabled, target_non_stop_enabled_1): New globals.
(maint_set_target_non_stop_command)
(maint_show_target_non_stop_command): New functions.
(_initilize_target): Install "maint set/show target-non-stop"
commands.
* target.h (struct target_ops) <to_always_non_stop_p>: New field.
(target_non_stop_enabled): New declaration.
(target_is_non_stop_p): New declaration.
gdb/doc/ChangeLog:
2015-08-07 Pedro Alves <palves@redhat.com>
* gdb.texinfo (Maintenance Commands): Document "maint set/show
target-non-stop".
|
|
That is, step past breakpoints by:
- pausing all threads
- removing breakpoint at PC
- single-step
- reinsert breakpoint
- restart threads
similarly to all-stop (with displaced stepping disabled). This allows
non-stop to work on targets/architectures without displaced stepping
support. That is, it makes displaced stepping an optimization instead
of a requirement. For example, in principle, all GNU/Linux ports
support non-stop mode at the target_ops level, but not all
corresponding gdbarch's implement displaced stepping. This should
make non-stop work for all (albeit, not as efficiently). And then
there are scenarios where even if the architecture supports displaced
stepping, we can't use it, because we e.g., don't find a usable
address to use as displaced step scratch pad. It should also fix
stepping past watchpoints on targets that have non-continuable
watchpoints in non-stop mode (e.g., PPC, untested). Running the
instruction out of line in the displaced stepping scratch pad doesn't
help that case, as the copied instruction reads/writes the same
watched memory... We can fix that too by teaching GDB to only remove
the watchpoint from the thread that we want to move past the
watchpoint (currently, removing a watchpoint always removes it from
all threads), but again, that can be considered an optimization; not
all targets would support it.
For those familiar with the gdb and gdbserver Linux target_ops
backends, the implementation should look similar, except it is done on
the core side. When we pause threads, we may find they stop with an
interesting event that should be handled later when the thread is
re-resumed, thus we store such events in the thread object, and mark
the event as pending. We should only consume pending events if the
thread is indeed resumed, thus we add a new "resumed" flag to the
thread object. At a later stage, we might add new target methods to
accelerate some of this, like "pause all threads", with corresponding
RSP packets, but we'd still need a fallback method for remote targets
that don't support such packets, so, again, that can be deferred as
optimization.
My _real_ motivation here is making it possible to reimplement
all-stop mode on top of the target always working on non-stop mode, so
that e.g., we can send RSP packets to a remote target even while the
target is running -- can't do that in the all-stop RSP variant, by
design).
Tested on x86_64 Fedora 20, with and without "set displaced off"
forced. The latter forces the new code paths whenever GDB needs to
step past a breakpoint.
gdb/ChangeLog:
2015-08-07 Pedro Alves <pedro@codesourcery.com>
* breakpoint.c (breakpoints_should_be_inserted_now): If any thread
has a pending status, return true.
* gdbthread.h: Include target/waitstatus.h.
(struct thread_suspend_state) <stop_reason, waitstatus_pending_p,
stop_pc>: New fields.
(struct thread_info) <resumed>: New field.
(set_resumed): Declare.
* infrun.c: Include "event-loop.h".
(infrun_async_inferior_event_token, infrun_is_async): New globals.
(infrun_async): New function.
(clear_step_over_info): Add debug output.
(displaced_step_in_progress_any_inferior): New function.
(displaced_step_fixup): New returns int.
(start_step_over): Handle in-line step-overs too. Assert the
thread is marked resumed.
(resume_cleanups): Clear the thread's resumed flag.
(resume): Set the thread's resumed flag. Return early if the
thread has a pending status. Allow stepping a breakpoint with no
signal.
(proceed): Adjust to check 'resumed' instead of 'executing'.
(clear_proceed_status_thread): If the thread has a pending status,
and that status is a finished step, discard the pending status.
(clear_proceed_status): Don't clear step_over_info here.
(random_pending_event_thread, do_target_wait): New functions.
(prepare_for_detach, wait_for_inferior, fetch_inferior_event): Use
do_target_wait.
(wait_one): New function.
(THREAD_STOPPED_BY): New macro.
(thread_stopped_by_watchpoint, thread_stopped_by_sw_breakpoint)
(thread_stopped_by_hw_breakpoint): New functions.
(switch_to_thread_cleanup, save_waitstatus, stop_all_threads): New
functions.
(handle_inferior_event): Also call set_resumed(false) on all
threads implicitly stopped by the event.
(restart_threads, resumed_thread_with_pending_status): New
functions.
(finish_step_over): If we were doing an in-line step-over before,
and no longer are after trying to start a new step-over, restart
all threads. If we have multiple threads with pending events,
save the current event and go through the event loop again.
(handle_signal_stop): Return early if finish_step_over returns
false.
<random signal>: If we get a signal while stepping over a
breakpoint in-line in non-stop mode, restart all threads. Clear
step_over_info before delivering the signal.
(keep_going_stepped_thread): Use internal_error instead of
gdb_assert. Mark the thread as resumed.
(keep_going_pass_signal): Assert the thread isn't already resumed.
If some other thread is doing an in-line step-over, defer the
resume. If we just started a new in-line step-over, stop all
threads. Don't clear step_over_info.
(infrun_async_inferior_event_handler): New function.
(_initialize_infrun): Create async event handler with
infrun_async_inferior_event_handler as callback.
(infrun_async): New declaration.
* target.c (target_async): New function.
* target.h (target_async): Declare macro and readd as function
declaration.
* target/waitstatus.h (enum target_stop_reason)
<TARGET_STOPPED_BY_SINGLE_STEP>: New value.
* thread.c (new_thread): Clear the new waitstatus field.
(set_resumed): New function.
|
|
Clarify that currently_stepping works at a higher level than
target_resume.
gdb/ChangeLog:
2015-08-07 Pedro Alves <palves@redhat.com>
* infrun.c (currently_stepping): Extend intro comment.
* target.h (target_resume): Extend intro comment.
|
|
This is a patch I extracted from Pedro's C++ branch. It contains the
most trivial enum fixes, where an integer type/value was used instead
of the appropriate enum type/value. It fixes many C++ errors, since
in C++ you can't mix integers and enums implicitely.
Regardless of the C++ conversion, I think this is a good cleanup to make
use of the appropriate enum types.
Regression-tested on native x86_64.
gdb/ChangeLog:
* aarch64-linux-nat.c (aarch64_linux_can_use_hw_breakpoint): Use enum
type or value instead of integer.
(aarch64_linux_insert_watchpoint): Likewise.
(aarch64_linux_remove_watchpoint): Likewise.
* ada-lang.c (ada_op_print_tab): Likewise.
* amd64-linux-tdep.c (amd64_canonicalize_syscall): Likewise.
(amd64_linux_syscall_record_common): Likewise.
* arch-utils.c (target_byte_order_user): Likewise.
(default_byte_order): Likewise.
* arm-linux-nat.c (arm_linux_can_use_hw_breakpoint): Likewise.
(arm_linux_get_hwbp_type): Likewise.
(arm_linux_hw_watchpoint_initialize): Likewise.
(arm_linux_insert_watchpoint): Likewise.
* arm-linux-tdep.c (arm_canonicalize_syscall): Likewise.
(arm_linux_syscall_record): Likewise.
* breakpoint.c (update_watchpoint): Likewise.
(breakpoint_here_p): Likewise.
(bpstat_print): Likewise.
(enable_breakpoint_disp): Likewise.
* c-lang.c (c_op_print_tab): Likewise.
* cli/cli-decode.c (add_info_alias): Likewise.
* d-lang.c (d_op_print_tab): Likewise.
* eval.c (evaluate_subexp_standard): Likewise.
* f-exp.y (dot_ops): Likewise.
(f77_keywords): Likewise.
* f-lang.c (f_op_print_tab): Likewise.
* go-lang.c (go_op_print_tab): Likewise.
* guile/scm-breakpoint.c (gdbscm_make_breakpoint): Likewise.
* guile/scm-cmd.c (gdbscm_make_command): Likewise.
* guile/scm-param.c (gdbscm_make_parameter): Likewise.
* guile/scm-pretty-print.c (gdbscm_apply_val_pretty_printer): Likewise.
* guile/scm-string.c (struct scm_to_stringn_data): Likewise.
(struct scm_from_stringn_data): Likewise.
* i386-linux-tdep.c (i386_canonicalize_syscall): Likewise.
* ia64-linux-nat.c (ia64_linux_insert_watchpoint): Likewise.
(ia64_linux_remove_watchpoint): Likewise.
(ia64_linux_can_use_hw_breakpoint): Likewise.
* infrun.c (print_stop_event): Likewise.
* jv-lang.c (java_op_print_tab): Likewise.
* linux-nat.c (linux_proc_xfer_partial): Likewise.
* linux-nat.h (struct lwp_info): Likewise.
* linux-thread-db.c (enable_thread_event): Likewise.
* m2-lang.c (m2_op_print_tab): Likewise.
* mi/mi-cmd-stack.c (mi_cmd_stack_list_locals): Likewise.
(mi_cmd_stack_list_variables): Likewise.
* mi/mi-main.c (mi_cmd_trace_frame_collected): Likewise.
* mi/mi-out.c (mi_table_begin): Likewise.
(mi_table_header): Likewise.
* mips-linux-nat.c (mips_linux_can_use_hw_breakpoint): Likewise.
(mips_linux_insert_watchpoint): Likewise.
(mips_linux_remove_watchpoint): Likewise.
* nat/mips-linux-watch.c (mips_linux_watch_type_to_irw): Likewise.
* nat/mips-linux-watch.h (struct mips_watchpoint): Likewise.
(mips_linux_watch_type_to_irw): Likewise.
* nto-procfs.c (procfs_can_use_hw_breakpoint): Likewise.
(procfs_insert_hw_watchpoint): Likewise.
(procfs_remove_hw_watchpoint): Likewise.
(procfs_hw_watchpoint): Likewise.
(procfs_can_use_hw_breakpoint): Likewise.
(procfs_remove_hw_watchpoint): Likewise.
(procfs_insert_hw_watchpoint): Likewise.
* p-lang.c (pascal_op_print_tab): Likewise.
* ppc-linux-nat.c (ppc_linux_can_use_hw_breakpoint): Likewise.
* ppc-linux-tdep.c (ppu2spu_unwind_register): Likewise.
* ppc-sysv-tdep.c (get_decimal_float_return_value): Likewise.
* procfs.c (procfs_can_use_hw_breakpoint): Likewise.
(procfs_insert_watchpoint): Likewise.
(procfs_remove_watchpoint): Likewise.
* psymtab.c (recursively_search_psymtabs): Likewise.
* remote-m32r-sdi.c (m32r_can_use_hw_watchpoint): Likewise.
(m32r_insert_watchpoint): Likewise.
* remote-mips.c (mips_can_use_watchpoint): Likewise.
(mips_insert_watchpoint): Likewise.
(mips_remove_watchpoint): Likewise.
* remote.c (watchpoint_to_Z_packet): Likewise.
(remote_insert_watchpoint): Likewise.
(remote_remove_watchpoint): Likewise.
(remote_check_watch_resources): Likewise.
* s390-linux-nat.c (s390_insert_watchpoint): Likewise.
(s390_remove_watchpoint): Likewise.
(s390_can_use_hw_breakpoint): Likewise.
* s390-linux-tdep.c (s390_gdbarch_init): Likewise.
* spu-linux-nat.c (spu_can_use_hw_breakpoint): Likewise.
* target.h (struct target_ops): Likewise.
* tilegx-tdep.c (tilegx_analyze_prologue): Likewise.
* ui-out.c (struct ui_out_hdr): Likewise.
(append_header_to_list): Likewise.
(get_next_header): Likewise.
(verify_field): Likewise.
(ui_out_begin): Likewise.
(ui_out_field_int): Likewise.
(ui_out_field_fmt_int): Likewise.
(ui_out_field_skip): Likewise.
(ui_out_field_string): Likewise.
(ui_out_field_fmt): Likewise.
* varobj.c (new_variable): Likewise.
* x86-nat.c (x86_insert_watchpoint): Likewise.
(x86_remove_watchpoint): Likewise.
(x86_can_use_hw_breakpoint): Likewise.
* xtensa-tdep.h (struct gdbarch_tdep): Likewise.
* inflow.c (enum gdb_has_a_terminal_flag_enum): Add name to
previously anonymous enumeration type..
* linux-record.h (enum gdb_syscall): Add gdb_sys_no_syscall
value.
* target-debug.h (target_debug_print_enum_target_hw_bp_type): New.
(target_debug_print_enum_bptype): New.
* target-delegates.c: Regenerate.
|