summaryrefslogtreecommitdiff
path: root/gdb/remote.c
Commit message (Collapse)AuthorAgeFilesLines
* gdb/qiyao2013-10-111-1/+1
| | | | Typo fix in my previous commit.
* gdb/qiyao2013-10-111-6/+33
| | | | | | | | | | | * remote.c (discard_pending_stop_replies_in_queue): Update declaration. (struct stop_reply) <rs>: New field. (remove_stop_reply_of_remote_state): New function. (discard_pending_stop_replies_in_queue): Add parameter 'rs'. Callers update. Pass remove_stop_reply_of_remote_state to QUEUE_iterate. (remote_parse_stop_reply): Initialize field 'rs'.
* Move pending_event to remote_notif_state.qiyao2013-10-041-32/+47
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This patch moves pending_event to remote_notif_state. All pending events are destroyed in remote_notif_state_xfree. However, discard_pending_stop_replies release pending event too, so the pending event of stop notification is released twice, we need some refactor here. We add a new function discard_pending_stop_replies_in_queue which only discard events in stop_reply_queue, and let remote_notif_state_xfree release pending event for all notif_client. After this change, discard_pending_stop_replies is only attached to ifnerior_exit observer, so the INF can't be NULL any more. The NULL checking is removed too. gdb: 2013-10-04 Yao Qi <yao@codesourcery.com> * remote-notif.h (REMOTE_NOTIF_ID): New enum. (struct notif_client) <pending_event>: Moved to struct remote_notif_state. <id>: New field. (struct remote_notif_state) <pending_event>: New field. (notif_event_xfree): Declare. * remote-notif.c (handle_notification): Adjust. (notif_event_xfree): New function. (do_notif_event_xfree): Call notif_event_xfree. (remote_notif_state_xfree): Call notif_event_xfree to free each element in field pending_event. * remote.c (discard_pending_stop_replies): Remove declaration. (discard_pending_stop_replies_in_queue): Declare. (remote_close): Call discard_pending_stop_replies_in_queue instead of discard_pending_stop_replies. (remote_start_remote): Adjust. (stop_reply_xfree): Call notif_event_xfree. (notif_client_stop): Adjust initialization. (remote_notif_remove_all): Rename it to ... (remove_stop_reply_for_inferior): ... this. Update comments. Don't check INF is NULL. (discard_pending_stop_replies): Return early if notif_state is NULL. Adjust. Don't check INF is NULL. (remote_notif_get_pending_events): Adjust. (discard_pending_stop_replies_in_queue): New function. (remote_wait_ns): Likewise.
* Move notif_queue and remote_async_get_pending_events_token to remote_stateqiyao2013-10-041-5/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This patch also removes notif_xfree, and don't pass it QUEUE_alloc, because we don't have to free notif_client when the remote_notif_state is freed. gdb: 2013-10-04 Yao Qi <yao@codesourcery.com> * remote-notif.c (DECLARE_QUEUE_P): Remove. (notif_queue): Remove. (remote_notif_process): Add one parameter 'notif_queue'. Update comments. Callers update. (remote_async_get_pending_events_token): Remove. (remote_notif_register_async_event_handler): Remove. (remote_notif_unregister_async_event_handler): Remove. (handle_notification): Add parameter 'notif_queue'. Update comments. Callers update. (notif_xfree): Remove. (remote_notif_state_allocate): New function. (remote_notif_state_xfree): New function. (_initialize_notif): Remove code to allocate queue. * remote-notif.h (DECLARE_QUEUE_P): Moved from remote-notif.c. (struct remote_notif_state): New. (handle_notification): Update declaration. (remote_notif_process): Likewise. (remote_notif_register_async_event_handler): Remove. (remote_notif_unregister_async_event_handler): Remove. (remote_notif_state_allocate): Declare. (remote_notif_state_xfree): Declare. * remote.c (struct remote_state) <notif_state>: New field. (remote_close): Don't call remote_notif_unregister_async_event_handler. Call remote_notif_state_xfree. (remote_open_1): Don't call remote_notif_register_async_event_handler. Call remote_notif_state_allocate.
* Fix regular /path/to/directory sysroots and target reported dll paths with ↵Pedro Alves2013-09-271-1/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | drive specs. I tried debugging a remote Windows program on Linux host, and pointed the sysroot to "/some/path/" rather than "remote:", and I found GDB couldn't find the dlls in the sysroot. If the dll name is "C:/Windows/system32/ntdll.dll", I end up with the sysroot+in_pathname concatenated this way: (top-gdb) p temp_pathname $1 = 0x228b690 "/some/pathC:/Windows/system32/ntdll.dll" ^^ That is, a directory separator is missing. This is a regression. The problem is that solib_find decides that since the target path has a drive spec, a separator is not necessary, which is clearly wrong in this case. That check was added in <https://sourceware.org/ml/gdb-patches/2013-06/msg00028.html>, to handle the case of sysroot being "remote:". This patch fixes that original issue in a different way. Instead of checking whether the path has a drive spec, check whether the sysroot is "remote:". The patch adds a table that helps visualize the cases that need a separator. I also confirmed the original issue is still handled as expected. That is, that "set sysroot remote:" still does the right thing. remote_filename_p returns true if the filename is prefixed with "remote:". In this case, we need to check whether the filename is exactly "remote:". I thought of different ways or either changing remote_filename_p or adding another convenience function to remote.c to avoid exposing the "remote:" prefix out of remote.c. But all attempts turned out adding lot of over needless complication. So the patch just exposes the prefix behind a new macro, which allows using a straighforward strcmp. gdb/ 2013-09-27 Pedro Alves <palves@redhat.com> * remote.h (REMOTE_SYSROOT_PREFIX): New define. (remote_filename_p): Add comment. * remote.c (remote_filename_p): Adjust to use REMOTE_SYSROOT_PREFIX. * solib.c (solib_find): When deciding whether we need to add a directory separator, check whether the sysroot is "remote:" instead of checking whether the patch has a drive spec. Add comments.
* remote.c: Remove unnecessary fields from 'struct stop_reply'.Pedro Alves2013-09-271-20/+11
| | | | | | | | | | | | | | | | | | I noticed these fields aren't really necessary -- if the T stop reply indicated any we have any special event, the fallthrough doesn't really do anything. Tested on x86_64 Fedora 17 w/ local gdbserver, and also confirmed "catch load" against a Windows gdbserver running under Wine, which exercises TARGET_WAITKIND_LOADED, still works as expected. gdb/ 2013-09-27 Pedro Alves <palves@redhat.com> * remote.c (struct stop_reply) <solibs_changed, replay_event>: Delete fields. (remote_parse_stop_reply): Adjust, setting event->ws.kind directly.
* remote.c: don't install a deprecated_xfer_memory hook.Pedro Alves2013-08-231-66/+17
| | | | | | | | | | | | | | | | | | | | | | There's no need for deprecated_xfer_memory nowadays. Memory access goes through target_xfer_partial/TARGET_OBJECT_MEMORY, etc. In fact, the remote target already handles that, and is deferring to the same helpers the deprecated_xfer_memory hook is. Basically, only a few adjustments to make these helper routines's interfaces closer to target_xfer_partial's were necessary. Tested on x86_64 Fedora 17 w/ gdbserver. gdb/ 2013-08-23 Pedro Alves <palves@redhat.com> * remote.c (remote_write_bytes_aux, remote_write_bytes) (remote_read_bytes): Change return type to LONGEST, and adjust to return a target_xfer_error on error. (remote_xfer_memory): Delete. (remote_flash_write): Change type of 'ret' local to LONGEST. (remote_xfer_partial, remote_xfer_partial): Adjust. (init_remote_ops): Don't install a deprecated_xfer_memory hook.
* move some static thread state into remote_stateTom Tromey2013-08-141-19/+23
| | | | | | | | | | | | | | | | | This moves a few static variables from thread-info functions into remote_state. Pedro said on irc that these functions implement the ancient thread-discovery method and that he wouldn't be surprised if they had rotted; nevertheless it seems safer to me to make them explicitly per-remote. This necessitated moving a couple of macros and a typedef earlier in the file. * remote.c (struct remote_state) <echo_nextthread, nextthread, resultthreadlist>: New fields. (OPAQUETHREADBYTES, threadref, MAXTHREADLISTRESULTS): Move earlier. (remote_get_threadlist, remote_threadlist_iterator): Use new fields. Remove static variables.
* move remote_stopped_by_watchpoint_p and remote_watch_data_address into ↵Tom Tromey2013-08-141-16/+17
| | | | | | | | | | | | | remote_state This moves the globals remote_stopped_by_watchpoint_p and remote_watch_data_address into remote_state. * remote.c (struct remote_state) <remote_stopped_by_watchpoint_p, remote_watch_data_address>: New fields. (remote_stopped_by_watchpoint_p, remote_watch_data_address): Remove. (process_stop_reply, remote_wait_as) (remote_check_watch_resources, remote_stopped_data_address): Update.
* move async_client_callback and async_client_context into remote_stateTom Tromey2013-08-141-7/+10
| | | | | | | | | | This moves async_client_callback and async_client_context into remote_state. * remote.c (struct remote_state) <async_client_callback, async_client_context>: New fields. (async_client_callback, async_client_context): Remove. (remote_async_serial_handler, remote_async): Update.
* move sizeof_pkt into remote_trace_findTom Tromey2013-08-141-3/+1
| | | | | | | | | | | | The global sizeof_pkt is only used in remote_trace_find, like so: reply = remote_get_noisy_reply (&(rs->buf), &sizeof_pkt); I think in this situation it is more correct to use the recorded size of the buffer. Otherwise it seems that some skew could result. * remote.c (sizeof_pkt): Remove. (remote_trace_find): Use rs->buf_size, not sizeof_pkt.
* move use_threadinfo_query and use_threadextra_query into struct remote_stateTom Tromey2013-08-141-17/+16
| | | | | | | | | | This moves the use_threadextra_query and use_threadinfo_query globals into remote_state. * remote.c (struct remote_state) <use_threadinfo_query, use_threadextra_query>: New fields. (remote_threads_info, remote_threads_extra_info) (remote_open_1): Update.
* move some statics from remote_read_qxfer into struct remote_stateTom Tromey2013-08-141-15/+15
| | | | | | | | | | This moves a few static variables out of remote_read_qxfer and into remote_state. * remote.c (struct remote_state) <finished_object, finished_annex, finished_offset>: New fields. (remote_read_qxfer): Use remote_state fields; remove static variables.
* push last_sent_step into struct remote_stateTom Tromey2013-08-141-4/+4
| | | | | | | | | This moves the global last_sent_step into remote_state. * remote.c (struct remote_state) <last_sent_step>: New field. (last_sent_step): Remove. (remote_resume, remote_wait_as): Update.
* push last_sent_signal into struct remote_stateTom Tromey2013-08-141-6/+7
| | | | | | | | | This moves the global last_sent_signal into remote_state. * remote.c (struct remote_state) <last_sent_signal>: New field. (last_sent_signal): Remove. (new_remote_state, remote_resume, remote_wait_as): Update.
* push last_program_signals_packet into struct remote_stateTom Tromey2013-08-141-14/+13
| | | | | | | | | This moves the global last_program_signals_packet into remote_state. * remote.c (struct remote_state) <last_program_signals_packet>: New field. (last_program_signals_packet): Remove. (remote_program_signals, remote_open_1): Update.
* push last_pass_packet into struct remote_stateTom Tromey2013-08-141-9/+9
| | | | | | | | | This moves the global last_pass_packet into remote_state. * remote.c (struct remote_state) <last_pass_packet>: New field. (last_pass_packet): Remove. (remote_pass_signals, remote_open_1): Update.
* push remote_traceframe_number into struct remote_stateTom Tromey2013-08-141-8/+10
| | | | | | | | | | This moves the global remote_traceframe_number into remote_state. * remote.c (struct remote_state) <remote_traceframe_number>: New field. (remote_traceframe_number): Remove. (new_remote_state, remote_open_1, set_remote_traceframe) (remote_trace_find): Update.
* push general_thread and continue_thread into struct remote_stateTom Tromey2013-08-141-20/+17
| | | | | | | | | | | | This moves the globals general_thread and continue_thread into remote_state. * remote.c (struct remote_state) <general_thread, continue_thread>: New fields. (general_thread, continue_thread): Remove. (record_currthread, set_thread, set_general_process) (remote_open_1, extended_remote_attach_1, remote_wait_as) (extended_remote_mourn_1): Update.
* push remote_desc into struct remote_stateTom Tromey2013-08-141-40/+58
| | | | | | | | | | | | | This moves the "remote_desc" global into remote_state. * remote.c (struct remote_state) <remote_desc>: New field. (remote_desc): Remove. (remote_threads_info, remote_threads_extra_info, remote_close) (send_interrupt_sequence, remote_start_remote, remote_open_1) (readchar, remote_xfer_partial, remote_rcmd, packet_command) (remote_hostio_send_command, remote_file_put, remote_file_get) (remote_file_delete, remote_can_async_p, remote_is_async_p) (remote_async, remote_new_objfile, set_range_stepping): Update.
* Add new_remote_stateTom Tromey2013-08-141-7/+20
| | | | | | | | | | | | Add new_remote_state and change remote_state to be a pointer. This is a preparatory patch for a later series. It could perhaps be omitted, but new_remote_state also does some initialization that was previously done for the globals. * remote.c (remote_state): Now a pointer. (get_remote_state_raw): Update. (new_remote_state): New function. (_initialize_remote): Use new_remote_state.
* make remote_protocol_features "const"Tom Tromey2013-08-141-1/+1
| | | | | | This is a trivial patch to make remote_protocol_features "const". * remote.c (remote_protocol_features): Now const.
* use the libiberty crc codeTom Tromey2013-08-141-31/+1
| | | | | | | | | | | | | gdb has a copy of some CRC code that also appears in libiberty. This patch just removes the local copy. You may notice that "crc32" returns unsigned long but "xcrc32" returns unsigned int. However, this does not matter, because crc32 actually does all its operations in unsigned int type, and only the return result is widened. So, the difference does not matter. * remote.c (crc32_table, crc32): Remove. (remote_verify_memory): Use xcrc32.
* gdb/Jan Kratochvil2013-08-051-32/+27
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Code cleanup. * remote.c (cleanup_sigint_signal_handler): Rename the declaration to ... (async_cleanup_sigint_signal_handler): ... this. (initialize_sigint_signal_handler): Remove declaration. (handle_remote_sigint): Rename the declaration to ... (async_handle_remote_sigint): ... this. (handle_remote_sigint_twice): Rename the declaration to ... (async_handle_remote_sigint_twice): ... this. (async_remote_interrupt, async_remote_interrupt_twice) (remote_interrupt): Remove the declarations. (remote_interrupt_twice): Rename the declaration ... (sync_remote_interrupt_twice): ... this. (sigint_remote_twice_token): Rename the variable to ... (async_sigint_remote_twice_token): ... this. (sigint_remote_token): Rename the variable to ... (async_sigint_remote_token): ... this. (initialize_sigint_signal_handler): Rename the function to ... (async_initialize_sigint_signal_handler): ... this. Update the name inside. (handle_remote_sigint): Rename the function to ... (async_handle_remote_sigint): ... this. Update the names inside. (handle_remote_sigint_twice): Rename the function to ... (async_handle_remote_sigint_twice): ... this. Update the names inside. (cleanup_sigint_signal_handler): Rename the function to ... (async_cleanup_sigint_signal_handler): ... this. (remote_interrupt): Rename the function to ... (sync_remote_interrupt): this. Update the names inside. (remote_interrupt_twice): Rename the function to ... (sync_remote_interrupt_twice): this. Update the names inside. (remote_terminal_inferior, remote_terminal_ours, remote_wait_as) (_initialize_remote): Update the names inside.
* Replace most uses of deprecated_throw_reason with quit.aburgess2013-07-311-2/+2
| | | | | | | | | | | | | http://sourceware.org/ml/gdb-patches/2013-07/msg00778.html gdb/ChangeLog * monitor.c (monitor_interrupt_query): Replace use of deprecated_throw_reason with quit. * nto-procfs.c (interrupt_query): Likewise. * remote-fileio.c (remote_fileio_sig_exit): Likewise. * remote-mips.c (mips_kill): Likewise. * remote.c (interrupt_query): Likewise.
* gdb/Jan Kratochvil2013-06-301-2/+2
| | | | | | Code cleanup. * remote.c (async_remote_interrupt_twice): Make it static. * remote.h (async_remote_interrupt_twice): Remove the declaration.
* gdb/qiyao2013-06-261-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 2013-06-26 Pedro Alves <pedro@codesourcery.com> Yao Qi <yao@codesourcery.com> * gdb.texinfo (GDB/MI Tracepoint Commands): Document -trace-frame-collected. gdb: 2013-06-26 Pedro Alves <pedro@codesourcery.com> Yao Qi <yao@codesourcery.com> * mi/mi-cmds.c (mi_cmds): Register -trace-frame-collected. * mi/mi-cmds.h (mi_cmd_trace_frame_collected): Declare. * mi/mi-main.c (print_variable_or_computed): New function. (mi_cmd_trace_frame_collected): New function. * tracepoint.c (find_trace_state_variable_by_number): New. (struct traceframe_info): Move to tracepoint.h (struct collection_list): Likewise. (do_collect_symbol): Include locals and arguments in the wholly collected variables list. (clear_collection_list): Clear wholly collected variables list and computed variables list. (append_exp): New function. (encode_actions_1): Include variables in the wholly collected variables list. Include memory ranges and full-fledged expressions in the computed expressions list. (encode_actions): Move some code to ... Return the cleanup chain. (encode_actions_rsp): ... here. New function. (get_traceframe_location, get_traceframe_info): Remove static. * tracepoint.h (struct memrange): Moved from tracepoint.c. (struct collection_list): Moved from tracepoint.c. Add two new fields 'wholly_collected' and 'computed'. (find_trace_state_variable_by_number): Declare. (encode_actions): Adjust declaration. (encode_actions_rsp): Declare. (get_traceframe_info, get_traceframe_location): Declare. * NEWS: Mention new MI command -trace-frame-collected.
* Upload tsv earlier in remote_start_remoteqiyao2013-06-251-8/+11
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | In extended-remote, when GDB connects the target, but target is not running, the TSVs are not uploaded. When GDB attaches to a process, the TSVs are not uploaded either. However, GDBserver has some builtin or predefined TSV to upload, such as $trace_timestamp. This bug causes $trace_timestamp is never uploaded. gdb/ 2013-06-25 Yao Qi <yao@codesourcery.com> * remote.c (remote_start_remote): Move code to upload tsv earlier. gdb/testsuite/ 2013-06-25 Yao Qi <yao@codesourcery.com> * boards/native-extended-gdbserver.exp: Set board_info 'gdb,predefined_tsv'. * boards/native-gdbserver.exp: Likewise. * boards/native-stdio-gdbserver.exp: Likewise. * gdb.server/ext-attach.exp: Load trace-support.exp. Check uploaded TSVs if target supports tracing. * gdb.trace/tsv.exp: Check uploaded TSVs if target supports tracing and target has predefined tsv. gdb/doc/ 2013-06-25 Yao Qi <yao@codesourcery.com> * gdbint.texinfo (Testsuite): Document 'gdb,predefined_tsv'.
* gdb/qiyao2013-06-071-0/+2
| | | | | | | | | | | | * tracepoint.c (start_tracing): Move code to ... (trace_reset_local_state): ... here. New. (disconnect_tracing): Don't call set_current_traceframe, set_tracepoint_num, and set_traceframe_context. Call trace_reset_local_state instead. (tfile_close): Call trace_reset_local_state. * ctf.c (ctf_close): Likewise. * remote.c (remote_close): Likewise. * tracepoint.h (trace_reset_local_state): Declare.
* GDB was not restoring the signal handler before returning when a notificationsergiodj2013-06-041-3/+3
| | | | | | | | | | was received. This patch fixes it. 2013-06-04 Sergio Durigan Junior <sergiodj@redhat.com> Pedro Alves <palves@redhat.com> * remote.c (remote_wait_as): Restore signal handler before returning when GDB gets a notification.
* 2013-06-04 Gary Benson <gbenson@redhat.com>gary2013-06-041-0/+26
| | | | | | | | | | | | | | | | * target.h (target_ops): New field "to_augmented_libraries_svr4_read". (target_augmented_libraries_svr4_read): New macro. * target.c (update_current_target): Handle to_augmented_libraries_svr4_read. * remote.c (remote_state): New field "augmented_libraries_svr4_read". (remote_augmented_libraries_svr4_read_feature): New function. (remote_protocol_features): Add entry for "augmented-libraries-svr4-read". (remote_augmented_libraries_svr4_read): New function. (init_remote_ops): Initialize remote_ops.to_augmented_libraries_svr4_read.
* gdb/qiyao2013-05-301-1/+1
| | | | | | | | * tracepoint.c (encode_actions_1): Remove parameter 't'. Caller update. (encode_actions): Likewise. * remote.c (remote_download_tracepoint): Caller update. * tracepoint.h (encode_actions): Update declaration.
* gdb/qiyao2013-05-301-4/+4
| | | | | | | * remote.c (remote_check_symbols): Remove unused parameter 'objfile'. Declaration update. (remote_start_remote, remote_new_objfile): Caller update.
* [remote] Insert breakpoints in the right process.Pedro Alves2013-05-291-0/+39
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | I noticed that gdb.multi/multi-arch.exp wasn't passing with extended-remote GDBserver with my pending multi-process+multi-arch series anymore on current mainline, while it used to pass before: (gdb) run Starting program: /home/pedro/gdb/mygit/build/gdb/testsuite/gdb.multi/ma-hangout Process /home/pedro/gdb/mygit/build/gdb/testsuite/gdb.multi/ma-hangout created; pid = 32067 Warning: Cannot insert breakpoint 2. Error accessing memory address 0x4005c2: Unknown error -1. Cannot insert breakpoint -1. Temporarily disabling shared library breakpoints: breakpoint #-1 (gdb) FAIL: gdb.multi/multi-arch.exp: starting inferior 2 Investigating manually, I found an easy way to reproduce. You just need breakpoints on distinct inferiors, and a way to have GDB install them in one go: (gdb) set breakpoint always-inserted on (gdb) info breakpoints Num Type Disp Enb Address What 2 breakpoint del n <MULTIPLE> 2.1 y 0x00000000004005c2 in main at ../../../src/gdb/testsuite/gdb.multi/hello.c:40 inf 1 2.2 y 0x08048475 in main at ../../../src/gdb/testsuite/gdb.multi/hangout.c:22 inf 2 (gdb) enable 2 Warning: Cannot insert breakpoint 2. Error accessing memory address 0x4005c2: Unknown error -1. And turning on remote debugging, we see: (gdb) set debug remote 1 (gdb) disable 2 (gdb) enable 2 Sending packet: $Z0,4005c2,1#71...Packet received: E01 Sending packet: $Z0,8048475,1#87...Packet received: OK Warning: Cannot insert breakpoint 2. Error accessing memory address 0x4005c2: Unknown error -1. Notice that each of those Z0 breakpoints should be set in different processes. However, no Hg packet to select a process has been sent in between, so GDBserver tries to plant both on the same process that happens to be current. The first Z0 then not so surprisingly fails. IOW, the blame is on GDB, for telling GDBserver to plant both breakpoints in the same process. remote.c has a lazy scheme where it keeps a local cache of the remote's selected general thread, and delays updating it on the remote side until necessary (memory/register reads/writes, etc.). This is done to reduce RSP traffic. The bug is that the Zx breakpoint insert/remove methods weren't committing the selected thread/process back to the remote side: Breakpoint 3, remote_insert_breakpoint (gdbarch=0x1383ae0, bp_tgt=0x140c2b0) at ../../src/gdb/remote.c:8148 8148 if (remote_protocol_packets[PACKET_Z0].support != PACKET_DISABLE) (top-gdb) p inferior_ptid $3 = {pid = 3670, lwp = 0, tid = 3670} (top-gdb) p general_thread $4 = {pid = 3671, lwp = 0, tid = 3671} IOW, a call to set_general_process is missing. I did some auditing over remote.c, and added calls to all places I found missing it. This only used to work by chance before. breakpoint.c switches to a thread of the target process before installing a breakpoint location. That calls switch_to_thread. Before: 2012-07-27 Yao Qi <yao@codesourcery.com> * thread.c (switch_to_thread): Don't call registers_changed. that caused the register caches to all be flushed and refetched before installing the breakpoint location. Given fetching registers commits the remote general thread (with Hg), masking out the latent bug. Tested on x86_64 Fedora 17 with GDBserver. gdb/ 2013-05-29 Pedro Alves <palves@redhat.com> * remote.c (remote_insert_breakpoint, remote_remove_breakpoint) (remote_insert_watchpoint, remote_remove_watchpoint) (remote_insert_hw_breakpoint, remote_remove_hw_breakpoint) (remote_verify_memory, compare_sections_command) (remote_search_memory): Set the general process/thread on the remote side.
* range stepping: gdbPedro Alves2013-05-231-0/+98
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This patch teaches GDB to take advantage of target-assisted range stepping. It adds a new 'r ADDR1,ADDR2' action to vCont (vCont;r), meaning, "step once, and keep stepping as long as the thread is in the [ADDR1,ADDR2) range". Rationale: When user issues the "step" command on the following line of source, a = b + c + d * e - a; GDB single-steps every single instruction until the program reaches a new different line. E.g., on x86_64, that line compiles to: 0x08048434 <+65>: mov 0x1c(%esp),%eax 0x08048438 <+69>: mov 0x30(%esp),%edx 0x0804843c <+73>: add %eax,%edx 0x0804843e <+75>: mov 0x18(%esp),%eax 0x08048442 <+79>: imul 0x2c(%esp),%eax 0x08048447 <+84>: add %edx,%eax 0x08048449 <+86>: sub 0x34(%esp),%eax 0x0804844d <+90>: mov %eax,0x34(%esp) 0x08048451 <+94>: mov 0x1c(%esp),%eax and the following is the RSP traffic between GDB and GDBserver: --> vCont;s:p2e13.2e13;c <-- T0505:68efffbf;04:30efffbf;08:3c840408;thread:p2e13.2e13;core:1; --> vCont;s:p2e13.2e13;c <-- T0505:68efffbf;04:30efffbf;08:3e840408;thread:p2e13.2e13;core:2; --> vCont;s:p2e13.2e13;c <-- T0505:68efffbf;04:30efffbf;08:42840408;thread:p2e13.2e13;core:2; --> vCont;s:p2e13.2e13;c <-- T0505:68efffbf;04:30efffbf;08:47840408;thread:p2e13.2e13;core:0; --> vCont;s:p2e13.2e13;c <-- T0505:68efffbf;04:30efffbf;08:49840408;thread:p2e13.2e13;core:0; --> vCont;s:p2e13.2e13;c <-- T0505:68efffbf;04:30efffbf;08:4d840408;thread:p2e13.2e13;core:0; --> vCont;s:p2e13.2e13;c <-- T0505:68efffbf;04:30efffbf;08:51840408;thread:p2e13.2e13;core:0; IOW, a lot of roundtrips between GDB and GDBserver. If we add a new command to the RSP, meaning "keep stepping and don't report a stop until the program goes out of the [0x08048434, 0x08048451) address range", then the RSP traffic can be reduced down to: --> vCont;r8048434,8048451:p2db0.2db0;c <-- T0505:68efffbf;04:30efffbf;08:51840408;thread:p2db0.2db0;core:1; As number of packets is reduced dramatically, the performance of stepping source lines is much improved. In case something is wrong with range stepping on the stub side, the debug info or even gdb, this adds a "set/show range-stepping" command to be able to turn range stepping off. gdb/ 2013-05-23 Yao Qi <yao@codesourcery.com> Pedro Alves <palves@redhat.com> * gdbthread.h (struct thread_control_state) <may_range_step>: New field. * infcmd.c (step_once, until_next_command): Enable range stepping. * infrun.c (displaced_step_prepare): Disable range stepping. (resume): Disable range stepping if stepping over a breakpoint or we have software watchpoints. If range stepping is enabled, assert the thread is in the stepping range. (clear_proceed_status_thread): Clear may_range_step. (handle_inferior_event): Disable range stepping as soon as we know the thread that hit the event. Re-enable it whenever we're going to step with a step range. * remote.c (struct vCont_action_support) <r>: New field. (use_range_stepping): New global. (remote_vcont_probe): Handle 'r' action. (append_resumption): Append an 'r' action if the thread may range step. (show_range_stepping): New function. (set_range_stepping): New function. (_initialize_remote): Call add_setshow_boolean_cmd to register the 'set range-stepping' and 'show range-stepping' commands. * NEWS: Mention range stepping, the new vCont;r action, and the new "set/show range-stepping" commands. gdb/doc/ 2013-05-23 Yao Qi <yao@codesourcery.com> Pedro Alves <palves@redhat.com> * gdb.texinfo (Packets): Document 'vCont;r'. (Continuing and Stepping): Document target-assisted range stepping, and the 'set range-stepping' and 'show range-stepping' commands.
* Convert rs->support_vCont_t to a struct.Pedro Alves2013-05-231-5/+16
| | | | | | | | | | | | | | Convert the 'support_vCont_t' int field to a struct, in preparation for adding more fields to it. gdb/ 2013-05-23 Yao Qi <yao@codesourcery.com> Pedro Alves <palves@redhat.com> * remote.c (struct vCont_action_support): New struct. (struct remote_state) <support_vCont_t>: Remove field. <vCont_actions_support>: New field. (remote_vcont_probe, remote_stop_ns): Update.
* * remote.c (remote_set_trace_notes): Make arguments const.Tom Tromey2013-05-141-1/+2
| | | | | * target.c (update_current_target): Update cast. * target.h (to_set_trace_notes): Make arguments const.
* Fix typo in "show remote traceframe-info-packet"Pedro Alves2013-05-101-1/+1
| | | | | | | | | | | | | | | | I noticed: (gdb) show remote traceframe-info-packet Support for the `qXfer:trace-frame-info:read' packet is auto-detected, currently unknown. ^^^^^^^^^^^ The packet is actually qXfer:traceframe-info:read. gdb/ 2013-05-10 Pedro Alves <palves@redhat.com> * remote.c (_initialize_remote): Fix spelling of qXfer:traceframe-info:read packet in packet config command.
* PR remote/15455 - QTro remote packet brokenPedro Alves2013-05-101-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | In the function remote_trace_set_readonly_regions in gdb/remote.c, the local variable 'offset' does not account for "QTro" at the start of the packet with the result that if there are any read-only regions, the packet is sent -- but without the "QTro" -- causing the remote stub to report that the packet is unsupported: Sending packet: $:0000000000400200,(...),00000000004560a4#ab...Packet received: vs the expected: Sending packet: $QTro:0000000000400200,(...),00000000004560a4#31...Packet received: OK We don't see the problem when testing with GDBserver, as that supports qXfer:trace-frame-info:read, meaning GDBserver never needs to read from the read-only sections directly itself. This commit adds a test that explicitly disables qXfer:trace-frame-info:read. gdb/ 2013-05-10 David Taylor <dtaylor@emc.com> PR remote/15455 * remote.c (remote_trace_set_readonly_regions): Do not overwrite "QTro" at start of packet. gdb/testsuite/ 2013-05-10 Pedro Alves <palves@redhat.com> PR remote/15455 * gdb.trace/qtro.c: New file. * gdb.trace/qtro.exp: New file.
* PR gdb/7912:Tom Tromey2013-04-221-2/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * Makefile.in (SFILES): Add filestuff.c (COMMON_OBS): Add filestuff.o. (filestuff.o): New target. * auto-load.c (auto_load_objfile_script_1): Use gdb_fopen_cloexec. * auxv.c (procfs_xfer_auxv): Use gdb_open_cloexec. * cli/cli-cmds.c (shell_escape): Call close_most_fds. * cli/cli-dump.c (fopen_with_cleanup): Use gdb_fopen_cloexec. * common/agent.c (gdb_connect_sync_socket): Use gdb_socket_cloexec. * common/filestuff.c: New file. * common/filestuff.h: New file. * common/linux-osdata.c (linux_common_core_of_thread) (command_from_pid, commandline_from_pid, print_source_lines) (linux_xfer_osdata_shm, linux_xfer_osdata_sem) (linux_xfer_osdata_msg, linux_xfer_osdata_modules): Use gdb_fopen_cloexec. * common/linux-procfs.c (linux_proc_get_int) (linux_proc_pid_has_state): Use gdb_fopen_cloexec. * config.in, configure: Rebuild. * configure.ac: Don't check for sys/socket.h. Check for fdwalk, pipe2. * corelow.c (core_open): Use gdb_open_cloexec. * dwarf2read.c (write_psymtabs_to_index): Use gdb_fopen_cloexec. * fork-child.c (fork_inferior): Call close_most_fds. * gdb_bfd.c (gdb_bfd_open): Use gdb_open_cloexec. * inf-child.c (inf_child_fileio_readlink): Use gdb_open_cloexec. * linux-nat.c (linux_nat_thread_name, linux_proc_pending_signals): Use gdb_fopen_cloexec. (linux_proc_xfer_partial, linux_proc_xfer_spu): Use gdb_open_cloexec. (linux_async_pipe): Use gdb_pipe_cloexec. * remote-fileio.c (remote_fileio_func_open): Use gdb_open_cloexec. * remote.c (remote_file_put, remote_file_get): Use gdb_fopen_cloexec. * ser-pipe.c (pipe_open): Use gdb_socketpair_cloexec, close_most_fds. * ser-tcp.c (net_open): Use gdb_socket_cloexec. * ser-unix.c (hardwire_open): Use gdb_open_cloexec. * solib.c (solib_find): Use gdb_open_cloexec. * source.c (openp, find_and_open_source): Use gdb_open_cloexec. * tracepoint.c (tfile_start): Use gdb_fopen_cloexec. (tfile_open): Use gdb_open_cloexec. * tui/tui-io.c (tui_initialize_io): Use gdb_pipe_cloexec. * ui-file.c (gdb_fopen): Use gdb_fopen_cloexec. * xml-support.c (xml_fetch_content_from_file): Use gdb_fopen_cloexec. * main.c (captured_main): Call notice_open_fds. gdbserver * Makefile.in (SFILES): Add filestuff.c. (OBS): Add filestuff.o. (filestuff.o): New target. * config.in, configure: Rebuild. * configure.ac: Check for fdwalk, pipe2.
* gdb_byte for binary buffer, char for string: remote.c, tracepoint.c.Pedro Alves2013-04-191-14/+15
| | | | | | | | | | | | | | | | | | | | | | | | While the RSP is largely ASCII based (hence the packet buffer type is char *), at places we pass around 8-bit binary packets in that buffer. Functions like hex2bin or remote_escape_output conceptually are handling binary buffers, so I left them as working with gdb_byte, and added casts where necessary. Whether these are host bytes or target bytes is blurry at present, so this is largely a matter of taste. Switching some of these functions to take "char *" or "void *" would be equally good. gdb/ 2013-04-19 Pedro Alves <palves@redhat.com> * remote.c (remote_write_bytes_aux, compare_sections_command) (remote_read_qxfer) (remote_search_memory, remote_hostio_pwrite, remote_hostio_pread) (remote_hostio_readlink, remote_bfd_iovec_pread) (remote_set_trace_notes): Use gdb_byte when RSP buffer is used as binary buffer, and char when buffer is used as string. * tracepoint.c (encode_source_string, tfile_write_uploaded_tp) (trace_save, tfile_open, traceframe_walk_blocks) (tfile_fetch_registers): Likewise.
* -Wpointer-sign: char -> gdb_byte.Pedro Alves2013-04-191-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | -Wpointer-sign catches all these cases across the codebase that should be using gdb_byte for raw target bytes. I think these are all obvious, hence I've collapsed into a single patch. gdb/ 2013-04-19 Pedro Alves <palves@redhat.com> * aarch64-tdep.c (aarch64_default_breakpoint): Change type to gdb_byte[]. (aarch64_breakpoint_from_pc): Change return type to gdb_byte *. * ada-lang.c (ada_value_assign): Use gdb_byte. * alphanbsd-tdep.c (sigtramp_retcode): Change type to gdb_byte[]. (alphanbsd_sigtramp_offset): Use gdb_byte. * arm-linux-tdep.c (arm_linux_arm_le_breakpoint) (arm_linux_arm_be_breakpoint, eabi_linux_arm_le_breakpoint) (eabi_linux_arm_be_breakpoint, arm_linux_thumb_be_breakpoint) (arm_linux_thumb_le_breakpoint, arm_linux_thumb2_be_breakpoint) (arm_linux_thumb2_le_breakpoint): Change type to gdb_byte[]. * arm-tdep.c (arm_stub_unwind_sniffer) (arm_displaced_init_closure): Use gdb_byte. (arm_default_arm_le_breakpoint, arm_default_arm_be_breakpoint) (arm_default_thumb_le_breakpoint) (arm_default_thumb_be_breakpoint): Change type to gdb_byte[]. * arm-tdep.h (struct gdbarch_tdep) <arm_breakpoint, thumb_breakpoint, thumb2_breakpoint>: Change type to gdb_byte *. * arm-wince-tdep.c (arm_wince_le_breakpoint) (arm_wince_thumb_le_breakpoint): Change type to gdb_byte[]. * armnbsd-tdep.c (arm_nbsd_arm_le_breakpoint) (arm_nbsd_arm_be_breakpoint, arm_nbsd_thumb_le_breakpoint) (arm_nbsd_thumb_be_breakpoint): Change type to gdb_byte[]. * armobsd-tdep.c (arm_obsd_thumb_le_breakpoint) (arm_obsd_thumb_be_breakpoint): Change type to gdb_byte[]. * cris-tdep.c (push_stack_item, cris_push_dummy_call) (cris_store_return_value, cris_extract_return_value): Use gdb_byte. (constraint): Change type of parameter to char * from signed char*. Use gdb_byte. * dwarf2loc.c (read_pieced_value, write_pieced_value): Change type of local buffer to gdb_byte *. * dwarf2read.c (read_index_from_section): Use gdb_byte. (create_dwp_hash_table): Change type of locals to gdb_byte *. (add_address_entry): Change type of local buffer to gdb_byte[]. * frv-tdep.c (frv_adjust_breakpoint_address, find_func_descr) (frv_push_dummy_call): Use gdb_byte. * hppa-hpux-tdep.c (hppa_hpux_push_dummy_code) (hppa_hpux_supply_ss_fpblock, hppa_hpux_supply_ss_wide) (hppa_hpux_supply_save_state): Use gdb_byte. * hppa-tdep.c (hppa32_push_dummy_call) (hppa64_convert_code_addr_to_fptr): Use gdb_byte. * ia64-tdep.c (extract_bit_field, replace_bit_field) (slotN_contents, replace_slotN_contents): Change type of parameter to gdb_byte *. (fetch_instruction, ia64_pseudo_register_write) (ia64_register_to_value, ia64_value_to_register) (ia64_extract_return_value, ia64_store_return_value) (ia64_push_dummy_call): Use gdb_byte. * m32c-tdep.c (m32c_return_value): Remove cast. * m68hc11-tdep.c (m68hc11_pseudo_register_write) (m68hc11_push_dummy_call, m68hc11_store_return_value): Use gdb_byte. * mipsnbsd-tdep.c (mipsnbsd_get_longjmp_target): Use gdb_byte. * mn10300-tdep.c (mn10300_store_return_value) (mn10300_breakpoint_from_pc, mn10300_push_dummy_call): Use gdb_byte. * moxie-tdep.c (moxie_process_readu): Use gdb_byte. (moxie_process_record): Remove casts. * ppc-ravenscar-thread.c (supply_register_at_address) (ppc_ravenscar_generic_store_registers): Use gdb_byte. * ravenscar-thread.c (get_running_thread_id): Use gdb_byte. * remote-m32r-sdi.c (m32r_fetch_register): Use gdb_byte. * remote-mips.c (mips_xfer_memory): Use gdb_byte. * remote.c (compare_sections_command): Use gdb_byte. * score-tdep.c (score7_free_memblock): Change type of parameter to gdb_byte *. * sh-tdep.c (sh_justify_value_in_reg): Change return type to gdb_byte *. Use gdb_byte. (sh_push_dummy_call_fpu): Use gdb_byte. (sh_extract_return_value_nofpu, sh_extract_return_value_fpu) (sh_store_return_value_nofpu, sh_store_return_value_fpu) (sh_register_convert_to_virtual, sh_register_convert_to_raw): Change parameter type to 'gdb_byte *'. Use gdb_byte. (sh_pseudo_register_read, sh_pseudo_register_write): Use gdb_byte. * sh64-tdep.c (sh64_push_dummy_call): Use gdb_byte. (sh64_store_return_value, sh64_register_convert_to_virtual): Change parameter type to 'gdb_byte *'. Use gdb_byte. (sh64_pseudo_register_write): Use gdb_byte. * solib-darwin.c (darwin_current_sos): Add casts to 'gdb_byte *'. * solib-irix.c (fetch_lm_info): Likewise. Use gdb_byte for byte buffer. (irix_current_sos): Use gdb_byte. * solib-som.c (som_current_sos): Use gdb_byte. * sparc-ravenscar-thread.c (supply_register_at_address) (sparc_ravenscar_generic_store_registers): Use gdb_byte. * spu-multiarch.c (spu_xfer_partial): Add cast to 'char *'. * spu-tdep.c (spu_get_overlay_table): Use gdb_byte. * tic6x-tdep.c (tic6x_breakpoint_from_pc): Change return type to 'gdb_byte *'. * tic6x-tdep.h (struct gdbarch_tdep) <breakpoint>: Change type to 'gdb_byte *'. * tracepoint.c (tfile_fetch_registers): Use gdb_byte. * xstormy16-tdep.c (xstormy16_extract_return_value) (xstormy16_store_return_value): Change parameter type to 'gdb_byte *'. Adjust. (xstormy16_push_dummy_call): Use gdb_byte. * xtensa-tdep.c (xtensa_scan_prologue, call0_ret) (call0_analyze_prologue, execute_code): Use gdb_byte.
* gdb/Jan Kratochvil2013-04-121-1/+2
| | | | | | | | | Fix GDB regression related to PR binutils/14813. * jit.c (mem_bfd_iovec_close): Return 0 for success. * minidebug.c (lzma_close): Add return value comment. * remote.c (remote_bfd_iovec_close): Return 0 for success. * solib-spu.c (spu_bfd_iovec_close): Likewise. * spu-linux-nat.c (spu_bfd_iovec_close): Likewise.
* gdb/Jan Kratochvil2013-04-111-6/+5
| | | | * remote.c (unpush_and_perror): Add output message final dot.
* Avoid potencially-stale errno usage.Pedro Alves2013-04-091-8/+21
| | | | | | | | | | | | | | The current throw_perror_with_name/TARGET_CLOSE_ERROR calls assume errno is still set to the right error, although remote_unpush_target is called in between, which may well change errno. Tested on x86_64 Fedora 17 w/ gdbserver. gdb/ 2013-04-09 Pedro Alves <palves@redhat.com> * remote.c (unpush_and_perror): New function. (readchar, remote_serial_write): Use it.
* gdb/qiyao2013-04-071-1/+1
| | | | | | | | | | | | | | * remote.c (remote_trace_find): Change type of parameters 'addr1' and 'addr2' to CORE_ADDR. * target.c (update_current_target): Update. * target.h (struct target_ops) <to_trace_find>: Change parameter type to CORE_ADDR. * tracepoint.c (tfind_1): Change type of parameters 'addr1' and 'addr2' to CORE_ADDR. (tfile_trace_find): Likewise. (tfile_get_traceframe_address): Change return type to CORE_ADDR. Change local variable 'addr' to type CORE_ADDR. * tracepoint.h (tfind_1): Update declaration.
* gdb/Jan Kratochvil2013-04-021-1/+2
| | | | | | Revert this patch: PR gdb/15275 * remote.c (remote_get_trace_status): Include putpkt in TRY_CATCH.
* unpush the remote target if serial_write fails.Pedro Alves2013-04-021-8/+24
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | PR gdb/15275 notes that when debugging with a remote connection over a serial link and the link is disconnected, say by disconnecting USB serial port, the GDB quit command no longer works: (gdb) tar ext /dev/ttyACM0 &"tar ext /dev/ttyACM0\n" ~"Remote debugging using /dev/ttyACM0\n" ^done (gdb) set debug remote 1 &"set debug remote 1\n" ^done (gdb) quit &"quit\n" &"Sending packet: $qTStatus#49..." &"putpkt: write failed: Input/output error.\n" ^error,msg="putpkt: write failed: Input/output error." (gdb) (gdb) quit &"quit\n" &"Sending packet: $qTStatus#49..." &"putpkt: write failed: Input/output error.\n" ^error,msg="putpkt: write failed: Input/output error." This is not reproducible with TCP connections, as with that, sending doesn't error out, but instead the error is detected on the subsequent readchar. When that read fails, we unpush the remote target, and throw TARGET_CLOSE_ERROR. To address PR gdb/15275, instead of catching the error in remote_get_trace_status as presently done (which leaves this same issue latent for another packet to trip on), or of making ser-unix.c fake success too on failed writes, so we'd get to readchar detecting the error on serial ports too, better let the error propagate out of serial_write, and catch it at the remote.c level, throwing away the target if writing fails too, instead of delaying that until the next read. gdb/ 2013-04-02 Pedro Alves <palves@redhat.com> PR gdb/15275 * remote.c (send_interrupt_sequence): Use remote_serial_write. (remote_serial_write): New function. (putpkt_binary, getpkt_or_notif_sane_1): Use remote_serial_write.
* Stop sending qTStatus if the target doesn't recognize it; add packet ↵Pedro Alves2013-03-281-1/+11
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | configuration command. GDB currently sends a qTStatus even if the target previously replied an empty packet to a previous qTStatus. If the target doesn't recognize the packet, there's no point in trying again. The machinery we have in place is packet_ok, which has the nice side effect of forcing one to install a configuration command/knob for the packet in question, which is often handy when you need to debug things, and/or emulate a target that doesn't support the packet, or even, it can be used as workaround for the old broken kgdb's that return error to qTSTatus instead of an empty packet. gdb/ 2013-03-28 Pedro Alves <palves@redhat.com> * NEWS (New options): New section. (New options): Mention set/show remote trace-status-packet. * remote.c (PACKET_qTStatus): New enumeration value. (remote_get_trace_status): Skip sending qTStatus if the packet is disabled. Use packet_ok. (_initialize_remote): Register a configuration command for qTStatus packet. gdb/doc/ 2013-03-28 Pedro Alves <palves@redhat.com> * gdb.texinfo (Remote Configuration) <set remote @var{name}-packet table>: Add entry for "trace-status".
* gdb/Jan Kratochvil2013-03-271-2/+1
| | | | | PR gdb/15275 * remote.c (remote_get_trace_status): Include putpkt in TRY_CATCH.