Introduce event_location_up
[deliverable/binutils-gdb.git] / gdb / thread.c
index 3aca30757c67dfa4203b765afd190ad8ca994efc..abfce71eda5e47075353eaf4123fcd4d19941de6 100644 (file)
@@ -279,7 +279,7 @@ add_thread_silent (ptid_t ptid)
         to it, delete the original thread, reset the new thread's
         ptid, and switch to it.  */
 
-      if (ptid_equal (inferior_ptid, ptid))
+      if (inferior_ptid == ptid)
        {
          tp = new_thread (inf, null_ptid);
 
@@ -448,7 +448,7 @@ delete_thread_1 (ptid_t ptid, int silent)
   tpprev = NULL;
 
   for (tp = thread_list; tp; tpprev = tp, tp = tp->next)
-    if (ptid_equal (tp->ptid, ptid))
+    if (tp->ptid == ptid)
       break;
 
   if (!tp)
@@ -517,7 +517,7 @@ find_thread_ptid (ptid_t ptid)
   struct thread_info *tp;
 
   for (tp = thread_list; tp; tp = tp->next)
-    if (ptid_equal (tp->ptid, ptid))
+    if (tp->ptid == ptid)
       return tp;
 
   return NULL;
@@ -529,11 +529,11 @@ find_thread_ptid (ptid_t ptid)
  * Calls a callback function once for each thread, so long as
  * the callback function returns false.  If the callback function
  * returns true, the iteration will end and the current thread
- * will be returned.  This can be useful for implementing a 
+ * will be returned.  This can be useful for implementing a
  * search for a thread with arbitrary attributes, or for applying
  * some operation to every thread.
  *
- * FIXME: some of the existing functionality, such as 
+ * FIXME: some of the existing functionality, such as
  * "Thread apply all", might be rewritten using this functionality.
  */
 
@@ -562,7 +562,7 @@ thread_count (void)
   for (tp = thread_list; tp; tp = tp->next)
     ++result;
 
-  return result;  
+  return result;
 }
 
 int
@@ -583,7 +583,7 @@ ptid_to_global_thread_id (ptid_t ptid)
   struct thread_info *tp;
 
   for (tp = thread_list; tp; tp = tp->next)
-    if (ptid_equal (tp->ptid, ptid))
+    if (tp->ptid == ptid)
       return tp->global_num;
 
   return 0;
@@ -606,7 +606,7 @@ in_thread_list (ptid_t ptid)
   struct thread_info *tp;
 
   for (tp = thread_list; tp; tp = tp->next)
-    if (ptid_equal (tp->ptid, ptid))
+    if (tp->ptid == ptid)
       return 1;
 
   return 0;                    /* Never heard of 'im.  */
@@ -705,7 +705,7 @@ do_captured_list_thread_ids (struct ui_out *uiout, void *arg)
       if (tp->state == THREAD_EXITED)
        continue;
 
-      if (ptid_equal (tp->ptid, inferior_ptid))
+      if (tp->ptid == inferior_ptid)
        current_thread = tp->global_num;
 
       num++;
@@ -896,7 +896,7 @@ void
 set_resumed (ptid_t ptid, int resumed)
 {
   struct thread_info *tp;
-  int all = ptid_equal (ptid, minus_one_ptid);
+  int all = ptid == minus_one_ptid;
 
   if (all || ptid_is_pid (ptid))
     {
@@ -940,11 +940,11 @@ void
 set_running (ptid_t ptid, int running)
 {
   struct thread_info *tp;
-  int all = ptid_equal (ptid, minus_one_ptid);
+  int all = ptid == minus_one_ptid;
   int any_started = 0;
 
-  /* We try not to notify the observer if no thread has actually changed 
-     the running state -- merely to reduce the number of messages to 
+  /* We try not to notify the observer if no thread has actually changed
+     the running state -- merely to reduce the number of messages to
      frontend.  Frontend is supposed to handle multiple *running just fine.  */
   if (all || ptid_is_pid (ptid))
     {
@@ -1012,7 +1012,7 @@ void
 set_executing (ptid_t ptid, int executing)
 {
   struct thread_info *tp;
-  int all = ptid_equal (ptid, minus_one_ptid);
+  int all = ptid == minus_one_ptid;
 
   if (all || ptid_is_pid (ptid))
     {
@@ -1032,7 +1032,7 @@ set_executing (ptid_t ptid, int executing)
     threads_executing = 1;
   /* Only clear the flag if the caller is telling us everything is
      stopped.  */
-  else if (ptid_equal (minus_one_ptid, ptid))
+  else if (minus_one_ptid == ptid)
     threads_executing = 0;
 }
 
@@ -1048,7 +1048,7 @@ void
 set_stop_requested (ptid_t ptid, int stop)
 {
   struct thread_info *tp;
-  int all = ptid_equal (ptid, minus_one_ptid);
+  int all = ptid == minus_one_ptid;
 
   if (all || ptid_is_pid (ptid))
     {
@@ -1076,14 +1076,14 @@ finish_thread_state (ptid_t ptid)
   int all;
   int any_started = 0;
 
-  all = ptid_equal (ptid, minus_one_ptid);
+  all = ptid == minus_one_ptid;
 
   if (all || ptid_is_pid (ptid))
     {
       for (tp = thread_list; tp; tp = tp->next)
        {
-         if (tp->state == THREAD_EXITED)
-           continue;
+         if (tp->state == THREAD_EXITED)
+           continue;
          if (all || ptid_get_pid (ptid) == ptid_get_pid (tp->ptid))
            {
              if (set_running_thread (tp, tp->executing))
@@ -1122,7 +1122,7 @@ void
 validate_registers_access (void)
 {
   /* No selected thread, no registers.  */
-  if (ptid_equal (inferior_ptid, null_ptid))
+  if (inferior_ptid == null_ptid)
     error (_("No thread selected."));
 
   /* Don't try to read from a dead thread.  */
@@ -1144,7 +1144,7 @@ bool
 can_access_registers_ptid (ptid_t ptid)
 {
   /* No thread, no registers.  */
-  if (ptid_equal (ptid, null_ptid))
+  if (ptid == null_ptid)
     return false;
 
   /* Don't try to read from a dead thread.  */
@@ -1286,14 +1286,14 @@ print_thread_info_1 (struct ui_out *uiout, char *requested_threads,
       if (uiout->is_mi_like_p ())
        {
          /* Compatibility.  */
-         if (ptid_equal (tp->ptid, current_ptid))
+         if (tp->ptid == current_ptid)
            uiout->text ("* ");
          else
            uiout->text ("  ");
        }
       else
        {
-         if (ptid_equal (tp->ptid, current_ptid))
+         if (tp->ptid == current_ptid)
            uiout->field_string ("current", "*");
          else
            uiout->field_skip ("current");
@@ -1380,7 +1380,7 @@ print_thread_info_1 (struct ui_out *uiout, char *requested_threads,
   if (pid == -1 && requested_threads == NULL)
     {
       if (uiout->is_mi_like_p ()
-         && !ptid_equal (inferior_ptid, null_ptid))
+         && inferior_ptid != null_ptid)
        {
          int num = ptid_to_global_thread_id (inferior_ptid);
 
@@ -1388,12 +1388,11 @@ print_thread_info_1 (struct ui_out *uiout, char *requested_threads,
          uiout->field_int ("current-thread-id", num);
        }
 
-      if (!ptid_equal (inferior_ptid, null_ptid) && is_exited (inferior_ptid))
+      if (inferior_ptid != null_ptid && is_exited (inferior_ptid))
        uiout->message ("\n\
 The current thread <Thread ID %s> has terminated.  See `help thread'.\n",
                        print_thread_id (inferior_thread ()));
-      else if (thread_list != NULL
-              && ptid_equal (inferior_ptid, null_ptid))
+      else if (thread_list != NULL && inferior_ptid == null_ptid)
        uiout->message ("\n\
 No selected thread.  See `help thread'.\n");
     }
@@ -1410,8 +1409,8 @@ print_thread_info (struct ui_out *uiout, char *requested_threads, int pid)
 /* Implementation of the "info threads" command.
 
    Note: this has the drawback that it _really_ switches
-         threads, which frees the frame cache.  A no-side
-         effects info-threads command would be nicer.  */
+        threads, which frees the frame cache.  A no-side
+        effects info-threads command would be nicer.  */
 
 static void
 info_threads_command (char *arg, int from_tty)
@@ -1452,7 +1451,7 @@ switch_to_thread (ptid_t ptid)
   /* Switch the program space as well, if we can infer it from the now
      current thread.  Otherwise, it's up to the caller to select the
      space it wants.  */
-  if (!ptid_equal (ptid, null_ptid))
+  if (ptid != null_ptid)
     {
       struct inferior *inf;
 
@@ -1462,7 +1461,7 @@ switch_to_thread (ptid_t ptid)
       set_current_inferior (inf);
     }
 
-  if (ptid_equal (ptid, inferior_ptid))
+  if (ptid == inferior_ptid)
     return;
 
   inferior_ptid = ptid;
@@ -1471,7 +1470,7 @@ switch_to_thread (ptid_t ptid)
   /* We don't check for is_stopped, because we're called at times
      while in the TARGET_RUNNING state, e.g., while handling an
      internal event.  */
-  if (!ptid_equal (inferior_ptid, null_ptid)
+  if (inferior_ptid != null_ptid
       && !is_exited (ptid)
       && !is_executing (ptid))
     stop_pc = regcache_read_pc (get_thread_regcache (ptid));
@@ -1580,7 +1579,7 @@ do_restore_current_thread_cleanup (void *arg)
 
   /* The running state of the originally selected thread may have
      changed, so we have to recheck it here.  */
-  if (!ptid_equal (inferior_ptid, null_ptid)
+  if (inferior_ptid != null_ptid
       && old->was_stopped
       && is_stopped (inferior_ptid)
       && target_has_registers
@@ -1628,7 +1627,7 @@ make_cleanup_restore_current_thread (void)
   old->inf_id = current_inferior ()->num;
   old->was_removable = current_inferior ()->removable;
 
-  if (!ptid_equal (inferior_ptid, null_ptid))
+  if (inferior_ptid != null_ptid)
     {
       struct frame_info *frame;
 
@@ -1765,16 +1764,16 @@ thread_apply_all_command (char *cmd, int from_tty)
       int i = 0, k;
 
       /* Save a copy of the thread_list in case we execute detach
-         command.  */
+        command.  */
       tp_array = XNEWVEC (struct thread_info *, tc);
       make_cleanup (xfree, tp_array);
 
       ALL_NON_EXITED_THREADS (tp)
-        {
-          tp_array[i] = tp;
-          tp->incref ();
-          i++;
-        }
+       {
+         tp_array[i] = tp;
+         tp->incref ();
+         i++;
+       }
       /* Because we skipped exited threads, we may end up with fewer
         threads in the array than the total count of threads.  */
       gdb_assert (i <= tc);
@@ -1787,16 +1786,16 @@ thread_apply_all_command (char *cmd, int from_tty)
       make_cleanup (set_thread_refcount, &ta_cleanup);
 
       for (k = 0; k != i; k++)
-        if (thread_alive (tp_array[k]))
-          {
-            switch_to_thread (tp_array[k]->ptid);
-            printf_filtered (_("\nThread %s (%s):\n"),
+       if (thread_alive (tp_array[k]))
+         {
+           switch_to_thread (tp_array[k]->ptid);
+           printf_filtered (_("\nThread %s (%s):\n"),
                             print_thread_id (tp_array[k]),
                             target_pid_to_str (inferior_ptid));
-            execute_command (cmd, from_tty);
+           execute_command (cmd, from_tty);
 
-            /* Restore exact command used previously.  */
-            strcpy (cmd, saved_cmd);
+           /* Restore exact command used previously.  */
+           strcpy (cmd, saved_cmd);
          }
     }
 
@@ -1908,7 +1907,7 @@ thread_command (char *tidstr, int from_tty)
 {
   if (tidstr == NULL)
     {
-      if (ptid_equal (inferior_ptid, null_ptid))
+      if (inferior_ptid == null_ptid)
        error (_("No thread selected"));
 
       if (target_has_stack)
@@ -1938,8 +1937,9 @@ thread_command (char *tidstr, int from_tty)
       if (result == GDB_RC_FAIL)
        return;
 
-      /* Print if the thread has not changed, otherwise an event will be sent.  */
-      if (ptid_equal (inferior_ptid, previous_ptid))
+      /* Print if the thread has not changed, otherwise an event will
+        be sent.  */
+      if (inferior_ptid == previous_ptid)
        {
          print_selected_thread_frame (current_uiout,
                                       USER_SELECTED_THREAD
@@ -1960,7 +1960,7 @@ thread_name_command (char *arg, int from_tty)
 {
   struct thread_info *info;
 
-  if (ptid_equal (inferior_ptid, null_ptid))
+  if (inferior_ptid == null_ptid)
     error (_("No thread selected"));
 
   arg = skip_spaces (arg);
@@ -2028,11 +2028,11 @@ thread_find_command (char *arg, int from_tty)
 int print_thread_events = 1;
 static void
 show_print_thread_events (struct ui_file *file, int from_tty,
-                          struct cmd_list_element *c, const char *value)
+                         struct cmd_list_element *c, const char *value)
 {
   fprintf_filtered (file,
                    _("Printing of thread events is %s.\n"),
-                    value);
+                   value);
 }
 
 static int
@@ -2171,7 +2171,8 @@ thread_num_make_value_helper (struct gdbarch *gdbarch, int global)
    threads exist.  */
 
 static struct value *
-thread_id_per_inf_num_make_value (struct gdbarch *gdbarch, struct internalvar *var,
+thread_id_per_inf_num_make_value (struct gdbarch *gdbarch,
+                                 struct internalvar *var,
                                  void *ignore)
 {
   return thread_num_make_value_helper (gdbarch, 0);
@@ -2213,7 +2214,7 @@ _initialize_thread (void)
 {
   static struct cmd_list_element *thread_apply_list = NULL;
 
-  add_info ("threads", info_threads_command, 
+  add_info ("threads", info_threads_command,
            _("Display currently known threads.\n\
 Usage: info threads [-gid] [ID]...\n\
 -gid: Show global thread IDs.\n\
@@ -2253,12 +2254,12 @@ Will display thread ids whose name, target ID, or extra info matches REGEXP."),
   add_com_alias ("t", "thread", class_run, 1);
 
   add_setshow_boolean_cmd ("thread-events", no_class,
-         &print_thread_events, _("\
+                          &print_thread_events, _("\
 Set printing of thread events (such as thread start and exit)."), _("\
 Show printing of thread events (such as thread start and exit)."), NULL,
-         NULL,
-         show_print_thread_events,
-         &setprintlist, &showprintlist);
+                          NULL,
+                          show_print_thread_events,
+                          &setprintlist, &showprintlist);
 
   create_internalvar_type_lazy ("_thread", &thread_funcs, NULL);
   create_internalvar_type_lazy ("_gthread", &gthread_funcs, NULL);
This page took 0.030619 seconds and 4 git commands to generate.