ntdll: Store the debug info in the TEB block after the 32-bit TEB.

Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Alexandre Julliard 2021-06-15 16:31:49 +02:00
parent 588d91aecf
commit 2084fbd93d
3 changed files with 17 additions and 16 deletions

View File

@ -43,6 +43,16 @@
WINE_DECLARE_DEBUG_CHANNEL(pid);
WINE_DECLARE_DEBUG_CHANNEL(timestamp);
struct debug_info
{
unsigned int str_pos; /* current position in strings buffer */
unsigned int out_pos; /* current position in output buffer */
char strings[1020]; /* buffer for temporary strings */
char output[1020]; /* current output line */
};
C_ASSERT( sizeof(struct debug_info) == 0x800 );
static BOOL init_done;
static struct debug_info initial_info; /* debug info for initial thread */
static unsigned char default_flags = (1 << __WINE_DBCL_ERR) | (1 << __WINE_DBCL_FIXME);
@ -56,7 +66,11 @@ static const char * const debug_classes[] = { "fixme", "err", "warn", "trace" };
static inline struct debug_info *get_info(void)
{
if (!init_done) return &initial_info;
return ntdll_get_thread_data()->debug_info;
#ifdef _WIN64
return (struct debug_info *)((TEB32 *)((char *)NtCurrentTeb() + teb_offset) + 1);
#else
return (struct debug_info *)(NtCurrentTeb() + 1);
#endif
}
/* add a string to the output buffer */
@ -304,6 +318,5 @@ void dbg_init(void)
free( debug_options );
debug_options = options;
options[nb_debug_options] = default_option;
ntdll_get_thread_data()->debug_info = (struct debug_info *)(options + nb_debug_options + 1);
init_done = TRUE;
}

View File

@ -731,11 +731,8 @@ static void pthread_exit_wrapper( int status )
static void start_thread( TEB *teb )
{
struct ntdll_thread_data *thread_data = (struct ntdll_thread_data *)&teb->GdiTebBatch;
struct debug_info debug_info;
BOOL suspend;
debug_info.str_pos = debug_info.out_pos = 0;
thread_data->debug_info = &debug_info;
thread_data->pthread_id = pthread_self();
signal_init_thread( teb );
server_init_thread( thread_data->start, &suspend );

View File

@ -47,19 +47,10 @@ static inline BOOL is_machine_64bit( WORD machine )
return (machine == IMAGE_FILE_MACHINE_AMD64 || machine == IMAGE_FILE_MACHINE_ARM64);
}
struct debug_info
{
unsigned int str_pos; /* current position in strings buffer */
unsigned int out_pos; /* current position in output buffer */
char strings[1024]; /* buffer for temporary strings */
char output[1024]; /* current output line */
};
/* thread private data, stored in NtCurrentTeb()->GdiTebBatch */
struct ntdll_thread_data
{
void *cpu_data[16]; /* reserved for CPU-specific data */
struct debug_info *debug_info; /* info for debugstr functions */
void *kernel_stack; /* stack for thread startup and kernel syscalls */
int request_fd; /* fd for sending server requests */
int reply_fd; /* fd for receiving server replies */
@ -88,9 +79,9 @@ struct async_fileio
};
static const SIZE_T page_size = 0x1000;
static const SIZE_T teb_size = 0x3000; /* TEB64 + TEB32 */
static const SIZE_T teb_size = 0x3800; /* TEB64 + TEB32 + debug info */
static const SIZE_T signal_stack_mask = 0xffff;
static const SIZE_T signal_stack_size = 0x10000 - 0x3000;
static const SIZE_T signal_stack_size = 0x10000 - 0x3800;
static const SIZE_T kernel_stack_size = 0x20000;
static const LONG teb_offset = 0x2000;