Module: wine Branch: master Commit: e7546542abbdd58299b8f7333a1f62ba969a9ea6 URL: https://gitlab.winehq.org/wine/wine/-/commit/e7546542abbdd58299b8f7333a1f62b...
Author: Alexandre Julliard julliard@winehq.org Date: Fri May 31 15:31:22 2024 +0200
msvcrt: Share a helper macro to print an exception type.
---
dlls/msvcrt/cppexcept.h | 17 +++++++++++++++++ dlls/msvcrt/except_i386.c | 23 +---------------------- dlls/msvcrt/except_x86_64.c | 28 +--------------------------- dlls/msvcrt/handler4.c | 28 +--------------------------- 4 files changed, 20 insertions(+), 76 deletions(-)
diff --git a/dlls/msvcrt/cppexcept.h b/dlls/msvcrt/cppexcept.h index a5a8abb9345..36bc72ab1bc 100644 --- a/dlls/msvcrt/cppexcept.h +++ b/dlls/msvcrt/cppexcept.h @@ -261,6 +261,23 @@ static inline void copy_exception( void *object, uintptr_t frame, int offset, UI } }
+#define TRACE_EXCEPTION_TYPE(type,base) do { \ + const cxx_type_info_table *table = rtti_rva( type->type_info_table, base ); \ + unsigned int i; \ + TRACE( "flags %x destr %p handler %p type info %p\n", \ + type->flags, rtti_rva( type->destructor, base ), \ + type->custom_handler ? rtti_rva( type->custom_handler, base ) : NULL, table ); \ + for (i = 0; i < table->count; i++) \ + { \ + const cxx_type_info *type = rtti_rva( table->info[i], base ); \ + const type_info *info = rtti_rva( type->type_info, base ); \ + TRACE( " %d: flags %x type %p %s offsets %d,%d,%d size %d copy ctor %p\n", \ + i, type->flags, info, dbgstr_type_info( info ), \ + type->offsets.this_offset, type->offsets.vbase_descr, type->offsets.vbase_offset, \ + type->size, rtti_rva( type->copy_ctor, base )); \ + } \ +} while(0) + extern void *find_catch_handler( void *object, uintptr_t frame, uintptr_t exc_base, const tryblock_info *tryblock, cxx_exception_type *exc_type, uintptr_t image_base ); diff --git a/dlls/msvcrt/except_i386.c b/dlls/msvcrt/except_i386.c index 5a8a84089d9..91fe11a4dfc 100644 --- a/dlls/msvcrt/except_i386.c +++ b/dlls/msvcrt/except_i386.c @@ -152,27 +152,6 @@ __ASM_GLOBAL_FUNC( call_handler, "popl %ebp\n\t" "ret" );
-static inline void dump_type( const cxx_type_info *type ) -{ - TRACE( "flags %x type %p %s offsets %d,%d,%d size %d copy ctor %p\n", - type->flags, type->type_info, dbgstr_type_info(type->type_info), - type->offsets.this_offset, type->offsets.vbase_descr, type->offsets.vbase_offset, - type->size, type->copy_ctor ); -} - -static void dump_exception_type( const cxx_exception_type *type ) -{ - UINT i; - - TRACE( "flags %x destr %p handler %p type info %p\n", - type->flags, type->destructor, type->custom_handler, type->type_info_table ); - for (i = 0; i < type->type_info_table->count; i++) - { - TRACE( " %d: ", i ); - dump_type( type->type_info_table->info[i] ); - } -} - static void dump_function_descr( const cxx_function_descr *descr ) { UINT i; @@ -488,7 +467,7 @@ DWORD CDECL cxx_frame_handler( PEXCEPTION_RECORD rec, cxx_exception_frame* frame { TRACE("handling C++ exception rec %p frame %p trylevel %d descr %p nested_frame %p\n", rec, frame, frame->trylevel, descr, nested_frame ); - dump_exception_type( exc_type ); + TRACE_EXCEPTION_TYPE( exc_type, 0 ); dump_function_descr( descr ); } } diff --git a/dlls/msvcrt/except_x86_64.c b/dlls/msvcrt/except_x86_64.c index 7dc12db0f25..39202ff7d9a 100644 --- a/dlls/msvcrt/except_x86_64.c +++ b/dlls/msvcrt/except_x86_64.c @@ -61,32 +61,6 @@ static inline void* rva_to_ptr(UINT rva, ULONG64 base) return rva ? (void*)(base+rva) : NULL; }
-static inline void dump_type(UINT type_rva, ULONG64 base) -{ - const cxx_type_info *type = rva_to_ptr(type_rva, base); - - TRACE("flags %x type %x %s offsets %d,%d,%d size %d copy ctor %x(%p)\n", - type->flags, type->type_info, dbgstr_type_info(rva_to_ptr(type->type_info, base)), - type->offsets.this_offset, type->offsets.vbase_descr, type->offsets.vbase_offset, - type->size, type->copy_ctor, rva_to_ptr(type->copy_ctor, base)); -} - -static void dump_exception_type(const cxx_exception_type *type, ULONG64 base) -{ - const cxx_type_info_table *type_info_table = rva_to_ptr(type->type_info_table, base); - UINT i; - - TRACE("flags %x destr %x(%p) handler %x(%p) type info %x(%p)\n", - type->flags, type->destructor, rva_to_ptr(type->destructor, base), - type->custom_handler, rva_to_ptr(type->custom_handler, base), - type->type_info_table, type_info_table); - for (i = 0; i < type_info_table->count; i++) - { - TRACE(" %d: ", i); - dump_type(type_info_table->info[i], base); - } -} - static void dump_function_descr(const cxx_function_descr *descr, ULONG64 image_base) { unwind_info *unwind_table = rva_to_ptr(descr->unwind_table, image_base); @@ -452,7 +426,7 @@ static DWORD cxx_frame_handler(EXCEPTION_RECORD *rec, ULONG64 frame, if (TRACE_ON(seh)) { TRACE("handling C++ exception rec %p frame %I64x descr %p\n", rec, frame, descr); - dump_exception_type(exc_type, rec->ExceptionInformation[3]); + TRACE_EXCEPTION_TYPE(exc_type, rec->ExceptionInformation[3]); dump_function_descr(descr, dispatch->ImageBase); } } diff --git a/dlls/msvcrt/handler4.c b/dlls/msvcrt/handler4.c index e805543d6ca..878a5497aaa 100644 --- a/dlls/msvcrt/handler4.c +++ b/dlls/msvcrt/handler4.c @@ -249,32 +249,6 @@ static void read_ipmap_info(BYTE **b, ipmap_info *ii) ii->state = (INT)decode_uint(b) - 1; }
-static inline void dump_type(UINT type_rva, ULONG64 base) -{ - const cxx_type_info *type = rva_to_ptr(type_rva, base); - - TRACE("flags %x type %x %s offsets %d,%d,%d size %d copy ctor %x(%p)\n", - type->flags, type->type_info, dbgstr_type_info(rva_to_ptr(type->type_info, base)), - type->offsets.this_offset, type->offsets.vbase_descr, type->offsets.vbase_offset, - type->size, type->copy_ctor, rva_to_ptr(type->copy_ctor, base)); -} - -static void dump_exception_type(const cxx_exception_type *type, ULONG64 base) -{ - const cxx_type_info_table *type_info_table = rva_to_ptr(type->type_info_table, base); - UINT i; - - TRACE("flags %x destr %x(%p) handler %x(%p) type info %x(%p)\n", - type->flags, type->destructor, rva_to_ptr(type->destructor, base), - type->custom_handler, rva_to_ptr(type->custom_handler, base), - type->type_info_table, type_info_table); - for (i = 0; i < type_info_table->count; i++) - { - TRACE(" %d: ", i); - dump_type(type_info_table->info[i], base); - } -} - static BOOL validate_cxx_function_descr4(const cxx_function_descr_v4 *descr, DISPATCHER_CONTEXT *dispatch) { ULONG64 image_base = dispatch->ImageBase; @@ -680,7 +654,7 @@ static DWORD cxx_frame_handler4(EXCEPTION_RECORD *rec, ULONG64 frame, if (TRACE_ON(seh)) { TRACE("handling C++ exception rec %p frame %Ix descr %p\n", rec, frame, descr); - dump_exception_type(exc_type, rec->ExceptionInformation[3]); + TRACE_EXCEPTION_TYPE(exc_type, rec->ExceptionInformation[3]); } } else