switch (signo)
{
case GDB_SIGNAL_BUS:
- exception = AMD_DBGAPI_EXCEPTION_WAVE_APERTURE_VIOLATION;
+ exception = AMD_DBGAPI_EXCEPTION_WAVE_ADDRESS_ERROR;
break;
case GDB_SIGNAL_SEGV:
exception = AMD_DBGAPI_EXCEPTION_WAVE_MEMORY_VIOLATION;
ws.set_thread_exited (0);
else if (status == AMD_DBGAPI_STATUS_SUCCESS)
{
- if (stop_reason & AMD_DBGAPI_WAVE_STOP_REASON_APERTURE_VIOLATION)
+ if (stop_reason & AMD_DBGAPI_WAVE_STOP_REASON_ADDRESS_ERROR)
ws.set_stopped (GDB_SIGNAL_BUS);
else if (stop_reason
& AMD_DBGAPI_WAVE_STOP_REASON_MEMORY_VIOLATION)
detach_amd_dbgapi (inf);
}
-/* get_os_pid callback. */
+/* client_process_get_info callback. */
static amd_dbgapi_status_t
-amd_dbgapi_get_os_pid_callback
- (amd_dbgapi_client_process_id_t client_process_id, pid_t *pid)
+amd_dbgapi_client_process_get_info_callback
+ (amd_dbgapi_client_process_id_t client_process_id,
+ amd_dbgapi_client_process_info_t query, size_t value_size, void *value)
{
inferior *inf = reinterpret_cast<inferior *> (client_process_id);
if (inf->pid == 0)
return AMD_DBGAPI_STATUS_ERROR_PROCESS_EXITED;
- *pid = inf->pid;
- return AMD_DBGAPI_STATUS_SUCCESS;
+ if (value == nullptr)
+ return AMD_DBGAPI_STATUS_ERROR_INVALID_ARGUMENT;
+
+ switch (query)
+ {
+ case AMD_DBGAPI_CLIENT_PROCESS_INFO_OS_PID:
+ if (value_size != sizeof (amd_dbgapi_os_process_id_t))
+ return AMD_DBGAPI_STATUS_ERROR_INVALID_ARGUMENT_COMPATIBILITY;
+
+ *static_cast<amd_dbgapi_os_process_id_t *> (value) = inf->pid;
+ return AMD_DBGAPI_STATUS_SUCCESS;
+
+ case AMD_DBGAPI_CLIENT_PROCESS_INFO_CORE_STATE:
+ return AMD_DBGAPI_STATUS_ERROR_NOT_AVAILABLE;
+ }
+
+ return AMD_DBGAPI_STATUS_ERROR_INVALID_ARGUMENT;
}
/* insert_breakpoint callback. */
return AMD_DBGAPI_STATUS_SUCCESS;
}
+/* xfer_global_memory callback. */
+
+static amd_dbgapi_status_t
+amd_dbgapi_xfer_global_memory_callback
+ (amd_dbgapi_client_process_id_t client_process_id,
+ amd_dbgapi_global_address_t global_address,
+ amd_dbgapi_size_t *value_size, void *read_buffer,
+ const void *write_buffer)
+{
+ if ((read_buffer != nullptr) == (write_buffer != nullptr))
+ return AMD_DBGAPI_STATUS_ERROR_INVALID_ARGUMENT_COMPATIBILITY;
+
+ inferior *inf = reinterpret_cast<inferior *> (client_process_id);
+
+ /* We need to set inferior_ptid / current_inferior as those are
+ used by the target which will process the xfer_partial request.
+
+ Note that we end up here when amd-dbgapi tries to access device memory or
+ register content which are at this point mapped/saved in the host process
+ memory. As a consequence, unwinding GPU frames will most likely call into
+ here. If we used switch_to_thread to select a host thread, this would
+ implicitly call reinit_frame_cache. We do not want to clear the frame
+ cache while trying to build it. */
+ scoped_restore save_inferior_ptid = make_scoped_restore (&inferior_ptid);
+ scoped_restore_current_inferior restore_current_inferior;
+ scoped_restore_current_program_space restore_program_space;
+ inferior_ptid = ptid_t (inf->pid);
+ set_current_inferior (inf);
+ set_current_program_space (inf->pspace);
+
+ target_xfer_status status
+ = target_xfer_partial (inf->top_target (), TARGET_OBJECT_RAW_MEMORY,
+ nullptr, static_cast<gdb_byte *> (read_buffer),
+ static_cast<const gdb_byte *> (write_buffer),
+ global_address, *value_size, value_size);
+
+ if (status == TARGET_XFER_EOF)
+ return AMD_DBGAPI_STATUS_ERROR_PROCESS_EXITED;
+ else if (status != TARGET_XFER_OK)
+ return AMD_DBGAPI_STATUS_ERROR_MEMORY_ACCESS;
+
+ return AMD_DBGAPI_STATUS_SUCCESS;
+}
+
/* signal_received observer. */
static void
static amd_dbgapi_callbacks_t dbgapi_callbacks = {
.allocate_memory = malloc,
.deallocate_memory = free,
- .get_os_pid = amd_dbgapi_get_os_pid_callback,
+ .client_process_get_info = amd_dbgapi_client_process_get_info_callback,
.insert_breakpoint = amd_dbgapi_insert_breakpoint_callback,
.remove_breakpoint = amd_dbgapi_remove_breakpoint_callback,
+ .xfer_global_memory = amd_dbgapi_xfer_global_memory_callback,
.log_message = amd_dbgapi_log_message_callback,
};
# version of the library.
pkg_failed=no
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for amd-dbgapi >= 0.68.0" >&5
-$as_echo_n "checking for amd-dbgapi >= 0.68.0... " >&6; }
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for amd-dbgapi >= 0.75.0" >&5
+$as_echo_n "checking for amd-dbgapi >= 0.75.0... " >&6; }
if test -n "$AMD_DBGAPI_CFLAGS"; then
pkg_cv_AMD_DBGAPI_CFLAGS="$AMD_DBGAPI_CFLAGS"
elif test -n "$PKG_CONFIG"; then
if test -n "$PKG_CONFIG" && \
- { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"amd-dbgapi >= 0.68.0\""; } >&5
- ($PKG_CONFIG --exists --print-errors "amd-dbgapi >= 0.68.0") 2>&5
+ { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"amd-dbgapi >= 0.75.0\""; } >&5
+ ($PKG_CONFIG --exists --print-errors "amd-dbgapi >= 0.75.0") 2>&5
ac_status=$?
$as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
test $ac_status = 0; }; then
- pkg_cv_AMD_DBGAPI_CFLAGS=`$PKG_CONFIG --cflags "amd-dbgapi >= 0.68.0" 2>/dev/null`
+ pkg_cv_AMD_DBGAPI_CFLAGS=`$PKG_CONFIG --cflags "amd-dbgapi >= 0.75.0" 2>/dev/null`
test "x$?" != "x0" && pkg_failed=yes
else
pkg_failed=yes
pkg_cv_AMD_DBGAPI_LIBS="$AMD_DBGAPI_LIBS"
elif test -n "$PKG_CONFIG"; then
if test -n "$PKG_CONFIG" && \
- { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"amd-dbgapi >= 0.68.0\""; } >&5
- ($PKG_CONFIG --exists --print-errors "amd-dbgapi >= 0.68.0") 2>&5
+ { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"amd-dbgapi >= 0.75.0\""; } >&5
+ ($PKG_CONFIG --exists --print-errors "amd-dbgapi >= 0.75.0") 2>&5
ac_status=$?
$as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
test $ac_status = 0; }; then
- pkg_cv_AMD_DBGAPI_LIBS=`$PKG_CONFIG --libs "amd-dbgapi >= 0.68.0" 2>/dev/null`
+ pkg_cv_AMD_DBGAPI_LIBS=`$PKG_CONFIG --libs "amd-dbgapi >= 0.75.0" 2>/dev/null`
test "x$?" != "x0" && pkg_failed=yes
else
pkg_failed=yes
_pkg_short_errors_supported=no
fi
if test $_pkg_short_errors_supported = yes; then
- AMD_DBGAPI_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors --cflags --libs "amd-dbgapi >= 0.68.0" 2>&1`
+ AMD_DBGAPI_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors --cflags --libs "amd-dbgapi >= 0.75.0" 2>&1`
else
- AMD_DBGAPI_PKG_ERRORS=`$PKG_CONFIG --print-errors --cflags --libs "amd-dbgapi >= 0.68.0" 2>&1`
+ AMD_DBGAPI_PKG_ERRORS=`$PKG_CONFIG --print-errors --cflags --libs "amd-dbgapi >= 0.75.0" 2>&1`
fi
# Put the nasty error message in config.log where it belongs
echo "$AMD_DBGAPI_PKG_ERRORS" >&5