aboutsummaryrefslogtreecommitdiff
path: root/gdb/thread.c
diff options
context:
space:
mode:
authorStan Shebs <shebs@codesourcery.com>2010-06-18 17:44:40 +0000
committerStan Shebs <shebs@codesourcery.com>2010-06-18 17:44:40 +0000
commit6aed2dbcba548376cdc0b98231fb9b174f9ca978 (patch)
tree37933482f06cdff97129271eb76c1e8401649ef9 /gdb/thread.c
parent6508b958ffb3afc176ac6b978e15baafbc85e4ab (diff)
downloadgdb-6aed2dbcba548376cdc0b98231fb9b174f9ca978.zip
gdb-6aed2dbcba548376cdc0b98231fb9b174f9ca978.tar.gz
gdb-6aed2dbcba548376cdc0b98231fb9b174f9ca978.tar.bz2
* thread.c (thread_id_make_value): Make a value representing the
current thread. (_initialize_thread): Create $_thread. * gdb.texinfo (Debugging Programs with Multiple Threads): Describe $_thread. * gdb.threads/thread-specific.exp: Add tests of $_thread.
Diffstat (limited to 'gdb/thread.c')
-rw-r--r--gdb/thread.c14
1 files changed, 14 insertions, 0 deletions
diff --git a/gdb/thread.c b/gdb/thread.c
index c10d23c..2fdc7f9 100644
--- a/gdb/thread.c
+++ b/gdb/thread.c
@@ -1262,6 +1262,18 @@ update_thread_list (void)
target_find_new_threads ();
}
+/* Return a new value for the selected thread's id. Return a value of 0 if
+ no thread is selected, or no threads exist. */
+
+static struct value *
+thread_id_make_value (struct gdbarch *gdbarch, struct internalvar *var)
+{
+ struct thread_info *tp = find_thread_ptid (inferior_ptid);
+
+ return value_from_longest (builtin_type (gdbarch)->builtin_int,
+ (tp ? tp->num : 0));
+}
+
/* Commands with a prefix of `thread'. */
struct cmd_list_element *thread_cmd_list = NULL;
@@ -1295,4 +1307,6 @@ Show printing of thread events (such as thread start and exit)."), NULL,
NULL,
show_print_thread_events,
&setprintlist, &showprintlist);
+
+ create_internalvar_type_lazy ("_thread", thread_id_make_value);
}