Re: Breakpoint Implementation
site_archiver@lists.apple.com Delivered-To: darwin-dev@lists.apple.com Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:mime-version:received:in-reply-to :references:from:date:message-id:subject:to:cc:content-type :content-transfer-encoding; bh=8oG3pgResKB+XgPTEjW19xR1BTuZ2v7paERZGsRL99Y=; b=btZ4Lj4+ALpQZ8RIKooeMwINO6uyJTngFe67LeKwS1W70wC+dpn6MiVrIOzZPxtCZe hPLxJrLNfEt2mtignhG0Ue4p0mJhJxRgwxYnzaIdVV4Oo5YqGEJPO/+pGW4WfMVmhfT0 tv1XVENaGhPlSkOk3ow9RbU50z5X11oFobNG4= Domainkey-signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc:content-type:content-transfer-encoding; b=RJqL9Poo9h63winSv49uUBs00CdNNqaGhK0VmvVWO4eXgd+nrFtLXKDeQ3TFAiaJF1 NVOvg6pbW7f3SulkT89cuvhxlltDM1HfcQdcz20IDO1I1gbmMXK4X/Ek/ZfNhlnWLOFG 5WSzdfGxrtuL1MmAznKED4l/4xKVQ5dMTqBGI=
Actually, the "run_state" member of the thread_basic_info_t structure returned for the thread_info() "flavor" argument of THREAD_BASIC_INFO returned in the "thread_info_out" data area argument will be TH_STATE_STOPPED. If you iterate over the task thread list, you can verify that this is the case for all threads. You really should be looking at the gdb source code for this type of information, since gdb has to solve similar problems.
On my end, 'run_state' never contains a value of _STOPPED, only _WAITING; it returns _WAITING both when a thread is in a 'sleep(UINT_MAX)' call, and also when it's actually been suspended via thread_suspend(). (In addition to 'run_state,' none of the other members appear to report any useful information either regarding the "true suspension state.") Here's my test case: ========== #include <mach/mach.h> #include <pthread.h> #include <stdbool.h> #include <unistd.h> #include <stdio.h> void *func(void *a) { for (;;); } int main(int argc, const char *argv[]) { pthread_t p_thread = NULL; thread_act_t m_thread = MACH_PORT_NULL; pthread_create(&p_thread, NULL, func, NULL); m_thread = pthread_mach_thread_np(p_thread); usleep(500000); thread_suspend(m_thread); for (;; sleep(1)) { struct thread_basic_info m_thread_info; mach_msg_type_number_t m_thread_info_count = 0; m_thread_info_count = THREAD_BASIC_INFO_COUNT; thread_info(m_thread, THREAD_BASIC_INFO, (thread_info_t)&m_thread_info, &m_thread_info_count); printf("Run state: %d\n", m_thread_info.run_state); } return 0; } ========== Running this for several minutes never resulted in run_state == _STOPPED. I looked through the GDB sources but didn't find anything that uses thread_info() for a similar purpose as I'm attempting; I'll look again more thoroughly. Thanks, David _______________________________________________ Do not post admin requests to the list. They will be ignored. Darwin-dev mailing list (Darwin-dev@lists.apple.com) Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/darwin-dev/site_archiver%40lists.appl... This email sent to site_archiver@lists.apple.com
participants (1)
-
Dave Keck