From a2f8e48b19cb3ae6a2984354f4cadbc23cf631cb Mon Sep 17 00:00:00 2001 From: Florian Krohm Date: Mon, 11 Aug 2025 18:39:28 +0000 Subject: [PATCH] Fix VALGRIND_CLO_CHANGE behaviour (BZ 508093) Command line flags that modify variable vex_control did not have the desired effect when processed dynamically via VALGRIND_CLO_CHANGE. The fix is to call the new function LibVEX_set_VexControl in process_dynamic_option. Fixes https://bugs.kde.org/show_bug.cgi?id=508093 --- NEWS | 3 +++ VEX/priv/main_main.c | 5 +++++ VEX/pub/libvex.h | 2 ++ coregrind/m_main.c | 4 ++++ 4 files changed, 14 insertions(+) diff --git a/NEWS b/NEWS index 1a0cee4c8..c754435d2 100644 --- a/NEWS +++ b/NEWS @@ -10,6 +10,8 @@ X86/macOS 10.13, AMD64/macOS 10.13 and nanoMIPS/Linux. * ==================== CORE CHANGES =================== +* New VEX API function LibVEX_set_VexControl + * ================== PLATFORM CHANGES ================= * ==================== TOOL CHANGES =================== @@ -75,6 +77,7 @@ are not entered into bugzilla tend to get forgotten about or ignored. 508027 Fix mips32 FTBFS 508029 Review the vmsplice syscall wrapper 508030 Add several missing syscall hooks to ppc64-linux +508093 VALGRIND_CLO_CHANGE does not update vex_control To see details of a given bug, visit https://bugs.kde.org/show_bug.cgi?id=XXXXXX diff --git a/VEX/priv/main_main.c b/VEX/priv/main_main.c index 0520fd747..619cace2e 100644 --- a/VEX/priv/main_main.c +++ b/VEX/priv/main_main.c @@ -206,6 +206,11 @@ void LibVEX_default_VexControl ( /*OUT*/ VexControl* vcon ) vcon->regalloc_version = 3; } +void LibVEX_set_VexControl ( VexControl vcon ) +{ + __builtin_memcpy(&vex_control, &vcon, sizeof vex_control); +} + /* Exported to library client. */ diff --git a/VEX/pub/libvex.h b/VEX/pub/libvex.h index de19e1ebf..177969978 100644 --- a/VEX/pub/libvex.h +++ b/VEX/pub/libvex.h @@ -581,6 +581,8 @@ typedef extern void LibVEX_default_VexControl ( /*OUT*/ VexControl* vcon ); +extern +void LibVEX_set_VexControl ( VexControl ); /*-------------------------------------------------------*/ /*--- Storage management control ---*/ diff --git a/coregrind/m_main.c b/coregrind/m_main.c index f7fd20dba..c94e5e053 100644 --- a/coregrind/m_main.c +++ b/coregrind/m_main.c @@ -939,6 +939,10 @@ void VG_(process_dynamic_option) (Clo_Mode mode, HChar *value) struct process_option_state dummy; process_option (mode, value, &dummy); // No need to handle a process_option_state once valgrind has started. + + /* Update vex_control in case VALGRIND_CLO_CHANGE was used to modify a + VexControl member. */ + LibVEX_set_VexControl(VG_(clo_vex_control)); } /* Peer at previously set up VG_(args_for_valgrind) and do some -- 2.47.2