Re: Breakpoint Implementation
Re: Breakpoint Implementation
- Subject: Re: Breakpoint Implementation
- From: Dave Keck <email@hidden>
- Date: Thu, 7 Oct 2010 23:04:05 -0400
> 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 (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden