From ed8a89fca03e264ad772f738bc966bbbe0d31b4d Mon Sep 17 00:00:00 2001
From: Tristan Partin <tristan@neon.tech>
Date: Tue, 12 Dec 2023 13:43:32 -0600
Subject: [PATCH v1 5/6] Add Mac support to find_typedef

This was previously unsupported on Mac.
---
 src/tools/find_typedef | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/src/tools/find_typedef b/src/tools/find_typedef
index 8adbe9ab94..ce82897c3f 100755
--- a/src/tools/find_typedef
+++ b/src/tools/find_typedef
@@ -45,6 +45,17 @@ do
 		readelf -w "$DIR"/* |
 		grep -E -A3 '\(DW_TAG_typedef\)' |
 		awk ' $1 == "DW_AT_name" {print $NF}'
+	elif [ "$system" = Darwin ]
+	then
+		# Creates *.dwarf files that we will remove later
+		dsymutil --flat "$DIR"/*
+
+		# Apple's dwarfdump, wraps types: ("example")
+		dwarfdump "$DIR"/*.dwarf |
+		grep -F -A3 'DW_TAG_typedef' |
+		awk ' $1 == "DW_AT_name" {print substr($NF, 3, length($NF) - 4)}'
+
+		rm -f "$DIR"/*.dwarf
 	fi
 done |
 grep -v ' ' | # some typedefs have spaces, remove them
-- 
Tristan Partin
Neon (https://neon.tech)

