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