Skip to contentSkip to conversation

perf dwarf-aux: Fix build with HAVE_DWARF_CFI_SUPPORT

PATCH Applied James Clark 5 participants 5 messages May 8, 2024 – May 9, 2024 perf events

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 perf dwarf-aux: Fix build with HAVE_DWARF_CFI_SUPPORT

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")
---
 tools/perf/util/dwarf-aux.c | 56 ++++++++++++++++++-------------------
 1 file changed, 28 insertions(+), 28 deletions(-)
tools/perf/util/dwarf-aux.c +28 -28
index c0a492e65388..c9584563cd56 100644
@@ -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)
 {
Signature · 1 line
2.34.1
reviewer Reviewed-by on v1 1/1
#1 lore raw
Quoted 6 lines · James Clark

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:

Quoted 7 lines
  $ 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")

(eye-balled to see the #if problem exists and this is the correct fix)

Thanks,
Ian

Quoted 81 lines
---
 tools/perf/util/dwarf-aux.c | 56 ++++++++++++++++++-------------------
 1 file changed, 28 insertions(+), 28 deletions(-)
tools/perf/util/dwarf-aux.c +28 -29
index c0a492e65388..c9584563cd56 100644
@@ -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

maintainer Acked-by
#2 lore raw
Quoted 11 lines · Ian Rogers
Quoted 9 lines · James Clark

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"
Quoted 7 lines
Quoted 4 lines

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

Fixes 55442cc2f22d ("perf dwarf-aux: Check allowed DWARF Ops")

(eye-balled to see the #if problem exists and this is the correct fix)

Thanks,
Namhyung

Acked-by on v1 1/1
#3 lore raw
In reply to James Clark
Quoted 10 lines · On Wed, 8 May 2024 15:14:57 +0100 James Clark <[email protected]> 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.

Thanks!

Quoted 84 lines
Fixes 55442cc2f22d ("perf dwarf-aux: Check allowed DWARF Ops")
---
 tools/perf/util/dwarf-aux.c | 56 ++++++++++++++++++-------------------
 1 file changed, 28 insertions(+), 28 deletions(-)
tools/perf/util/dwarf-aux.c +28 -28
index c0a492e65388..c9584563cd56 100644
@@ -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)
 {
Signature · 1 line
2.34.1
Signature · 1 line
Masami Hiramatsu (Google) <[email protected]>
maintainer Applied
#4 lore raw
Quoted 11 lines · Masami Hiramatsu
Quoted 8 lines · On Wed, 8 May 2024 15:14:57 +0100 James Clark <[email protected]> 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"
Quoted 8 lines
Quoted 2 lines

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

Looks good to me.

Thanks!

Thanks, applied to perf-tools-next,

- Arnaldo

Quoted 88 lines
Quoted 84 lines
Fixes 55442cc2f22d ("perf dwarf-aux: Check allowed DWARF Ops")
---
 tools/perf/util/dwarf-aux.c | 56 ++++++++++++++++++-------------------
 1 file changed, 28 insertions(+), 28 deletions(-)
tools/perf/util/dwarf-aux.c +28 -28
index c0a492e65388..c9584563cd56 100644
@@ -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)
 {
Signature · 1 line
2.34.1
Signature · 1 line
Masami Hiramatsu (Google) <[email protected]>