Module: wine Branch: master Commit: df09103ab6cfc55659c068c51bee8ad24ab9134d URL: https://gitlab.winehq.org/wine/wine/-/commit/df09103ab6cfc55659c068c51bee8ad...
Author: Alexandre Julliard julliard@winehq.org Date: Fri May 31 15:33:08 2024 +0200
msvcrt: Share the dump_function_descr() helper between platforms.
---
dlls/msvcrt/cppexcept.h | 1 + dlls/msvcrt/except.c | 46 +++++++++++++++++++++++++++++++++++++++++++++ dlls/msvcrt/except_i386.c | 35 +--------------------------------- dlls/msvcrt/except_x86_64.c | 44 ------------------------------------------- 4 files changed, 48 insertions(+), 78 deletions(-)
diff --git a/dlls/msvcrt/cppexcept.h b/dlls/msvcrt/cppexcept.h index 36bc72ab1bc..690c1f5817f 100644 --- a/dlls/msvcrt/cppexcept.h +++ b/dlls/msvcrt/cppexcept.h @@ -278,6 +278,7 @@ static inline void copy_exception( void *object, uintptr_t frame, int offset, UI } \ } while(0)
+extern void dump_function_descr( const cxx_function_descr *descr, uintptr_t base ); 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.c b/dlls/msvcrt/except.c index 08e2a51011d..b6f2bb8784d 100644 --- a/dlls/msvcrt/except.c +++ b/dlls/msvcrt/except.c @@ -46,6 +46,52 @@ static MSVCRT_security_error_handler security_error_handler;
static __sighandler_t sighandlers[NSIG] = { SIG_DFL };
+void dump_function_descr( const cxx_function_descr *descr, uintptr_t base ) +{ + unwind_info *unwind_table = rtti_rva( descr->unwind_table, base ); + tryblock_info *tryblock = rtti_rva( descr->tryblock, base ); + ipmap_info *ipmap = rtti_rva( descr->ipmap, base ); + UINT i, j; + + TRACE( "magic %x\n", descr->magic ); + TRACE( "unwind table: %p %d\n", unwind_table, descr->unwind_count ); + for (i = 0; i < descr->unwind_count; i++) + { + TRACE(" %d: prev %d func %p\n", i, unwind_table[i].prev, + unwind_table[i].handler ? rtti_rva( unwind_table[i].handler, base ) : NULL ); + } + TRACE( "try table: %p %d\n", tryblock, descr->tryblock_count ); + for (i = 0; i < descr->tryblock_count; i++) + { + catchblock_info *catchblock = rtti_rva( tryblock[i].catchblock, base ); + + TRACE( " %d: start %d end %d catchlevel %d catch %p %d\n", i, + tryblock[i].start_level, tryblock[i].end_level, + tryblock[i].catch_level, catchblock, tryblock[i].catchblock_count); + for (j = 0; j < tryblock[i].catchblock_count; j++) + { + type_info *type_info = catchblock[j].type_info ? rtti_rva( catchblock[j].type_info, base ) : NULL; + TRACE( " %d: flags %x offset %d handler %p", + j, catchblock[j].flags, catchblock[j].offset, + catchblock[j].handler ? rtti_rva(catchblock[j].handler, base) : NULL ); +#ifdef RTTI_USE_RVA + TRACE( " frame %x", catchblock[j].frame ); +#endif + TRACE( " type %p %s\n", type_info, dbgstr_type_info(type_info) ); + } + } + TRACE( "ipmap: %p %d\n", ipmap, descr->ipmap_count ); + for (i = 0; i < descr->ipmap_count; i++) + TRACE( " %d: ip %x state %d\n", i, ipmap[i].ip, ipmap[i].state ); +#ifdef RTTI_USE_RVA + TRACE( "unwind_help %+d\n", descr->unwind_help ); +#endif + if (descr->magic <= CXX_FRAME_MAGIC_VC6) return; + TRACE( "expect list: %p\n", rtti_rva( descr->expect_list, base ) ); + if (descr->magic <= CXX_FRAME_MAGIC_VC7) return; + TRACE( "flags: %08x\n", descr->flags ); +} + 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 91fe11a4dfc..f76762d3cb0 100644 --- a/dlls/msvcrt/except_i386.c +++ b/dlls/msvcrt/except_i386.c @@ -152,39 +152,6 @@ __ASM_GLOBAL_FUNC( call_handler, "popl %ebp\n\t" "ret" );
-static void dump_function_descr( const cxx_function_descr *descr ) -{ - UINT i; - int j; - - TRACE( "magic %x\n", descr->magic ); - TRACE( "unwind table: %p %d\n", descr->unwind_table, descr->unwind_count ); - for (i = 0; i < descr->unwind_count; i++) - { - TRACE( " %d: prev %d func %p\n", i, - descr->unwind_table[i].prev, descr->unwind_table[i].handler ); - } - TRACE( "try table: %p %d\n", descr->tryblock, descr->tryblock_count ); - for (i = 0; i < descr->tryblock_count; i++) - { - TRACE( " %d: start %d end %d catchlevel %d catch %p %d\n", i, - descr->tryblock[i].start_level, descr->tryblock[i].end_level, - descr->tryblock[i].catch_level, descr->tryblock[i].catchblock, - descr->tryblock[i].catchblock_count ); - for (j = 0; j < descr->tryblock[i].catchblock_count; j++) - { - const catchblock_info *ptr = &descr->tryblock[i].catchblock[j]; - TRACE( " %d: flags %x offset %d handler %p type %p %s\n", - j, ptr->flags, ptr->offset, ptr->handler, - ptr->type_info, dbgstr_type_info( ptr->type_info ) ); - } - } - if (descr->magic <= CXX_FRAME_MAGIC_VC6) return; - TRACE( "expect list: %p\n", descr->expect_list ); - if (descr->magic <= CXX_FRAME_MAGIC_VC7) return; - TRACE( "flags: %08x\n", descr->flags ); -} - /* unwind the local function up to a given trylevel */ static void cxx_local_unwind( cxx_exception_frame* frame, const cxx_function_descr *descr, int last_level) { @@ -468,7 +435,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 ); TRACE_EXCEPTION_TYPE( exc_type, 0 ); - dump_function_descr( descr ); + dump_function_descr( descr, 0 ); } } else diff --git a/dlls/msvcrt/except_x86_64.c b/dlls/msvcrt/except_x86_64.c index 39202ff7d9a..81a2515997b 100644 --- a/dlls/msvcrt/except_x86_64.c +++ b/dlls/msvcrt/except_x86_64.c @@ -61,50 +61,6 @@ static inline void* rva_to_ptr(UINT rva, ULONG64 base) return rva ? (void*)(base+rva) : NULL; }
-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); - tryblock_info *tryblock = rva_to_ptr(descr->tryblock, image_base); - ipmap_info *ipmap = rva_to_ptr(descr->ipmap, image_base); - UINT i, j; - - TRACE("magic %x\n", descr->magic); - TRACE("unwind table: %x(%p) %d\n", descr->unwind_table, unwind_table, descr->unwind_count); - for (i=0; i<descr->unwind_count; i++) - { - TRACE(" %d: prev %d func %x(%p)\n", i, unwind_table[i].prev, - unwind_table[i].handler, rva_to_ptr(unwind_table[i].handler, image_base)); - } - TRACE("try table: %x(%p) %d\n", descr->tryblock, tryblock, descr->tryblock_count); - for (i=0; i<descr->tryblock_count; i++) - { - catchblock_info *catchblock = rva_to_ptr(tryblock[i].catchblock, image_base); - - TRACE(" %d: start %d end %d catchlevel %d catch %x(%p) %d\n", i, - tryblock[i].start_level, tryblock[i].end_level, - tryblock[i].catch_level, tryblock[i].catchblock, - catchblock, tryblock[i].catchblock_count); - for (j=0; j<tryblock[i].catchblock_count; j++) - { - TRACE(" %d: flags %x offset %d handler %x(%p) frame %x type %x %s\n", - j, catchblock[j].flags, catchblock[j].offset, catchblock[j].handler, - rva_to_ptr(catchblock[j].handler, image_base), catchblock[j].frame, - catchblock[j].type_info, - dbgstr_type_info(rva_to_ptr(catchblock[j].type_info, image_base))); - } - } - TRACE("ipmap: %x(%p) %d\n", descr->ipmap, ipmap, descr->ipmap_count); - for (i=0; i<descr->ipmap_count; i++) - { - TRACE(" %d: ip %x state %d\n", i, ipmap[i].ip, ipmap[i].state); - } - TRACE("unwind_help %d\n", descr->unwind_help); - if (descr->magic <= CXX_FRAME_MAGIC_VC6) return; - TRACE("expect list: %x\n", descr->expect_list); - if (descr->magic <= CXX_FRAME_MAGIC_VC7) return; - TRACE("flags: %08x\n", descr->flags); -} - static inline int ip_to_state(ipmap_info *ipmap, UINT count, int ip) { UINT low = 0, high = count-1, med;