Commit 24f4eced authored by Ryan Cumming's avatar Ryan Cumming Committed by Alexandre Julliard

Partially implement GetThreadTimes.

parent 8ed35fe8
...@@ -394,6 +394,8 @@ struct get_thread_info_reply ...@@ -394,6 +394,8 @@ struct get_thread_info_reply
void* teb; void* teb;
int exit_code; int exit_code;
int priority; int priority;
time_t creation_time;
time_t exit_time;
}; };
...@@ -3460,6 +3462,6 @@ union generic_reply ...@@ -3460,6 +3462,6 @@ union generic_reply
struct get_next_hook_reply get_next_hook_reply; struct get_next_hook_reply get_next_hook_reply;
}; };
#define SERVER_PROTOCOL_VERSION 90 #define SERVER_PROTOCOL_VERSION 91
#endif /* __WINE_WINE_SERVER_PROTOCOL_H */ #endif /* __WINE_WINE_SERVER_PROTOCOL_H */
...@@ -677,9 +677,6 @@ DWORD WINAPI QueueUserAPC( PAPCFUNC func, HANDLE hthread, ULONG_PTR data ) ...@@ -677,9 +677,6 @@ DWORD WINAPI QueueUserAPC( PAPCFUNC func, HANDLE hthread, ULONG_PTR data )
/********************************************************************** /**********************************************************************
* GetThreadTimes [KERNEL32.@] Obtains timing information. * GetThreadTimes [KERNEL32.@] Obtains timing information.
* *
* NOTES
* What are the fields where these values are stored?
*
* RETURNS * RETURNS
* Success: TRUE * Success: TRUE
* Failure: FALSE * Failure: FALSE
...@@ -691,9 +688,28 @@ BOOL WINAPI GetThreadTimes( ...@@ -691,9 +688,28 @@ BOOL WINAPI GetThreadTimes(
LPFILETIME kerneltime, /* [out] Time thread spent in kernel mode */ LPFILETIME kerneltime, /* [out] Time thread spent in kernel mode */
LPFILETIME usertime) /* [out] Time thread spent in user mode */ LPFILETIME usertime) /* [out] Time thread spent in user mode */
{ {
FIXME("(0x%p): stub\n",thread); BOOL ret = TRUE;
SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
return FALSE; if (creationtime || exittime)
{
/* We need to do a server call to get the creation time or exit time */
/* This works on any thread */
SERVER_START_REQ( get_thread_info )
{
req->handle = thread;
req->tid_in = 0;
if ((ret = !wine_server_call_err( req )))
{
if (creationtime)
RtlSecondsSince1970ToTime( reply->creation_time, (LARGE_INTEGER*)creationtime );
if (exittime)
RtlSecondsSince1970ToTime( reply->exit_time, (LARGE_INTEGER*)exittime );
}
}
SERVER_END_REQ;
}
return ret;
} }
......
...@@ -336,13 +336,15 @@ typedef struct ...@@ -336,13 +336,15 @@ typedef struct
/* Retrieve information about a thread */ /* Retrieve information about a thread */
@REQ(get_thread_info) @REQ(get_thread_info)
obj_handle_t handle; /* thread handle */ obj_handle_t handle; /* thread handle */
thread_id_t tid_in; /* thread id (optional) */ thread_id_t tid_in; /* thread id (optional) */
@REPLY @REPLY
thread_id_t tid; /* server thread id */ thread_id_t tid; /* server thread id */
void* teb; /* thread teb pointer */ void* teb; /* thread teb pointer */
int exit_code; /* thread exit code */ int exit_code; /* thread exit code */
int priority; /* thread priority level */ int priority; /* thread priority level */
time_t creation_time; /* thread creation time */
time_t exit_time; /* thread exit time */
@END @END
......
...@@ -31,7 +31,7 @@ ...@@ -31,7 +31,7 @@
#include <string.h> #include <string.h>
#include <sys/types.h> #include <sys/types.h>
#include <unistd.h> #include <unistd.h>
#include <stdarg.h> #include <time.h>
#include "winbase.h" #include "winbase.h"
...@@ -132,6 +132,8 @@ inline static void init_thread_structure( struct thread *thread ) ...@@ -132,6 +132,8 @@ inline static void init_thread_structure( struct thread *thread )
thread->priority = THREAD_PRIORITY_NORMAL; thread->priority = THREAD_PRIORITY_NORMAL;
thread->affinity = 1; thread->affinity = 1;
thread->suspend = 0; thread->suspend = 0;
thread->creation_time = time(NULL);
thread->exit_time = 0;
for (i = 0; i < MAX_INFLIGHT_FDS; i++) for (i = 0; i < MAX_INFLIGHT_FDS; i++)
thread->inflight[i].server = thread->inflight[i].client = -1; thread->inflight[i].server = thread->inflight[i].client = -1;
...@@ -706,6 +708,7 @@ void kill_thread( struct thread *thread, int violent_death ) ...@@ -706,6 +708,7 @@ void kill_thread( struct thread *thread, int violent_death )
{ {
if (thread->state == TERMINATED) return; /* already killed */ if (thread->state == TERMINATED) return; /* already killed */
thread->state = TERMINATED; thread->state = TERMINATED;
thread->exit_time = time(NULL);
if (current == thread) current = NULL; if (current == thread) current = NULL;
if (debug_level) if (debug_level)
fprintf( stderr,"%08x: *killed* exit_code=%d\n", fprintf( stderr,"%08x: *killed* exit_code=%d\n",
...@@ -878,10 +881,13 @@ DECL_HANDLER(get_thread_info) ...@@ -878,10 +881,13 @@ DECL_HANDLER(get_thread_info)
if (thread) if (thread)
{ {
reply->tid = get_thread_id( thread ); reply->tid = get_thread_id( thread );
reply->teb = thread->teb; reply->teb = thread->teb;
reply->exit_code = (thread->state == TERMINATED) ? thread->exit_code : STILL_ACTIVE; reply->exit_code = (thread->state == TERMINATED) ? thread->exit_code : STILL_ACTIVE;
reply->priority = thread->priority; reply->priority = thread->priority;
reply->creation_time = thread->creation_time;
reply->exit_time = thread->exit_time;
release_object( thread ); release_object( thread );
} }
} }
......
...@@ -92,6 +92,8 @@ struct thread ...@@ -92,6 +92,8 @@ struct thread
int priority; /* priority level */ int priority; /* priority level */
int affinity; /* affinity mask */ int affinity; /* affinity mask */
int suspend; /* suspend count */ int suspend; /* suspend count */
time_t creation_time; /* Thread creation time */
time_t exit_time; /* Thread exit time */
}; };
struct thread_snapshot struct thread_snapshot
......
...@@ -515,7 +515,9 @@ static void dump_get_thread_info_reply( const struct get_thread_info_reply *req ...@@ -515,7 +515,9 @@ static void dump_get_thread_info_reply( const struct get_thread_info_reply *req
fprintf( stderr, " tid=%08x,", req->tid ); fprintf( stderr, " tid=%08x,", req->tid );
fprintf( stderr, " teb=%p,", req->teb ); fprintf( stderr, " teb=%p,", req->teb );
fprintf( stderr, " exit_code=%d,", req->exit_code ); fprintf( stderr, " exit_code=%d,", req->exit_code );
fprintf( stderr, " priority=%d", req->priority ); fprintf( stderr, " priority=%d,", req->priority );
fprintf( stderr, " creation_time=%ld,", req->creation_time );
fprintf( stderr, " exit_time=%ld", req->exit_time );
} }
static void dump_set_thread_info_request( const struct set_thread_info_request *req ) static void dump_set_thread_info_request( const struct set_thread_info_request *req )
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment