diff options
author | Simon Marchi <simon.marchi@efficios.com> | 2021-11-22 11:27:31 -0500 |
---|---|---|
committer | Simon Marchi <simon.marchi@polymtl.ca> | 2021-11-22 13:57:54 -0500 |
commit | c272a98cbf596ddf1a70a41801c6e86d9564d152 (patch) | |
tree | 366b8b105f8450dd1894aebbbae82b8e1946d249 /gdbserver | |
parent | 06de25b7af21eb1173d7b86c5c0f37aae5ec2674 (diff) | |
download | binutils-gdb-c272a98cbf596ddf1a70a41801c6e86d9564d152.tar.gz |
gdb: pass more const target_waitstatus by reference
While working on target_waitstatus changes, I noticed a few places where
const target_waitstatus objects could be passed by reference instead of
by pointers. And in some cases, places where a target_waitstatus could
be passed as const, but was not. Convert them as much as possible.
Change-Id: Ied552d464be5d5b87489913b95f9720a5ad50c5a
Diffstat (limited to 'gdbserver')
-rw-r--r-- | gdbserver/remote-utils.cc | 45 | ||||
-rw-r--r-- | gdbserver/remote-utils.h | 2 | ||||
-rw-r--r-- | gdbserver/server.cc | 26 |
3 files changed, 36 insertions, 37 deletions
diff --git a/gdbserver/remote-utils.cc b/gdbserver/remote-utils.cc index 5bc261a9c7b..8202365350a 100644 --- a/gdbserver/remote-utils.cc +++ b/gdbserver/remote-utils.cc @@ -1081,15 +1081,14 @@ outreg (struct regcache *regcache, int regno, char *buf) } void -prepare_resume_reply (char *buf, ptid_t ptid, - struct target_waitstatus *status) +prepare_resume_reply (char *buf, ptid_t ptid, const target_waitstatus &status) { client_state &cs = get_client_state (); if (debug_threads) debug_printf ("Writing resume reply for %s:%d\n", - target_pid_to_str (ptid).c_str (), status->kind ()); + target_pid_to_str (ptid).c_str (), status.kind ()); - switch (status->kind ()) + switch (status.kind ()) { case TARGET_WAITKIND_STOPPED: case TARGET_WAITKIND_FORKED: @@ -1104,27 +1103,27 @@ prepare_resume_reply (char *buf, ptid_t ptid, const char **regp; struct regcache *regcache; - if ((status->kind () == TARGET_WAITKIND_FORKED && cs.report_fork_events) - || (status->kind () == TARGET_WAITKIND_VFORKED + if ((status.kind () == TARGET_WAITKIND_FORKED && cs.report_fork_events) + || (status.kind () == TARGET_WAITKIND_VFORKED && cs.report_vfork_events)) { enum gdb_signal signal = GDB_SIGNAL_TRAP; - const char *event = (status->kind () == TARGET_WAITKIND_FORKED + const char *event = (status.kind () == TARGET_WAITKIND_FORKED ? "fork" : "vfork"); sprintf (buf, "T%02x%s:", signal, event); buf += strlen (buf); - buf = write_ptid (buf, status->child_ptid ()); + buf = write_ptid (buf, status.child_ptid ()); strcat (buf, ";"); } - else if (status->kind () == TARGET_WAITKIND_VFORK_DONE + else if (status.kind () == TARGET_WAITKIND_VFORK_DONE && cs.report_vfork_events) { enum gdb_signal signal = GDB_SIGNAL_TRAP; sprintf (buf, "T%02xvforkdone:;", signal); } - else if (status->kind () == TARGET_WAITKIND_EXECD && cs.report_exec_events) + else if (status.kind () == TARGET_WAITKIND_EXECD && cs.report_exec_events) { enum gdb_signal signal = GDB_SIGNAL_TRAP; const char *event = "exec"; @@ -1134,32 +1133,32 @@ prepare_resume_reply (char *buf, ptid_t ptid, buf += strlen (buf); /* Encode pathname to hexified format. */ - bin2hex ((const gdb_byte *) status->execd_pathname (), + bin2hex ((const gdb_byte *) status.execd_pathname (), hexified_pathname, - strlen (status->execd_pathname ())); + strlen (status.execd_pathname ())); sprintf (buf, "%s;", hexified_pathname); buf += strlen (buf); } - else if (status->kind () == TARGET_WAITKIND_THREAD_CREATED + else if (status.kind () == TARGET_WAITKIND_THREAD_CREATED && cs.report_thread_events) { enum gdb_signal signal = GDB_SIGNAL_TRAP; sprintf (buf, "T%02xcreate:;", signal); } - else if (status->kind () == TARGET_WAITKIND_SYSCALL_ENTRY - || status->kind () == TARGET_WAITKIND_SYSCALL_RETURN) + else if (status.kind () == TARGET_WAITKIND_SYSCALL_ENTRY + || status.kind () == TARGET_WAITKIND_SYSCALL_RETURN) { enum gdb_signal signal = GDB_SIGNAL_TRAP; - const char *event = (status->kind () == TARGET_WAITKIND_SYSCALL_ENTRY + const char *event = (status.kind () == TARGET_WAITKIND_SYSCALL_ENTRY ? "syscall_entry" : "syscall_return"); sprintf (buf, "T%02x%s:%x;", signal, event, - status->syscall_number ()); + status.syscall_number ()); } else - sprintf (buf, "T%02x", status->sig ()); + sprintf (buf, "T%02x", status.sig ()); if (disable_packet_T) { @@ -1281,19 +1280,19 @@ prepare_resume_reply (char *buf, ptid_t ptid, case TARGET_WAITKIND_EXITED: if (cs.multi_process) sprintf (buf, "W%x;process:%x", - status->exit_status (), ptid.pid ()); + status.exit_status (), ptid.pid ()); else - sprintf (buf, "W%02x", status->exit_status ()); + sprintf (buf, "W%02x", status.exit_status ()); break; case TARGET_WAITKIND_SIGNALLED: if (cs.multi_process) sprintf (buf, "X%x;process:%x", - status->sig (), ptid.pid ()); + status.sig (), ptid.pid ()); else - sprintf (buf, "X%02x", status->sig ()); + sprintf (buf, "X%02x", status.sig ()); break; case TARGET_WAITKIND_THREAD_EXITED: - sprintf (buf, "w%x;", status->exit_status ()); + sprintf (buf, "w%x;", status.exit_status ()); buf += strlen (buf); buf = write_ptid (buf, ptid); break; diff --git a/gdbserver/remote-utils.h b/gdbserver/remote-utils.h index 25074bcc2b9..b856862d367 100644 --- a/gdbserver/remote-utils.h +++ b/gdbserver/remote-utils.h @@ -41,7 +41,7 @@ void enable_async_io (void); void disable_async_io (void); void check_remote_input_interrupt_request (void); void prepare_resume_reply (char *buf, ptid_t ptid, - struct target_waitstatus *status); + const target_waitstatus &status); const char *decode_address_to_semicolon (CORE_ADDR *addrp, const char *start); void decode_address (CORE_ADDR *addrp, const char *start, int len); diff --git a/gdbserver/server.cc b/gdbserver/server.cc index 2807525d11c..b1d4c92b3d9 100644 --- a/gdbserver/server.cc +++ b/gdbserver/server.cc @@ -173,12 +173,12 @@ get_client_state () /* Put a stop reply to the stop reply queue. */ static void -queue_stop_reply (ptid_t ptid, struct target_waitstatus *status) +queue_stop_reply (ptid_t ptid, const target_waitstatus &status) { struct vstop_notif *new_notif = new struct vstop_notif; new_notif->ptid = ptid; - new_notif->status = *status; + new_notif->status = status; notif_event_enque (¬if_stop, new_notif); } @@ -225,7 +225,7 @@ vstop_notif_reply (struct notif_event *event, char *own_buf) { struct vstop_notif *vstop = (struct vstop_notif *) event; - prepare_resume_reply (own_buf, vstop->ptid, &vstop->status); + prepare_resume_reply (own_buf, vstop->ptid, vstop->status); } /* Helper for in_queued_stop_replies. */ @@ -2795,7 +2795,7 @@ handle_pending_status (const struct thread_resume *resumption, cs.last_status = thread->last_status; cs.last_ptid = thread->id; - prepare_resume_reply (cs.own_buf, cs.last_ptid, &cs.last_status); + prepare_resume_reply (cs.own_buf, cs.last_ptid, cs.last_status); return 1; } return 0; @@ -2963,7 +2963,7 @@ resume (struct thread_resume *actions, size_t num_actions) so by now). Tag all threads as "want-stopped", so we don't resume them implicitly without the client telling us to. */ gdb_wants_all_threads_stopped (); - prepare_resume_reply (cs.own_buf, cs.last_ptid, &cs.last_status); + prepare_resume_reply (cs.own_buf, cs.last_ptid, cs.last_status); disable_async_io (); if (cs.last_status.kind () == TARGET_WAITKIND_EXITED @@ -2996,7 +2996,7 @@ handle_v_attach (char *own_buf) write_ok (own_buf); } else - prepare_resume_reply (own_buf, cs.last_ptid, &cs.last_status); + prepare_resume_reply (own_buf, cs.last_ptid, cs.last_status); } else write_enn (own_buf); @@ -3114,7 +3114,7 @@ handle_v_run (char *own_buf) if (cs.last_status.kind () == TARGET_WAITKIND_STOPPED) { - prepare_resume_reply (own_buf, cs.last_ptid, &cs.last_status); + prepare_resume_reply (own_buf, cs.last_ptid, cs.last_status); /* In non-stop, sending a resume reply doesn't set the general thread, but GDB assumes a vRun sets it (this is so GDB can @@ -3313,7 +3313,7 @@ queue_stop_reply_callback (thread_info *thread) /* Pass the last stop reply back to GDB, but don't notify yet. */ - queue_stop_reply (thread->id, &thread->last_status); + queue_stop_reply (thread->id, thread->last_status); } } } @@ -3436,7 +3436,7 @@ handle_status (char *own_buf) set_desired_thread (); gdb_assert (tp->last_status.kind () != TARGET_WAITKIND_IGNORE); - prepare_resume_reply (own_buf, tp->id, &tp->last_status); + prepare_resume_reply (own_buf, tp->id, tp->last_status); } else strcpy (own_buf, "W00"); @@ -4562,11 +4562,11 @@ handle_serial_event (int err, gdb_client_data client_data) /* Push a stop notification on the notification queue. */ static void -push_stop_notification (ptid_t ptid, struct target_waitstatus *status) +push_stop_notification (ptid_t ptid, const target_waitstatus &status) { struct vstop_notif *vstop_notif = new struct vstop_notif; - vstop_notif->status = *status; + vstop_notif->status = status; vstop_notif->ptid = ptid; /* Push Stop notification. */ notif_push (¬if_stop, vstop_notif); @@ -4587,7 +4587,7 @@ handle_target_event (int err, gdb_client_data client_data) if (cs.last_status.kind () == TARGET_WAITKIND_NO_RESUMED) { if (gdb_connected () && report_no_resumed) - push_stop_notification (null_ptid, &cs.last_status); + push_stop_notification (null_ptid, cs.last_status); } else if (cs.last_status.kind () != TARGET_WAITKIND_IGNORE) { @@ -4645,7 +4645,7 @@ handle_target_event (int err, gdb_client_data client_data) } } else - push_stop_notification (cs.last_ptid, &cs.last_status); + push_stop_notification (cs.last_ptid, cs.last_status); } /* Be sure to not change the selected thread behind GDB's back. |