thread.c: cleanup breakpoint deletion
[deliverable/binutils-gdb.git] / gdb / thread.c
1 /* Multi-process/thread control for GDB, the GNU debugger.
2
3 Copyright (C) 1986-2014 Free Software Foundation, Inc.
4
5 Contributed by Lynx Real-Time Systems, Inc. Los Gatos, CA.
6
7 This file is part of GDB.
8
9 This program is free software; you can redistribute it and/or modify
10 it under the terms of the GNU General Public License as published by
11 the Free Software Foundation; either version 3 of the License, or
12 (at your option) any later version.
13
14 This program is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU General Public License for more details.
18
19 You should have received a copy of the GNU General Public License
20 along with this program. If not, see <http://www.gnu.org/licenses/>. */
21
22 #include "defs.h"
23 #include "symtab.h"
24 #include "frame.h"
25 #include "inferior.h"
26 #include "environ.h"
27 #include "value.h"
28 #include "target.h"
29 #include "gdbthread.h"
30 #include "command.h"
31 #include "gdbcmd.h"
32 #include "regcache.h"
33 #include "gdb.h"
34 #include "btrace.h"
35
36 #include <ctype.h>
37 #include <sys/types.h>
38 #include <signal.h>
39 #include "ui-out.h"
40 #include "observer.h"
41 #include "annotate.h"
42 #include "cli/cli-decode.h"
43 #include "gdb_regex.h"
44 #include "cli/cli-utils.h"
45 #include "continuations.h"
46
47 /* Definition of struct thread_info exported to gdbthread.h. */
48
49 /* Prototypes for exported functions. */
50
51 void _initialize_thread (void);
52
53 /* Prototypes for local functions. */
54
55 struct thread_info *thread_list = NULL;
56 static int highest_thread_num;
57
58 /* True if any thread is, or may be executing. We need to track this
59 separately because until we fully sync the thread list, we won't
60 know whether the target is fully stopped, even if we see stop
61 events for all known threads, because any of those threads may have
62 spawned new threads we haven't heard of yet. */
63 static int threads_executing;
64
65 static void thread_command (char *tidstr, int from_tty);
66 static void thread_apply_all_command (char *, int);
67 static int thread_alive (struct thread_info *);
68 static void info_threads_command (char *, int);
69 static void thread_apply_command (char *, int);
70 static void restore_current_thread (ptid_t);
71 static void prune_threads (void);
72
73 /* Data to cleanup thread array. */
74
75 struct thread_array_cleanup
76 {
77 /* Array of thread pointers used to set
78 reference count. */
79 struct thread_info **tp_array;
80
81 /* Thread count in the array. */
82 int count;
83 };
84
85
86 struct thread_info*
87 inferior_thread (void)
88 {
89 struct thread_info *tp = find_thread_ptid (inferior_ptid);
90 gdb_assert (tp);
91 return tp;
92 }
93
94 /* Delete the breakpoint pointed at by BP_P, if there's one. */
95
96 static void
97 delete_thread_breakpoint (struct breakpoint **bp_p)
98 {
99 if (*bp_p != NULL)
100 {
101 delete_breakpoint (*bp_p);
102 *bp_p = NULL;
103 }
104 }
105
106 void
107 delete_step_resume_breakpoint (struct thread_info *tp)
108 {
109 if (tp != NULL)
110 delete_thread_breakpoint (&tp->control.step_resume_breakpoint);
111 }
112
113 void
114 delete_exception_resume_breakpoint (struct thread_info *tp)
115 {
116 if (tp != NULL)
117 delete_thread_breakpoint (&tp->control.exception_resume_breakpoint);
118 }
119
120 /* Delete the breakpoint pointed at by BP_P at the next stop, if
121 there's one. */
122
123 static void
124 delete_at_next_stop (struct breakpoint **bp)
125 {
126 if (*bp != NULL)
127 {
128 (*bp)->disposition = disp_del_at_next_stop;
129 *bp = NULL;
130 }
131 }
132
133 static void
134 clear_thread_inferior_resources (struct thread_info *tp)
135 {
136 /* NOTE: this will take care of any left-over step_resume breakpoints,
137 but not any user-specified thread-specific breakpoints. We can not
138 delete the breakpoint straight-off, because the inferior might not
139 be stopped at the moment. */
140 delete_at_next_stop (&tp->control.step_resume_breakpoint);
141 delete_at_next_stop (&tp->control.exception_resume_breakpoint);
142
143 delete_longjmp_breakpoint_at_next_stop (tp->num);
144
145 bpstat_clear (&tp->control.stop_bpstat);
146
147 btrace_teardown (tp);
148
149 do_all_intermediate_continuations_thread (tp, 1);
150 do_all_continuations_thread (tp, 1);
151 }
152
153 static void
154 free_thread (struct thread_info *tp)
155 {
156 if (tp->private)
157 {
158 if (tp->private_dtor)
159 tp->private_dtor (tp->private);
160 else
161 xfree (tp->private);
162 }
163
164 xfree (tp->name);
165 xfree (tp);
166 }
167
168 void
169 init_thread_list (void)
170 {
171 struct thread_info *tp, *tpnext;
172
173 highest_thread_num = 0;
174
175 if (!thread_list)
176 return;
177
178 for (tp = thread_list; tp; tp = tpnext)
179 {
180 tpnext = tp->next;
181 free_thread (tp);
182 }
183
184 thread_list = NULL;
185 threads_executing = 0;
186 }
187
188 /* Allocate a new thread with target id PTID and add it to the thread
189 list. */
190
191 static struct thread_info *
192 new_thread (ptid_t ptid)
193 {
194 struct thread_info *tp;
195
196 tp = xcalloc (1, sizeof (*tp));
197
198 tp->ptid = ptid;
199 tp->num = ++highest_thread_num;
200 tp->next = thread_list;
201 thread_list = tp;
202
203 /* Nothing to follow yet. */
204 tp->pending_follow.kind = TARGET_WAITKIND_SPURIOUS;
205 tp->state = THREAD_STOPPED;
206
207 return tp;
208 }
209
210 struct thread_info *
211 add_thread_silent (ptid_t ptid)
212 {
213 struct thread_info *tp;
214
215 tp = find_thread_ptid (ptid);
216 if (tp)
217 /* Found an old thread with the same id. It has to be dead,
218 otherwise we wouldn't be adding a new thread with the same id.
219 The OS is reusing this id --- delete it, and recreate a new
220 one. */
221 {
222 /* In addition to deleting the thread, if this is the current
223 thread, then we need to take care that delete_thread doesn't
224 really delete the thread if it is inferior_ptid. Create a
225 new template thread in the list with an invalid ptid, switch
226 to it, delete the original thread, reset the new thread's
227 ptid, and switch to it. */
228
229 if (ptid_equal (inferior_ptid, ptid))
230 {
231 tp = new_thread (null_ptid);
232
233 /* Make switch_to_thread not read from the thread. */
234 tp->state = THREAD_EXITED;
235 switch_to_thread (null_ptid);
236
237 /* Now we can delete it. */
238 delete_thread (ptid);
239
240 /* Now reset its ptid, and reswitch inferior_ptid to it. */
241 tp->ptid = ptid;
242 tp->state = THREAD_STOPPED;
243 switch_to_thread (ptid);
244
245 observer_notify_new_thread (tp);
246
247 /* All done. */
248 return tp;
249 }
250 else
251 /* Just go ahead and delete it. */
252 delete_thread (ptid);
253 }
254
255 tp = new_thread (ptid);
256 observer_notify_new_thread (tp);
257
258 return tp;
259 }
260
261 struct thread_info *
262 add_thread_with_info (ptid_t ptid, struct private_thread_info *private)
263 {
264 struct thread_info *result = add_thread_silent (ptid);
265
266 result->private = private;
267
268 if (print_thread_events)
269 printf_unfiltered (_("[New %s]\n"), target_pid_to_str (ptid));
270
271 annotate_new_thread ();
272 return result;
273 }
274
275 struct thread_info *
276 add_thread (ptid_t ptid)
277 {
278 return add_thread_with_info (ptid, NULL);
279 }
280
281 /* Delete thread PTID. If SILENT, don't notify the observer of this
282 exit. */
283 static void
284 delete_thread_1 (ptid_t ptid, int silent)
285 {
286 struct thread_info *tp, *tpprev;
287
288 tpprev = NULL;
289
290 for (tp = thread_list; tp; tpprev = tp, tp = tp->next)
291 if (ptid_equal (tp->ptid, ptid))
292 break;
293
294 if (!tp)
295 return;
296
297 /* If this is the current thread, or there's code out there that
298 relies on it existing (refcount > 0) we can't delete yet. Mark
299 it as exited, and notify it. */
300 if (tp->refcount > 0
301 || ptid_equal (tp->ptid, inferior_ptid))
302 {
303 if (tp->state != THREAD_EXITED)
304 {
305 observer_notify_thread_exit (tp, silent);
306
307 /* Tag it as exited. */
308 tp->state = THREAD_EXITED;
309
310 /* Clear breakpoints, etc. associated with this thread. */
311 clear_thread_inferior_resources (tp);
312 }
313
314 /* Will be really deleted some other time. */
315 return;
316 }
317
318 /* Notify thread exit, but only if we haven't already. */
319 if (tp->state != THREAD_EXITED)
320 observer_notify_thread_exit (tp, silent);
321
322 /* Tag it as exited. */
323 tp->state = THREAD_EXITED;
324 clear_thread_inferior_resources (tp);
325
326 if (tpprev)
327 tpprev->next = tp->next;
328 else
329 thread_list = tp->next;
330
331 free_thread (tp);
332 }
333
334 /* Delete thread PTID and notify of thread exit. If this is
335 inferior_ptid, don't actually delete it, but tag it as exited and
336 do the notification. If PTID is the user selected thread, clear
337 it. */
338 void
339 delete_thread (ptid_t ptid)
340 {
341 delete_thread_1 (ptid, 0 /* not silent */);
342 }
343
344 void
345 delete_thread_silent (ptid_t ptid)
346 {
347 delete_thread_1 (ptid, 1 /* silent */);
348 }
349
350 struct thread_info *
351 find_thread_id (int num)
352 {
353 struct thread_info *tp;
354
355 for (tp = thread_list; tp; tp = tp->next)
356 if (tp->num == num)
357 return tp;
358
359 return NULL;
360 }
361
362 /* Find a thread_info by matching PTID. */
363 struct thread_info *
364 find_thread_ptid (ptid_t ptid)
365 {
366 struct thread_info *tp;
367
368 for (tp = thread_list; tp; tp = tp->next)
369 if (ptid_equal (tp->ptid, ptid))
370 return tp;
371
372 return NULL;
373 }
374
375 /*
376 * Thread iterator function.
377 *
378 * Calls a callback function once for each thread, so long as
379 * the callback function returns false. If the callback function
380 * returns true, the iteration will end and the current thread
381 * will be returned. This can be useful for implementing a
382 * search for a thread with arbitrary attributes, or for applying
383 * some operation to every thread.
384 *
385 * FIXME: some of the existing functionality, such as
386 * "Thread apply all", might be rewritten using this functionality.
387 */
388
389 struct thread_info *
390 iterate_over_threads (int (*callback) (struct thread_info *, void *),
391 void *data)
392 {
393 struct thread_info *tp, *next;
394
395 for (tp = thread_list; tp; tp = next)
396 {
397 next = tp->next;
398 if ((*callback) (tp, data))
399 return tp;
400 }
401
402 return NULL;
403 }
404
405 int
406 thread_count (void)
407 {
408 int result = 0;
409 struct thread_info *tp;
410
411 for (tp = thread_list; tp; tp = tp->next)
412 ++result;
413
414 return result;
415 }
416
417 int
418 valid_thread_id (int num)
419 {
420 struct thread_info *tp;
421
422 for (tp = thread_list; tp; tp = tp->next)
423 if (tp->num == num)
424 return 1;
425
426 return 0;
427 }
428
429 int
430 pid_to_thread_id (ptid_t ptid)
431 {
432 struct thread_info *tp;
433
434 for (tp = thread_list; tp; tp = tp->next)
435 if (ptid_equal (tp->ptid, ptid))
436 return tp->num;
437
438 return 0;
439 }
440
441 ptid_t
442 thread_id_to_pid (int num)
443 {
444 struct thread_info *thread = find_thread_id (num);
445
446 if (thread)
447 return thread->ptid;
448 else
449 return pid_to_ptid (-1);
450 }
451
452 int
453 in_thread_list (ptid_t ptid)
454 {
455 struct thread_info *tp;
456
457 for (tp = thread_list; tp; tp = tp->next)
458 if (ptid_equal (tp->ptid, ptid))
459 return 1;
460
461 return 0; /* Never heard of 'im. */
462 }
463
464 /* Finds the first thread of the inferior given by PID. If PID is -1,
465 return the first thread in the list. */
466
467 struct thread_info *
468 first_thread_of_process (int pid)
469 {
470 struct thread_info *tp, *ret = NULL;
471
472 for (tp = thread_list; tp; tp = tp->next)
473 if (pid == -1 || ptid_get_pid (tp->ptid) == pid)
474 if (ret == NULL || tp->num < ret->num)
475 ret = tp;
476
477 return ret;
478 }
479
480 struct thread_info *
481 any_thread_of_process (int pid)
482 {
483 struct thread_info *tp;
484
485 gdb_assert (pid != 0);
486
487 /* Prefer the current thread. */
488 if (ptid_get_pid (inferior_ptid) == pid)
489 return inferior_thread ();
490
491 ALL_NON_EXITED_THREADS (tp)
492 if (ptid_get_pid (tp->ptid) == pid)
493 return tp;
494
495 return NULL;
496 }
497
498 struct thread_info *
499 any_live_thread_of_process (int pid)
500 {
501 struct thread_info *curr_tp = NULL;
502 struct thread_info *tp;
503 struct thread_info *tp_executing = NULL;
504
505 gdb_assert (pid != 0);
506
507 /* Prefer the current thread if it's not executing. */
508 if (ptid_get_pid (inferior_ptid) == pid)
509 {
510 /* If the current thread is dead, forget it. If it's not
511 executing, use it. Otherwise, still choose it (below), but
512 only if no other non-executing thread is found. */
513 curr_tp = inferior_thread ();
514 if (curr_tp->state == THREAD_EXITED)
515 curr_tp = NULL;
516 else if (!curr_tp->executing)
517 return curr_tp;
518 }
519
520 ALL_NON_EXITED_THREADS (tp)
521 if (ptid_get_pid (tp->ptid) == pid)
522 {
523 if (!tp->executing)
524 return tp;
525
526 tp_executing = tp;
527 }
528
529 /* If both the current thread and all live threads are executing,
530 prefer the current thread. */
531 if (curr_tp != NULL)
532 return curr_tp;
533
534 /* Otherwise, just return an executing thread, if any. */
535 return tp_executing;
536 }
537
538 /* Print a list of thread ids currently known, and the total number of
539 threads. To be used from within catch_errors. */
540 static int
541 do_captured_list_thread_ids (struct ui_out *uiout, void *arg)
542 {
543 struct thread_info *tp;
544 int num = 0;
545 struct cleanup *cleanup_chain;
546 int current_thread = -1;
547
548 update_thread_list ();
549
550 cleanup_chain = make_cleanup_ui_out_tuple_begin_end (uiout, "thread-ids");
551
552 for (tp = thread_list; tp; tp = tp->next)
553 {
554 if (tp->state == THREAD_EXITED)
555 continue;
556
557 if (ptid_equal (tp->ptid, inferior_ptid))
558 current_thread = tp->num;
559
560 num++;
561 ui_out_field_int (uiout, "thread-id", tp->num);
562 }
563
564 do_cleanups (cleanup_chain);
565
566 if (current_thread != -1)
567 ui_out_field_int (uiout, "current-thread-id", current_thread);
568 ui_out_field_int (uiout, "number-of-threads", num);
569 return GDB_RC_OK;
570 }
571
572 /* Official gdblib interface function to get a list of thread ids and
573 the total number. */
574 enum gdb_rc
575 gdb_list_thread_ids (struct ui_out *uiout, char **error_message)
576 {
577 if (catch_exceptions_with_msg (uiout, do_captured_list_thread_ids, NULL,
578 error_message, RETURN_MASK_ALL) < 0)
579 return GDB_RC_FAIL;
580 return GDB_RC_OK;
581 }
582
583 /* Return true if TP is an active thread. */
584 static int
585 thread_alive (struct thread_info *tp)
586 {
587 if (tp->state == THREAD_EXITED)
588 return 0;
589 if (!target_thread_alive (tp->ptid))
590 return 0;
591 return 1;
592 }
593
594 static void
595 prune_threads (void)
596 {
597 struct thread_info *tp, *next;
598
599 for (tp = thread_list; tp; tp = next)
600 {
601 next = tp->next;
602 if (!thread_alive (tp))
603 delete_thread (tp->ptid);
604 }
605 }
606
607 void
608 thread_change_ptid (ptid_t old_ptid, ptid_t new_ptid)
609 {
610 struct inferior *inf;
611 struct thread_info *tp;
612
613 /* It can happen that what we knew as the target inferior id
614 changes. E.g, target remote may only discover the remote process
615 pid after adding the inferior to GDB's list. */
616 inf = find_inferior_pid (ptid_get_pid (old_ptid));
617 inf->pid = ptid_get_pid (new_ptid);
618
619 tp = find_thread_ptid (old_ptid);
620 tp->ptid = new_ptid;
621
622 observer_notify_thread_ptid_changed (old_ptid, new_ptid);
623 }
624
625 void
626 set_running (ptid_t ptid, int running)
627 {
628 struct thread_info *tp;
629 int all = ptid_equal (ptid, minus_one_ptid);
630
631 /* We try not to notify the observer if no thread has actually changed
632 the running state -- merely to reduce the number of messages to
633 frontend. Frontend is supposed to handle multiple *running just fine. */
634 if (all || ptid_is_pid (ptid))
635 {
636 int any_started = 0;
637
638 for (tp = thread_list; tp; tp = tp->next)
639 if (all || ptid_get_pid (tp->ptid) == ptid_get_pid (ptid))
640 {
641 if (tp->state == THREAD_EXITED)
642 continue;
643 if (running && tp->state == THREAD_STOPPED)
644 any_started = 1;
645 tp->state = running ? THREAD_RUNNING : THREAD_STOPPED;
646 }
647 if (any_started)
648 observer_notify_target_resumed (ptid);
649 }
650 else
651 {
652 int started = 0;
653
654 tp = find_thread_ptid (ptid);
655 gdb_assert (tp);
656 gdb_assert (tp->state != THREAD_EXITED);
657 if (running && tp->state == THREAD_STOPPED)
658 started = 1;
659 tp->state = running ? THREAD_RUNNING : THREAD_STOPPED;
660 if (started)
661 observer_notify_target_resumed (ptid);
662 }
663 }
664
665 static int
666 is_thread_state (ptid_t ptid, enum thread_state state)
667 {
668 struct thread_info *tp;
669
670 tp = find_thread_ptid (ptid);
671 gdb_assert (tp);
672 return tp->state == state;
673 }
674
675 int
676 is_stopped (ptid_t ptid)
677 {
678 return is_thread_state (ptid, THREAD_STOPPED);
679 }
680
681 int
682 is_exited (ptid_t ptid)
683 {
684 return is_thread_state (ptid, THREAD_EXITED);
685 }
686
687 int
688 is_running (ptid_t ptid)
689 {
690 return is_thread_state (ptid, THREAD_RUNNING);
691 }
692
693 int
694 is_executing (ptid_t ptid)
695 {
696 struct thread_info *tp;
697
698 tp = find_thread_ptid (ptid);
699 gdb_assert (tp);
700 return tp->executing;
701 }
702
703 void
704 set_executing (ptid_t ptid, int executing)
705 {
706 struct thread_info *tp;
707 int all = ptid_equal (ptid, minus_one_ptid);
708
709 if (all || ptid_is_pid (ptid))
710 {
711 for (tp = thread_list; tp; tp = tp->next)
712 if (all || ptid_get_pid (tp->ptid) == ptid_get_pid (ptid))
713 tp->executing = executing;
714 }
715 else
716 {
717 tp = find_thread_ptid (ptid);
718 gdb_assert (tp);
719 tp->executing = executing;
720 }
721
722 /* It only takes one running thread to spawn more threads.*/
723 if (executing)
724 threads_executing = 1;
725 /* Only clear the flag if the caller is telling us everything is
726 stopped. */
727 else if (ptid_equal (minus_one_ptid, ptid))
728 threads_executing = 0;
729 }
730
731 /* See gdbthread.h. */
732
733 int
734 threads_are_executing (void)
735 {
736 return threads_executing;
737 }
738
739 void
740 set_stop_requested (ptid_t ptid, int stop)
741 {
742 struct thread_info *tp;
743 int all = ptid_equal (ptid, minus_one_ptid);
744
745 if (all || ptid_is_pid (ptid))
746 {
747 for (tp = thread_list; tp; tp = tp->next)
748 if (all || ptid_get_pid (tp->ptid) == ptid_get_pid (ptid))
749 tp->stop_requested = stop;
750 }
751 else
752 {
753 tp = find_thread_ptid (ptid);
754 gdb_assert (tp);
755 tp->stop_requested = stop;
756 }
757
758 /* Call the stop requested observer so other components of GDB can
759 react to this request. */
760 if (stop)
761 observer_notify_thread_stop_requested (ptid);
762 }
763
764 void
765 finish_thread_state (ptid_t ptid)
766 {
767 struct thread_info *tp;
768 int all;
769 int any_started = 0;
770
771 all = ptid_equal (ptid, minus_one_ptid);
772
773 if (all || ptid_is_pid (ptid))
774 {
775 for (tp = thread_list; tp; tp = tp->next)
776 {
777 if (tp->state == THREAD_EXITED)
778 continue;
779 if (all || ptid_get_pid (ptid) == ptid_get_pid (tp->ptid))
780 {
781 if (tp->executing && tp->state == THREAD_STOPPED)
782 any_started = 1;
783 tp->state = tp->executing ? THREAD_RUNNING : THREAD_STOPPED;
784 }
785 }
786 }
787 else
788 {
789 tp = find_thread_ptid (ptid);
790 gdb_assert (tp);
791 if (tp->state != THREAD_EXITED)
792 {
793 if (tp->executing && tp->state == THREAD_STOPPED)
794 any_started = 1;
795 tp->state = tp->executing ? THREAD_RUNNING : THREAD_STOPPED;
796 }
797 }
798
799 if (any_started)
800 observer_notify_target_resumed (ptid);
801 }
802
803 void
804 finish_thread_state_cleanup (void *arg)
805 {
806 ptid_t *ptid_p = arg;
807
808 gdb_assert (arg);
809
810 finish_thread_state (*ptid_p);
811 }
812
813 int
814 pc_in_thread_step_range (CORE_ADDR pc, struct thread_info *thread)
815 {
816 return (pc >= thread->control.step_range_start
817 && pc < thread->control.step_range_end);
818 }
819
820 /* Prints the list of threads and their details on UIOUT.
821 This is a version of 'info_threads_command' suitable for
822 use from MI.
823 If REQUESTED_THREAD is not -1, it's the GDB id of the thread
824 that should be printed. Otherwise, all threads are
825 printed.
826 If PID is not -1, only print threads from the process PID.
827 Otherwise, threads from all attached PIDs are printed.
828 If both REQUESTED_THREAD and PID are not -1, then the thread
829 is printed if it belongs to the specified process. Otherwise,
830 an error is raised. */
831 void
832 print_thread_info (struct ui_out *uiout, char *requested_threads, int pid)
833 {
834 struct thread_info *tp;
835 ptid_t current_ptid;
836 struct cleanup *old_chain;
837 char *extra_info, *name, *target_id;
838 int current_thread = -1;
839
840 update_thread_list ();
841 current_ptid = inferior_ptid;
842
843 /* We'll be switching threads temporarily. */
844 old_chain = make_cleanup_restore_current_thread ();
845
846 /* For backward compatibility, we make a list for MI. A table is
847 preferable for the CLI, though, because it shows table
848 headers. */
849 if (ui_out_is_mi_like_p (uiout))
850 make_cleanup_ui_out_list_begin_end (uiout, "threads");
851 else
852 {
853 int n_threads = 0;
854
855 for (tp = thread_list; tp; tp = tp->next)
856 {
857 if (!number_is_in_list (requested_threads, tp->num))
858 continue;
859
860 if (pid != -1 && ptid_get_pid (tp->ptid) != pid)
861 continue;
862
863 if (tp->state == THREAD_EXITED)
864 continue;
865
866 ++n_threads;
867 }
868
869 if (n_threads == 0)
870 {
871 if (requested_threads == NULL || *requested_threads == '\0')
872 ui_out_message (uiout, 0, _("No threads.\n"));
873 else
874 ui_out_message (uiout, 0, _("No threads match '%s'.\n"),
875 requested_threads);
876 do_cleanups (old_chain);
877 return;
878 }
879
880 make_cleanup_ui_out_table_begin_end (uiout, 4, n_threads, "threads");
881
882 ui_out_table_header (uiout, 1, ui_left, "current", "");
883 ui_out_table_header (uiout, 4, ui_left, "id", "Id");
884 ui_out_table_header (uiout, 17, ui_left, "target-id", "Target Id");
885 ui_out_table_header (uiout, 1, ui_left, "frame", "Frame");
886 ui_out_table_body (uiout);
887 }
888
889 for (tp = thread_list; tp; tp = tp->next)
890 {
891 struct cleanup *chain2;
892 int core;
893
894 if (!number_is_in_list (requested_threads, tp->num))
895 continue;
896
897 if (pid != -1 && ptid_get_pid (tp->ptid) != pid)
898 {
899 if (requested_threads != NULL && *requested_threads != '\0')
900 error (_("Requested thread not found in requested process"));
901 continue;
902 }
903
904 if (ptid_equal (tp->ptid, current_ptid))
905 current_thread = tp->num;
906
907 if (tp->state == THREAD_EXITED)
908 continue;
909
910 chain2 = make_cleanup_ui_out_tuple_begin_end (uiout, NULL);
911
912 if (ui_out_is_mi_like_p (uiout))
913 {
914 /* Compatibility. */
915 if (ptid_equal (tp->ptid, current_ptid))
916 ui_out_text (uiout, "* ");
917 else
918 ui_out_text (uiout, " ");
919 }
920 else
921 {
922 if (ptid_equal (tp->ptid, current_ptid))
923 ui_out_field_string (uiout, "current", "*");
924 else
925 ui_out_field_skip (uiout, "current");
926 }
927
928 ui_out_field_int (uiout, "id", tp->num);
929
930 /* For the CLI, we stuff everything into the target-id field.
931 This is a gross hack to make the output come out looking
932 correct. The underlying problem here is that ui-out has no
933 way to specify that a field's space allocation should be
934 shared by several fields. For MI, we do the right thing
935 instead. */
936
937 target_id = target_pid_to_str (tp->ptid);
938 extra_info = target_extra_thread_info (tp);
939 name = tp->name ? tp->name : target_thread_name (tp);
940
941 if (ui_out_is_mi_like_p (uiout))
942 {
943 ui_out_field_string (uiout, "target-id", target_id);
944 if (extra_info)
945 ui_out_field_string (uiout, "details", extra_info);
946 if (name)
947 ui_out_field_string (uiout, "name", name);
948 }
949 else
950 {
951 struct cleanup *str_cleanup;
952 char *contents;
953
954 if (extra_info && name)
955 contents = xstrprintf ("%s \"%s\" (%s)", target_id,
956 name, extra_info);
957 else if (extra_info)
958 contents = xstrprintf ("%s (%s)", target_id, extra_info);
959 else if (name)
960 contents = xstrprintf ("%s \"%s\"", target_id, name);
961 else
962 contents = xstrdup (target_id);
963 str_cleanup = make_cleanup (xfree, contents);
964
965 ui_out_field_string (uiout, "target-id", contents);
966 do_cleanups (str_cleanup);
967 }
968
969 if (tp->state == THREAD_RUNNING)
970 ui_out_text (uiout, "(running)\n");
971 else
972 {
973 /* The switch below puts us at the top of the stack (leaf
974 frame). */
975 switch_to_thread (tp->ptid);
976 print_stack_frame (get_selected_frame (NULL),
977 /* For MI output, print frame level. */
978 ui_out_is_mi_like_p (uiout),
979 LOCATION, 0);
980 }
981
982 if (ui_out_is_mi_like_p (uiout))
983 {
984 char *state = "stopped";
985
986 if (tp->state == THREAD_RUNNING)
987 state = "running";
988 ui_out_field_string (uiout, "state", state);
989 }
990
991 core = target_core_of_thread (tp->ptid);
992 if (ui_out_is_mi_like_p (uiout) && core != -1)
993 ui_out_field_int (uiout, "core", core);
994
995 do_cleanups (chain2);
996 }
997
998 /* Restores the current thread and the frame selected before
999 the "info threads" command. */
1000 do_cleanups (old_chain);
1001
1002 if (pid == -1 && requested_threads == NULL)
1003 {
1004 gdb_assert (current_thread != -1
1005 || !thread_list
1006 || ptid_equal (inferior_ptid, null_ptid));
1007 if (current_thread != -1 && ui_out_is_mi_like_p (uiout))
1008 ui_out_field_int (uiout, "current-thread-id", current_thread);
1009
1010 if (current_thread != -1 && is_exited (current_ptid))
1011 ui_out_message (uiout, 0, "\n\
1012 The current thread <Thread ID %d> has terminated. See `help thread'.\n",
1013 current_thread);
1014 else if (thread_list
1015 && current_thread == -1
1016 && ptid_equal (current_ptid, null_ptid))
1017 ui_out_message (uiout, 0, "\n\
1018 No selected thread. See `help thread'.\n");
1019 }
1020 }
1021
1022 /* Print information about currently known threads
1023
1024 Optional ARG is a thread id, or list of thread ids.
1025
1026 Note: this has the drawback that it _really_ switches
1027 threads, which frees the frame cache. A no-side
1028 effects info-threads command would be nicer. */
1029
1030 static void
1031 info_threads_command (char *arg, int from_tty)
1032 {
1033 print_thread_info (current_uiout, arg, -1);
1034 }
1035
1036 /* Switch from one thread to another. */
1037
1038 void
1039 switch_to_thread (ptid_t ptid)
1040 {
1041 /* Switch the program space as well, if we can infer it from the now
1042 current thread. Otherwise, it's up to the caller to select the
1043 space it wants. */
1044 if (!ptid_equal (ptid, null_ptid))
1045 {
1046 struct inferior *inf;
1047
1048 inf = find_inferior_pid (ptid_get_pid (ptid));
1049 gdb_assert (inf != NULL);
1050 set_current_program_space (inf->pspace);
1051 set_current_inferior (inf);
1052 }
1053
1054 if (ptid_equal (ptid, inferior_ptid))
1055 return;
1056
1057 inferior_ptid = ptid;
1058 reinit_frame_cache ();
1059
1060 /* We don't check for is_stopped, because we're called at times
1061 while in the TARGET_RUNNING state, e.g., while handling an
1062 internal event. */
1063 if (!ptid_equal (inferior_ptid, null_ptid)
1064 && !is_exited (ptid)
1065 && !is_executing (ptid))
1066 stop_pc = regcache_read_pc (get_thread_regcache (ptid));
1067 else
1068 stop_pc = ~(CORE_ADDR) 0;
1069 }
1070
1071 static void
1072 restore_current_thread (ptid_t ptid)
1073 {
1074 switch_to_thread (ptid);
1075 }
1076
1077 static void
1078 restore_selected_frame (struct frame_id a_frame_id, int frame_level)
1079 {
1080 struct frame_info *frame = NULL;
1081 int count;
1082
1083 /* This means there was no selected frame. */
1084 if (frame_level == -1)
1085 {
1086 select_frame (NULL);
1087 return;
1088 }
1089
1090 gdb_assert (frame_level >= 0);
1091
1092 /* Restore by level first, check if the frame id is the same as
1093 expected. If that fails, try restoring by frame id. If that
1094 fails, nothing to do, just warn the user. */
1095
1096 count = frame_level;
1097 frame = find_relative_frame (get_current_frame (), &count);
1098 if (count == 0
1099 && frame != NULL
1100 /* The frame ids must match - either both valid or both outer_frame_id.
1101 The latter case is not failsafe, but since it's highly unlikely
1102 the search by level finds the wrong frame, it's 99.9(9)% of
1103 the time (for all practical purposes) safe. */
1104 && frame_id_eq (get_frame_id (frame), a_frame_id))
1105 {
1106 /* Cool, all is fine. */
1107 select_frame (frame);
1108 return;
1109 }
1110
1111 frame = frame_find_by_id (a_frame_id);
1112 if (frame != NULL)
1113 {
1114 /* Cool, refound it. */
1115 select_frame (frame);
1116 return;
1117 }
1118
1119 /* Nothing else to do, the frame layout really changed. Select the
1120 innermost stack frame. */
1121 select_frame (get_current_frame ());
1122
1123 /* Warn the user. */
1124 if (frame_level > 0 && !ui_out_is_mi_like_p (current_uiout))
1125 {
1126 warning (_("Couldn't restore frame #%d in "
1127 "current thread. Bottom (innermost) frame selected:"),
1128 frame_level);
1129 /* For MI, we should probably have a notification about
1130 current frame change. But this error is not very
1131 likely, so don't bother for now. */
1132 print_stack_frame (get_selected_frame (NULL), 1, SRC_AND_LOC, 1);
1133 }
1134 }
1135
1136 struct current_thread_cleanup
1137 {
1138 ptid_t inferior_ptid;
1139 struct frame_id selected_frame_id;
1140 int selected_frame_level;
1141 int was_stopped;
1142 int inf_id;
1143 int was_removable;
1144 };
1145
1146 static void
1147 do_restore_current_thread_cleanup (void *arg)
1148 {
1149 struct thread_info *tp;
1150 struct current_thread_cleanup *old = arg;
1151
1152 tp = find_thread_ptid (old->inferior_ptid);
1153
1154 /* If the previously selected thread belonged to a process that has
1155 in the mean time been deleted (due to normal exit, detach, etc.),
1156 then don't revert back to it, but instead simply drop back to no
1157 thread selected. */
1158 if (tp
1159 && find_inferior_pid (ptid_get_pid (tp->ptid)) != NULL)
1160 restore_current_thread (old->inferior_ptid);
1161 else
1162 {
1163 restore_current_thread (null_ptid);
1164 set_current_inferior (find_inferior_id (old->inf_id));
1165 }
1166
1167 /* The running state of the originally selected thread may have
1168 changed, so we have to recheck it here. */
1169 if (!ptid_equal (inferior_ptid, null_ptid)
1170 && old->was_stopped
1171 && is_stopped (inferior_ptid)
1172 && target_has_registers
1173 && target_has_stack
1174 && target_has_memory)
1175 restore_selected_frame (old->selected_frame_id,
1176 old->selected_frame_level);
1177 }
1178
1179 static void
1180 restore_current_thread_cleanup_dtor (void *arg)
1181 {
1182 struct current_thread_cleanup *old = arg;
1183 struct thread_info *tp;
1184 struct inferior *inf;
1185
1186 tp = find_thread_ptid (old->inferior_ptid);
1187 if (tp)
1188 tp->refcount--;
1189 inf = find_inferior_id (old->inf_id);
1190 if (inf != NULL)
1191 inf->removable = old->was_removable;
1192 xfree (old);
1193 }
1194
1195 /* Set the thread reference count. */
1196
1197 static void
1198 set_thread_refcount (void *data)
1199 {
1200 int k;
1201 struct thread_array_cleanup *ta_cleanup = data;
1202
1203 for (k = 0; k != ta_cleanup->count; k++)
1204 ta_cleanup->tp_array[k]->refcount--;
1205 }
1206
1207 struct cleanup *
1208 make_cleanup_restore_current_thread (void)
1209 {
1210 struct thread_info *tp;
1211 struct frame_info *frame;
1212 struct current_thread_cleanup *old;
1213
1214 old = xmalloc (sizeof (struct current_thread_cleanup));
1215 old->inferior_ptid = inferior_ptid;
1216 old->inf_id = current_inferior ()->num;
1217 old->was_removable = current_inferior ()->removable;
1218
1219 if (!ptid_equal (inferior_ptid, null_ptid))
1220 {
1221 old->was_stopped = is_stopped (inferior_ptid);
1222 if (old->was_stopped
1223 && target_has_registers
1224 && target_has_stack
1225 && target_has_memory)
1226 {
1227 /* When processing internal events, there might not be a
1228 selected frame. If we naively call get_selected_frame
1229 here, then we can end up reading debuginfo for the
1230 current frame, but we don't generally need the debuginfo
1231 at this point. */
1232 frame = get_selected_frame_if_set ();
1233 }
1234 else
1235 frame = NULL;
1236
1237 old->selected_frame_id = get_frame_id (frame);
1238 old->selected_frame_level = frame_relative_level (frame);
1239
1240 tp = find_thread_ptid (inferior_ptid);
1241 if (tp)
1242 tp->refcount++;
1243 }
1244
1245 current_inferior ()->removable = 0;
1246
1247 return make_cleanup_dtor (do_restore_current_thread_cleanup, old,
1248 restore_current_thread_cleanup_dtor);
1249 }
1250
1251 /* Apply a GDB command to a list of threads. List syntax is a whitespace
1252 seperated list of numbers, or ranges, or the keyword `all'. Ranges consist
1253 of two numbers seperated by a hyphen. Examples:
1254
1255 thread apply 1 2 7 4 backtrace Apply backtrace cmd to threads 1,2,7,4
1256 thread apply 2-7 9 p foo(1) Apply p foo(1) cmd to threads 2->7 & 9
1257 thread apply all p x/i $pc Apply x/i $pc cmd to all threads. */
1258
1259 static void
1260 thread_apply_all_command (char *cmd, int from_tty)
1261 {
1262 struct cleanup *old_chain;
1263 char *saved_cmd;
1264 int tc;
1265 struct thread_array_cleanup ta_cleanup;
1266
1267 if (cmd == NULL || *cmd == '\000')
1268 error (_("Please specify a command following the thread ID list"));
1269
1270 update_thread_list ();
1271
1272 old_chain = make_cleanup_restore_current_thread ();
1273
1274 /* Save a copy of the command in case it is clobbered by
1275 execute_command. */
1276 saved_cmd = xstrdup (cmd);
1277 make_cleanup (xfree, saved_cmd);
1278 tc = thread_count ();
1279
1280 if (tc)
1281 {
1282 struct thread_info **tp_array;
1283 struct thread_info *tp;
1284 int i = 0, k;
1285
1286 /* Save a copy of the thread_list in case we execute detach
1287 command. */
1288 tp_array = xmalloc (sizeof (struct thread_info *) * tc);
1289 make_cleanup (xfree, tp_array);
1290 ta_cleanup.tp_array = tp_array;
1291 ta_cleanup.count = tc;
1292
1293 ALL_NON_EXITED_THREADS (tp)
1294 {
1295 tp_array[i] = tp;
1296 tp->refcount++;
1297 i++;
1298 }
1299
1300 make_cleanup (set_thread_refcount, &ta_cleanup);
1301
1302 for (k = 0; k != i; k++)
1303 if (thread_alive (tp_array[k]))
1304 {
1305 switch_to_thread (tp_array[k]->ptid);
1306 printf_filtered (_("\nThread %d (%s):\n"),
1307 tp_array[k]->num,
1308 target_pid_to_str (inferior_ptid));
1309 execute_command (cmd, from_tty);
1310
1311 /* Restore exact command used previously. */
1312 strcpy (cmd, saved_cmd);
1313 }
1314 }
1315
1316 do_cleanups (old_chain);
1317 }
1318
1319 static void
1320 thread_apply_command (char *tidlist, int from_tty)
1321 {
1322 char *cmd;
1323 struct cleanup *old_chain;
1324 char *saved_cmd;
1325 struct get_number_or_range_state state;
1326
1327 if (tidlist == NULL || *tidlist == '\000')
1328 error (_("Please specify a thread ID list"));
1329
1330 for (cmd = tidlist; *cmd != '\000' && !isalpha (*cmd); cmd++);
1331
1332 if (*cmd == '\000')
1333 error (_("Please specify a command following the thread ID list"));
1334
1335 /* Save a copy of the command in case it is clobbered by
1336 execute_command. */
1337 saved_cmd = xstrdup (cmd);
1338 old_chain = make_cleanup (xfree, saved_cmd);
1339
1340 init_number_or_range (&state, tidlist);
1341 while (!state.finished && state.string < cmd)
1342 {
1343 struct thread_info *tp;
1344 int start;
1345
1346 start = get_number_or_range (&state);
1347
1348 make_cleanup_restore_current_thread ();
1349
1350 tp = find_thread_id (start);
1351
1352 if (!tp)
1353 warning (_("Unknown thread %d."), start);
1354 else if (!thread_alive (tp))
1355 warning (_("Thread %d has terminated."), start);
1356 else
1357 {
1358 switch_to_thread (tp->ptid);
1359
1360 printf_filtered (_("\nThread %d (%s):\n"), tp->num,
1361 target_pid_to_str (inferior_ptid));
1362 execute_command (cmd, from_tty);
1363
1364 /* Restore exact command used previously. */
1365 strcpy (cmd, saved_cmd);
1366 }
1367 }
1368
1369 do_cleanups (old_chain);
1370 }
1371
1372 /* Switch to the specified thread. Will dispatch off to thread_apply_command
1373 if prefix of arg is `apply'. */
1374
1375 static void
1376 thread_command (char *tidstr, int from_tty)
1377 {
1378 if (!tidstr)
1379 {
1380 if (ptid_equal (inferior_ptid, null_ptid))
1381 error (_("No thread selected"));
1382
1383 if (target_has_stack)
1384 {
1385 if (is_exited (inferior_ptid))
1386 printf_filtered (_("[Current thread is %d (%s) (exited)]\n"),
1387 pid_to_thread_id (inferior_ptid),
1388 target_pid_to_str (inferior_ptid));
1389 else
1390 printf_filtered (_("[Current thread is %d (%s)]\n"),
1391 pid_to_thread_id (inferior_ptid),
1392 target_pid_to_str (inferior_ptid));
1393 }
1394 else
1395 error (_("No stack."));
1396 return;
1397 }
1398
1399 gdb_thread_select (current_uiout, tidstr, NULL);
1400 }
1401
1402 /* Implementation of `thread name'. */
1403
1404 static void
1405 thread_name_command (char *arg, int from_tty)
1406 {
1407 struct thread_info *info;
1408
1409 if (ptid_equal (inferior_ptid, null_ptid))
1410 error (_("No thread selected"));
1411
1412 arg = skip_spaces (arg);
1413
1414 info = inferior_thread ();
1415 xfree (info->name);
1416 info->name = arg ? xstrdup (arg) : NULL;
1417 }
1418
1419 /* Find thread ids with a name, target pid, or extra info matching ARG. */
1420
1421 static void
1422 thread_find_command (char *arg, int from_tty)
1423 {
1424 struct thread_info *tp;
1425 char *tmp;
1426 unsigned long match = 0;
1427
1428 if (arg == NULL || *arg == '\0')
1429 error (_("Command requires an argument."));
1430
1431 tmp = re_comp (arg);
1432 if (tmp != 0)
1433 error (_("Invalid regexp (%s): %s"), tmp, arg);
1434
1435 update_thread_list ();
1436 for (tp = thread_list; tp; tp = tp->next)
1437 {
1438 if (tp->name != NULL && re_exec (tp->name))
1439 {
1440 printf_filtered (_("Thread %d has name '%s'\n"),
1441 tp->num, tp->name);
1442 match++;
1443 }
1444
1445 tmp = target_thread_name (tp);
1446 if (tmp != NULL && re_exec (tmp))
1447 {
1448 printf_filtered (_("Thread %d has target name '%s'\n"),
1449 tp->num, tmp);
1450 match++;
1451 }
1452
1453 tmp = target_pid_to_str (tp->ptid);
1454 if (tmp != NULL && re_exec (tmp))
1455 {
1456 printf_filtered (_("Thread %d has target id '%s'\n"),
1457 tp->num, tmp);
1458 match++;
1459 }
1460
1461 tmp = target_extra_thread_info (tp);
1462 if (tmp != NULL && re_exec (tmp))
1463 {
1464 printf_filtered (_("Thread %d has extra info '%s'\n"),
1465 tp->num, tmp);
1466 match++;
1467 }
1468 }
1469 if (!match)
1470 printf_filtered (_("No threads match '%s'\n"), arg);
1471 }
1472
1473 /* Print notices when new threads are attached and detached. */
1474 int print_thread_events = 1;
1475 static void
1476 show_print_thread_events (struct ui_file *file, int from_tty,
1477 struct cmd_list_element *c, const char *value)
1478 {
1479 fprintf_filtered (file,
1480 _("Printing of thread events is %s.\n"),
1481 value);
1482 }
1483
1484 static int
1485 do_captured_thread_select (struct ui_out *uiout, void *tidstr)
1486 {
1487 int num;
1488 struct thread_info *tp;
1489
1490 num = value_as_long (parse_and_eval (tidstr));
1491
1492 tp = find_thread_id (num);
1493
1494 if (!tp)
1495 error (_("Thread ID %d not known."), num);
1496
1497 if (!thread_alive (tp))
1498 error (_("Thread ID %d has terminated."), num);
1499
1500 switch_to_thread (tp->ptid);
1501
1502 annotate_thread_changed ();
1503
1504 ui_out_text (uiout, "[Switching to thread ");
1505 ui_out_field_int (uiout, "new-thread-id", pid_to_thread_id (inferior_ptid));
1506 ui_out_text (uiout, " (");
1507 ui_out_text (uiout, target_pid_to_str (inferior_ptid));
1508 ui_out_text (uiout, ")]");
1509
1510 /* Note that we can't reach this with an exited thread, due to the
1511 thread_alive check above. */
1512 if (tp->state == THREAD_RUNNING)
1513 ui_out_text (uiout, "(running)\n");
1514 else
1515 {
1516 ui_out_text (uiout, "\n");
1517 print_stack_frame (get_selected_frame (NULL), 1, SRC_AND_LOC, 1);
1518 }
1519
1520 /* Since the current thread may have changed, see if there is any
1521 exited thread we can now delete. */
1522 prune_threads ();
1523
1524 return GDB_RC_OK;
1525 }
1526
1527 enum gdb_rc
1528 gdb_thread_select (struct ui_out *uiout, char *tidstr, char **error_message)
1529 {
1530 if (catch_exceptions_with_msg (uiout, do_captured_thread_select, tidstr,
1531 error_message, RETURN_MASK_ALL) < 0)
1532 return GDB_RC_FAIL;
1533 return GDB_RC_OK;
1534 }
1535
1536 /* Update the 'threads_executing' global based on the threads we know
1537 about right now. */
1538
1539 static void
1540 update_threads_executing (void)
1541 {
1542 struct thread_info *tp;
1543
1544 threads_executing = 0;
1545 ALL_NON_EXITED_THREADS (tp)
1546 {
1547 if (tp->executing)
1548 {
1549 threads_executing = 1;
1550 break;
1551 }
1552 }
1553 }
1554
1555 void
1556 update_thread_list (void)
1557 {
1558 prune_threads ();
1559 target_find_new_threads ();
1560 update_threads_executing ();
1561 }
1562
1563 /* Return a new value for the selected thread's id. Return a value of 0 if
1564 no thread is selected, or no threads exist. */
1565
1566 static struct value *
1567 thread_id_make_value (struct gdbarch *gdbarch, struct internalvar *var,
1568 void *ignore)
1569 {
1570 struct thread_info *tp = find_thread_ptid (inferior_ptid);
1571
1572 return value_from_longest (builtin_type (gdbarch)->builtin_int,
1573 (tp ? tp->num : 0));
1574 }
1575
1576 /* Commands with a prefix of `thread'. */
1577 struct cmd_list_element *thread_cmd_list = NULL;
1578
1579 /* Implementation of `thread' variable. */
1580
1581 static const struct internalvar_funcs thread_funcs =
1582 {
1583 thread_id_make_value,
1584 NULL,
1585 NULL
1586 };
1587
1588 void
1589 _initialize_thread (void)
1590 {
1591 static struct cmd_list_element *thread_apply_list = NULL;
1592
1593 add_info ("threads", info_threads_command,
1594 _("Display currently known threads.\n\
1595 Usage: info threads [ID]...\n\
1596 Optional arguments are thread IDs with spaces between.\n\
1597 If no arguments, all threads are displayed."));
1598
1599 add_prefix_cmd ("thread", class_run, thread_command, _("\
1600 Use this command to switch between threads.\n\
1601 The new thread ID must be currently known."),
1602 &thread_cmd_list, "thread ", 1, &cmdlist);
1603
1604 add_prefix_cmd ("apply", class_run, thread_apply_command,
1605 _("Apply a command to a list of threads."),
1606 &thread_apply_list, "thread apply ", 1, &thread_cmd_list);
1607
1608 add_cmd ("all", class_run, thread_apply_all_command,
1609 _("Apply a command to all threads."), &thread_apply_list);
1610
1611 add_cmd ("name", class_run, thread_name_command,
1612 _("Set the current thread's name.\n\
1613 Usage: thread name [NAME]\n\
1614 If NAME is not given, then any existing name is removed."), &thread_cmd_list);
1615
1616 add_cmd ("find", class_run, thread_find_command, _("\
1617 Find threads that match a regular expression.\n\
1618 Usage: thread find REGEXP\n\
1619 Will display thread ids whose name, target ID, or extra info matches REGEXP."),
1620 &thread_cmd_list);
1621
1622 if (!xdb_commands)
1623 add_com_alias ("t", "thread", class_run, 1);
1624
1625 add_setshow_boolean_cmd ("thread-events", no_class,
1626 &print_thread_events, _("\
1627 Set printing of thread events (such as thread start and exit)."), _("\
1628 Show printing of thread events (such as thread start and exit)."), NULL,
1629 NULL,
1630 show_print_thread_events,
1631 &setprintlist, &showprintlist);
1632
1633 create_internalvar_type_lazy ("_thread", &thread_funcs, NULL);
1634 }
This page took 0.073826 seconds and 5 git commands to generate.