aboutsummaryrefslogtreecommitdiff
path: root/gdb
diff options
context:
space:
mode:
authorPedro Alves <palves@redhat.com>2011-09-13 14:48:55 +0000
committerPedro Alves <palves@redhat.com>2011-09-13 14:48:55 +0000
commit305962315a5d52b2289bac2623e04abbda158597 (patch)
tree3f1139740da1452554a7e580c79d82b351ddb7c9 /gdb
parentbede5f5f81e145b3c1dd21cbf4e8695de83298e6 (diff)
downloadbinutils-305962315a5d52b2289bac2623e04abbda158597.zip
binutils-305962315a5d52b2289bac2623e04abbda158597.tar.gz
binutils-305962315a5d52b2289bac2623e04abbda158597.tar.bz2
2011-09-13 Pedro Alves <pedro@codesourcery.com>
* gdbthread.h (enum thread_state): Moved here. (struct thread_info): Rename `executing_' field to `executing' and `state_' to `state'. * thread.c (enum thread_state): Moved to gdbthread.h. (new_thread, add_thread_silent, delete_thread_1) (any_live_thread_of_process, thread_alive, set_running) (set_running, is_thread_state, any_running, is_executing) (set_executing, finish_thread_state, print_thread_info) (do_captured_thread_select): Adjust.
Diffstat (limited to 'gdb')
-rw-r--r--gdb/ChangeLog12
-rw-r--r--gdb/gdbthread.h19
-rw-r--r--gdb/thread.c75
3 files changed, 57 insertions, 49 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 05d523f..8242745 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,3 +1,15 @@
+2011-09-13 Pedro Alves <pedro@codesourcery.com>
+
+ * gdbthread.h (enum thread_state): Moved here.
+ (struct thread_info): Rename `executing_' field to `executing' and
+ `state_' to `state'.
+ * thread.c (enum thread_state): Moved to gdbthread.h.
+ (new_thread, add_thread_silent, delete_thread_1)
+ (any_live_thread_of_process, thread_alive, set_running)
+ (set_running, is_thread_state, any_running, is_executing)
+ (set_executing, finish_thread_state, print_thread_info)
+ (do_captured_thread_select): Adjust.
+
2011-09-13 Jan Kratochvil <jan.kratochvil@redhat.com>
Fix compatibility with gcc < 4.3 and non-gcc compilers.
diff --git a/gdb/gdbthread.h b/gdb/gdbthread.h
index 6011087..af987f2 100644
--- a/gdb/gdbthread.h
+++ b/gdb/gdbthread.h
@@ -29,6 +29,15 @@ struct symtab;
#include "ui-out.h"
#include "inferior.h"
+/* Frontend view of the thread state. Possible extensions: stepping,
+ finishing, until(ling),... */
+enum thread_state
+{
+ THREAD_STOPPED,
+ THREAD_RUNNING,
+ THREAD_EXITED,
+};
+
/* Inferior thread specific part of `struct infcall_control_state'.
Inferior process counterpart is `struct inferior_control_state'. */
@@ -133,9 +142,7 @@ struct thread_info
from saying that there is an active target and we are stopped at
a breakpoint, for instance. This is a real indicator whether the
thread is off and running. */
- /* This field is internal to thread.c. Never access it directly,
- use is_executing instead. */
- int executing_;
+ int executing;
/* Frontend view of the thread state. Note that the RUNNING/STOPPED
states are different from EXECUTING. When the thread is stopped
@@ -144,9 +151,7 @@ struct thread_info
still be true. As a possible future extension, this could turn
into enum { stopped, exited, stepping, finishing, until(ling),
running ... } */
- /* This field is internal to thread.c. Never access it directly,
- use is_running instead. */
- int state_;
+ int state;
/* If this is > 0, then it means there's code out there that relies
on this thread being listed. Don't delete it from the lists even
@@ -342,7 +347,7 @@ extern int any_running (void);
marks all threads.
Note that this is different from the running state. See the
- description of state_ and executing_ fields of struct
+ description of state and executing fields of struct
thread_info. */
extern void set_executing (ptid_t ptid, int executing);
diff --git a/gdb/thread.c b/gdb/thread.c
index ceeaa99..8cca83d 100644
--- a/gdb/thread.c
+++ b/gdb/thread.c
@@ -66,15 +66,6 @@ static void thread_apply_command (char *, int);
static void restore_current_thread (ptid_t);
static void prune_threads (void);
-/* Frontend view of the thread state. Possible extensions: stepping,
- finishing, until(ling),... */
-enum thread_state
-{
- THREAD_STOPPED,
- THREAD_RUNNING,
- THREAD_EXITED,
-};
-
struct thread_info*
inferior_thread (void)
{
@@ -182,7 +173,7 @@ new_thread (ptid_t ptid)
/* Nothing to follow yet. */
tp->pending_follow.kind = TARGET_WAITKIND_SPURIOUS;
- tp->state_ = THREAD_STOPPED;
+ tp->state = THREAD_STOPPED;
return tp;
}
@@ -211,7 +202,7 @@ add_thread_silent (ptid_t ptid)
tp = new_thread (null_ptid);
/* Make switch_to_thread not read from the thread. */
- tp->state_ = THREAD_EXITED;
+ tp->state = THREAD_EXITED;
switch_to_thread (null_ptid);
/* Now we can delete it. */
@@ -219,7 +210,7 @@ add_thread_silent (ptid_t ptid)
/* Now reset its ptid, and reswitch inferior_ptid to it. */
tp->ptid = ptid;
- tp->state_ = THREAD_STOPPED;
+ tp->state = THREAD_STOPPED;
switch_to_thread (ptid);
observer_notify_new_thread (tp);
@@ -280,12 +271,12 @@ delete_thread_1 (ptid_t ptid, int silent)
if (tp->refcount > 0
|| ptid_equal (tp->ptid, inferior_ptid))
{
- if (tp->state_ != THREAD_EXITED)
+ if (tp->state != THREAD_EXITED)
{
observer_notify_thread_exit (tp, silent);
/* Tag it as exited. */
- tp->state_ = THREAD_EXITED;
+ tp->state = THREAD_EXITED;
/* Clear breakpoints, etc. associated with this thread. */
clear_thread_inferior_resources (tp);
@@ -296,11 +287,11 @@ delete_thread_1 (ptid_t ptid, int silent)
}
/* Notify thread exit, but only if we haven't already. */
- if (tp->state_ != THREAD_EXITED)
+ if (tp->state != THREAD_EXITED)
observer_notify_thread_exit (tp, silent);
/* Tag it as exited. */
- tp->state_ = THREAD_EXITED;
+ tp->state = THREAD_EXITED;
clear_thread_inferior_resources (tp);
if (tpprev)
@@ -476,9 +467,9 @@ any_live_thread_of_process (int pid)
struct thread_info *tp_executing = NULL;
for (tp = thread_list; tp; tp = tp->next)
- if (tp->state_ != THREAD_EXITED && ptid_get_pid (tp->ptid) == pid)
+ if (tp->state != THREAD_EXITED && ptid_get_pid (tp->ptid) == pid)
{
- if (tp->executing_)
+ if (tp->executing)
tp_executing = tp;
else
return tp;
@@ -503,7 +494,7 @@ do_captured_list_thread_ids (struct ui_out *uiout, void *arg)
for (tp = thread_list; tp; tp = tp->next)
{
- if (tp->state_ == THREAD_EXITED)
+ if (tp->state == THREAD_EXITED)
continue;
if (ptid_equal (tp->ptid, inferior_ptid))
@@ -536,7 +527,7 @@ gdb_list_thread_ids (struct ui_out *uiout, char **error_message)
static int
thread_alive (struct thread_info *tp)
{
- if (tp->state_ == THREAD_EXITED)
+ if (tp->state == THREAD_EXITED)
return 0;
if (!target_thread_alive (tp->ptid))
return 0;
@@ -590,11 +581,11 @@ set_running (ptid_t ptid, int running)
for (tp = thread_list; tp; tp = tp->next)
if (all || ptid_get_pid (tp->ptid) == ptid_get_pid (ptid))
{
- if (tp->state_ == THREAD_EXITED)
+ if (tp->state == THREAD_EXITED)
continue;
- if (running && tp->state_ == THREAD_STOPPED)
+ if (running && tp->state == THREAD_STOPPED)
any_started = 1;
- tp->state_ = running ? THREAD_RUNNING : THREAD_STOPPED;
+ tp->state = running ? THREAD_RUNNING : THREAD_STOPPED;
}
if (any_started)
observer_notify_target_resumed (ptid);
@@ -605,10 +596,10 @@ set_running (ptid_t ptid, int running)
tp = find_thread_ptid (ptid);
gdb_assert (tp);
- gdb_assert (tp->state_ != THREAD_EXITED);
- if (running && tp->state_ == THREAD_STOPPED)
+ gdb_assert (tp->state != THREAD_EXITED);
+ if (running && tp->state == THREAD_STOPPED)
started = 1;
- tp->state_ = running ? THREAD_RUNNING : THREAD_STOPPED;
+ tp->state = running ? THREAD_RUNNING : THREAD_STOPPED;
if (started)
observer_notify_target_resumed (ptid);
}
@@ -621,7 +612,7 @@ is_thread_state (ptid_t ptid, enum thread_state state)
tp = find_thread_ptid (ptid);
gdb_assert (tp);
- return tp->state_ == state;
+ return tp->state == state;
}
int
@@ -648,7 +639,7 @@ any_running (void)
struct thread_info *tp;
for (tp = thread_list; tp; tp = tp->next)
- if (tp->state_ == THREAD_RUNNING)
+ if (tp->state == THREAD_RUNNING)
return 1;
return 0;
@@ -661,7 +652,7 @@ is_executing (ptid_t ptid)
tp = find_thread_ptid (ptid);
gdb_assert (tp);
- return tp->executing_;
+ return tp->executing;
}
void
@@ -674,13 +665,13 @@ set_executing (ptid_t ptid, int executing)
{
for (tp = thread_list; tp; tp = tp->next)
if (all || ptid_get_pid (tp->ptid) == ptid_get_pid (ptid))
- tp->executing_ = executing;
+ tp->executing = executing;
}
else
{
tp = find_thread_ptid (ptid);
gdb_assert (tp);
- tp->executing_ = executing;
+ tp->executing = executing;
}
}
@@ -722,13 +713,13 @@ finish_thread_state (ptid_t ptid)
{
for (tp = thread_list; tp; tp = tp->next)
{
- if (tp->state_ == THREAD_EXITED)
+ if (tp->state == THREAD_EXITED)
continue;
if (all || ptid_get_pid (ptid) == ptid_get_pid (tp->ptid))
{
- if (tp->executing_ && tp->state_ == THREAD_STOPPED)
+ if (tp->executing && tp->state == THREAD_STOPPED)
any_started = 1;
- tp->state_ = tp->executing_ ? THREAD_RUNNING : THREAD_STOPPED;
+ tp->state = tp->executing ? THREAD_RUNNING : THREAD_STOPPED;
}
}
}
@@ -736,11 +727,11 @@ finish_thread_state (ptid_t ptid)
{
tp = find_thread_ptid (ptid);
gdb_assert (tp);
- if (tp->state_ != THREAD_EXITED)
+ if (tp->state != THREAD_EXITED)
{
- if (tp->executing_ && tp->state_ == THREAD_STOPPED)
+ if (tp->executing && tp->state == THREAD_STOPPED)
any_started = 1;
- tp->state_ = tp->executing_ ? THREAD_RUNNING : THREAD_STOPPED;
+ tp->state = tp->executing ? THREAD_RUNNING : THREAD_STOPPED;
}
}
@@ -801,7 +792,7 @@ print_thread_info (struct ui_out *uiout, char *requested_threads, int pid)
if (pid != -1 && PIDGET (tp->ptid) != pid)
continue;
- if (tp->state_ == THREAD_EXITED)
+ if (tp->state == THREAD_EXITED)
continue;
++n_threads;
@@ -845,7 +836,7 @@ print_thread_info (struct ui_out *uiout, char *requested_threads, int pid)
if (ptid_equal (tp->ptid, current_ptid))
current_thread = tp->num;
- if (tp->state_ == THREAD_EXITED)
+ if (tp->state == THREAD_EXITED)
continue;
chain2 = make_cleanup_ui_out_tuple_begin_end (uiout, NULL);
@@ -907,7 +898,7 @@ print_thread_info (struct ui_out *uiout, char *requested_threads, int pid)
do_cleanups (str_cleanup);
}
- if (tp->state_ == THREAD_RUNNING)
+ if (tp->state == THREAD_RUNNING)
ui_out_text (uiout, "(running)\n");
else
{
@@ -924,7 +915,7 @@ print_thread_info (struct ui_out *uiout, char *requested_threads, int pid)
{
char *state = "stopped";
- if (tp->state_ == THREAD_RUNNING)
+ if (tp->state == THREAD_RUNNING)
state = "running";
ui_out_field_string (uiout, "state", state);
}
@@ -1406,7 +1397,7 @@ do_captured_thread_select (struct ui_out *uiout, void *tidstr)
/* Note that we can't reach this with an exited thread, due to the
thread_alive check above. */
- if (tp->state_ == THREAD_RUNNING)
+ if (tp->state == THREAD_RUNNING)
ui_out_text (uiout, "(running)\n");
else
{