Alexandre Julliard : ntdll: Move the debug functions to the Unix library.
Alexandre Julliard
julliard at winehq.org
Mon May 18 15:00:12 CDT 2020
Module: wine
Branch: master
Commit: 2424742d0711914f02864bcfb945605825b199a3
URL: https://source.winehq.org/git/wine.git/?a=commit;h=2424742d0711914f02864bcfb945605825b199a3
Author: Alexandre Julliard <julliard at winehq.org>
Date: Sun May 17 11:07:02 2020 +0200
ntdll: Move the debug functions to the Unix library.
Signed-off-by: Alexandre Julliard <julliard at winehq.org>
---
dlls/ntdll/Makefile.in | 2 +-
dlls/ntdll/thread.c | 37 ++++++++++++++++++++++++++++++-
dlls/ntdll/{debugtools.c => unix/debug.c} | 8 +++++--
dlls/ntdll/unix/loader.c | 18 ++++++++++-----
dlls/ntdll/unix/unix_private.h | 2 ++
dlls/ntdll/unixlib.h | 12 +++++++++-
6 files changed, 69 insertions(+), 10 deletions(-)
diff --git a/dlls/ntdll/Makefile.in b/dlls/ntdll/Makefile.in
index 699c97a1ce..f1ecb395e3 100644
--- a/dlls/ntdll/Makefile.in
+++ b/dlls/ntdll/Makefile.in
@@ -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 \
diff --git a/dlls/ntdll/thread.c b/dlls/ntdll/thread.c
index 0fc8aa9e92..2de2804f8c 100644
--- a/dlls/ntdll/thread.c
+++ b/dlls/ntdll/thread.c
@@ -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 );
diff --git a/dlls/ntdll/debugtools.c b/dlls/ntdll/unix/debug.c
similarity index 99%
rename from dlls/ntdll/debugtools.c
rename to dlls/ntdll/unix/debug.c
index 546d527323..7bc7787c9d 100644
--- a/dlls/ntdll/debugtools.c
+++ b/dlls/ntdll/unix/debug.c
@@ -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 );
diff --git a/dlls/ntdll/unix/loader.c b/dlls/ntdll/unix/loader.c
index c974f526a1..fdcca55beb 100644
--- a/dlls/ntdll/unix/loader.c
+++ b/dlls/ntdll/unix/loader.c
@@ -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,
};
diff --git a/dlls/ntdll/unix/unix_private.h b/dlls/ntdll/unix/unix_private.h
index d7f5778902..663036a699 100644
--- a/dlls/ntdll/unix/unix_private.h
+++ b/dlls/ntdll/unix/unix_private.h
@@ -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 */
diff --git a/dlls/ntdll/unixlib.h b/dlls/ntdll/unixlib.h
index 54eedc1a25..753dea6acc 100644
--- a/dlls/ntdll/unixlib.h
+++ b/dlls/ntdll/unixlib.h
@@ -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 */
More information about the wine-cvs
mailing list