[DTrace-devel] [PATCH 3/6] build: add gdb and valgrind support to the run-dtrace wrapper

Kris Van Hees kris.van.hees at oracle.com
Fri May 12 14:07:40 UTC 2023


On Wed, Apr 19, 2023 at 04:41:28PM +0100, Nick Alcock via DTrace-devel wrote:
> 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 at oracle.com>

Reviewed-by: Kris Van Hees <kris.van.hees at oracle.com>

... with one change...  THe run-dtrace script should now use

	#!/usr/bin/bash

instead of

	#!/bin/sh

because e.g. on Debian the default /bin/dh is *not* bash and you are now
using a bash construct.

> ---
>  cmd/Build | 12 +++++++++---
>  1 file changed, 9 insertions(+), 3 deletions(-)
> 
> diff --git a/cmd/Build b/cmd/Build
> index 644a3449d2ffc..b9c582a25ea8a 100644
> --- a/cmd/Build
> +++ b/cmd/Build
> @@ -31,12 +31,18 @@ $(objdir)/run-dtrace: $(DTRACE)
>  # 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\
> +    if [[ -n \$$DTRACE_GDB ]]; then\n\
> +        exec gdb --args /usr/sbin/dtrace \"\$$@\"\n\
> +    elif [[ -n \$$DTRACE_VALGRIND ]]; then\n\
> +        exec valgrind /usr/sbin/dtrace \"\$$@\"\n\
> +    else\n\
> +        exec $(objdir)/dtrace \"\$$@\"\n\
> +    fi\n\
>  else\n\
> -    exec /usr/sbin/dtrace \"\$$@\"\n\
> +        exec /usr/sbin/dtrace \"\$$@\"\n\
>  fi\n"
>  	chmod a+x $(objdir)/run-dtrace
>  
> -- 
> 2.39.1.268.g9de2f9a303
> 
> 
> _______________________________________________
> DTrace-devel mailing list
> DTrace-devel at oss.oracle.com
> https://oss.oracle.com/mailman/listinfo/dtrace-devel



More information about the DTrace-devel mailing list