From: Paul Floyd Date: Sun, 20 Aug 2023 06:52:36 +0000 (+0200) Subject: FreeBSD: complete loading debuginfo if entering capability mode X-Git-Tag: VALGRIND_3_22_0~128 X-Git-Url: http://git.ipfire.org/gitweb/gitweb.cgi?a=commitdiff_plain;h=b9326bb1db5fff20332fd6bdbf37741784c215ea;p=thirdparty%2Fvalgrind.git FreeBSD: complete loading debuginfo if entering capability mode --- diff --git a/coregrind/m_debuginfo/debuginfo.c b/coregrind/m_debuginfo/debuginfo.c index 8d1fdc6960..c37e50b9d3 100644 --- a/coregrind/m_debuginfo/debuginfo.c +++ b/coregrind/m_debuginfo/debuginfo.c @@ -5102,6 +5102,21 @@ static void caches__invalidate ( void ) { debuginfo_generation++; } +#if defined(VGO_freebsd) +void VG_(load_all_debuginfo) (void) +{ + for (DebugInfo* di = debugInfo_list; di; di = di->next) { + if (di->deferred == True) { + di->deferred = False; + ML_(read_elf_debug)( di ); + ML_(canonicaliseTables)( di ); + check_CFSI_related_invariants(di); + ML_(finish_CFSI_arrays)(di); + } + } +} +#endif + /*--------------------------------------------------------------------*/ /*--- end ---*/ /*--------------------------------------------------------------------*/ diff --git a/coregrind/m_syswrap/syswrap-freebsd.c b/coregrind/m_syswrap/syswrap-freebsd.c index 9af37cfb83..a59872b3c9 100644 --- a/coregrind/m_syswrap/syswrap-freebsd.c +++ b/coregrind/m_syswrap/syswrap-freebsd.c @@ -5645,6 +5645,8 @@ PRE(sys_cap_enter) " Please consider disabling capability by using the RUNNING_ON_VALGRIND mechanism.\n" " See http://valgrind.org/docs/manual/manual-core-adv.html#manual-core-adv.clientreq\n"); } + /* now complete loading debuginfo since it is not allowed after entering cap mode */ + VG_(load_all_debuginfo)(); } // SYS_cap_getmode 517 diff --git a/coregrind/pub_core_debuginfo.h b/coregrind/pub_core_debuginfo.h index ce72462178..6e93bb93c5 100644 --- a/coregrind/pub_core_debuginfo.h +++ b/coregrind/pub_core_debuginfo.h @@ -150,6 +150,13 @@ extern Bool VG_(use_CF_info) ( /*MOD*/D3UnwindRegs* uregs, info (e.g. CFI info or FPO info or ...). */ extern UInt VG_(debuginfo_generation) (void); +#if defined(VGO_freebsd) +/* Force completion of loading all debuginfo. + Needed on FreeBSD when entering capability mode since + we can't open executable files to get the debuginfo after + entering capability mode. */ +extern void VG_(load_all_debuginfo) (void); +#endif /* True if some FPO information is loaded.