amd64-nat.h \
amd64-ravenscar-thread.h \
amd64-tdep.h \
+ amd-dbgapi-hdep.h \
amd-dbgapi-target.h \
amdgpu-tdep.h \
annotate.h \
alpha-netbsd-tdep.c \
alpha-obsd-tdep.c \
alpha-tdep.c \
+ amd-dbgapi-posix-hdep.c \
amd-dbgapi-target.c \
amd64-bsd-nat.c \
amd64-darwin-tdep.c \
--- /dev/null
+/* Host dependent utilities used by the amd-dbgapi target.
+
+ Copyright (C) 2024-2026 Free Software Foundation, Inc.
+
+ This file is part of GDB.
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>. */
+
+#ifndef GDB_AMD_DBGAPI_HDEP_H
+#define GDB_AMD_DBGAPI_HDEP_H
+
+#include <amd-dbgapi/amd-dbgapi.h>
+
+/* Null amd_dbgapi_notifier_t. */
+extern const amd_dbgapi_notifier_t null_amd_dbgapi_notifier;
+
+/* Clear the notifier. */
+extern void amd_dbgapi_notifier_clear (amd_dbgapi_notifier_t notifier);
+
+/* Get the file descriptor associated with the notifier. */
+extern int amd_dbgapi_notifier_get_fd (amd_dbgapi_notifier_t notifier);
+
+#endif /* GDB_AMD_DBGAPI_HDEP_H */
--- /dev/null
+/* Host dependent utilities for the amd-dbgapi target on POSIX.
+
+ Copyright (C) 2019-2026 Free Software Foundation, Inc.
+
+ This file is part of GDB.
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>. */
+
+#include "amd-dbgapi-hdep.h"
+#include <amd-dbgapi/amd-dbgapi.h>
+
+/* See amd-dbgapi-hdep.h. */
+const amd_dbgapi_notifier_t null_amd_dbgapi_notifier = -1;
+
+/* See amd-dbgapi-hdep.h. */
+
+void
+amd_dbgapi_notifier_clear (amd_dbgapi_notifier_t notifier)
+{
+ int ret;
+
+ /* Drain the notifier pipe. */
+ do
+ {
+ char buf;
+ ret = read (notifier, &buf, 1);
+ }
+ while (ret >= 0 || (ret == -1 && errno == EINTR));
+}
+
+/* See amd-dbgapi-hdep.h. */
+
+int
+amd_dbgapi_notifier_get_fd (amd_dbgapi_notifier_t notifier)
+{
+ return notifier;
+}
#include "amd-dbgapi-target.h"
+#include "amd-dbgapi-hdep.h"
#include "amdgpu-tdep.h"
#include "async-event.h"
#include "breakpoint.h"
amd_dbgapi_process_id_t process_id = AMD_DBGAPI_PROCESS_NONE;
/* The amd_dbgapi_notifier_t for this inferior. */
- amd_dbgapi_notifier_t notifier = -1;
+ amd_dbgapi_notifier_t notifier = null_amd_dbgapi_notifier;
/* The status of the inferior's runtime support. */
amd_dbgapi_runtime_state_t runtime_state = AMD_DBGAPI_RUNTIME_STATE_UNLOADED;
{
amd_dbgapi_inferior_info &info
= *static_cast<amd_dbgapi_inferior_info *> (client_data);
- int ret;
- /* Drain the notifier pipe. */
- do
- {
- char buf;
- ret = read (info.notifier, &buf, 1);
- }
- while (ret >= 0 || (ret == -1 && errno == EINTR));
+ amd_dbgapi_notifier_clear (info.notifier);
if (info.inf->target_is_pushed (&the_amd_dbgapi_target))
{
{
amd_dbgapi_inferior_info &info = get_amd_dbgapi_inferior_info (inf);
- if (info.notifier != -1)
- add_file_handler (info.notifier, dbgapi_notifier_handler, &info,
+ if (info.notifier != null_amd_dbgapi_notifier)
+ add_file_handler (amd_dbgapi_notifier_get_fd (info.notifier),
+ dbgapi_notifier_handler, &info,
string_printf ("amd-dbgapi notifier for pid %d",
inf->pid));
}
const amd_dbgapi_inferior_info &info
= get_amd_dbgapi_inferior_info (inf);
- if (info.notifier != -1)
- delete_file_handler (info.notifier);
+ if (info.notifier != null_amd_dbgapi_notifier)
+ delete_file_handler (amd_dbgapi_notifier_get_fd (info.notifier));
}
delete_async_event_handler (&amd_dbgapi_async_event_handler);
}
amd_dbgapi_debug_printf ("process_id = %" PRIu64 ", notifier fd = %d",
- info.process_id.handle, info.notifier);
+ info.process_id.handle,
+ amd_dbgapi_notifier_get_fd (info.notifier));
set_process_memory_precision (info);
target. */
dbgapi_notifier_handler (0, &info);
- add_file_handler (info.notifier, dbgapi_notifier_handler, &info,
- "amd-dbgapi notifier");
+ add_file_handler (amd_dbgapi_notifier_get_fd (info.notifier),
+ dbgapi_notifier_handler, &info, "amd-dbgapi notifier");
}
static void maybe_reset_amd_dbgapi ();
warning (_("amd-dbgapi: could not detach from process %d (%s)"),
inf->pid, get_status_string (status));
- gdb_assert (info.notifier != -1);
- delete_file_handler (info.notifier);
+ gdb_assert (info.notifier != null_amd_dbgapi_notifier);
+ delete_file_handler (amd_dbgapi_notifier_get_fd (info.notifier));
/* This is a noop if the target is not pushed. */
inf->unpush_target (&the_amd_dbgapi_target);
if test "$all_targets" = true; then
TARGET_OBS="$TARGET_OBS \$(ALL_AMD_DBGAPI_TARGET_OBS)"
fi
+
+ # Add the host-specific objects.
+ case ${gdb_host} in
+ *linux*)
+ gdb_host_obs="${gdb_host_obs} amd-dbgapi-posix-hdep.o"
+ ;;
+ *)
+ as_fn_error $? "amd-dbgapi not supported for host ${gdb_host}" "$LINENO" 5
+ ;;
+ esac
elif test "$gdb_require_amd_dbgapi" = true -o "$with_amd_dbgapi" = yes; then
# amd-dbgapi was not found and...
#
if test "$all_targets" = true; then
TARGET_OBS="$TARGET_OBS \$(ALL_AMD_DBGAPI_TARGET_OBS)"
fi
+
+ # Add the host-specific objects.
+ case ${gdb_host} in
+ *linux*)
+ gdb_host_obs="${gdb_host_obs} amd-dbgapi-posix-hdep.o"
+ ;;
+ *)
+ AC_MSG_ERROR([amd-dbgapi not supported for host ${gdb_host}])
+ ;;
+ esac
elif test "$gdb_require_amd_dbgapi" = true -o "$with_amd_dbgapi" = yes; then
# amd-dbgapi was not found and...
#