ntdll: Move the debug functions to the Unix library.

Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Alexandre Julliard 2020-05-17 11:07:02 +02:00
parent aaa654abd6
commit 2424742d07
6 changed files with 69 additions and 10 deletions

View File

@ -13,7 +13,6 @@ C_SRCS = \
critsection.c \
crypt.c \
debugbuffer.c \
debugtools.c \
directory.c \
env.c \
error.c \
@ -51,6 +50,7 @@ C_SRCS = \
thread.c \
threadpool.c \
time.c \
unix/debug.c \
unix/loader.c \
unix/virtual.c \
version.c \

View File

@ -152,6 +152,41 @@ static ULONG_PTR get_image_addr(void)
#endif
/***********************************************************************
* __wine_dbg_get_channel_flags (NTDLL.@)
*
* Get the flags to use for a given channel, possibly setting them too in case of lazy init
*/
unsigned char __cdecl __wine_dbg_get_channel_flags( struct __wine_debug_channel *channel )
{
return unix_funcs->dbg_get_channel_flags( channel );
}
/***********************************************************************
* __wine_dbg_strdup (NTDLL.@)
*/
const char * __cdecl __wine_dbg_strdup( const char *str )
{
return unix_funcs->dbg_strdup( str );
}
/***********************************************************************
* __wine_dbg_header (NTDLL.@)
*/
int __cdecl __wine_dbg_header( enum __wine_debug_class cls, struct __wine_debug_channel *channel,
const char *function )
{
return unix_funcs->dbg_header( cls, channel, function );
}
/***********************************************************************
* __wine_dbg_output (NTDLL.@)
*/
int __cdecl __wine_dbg_output( const char *str )
{
return unix_funcs->dbg_output( str );
}
/***********************************************************************
* set_process_name
*
@ -345,7 +380,7 @@ TEB *thread_init(void)
thread_data->wait_fd[0] = -1;
thread_data->wait_fd[1] = -1;
debug_init();
unix_funcs->dbg_init();
init_paths();
set_process_name( __wine_main_argc, __wine_main_argv );

View File

@ -18,6 +18,10 @@
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
#if 0
#pragma makedep unix
#endif
#include "config.h"
#include "wine/port.h"
@ -280,9 +284,9 @@ int __cdecl __wine_dbg_header( enum __wine_debug_class cls, struct __wine_debug_
}
/***********************************************************************
* debug_init
* dbg_init
*/
void debug_init(void)
void CDECL dbg_init(void)
{
setbuf( stdout, NULL );
setbuf( stderr, NULL );

View File

@ -51,6 +51,9 @@
#include "winternl.h"
#include "unix_private.h"
#include "wine/library.h"
#include "wine/debug.h"
WINE_DEFAULT_DEBUG_CHANNEL(ntdll);
extern IMAGE_NT_HEADERS __wine_spec_nt_header;
extern void CDECL __wine_set_unix_funcs( int version, const struct unix_funcs *funcs );
@ -319,13 +322,13 @@ static void fixup_ntdll_imports( const IMAGE_NT_HEADERS *nt, HMODULE ntdll_modul
{
int ordinal = IMAGE_ORDINAL( import_list->u1.Ordinal ) - ntdll_exports->Base;
thunk_list->u1.Function = find_ordinal_export( ntdll_module, ntdll_exports, ordinal );
if (!thunk_list->u1.Function) fprintf( stderr, "ntdll: ordinal %u not found\n", ordinal );
if (!thunk_list->u1.Function) ERR( "ordinal %u not found\n", ordinal );
}
else /* import by name */
{
IMAGE_IMPORT_BY_NAME *pe_name = get_rva( nt, import_list->u1.AddressOfData );
thunk_list->u1.Function = find_named_export( ntdll_module, ntdll_exports, pe_name );
if (!thunk_list->u1.Function) fprintf( stderr, "ntdll: %s not found\n", pe_name->Name );
if (!thunk_list->u1.Function) ERR( "%s not found\n", pe_name->Name );
}
import_list++;
thunk_list++;
@ -348,7 +351,7 @@ static HMODULE load_ntdll(void)
if (!dladdr( load_ntdll, &info ))
{
fprintf( stderr, "cannot get path to ntdll.so\n" );
ERR( "cannot get path to ntdll.so\n" );
exit(1);
}
name = malloc( strlen(info.dli_fname) + 5 );
@ -356,12 +359,12 @@ static HMODULE load_ntdll(void)
strcpy( name + strlen(info.dli_fname) - 3, ".dll.so" );
if (!(handle = dlopen( name, RTLD_NOW )))
{
fprintf( stderr, "failed to load %s: %s\n", name, dlerror() );
ERR( "failed to load %s: %s\n", name, dlerror() );
exit(1);
}
if (!(nt = dlsym( handle, "__wine_spec_nt_header" )))
{
fprintf( stderr, "NT header not found in %s (too old?)\n", name );
ERR( "NT header not found in %s (too old?)\n", name );
exit(1);
}
free( name );
@ -381,6 +384,11 @@ static struct unix_funcs unix_funcs =
mmap_remove_reserved_area,
mmap_is_in_reserved_area,
mmap_enum_reserved_areas,
dbg_init,
__wine_dbg_get_channel_flags,
__wine_dbg_strdup,
__wine_dbg_output,
__wine_dbg_header,
};

View File

@ -31,4 +31,6 @@ int CDECL mmap_enum_reserved_areas( int (CDECL *enum_func)(void *base, SIZE_T s
extern void virtual_init(void) DECLSPEC_HIDDEN;
extern void CDECL dbg_init(void) DECLSPEC_HIDDEN;
#endif /* __NTDLL_UNIX_PRIVATE_H */

View File

@ -21,8 +21,10 @@
#ifndef __NTDLL_UNIXLIB_H
#define __NTDLL_UNIXLIB_H
#include "wine/debug.h"
/* increment this when you change the function table */
#define NTDLL_UNIXLIB_VERSION 2
#define NTDLL_UNIXLIB_VERSION 3
struct unix_funcs
{
@ -33,6 +35,14 @@ struct unix_funcs
int (CDECL *mmap_is_in_reserved_area)( void *addr, SIZE_T size );
int (CDECL *mmap_enum_reserved_areas)( int (CDECL *enum_func)(void *base, SIZE_T size, void *arg),
void *arg, int top_down );
/* debugging functions */
void (CDECL *dbg_init)(void);
unsigned char (CDECL *dbg_get_channel_flags)( struct __wine_debug_channel *channel );
const char * (CDECL *dbg_strdup)( const char *str );
int (CDECL *dbg_output)( const char *str );
int (CDECL *dbg_header)( enum __wine_debug_class cls, struct __wine_debug_channel *channel,
const char *function );
};
#endif /* __NTDLL_UNIXLIB_H */