msvcrt: Share a helper macro to print an exception type.

This commit is contained in:
Alexandre Julliard 2024-05-31 15:31:22 +02:00
parent 41c65022c1
commit e7546542ab
4 changed files with 20 additions and 76 deletions

View file

@ -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 );

View file

@ -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 );
}
}

View file

@ -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);
}
}

View file

@ -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