Linux-perf-users Archive mirror
 help / color / mirror / Atom feed
* [PATCH] perf dwarf-aux: Fix build with HAVE_DWARF_CFI_SUPPORT
@ 2024-05-08 14:14 James Clark
  2024-05-08 21:04 ` Ian Rogers
  2024-05-09  1:11 ` Masami Hiramatsu
  0 siblings, 2 replies; 5+ messages in thread
From: James Clark @ 2024-05-08 14:14 UTC (permalink / raw
  To: linux-perf-users
  Cc: leo.yan, James Clark, Peter Zijlstra, Ingo Molnar,
	Arnaldo Carvalho de Melo, Namhyung Kim, Mark Rutland,
	Alexander Shishkin, Jiri Olsa, Ian Rogers, Adrian Hunter,
	Liang, Kan, Masami Hiramatsu, linux-kernel

check_allowed_ops() is used from both HAVE_DWARF_GETLOCATIONS_SUPPORT
and HAVE_DWARF_CFI_SUPPORT sections, so move it into the right place so
that it's available when either are defined. This shows up when doing
a static cross compile for arm64:

  $ make ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu- LDFLAGS="-static" \
    EXTRA_PERFLIBS="-lexpat"

  util/dwarf-aux.c:1723:6: error: implicit declaration of function 'check_allowed_ops'

Fixes: 55442cc2f22d ("perf dwarf-aux: Check allowed DWARF Ops")
Signed-off-by: James Clark <james.clark@arm.com>
---
 tools/perf/util/dwarf-aux.c | 56 ++++++++++++++++++-------------------
 1 file changed, 28 insertions(+), 28 deletions(-)

diff --git a/tools/perf/util/dwarf-aux.c b/tools/perf/util/dwarf-aux.c
index c0a492e65388..c9584563cd56 100644
--- a/tools/perf/util/dwarf-aux.c
+++ b/tools/perf/util/dwarf-aux.c
@@ -1215,6 +1215,34 @@ static int offset_from_dwarf_op(Dwarf_Op *op)
 	}
 	return -1;
 }
+
+static bool check_allowed_ops(Dwarf_Op *ops, size_t nops)
+{
+	/* The first op is checked separately */
+	ops++;
+	nops--;
+
+	/*
+	 * It needs to make sure if the location expression matches to the given
+	 * register and offset exactly.  Thus it rejects any complex expressions
+	 * and only allows a few of selected operators that doesn't change the
+	 * location.
+	 */
+	while (nops) {
+		switch (ops->atom) {
+		case DW_OP_stack_value:
+		case DW_OP_deref_size:
+		case DW_OP_deref:
+		case DW_OP_piece:
+			break;
+		default:
+			return false;
+		}
+		ops++;
+		nops--;
+	}
+	return true;
+}
 #endif /* HAVE_DWARF_GETLOCATIONS_SUPPORT || HAVE_DWARF_CFI_SUPPORT */
 
 #ifdef HAVE_DWARF_GETLOCATIONS_SUPPORT
@@ -1395,34 +1423,6 @@ static bool match_var_offset(Dwarf_Die *die_mem, struct find_var_data *data,
 	return true;
 }
 
-static bool check_allowed_ops(Dwarf_Op *ops, size_t nops)
-{
-	/* The first op is checked separately */
-	ops++;
-	nops--;
-
-	/*
-	 * It needs to make sure if the location expression matches to the given
-	 * register and offset exactly.  Thus it rejects any complex expressions
-	 * and only allows a few of selected operators that doesn't change the
-	 * location.
-	 */
-	while (nops) {
-		switch (ops->atom) {
-		case DW_OP_stack_value:
-		case DW_OP_deref_size:
-		case DW_OP_deref:
-		case DW_OP_piece:
-			break;
-		default:
-			return false;
-		}
-		ops++;
-		nops--;
-	}
-	return true;
-}
-
 /* Only checks direct child DIEs in the given scope. */
 static int __die_find_var_reg_cb(Dwarf_Die *die_mem, void *arg)
 {
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH] perf dwarf-aux: Fix build with HAVE_DWARF_CFI_SUPPORT
  2024-05-08 14:14 [PATCH] perf dwarf-aux: Fix build with HAVE_DWARF_CFI_SUPPORT James Clark
@ 2024-05-08 21:04 ` Ian Rogers
  2024-05-08 21:10   ` Namhyung Kim
  2024-05-09  1:11 ` Masami Hiramatsu
  1 sibling, 1 reply; 5+ messages in thread
From: Ian Rogers @ 2024-05-08 21:04 UTC (permalink / raw
  To: James Clark
  Cc: linux-perf-users, leo.yan, Peter Zijlstra, Ingo Molnar,
	Arnaldo Carvalho de Melo, Namhyung Kim, Mark Rutland,
	Alexander Shishkin, Jiri Olsa, Adrian Hunter, Liang, Kan,
	Masami Hiramatsu, linux-kernel

On Wed, May 8, 2024 at 7:15 AM James Clark <james.clark@arm.com> wrote:
>
> check_allowed_ops() is used from both HAVE_DWARF_GETLOCATIONS_SUPPORT
> and HAVE_DWARF_CFI_SUPPORT sections, so move it into the right place so
> that it's available when either are defined. This shows up when doing
> a static cross compile for arm64:
>
>   $ make ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu- LDFLAGS="-static" \
>     EXTRA_PERFLIBS="-lexpat"
>
>   util/dwarf-aux.c:1723:6: error: implicit declaration of function 'check_allowed_ops'
>
> Fixes: 55442cc2f22d ("perf dwarf-aux: Check allowed DWARF Ops")
> Signed-off-by: James Clark <james.clark@arm.com>

Reviewed-by: Ian Rogers <irogers@google.com>
(eye-balled to see the #if problem exists and this is the correct fix)

Thanks,
Ian

> ---
>  tools/perf/util/dwarf-aux.c | 56 ++++++++++++++++++-------------------
>  1 file changed, 28 insertions(+), 28 deletions(-)
>
> diff --git a/tools/perf/util/dwarf-aux.c b/tools/perf/util/dwarf-aux.c
> index c0a492e65388..c9584563cd56 100644
> --- a/tools/perf/util/dwarf-aux.c
> +++ b/tools/perf/util/dwarf-aux.c
> @@ -1215,6 +1215,34 @@ static int offset_from_dwarf_op(Dwarf_Op *op)
>         }
>         return -1;
>  }
> +
> +static bool check_allowed_ops(Dwarf_Op *ops, size_t nops)
> +{
> +       /* The first op is checked separately */
> +       ops++;
> +       nops--;
> +
> +       /*
> +        * It needs to make sure if the location expression matches to the given
> +        * register and offset exactly.  Thus it rejects any complex expressions
> +        * and only allows a few of selected operators that doesn't change the
> +        * location.
> +        */
> +       while (nops) {
> +               switch (ops->atom) {
> +               case DW_OP_stack_value:
> +               case DW_OP_deref_size:
> +               case DW_OP_deref:
> +               case DW_OP_piece:
> +                       break;
> +               default:
> +                       return false;
> +               }
> +               ops++;
> +               nops--;
> +       }
> +       return true;
> +}
>  #endif /* HAVE_DWARF_GETLOCATIONS_SUPPORT || HAVE_DWARF_CFI_SUPPORT */
>
>  #ifdef HAVE_DWARF_GETLOCATIONS_SUPPORT
> @@ -1395,34 +1423,6 @@ static bool match_var_offset(Dwarf_Die *die_mem, struct find_var_data *data,
>         return true;
>  }
>
> -static bool check_allowed_ops(Dwarf_Op *ops, size_t nops)
> -{
> -       /* The first op is checked separately */
> -       ops++;
> -       nops--;
> -
> -       /*
> -        * It needs to make sure if the location expression matches to the given
> -        * register and offset exactly.  Thus it rejects any complex expressions
> -        * and only allows a few of selected operators that doesn't change the
> -        * location.
> -        */
> -       while (nops) {
> -               switch (ops->atom) {
> -               case DW_OP_stack_value:
> -               case DW_OP_deref_size:
> -               case DW_OP_deref:
> -               case DW_OP_piece:
> -                       break;
> -               default:
> -                       return false;
> -               }
> -               ops++;
> -               nops--;
> -       }
> -       return true;
> -}
> -
>  /* Only checks direct child DIEs in the given scope. */
>  static int __die_find_var_reg_cb(Dwarf_Die *die_mem, void *arg)
>  {
> --
> 2.34.1
>

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] perf dwarf-aux: Fix build with HAVE_DWARF_CFI_SUPPORT
  2024-05-08 21:04 ` Ian Rogers
@ 2024-05-08 21:10   ` Namhyung Kim
  0 siblings, 0 replies; 5+ messages in thread
From: Namhyung Kim @ 2024-05-08 21:10 UTC (permalink / raw
  To: Ian Rogers
  Cc: James Clark, linux-perf-users, leo.yan, Peter Zijlstra,
	Ingo Molnar, Arnaldo Carvalho de Melo, Mark Rutland,
	Alexander Shishkin, Jiri Olsa, Adrian Hunter, Liang, Kan,
	Masami Hiramatsu, linux-kernel

On Wed, May 8, 2024 at 2:05 PM Ian Rogers <irogers@google.com> wrote:
>
> On Wed, May 8, 2024 at 7:15 AM James Clark <james.clark@arm.com> wrote:
> >
> > check_allowed_ops() is used from both HAVE_DWARF_GETLOCATIONS_SUPPORT
> > and HAVE_DWARF_CFI_SUPPORT sections, so move it into the right place so
> > that it's available when either are defined. This shows up when doing
> > a static cross compile for arm64:
> >
> >   $ make ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu- LDFLAGS="-static" \
> >     EXTRA_PERFLIBS="-lexpat"
> >
> >   util/dwarf-aux.c:1723:6: error: implicit declaration of function 'check_allowed_ops'
> >
> > Fixes: 55442cc2f22d ("perf dwarf-aux: Check allowed DWARF Ops")
> > Signed-off-by: James Clark <james.clark@arm.com>
>
> Reviewed-by: Ian Rogers <irogers@google.com>
> (eye-balled to see the #if problem exists and this is the correct fix)

Acked-by: Namhyung Kim <namhyung@kernel.org>

Thanks,
Namhyung

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] perf dwarf-aux: Fix build with HAVE_DWARF_CFI_SUPPORT
  2024-05-08 14:14 [PATCH] perf dwarf-aux: Fix build with HAVE_DWARF_CFI_SUPPORT James Clark
  2024-05-08 21:04 ` Ian Rogers
@ 2024-05-09  1:11 ` Masami Hiramatsu
  2024-05-09 21:21   ` Arnaldo Carvalho de Melo
  1 sibling, 1 reply; 5+ messages in thread
From: Masami Hiramatsu @ 2024-05-09  1:11 UTC (permalink / raw
  To: James Clark
  Cc: linux-perf-users, leo.yan, Peter Zijlstra, Ingo Molnar,
	Arnaldo Carvalho de Melo, Namhyung Kim, Mark Rutland,
	Alexander Shishkin, Jiri Olsa, Ian Rogers, Adrian Hunter,
	Liang, Kan, Masami Hiramatsu, linux-kernel

On Wed,  8 May 2024 15:14:57 +0100
James Clark <james.clark@arm.com> wrote:

> check_allowed_ops() is used from both HAVE_DWARF_GETLOCATIONS_SUPPORT
> and HAVE_DWARF_CFI_SUPPORT sections, so move it into the right place so
> that it's available when either are defined. This shows up when doing
> a static cross compile for arm64:
> 
>   $ make ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu- LDFLAGS="-static" \
>     EXTRA_PERFLIBS="-lexpat"
> 
>   util/dwarf-aux.c:1723:6: error: implicit declaration of function 'check_allowed_ops'
> 

Looks good to me.

Acked-by: Masami Hiramatsu (Google) <mhiramat@kernel.org>

Thanks!

> Fixes: 55442cc2f22d ("perf dwarf-aux: Check allowed DWARF Ops")
> Signed-off-by: James Clark <james.clark@arm.com>
> ---
>  tools/perf/util/dwarf-aux.c | 56 ++++++++++++++++++-------------------
>  1 file changed, 28 insertions(+), 28 deletions(-)
> 
> diff --git a/tools/perf/util/dwarf-aux.c b/tools/perf/util/dwarf-aux.c
> index c0a492e65388..c9584563cd56 100644
> --- a/tools/perf/util/dwarf-aux.c
> +++ b/tools/perf/util/dwarf-aux.c
> @@ -1215,6 +1215,34 @@ static int offset_from_dwarf_op(Dwarf_Op *op)
>  	}
>  	return -1;
>  }
> +
> +static bool check_allowed_ops(Dwarf_Op *ops, size_t nops)
> +{
> +	/* The first op is checked separately */
> +	ops++;
> +	nops--;
> +
> +	/*
> +	 * It needs to make sure if the location expression matches to the given
> +	 * register and offset exactly.  Thus it rejects any complex expressions
> +	 * and only allows a few of selected operators that doesn't change the
> +	 * location.
> +	 */
> +	while (nops) {
> +		switch (ops->atom) {
> +		case DW_OP_stack_value:
> +		case DW_OP_deref_size:
> +		case DW_OP_deref:
> +		case DW_OP_piece:
> +			break;
> +		default:
> +			return false;
> +		}
> +		ops++;
> +		nops--;
> +	}
> +	return true;
> +}
>  #endif /* HAVE_DWARF_GETLOCATIONS_SUPPORT || HAVE_DWARF_CFI_SUPPORT */
>  
>  #ifdef HAVE_DWARF_GETLOCATIONS_SUPPORT
> @@ -1395,34 +1423,6 @@ static bool match_var_offset(Dwarf_Die *die_mem, struct find_var_data *data,
>  	return true;
>  }
>  
> -static bool check_allowed_ops(Dwarf_Op *ops, size_t nops)
> -{
> -	/* The first op is checked separately */
> -	ops++;
> -	nops--;
> -
> -	/*
> -	 * It needs to make sure if the location expression matches to the given
> -	 * register and offset exactly.  Thus it rejects any complex expressions
> -	 * and only allows a few of selected operators that doesn't change the
> -	 * location.
> -	 */
> -	while (nops) {
> -		switch (ops->atom) {
> -		case DW_OP_stack_value:
> -		case DW_OP_deref_size:
> -		case DW_OP_deref:
> -		case DW_OP_piece:
> -			break;
> -		default:
> -			return false;
> -		}
> -		ops++;
> -		nops--;
> -	}
> -	return true;
> -}
> -
>  /* Only checks direct child DIEs in the given scope. */
>  static int __die_find_var_reg_cb(Dwarf_Die *die_mem, void *arg)
>  {
> -- 
> 2.34.1
> 
> 


-- 
Masami Hiramatsu (Google) <mhiramat@kernel.org>

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] perf dwarf-aux: Fix build with HAVE_DWARF_CFI_SUPPORT
  2024-05-09  1:11 ` Masami Hiramatsu
@ 2024-05-09 21:21   ` Arnaldo Carvalho de Melo
  0 siblings, 0 replies; 5+ messages in thread
From: Arnaldo Carvalho de Melo @ 2024-05-09 21:21 UTC (permalink / raw
  To: Masami Hiramatsu
  Cc: James Clark, linux-perf-users, leo.yan, Peter Zijlstra,
	Ingo Molnar, Namhyung Kim, Mark Rutland, Alexander Shishkin,
	Jiri Olsa, Ian Rogers, Adrian Hunter, Liang, Kan, linux-kernel

On Thu, May 09, 2024 at 10:11:36AM +0900, Masami Hiramatsu wrote:
> On Wed,  8 May 2024 15:14:57 +0100
> James Clark <james.clark@arm.com> wrote:
> 
> > check_allowed_ops() is used from both HAVE_DWARF_GETLOCATIONS_SUPPORT
> > and HAVE_DWARF_CFI_SUPPORT sections, so move it into the right place so
> > that it's available when either are defined. This shows up when doing
> > a static cross compile for arm64:
> > 
> >   $ make ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu- LDFLAGS="-static" \
> >     EXTRA_PERFLIBS="-lexpat"
> > 
> >   util/dwarf-aux.c:1723:6: error: implicit declaration of function 'check_allowed_ops'
> > 
> 
> Looks good to me.
> 
> Acked-by: Masami Hiramatsu (Google) <mhiramat@kernel.org>
> 
> Thanks!

Thanks, applied to perf-tools-next,

- Arnaldo
 
> > Fixes: 55442cc2f22d ("perf dwarf-aux: Check allowed DWARF Ops")
> > Signed-off-by: James Clark <james.clark@arm.com>
> > ---
> >  tools/perf/util/dwarf-aux.c | 56 ++++++++++++++++++-------------------
> >  1 file changed, 28 insertions(+), 28 deletions(-)
> > 
> > diff --git a/tools/perf/util/dwarf-aux.c b/tools/perf/util/dwarf-aux.c
> > index c0a492e65388..c9584563cd56 100644
> > --- a/tools/perf/util/dwarf-aux.c
> > +++ b/tools/perf/util/dwarf-aux.c
> > @@ -1215,6 +1215,34 @@ static int offset_from_dwarf_op(Dwarf_Op *op)
> >  	}
> >  	return -1;
> >  }
> > +
> > +static bool check_allowed_ops(Dwarf_Op *ops, size_t nops)
> > +{
> > +	/* The first op is checked separately */
> > +	ops++;
> > +	nops--;
> > +
> > +	/*
> > +	 * It needs to make sure if the location expression matches to the given
> > +	 * register and offset exactly.  Thus it rejects any complex expressions
> > +	 * and only allows a few of selected operators that doesn't change the
> > +	 * location.
> > +	 */
> > +	while (nops) {
> > +		switch (ops->atom) {
> > +		case DW_OP_stack_value:
> > +		case DW_OP_deref_size:
> > +		case DW_OP_deref:
> > +		case DW_OP_piece:
> > +			break;
> > +		default:
> > +			return false;
> > +		}
> > +		ops++;
> > +		nops--;
> > +	}
> > +	return true;
> > +}
> >  #endif /* HAVE_DWARF_GETLOCATIONS_SUPPORT || HAVE_DWARF_CFI_SUPPORT */
> >  
> >  #ifdef HAVE_DWARF_GETLOCATIONS_SUPPORT
> > @@ -1395,34 +1423,6 @@ static bool match_var_offset(Dwarf_Die *die_mem, struct find_var_data *data,
> >  	return true;
> >  }
> >  
> > -static bool check_allowed_ops(Dwarf_Op *ops, size_t nops)
> > -{
> > -	/* The first op is checked separately */
> > -	ops++;
> > -	nops--;
> > -
> > -	/*
> > -	 * It needs to make sure if the location expression matches to the given
> > -	 * register and offset exactly.  Thus it rejects any complex expressions
> > -	 * and only allows a few of selected operators that doesn't change the
> > -	 * location.
> > -	 */
> > -	while (nops) {
> > -		switch (ops->atom) {
> > -		case DW_OP_stack_value:
> > -		case DW_OP_deref_size:
> > -		case DW_OP_deref:
> > -		case DW_OP_piece:
> > -			break;
> > -		default:
> > -			return false;
> > -		}
> > -		ops++;
> > -		nops--;
> > -	}
> > -	return true;
> > -}
> > -
> >  /* Only checks direct child DIEs in the given scope. */
> >  static int __die_find_var_reg_cb(Dwarf_Die *die_mem, void *arg)
> >  {
> > -- 
> > 2.34.1
> > 
> > 
> 
> 
> -- 
> Masami Hiramatsu (Google) <mhiramat@kernel.org>

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2024-05-09 21:21 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-05-08 14:14 [PATCH] perf dwarf-aux: Fix build with HAVE_DWARF_CFI_SUPPORT James Clark
2024-05-08 21:04 ` Ian Rogers
2024-05-08 21:10   ` Namhyung Kim
2024-05-09  1:11 ` Masami Hiramatsu
2024-05-09 21:21   ` Arnaldo Carvalho de Melo

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).