Skip to content

Commit

Permalink
vlog: Make the vlog module catalog program-specific.
Browse files Browse the repository at this point in the history
Until now, the collection of vlog modules supported by a given OVS program
was not specific to that program.  That means that, for example, even
though ovs-dpctl does not have anything to do with jsonrpc, it still has
a vlog module for it.  This is confusing, at best.

This commit fixes the problem on some systems, in particular on ones that
use GCC and the GNU linker.  It uses the feature of the GNU linker
described in its manual as:

    If an orphaned section's name is representable as a C identifier then
    the linker will automatically see PROVIDE two symbols: __start_SECNAME
    and __end_SECNAME, where SECNAME is the name of the section.  These
    indicate the start address and end address of the orphaned section
    respectively.

Systems that don't support these features retain the earlier behavior.

This commit also fixes the annoyance that modifying lib/vlog-modules.def
causes all sources files that #include "vlog.h" to recompile.
  • Loading branch information
blp committed Jul 21, 2010
1 parent 5136ce4 commit 480ce8a
Show file tree
Hide file tree
Showing 16 changed files with 292 additions and 134 deletions.
66 changes: 66 additions & 0 deletions build-aux/check-vlog-modules
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
#! /bin/sh

if test "$1" = --help; then
cat <<EOF
$0: cross-check declared and defined vlog modules
usage: $0 [--help]
Must be run from the top-level source directory.
On systems that don't support user-defined section names, the 'vlog'
logging subsystem requires the list of modules in lib/vlog-modules.def
to match the set of vlog modules actually used by the source files.
However, most Open vSwitch development happens on systems that do
support user-defined section names and don't have this requirement.
This utility runs automatically at build time to check this
requirement "by hand", so that Open vSwitch developers don't
accidentally break the build for others.
EOF
exit 0
elif test "$#" != 0; then
echo "no arguments accepted (use --help for help)"
exit 1
elif test ! -e lib/vlog-modules.def; then
echo "must run from the top-level source directory (use --help for help)"
exit 1
fi

# We can only get a list of source files if this is a Git checkout.
if test -e .git && (git --version) >/dev/null 2>&1; then
:
else
exit 0
fi

# Get the list of modules declared in lib/vlog-modules.def.
vlog_modules=`
sed -n 's/^VLOG_MODULE(\([_a-zA-Z0-9]\{1,\}\)).*$/\1/p' \
lib/vlog-modules.def \
| LC_ALL=C sort -u | xargs echo`

# Get the list of modules defined in some source file.
src_modules=`
git grep -h -E '^[ ]*VLOG_DEFINE(_THIS)?_MODULE\([_a-zA-Z0-9]+\)[ ]*$' \
| sed 's/.*(\([_a-zA-Z0-9]\{1,\}\)).*/\1/' \
| LC_ALL=C sort -u \
| xargs echo`

rc=0

for module in $vlog_modules; do
case " $src_modules " in
*" $module "*) ;;
*) echo "vlog module $module is declared in lib/vlog-modules.def but not defined by any source file";
rc=1 ;;
esac
done

for module in $src_modules; do
case " $vlog_modules " in
*" $module "*) ;;
*) echo "vlog module $module is defined in a source file but not declared in lib/vlog-modules.def";
rc=1 ;;
esac
done

exit $rc
1 change: 1 addition & 0 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ OVS_CHECK_MALLOC_HOOKS
OVS_CHECK_VALGRIND
OVS_CHECK_TTY_LOCK_DIR
OVS_CHECK_SOCKET_LIBS
OVS_CHECK_LINKER_SECTIONS

AC_CHECK_FUNCS([strsignal])

Expand Down
2 changes: 1 addition & 1 deletion extras/ezio/ovs-switchui.c
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ main(int argc, char *argv[])
set_program_name(argv[0]);
parse_options(argc, argv);
signal(SIGPIPE, SIG_IGN);
vlog_set_levels(VLM_ANY_MODULE, VLF_CONSOLE, VLL_EMER);
vlog_set_levels(NULL, VLF_CONSOLE, VLL_EMER);
init_reboot_notifier();

argc -= optind;
Expand Down
32 changes: 5 additions & 27 deletions lib/automake.mk
Original file line number Diff line number Diff line change
Expand Up @@ -263,30 +263,8 @@ lib/coverage-counters.c: $(COVERAGE_FILES) lib/coverage-scan.pl
mv $@.tmp $@
EXTRA_DIST += lib/coverage-scan.pl


# Make sure that every vlog module listed in vlog-modules.def is
# actually used somewhere.
ALL_LOCAL += check-for-unused-vlog-modules
check-for-unused-vlog-modules:
if test -e $(srcdir)/.git && (git --version) >/dev/null 2>&1; then \
cd $(srcdir); \
decl_vlog=`sed -n 's/^VLOG_MODULE(\([_a-z0-9]\{1,\}\)).*$$/\1/p' \
lib/vlog-modules.def | \
LC_ALL=C sort -u | \
xargs echo`; \
used_vlog=`git grep VLOG_DEFINE_THIS_MODULE | \
sed -n 's/.*VLOG_DEFINE_THIS_MODULE(\([a-z_0-9]\{1,\}\)).*/\1/p' | \
LC_ALL=C sort -u | \
xargs echo`; \
rc=0; \
for decl in $$decl_vlog; do \
case " $$used_vlog " in \
*" $$decl "*) ;; \
*) echo "vlog module $$decl is declared in lib/vlog-modules.def \
but not used by any source file"; \
rc=1 ;; \
esac \
done; \
exit $$rc; \
fi
.PHONY: check-for-unused-vlog-modules
ALL_LOCAL += check-vlog-modules
check-vlog-modules:
cd $(srcdir) && build-aux/check-vlog-modules
.PHONY: check-vlog-modules
EXTRA_DIST += build-aux/check-vlog-modules
2 changes: 1 addition & 1 deletion lib/stream.c
Original file line number Diff line number Diff line change
Expand Up @@ -769,7 +769,7 @@ stream_content_type_to_string(enum stream_content_type type)
void
stream_report_content(const void *data, size_t size,
enum stream_content_type expected_type,
enum vlog_module module, const char *stream_name)
struct vlog_module *module, const char *stream_name)
{
static struct vlog_rate_limit rl = VLOG_RATE_LIMIT_INIT(5, 5);
enum stream_content_type actual_type;
Expand Down
2 changes: 1 addition & 1 deletion lib/stream.h
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,6 @@ enum stream_content_type {
};

void stream_report_content(const void *, size_t, enum stream_content_type,
enum vlog_module, const char *stream_name);
struct vlog_module *, const char *stream_name);

#endif /* stream.h */
Loading

0 comments on commit 480ce8a

Please sign in to comment.