From: Rémi Bernon rbernon@codeweavers.com
--- dlls/msxml3/main.c | 8 ++++---- dlls/windowscodecs/libtiff.c | 4 ++-- include/wine/debug.h | 26 +++++++++++++++++--------- 3 files changed, 23 insertions(+), 15 deletions(-)
diff --git a/dlls/msxml3/main.c b/dlls/msxml3/main.c index c4234711fa2..c6b6b51f68a 100644 --- a/dlls/msxml3/main.c +++ b/dlls/msxml3/main.c @@ -74,7 +74,7 @@ void wineXmlCallbackLog(char const* caller, xmlErrorLevel lvl, char const* msg, len = vsnprintf(buff, max_size, msg, ap); if (len == -1 || len >= max_size) buff[max_size-1] = 0;
- wine_dbg_log(dbcl, &__wine_dbch_msxml, __FILE__, __LINE__, caller, "%s", buff); + wine_dbg_log(dbcl, &__wine_dbch_msxml, __FILE__, __LINE__, caller, __WINE_DBG_RETADDR, "%s", buff); }
void wineXmlCallbackError(char const* caller, xmlErrorPtr err) @@ -88,11 +88,11 @@ void wineXmlCallbackError(char const* caller, xmlErrorPtr err) default: dbcl = __WINE_DBCL_ERR; break; }
- wine_dbg_log(dbcl, &__wine_dbch_msxml, __FILE__, __LINE__, caller, "error code %d", err->code); + wine_dbg_log(dbcl, &__wine_dbch_msxml, __FILE__, __LINE__, caller, __WINE_DBG_RETADDR, "error code %d", err->code); if (err->message) - wine_dbg_log(dbcl, &__wine_dbch_msxml, __FILE__, __LINE__, caller, ": %s", err->message); + wine_dbg_log(dbcl, &__wine_dbch_msxml, __FILE__, __LINE__, caller, __WINE_DBG_RETADDR, ": %s", err->message); else - wine_dbg_log(dbcl, &__wine_dbch_msxml, __FILE__, __LINE__, caller, "\n"); + wine_dbg_log(dbcl, &__wine_dbch_msxml, __FILE__, __LINE__, caller, __WINE_DBG_RETADDR, "\n"); }
/* Support for loading xml files from a Wine Windows drive */ diff --git a/dlls/windowscodecs/libtiff.c b/dlls/windowscodecs/libtiff.c index 3173da0ea0b..dcaeaaad4fb 100644 --- a/dlls/windowscodecs/libtiff.c +++ b/dlls/windowscodecs/libtiff.c @@ -39,14 +39,14 @@ WINE_DECLARE_DEBUG_CHANNEL(tiff); static void tiff_error_handler( const char *module, const char *format, va_list args ) { if (!ERR_ON(tiff)) return; - if (wine_dbg_vlog( __WINE_DBCL_ERR, &__wine_dbch_tiff, __FILE__, __LINE__, module, format, args ) != -1) + if (wine_dbg_vlog( __WINE_DBCL_ERR, &__wine_dbch_tiff, __FILE__, __LINE__, module, __WINE_DBG_RETADDR, format, args ) != -1) __wine_dbg_output( "\n" ); }
static void tiff_warning_handler( const char *module, const char *format, va_list args ) { if (!WARN_ON(tiff)) return; - if (wine_dbg_vlog( __WINE_DBCL_WARN, &__wine_dbch_tiff, __FILE__, __LINE__, module, format, args ) != -1) + if (wine_dbg_vlog( __WINE_DBCL_WARN, &__wine_dbch_tiff, __FILE__, __LINE__, module, __WINE_DBG_RETADDR, format, args ) != -1) __wine_dbg_output( "\n" ); }
diff --git a/include/wine/debug.h b/include/wine/debug.h index c53d8fbd32d..dca943447f9 100644 --- a/include/wine/debug.h +++ b/include/wine/debug.h @@ -93,12 +93,19 @@ struct __wine_debug_context int version; /* for forward compatibility */ const char *function; const char *file; + const void *retaddr; int line; }; -#define WINE_DEBUG_CONTEXT_VERSION 2 +#define WINE_DEBUG_CONTEXT_VERSION 3 + +#if defined(__GNUC__) || defined(__clang__) +#define __WINE_DBG_RETADDR __builtin_extract_return_addr(__builtin_return_address(0)) +#else +#define __WINE_DBG_RETADDR ((void *)0) +#endif
#define __WINE_DBG_LOG(...) \ - wine_dbg_log( __dbcl, __dbch, __FILE__, __LINE__, __func__, __VA_ARGS__); } } while(0) + wine_dbg_log( __dbcl, __dbch, __FILE__, __LINE__, __func__, __WINE_DBG_RETADDR, __VA_ARGS__); } } while(0)
#if defined(__MINGW32__) || (!defined(__WINE_USE_MSVCRT) && (defined(__GNUC__) || defined(__clang__))) #define __WINE_PRINTF_ATTR(fmt,args) __attribute__((format (printf,fmt,args))) @@ -182,10 +189,10 @@ static inline int __wine_dbg_cdecl wine_dbg_printf( const char *format, ... ) }
static int __wine_dbg_cdecl wine_dbg_vlog( enum __wine_debug_class cls, struct __wine_debug_channel *channel, - const char *file, int line, const char *function, - const char *format, va_list args ) __WINE_PRINTF_ATTR(6,0); + const char *file, int line, const char *function, const void *retaddr, + const char *format, va_list args ) __WINE_PRINTF_ATTR(7,0); static inline int __wine_dbg_cdecl wine_dbg_vlog( enum __wine_debug_class cls, struct __wine_debug_channel *channel, - const char *file, int line, const char *function, + const char *file, int line, const char *function, const void *retaddr, const char *format, va_list args ) { struct __wine_debug_context info = @@ -194,6 +201,7 @@ static inline int __wine_dbg_cdecl wine_dbg_vlog( enum __wine_debug_class cls, s .function = function, .file = file, .line = line, + .retaddr = retaddr, }; struct __wine_debug_context *context = &info; int ret; @@ -208,17 +216,17 @@ static inline int __wine_dbg_cdecl wine_dbg_vlog( enum __wine_debug_class cls, s }
static int __wine_dbg_cdecl wine_dbg_log( enum __wine_debug_class cls, struct __wine_debug_channel *channel, - const char *file, int line, const char *function, - const char *format, ... ) __WINE_PRINTF_ATTR(6,7); + const char *file, int line, const char *function, const void *retaddr, + const char *format, ... ) __WINE_PRINTF_ATTR(7,8); static inline int __wine_dbg_cdecl wine_dbg_log( enum __wine_debug_class cls, struct __wine_debug_channel *channel, - const char *file, int line, const char *function, + const char *file, int line, const char *function, const void *retaddr, const char *format, ... ) { va_list args; int ret;
va_start( args, format ); - ret = wine_dbg_vlog( cls, channel, file, line, function, format, args ); + ret = wine_dbg_vlog( cls, channel, file, line, function, retaddr, format, args ); va_end( args ); return ret; }