Allow ARC target to be configured with --with-cpu=<cpu-name>.
[external/binutils.git] / gdb / thread-fsm.c
1 /* Thread command's finish-state machine, for GDB, the GNU debugger.
2    Copyright (C) 2015-2016 Free Software Foundation, Inc.
3
4    This file is part of GDB.
5
6    This program is free software; you can redistribute it and/or modify
7    it under the terms of the GNU General Public License as published by
8    the Free Software Foundation; either version 3 of the License, or
9    (at your option) any later version.
10
11    This program is distributed in the hope that it will be useful,
12    but WITHOUT ANY WARRANTY; without even the implied warranty of
13    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14    GNU General Public License for more details.
15
16    You should have received a copy of the GNU General Public License
17    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
18
19 #include "defs.h"
20 #include "thread-fsm.h"
21
22 /* See thread-fsm.h.  */
23
24 void
25 thread_fsm_ctor (struct thread_fsm *self, struct thread_fsm_ops *ops,
26                  struct interp *cmd_interp)
27 {
28   self->command_interp = cmd_interp;
29   self->finished = 0;
30   self->ops = ops;
31 }
32
33 /* See thread-fsm.h.  */
34
35 void
36 thread_fsm_delete (struct thread_fsm *self)
37 {
38   if (self != NULL)
39     {
40       if (self->ops->dtor != NULL)
41         self->ops->dtor (self);
42       xfree (self);
43     }
44 }
45
46 /* See thread-fsm.h.  */
47
48 void
49 thread_fsm_clean_up (struct thread_fsm *self, struct thread_info *thread)
50 {
51   if (self->ops->clean_up != NULL)
52     self->ops->clean_up (self, thread);
53 }
54
55 /* See thread-fsm.h.  */
56
57 int
58 thread_fsm_should_stop (struct thread_fsm *self, struct thread_info *thread)
59 {
60   return self->ops->should_stop (self, thread);
61 }
62
63 /* See thread-fsm.h.  */
64
65 struct return_value_info *
66 thread_fsm_return_value (struct thread_fsm *self)
67 {
68   if (self->ops->return_value != NULL)
69     return self->ops->return_value (self);
70   return NULL;
71 }
72
73 /* See thread-fsm.h.  */
74
75 void
76 thread_fsm_set_finished (struct thread_fsm *self)
77 {
78   self->finished = 1;
79 }
80
81 /* See thread-fsm.h.  */
82
83 int
84 thread_fsm_finished_p (struct thread_fsm *self)
85 {
86   return self->finished;
87 }
88
89 /* See thread-fsm.h.  */
90
91 enum async_reply_reason
92 thread_fsm_async_reply_reason (struct thread_fsm *self)
93 {
94   /* If we didn't finish, then the stop reason must come from
95      elsewhere.  E.g., a breakpoint hit or a signal intercepted.  */
96   gdb_assert (thread_fsm_finished_p (self));
97
98   return self->ops->async_reply_reason (self);
99 }
100
101 /* See thread-fsm.h.  */
102
103 int
104 thread_fsm_should_notify_stop (struct thread_fsm *self)
105 {
106   if (self->ops->should_notify_stop != NULL)
107     return self->ops->should_notify_stop (self);
108   return 1;
109 }