Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -735,6 +735,9 @@ valgrind/fjalar/rundoxy
# Ignore shell scripts for compiling fjalar
valgrind/fjalar/*.sh

# Stamp file for the fjalar_core_decls.h consistency check
valgrind/fjalar/fjalar_core_decls.stamp

# Documentation
valgrind-merge.aux
valgrind-merge.cp
Expand Down
5 changes: 5 additions & 0 deletions doc/valgrind-merge.texinfo
Original file line number Diff line number Diff line change
Expand Up @@ -495,6 +495,11 @@ changes in Valgrind API/functionality. For the most part Valgrind
maintains a relatively stable interface to its tools. Any tool-visible
changes should be noted in the change logs.

If the build fails in the rule for
@file{fjalar_core_decls.stamp}, then a core declaration has changed.
Update the copy in @file{valgrind/fjalar/fjalar_core_decls.h} to match
the core header that it names.

A somewhat more problematic area are changes in the VEX IR. DynComp
makes heavy use of the VEX IR, so any changes in it need to be
reflected. Most of the changes to the public VEX IR can be discovered
Expand Down
34 changes: 32 additions & 2 deletions valgrind/fjalar/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,8 @@ fjalar_@VGCONF_ARCH_PRI@_@VGCONF_OS@_CPPFLAGS = \
fjalar_@VGCONF_ARCH_PRI@_@VGCONF_OS@_CFLAGS = $(LTO_CFLAGS) \
$(AM_CFLAGS_@VGCONF_PLATFORM_PRI_CAPS@: -O2=-O0) $(EXTRA_CFLAGS)
fjalar_@VGCONF_ARCH_PRI@_@VGCONF_OS@_DEPENDENCIES = \
$(TOOL_DEPENDENCIES_@VGCONF_PLATFORM_PRI_CAPS@)
$(TOOL_DEPENDENCIES_@VGCONF_PLATFORM_PRI_CAPS@) \
fjalar_core_decls.stamp
fjalar_@VGCONF_ARCH_PRI@_@VGCONF_OS@_LDADD = \
$(TOOL_LDADD_@VGCONF_PLATFORM_PRI_CAPS@)
fjalar_@VGCONF_ARCH_PRI@_@VGCONF_OS@_LDFLAGS = \
Expand All @@ -119,7 +120,8 @@ fjalar_@VGCONF_ARCH_SEC@_@VGCONF_OS@_CPPFLAGS = \
fjalar_@VGCONF_ARCH_SEC@_@VGCONF_OS@_CFLAGS = $(LTO_CFLAGS) \
$(AM_CFLAGS_@VGCONF_PLATFORM_SEC_CAPS@: -O2=-O0) $(EXTRA_CFLAGS)
fjalar_@VGCONF_ARCH_SEC@_@VGCONF_OS@_DEPENDENCIES = \
$(TOOL_DEPENDENCIES_@VGCONF_PLATFORM_SEC_CAPS@)
$(TOOL_DEPENDENCIES_@VGCONF_PLATFORM_SEC_CAPS@) \
fjalar_core_decls.stamp
fjalar_@VGCONF_ARCH_SEC@_@VGCONF_OS@_LDADD = \
$(TOOL_LDADD_@VGCONF_PLATFORM_SEC_CAPS@)
fjalar_@VGCONF_ARCH_SEC@_@VGCONF_OS@_LDFLAGS = \
Expand Down Expand Up @@ -177,3 +179,31 @@ vgpreload_fjalar_@VGCONF_ARCH_SEC@_@VGCONF_OS@_so_LDFLAGS = \
$(LIBREPLACEMALLOC_LDFLAGS_@VGCONF_PLATFORM_SEC_CAPS@)
endif


#----------------------------------------------------------------------------
# Consistency check for fjalar_core_decls.h
#----------------------------------------------------------------------------

# fjalar_core_decls.h copies declarations from coregrind headers, which
# tool files must not include. Compile it together with those headers, so
# that the build fails if a Valgrind merge makes the copies wrong. The
# test program is piped to the compiler rather than stored in a .c file,
# because tests/check_headers_and_includes forbids tool .c files from
# including pub_core headers. Each fjalar program depends on the stamp,
# so the check runs whenever a program is built.
CLEANFILES = fjalar_core_decls.stamp

fjalar_core_decls.stamp: $(srcdir)/fjalar_core_decls.h \
Comment thread
coderabbitai[bot] marked this conversation as resolved.
$(top_srcdir)/coregrind/pub_core_aspacemgr.h \
$(top_srcdir)/coregrind/pub_core_mallocfree.h
{ echo '#include "fjalar_core_decls.h"'; \
echo 'enum { fjalar_ar_demangle = VG_AR_DEMANGLE };'; \
echo '#undef VG_AR_DEMANGLE'; \
echo '#include "pub_core_aspacemgr.h"'; \
echo '#include "pub_core_mallocfree.h"'; \
echo '_Static_assert(fjalar_ar_demangle == VG_AR_DEMANGLE,'; \
echo ' "VG_AR_DEMANGLE in fjalar_core_decls.h is wrong");'; \
} | $(CC) $(fjalar_@VGCONF_ARCH_PRI@_@VGCONF_OS@_CPPFLAGS) \
$(fjalar_@VGCONF_ARCH_PRI@_@VGCONF_OS@_CFLAGS) \
-I$(srcdir) -I$(top_srcdir)/coregrind -fsyntax-only -x c -
touch $@
41 changes: 41 additions & 0 deletions valgrind/fjalar/fjalar_core_decls.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
/*
This file is part of Fjalar, a dynamic analysis framework for C/C++
programs.

Copyright (C) 2007-2026 University of Washington Computer Science & Engineering Department,
Programming Languages and Software Engineering Group

This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License as
published by the Free Software Foundation; either version 2 of the
License, or (at your option) any later version.
*/

/* fjalar_core_decls.h:

Declarations of the few Valgrind core (non-tool) entities that Fjalar
uses. Fjalar code (e.g., mc_main.c and typedata.c) includes this file
to call those entities. Tool files must not include coregrind/pub_core_*.h (see
tests/check_headers_and_includes), so these are copied here instead.
The build checks that the copies agree with the originals (see the
fjalar_core_decls.stamp rule in Makefile.am).

*/

#ifndef FJALAR_CORE_DECLS_H
#define FJALAR_CORE_DECLS_H

#include "pub_tool_basics.h"

// From coregrind/pub_core_aspacemgr.h.
// mc_check_readable uses this to accept readable memory that Valgrind
// owns, which VG_(am_is_valid_for_client) rejects.
extern Bool VG_(am_is_valid_for_valgrind)(Addr start, SizeT len, UInt prot);

// From coregrind/pub_core_mallocfree.h.
// Used to release the demanglers' results, which are allocated in the
// VG_AR_DEMANGLE arena. ArenaId is a typedef for Int.
extern void VG_(arena_free)(Int arena, void* ptr);
#define VG_AR_DEMANGLE 3

#endif /* FJALAR_CORE_DECLS_H */
2 changes: 1 addition & 1 deletion valgrind/fjalar/mc_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@
#include "kvasir/kvasir_main.h"
#include "kvasir/dyncomp_main.h"
#include "fjalar_main.h"
#include "../coregrind/pub_core_aspacemgr.h" // needed for am_is_valid_for_client
#include "fjalar_core_decls.h" // for VG_(am_is_valid_for_valgrind)

#include "mc_include.h"
#include "memcheck.h" /* for client requests */
Expand Down
2 changes: 1 addition & 1 deletion valgrind/fjalar/typedata.c
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
// For name demangling.
#include "../coregrind/m_demangle/demangle.h"
// For VG_(arena_free), to release the demanglers' results.
#include "../coregrind/pub_core_mallocfree.h"
#include "fjalar_core_decls.h"

// Most of the following information is taken from "DWARF Debugging
// Information Format Version 4". Published by the DWARF Debugging
Expand Down
Loading