ReactOS 0.4.15-dev-8390-g075894b
utils.c File Reference
#include "kdgdb.h"
Include dependency graph for utils.c:

Go to the source code of this file.

Functions

PEPROCESS find_process (_In_ UINT_PTR Pid)
 
PETHREAD find_thread (_In_ UINT_PTR Pid, _In_ UINT_PTR Tid)
 

Function Documentation

◆ find_process()

PEPROCESS find_process ( _In_ UINT_PTR  Pid)

Definition at line 16 of file utils.c.

18{
20 LIST_ENTRY* ProcessEntry;
22
23 /* Special case for idle process */
24 if (ProcessId == NULL)
25 return TheIdleProcess;
26
27 for (ProcessEntry = ProcessListHead->Flink;
28 ProcessEntry != ProcessListHead;
29 ProcessEntry = ProcessEntry->Flink)
30 {
31 Process = CONTAINING_RECORD(ProcessEntry, EPROCESS, ActiveProcessLinks);
32
33 if (Process->UniqueProcessId == ProcessId)
34 return Process;
35 }
36
37 return NULL;
38}
#define NULL
Definition: types.h:112
IN PLARGE_INTEGER IN PLARGE_INTEGER PEPROCESS ProcessId
Definition: fatprocs.h:2711
_Must_inspect_result_ _In_ PLARGE_INTEGER _In_ PLARGE_INTEGER _In_ ULONG _In_ PFILE_OBJECT _In_ PVOID Process
Definition: fsrtlfuncs.h:223
#define gdb_pid_to_handle
Definition: kdgdb.h:39
PEPROCESS TheIdleProcess
Definition: kdpacket.c:30
LIST_ENTRY * ProcessListHead
Definition: kdpacket.c:22
Definition: typedefs.h:120
struct _LIST_ENTRY * Flink
Definition: typedefs.h:121
#define CONTAINING_RECORD(address, type, field)
Definition: typedefs.h:260

Referenced by find_thread(), handle_gdb_query(), handle_gdb_read_mem(), and handle_gdb_write_mem().

◆ find_thread()

PETHREAD find_thread ( _In_ UINT_PTR  Pid,
_In_ UINT_PTR  Tid 
)

Definition at line 41 of file utils.c.

44{
45 HANDLE ThreadId = gdb_tid_to_handle(Tid);
49#if MONOPROCESS
50 LIST_ENTRY* ProcessEntry;
51#endif
52
53 if (
54#if !MONOPROCESS
55 (Pid == 0) &&
56#endif
57 (Tid == 0))
58 {
59 /* Zero means any, so use the current one */
61 }
62
63#if MONOPROCESS
64
65 /* Special case for the idle thread */
66 if (Tid == 1)
67 return TheIdleThread;
68
69 for (ProcessEntry = ProcessListHead->Flink;
70 ProcessEntry != ProcessListHead;
71 ProcessEntry = ProcessEntry->Flink)
72 {
73 Process = CONTAINING_RECORD(ProcessEntry, EPROCESS, ActiveProcessLinks);
74#else
75
76 Process = find_process(Pid);
77
78 /* Special case for the idle thread */
79 if ((Process == TheIdleProcess) && (Tid == 1))
80 return TheIdleThread;
81
82 if (!Process)
83 return NULL;
84
85#endif
86
87 for (ThreadEntry = Process->ThreadListHead.Flink;
88 ThreadEntry != &Process->ThreadListHead;
89 ThreadEntry = ThreadEntry->Flink)
90 {
91 Thread = CONTAINING_RECORD(ThreadEntry, ETHREAD, ThreadListEntry);
92 /* For GDB, Tid == 0 means any thread */
93 if ((Thread->Cid.UniqueThread == ThreadId) || (Tid == 0))
94 {
95 return Thread;
96 }
97 }
98
99#if MONOPROCESS
100 }
101#endif
102
103 return NULL;
104}
PEPROCESS find_process(_In_ UINT_PTR Pid)
Definition: utils.c:16
#define ULONG_PTR
Definition: config.h:101
_In_opt_ PFILE_OBJECT _In_opt_ PETHREAD Thread
Definition: fltkernel.h:2653
PETHREAD TheIdleThread
Definition: kdpacket.c:31
DBGKD_ANY_WAIT_STATE_CHANGE CurrentStateChange
Definition: kdpacket.c:28
FORCEINLINE HANDLE gdb_tid_to_handle(UINT_PTR Tid)
Definition: kdgdb.h:35
#define MONOPROCESS
Definition: kdgdb.h:25
HANDLE UniqueThread
Definition: compat.h:826
CLIENT_ID Cid
Definition: pstypes.h:1128
DWORD WINAPI ThreadEntry(LPVOID parameter)
Definition: thread.cpp:16

Referenced by gdb_send_register(), gdb_send_registers(), handle_gdb_query(), handle_gdb_read_mem(), handle_gdb_thread_alive(), handle_gdb_write_mem(), xmlGetThreadId(), xmlIsMainThread(), xmlMutexLock(), xmlMutexUnlock(), xmlRMutexLock(), and xmlRMutexUnlock().