Module: wine Branch: master Commit: 2084fbd93dd607a6534eba7cab7dd60e0a12ca37 URL: https://source.winehq.org/git/wine.git/?a=commit;h=2084fbd93dd607a6534eba7ca...
Author: Alexandre Julliard julliard@winehq.org Date: Tue Jun 15 16:31:49 2021 +0200
ntdll: Store the debug info in the TEB block after the 32-bit TEB.
Signed-off-by: Alexandre Julliard julliard@winehq.org
---
dlls/ntdll/unix/debug.c | 17 +++++++++++++++-- dlls/ntdll/unix/thread.c | 3 --- dlls/ntdll/unix/unix_private.h | 13 ++----------- 3 files changed, 17 insertions(+), 16 deletions(-)
diff --git a/dlls/ntdll/unix/debug.c b/dlls/ntdll/unix/debug.c index b733ff24ab9..753bc36e469 100644 --- a/dlls/ntdll/unix/debug.c +++ b/dlls/ntdll/unix/debug.c @@ -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; } diff --git a/dlls/ntdll/unix/thread.c b/dlls/ntdll/unix/thread.c index 10144dc2e61..c7b94eba923 100644 --- a/dlls/ntdll/unix/thread.c +++ b/dlls/ntdll/unix/thread.c @@ -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 ); diff --git a/dlls/ntdll/unix/unix_private.h b/dlls/ntdll/unix/unix_private.h index 37ebd99e536..c8c959029d0 100644 --- a/dlls/ntdll/unix/unix_private.h +++ b/dlls/ntdll/unix/unix_private.h @@ -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;