Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Tankut Baris Aktemur <tankut.baris.aktemur@intel.com>
To: gdb-patches@sourceware.org, Markus Metzger <markus.t.metzger@intel.com>
Subject: [PATCH v3 08/44] gdb, intelgt: add disassemble feature for the Intel GT architecture.
Date: Fri,  1 Aug 2025 11:37:10 +0200	[thread overview]
Message-ID: <20250801-upstream-intelgt-mvp-v3-8-59ce0f87075b@intel.com> (raw)
In-Reply-To: <20250801-upstream-intelgt-mvp-v3-0-59ce0f87075b@intel.com>

From: Albertano Caruso <albertano.caruso@intel.com>

Disassembly of Intel GT programs is done via the Intel Gen Assembler
library.  Add this library as an optional dependency.  If the library
is not found, disassembly is disabled.
---
 gdb/Makefile.in        |   6 +-
 gdb/README             |   8 +
 gdb/config.in          |   3 +
 gdb/configure          | 559 ++++++++++++++++++++++++++++++++++++++++++++++++-
 gdb/configure.ac       |  52 +++++
 gdb/disasm-selftests.c |  12 ++
 gdb/doc/gdb.texinfo    |   5 +
 gdb/intelgt-tdep.c     | 113 +++++++++-
 gdb/top.c              |  10 +
 9 files changed, 764 insertions(+), 4 deletions(-)

diff --git a/gdb/Makefile.in b/gdb/Makefile.in
index a6f32b5c02877592ff3072a431b7e229e031ebde..89e613e705963261906fb3bdaa5a3400b2e618e6 100644
--- a/gdb/Makefile.in
+++ b/gdb/Makefile.in
@@ -250,6 +250,10 @@ CODESIGN_CERT = @CODESIGN_CERT@
 # Flags to pass to gdb when invoked with "make run".
 GDBFLAGS =
 
+# Where is libiga (i.e.  the disassembler lib for the intelgt target)?
+# This will be empty if libiga was not available.
+LIBIGA = @LIBIGA64@
+
 # Helper code from gnulib.
 GNULIB_PARENT_DIR = ..
 include $(GNULIB_PARENT_DIR)/gnulib/Makefile.gnulib.inc
@@ -684,7 +688,7 @@ CLIBS = $(SIM) $(READLINE) $(OPCODES) $(LIBCTF) $(BFD) $(ZLIB) $(ZSTD_LIBS) \
 	$(LIBEXPAT) $(LIBLZMA) $(LIBBABELTRACE) $(LIBIPT) \
 	$(WIN32LIBS) $(LIBGNU) $(LIBGNU_EXTRA_LIBS) $(LIBICONV) \
 	$(GMPLIBS) $(SRCHIGH_LIBS) $(LIBXXHASH) $(PTHREAD_LIBS) \
-	$(DEBUGINFOD_LIBS) $(LIBBABELTRACE_LIB)
+	$(DEBUGINFOD_LIBS) $(LIBBABELTRACE_LIB) $(LIBIGA)
 CDEPS = $(NAT_CDEPS) $(SIM) $(BFD) $(READLINE_DEPS) $(CTF_DEPS) \
 	$(OPCODES) $(INTL_DEPS) $(LIBIBERTY) $(CONFIG_DEPS) $(LIBGNU) \
 	$(LIBSUPPORT)
diff --git a/gdb/README b/gdb/README
index eca4181c751eb3ff74dae505e98ed2826ebf2f27..9f1192f591967e81a7dc155f5a4cec1e8a89cb9f 100644
--- a/gdb/README
+++ b/gdb/README
@@ -500,6 +500,14 @@ more obscure GDB `configure' options are not listed here.
      the overall build.  See the GDB manual instructions on how to do
      this.
 
+`--with-libiga64`
+     Build GDB with Intel Gen Assembler (IGA) library.  If requested and
+     the IntelGT target is enabled but the library cannot be found,
+     configure gives an error.  If not requested explicitly and cannot
+     be found, disassembly feature for the IntelGT target will not be
+     available in GDB.  IGA is available as part of the Intel Graphics
+     Compiler: `https://github.com/intel/intel-graphics-compiler`
+
 `--with-lzma'
      Build GDB with LZMA, a compression library.  (Done by default if
      liblzma is installed and found at configure time.)  LZMA is used
diff --git a/gdb/config.in b/gdb/config.in
index 149aeaf979bafe4eb8248d9ba0bdefe13a761de8..103fcf8e8bc044e4c72ae3046a0d84491f78845f 100644
--- a/gdb/config.in
+++ b/gdb/config.in
@@ -283,6 +283,9 @@
 /* Define to 1 if you have the `libiconvlist' function. */
 #undef HAVE_LIBICONVLIST
 
+/* Define if you have the iga64 library. */
+#undef HAVE_LIBIGA64
+
 /* Define if you have the ipt library. */
 #undef HAVE_LIBIPT
 
diff --git a/gdb/configure b/gdb/configure
index 8fc3b04efbfc2323c1bc9690a9ec7b10442ed5b1..b4120f4eefbe527c1b8d2ac0978327e2bb9a6851 100755
--- a/gdb/configure
+++ b/gdb/configure
@@ -714,6 +714,9 @@ SYSTEM_GDBINIT
 TARGET_SYSTEM_ROOT
 CONFIG_LDFLAGS
 RDYNAMIC
+LTLIBIGA64
+LIBIGA64
+HAVE_LIBIGA64
 SRCHIGH_CFLAGS
 SRCHIGH_LIBS
 HAVE_GUILE_FALSE
@@ -957,6 +960,9 @@ with_python_libdir
 with_guile
 enable_gdb_compile
 enable_source_highlight
+with_libiga64
+with_libiga64_prefix
+with_libiga64_type
 with_sysroot
 with_system_gdbinit
 with_system_gdbinit_dir
@@ -1736,6 +1742,10 @@ Optional Packages:
                           search for python's libraries in DIR
   --with-guile[=GUILE]    include guile support
                           (auto/yes/no/<guile-version>/<pkg-config-program>)
+  --with-libiga64         include IntelGT disassembly support (auto/yes/no)
+  --with-libiga64-prefix[=DIR]  search for libiga64 in DIR/include and DIR/lib
+  --without-libiga64-prefix     don't search for libiga64 in includedir and libdir
+  --with-libiga64-type=TYPE     type of library to search for (auto/static/shared)
   --with-sysroot[=DIR]    search for usr/lib et al within DIR
   --with-system-gdbinit=PATH
                           automatically load a system-wide gdbinit file
@@ -11507,7 +11517,7 @@ else
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<_LT_EOF
-#line 11510 "configure"
+#line 11520 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
@@ -11613,7 +11623,7 @@ else
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<_LT_EOF
-#line 11616 "configure"
+#line 11626 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
@@ -29146,6 +29156,551 @@ fi
 
 
 
+# Check for Intel(R) Graphics Technology assembler library
+intelgt_target=false
+
+for targ_alias in `echo $target_alias $enable_targets | sed 's/,/ /g'`
+do
+  if test "$targ_alias" = "all"; then
+    intelgt_target=true
+  else
+    case "$targ_alias" in
+      intelgt-*)
+        intelgt_target=true
+        ;;
+    esac
+  fi
+done
+
+case "${target}" in
+  intelgt-*)
+    intelgt_target=true
+    ;;
+esac
+
+if test "${intelgt_target}" != true; then
+  HAVE_LIBIGA64=no
+else
+
+# Check whether --with-libiga64 was given.
+if test "${with_libiga64+set}" = set; then :
+  withval=$with_libiga64;
+else
+  with_libiga64=auto
+fi
+
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether to use libiga64" >&5
+$as_echo_n "checking whether to use libiga64... " >&6; }
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $with_libiga64" >&5
+$as_echo "$with_libiga64" >&6; }
+
+  if test "${with_libiga64}" = no; then
+    { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: IntelGT disassembly support disabled; some features may be unavailable." >&5
+$as_echo "$as_me: WARNING: IntelGT disassembly support disabled; some features may be unavailable." >&2;}
+    HAVE_LIBIGA64=no
+  else
+    ac_ext=cpp
+ac_cpp='$CXXCPP $CPPFLAGS'
+ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_cxx_compiler_gnu
+
+
+
+
+
+
+
+
+
+    use_additional=yes
+
+  acl_save_prefix="$prefix"
+  prefix="$acl_final_prefix"
+  acl_save_exec_prefix="$exec_prefix"
+  exec_prefix="$acl_final_exec_prefix"
+
+    eval additional_includedir=\"$includedir\"
+    eval additional_libdir=\"$libdir\"
+
+  exec_prefix="$acl_save_exec_prefix"
+  prefix="$acl_save_prefix"
+
+
+# Check whether --with-libiga64-prefix was given.
+if test "${with_libiga64_prefix+set}" = set; then :
+  withval=$with_libiga64_prefix;
+    if test "X$withval" = "Xno"; then
+      use_additional=no
+    else
+      if test "X$withval" = "X"; then
+
+  acl_save_prefix="$prefix"
+  prefix="$acl_final_prefix"
+  acl_save_exec_prefix="$exec_prefix"
+  exec_prefix="$acl_final_exec_prefix"
+
+          eval additional_includedir=\"$includedir\"
+          eval additional_libdir=\"$libdir\"
+
+  exec_prefix="$acl_save_exec_prefix"
+  prefix="$acl_save_prefix"
+
+      else
+        additional_includedir="$withval/include"
+        additional_libdir="$withval/lib"
+      fi
+    fi
+
+fi
+
+
+# Check whether --with-libiga64-type was given.
+if test "${with_libiga64_type+set}" = set; then :
+  withval=$with_libiga64_type;  with_libiga64_type=$withval
+else
+   with_libiga64_type=auto
+fi
+
+  lib_type=`eval echo \$with_libiga64_type`
+
+      LIBIGA64=
+  LTLIBIGA64=
+  INCIGA64=
+  rpathdirs=
+  ltrpathdirs=
+  names_already_handled=
+  names_next_round='iga64 '
+  while test -n "$names_next_round"; do
+    names_this_round="$names_next_round"
+    names_next_round=
+    for name in $names_this_round; do
+      already_handled=
+      for n in $names_already_handled; do
+        if test "$n" = "$name"; then
+          already_handled=yes
+          break
+        fi
+      done
+      if test -z "$already_handled"; then
+        names_already_handled="$names_already_handled $name"
+                        uppername=`echo "$name" | sed -e 'y|abcdefghijklmnopqrstuvwxyz./-|ABCDEFGHIJKLMNOPQRSTUVWXYZ___|'`
+        eval value=\"\$HAVE_LIB$uppername\"
+        if test -n "$value"; then
+          if test "$value" = yes; then
+            eval value=\"\$LIB$uppername\"
+            test -z "$value" || LIBIGA64="${LIBIGA64}${LIBIGA64:+ }$value"
+            eval value=\"\$LTLIB$uppername\"
+            test -z "$value" || LTLIBIGA64="${LTLIBIGA64}${LTLIBIGA64:+ }$value"
+          else
+                                    :
+          fi
+        else
+                              found_dir=
+          found_la=
+          found_so=
+          found_a=
+          if test $use_additional = yes; then
+            if test -n "$shlibext" && test -f "$additional_libdir/lib$name.$shlibext" && test x$lib_type != xstatic; then
+              found_dir="$additional_libdir"
+              found_so="$additional_libdir/lib$name.$shlibext"
+              if test -f "$additional_libdir/lib$name.la"; then
+                found_la="$additional_libdir/lib$name.la"
+              fi
+            elif test x$lib_type != xshared; then
+              if test -f "$additional_libdir/lib$name.$libext"; then
+                found_dir="$additional_libdir"
+                found_a="$additional_libdir/lib$name.$libext"
+                if test -f "$additional_libdir/lib$name.la"; then
+                  found_la="$additional_libdir/lib$name.la"
+                fi
+              fi
+            fi
+          fi
+          if test "X$found_dir" = "X"; then
+            for x in $LDFLAGS $LTLIBIGA64; do
+
+  acl_save_prefix="$prefix"
+  prefix="$acl_final_prefix"
+  acl_save_exec_prefix="$exec_prefix"
+  exec_prefix="$acl_final_exec_prefix"
+  eval x=\"$x\"
+  exec_prefix="$acl_save_exec_prefix"
+  prefix="$acl_save_prefix"
+
+              case "$x" in
+                -L*)
+                  dir=`echo "X$x" | sed -e 's/^X-L//'`
+                  if test -n "$shlibext" && test -f "$dir/lib$name.$shlibext" && test x$lib_type != xstatic; then
+                    found_dir="$dir"
+                    found_so="$dir/lib$name.$shlibext"
+                    if test -f "$dir/lib$name.la"; then
+                      found_la="$dir/lib$name.la"
+                    fi
+                  elif test x$lib_type != xshared; then
+                    if test -f "$dir/lib$name.$libext"; then
+                      found_dir="$dir"
+                      found_a="$dir/lib$name.$libext"
+                      if test -f "$dir/lib$name.la"; then
+                        found_la="$dir/lib$name.la"
+                      fi
+                    fi
+                  fi
+                  ;;
+              esac
+              if test "X$found_dir" != "X"; then
+                break
+              fi
+            done
+          fi
+          if test "X$found_dir" != "X"; then
+                        LTLIBIGA64="${LTLIBIGA64}${LTLIBIGA64:+ }-L$found_dir -l$name"
+            if test "X$found_so" != "X"; then
+                                                        if test "$enable_rpath" = no || test "X$found_dir" = "X/usr/lib"; then
+                                LIBIGA64="${LIBIGA64}${LIBIGA64:+ }$found_so"
+              else
+                                                                                haveit=
+                for x in $ltrpathdirs; do
+                  if test "X$x" = "X$found_dir"; then
+                    haveit=yes
+                    break
+                  fi
+                done
+                if test -z "$haveit"; then
+                  ltrpathdirs="$ltrpathdirs $found_dir"
+                fi
+                                if test "$hardcode_direct" = yes; then
+                                                      LIBIGA64="${LIBIGA64}${LIBIGA64:+ }$found_so"
+                else
+                  if test -n "$hardcode_libdir_flag_spec" && test "$hardcode_minus_L" = no; then
+                                                            LIBIGA64="${LIBIGA64}${LIBIGA64:+ }$found_so"
+                                                            haveit=
+                    for x in $rpathdirs; do
+                      if test "X$x" = "X$found_dir"; then
+                        haveit=yes
+                        break
+                      fi
+                    done
+                    if test -z "$haveit"; then
+                      rpathdirs="$rpathdirs $found_dir"
+                    fi
+                  else
+                                                                                haveit=
+                    for x in $LDFLAGS $LIBIGA64; do
+
+  acl_save_prefix="$prefix"
+  prefix="$acl_final_prefix"
+  acl_save_exec_prefix="$exec_prefix"
+  exec_prefix="$acl_final_exec_prefix"
+  eval x=\"$x\"
+  exec_prefix="$acl_save_exec_prefix"
+  prefix="$acl_save_prefix"
+
+                      if test "X$x" = "X-L$found_dir"; then
+                        haveit=yes
+                        break
+                      fi
+                    done
+                    if test -z "$haveit"; then
+                      LIBIGA64="${LIBIGA64}${LIBIGA64:+ }-L$found_dir"
+                    fi
+                    if test "$hardcode_minus_L" != no; then
+                                                                                        LIBIGA64="${LIBIGA64}${LIBIGA64:+ }$found_so"
+                    else
+                                                                                                                                                                                LIBIGA64="${LIBIGA64}${LIBIGA64:+ }-l$name"
+                    fi
+                  fi
+                fi
+              fi
+            else
+              if test "X$found_a" != "X"; then
+                                LIBIGA64="${LIBIGA64}${LIBIGA64:+ }$found_a"
+              else
+                                                LIBIGA64="${LIBIGA64}${LIBIGA64:+ }-L$found_dir -l$name"
+              fi
+            fi
+                        additional_includedir=
+            case "$found_dir" in
+              */lib | */lib/)
+                basedir=`echo "X$found_dir" | sed -e 's,^X,,' -e 's,/lib/*$,,'`
+                additional_includedir="$basedir/include"
+                ;;
+            esac
+            if test "X$additional_includedir" != "X"; then
+                                                                                                                if test "X$additional_includedir" != "X/usr/include"; then
+                haveit=
+                if test "X$additional_includedir" = "X/usr/local/include"; then
+                  if test -n "$GCC"; then
+                    case $host_os in
+                      linux*) haveit=yes;;
+                    esac
+                  fi
+                fi
+                if test -z "$haveit"; then
+                  for x in $CPPFLAGS $INCIGA64; do
+
+  acl_save_prefix="$prefix"
+  prefix="$acl_final_prefix"
+  acl_save_exec_prefix="$exec_prefix"
+  exec_prefix="$acl_final_exec_prefix"
+  eval x=\"$x\"
+  exec_prefix="$acl_save_exec_prefix"
+  prefix="$acl_save_prefix"
+
+                    if test "X$x" = "X-I$additional_includedir"; then
+                      haveit=yes
+                      break
+                    fi
+                  done
+                  if test -z "$haveit"; then
+                    if test -d "$additional_includedir"; then
+                                            INCIGA64="${INCIGA64}${INCIGA64:+ }-I$additional_includedir"
+                    fi
+                  fi
+                fi
+              fi
+            fi
+                        if test -n "$found_la"; then
+                                                        save_libdir="$libdir"
+              case "$found_la" in
+                */* | *\\*) . "$found_la" ;;
+                *) . "./$found_la" ;;
+              esac
+              libdir="$save_libdir"
+                            for dep in $dependency_libs; do
+                case "$dep" in
+                  -L*)
+                    additional_libdir=`echo "X$dep" | sed -e 's/^X-L//'`
+                                                                                                                                                                if test "X$additional_libdir" != "X/usr/lib"; then
+                      haveit=
+                      if test "X$additional_libdir" = "X/usr/local/lib"; then
+                        if test -n "$GCC"; then
+                          case $host_os in
+                            linux*) haveit=yes;;
+                          esac
+                        fi
+                      fi
+                      if test -z "$haveit"; then
+                        haveit=
+                        for x in $LDFLAGS $LIBIGA64; do
+
+  acl_save_prefix="$prefix"
+  prefix="$acl_final_prefix"
+  acl_save_exec_prefix="$exec_prefix"
+  exec_prefix="$acl_final_exec_prefix"
+  eval x=\"$x\"
+  exec_prefix="$acl_save_exec_prefix"
+  prefix="$acl_save_prefix"
+
+                          if test "X$x" = "X-L$additional_libdir"; then
+                            haveit=yes
+                            break
+                          fi
+                        done
+                        if test -z "$haveit"; then
+                          if test -d "$additional_libdir"; then
+                                                        LIBIGA64="${LIBIGA64}${LIBIGA64:+ }-L$additional_libdir"
+                          fi
+                        fi
+                        haveit=
+                        for x in $LDFLAGS $LTLIBIGA64; do
+
+  acl_save_prefix="$prefix"
+  prefix="$acl_final_prefix"
+  acl_save_exec_prefix="$exec_prefix"
+  exec_prefix="$acl_final_exec_prefix"
+  eval x=\"$x\"
+  exec_prefix="$acl_save_exec_prefix"
+  prefix="$acl_save_prefix"
+
+                          if test "X$x" = "X-L$additional_libdir"; then
+                            haveit=yes
+                            break
+                          fi
+                        done
+                        if test -z "$haveit"; then
+                          if test -d "$additional_libdir"; then
+                                                        LTLIBIGA64="${LTLIBIGA64}${LTLIBIGA64:+ }-L$additional_libdir"
+                          fi
+                        fi
+                      fi
+                    fi
+                    ;;
+                  -R*)
+                    dir=`echo "X$dep" | sed -e 's/^X-R//'`
+                    if test "$enable_rpath" != no; then
+                                                                  haveit=
+                      for x in $rpathdirs; do
+                        if test "X$x" = "X$dir"; then
+                          haveit=yes
+                          break
+                        fi
+                      done
+                      if test -z "$haveit"; then
+                        rpathdirs="$rpathdirs $dir"
+                      fi
+                                                                  haveit=
+                      for x in $ltrpathdirs; do
+                        if test "X$x" = "X$dir"; then
+                          haveit=yes
+                          break
+                        fi
+                      done
+                      if test -z "$haveit"; then
+                        ltrpathdirs="$ltrpathdirs $dir"
+                      fi
+                    fi
+                    ;;
+                  -l*)
+                                        names_next_round="$names_next_round "`echo "X$dep" | sed -e 's/^X-l//'`
+                    ;;
+                  *.la)
+                                                                                names_next_round="$names_next_round "`echo "X$dep" | sed -e 's,^X.*/,,' -e 's,^lib,,' -e 's,\.la$,,'`
+                    ;;
+                  *)
+                                        LIBIGA64="${LIBIGA64}${LIBIGA64:+ }$dep"
+                    LTLIBIGA64="${LTLIBIGA64}${LTLIBIGA64:+ }$dep"
+                    ;;
+                esac
+              done
+            fi
+          else
+                                                            if test "x$lib_type" = "xauto" || test "x$lib_type" = "xshared"; then
+              LIBIGA64="${LIBIGA64}${LIBIGA64:+ }-l$name"
+              LTLIBIGA64="${LTLIBIGA64}${LTLIBIGA64:+ }-l$name"
+            else
+              LIBIGA64="${LIBIGA64}${LIBIGA64:+ }-l:lib$name.$libext"
+              LTLIBIGA64="${LTLIBIGA64}${LTLIBIGA64:+ }-l:lib$name.$libext"
+            fi
+          fi
+        fi
+      fi
+    done
+  done
+  if test "X$rpathdirs" != "X"; then
+    if test -n "$hardcode_libdir_separator"; then
+                        alldirs=
+      for found_dir in $rpathdirs; do
+        alldirs="${alldirs}${alldirs:+$hardcode_libdir_separator}$found_dir"
+      done
+            acl_save_libdir="$libdir"
+      libdir="$alldirs"
+      eval flag=\"$hardcode_libdir_flag_spec\"
+      libdir="$acl_save_libdir"
+      LIBIGA64="${LIBIGA64}${LIBIGA64:+ }$flag"
+    else
+            for found_dir in $rpathdirs; do
+        acl_save_libdir="$libdir"
+        libdir="$found_dir"
+        eval flag=\"$hardcode_libdir_flag_spec\"
+        libdir="$acl_save_libdir"
+        LIBIGA64="${LIBIGA64}${LIBIGA64:+ }$flag"
+      done
+    fi
+  fi
+  if test "X$ltrpathdirs" != "X"; then
+            for found_dir in $ltrpathdirs; do
+      LTLIBIGA64="${LTLIBIGA64}${LTLIBIGA64:+ }-R$found_dir"
+    done
+  fi
+
+
+        ac_save_CPPFLAGS="$CPPFLAGS"
+
+  for element in $INCIGA64; do
+    haveit=
+    for x in $CPPFLAGS; do
+
+  acl_save_prefix="$prefix"
+  prefix="$acl_final_prefix"
+  acl_save_exec_prefix="$exec_prefix"
+  exec_prefix="$acl_final_exec_prefix"
+  eval x=\"$x\"
+  exec_prefix="$acl_save_exec_prefix"
+  prefix="$acl_save_prefix"
+
+      if test "X$x" = "X$element"; then
+        haveit=yes
+        break
+      fi
+    done
+    if test -z "$haveit"; then
+      CPPFLAGS="${CPPFLAGS}${CPPFLAGS:+ }$element"
+    fi
+  done
+
+
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for libiga64" >&5
+$as_echo_n "checking for libiga64... " >&6; }
+if ${ac_cv_libiga64+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+
+    ac_save_LIBS="$LIBS"
+    LIBS="$LIBS $LIBIGA64"
+    cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+#include "assert.h"
+       #include "iga/iga.h"
+int
+main ()
+{
+iga_version_string();
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_cxx_try_link "$LINENO"; then :
+  ac_cv_libiga64=yes
+else
+  ac_cv_libiga64=no
+fi
+rm -f core conftest.err conftest.$ac_objext \
+    conftest$ac_exeext conftest.$ac_ext
+    LIBS="$ac_save_LIBS"
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_libiga64" >&5
+$as_echo "$ac_cv_libiga64" >&6; }
+  if test "$ac_cv_libiga64" = yes; then
+    HAVE_LIBIGA64=yes
+
+$as_echo "#define HAVE_LIBIGA64 1" >>confdefs.h
+
+    { $as_echo "$as_me:${as_lineno-$LINENO}: checking how to link with libiga64" >&5
+$as_echo_n "checking how to link with libiga64... " >&6; }
+    { $as_echo "$as_me:${as_lineno-$LINENO}: result: $LIBIGA64" >&5
+$as_echo "$LIBIGA64" >&6; }
+  else
+    HAVE_LIBIGA64=no
+            CPPFLAGS="$ac_save_CPPFLAGS"
+    LIBIGA64=
+    LTLIBIGA64=
+  fi
+
+
+
+
+
+
+    ac_ext=c
+ac_cpp='$CPP $CPPFLAGS'
+ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_c_compiler_gnu
+
+
+    if test "$HAVE_LIBIGA64" != yes; then
+      if test "$with_libiga64" = yes; then
+        as_fn_error $? "libiga64 is missing or unusable" "$LINENO" 5
+      else
+        { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: libiga64 is missing or unusable; some features may be unavailable." >&5
+$as_echo "$as_me: WARNING: libiga64 is missing or unusable; some features may be unavailable." >&2;}
+      fi
+    fi
+  fi
+fi
+
 # ------------------------- #
 # Checks for header files.  #
 # ------------------------- #
diff --git a/gdb/configure.ac b/gdb/configure.ac
index 226e27e4fe54a9d3ac06e8be4439dd5dce8eb975..0507f03043c61385181b667d0e7117d4b2547d6d 100644
--- a/gdb/configure.ac
+++ b/gdb/configure.ac
@@ -1351,6 +1351,58 @@ fi
 AC_SUBST(SRCHIGH_LIBS)
 AC_SUBST(SRCHIGH_CFLAGS)
 
+# Check for Intel(R) Graphics Technology assembler library
+intelgt_target=false
+
+for targ_alias in `echo $target_alias $enable_targets | sed 's/,/ /g'`
+do
+  if test "$targ_alias" = "all"; then
+    intelgt_target=true
+  else
+    case "$targ_alias" in
+      intelgt-*)
+        intelgt_target=true
+        ;;
+    esac
+  fi
+done
+
+case "${target}" in
+  intelgt-*)
+    intelgt_target=true
+    ;;
+esac
+
+if test "${intelgt_target}" != true; then
+  HAVE_LIBIGA64=no
+else
+  AC_ARG_WITH(libiga64,
+    AS_HELP_STRING([--with-libiga64], [include IntelGT disassembly support (auto/yes/no)]),
+    [], [with_libiga64=auto])
+  AC_MSG_CHECKING([whether to use libiga64])
+  AC_MSG_RESULT([$with_libiga64])
+
+  if test "${with_libiga64}" = no; then
+    AC_MSG_WARN([IntelGT disassembly support disabled; some features may be unavailable.])
+    HAVE_LIBIGA64=no
+  else
+    AC_LANG_PUSH([C++])
+    AC_LIB_HAVE_LINKFLAGS([iga64], [],
+      [#include "assert.h"
+       #include "iga/iga.h"],
+      [iga_version_string();])
+    AC_LANG_POP([C++])
+
+    if test "$HAVE_LIBIGA64" != yes; then
+      if test "$with_libiga64" = yes; then
+        AC_MSG_ERROR([libiga64 is missing or unusable])
+      else
+        AC_MSG_WARN([libiga64 is missing or unusable; some features may be unavailable.])
+      fi
+    fi
+  fi
+fi
+
 # ------------------------- #
 # Checks for header files.  #
 # ------------------------- #
diff --git a/gdb/disasm-selftests.c b/gdb/disasm-selftests.c
index 0d060654da10ec49c5a71e0009391e400d3d66ef..607f12bdc67ab051d212183a100ae29c93a0cdac 100644
--- a/gdb/disasm-selftests.c
+++ b/gdb/disasm-selftests.c
@@ -116,6 +116,10 @@ get_test_insn (struct gdbarch *gdbarch, size_t *len)
 	*len = bplen;
       }
       break;
+    case bfd_arch_intelgt:
+      /* The intelgt architecture needs to initialize the gdbarch with
+	 an IGA context to be able to use the disassembler.  */
+      return insn;
     case bfd_arch_i386:
       {
 	const struct bfd_arch_info *info = gdbarch_bfd_arch_info (gdbarch);
@@ -313,6 +317,14 @@ memory_error_test (struct gdbarch *gdbarch)
 	return;
     }
 
+#if !defined (HAVE_LIBIGA64)
+  if (gdbarch_bfd_arch_info (gdbarch)->arch == bfd_arch_intelgt)
+    {
+      /* Disassembler for intelgt requires libiga64.  */
+      return;
+    }
+#endif
+
   gdb_disassembler_test di (gdbarch);
   bool saw_memory_error = false;
 
diff --git a/gdb/doc/gdb.texinfo b/gdb/doc/gdb.texinfo
index 3d5b4491f775866d806782a92e0aa76c3539ff25..a4c98d18e20182765f8cf0546447c6777cdd5e2d 100644
--- a/gdb/doc/gdb.texinfo
+++ b/gdb/doc/gdb.texinfo
@@ -40984,6 +40984,11 @@ to download GNU Libiconv, unpack it inside the top-level directory of
 the @value{GDBN} source tree, and then rename the directory holding
 the Libiconv source code to @samp{libiconv}.
 
+@item libiga64 (IGA)
+@value{GDBN} can disassemble IntelGT machine code if this library is
+included.  Use the @option{--with-libiga64-prefix} option to specify
+its non-standard location.
+
 @cindex compressed debug sections
 @item lzma
 @value{GDBN} can support debugging sections that are compressed with
diff --git a/gdb/intelgt-tdep.c b/gdb/intelgt-tdep.c
index 3919947fed44c9e939bef6c14b854ae416ab7c41..583847dd168b39ff68036c91e1c63d7290988a7a 100644
--- a/gdb/intelgt-tdep.c
+++ b/gdb/intelgt-tdep.c
@@ -31,6 +31,10 @@
 #include "inferior.h"
 #include "user-regs.h"
 #include <algorithm>
+#include "disasm.h"
+#if defined (HAVE_LIBIGA64)
+#include "iga/iga.h"
+#endif /* defined (HAVE_LIBIGA64)  */
 
 /* Global debug flag.  */
 static bool intelgt_debug = false;
@@ -99,6 +103,11 @@ struct intelgt_gdbarch_tdep : gdbarch_tdep_base
     gdb_assert (regset_ranges[intelgt::REGSET_GRF].end > 1);
     return regset_ranges[intelgt::REGSET_GRF].end - 1;
   }
+
+#if defined (HAVE_LIBIGA64)
+  /* libiga context for disassembly.  */
+  iga_context_t iga_ctx = nullptr;
+#endif
 };
 
 /* Per-inferior cached data for the Intelgt target.  */
@@ -544,13 +553,75 @@ intelgt_sw_breakpoint_from_kind (gdbarch *gdbarch, int kind, int *size)
   return nullptr;
 }
 
+#if defined (HAVE_LIBIGA64)
+/* Map CORE_ADDR to symbol names for jump labels in an IGA disassembly.  */
+
+static const char *
+intelgt_disasm_sym_cb (int addr, void *ctx)
+{
+  disassemble_info *info = (disassemble_info *) ctx;
+  symbol *sym = find_pc_function (addr + (uintptr_t) info->private_data);
+  return sym ? sym->linkage_name () : nullptr;
+}
+#endif /* defined (HAVE_LIBIGA64)  */
+
 /* Print one instruction from MEMADDR on INFO->STREAM.  */
 
 static int
 intelgt_print_insn (bfd_vma memaddr, struct disassemble_info *info)
 {
-  /* Disassembler is to be added in a later patch.  */
+#if !defined (HAVE_LIBIGA64)
+  gdb_printf (_("\nDisassemble feature not available: libiga64 "
+		"is missing.\n"));
   return -1;
+#else
+  std::unique_ptr<bfd_byte[]> insn (new bfd_byte[intelgt::MAX_INST_LENGTH]);
+
+  int status = (*info->read_memory_func) (memaddr, insn.get (),
+					  intelgt::COMPACT_INST_LENGTH, info);
+  if (status != 0)
+    {
+      /* Aborts disassembling with a memory_error exception.  */
+      (*info->memory_error_func) (status, memaddr, info);
+      return -1;
+    }
+
+  uint32_t device_id = get_device_id (current_inferior ());
+  gdb::array_view<bfd_byte> insn_view
+    = gdb::make_array_view (insn.get (), intelgt::COMPACT_INST_LENGTH);
+  unsigned int length = intelgt::inst_length (insn_view, device_id);
+
+  if (length == intelgt::MAX_INST_LENGTH)
+    {
+      status = (*info->read_memory_func) (memaddr, insn.get (),
+					  intelgt::MAX_INST_LENGTH, info);
+      if (status != 0)
+	{
+	  /* Aborts disassembling with a memory_error exception.  */
+	  (*info->memory_error_func) (status, memaddr, info);
+	  return -1;
+	}
+    }
+
+  char *dbuf;
+  iga_disassemble_options_t dopts = IGA_DISASSEMBLE_OPTIONS_INIT ();
+  gdb_disassemble_info *di
+    = static_cast<gdb_disassemble_info *>(info->application_data);
+  struct gdbarch *gdbarch = di->arch ();
+
+  iga_context_t iga_ctx
+    = gdbarch_tdep<intelgt_gdbarch_tdep> (gdbarch)->iga_ctx;
+  iga_status_t iga_status
+    = iga_context_disassemble_instruction (iga_ctx, &dopts, insn.get (),
+					   intelgt_disasm_sym_cb,
+					   info, &dbuf);
+  if (iga_status != IGA_SUCCESS)
+    return -1;
+
+  (*info->fprintf_func) (info->stream, "%s", dbuf);
+
+  return length;
+#endif /* defined (HAVE_LIBIGA64)  */
 }
 
 /* The "read_pc" gdbarch method.  */
@@ -771,6 +842,46 @@ intelgt_gdbarch_init (gdbarch_info info, gdbarch_list *arches)
   intelgt_gdbarch_tdep *data
     = gdbarch_tdep<intelgt_gdbarch_tdep> (gdbarch);
 
+#if defined (HAVE_LIBIGA64)
+  iga_gen_t iga_version = IGA_GEN_INVALID;
+
+  if (tdesc != nullptr)
+    {
+      const tdesc_device *device_info = tdesc_device_info (tdesc);
+      if (!(device_info->vendor_id.has_value ()
+	    && device_info->target_id.has_value ()))
+	{
+	  warning (_("Device vendor id and target id not found."));
+	  gdbarch_free (gdbarch);
+	  return nullptr;
+	}
+
+      uint32_t vendor_id = *device_info->vendor_id;
+      uint32_t device_id = *device_info->target_id;
+      if (vendor_id != 0x8086)
+	{
+	  warning (_("Device not recognized: vendor id=0x%04x,"
+		     " device id=0x%04x"), vendor_id, device_id);
+	  gdbarch_free (gdbarch);
+	  return nullptr;
+	}
+      else
+	{
+	  iga_version = (iga_gen_t) intelgt::get_xe_version (device_id);
+	  if (iga_version == IGA_GEN_INVALID)
+	    warning (_("Intel GT device id is unrecognized: ID 0x%04x"),
+		     device_id);
+	}
+    }
+
+  /* Take the best guess in case IGA_VERSION is still invalid.  */
+  if (iga_version == IGA_GEN_INVALID)
+    iga_version = IGA_XE_HPC;
+
+  const iga_context_options_t options = IGA_CONTEXT_OPTIONS_INIT (iga_version);
+  iga_context_create (&options, &data->iga_ctx);
+#endif
+
   /* Initialize register info.  */
   set_gdbarch_num_regs (gdbarch, 0);
   set_gdbarch_register_name (gdbarch, tdesc_register_name);
diff --git a/gdb/top.c b/gdb/top.c
index 72d19530070ea0c7cec0647cf643bb0556e3a37b..25576d28964f61915775fe62594207f68d2ed716 100644
--- a/gdb/top.c
+++ b/gdb/top.c
@@ -1523,6 +1523,16 @@ This GDB was configured as follows:\n\
 "));
 #endif
 
+#ifdef HAVE_LIBIGA64
+  gdb_printf (stream, _("\
+	     --with-libiga64\n\
+"));
+#else
+  gdb_printf (stream, _("\
+	     --without-libiga64\n\
+"));
+#endif
+
 #if HAVE_SOURCE_HIGHLIGHT
   gdb_printf (stream, _("\
 	     --enable-source-highlight\n\

-- 
2.34.1

Intel Deutschland GmbH
Registered Address: Am Campeon 10, 85579 Neubiberg, Germany
Tel: +49 89 99 8853-0, www.intel.de
Managing Directors: Sean Fennelly, Jeffrey Schneiderman, Tiffany Doon Silva
Chairperson of the Supervisory Board: Nicole Lau
Registered Office: Munich
Commercial Register: Amtsgericht Muenchen HRB 186928

  parent reply	other threads:[~2025-08-01  9:55 UTC|newest]

Thread overview: 92+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-08-01  9:37 [PATCH v3 00/44] A new target to debug Intel GPUs Tankut Baris Aktemur
2025-08-01  9:37 ` [PATCH v3 01/44] gdb, intelgt: add intelgt as a basic machine Tankut Baris Aktemur
2025-12-09 20:44   ` Simon Marchi
2025-12-19 11:13     ` Aktemur, Tankut Baris
2025-08-01  9:37 ` [PATCH v3 02/44] bfd: add intelgt target to BFD Tankut Baris Aktemur
2025-08-01 12:20   ` Jan Beulich
2025-08-08  5:03     ` Metzger, Markus T
2025-12-09 21:05   ` Simon Marchi
2025-12-19 12:46     ` Aktemur, Tankut Baris
2025-08-01  9:37 ` [PATCH v3 03/44] ld: add intelgt as a target configuration Tankut Baris Aktemur
2025-08-01 12:06   ` Jan Beulich
2025-08-08  5:03     ` Metzger, Markus T
2025-08-01  9:37 ` [PATCH v3 04/44] opcodes: add intelgt as a configuration Tankut Baris Aktemur
2025-08-01  9:37 ` [PATCH v3 05/44] gdb, gdbserver, gdbsupport: add 'device' tag to XML target description Tankut Baris Aktemur
2025-12-09 21:27   ` Simon Marchi
2025-12-15 21:03     ` Simon Marchi
2025-12-18 15:04       ` Aktemur, Tankut Baris
2026-01-09 19:12         ` Aktemur, Tankut Baris
2026-01-09 19:34           ` Simon Marchi
2025-08-01  9:37 ` [PATCH v3 06/44] gdb, arch, intelgt: add intelgt arch definitions Tankut Baris Aktemur
2025-12-09 21:48   ` Simon Marchi
2025-12-16 15:47     ` Metzger, Markus T
2025-08-01  9:37 ` [PATCH v3 07/44] gdb, intelgt: add the target-dependent definitions for the Intel GT architecture Tankut Baris Aktemur
2025-12-11 18:53   ` Simon Marchi
2025-12-19 16:01     ` Aktemur, Tankut Baris
2025-08-01  9:37 ` Tankut Baris Aktemur [this message]
2025-12-11 19:37   ` [PATCH v3 08/44] gdb, intelgt: add disassemble feature " Simon Marchi
2025-12-23 11:03     ` Aktemur, Tankut Baris
2025-08-01  9:37 ` [PATCH v3 09/44] gdb, gdbserver, ze: in-memory libraries Tankut Baris Aktemur
2025-12-12  4:13   ` Simon Marchi
2025-12-12 11:20     ` Metzger, Markus T
2025-12-12 19:34       ` Simon Marchi
2025-12-15 13:07         ` Metzger, Markus T
2025-12-15 21:25           ` Simon Marchi
2025-08-01  9:37 ` [PATCH v3 10/44] gdb, gdbserver, rsp, ze: acknowledge libraries Tankut Baris Aktemur
2025-12-12  4:41   ` Simon Marchi
2025-12-12 14:28     ` Metzger, Markus T
2025-08-01  9:37 ` [PATCH v3 11/44] gdb, solib, ze: update target_solib_ops::bfd_open_from_target_memory Tankut Baris Aktemur
2025-12-12  4:43   ` Simon Marchi
2025-12-12 14:33     ` Metzger, Markus T
2025-08-01  9:37 ` [PATCH v3 12/44] gdb, infrun, ze: allow saving process events Tankut Baris Aktemur
2025-12-12  4:57   ` Simon Marchi
2025-12-15 13:13     ` Metzger, Markus T
2025-12-16 21:10       ` Simon Marchi
2025-12-17  9:30         ` Metzger, Markus T
2025-12-17 20:44           ` Simon Marchi
2025-12-18  7:20             ` Metzger, Markus T
2025-08-01  9:37 ` [PATCH v3 13/44] gdb, ze: add TARGET_WAITKIND_UNAVAILABLE Tankut Baris Aktemur
2025-08-01  9:37 ` [PATCH v3 14/44] gdb, infrun, ze: handle stopping unavailable threads Tankut Baris Aktemur
2025-08-01  9:37 ` [PATCH v3 15/44] gdb, infrun, ze: allow resuming " Tankut Baris Aktemur
2025-08-01  9:37 ` [PATCH v3 16/44] gdb, gdbserver, ze: add U stop reply Tankut Baris Aktemur
2025-08-01  9:37 ` [PATCH v3 17/44] gdb, gdbserver, ze: add library notification to " Tankut Baris Aktemur
2025-08-01  9:37 ` [PATCH v3 18/44] gdbserver, ze: report TARGET_WAITKIND_UNAVAILABLE events Tankut Baris Aktemur
2025-08-01  9:37 ` [PATCH v3 19/44] gdb, ze: handle TARGET_WAITKIND_UNAVAILABLE in stop_all_threads Tankut Baris Aktemur
2025-08-01  9:37 ` [PATCH v3 20/44] gdb, remote: handle thread unavailability in print_one_stopped_thread Tankut Baris Aktemur
2025-08-01  9:37 ` [PATCH v3 21/44] gdb, remote: do 'remote_add_inferior' in 'remote_notice_new_inferior' earlier Tankut Baris Aktemur
2025-08-01  9:37 ` [PATCH v3 22/44] gdb, remote: handle a generic process PID in remote_notice_new_inferior Tankut Baris Aktemur
2025-08-01  9:37 ` [PATCH v3 23/44] gdb, remote: handle a generic process PID in process_stop_reply Tankut Baris Aktemur
2025-08-01  9:37 ` [PATCH v3 24/44] gdb: use the pid from inferior in setup_inferior Tankut Baris Aktemur
2025-12-12 19:51   ` Simon Marchi
2025-12-13 12:40     ` Aktemur, Tankut Baris
2025-08-01  9:37 ` [PATCH v3 25/44] gdb: revise the pid_to_exec_file target op Tankut Baris Aktemur
2025-08-01  9:37 ` [PATCH v3 26/44] gdb: load solibs if the target does not have the notion of an exec file Tankut Baris Aktemur
2025-12-12 20:30   ` Simon Marchi
2026-01-09 19:10     ` Aktemur, Tankut Baris
2025-08-01  9:37 ` [PATCH v3 27/44] gdbserver: import AC_LIB_HAVE_LINKFLAGS macro into the autoconf script Tankut Baris Aktemur
2025-08-01  9:37 ` [PATCH v3 28/44] gdbserver: add a pointer to the owner thread in regcache Tankut Baris Aktemur
2025-08-01  9:37 ` [PATCH v3 29/44] gdbserver: wait for stopped threads in queue_stop_reply_callback Tankut Baris Aktemur
2025-08-01  9:37 ` [PATCH v3 30/44] gdbserver: adjust pid after the target attaches Tankut Baris Aktemur
2025-08-01  9:37 ` [PATCH v3 31/44] gdb: do not create a thread after a process event Tankut Baris Aktemur
2025-08-01  9:37 ` [PATCH v3 32/44] gdb, ze: on a whole process stop, mark all threads as not_resumed Tankut Baris Aktemur
2025-08-01  9:37 ` [PATCH v3 33/44] gdb, dwarf, ze: add DW_OP_INTEL_regval_bits Tankut Baris Aktemur
2025-08-01 12:02   ` Jan Beulich
2025-08-01 12:31     ` Metzger, Markus T
2025-08-01 12:50       ` Jan Beulich
2025-08-08  5:25         ` Metzger, Markus T
2025-08-01  9:37 ` [PATCH v3 34/44] gdbserver: allow configuring for a heterogeneous target Tankut Baris Aktemur
2025-08-01  9:37 ` [PATCH v3 35/44] gdbserver, ze, intelgt: introduce ze-low and intel-ze-low targets Tankut Baris Aktemur
2025-08-01  9:37 ` [PATCH v3 36/44] testsuite, sycl: add SYCL support Tankut Baris Aktemur
2025-08-01  9:37 ` [PATCH v3 37/44] testsuite, sycl: add test for backtracing inside a kernel Tankut Baris Aktemur
2025-08-01  9:37 ` [PATCH v3 38/44] testsuite, sycl: add test for 'info locals' and 'info args' Tankut Baris Aktemur
2025-08-01  9:37 ` [PATCH v3 39/44] testsuite, sycl: add tests for stepping and accessing data elements Tankut Baris Aktemur
2025-08-01  9:37 ` [PATCH v3 40/44] testsuite, sycl: add test for 1-D and 2-D parallel_for kernels Tankut Baris Aktemur
2025-08-01  9:37 ` [PATCH v3 41/44] testsuite, sycl: add test for scheduler-locking Tankut Baris Aktemur
2025-08-01  9:37 ` [PATCH v3 42/44] testsuite, arch, intelgt: add a disassembly test Tankut Baris Aktemur
2025-08-01  9:37 ` [PATCH v3 43/44] testsuite, arch, intelgt: add intelgt-program-bp.exp Tankut Baris Aktemur
2025-08-01  9:37 ` [PATCH v3 44/44] testsuite, sycl: test canceling a stepping flow Tankut Baris Aktemur
2025-09-17 12:43 ` [PATCH v3 00/44] A new target to debug Intel GPUs Aktemur, Tankut Baris
2025-10-14  6:34   ` Aktemur, Tankut Baris
2025-12-08 11:32 ` Aktemur, Tankut Baris
2025-12-09 21:30 ` Simon Marchi
2025-12-19 12:52   ` Aktemur, Tankut Baris

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20250801-upstream-intelgt-mvp-v3-8-59ce0f87075b@intel.com \
    --to=tankut.baris.aktemur@intel.com \
    --cc=gdb-patches@sourceware.org \
    --cc=markus.t.metzger@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox