[PATCH] Implement "record btrace pt" for Windows
Hannes Domani
ssbssa@yahoo.de
Wed Dec 4 17:21:06 GMT 2024
Windows 10 contains since version 1809 the ability to enable IPT
recording.
No official API was made available for this, so instead this uses the
reverse-engineered interface of the WinIPT library.
---
A few questions remain:
- The btrace_this_cpu function was copied from linux-btrace.c, should it
be moved in some common location, and if so, where?
- I haven't actually tried it yet, but on gdbserver side it should also
work if I copy the logic from linux-low.cc.
Would that be fine, or should I also move the common stuff somewhere
else?
---
gdb/Makefile.in | 5 +-
gdb/NEWS | 3 +
gdb/config.in | 3 +
gdb/configure | 493 ++++++++++++++++++++++++++++++++++++++-
gdb/configure.nat | 6 +-
gdb/nat/windows-btrace.c | 276 ++++++++++++++++++++++
gdb/nat/windows-btrace.h | 22 ++
gdb/windows-nat.c | 83 +++++++
gdbserver/config.in | 3 +
gdbserver/configure | 489 ++++++++++++++++++++++++++++++++++++++
gdbsupport/Makefile.in | 3 +
gdbsupport/common.m4 | 5 +
gdbsupport/config.in | 3 +
gdbsupport/configure | 489 ++++++++++++++++++++++++++++++++++++++
14 files changed, 1878 insertions(+), 5 deletions(-)
create mode 100644 gdb/nat/windows-btrace.c
create mode 100644 gdb/nat/windows-btrace.h
diff --git a/gdb/Makefile.in b/gdb/Makefile.in
index ecb323d8f02..6080c87eb2e 100644
--- a/gdb/Makefile.in
+++ b/gdb/Makefile.in
@@ -208,6 +208,9 @@ LIBXXHASH = @LIBXXHASH@
# Where is libipt? This will be empty if libipt was not available.
LIBIPT = @LIBIPT@
+# Where is libwinipt? This will be empty if libwinipt was not available.
+LIBWINIPT = @LIBWINIPT@
+
# How to find GMP and MPFR
GMPLIBS = @GMPLIBS@
GMPINC = @GMPINC@
@@ -677,7 +680,7 @@ CLIBS = $(SIM) $(READLINE) $(OPCODES) $(LIBCTF) $(BFD) $(ZLIB) $(ZSTD_LIBS) \
$(LIBSUPPORT) $(INTL) $(LIBIBERTY) $(LIBDECNUMBER) \
$(XM_CLIBS) $(GDBTKLIBS) $(LIBBACKTRACE_LIB) \
@LIBS@ @GUILE_LIBS@ @PYTHON_LIBS@ $(AMD_DBGAPI_LIBS) \
- $(LIBEXPAT) $(LIBLZMA) $(LIBBABELTRACE) $(LIBIPT) \
+ $(LIBEXPAT) $(LIBLZMA) $(LIBBABELTRACE) $(LIBIPT) $(LIBWINIPT) \
$(WIN32LIBS) $(LIBGNU) $(LIBGNU_EXTRA_LIBS) $(LIBICONV) \
$(GMPLIBS) $(SRCHIGH_LIBS) $(LIBXXHASH) $(PTHREAD_LIBS) \
$(DEBUGINFOD_LIBS) $(LIBBABELTRACE_LIB)
diff --git a/gdb/NEWS b/gdb/NEWS
index f3c5d720b15..42d9413ad0d 100644
--- a/gdb/NEWS
+++ b/gdb/NEWS
@@ -56,6 +56,9 @@
* The Ada 'Object_Size attribute is now supported.
+* GDB now supports branch trace recording using Intel Processor Trace on
+ Windows targets.
+
* Python API
** Added gdb.record.clear. Clears the trace data of the current recording.
diff --git a/gdb/config.in b/gdb/config.in
index 59a5da39553..65bbe04b628 100644
--- a/gdb/config.in
+++ b/gdb/config.in
@@ -286,6 +286,9 @@
/* Define to 1 if you have the <libunwind-ia64.h> header file. */
#undef HAVE_LIBUNWIND_IA64_H
+/* Define if you have the winipt library. */
+#undef HAVE_LIBWINIPT
+
/* Define if you have the xxhash library. */
#undef HAVE_LIBXXHASH
diff --git a/gdb/configure b/gdb/configure
index ec9bbd3a842..5b130caefc8 100755
--- a/gdb/configure
+++ b/gdb/configure
@@ -802,6 +802,9 @@ am__leading_dot
LTLIBXXHASH
LIBXXHASH
HAVE_LIBXXHASH
+LTLIBWINIPT
+LIBWINIPT
+HAVE_LIBWINIPT
LTLIBIPT
LIBIPT
HAVE_LIBIPT
@@ -918,6 +921,8 @@ with_intel_pt
enable_rpath
with_libipt_prefix
with_libipt_type
+with_libwinipt_prefix
+with_libwinipt_type
with_xxhash
with_libxxhash_prefix
with_libxxhash_type
@@ -1675,6 +1680,9 @@ Optional Packages:
--with-libipt-prefix[=DIR] search for libipt in DIR/include and DIR/lib
--without-libipt-prefix don't search for libipt in includedir and libdir
--with-libipt-type=TYPE type of library to search for (auto/static/shared)
+ --with-libwinipt-prefix[=DIR] search for libwinipt in DIR/include and DIR/lib
+ --without-libwinipt-prefix don't search for libwinipt in includedir and libdir
+ --with-libwinipt-type=TYPE type of library to search for (auto/static/shared)
--with-xxhash use libxxhash for hashing (faster) (auto/yes/no)
--with-libxxhash-prefix[=DIR] search for libxxhash in DIR/include and DIR/lib
--without-libxxhash-prefix don't search for libxxhash in includedir and libdir
@@ -11499,7 +11507,7 @@ else
lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
lt_status=$lt_dlunknown
cat > conftest.$ac_ext <<_LT_EOF
-#line 11502 "configure"
+#line 11510 "configure"
#include "confdefs.h"
#if HAVE_DLFCN_H
@@ -11605,7 +11613,7 @@ else
lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
lt_status=$lt_dlunknown
cat > conftest.$ac_ext <<_LT_EOF
-#line 11608 "configure"
+#line 11616 "configure"
#include "confdefs.h"
#if HAVE_DLFCN_H
@@ -21524,6 +21532,487 @@ _ACEOF
fi
LIBS=$save_LIBS
+
+
+
+
+
+
+
+
+
+ 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-libwinipt-prefix was given.
+if test "${with_libwinipt_prefix+set}" = set; then :
+ withval=$with_libwinipt_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-libwinipt-type was given.
+if test "${with_libwinipt_type+set}" = set; then :
+ withval=$with_libwinipt_type; with_libwinipt_type=$withval
+else
+ with_libwinipt_type=auto
+fi
+
+ lib_type=`eval echo \$with_libwinipt_type`
+
+ LIBWINIPT=
+ LTLIBWINIPT=
+ INCWINIPT=
+ rpathdirs=
+ ltrpathdirs=
+ names_already_handled=
+ names_next_round='winipt '
+ 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" || LIBWINIPT="${LIBWINIPT}${LIBWINIPT:+ }$value"
+ eval value=\"\$LTLIB$uppername\"
+ test -z "$value" || LTLIBWINIPT="${LTLIBWINIPT}${LTLIBWINIPT:+ }$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 $LTLIBWINIPT; 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
+ LTLIBWINIPT="${LTLIBWINIPT}${LTLIBWINIPT:+ }-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
+ LIBWINIPT="${LIBWINIPT}${LIBWINIPT:+ }$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
+ LIBWINIPT="${LIBWINIPT}${LIBWINIPT:+ }$found_so"
+ else
+ if test -n "$hardcode_libdir_flag_spec" && test "$hardcode_minus_L" = no; then
+ LIBWINIPT="${LIBWINIPT}${LIBWINIPT:+ }$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 $LIBWINIPT; 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
+ LIBWINIPT="${LIBWINIPT}${LIBWINIPT:+ }-L$found_dir"
+ fi
+ if test "$hardcode_minus_L" != no; then
+ LIBWINIPT="${LIBWINIPT}${LIBWINIPT:+ }$found_so"
+ else
+ LIBWINIPT="${LIBWINIPT}${LIBWINIPT:+ }-l$name"
+ fi
+ fi
+ fi
+ fi
+ else
+ if test "X$found_a" != "X"; then
+ LIBWINIPT="${LIBWINIPT}${LIBWINIPT:+ }$found_a"
+ else
+ LIBWINIPT="${LIBWINIPT}${LIBWINIPT:+ }-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 $INCWINIPT; 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
+ INCWINIPT="${INCWINIPT}${INCWINIPT:+ }-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 $LIBWINIPT; 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
+ LIBWINIPT="${LIBWINIPT}${LIBWINIPT:+ }-L$additional_libdir"
+ fi
+ fi
+ haveit=
+ for x in $LDFLAGS $LTLIBWINIPT; 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
+ LTLIBWINIPT="${LTLIBWINIPT}${LTLIBWINIPT:+ }-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$,,'`
+ ;;
+ *)
+ LIBWINIPT="${LIBWINIPT}${LIBWINIPT:+ }$dep"
+ LTLIBWINIPT="${LTLIBWINIPT}${LTLIBWINIPT:+ }$dep"
+ ;;
+ esac
+ done
+ fi
+ else
+ if test "x$lib_type" = "xauto" || test "x$lib_type" = "xshared"; then
+ LIBWINIPT="${LIBWINIPT}${LIBWINIPT:+ }-l$name"
+ LTLIBWINIPT="${LTLIBWINIPT}${LTLIBWINIPT:+ }-l$name"
+ else
+ LIBWINIPT="${LIBWINIPT}${LIBWINIPT:+ }-l:lib$name.$libext"
+ LTLIBWINIPT="${LTLIBWINIPT}${LTLIBWINIPT:+ }-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"
+ LIBWINIPT="${LIBWINIPT}${LIBWINIPT:+ }$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"
+ LIBWINIPT="${LIBWINIPT}${LIBWINIPT:+ }$flag"
+ done
+ fi
+ fi
+ if test "X$ltrpathdirs" != "X"; then
+ for found_dir in $ltrpathdirs; do
+ LTLIBWINIPT="${LTLIBWINIPT}${LTLIBWINIPT:+ }-R$found_dir"
+ done
+ fi
+
+
+ ac_save_CPPFLAGS="$CPPFLAGS"
+
+ for element in $INCWINIPT; 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 libwinipt" >&5
+$as_echo_n "checking for libwinipt... " >&6; }
+if ${ac_cv_libwinipt+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+
+ ac_save_LIBS="$LIBS"
+ LIBS="$LIBS $LIBWINIPT"
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+
+#include <windows.h>
+#include <libipt.h>
+
+int
+main ()
+{
+GetIptBufferVersion (0);
+ ;
+ return 0;
+}
+_ACEOF
+if ac_fn_c_try_link "$LINENO"; then :
+ ac_cv_libwinipt=yes
+else
+ ac_cv_libwinipt=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_libwinipt" >&5
+$as_echo "$ac_cv_libwinipt" >&6; }
+ if test "$ac_cv_libwinipt" = yes; then
+ HAVE_LIBWINIPT=yes
+
+$as_echo "#define HAVE_LIBWINIPT 1" >>confdefs.h
+
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking how to link with libwinipt" >&5
+$as_echo_n "checking how to link with libwinipt... " >&6; }
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $LIBWINIPT" >&5
+$as_echo "$LIBWINIPT" >&6; }
+ else
+ HAVE_LIBWINIPT=no
+ CPPFLAGS="$ac_save_CPPFLAGS"
+ LIBWINIPT=
+ LTLIBWINIPT=
+ fi
+
+
+
+
+
+
fi
fi
diff --git a/gdb/configure.nat b/gdb/configure.nat
index 9e78091250a..e1551f2f674 100644
--- a/gdb/configure.nat
+++ b/gdb/configure.nat
@@ -340,14 +340,16 @@ case ${gdb_host} in
mingw)
case ${gdb_host_cpu} in
i386)
- NATDEPFILES="${NATDEPFILES} i386-windows-nat.o"
+ NATDEPFILES="${NATDEPFILES} i386-windows-nat.o \
+ nat/windows-btrace.o"
;;
esac
;;
mingw64)
case ${gdb_host_cpu} in
i386)
- NATDEPFILES="${NATDEPFILES} i386-windows-nat.o amd64-windows-nat.o"
+ NATDEPFILES="${NATDEPFILES} i386-windows-nat.o amd64-windows-nat.o \
+ nat/windows-btrace.o"
;;
esac
;;
diff --git a/gdb/nat/windows-btrace.c b/gdb/nat/windows-btrace.c
new file mode 100644
index 00000000000..f1c68d59a84
--- /dev/null
+++ b/gdb/nat/windows-btrace.c
@@ -0,0 +1,276 @@
+
+#ifdef HAVE_LIBWINIPT
+#include "windows-btrace.h"
+#include "nat/x86-cpuid.h"
+
+#include <windows.h>
+
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wunknown-pragmas"
+extern "C" {
+#include <libipt.h>
+}
+#pragma GCC diagnostic pop
+
+struct handle_deleter
+{
+ void operator() (HANDLE h) const
+ {
+ if (h != INVALID_HANDLE_VALUE)
+ CloseHandle (h);
+ }
+ using pointer = HANDLE;
+};
+
+using handle_up = std::unique_ptr<HANDLE, handle_deleter>;
+
+struct sc_handle_deleter
+{
+ void operator() (SC_HANDLE sch) const
+ {
+ CloseServiceHandle (sch);
+ }
+ using pointer = SC_HANDLE;
+};
+
+using sc_handle_up = std::unique_ptr<SC_HANDLE, sc_handle_deleter>;
+
+/* Look up and start IPT service. */
+
+static void
+windows_enable_ipt_service ()
+{
+ sc_handle_up scManager
+ (OpenSCManager (nullptr, nullptr, SC_MANAGER_CONNECT));
+ if (!scManager)
+ {
+ unsigned err = (unsigned) GetLastError ();
+ error (_("Can't open SCM handle (error %u: %s)."),
+ err, strwinerror (err));
+ }
+
+ sc_handle_up scService
+ (OpenServiceW (scManager.get (), L"Ipt", SERVICE_START));
+ if (!scService)
+ {
+ unsigned err = (unsigned) GetLastError ();
+ error (_("Can't open IPT service (error %u: %s)."),
+ err, strwinerror (err));
+ }
+
+ if (!StartService (scService.get (), 0, nullptr))
+ {
+ unsigned err = (unsigned) GetLastError ();
+ if (err != ERROR_SERVICE_ALREADY_RUNNING)
+ error (_("Can't start IPT service (error %u: %s)."),
+ err, strwinerror (err));
+ }
+}
+
+/* See windows-btrace.h. */
+
+struct btrace_target_info *
+windows_enable_btrace (ptid_t ptid, const struct btrace_config *conf,
+ int &ipt_threads)
+{
+ if (conf->format != BTRACE_FORMAT_PT)
+ error (_("Unknown branch trace format."));
+
+ DWORD size = conf->pt.size;
+ if (size < 4 * 1024)
+ size = 4 * 1024;
+ else if (size > 128 * 1024 * 1024)
+ size = 128 * 1024 * 1024;
+
+ /* IPT tracing is enabled per process, so only do it for the first
+ thread. */
+ if (ipt_threads == 0)
+ {
+ windows_enable_ipt_service ();
+
+ DWORD bufferVersion;
+ if (!GetIptBufferVersion (&bufferVersion))
+ error (_("Can't get IPT buffer version."));
+ if (bufferVersion != IPT_BUFFER_MAJOR_VERSION_CURRENT)
+ error (_("IPT buffer version mismatch."));
+
+ WORD traceVersion;
+ if (!GetIptTraceVersion (&traceVersion))
+ error (_("Can't get IPT trace version."));
+ if (traceVersion != IPT_TRACE_VERSION_CURRENT)
+ error (_("IPT trace version mismatch."));
+
+ int pid = ptid.pid ();
+ handle_up hProcess (OpenProcess (PROCESS_VM_READ, FALSE, pid));
+ if (!hProcess)
+ {
+ unsigned err = (unsigned) GetLastError ();
+ error (_("Can't open process handle (error %u: %s)."),
+ err, strwinerror (err));
+ }
+
+ DWORD index;
+ BitScanReverse(&index, size);
+
+ IPT_OPTIONS options;
+ options.AsULonglong = 0;
+ options.OptionVersion = 1;
+ options.TopaPagesPow2 = index - 12;
+ options.TimingSettings = IptNoTimingPackets;
+ options.ModeSettings = IptCtlUserModeOnly;
+
+ if (!StartProcessIptTracing (hProcess.get (), options))
+ error (_("Can't start trace."));
+ }
+
+ ipt_threads++;
+
+ std::unique_ptr<btrace_target_info> tinfo
+ { std::make_unique<btrace_target_info> (ptid) };
+
+ tinfo->conf.format = BTRACE_FORMAT_PT;
+ tinfo->conf.pt.size = size;
+
+ return tinfo.release ();
+}
+
+/* See windows-btrace.h. */
+
+bool
+windows_disable_btrace (struct btrace_target_info *tinfo, int &ipt_threads)
+{
+ if (tinfo->conf.format != BTRACE_FORMAT_PT)
+ return false;
+
+ /* Disable IPT tracing when the last thread is reached. */
+ if (--ipt_threads > 0)
+ return true;
+
+ int pid = tinfo->ptid.pid ();
+ handle_up hProcess (OpenProcess (PROCESS_VM_READ, FALSE, pid));
+ if (!hProcess)
+ return false;
+
+ if (!StopProcessIptTracing (hProcess.get ()))
+ return false;
+
+ return true;
+}
+
+/* Identify the cpu we're running on. */
+
+static struct btrace_cpu
+btrace_this_cpu (void)
+{
+ struct btrace_cpu cpu;
+ unsigned int eax, ebx, ecx, edx;
+ int ok;
+
+ memset (&cpu, 0, sizeof (cpu));
+
+ ok = x86_cpuid (0, &eax, &ebx, &ecx, &edx);
+ if (ok != 0)
+ {
+ if (ebx == signature_INTEL_ebx && ecx == signature_INTEL_ecx
+ && edx == signature_INTEL_edx)
+ {
+ unsigned int cpuid, ignore;
+
+ ok = x86_cpuid (1, &cpuid, &ignore, &ignore, &ignore);
+ if (ok != 0)
+ {
+ cpu.vendor = CV_INTEL;
+
+ cpu.family = (cpuid >> 8) & 0xf;
+ if (cpu.family == 0xf)
+ cpu.family += (cpuid >> 20) & 0xff;
+
+ cpu.model = (cpuid >> 4) & 0xf;
+ if ((cpu.family == 0x6) || ((cpu.family & 0xf) == 0xf))
+ cpu.model += (cpuid >> 12) & 0xf0;
+ }
+ }
+ else if (ebx == signature_AMD_ebx && ecx == signature_AMD_ecx
+ && edx == signature_AMD_edx)
+ cpu.vendor = CV_AMD;
+ }
+
+ return cpu;
+}
+
+/* See windows-btrace.h. */
+
+enum btrace_error
+windows_read_btrace (struct btrace_data *data,
+ struct btrace_target_info *btinfo,
+ enum btrace_read_type type)
+{
+ if (btinfo->conf.format != BTRACE_FORMAT_PT)
+ return BTRACE_ERR_NOT_SUPPORTED;
+
+ data->format = BTRACE_FORMAT_PT;
+ data->variant.pt.data = nullptr;
+ data->variant.pt.size = 0;
+ data->variant.pt.config.cpu = btrace_this_cpu ();
+
+ if (type == BTRACE_READ_NEW)
+ type = BTRACE_READ_ALL;
+
+ if (type != BTRACE_READ_ALL)
+ return BTRACE_ERR_NOT_SUPPORTED;
+
+ int pid = btinfo->ptid.pid ();
+ handle_up hProcess (OpenProcess (PROCESS_VM_READ, FALSE, pid));
+ if (!hProcess)
+ return BTRACE_ERR_UNKNOWN;
+
+ DWORD traceSize;
+ if (!GetProcessIptTraceSize (hProcess.get (), &traceSize))
+ return BTRACE_ERR_UNKNOWN;
+
+ gdb::unique_xmalloc_ptr<unsigned char> buf
+ ((unsigned char *) xmalloc (traceSize));
+
+ if (!GetProcessIptTrace (hProcess.get (), buf.get (), traceSize))
+ return BTRACE_ERR_UNKNOWN;
+
+ IPT_TRACE_DATA *pt_data = (IPT_TRACE_DATA *) buf.get ();
+ unsigned char *buf_end = buf.get () + traceSize;
+ size_t trace_offset = offsetof (IPT_TRACE_HEADER, Trace);
+
+ DWORD threadId = btinfo->ptid.lwp ();
+ IPT_TRACE_HEADER *pt_thread = (IPT_TRACE_HEADER *) pt_data->TraceData;
+ while ((unsigned char *) pt_thread + trace_offset < buf_end
+ && pt_thread->Trace + pt_thread->TraceSize <= buf_end)
+ {
+ if (pt_thread->ThreadId == threadId)
+ {
+ uint32_t trace_size = pt_thread->TraceSize;
+ BYTE *trace_data = pt_thread->Trace;
+ gdb::unique_xmalloc_ptr<gdb_byte> bytes
+ ((gdb_byte *) xmalloc (trace_size));
+ uint32_t start = pt_thread->RingBufferOffset;
+ if (start > 0)
+ memcpy (bytes.get () + (trace_size - start), trace_data, start);
+ memcpy (bytes.get (), trace_data + start, trace_size - start);
+
+ data->variant.pt.data = bytes.release ();
+ data->variant.pt.size = trace_size;
+ return BTRACE_ERR_NONE;
+ }
+
+ pt_thread
+ = (IPT_TRACE_HEADER *) (pt_thread->Trace + pt_thread->TraceSize);
+ }
+
+ return BTRACE_ERR_UNKNOWN;
+}
+
+/* See windows-btrace.h. */
+
+const struct btrace_config *
+windows_btrace_conf (const struct btrace_target_info *btinfo)
+{
+ return &btinfo->conf;
+}
+#endif
diff --git a/gdb/nat/windows-btrace.h b/gdb/nat/windows-btrace.h
new file mode 100644
index 00000000000..b2cabd13fc7
--- /dev/null
+++ b/gdb/nat/windows-btrace.h
@@ -0,0 +1,22 @@
+
+#ifdef HAVE_LIBWINIPT
+#include "gdbsupport/btrace-common.h"
+
+/* See target_ops::enable_btrace in target.h. */
+struct btrace_target_info *
+windows_enable_btrace (ptid_t ptid, const struct btrace_config *conf,
+ int &ipt_threads);
+
+/* See target_ops::disable_btrace in target.h. */
+bool windows_disable_btrace (struct btrace_target_info *tinfo,
+ int &ipt_threads);
+
+/* See target_ops::read_btrace in target.h. */
+enum btrace_error windows_read_btrace (struct btrace_data *data,
+ struct btrace_target_info *btinfo,
+ enum btrace_read_type type);
+
+/* See target_ops::btrace_conf in target.h. */
+const struct btrace_config *
+windows_btrace_conf (const struct btrace_target_info *btinfo);
+#endif
diff --git a/gdb/windows-nat.c b/gdb/windows-nat.c
index f2d0633b32f..ede92b51277 100644
--- a/gdb/windows-nat.c
+++ b/gdb/windows-nat.c
@@ -75,6 +75,7 @@
#include "gdbsupport/symbol.h"
#include "ser-event.h"
#include "inf-loop.h"
+#include "nat/windows-btrace.h"
using namespace windows_nat;
@@ -141,6 +142,11 @@ struct windows_per_inferior : public windows_process_info
CORE_ADDR cygwin_load_start = 0;
CORE_ADDR cygwin_load_end = 0;
#endif /* __CYGWIN__ */
+
+#ifdef HAVE_LIBWINIPT
+ /* Number of threads for which IPT was enabled. */
+ int ipt_threads = 0;
+#endif
};
/* The current process. */
@@ -319,6 +325,17 @@ struct windows_nat_target final : public x86_nat_target<inf_child_target>
return serial_event_fd (m_wait_event);
}
+#ifdef HAVE_LIBWINIPT
+ struct btrace_target_info *enable_btrace (thread_info *tp,
+ const struct btrace_config *conf) override;
+ void disable_btrace (struct btrace_target_info *tinfo) override;
+ void teardown_btrace (struct btrace_target_info *tinfo) override;
+ enum btrace_error read_btrace (struct btrace_data *data,
+ struct btrace_target_info *btinfo,
+ enum btrace_read_type type) override;
+ const struct btrace_config *btrace_conf (const struct btrace_target_info *) override;
+#endif
+
private:
windows_thread_info *add_thread (ptid_t ptid, HANDLE h, void *tlb,
@@ -1817,6 +1834,10 @@ windows_nat_target::do_initial_windows_stuff (DWORD pid, bool attaching)
windows_process.windows_initialization_done = 0;
+#ifdef HAVE_LIBWINIPT
+ windows_process.ipt_threads = 0;
+#endif
+
ptid_t last_ptid;
while (1)
@@ -1857,6 +1878,68 @@ windows_nat_target::do_initial_windows_stuff (DWORD pid, bool attaching)
return;
}
+#ifdef HAVE_LIBWINIPT
+/* Enable branch tracing. */
+
+struct btrace_target_info *
+windows_nat_target::enable_btrace (thread_info *tp,
+ const struct btrace_config *conf)
+{
+ struct btrace_target_info *tinfo = nullptr;
+ ptid_t ptid = tp->ptid;
+ try
+ {
+ tinfo = windows_enable_btrace (ptid, conf, windows_process.ipt_threads);
+ }
+ catch (const gdb_exception_error &exception)
+ {
+ error (_("Could not enable branch tracing for %s: %s"),
+ target_pid_to_str (ptid).c_str (), exception.what ());
+ }
+
+ return tinfo;
+}
+
+/* Disable branch tracing. */
+
+void
+windows_nat_target::disable_btrace (struct btrace_target_info *tinfo)
+{
+ bool ret = windows_disable_btrace (tinfo, windows_process.ipt_threads);
+ delete tinfo;
+
+ if (!ret)
+ error (_("Could not disable branch tracing."));
+}
+
+/* Teardown branch tracing. */
+
+void
+windows_nat_target::teardown_btrace (struct btrace_target_info *tinfo)
+{
+ windows_disable_btrace (tinfo, windows_process.ipt_threads);
+ delete tinfo;
+}
+
+/* Read branch trace data. */
+
+enum btrace_error
+windows_nat_target::read_btrace (struct btrace_data *data,
+ struct btrace_target_info *btinfo,
+ enum btrace_read_type type)
+{
+ return windows_read_btrace (data, btinfo, type);
+}
+
+/* Get the branch trace configuration. */
+
+const struct btrace_config *
+windows_nat_target::btrace_conf (const struct btrace_target_info *btinfo)
+{
+ return windows_btrace_conf (btinfo);
+}
+#endif
+
/* Try to set or remove a user privilege to the current process. Return -1
if that fails, the previous setting of that privilege otherwise.
diff --git a/gdbserver/config.in b/gdbserver/config.in
index 65f9ff6e647..47c07fd1634 100644
--- a/gdbserver/config.in
+++ b/gdbserver/config.in
@@ -161,6 +161,9 @@
/* Define if you have the ipt library. */
#undef HAVE_LIBIPT
+/* Define if you have the winipt library. */
+#undef HAVE_LIBWINIPT
+
/* Define if you have the xxhash library. */
#undef HAVE_LIBXXHASH
diff --git a/gdbserver/configure b/gdbserver/configure
index 09cb3c5bf43..49a032ef27a 100755
--- a/gdbserver/configure
+++ b/gdbserver/configure
@@ -670,6 +670,9 @@ WIN32APILIBS
LTLIBXXHASH
LIBXXHASH
HAVE_LIBXXHASH
+LTLIBWINIPT
+LIBWINIPT
+HAVE_LIBWINIPT
LTLIBIPT
LIBIPT
HAVE_LIBIPT
@@ -766,6 +769,8 @@ with_gnu_ld
enable_rpath
with_libipt_prefix
with_libipt_type
+with_libwinipt_prefix
+with_libwinipt_type
with_xxhash
with_libxxhash_prefix
with_libxxhash_type
@@ -1441,6 +1446,9 @@ Optional Packages:
--with-libipt-prefix[=DIR] search for libipt in DIR/include and DIR/lib
--without-libipt-prefix don't search for libipt in includedir and libdir
--with-libipt-type=TYPE type of library to search for (auto/static/shared)
+ --with-libwinipt-prefix[=DIR] search for libwinipt in DIR/include and DIR/lib
+ --without-libwinipt-prefix don't search for libwinipt in includedir and libdir
+ --with-libwinipt-type=TYPE type of library to search for (auto/static/shared)
--with-xxhash use libxxhash for hashing (faster) (auto/yes/no)
--with-libxxhash-prefix[=DIR] search for libxxhash in DIR/include and DIR/lib
--without-libxxhash-prefix don't search for libxxhash in includedir and libdir
@@ -10231,6 +10239,487 @@ _ACEOF
fi
LIBS=$save_LIBS
+
+
+
+
+
+
+
+
+
+ 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-libwinipt-prefix was given.
+if test "${with_libwinipt_prefix+set}" = set; then :
+ withval=$with_libwinipt_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-libwinipt-type was given.
+if test "${with_libwinipt_type+set}" = set; then :
+ withval=$with_libwinipt_type; with_libwinipt_type=$withval
+else
+ with_libwinipt_type=auto
+fi
+
+ lib_type=`eval echo \$with_libwinipt_type`
+
+ LIBWINIPT=
+ LTLIBWINIPT=
+ INCWINIPT=
+ rpathdirs=
+ ltrpathdirs=
+ names_already_handled=
+ names_next_round='winipt '
+ 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" || LIBWINIPT="${LIBWINIPT}${LIBWINIPT:+ }$value"
+ eval value=\"\$LTLIB$uppername\"
+ test -z "$value" || LTLIBWINIPT="${LTLIBWINIPT}${LTLIBWINIPT:+ }$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 $LTLIBWINIPT; 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
+ LTLIBWINIPT="${LTLIBWINIPT}${LTLIBWINIPT:+ }-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
+ LIBWINIPT="${LIBWINIPT}${LIBWINIPT:+ }$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
+ LIBWINIPT="${LIBWINIPT}${LIBWINIPT:+ }$found_so"
+ else
+ if test -n "$hardcode_libdir_flag_spec" && test "$hardcode_minus_L" = no; then
+ LIBWINIPT="${LIBWINIPT}${LIBWINIPT:+ }$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 $LIBWINIPT; 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
+ LIBWINIPT="${LIBWINIPT}${LIBWINIPT:+ }-L$found_dir"
+ fi
+ if test "$hardcode_minus_L" != no; then
+ LIBWINIPT="${LIBWINIPT}${LIBWINIPT:+ }$found_so"
+ else
+ LIBWINIPT="${LIBWINIPT}${LIBWINIPT:+ }-l$name"
+ fi
+ fi
+ fi
+ fi
+ else
+ if test "X$found_a" != "X"; then
+ LIBWINIPT="${LIBWINIPT}${LIBWINIPT:+ }$found_a"
+ else
+ LIBWINIPT="${LIBWINIPT}${LIBWINIPT:+ }-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 $INCWINIPT; 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
+ INCWINIPT="${INCWINIPT}${INCWINIPT:+ }-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 $LIBWINIPT; 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
+ LIBWINIPT="${LIBWINIPT}${LIBWINIPT:+ }-L$additional_libdir"
+ fi
+ fi
+ haveit=
+ for x in $LDFLAGS $LTLIBWINIPT; 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
+ LTLIBWINIPT="${LTLIBWINIPT}${LTLIBWINIPT:+ }-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$,,'`
+ ;;
+ *)
+ LIBWINIPT="${LIBWINIPT}${LIBWINIPT:+ }$dep"
+ LTLIBWINIPT="${LTLIBWINIPT}${LTLIBWINIPT:+ }$dep"
+ ;;
+ esac
+ done
+ fi
+ else
+ if test "x$lib_type" = "xauto" || test "x$lib_type" = "xshared"; then
+ LIBWINIPT="${LIBWINIPT}${LIBWINIPT:+ }-l$name"
+ LTLIBWINIPT="${LTLIBWINIPT}${LTLIBWINIPT:+ }-l$name"
+ else
+ LIBWINIPT="${LIBWINIPT}${LIBWINIPT:+ }-l:lib$name.$libext"
+ LTLIBWINIPT="${LTLIBWINIPT}${LTLIBWINIPT:+ }-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"
+ LIBWINIPT="${LIBWINIPT}${LIBWINIPT:+ }$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"
+ LIBWINIPT="${LIBWINIPT}${LIBWINIPT:+ }$flag"
+ done
+ fi
+ fi
+ if test "X$ltrpathdirs" != "X"; then
+ for found_dir in $ltrpathdirs; do
+ LTLIBWINIPT="${LTLIBWINIPT}${LTLIBWINIPT:+ }-R$found_dir"
+ done
+ fi
+
+
+ ac_save_CPPFLAGS="$CPPFLAGS"
+
+ for element in $INCWINIPT; 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 libwinipt" >&5
+$as_echo_n "checking for libwinipt... " >&6; }
+if ${ac_cv_libwinipt+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+
+ ac_save_LIBS="$LIBS"
+ LIBS="$LIBS $LIBWINIPT"
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+
+#include <windows.h>
+#include <libipt.h>
+
+int
+main ()
+{
+GetIptBufferVersion (0);
+ ;
+ return 0;
+}
+_ACEOF
+if ac_fn_c_try_link "$LINENO"; then :
+ ac_cv_libwinipt=yes
+else
+ ac_cv_libwinipt=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_libwinipt" >&5
+$as_echo "$ac_cv_libwinipt" >&6; }
+ if test "$ac_cv_libwinipt" = yes; then
+ HAVE_LIBWINIPT=yes
+
+$as_echo "#define HAVE_LIBWINIPT 1" >>confdefs.h
+
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking how to link with libwinipt" >&5
+$as_echo_n "checking how to link with libwinipt... " >&6; }
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $LIBWINIPT" >&5
+$as_echo "$LIBWINIPT" >&6; }
+ else
+ HAVE_LIBWINIPT=no
+ CPPFLAGS="$ac_save_CPPFLAGS"
+ LIBWINIPT=
+ LTLIBWINIPT=
+ fi
+
+
+
+
+
+
fi
fi
diff --git a/gdbsupport/Makefile.in b/gdbsupport/Makefile.in
index db3d6f6b4dd..88fd0dd786d 100644
--- a/gdbsupport/Makefile.in
+++ b/gdbsupport/Makefile.in
@@ -277,6 +277,7 @@ GMSGFMT = @GMSGFMT@
GREP = @GREP@
HAVE_CXX17 = @HAVE_CXX17@
HAVE_LIBIPT = @HAVE_LIBIPT@
+HAVE_LIBWINIPT = @HAVE_LIBWINIPT@
HAVE_LIBXXHASH = @HAVE_LIBXXHASH@
INCINTL = @INCINTL@
INSTALL = @INSTALL@
@@ -295,11 +296,13 @@ LIBINTL_DEP = @LIBINTL_DEP@
LIBIPT = @LIBIPT@
LIBOBJS = @LIBOBJS@
LIBS = @LIBS@
+LIBWINIPT = @LIBWINIPT@
LIBXXHASH = @LIBXXHASH@
LTLIBICONV = @LTLIBICONV@
LTLIBINTL = @LTLIBINTL@
LTLIBIPT = @LTLIBIPT@
LTLIBOBJS = @LTLIBOBJS@
+LTLIBWINIPT = @LTLIBWINIPT@
LTLIBXXHASH = @LTLIBXXHASH@
MAINT = @MAINT@
MAKEINFO = @MAKEINFO@
diff --git a/gdbsupport/common.m4 b/gdbsupport/common.m4
index d89c3aed0fe..d5382419674 100644
--- a/gdbsupport/common.m4
+++ b/gdbsupport/common.m4
@@ -203,6 +203,11 @@ AC_DEFUN([GDB_AC_COMMON], [
AC_CHECK_MEMBERS([struct pt_event.variant.ptwrite], [], [],
[#include <intel-pt.h>])
LIBS=$save_LIBS
+
+ AC_LIB_HAVE_LINKFLAGS([winipt], [], [
+#include <windows.h>
+#include <libipt.h>
+ ], [GetIptBufferVersion (0);])
fi
fi
diff --git a/gdbsupport/config.in b/gdbsupport/config.in
index 8467072752a..f140c4250b8 100644
--- a/gdbsupport/config.in
+++ b/gdbsupport/config.in
@@ -142,6 +142,9 @@
/* Define if you have the ipt library. */
#undef HAVE_LIBIPT
+/* Define if you have the winipt library. */
+#undef HAVE_LIBWINIPT
+
/* Define if you have the xxhash library. */
#undef HAVE_LIBXXHASH
diff --git a/gdbsupport/configure b/gdbsupport/configure
index 02408472771..8cdb6d37fff 100755
--- a/gdbsupport/configure
+++ b/gdbsupport/configure
@@ -635,6 +635,9 @@ SELFTEST_TRUE
LTLIBXXHASH
LIBXXHASH
HAVE_LIBXXHASH
+LTLIBWINIPT
+LIBWINIPT
+HAVE_LIBWINIPT
LTLIBIPT
LIBIPT
HAVE_LIBIPT
@@ -793,6 +796,8 @@ enable_threading
with_intel_pt
with_libipt_prefix
with_libipt_type
+with_libwinipt_prefix
+with_libwinipt_type
with_xxhash
with_libxxhash_prefix
with_libxxhash_type
@@ -1469,6 +1474,9 @@ Optional Packages:
--with-libipt-prefix[=DIR] search for libipt in DIR/include and DIR/lib
--without-libipt-prefix don't search for libipt in includedir and libdir
--with-libipt-type=TYPE type of library to search for (auto/static/shared)
+ --with-libwinipt-prefix[=DIR] search for libwinipt in DIR/include and DIR/lib
+ --without-libwinipt-prefix don't search for libwinipt in includedir and libdir
+ --with-libwinipt-type=TYPE type of library to search for (auto/static/shared)
--with-xxhash use libxxhash for hashing (faster) (auto/yes/no)
--with-libxxhash-prefix[=DIR] search for libxxhash in DIR/include and DIR/lib
--without-libxxhash-prefix don't search for libxxhash in includedir and libdir
@@ -13005,6 +13013,487 @@ _ACEOF
fi
LIBS=$save_LIBS
+
+
+
+
+
+
+
+
+
+ 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-libwinipt-prefix was given.
+if test "${with_libwinipt_prefix+set}" = set; then :
+ withval=$with_libwinipt_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-libwinipt-type was given.
+if test "${with_libwinipt_type+set}" = set; then :
+ withval=$with_libwinipt_type; with_libwinipt_type=$withval
+else
+ with_libwinipt_type=auto
+fi
+
+ lib_type=`eval echo \$with_libwinipt_type`
+
+ LIBWINIPT=
+ LTLIBWINIPT=
+ INCWINIPT=
+ rpathdirs=
+ ltrpathdirs=
+ names_already_handled=
+ names_next_round='winipt '
+ 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" || LIBWINIPT="${LIBWINIPT}${LIBWINIPT:+ }$value"
+ eval value=\"\$LTLIB$uppername\"
+ test -z "$value" || LTLIBWINIPT="${LTLIBWINIPT}${LTLIBWINIPT:+ }$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 $LTLIBWINIPT; 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
+ LTLIBWINIPT="${LTLIBWINIPT}${LTLIBWINIPT:+ }-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
+ LIBWINIPT="${LIBWINIPT}${LIBWINIPT:+ }$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
+ LIBWINIPT="${LIBWINIPT}${LIBWINIPT:+ }$found_so"
+ else
+ if test -n "$hardcode_libdir_flag_spec" && test "$hardcode_minus_L" = no; then
+ LIBWINIPT="${LIBWINIPT}${LIBWINIPT:+ }$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 $LIBWINIPT; 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
+ LIBWINIPT="${LIBWINIPT}${LIBWINIPT:+ }-L$found_dir"
+ fi
+ if test "$hardcode_minus_L" != no; then
+ LIBWINIPT="${LIBWINIPT}${LIBWINIPT:+ }$found_so"
+ else
+ LIBWINIPT="${LIBWINIPT}${LIBWINIPT:+ }-l$name"
+ fi
+ fi
+ fi
+ fi
+ else
+ if test "X$found_a" != "X"; then
+ LIBWINIPT="${LIBWINIPT}${LIBWINIPT:+ }$found_a"
+ else
+ LIBWINIPT="${LIBWINIPT}${LIBWINIPT:+ }-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 $INCWINIPT; 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
+ INCWINIPT="${INCWINIPT}${INCWINIPT:+ }-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 $LIBWINIPT; 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
+ LIBWINIPT="${LIBWINIPT}${LIBWINIPT:+ }-L$additional_libdir"
+ fi
+ fi
+ haveit=
+ for x in $LDFLAGS $LTLIBWINIPT; 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
+ LTLIBWINIPT="${LTLIBWINIPT}${LTLIBWINIPT:+ }-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$,,'`
+ ;;
+ *)
+ LIBWINIPT="${LIBWINIPT}${LIBWINIPT:+ }$dep"
+ LTLIBWINIPT="${LTLIBWINIPT}${LTLIBWINIPT:+ }$dep"
+ ;;
+ esac
+ done
+ fi
+ else
+ if test "x$lib_type" = "xauto" || test "x$lib_type" = "xshared"; then
+ LIBWINIPT="${LIBWINIPT}${LIBWINIPT:+ }-l$name"
+ LTLIBWINIPT="${LTLIBWINIPT}${LTLIBWINIPT:+ }-l$name"
+ else
+ LIBWINIPT="${LIBWINIPT}${LIBWINIPT:+ }-l:lib$name.$libext"
+ LTLIBWINIPT="${LTLIBWINIPT}${LTLIBWINIPT:+ }-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"
+ LIBWINIPT="${LIBWINIPT}${LIBWINIPT:+ }$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"
+ LIBWINIPT="${LIBWINIPT}${LIBWINIPT:+ }$flag"
+ done
+ fi
+ fi
+ if test "X$ltrpathdirs" != "X"; then
+ for found_dir in $ltrpathdirs; do
+ LTLIBWINIPT="${LTLIBWINIPT}${LTLIBWINIPT:+ }-R$found_dir"
+ done
+ fi
+
+
+ ac_save_CPPFLAGS="$CPPFLAGS"
+
+ for element in $INCWINIPT; 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 libwinipt" >&5
+$as_echo_n "checking for libwinipt... " >&6; }
+if ${ac_cv_libwinipt+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+
+ ac_save_LIBS="$LIBS"
+ LIBS="$LIBS $LIBWINIPT"
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+
+#include <windows.h>
+#include <libipt.h>
+
+int
+main ()
+{
+GetIptBufferVersion (0);
+ ;
+ return 0;
+}
+_ACEOF
+if ac_fn_c_try_link "$LINENO"; then :
+ ac_cv_libwinipt=yes
+else
+ ac_cv_libwinipt=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_libwinipt" >&5
+$as_echo "$ac_cv_libwinipt" >&6; }
+ if test "$ac_cv_libwinipt" = yes; then
+ HAVE_LIBWINIPT=yes
+
+$as_echo "#define HAVE_LIBWINIPT 1" >>confdefs.h
+
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking how to link with libwinipt" >&5
+$as_echo_n "checking how to link with libwinipt... " >&6; }
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $LIBWINIPT" >&5
+$as_echo "$LIBWINIPT" >&6; }
+ else
+ HAVE_LIBWINIPT=no
+ CPPFLAGS="$ac_save_CPPFLAGS"
+ LIBWINIPT=
+ LTLIBWINIPT=
+ fi
+
+
+
+
+
+
fi
fi
--
2.35.1
More information about the Gdb-patches
mailing list