Skip to content

Commit

Permalink
build: add gdb and valgrind support to the run-dtrace wrapper
Browse files Browse the repository at this point in the history
Now, rather than having to mess around setting SYSLIBDIR and
LD_LIBRARY_PATH yourself to debug a just-built dtrace, you can
just run DTRACE_GDB=t build/run-dtrace or
DTRACE_VALGRIND=t build/run-dtrace

GDB is run with --args. Valgrind is run with no args other that the
just-built dtrace's for now.

Signed-off-by: Nick Alcock <nick.alcock@oracle.com>
Reviewed-by: Kris Van Hees <kris.van.hees@oracle.com>
  • Loading branch information
nickalcock authored and kvanhees committed May 24, 2023
1 parent 0b7a061 commit 5582d14
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions cmd/Build
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Oracle Linux DTrace.
# Copyright (c) 2011, 2022, Oracle and/or its affiliates. All rights reserved.
# Copyright (c) 2011, 2023, Oracle and/or its affiliates. All rights reserved.
# Licensed under the Universal Permissive License v 1.0 as shown at
# http://oss.oracle.com/licenses/upl.

Expand Down Expand Up @@ -27,16 +27,24 @@ bpf_dump_LIBS = -lelf

$(objdir)/run-dtrace: $(DTRACE)
printf > $@ "\
#!/bin/sh\n\
#!/bin/bash\n\
# run-dtrace -- A wrapper to run DTrace out of the build tree, or from /usr/sbin\n\
# if this is a check-installed run\n\
\n\
if [ -z \$$_DTRACE_CHECK_INSTALLED ]; then\n\
if [[ -z \$$_DTRACE_CHECK_INSTALLED ]]; then\n\
export DTRACE_OPT_SYSLIBDIR=$(objdir)/dlibs\n\
export LD_LIBRARY_PATH=$(objdir)\n\
exec $(objdir)/dtrace \"\$$@\"\n\
dtrace_cmd=$(objdir)/dtrace\n\
else\n\
exec /usr/sbin/dtrace \"\$$@\"\n\
dtrace_cmd=/usr/sbin/dtrace\n\
fi\n\
\n\
if [[ -n \$$DTRACE_GDB ]]; then\n\
exec gdb --args \$$dtrace_cmd \"\$$@\"\n\
elif [[ -n \$$DTRACE_VALGRIND ]]; then\n\
exec valgrind \$$dtrace_cmd \"\$$@\"\n\
else\n\
exec \$$dtrace_cmd \"\$$@\"\n\
fi\n"
chmod a+x $(objdir)/run-dtrace

Expand Down

0 comments on commit 5582d14

Please sign in to comment.