From b9326bb1db5fff20332fd6bdbf37741784c215ea Mon Sep 17 00:00:00 2001 From: Paul Floyd Date: Sun, 20 Aug 2023 08:52:36 +0200 Subject: [PATCH] FreeBSD: complete loading debuginfo if entering capability mode --- coregrind/m_debuginfo/debuginfo.c | 15 +++++++++++++++ coregrind/m_syswrap/syswrap-freebsd.c | 2 ++ coregrind/pub_core_debuginfo.h | 7 +++++++ 3 files changed, 24 insertions(+) diff --git a/coregrind/m_debuginfo/debuginfo.c b/coregrind/m_debuginfo/debuginfo.c index 8d1fdc696..c37e50b9d 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 9af37cfb8..a59872b3c 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 ce7246217..6e93bb93c 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. -- 2.11.4.GIT