mirror of
https://github.com/bminor/binutils-gdb.git
synced 2025-12-05 15:15:42 +00:00
gdb/amd-dbgapi: make get_amd_dbgapi_inferior_info return a reference
This function can't return a NULL pointer, so make it return a reference instead. Change-Id: I0970d6d0757181291b300bd840037a48330a7fbb
This commit is contained in:
@@ -345,15 +345,15 @@ static const registry<inferior>::key<amd_dbgapi_inferior_info>
|
|||||||
|
|
||||||
/* Fetch the amd_dbgapi_inferior_info data for the given inferior. */
|
/* Fetch the amd_dbgapi_inferior_info data for the given inferior. */
|
||||||
|
|
||||||
static struct amd_dbgapi_inferior_info *
|
static amd_dbgapi_inferior_info &
|
||||||
get_amd_dbgapi_inferior_info (struct inferior *inferior)
|
get_amd_dbgapi_inferior_info (inferior *inferior)
|
||||||
{
|
{
|
||||||
amd_dbgapi_inferior_info *info = amd_dbgapi_inferior_data.get (inferior);
|
amd_dbgapi_inferior_info *info = amd_dbgapi_inferior_data.get (inferior);
|
||||||
|
|
||||||
if (info == nullptr)
|
if (info == nullptr)
|
||||||
info = amd_dbgapi_inferior_data.emplace (inferior, inferior);
|
info = amd_dbgapi_inferior_data.emplace (inferior, inferior);
|
||||||
|
|
||||||
return info;
|
return *info;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* The async event handler registered with the event loop, indicating that we
|
/* The async event handler registered with the event loop, indicating that we
|
||||||
@@ -430,11 +430,11 @@ wave_coordinates::fetch ()
|
|||||||
static wave_info &
|
static wave_info &
|
||||||
get_thread_wave_info (thread_info *tp)
|
get_thread_wave_info (thread_info *tp)
|
||||||
{
|
{
|
||||||
amd_dbgapi_inferior_info *info = get_amd_dbgapi_inferior_info (tp->inf);
|
amd_dbgapi_inferior_info &info = get_amd_dbgapi_inferior_info (tp->inf);
|
||||||
amd_dbgapi_wave_id_t wave_id = get_amd_dbgapi_wave_id (tp->ptid);
|
amd_dbgapi_wave_id_t wave_id = get_amd_dbgapi_wave_id (tp->ptid);
|
||||||
|
|
||||||
auto it = info->wave_info_map.find (wave_id.handle);
|
auto it = info.wave_info_map.find (wave_id.handle);
|
||||||
gdb_assert (it != info->wave_info_map.end ());
|
gdb_assert (it != info.wave_info_map.end ());
|
||||||
|
|
||||||
return it->second;
|
return it->second;
|
||||||
}
|
}
|
||||||
@@ -495,10 +495,10 @@ require_forward_progress (ptid_t ptid, process_stratum_target *proc_target,
|
|||||||
if (ptid != minus_one_ptid && inf->pid != ptid.pid ())
|
if (ptid != minus_one_ptid && inf->pid != ptid.pid ())
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
amd_dbgapi_inferior_info *info = get_amd_dbgapi_inferior_info (inf);
|
amd_dbgapi_inferior_info &info = get_amd_dbgapi_inferior_info (inf);
|
||||||
|
|
||||||
if (info->process_id != AMD_DBGAPI_PROCESS_NONE)
|
if (info.process_id != AMD_DBGAPI_PROCESS_NONE)
|
||||||
require_forward_progress (*info, require);
|
require_forward_progress (info, require);
|
||||||
|
|
||||||
/* If ptid targets a single inferior and we have found it, no need to
|
/* If ptid targets a single inferior and we have found it, no need to
|
||||||
continue. */
|
continue. */
|
||||||
@@ -512,7 +512,7 @@ require_forward_progress (ptid_t ptid, process_stratum_target *proc_target,
|
|||||||
amd_dbgapi_process_id_t
|
amd_dbgapi_process_id_t
|
||||||
get_amd_dbgapi_process_id (inferior *inf)
|
get_amd_dbgapi_process_id (inferior *inf)
|
||||||
{
|
{
|
||||||
return get_amd_dbgapi_inferior_info (inf)->process_id;
|
return get_amd_dbgapi_inferior_info (inf).process_id;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* A breakpoint dbgapi wants us to insert, to handle shared library
|
/* A breakpoint dbgapi wants us to insert, to handle shared library
|
||||||
@@ -547,7 +547,7 @@ void
|
|||||||
amd_dbgapi_target_breakpoint::check_status (struct bpstat *bs)
|
amd_dbgapi_target_breakpoint::check_status (struct bpstat *bs)
|
||||||
{
|
{
|
||||||
struct inferior *inf = current_inferior ();
|
struct inferior *inf = current_inferior ();
|
||||||
amd_dbgapi_inferior_info *info = get_amd_dbgapi_inferior_info (inf);
|
amd_dbgapi_inferior_info &info = get_amd_dbgapi_inferior_info (inf);
|
||||||
amd_dbgapi_status_t status;
|
amd_dbgapi_status_t status;
|
||||||
|
|
||||||
bs->stop = 0;
|
bs->stop = 0;
|
||||||
@@ -555,13 +555,13 @@ amd_dbgapi_target_breakpoint::check_status (struct bpstat *bs)
|
|||||||
|
|
||||||
/* Find the address the breakpoint is set at. */
|
/* Find the address the breakpoint is set at. */
|
||||||
auto match_breakpoint
|
auto match_breakpoint
|
||||||
= [bs] (const decltype (info->breakpoint_map)::value_type &value)
|
= [bs] (const decltype (info.breakpoint_map)::value_type &value)
|
||||||
{ return value.second == bs->breakpoint_at; };
|
{ return value.second == bs->breakpoint_at; };
|
||||||
auto it
|
auto it
|
||||||
= std::find_if (info->breakpoint_map.begin (), info->breakpoint_map.end (),
|
= std::find_if (info.breakpoint_map.begin (), info.breakpoint_map.end (),
|
||||||
match_breakpoint);
|
match_breakpoint);
|
||||||
|
|
||||||
if (it == info->breakpoint_map.end ())
|
if (it == info.breakpoint_map.end ())
|
||||||
error (_("Could not find breakpoint_id for breakpoint at %s"),
|
error (_("Could not find breakpoint_id for breakpoint at %s"),
|
||||||
paddress (inf->arch (), bs->bp_location_at->address));
|
paddress (inf->arch (), bs->bp_location_at->address));
|
||||||
|
|
||||||
@@ -582,12 +582,12 @@ amd_dbgapi_target_breakpoint::check_status (struct bpstat *bs)
|
|||||||
if (action == AMD_DBGAPI_BREAKPOINT_ACTION_RESUME)
|
if (action == AMD_DBGAPI_BREAKPOINT_ACTION_RESUME)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
require_forward_progress (*info, false);
|
require_forward_progress (info, false);
|
||||||
|
|
||||||
/* If the action is AMD_DBGAPI_BREAKPOINT_ACTION_HALT, we need to wait until
|
/* If the action is AMD_DBGAPI_BREAKPOINT_ACTION_HALT, we need to wait until
|
||||||
a breakpoint resume event for this breakpoint_id is seen. */
|
a breakpoint resume event for this breakpoint_id is seen. */
|
||||||
amd_dbgapi_event_id_t resume_event_id
|
amd_dbgapi_event_id_t resume_event_id
|
||||||
= process_event_queue (*info, AMD_DBGAPI_EVENT_KIND_BREAKPOINT_RESUME);
|
= process_event_queue (info, AMD_DBGAPI_EVENT_KIND_BREAKPOINT_RESUME);
|
||||||
|
|
||||||
/* We should always get a breakpoint_resume event after processing all
|
/* We should always get a breakpoint_resume event after processing all
|
||||||
events generated by reporting the breakpoint hit. */
|
events generated by reporting the breakpoint hit. */
|
||||||
@@ -647,12 +647,12 @@ amd_dbgapi_target::pid_to_str (ptid_t ptid)
|
|||||||
process_stratum_target *proc_target = current_inferior ()->process_target ();
|
process_stratum_target *proc_target = current_inferior ()->process_target ();
|
||||||
inferior *inf = find_inferior_pid (proc_target, ptid.pid ());
|
inferior *inf = find_inferior_pid (proc_target, ptid.pid ());
|
||||||
gdb_assert (inf != nullptr);
|
gdb_assert (inf != nullptr);
|
||||||
amd_dbgapi_inferior_info *info = get_amd_dbgapi_inferior_info (inf);
|
const amd_dbgapi_inferior_info &info = get_amd_dbgapi_inferior_info (inf);
|
||||||
|
|
||||||
auto wave_id = get_amd_dbgapi_wave_id (ptid);
|
auto wave_id = get_amd_dbgapi_wave_id (ptid);
|
||||||
|
|
||||||
auto it = info->wave_info_map.find (wave_id.handle);
|
auto it = info.wave_info_map.find (wave_id.handle);
|
||||||
if (it != info->wave_info_map.end ())
|
if (it != info.wave_info_map.end ())
|
||||||
return it->second.coords.to_string ();
|
return it->second.coords.to_string ();
|
||||||
|
|
||||||
/* A wave we don't know about. Shouldn't usually happen, but
|
/* A wave we don't know about. Shouldn't usually happen, but
|
||||||
@@ -908,7 +908,7 @@ amd_dbgapi_target::stop (ptid_t ptid)
|
|||||||
|
|
||||||
if (m_report_thread_events)
|
if (m_report_thread_events)
|
||||||
{
|
{
|
||||||
get_amd_dbgapi_inferior_info (thread->inf)->wave_events.emplace_back
|
get_amd_dbgapi_inferior_info (thread->inf).wave_events.emplace_back
|
||||||
(thread->ptid, target_waitstatus ().set_thread_exited (0));
|
(thread->ptid, target_waitstatus ().set_thread_exited (0));
|
||||||
|
|
||||||
if (target_is_async_p ())
|
if (target_is_async_p ())
|
||||||
@@ -976,18 +976,19 @@ private:
|
|||||||
static void
|
static void
|
||||||
dbgapi_notifier_handler (int err, gdb_client_data client_data)
|
dbgapi_notifier_handler (int err, gdb_client_data client_data)
|
||||||
{
|
{
|
||||||
amd_dbgapi_inferior_info *info = (amd_dbgapi_inferior_info *) client_data;
|
amd_dbgapi_inferior_info &info
|
||||||
|
= *static_cast<amd_dbgapi_inferior_info *> (client_data);
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
/* Drain the notifier pipe. */
|
/* Drain the notifier pipe. */
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
char buf;
|
char buf;
|
||||||
ret = read (info->notifier, &buf, 1);
|
ret = read (info.notifier, &buf, 1);
|
||||||
}
|
}
|
||||||
while (ret >= 0 || (ret == -1 && errno == EINTR));
|
while (ret >= 0 || (ret == -1 && errno == EINTR));
|
||||||
|
|
||||||
if (info->inf->target_is_pushed (&the_amd_dbgapi_target))
|
if (info.inf->target_is_pushed (&the_amd_dbgapi_target))
|
||||||
{
|
{
|
||||||
/* The amd-dbgapi target is pushed: signal our async handler, the event
|
/* The amd-dbgapi target is pushed: signal our async handler, the event
|
||||||
will be consumed through our wait method. */
|
will be consumed through our wait method. */
|
||||||
@@ -1004,7 +1005,7 @@ dbgapi_notifier_handler (int err, gdb_client_data client_data)
|
|||||||
amd_dbgapi_event_id_t event_id;
|
amd_dbgapi_event_id_t event_id;
|
||||||
amd_dbgapi_event_kind_t event_kind;
|
amd_dbgapi_event_kind_t event_kind;
|
||||||
amd_dbgapi_status_t status
|
amd_dbgapi_status_t status
|
||||||
= amd_dbgapi_process_next_pending_event (info->process_id, &event_id,
|
= amd_dbgapi_process_next_pending_event (info.process_id, &event_id,
|
||||||
&event_kind);
|
&event_kind);
|
||||||
if (status != AMD_DBGAPI_STATUS_SUCCESS)
|
if (status != AMD_DBGAPI_STATUS_SUCCESS)
|
||||||
error (_("next_pending_event failed (%s)"), get_status_string (status));
|
error (_("next_pending_event failed (%s)"), get_status_string (status));
|
||||||
@@ -1028,17 +1029,17 @@ dbgapi_notifier_handler (int err, gdb_client_data client_data)
|
|||||||
switch (runtime_state)
|
switch (runtime_state)
|
||||||
{
|
{
|
||||||
case AMD_DBGAPI_RUNTIME_STATE_LOADED_SUCCESS:
|
case AMD_DBGAPI_RUNTIME_STATE_LOADED_SUCCESS:
|
||||||
gdb_assert (info->runtime_state == AMD_DBGAPI_RUNTIME_STATE_UNLOADED);
|
gdb_assert (info.runtime_state == AMD_DBGAPI_RUNTIME_STATE_UNLOADED);
|
||||||
info->runtime_state = runtime_state;
|
info.runtime_state = runtime_state;
|
||||||
amd_dbgapi_debug_printf ("pushing amd-dbgapi target");
|
amd_dbgapi_debug_printf ("pushing amd-dbgapi target");
|
||||||
info->inf->push_target (&the_amd_dbgapi_target);
|
info.inf->push_target (&the_amd_dbgapi_target);
|
||||||
|
|
||||||
/* The underlying target will already be async if we are running, but not if
|
/* The underlying target will already be async if we are running, but not if
|
||||||
we are attaching. */
|
we are attaching. */
|
||||||
if (info->inf->process_target ()->is_async_p ())
|
if (info.inf->process_target ()->is_async_p ())
|
||||||
{
|
{
|
||||||
scoped_restore_current_thread restore_thread;
|
scoped_restore_current_thread restore_thread;
|
||||||
switch_to_inferior_no_thread (info->inf);
|
switch_to_inferior_no_thread (info.inf);
|
||||||
|
|
||||||
/* Make sure our async event handler is created. */
|
/* Make sure our async event handler is created. */
|
||||||
target_async (true);
|
target_async (true);
|
||||||
@@ -1046,14 +1047,14 @@ dbgapi_notifier_handler (int err, gdb_client_data client_data)
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case AMD_DBGAPI_RUNTIME_STATE_UNLOADED:
|
case AMD_DBGAPI_RUNTIME_STATE_UNLOADED:
|
||||||
gdb_assert (info->runtime_state
|
gdb_assert (info.runtime_state
|
||||||
== AMD_DBGAPI_RUNTIME_STATE_LOADED_ERROR_RESTRICTION);
|
== AMD_DBGAPI_RUNTIME_STATE_LOADED_ERROR_RESTRICTION);
|
||||||
info->runtime_state = runtime_state;
|
info.runtime_state = runtime_state;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case AMD_DBGAPI_RUNTIME_STATE_LOADED_ERROR_RESTRICTION:
|
case AMD_DBGAPI_RUNTIME_STATE_LOADED_ERROR_RESTRICTION:
|
||||||
gdb_assert (info->runtime_state == AMD_DBGAPI_RUNTIME_STATE_UNLOADED);
|
gdb_assert (info.runtime_state == AMD_DBGAPI_RUNTIME_STATE_UNLOADED);
|
||||||
info->runtime_state = runtime_state;
|
info.runtime_state = runtime_state;
|
||||||
warning (_("amd-dbgapi: unable to enable GPU debugging "
|
warning (_("amd-dbgapi: unable to enable GPU debugging "
|
||||||
"due to a restriction error"));
|
"due to a restriction error"));
|
||||||
break;
|
break;
|
||||||
@@ -1082,10 +1083,10 @@ amd_dbgapi_target::async (bool enable)
|
|||||||
|
|
||||||
for (inferior *inf : all_non_exited_inferiors (proc_target))
|
for (inferior *inf : all_non_exited_inferiors (proc_target))
|
||||||
{
|
{
|
||||||
amd_dbgapi_inferior_info *info = get_amd_dbgapi_inferior_info (inf);
|
amd_dbgapi_inferior_info &info = get_amd_dbgapi_inferior_info (inf);
|
||||||
|
|
||||||
if (info->notifier != -1)
|
if (info.notifier != -1)
|
||||||
add_file_handler (info->notifier, dbgapi_notifier_handler, info,
|
add_file_handler (info.notifier, dbgapi_notifier_handler, &info,
|
||||||
string_printf ("amd-dbgapi notifier for pid %d",
|
string_printf ("amd-dbgapi notifier for pid %d",
|
||||||
inf->pid));
|
inf->pid));
|
||||||
}
|
}
|
||||||
@@ -1105,10 +1106,11 @@ amd_dbgapi_target::async (bool enable)
|
|||||||
|
|
||||||
for (inferior *inf : all_inferiors ())
|
for (inferior *inf : all_inferiors ())
|
||||||
{
|
{
|
||||||
amd_dbgapi_inferior_info *info = get_amd_dbgapi_inferior_info (inf);
|
const amd_dbgapi_inferior_info &info
|
||||||
|
= get_amd_dbgapi_inferior_info (inf);
|
||||||
|
|
||||||
if (info->notifier != -1)
|
if (info.notifier != -1)
|
||||||
delete_file_handler (info->notifier);
|
delete_file_handler (info.notifier);
|
||||||
}
|
}
|
||||||
|
|
||||||
delete_async_event_handler (&amd_dbgapi_async_event_handler);
|
delete_async_event_handler (&amd_dbgapi_async_event_handler);
|
||||||
@@ -1132,11 +1134,11 @@ amd_dbgapi_thread_deleted (thread_info *tp)
|
|||||||
if (tp->inf->target_at (arch_stratum) == &the_amd_dbgapi_target
|
if (tp->inf->target_at (arch_stratum) == &the_amd_dbgapi_target
|
||||||
&& ptid_is_gpu (tp->ptid))
|
&& ptid_is_gpu (tp->ptid))
|
||||||
{
|
{
|
||||||
amd_dbgapi_inferior_info *info = amd_dbgapi_inferior_data.get (tp->inf);
|
amd_dbgapi_inferior_info &info = get_amd_dbgapi_inferior_info (tp->inf);
|
||||||
auto wave_id = get_amd_dbgapi_wave_id (tp->ptid);
|
auto wave_id = get_amd_dbgapi_wave_id (tp->ptid);
|
||||||
auto it = info->wave_info_map.find (wave_id.handle);
|
auto it = info.wave_info_map.find (wave_id.handle);
|
||||||
gdb_assert (it != info->wave_info_map.end ());
|
gdb_assert (it != info.wave_info_map.end ());
|
||||||
info->wave_info_map.erase (it);
|
info.wave_info_map.erase (it);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1147,11 +1149,11 @@ static thread_info *
|
|||||||
add_gpu_thread (inferior *inf, ptid_t wave_ptid)
|
add_gpu_thread (inferior *inf, ptid_t wave_ptid)
|
||||||
{
|
{
|
||||||
process_stratum_target *proc_target = inf->process_target ();
|
process_stratum_target *proc_target = inf->process_target ();
|
||||||
amd_dbgapi_inferior_info *info = get_amd_dbgapi_inferior_info (inf);
|
amd_dbgapi_inferior_info &info = get_amd_dbgapi_inferior_info (inf);
|
||||||
|
|
||||||
auto wave_id = get_amd_dbgapi_wave_id (wave_ptid);
|
auto wave_id = get_amd_dbgapi_wave_id (wave_ptid);
|
||||||
|
|
||||||
if (!info->wave_info_map.try_emplace (wave_id.handle,
|
if (!info.wave_info_map.try_emplace (wave_id.handle,
|
||||||
wave_info (wave_id)).second)
|
wave_info (wave_id)).second)
|
||||||
internal_error ("wave ID %ld already in map", wave_id.handle);
|
internal_error ("wave ID %ld already in map", wave_id.handle);
|
||||||
|
|
||||||
@@ -1399,13 +1401,13 @@ static std::pair<ptid_t, target_waitstatus>
|
|||||||
consume_one_event (int pid)
|
consume_one_event (int pid)
|
||||||
{
|
{
|
||||||
auto *target = current_inferior ()->process_target ();
|
auto *target = current_inferior ()->process_target ();
|
||||||
struct amd_dbgapi_inferior_info *info = nullptr;
|
amd_dbgapi_inferior_info *info = nullptr;
|
||||||
|
|
||||||
if (pid == -1)
|
if (pid == -1)
|
||||||
{
|
{
|
||||||
for (inferior *inf : all_inferiors (target))
|
for (inferior *inf : all_inferiors (target))
|
||||||
{
|
{
|
||||||
info = get_amd_dbgapi_inferior_info (inf);
|
info = &get_amd_dbgapi_inferior_info (inf);
|
||||||
if (!info->wave_events.empty ())
|
if (!info->wave_events.empty ())
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -1417,7 +1419,7 @@ consume_one_event (int pid)
|
|||||||
inferior *inf = find_inferior_pid (target, pid);
|
inferior *inf = find_inferior_pid (target, pid);
|
||||||
|
|
||||||
gdb_assert (inf != nullptr);
|
gdb_assert (inf != nullptr);
|
||||||
info = get_amd_dbgapi_inferior_info (inf);
|
info = &get_amd_dbgapi_inferior_info (inf);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (info->wave_events.empty ())
|
if (info->wave_events.empty ())
|
||||||
@@ -1481,8 +1483,9 @@ amd_dbgapi_target::wait (ptid_t ptid, struct target_waitstatus *ws,
|
|||||||
{
|
{
|
||||||
/* Drain the events for the current inferior from the amd_dbgapi and
|
/* Drain the events for the current inferior from the amd_dbgapi and
|
||||||
preserve the ordering. */
|
preserve the ordering. */
|
||||||
auto info = get_amd_dbgapi_inferior_info (current_inferior ());
|
amd_dbgapi_inferior_info &info
|
||||||
process_event_queue (*info);
|
= get_amd_dbgapi_inferior_info (current_inferior ());
|
||||||
|
process_event_queue (info);
|
||||||
|
|
||||||
std::tie (event_ptid, gpu_waitstatus) = consume_one_event (ptid.pid ());
|
std::tie (event_ptid, gpu_waitstatus) = consume_one_event (ptid.pid ());
|
||||||
if (event_ptid == minus_one_ptid)
|
if (event_ptid == minus_one_ptid)
|
||||||
@@ -1504,7 +1507,7 @@ amd_dbgapi_target::wait (ptid_t ptid, struct target_waitstatus *ws,
|
|||||||
|
|
||||||
for (inferior *inf : all_inferiors ())
|
for (inferior *inf : all_inferiors ())
|
||||||
if (inf->target_at (arch_stratum) == &the_amd_dbgapi_target
|
if (inf->target_at (arch_stratum) == &the_amd_dbgapi_target
|
||||||
&& get_amd_dbgapi_inferior_info (inf)->runtime_state
|
&& get_amd_dbgapi_inferior_info (inf).runtime_state
|
||||||
== AMD_DBGAPI_RUNTIME_STATE_LOADED_SUCCESS)
|
== AMD_DBGAPI_RUNTIME_STATE_LOADED_SUCCESS)
|
||||||
{
|
{
|
||||||
ws->set_ignore ();
|
ws->set_ignore ();
|
||||||
@@ -1605,20 +1608,20 @@ attach_amd_dbgapi (inferior *inf)
|
|||||||
if (inf->vfork_parent != nullptr)
|
if (inf->vfork_parent != nullptr)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
auto *info = get_amd_dbgapi_inferior_info (inf);
|
amd_dbgapi_inferior_info &info = get_amd_dbgapi_inferior_info (inf);
|
||||||
|
|
||||||
/* Are we already attached? */
|
/* Are we already attached? */
|
||||||
if (info->process_id != AMD_DBGAPI_PROCESS_NONE)
|
if (info.process_id != AMD_DBGAPI_PROCESS_NONE)
|
||||||
{
|
{
|
||||||
amd_dbgapi_debug_printf
|
amd_dbgapi_debug_printf
|
||||||
("already attached: process_id = %" PRIu64, info->process_id.handle);
|
("already attached: process_id = %" PRIu64, info.process_id.handle);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
amd_dbgapi_status_t status
|
amd_dbgapi_status_t status
|
||||||
= amd_dbgapi_process_attach
|
= amd_dbgapi_process_attach
|
||||||
(reinterpret_cast<amd_dbgapi_client_process_id_t> (inf),
|
(reinterpret_cast<amd_dbgapi_client_process_id_t> (inf),
|
||||||
&info->process_id);
|
&info.process_id);
|
||||||
if (status == AMD_DBGAPI_STATUS_ERROR_RESTRICTION)
|
if (status == AMD_DBGAPI_STATUS_ERROR_RESTRICTION)
|
||||||
{
|
{
|
||||||
warning (_("amd-dbgapi: unable to enable GPU debugging due to a "
|
warning (_("amd-dbgapi: unable to enable GPU debugging due to a "
|
||||||
@@ -1633,29 +1636,29 @@ attach_amd_dbgapi (inferior *inf)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (amd_dbgapi_process_get_info (info->process_id,
|
if (amd_dbgapi_process_get_info (info.process_id,
|
||||||
AMD_DBGAPI_PROCESS_INFO_NOTIFIER,
|
AMD_DBGAPI_PROCESS_INFO_NOTIFIER,
|
||||||
sizeof (info->notifier), &info->notifier)
|
sizeof (info.notifier), &info.notifier)
|
||||||
!= AMD_DBGAPI_STATUS_SUCCESS)
|
!= AMD_DBGAPI_STATUS_SUCCESS)
|
||||||
{
|
{
|
||||||
amd_dbgapi_process_detach (info->process_id);
|
amd_dbgapi_process_detach (info.process_id);
|
||||||
info->process_id = AMD_DBGAPI_PROCESS_NONE;
|
info.process_id = AMD_DBGAPI_PROCESS_NONE;
|
||||||
warning (_("amd-dbgapi: could not retrieve process %d's notifier, GPU "
|
warning (_("amd-dbgapi: could not retrieve process %d's notifier, GPU "
|
||||||
"debugging will not be available."), inf->pid);
|
"debugging will not be available."), inf->pid);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
amd_dbgapi_debug_printf ("process_id = %" PRIu64 ", notifier fd = %d",
|
amd_dbgapi_debug_printf ("process_id = %" PRIu64 ", notifier fd = %d",
|
||||||
info->process_id.handle, info->notifier);
|
info.process_id.handle, info.notifier);
|
||||||
|
|
||||||
set_process_memory_precision (*info);
|
set_process_memory_precision (info);
|
||||||
|
|
||||||
/* If GDB is attaching to a process that has the runtime loaded, there will
|
/* If GDB is attaching to a process that has the runtime loaded, there will
|
||||||
already be a "runtime loaded" event available. Consume it and push the
|
already be a "runtime loaded" event available. Consume it and push the
|
||||||
target. */
|
target. */
|
||||||
dbgapi_notifier_handler (0, info);
|
dbgapi_notifier_handler (0, &info);
|
||||||
|
|
||||||
add_file_handler (info->notifier, dbgapi_notifier_handler, info,
|
add_file_handler (info.notifier, dbgapi_notifier_handler, &info,
|
||||||
"amd-dbgapi notifier");
|
"amd-dbgapi notifier");
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1672,30 +1675,30 @@ detach_amd_dbgapi (inferior *inf)
|
|||||||
{
|
{
|
||||||
AMD_DBGAPI_SCOPED_DEBUG_START_END ("inf num = %d", inf->num);
|
AMD_DBGAPI_SCOPED_DEBUG_START_END ("inf num = %d", inf->num);
|
||||||
|
|
||||||
auto *info = get_amd_dbgapi_inferior_info (inf);
|
amd_dbgapi_inferior_info &info = get_amd_dbgapi_inferior_info (inf);
|
||||||
|
|
||||||
if (info->process_id == AMD_DBGAPI_PROCESS_NONE)
|
if (info.process_id == AMD_DBGAPI_PROCESS_NONE)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
info->runtime_state = AMD_DBGAPI_RUNTIME_STATE_UNLOADED;
|
info.runtime_state = AMD_DBGAPI_RUNTIME_STATE_UNLOADED;
|
||||||
|
|
||||||
amd_dbgapi_status_t status = amd_dbgapi_process_detach (info->process_id);
|
amd_dbgapi_status_t status = amd_dbgapi_process_detach (info.process_id);
|
||||||
if (status != AMD_DBGAPI_STATUS_SUCCESS)
|
if (status != AMD_DBGAPI_STATUS_SUCCESS)
|
||||||
warning (_("amd-dbgapi: could not detach from process %d (%s)"),
|
warning (_("amd-dbgapi: could not detach from process %d (%s)"),
|
||||||
inf->pid, get_status_string (status));
|
inf->pid, get_status_string (status));
|
||||||
|
|
||||||
gdb_assert (info->notifier != -1);
|
gdb_assert (info.notifier != -1);
|
||||||
delete_file_handler (info->notifier);
|
delete_file_handler (info.notifier);
|
||||||
|
|
||||||
/* This is a noop if the target is not pushed. */
|
/* This is a noop if the target is not pushed. */
|
||||||
inf->unpush_target (&the_amd_dbgapi_target);
|
inf->unpush_target (&the_amd_dbgapi_target);
|
||||||
|
|
||||||
/* Delete the breakpoints that are still active. */
|
/* Delete the breakpoints that are still active. */
|
||||||
for (auto &&value : info->breakpoint_map)
|
for (auto &&value : info.breakpoint_map)
|
||||||
delete_breakpoint (value.second);
|
delete_breakpoint (value.second);
|
||||||
|
|
||||||
/* Reset the amd_dbgapi_inferior_info, except for precise_memory_mode. */
|
/* Reset the amd_dbgapi_inferior_info, except for precise_memory_mode. */
|
||||||
*info = amd_dbgapi_inferior_info (inf, info->precise_memory.requested);
|
info = amd_dbgapi_inferior_info (inf, info.precise_memory.requested);
|
||||||
|
|
||||||
maybe_reset_amd_dbgapi ();
|
maybe_reset_amd_dbgapi ();
|
||||||
}
|
}
|
||||||
@@ -1971,10 +1974,10 @@ amd_dbgapi_target::displaced_step_prepare (thread_info *thread,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Save the displaced stepping id in the per-inferior info. */
|
/* Save the displaced stepping id in the per-inferior info. */
|
||||||
amd_dbgapi_inferior_info *info = get_amd_dbgapi_inferior_info (thread->inf);
|
amd_dbgapi_inferior_info &info = get_amd_dbgapi_inferior_info (thread->inf);
|
||||||
|
|
||||||
bool inserted
|
bool inserted
|
||||||
= info->stepping_id_map.emplace (thread, stepping_id.handle).second;
|
= info.stepping_id_map.emplace (thread, stepping_id.handle).second;
|
||||||
gdb_assert (inserted);
|
gdb_assert (inserted);
|
||||||
|
|
||||||
/* Get the new (displaced) PC. */
|
/* Get the new (displaced) PC. */
|
||||||
@@ -2006,8 +2009,8 @@ amd_dbgapi_target::displaced_step_finish (thread_info *thread,
|
|||||||
gdb_assert (thread->displaced_step_state.in_progress ());
|
gdb_assert (thread->displaced_step_state.in_progress ());
|
||||||
|
|
||||||
/* Find the displaced stepping id for this thread. */
|
/* Find the displaced stepping id for this thread. */
|
||||||
amd_dbgapi_inferior_info *info = get_amd_dbgapi_inferior_info (thread->inf);
|
amd_dbgapi_inferior_info &info = get_amd_dbgapi_inferior_info (thread->inf);
|
||||||
auto entry = info->stepping_id_map.extract (thread);
|
auto entry = info.stepping_id_map.extract (thread);
|
||||||
|
|
||||||
gdb_assert (entry.has_value ());
|
gdb_assert (entry.has_value ());
|
||||||
amd_dbgapi_displaced_stepping_id_t stepping_id {entry->second};
|
amd_dbgapi_displaced_stepping_id_t stepping_id {entry->second};
|
||||||
@@ -2064,14 +2067,16 @@ static void
|
|||||||
amd_dbgapi_target_inferior_cloned (inferior *original_inferior,
|
amd_dbgapi_target_inferior_cloned (inferior *original_inferior,
|
||||||
inferior *new_inferior)
|
inferior *new_inferior)
|
||||||
{
|
{
|
||||||
auto *orig_info = get_amd_dbgapi_inferior_info (original_inferior);
|
const amd_dbgapi_inferior_info &orig_info
|
||||||
auto *new_info = get_amd_dbgapi_inferior_info (new_inferior);
|
= get_amd_dbgapi_inferior_info (original_inferior);
|
||||||
|
amd_dbgapi_inferior_info &new_info
|
||||||
|
= get_amd_dbgapi_inferior_info (new_inferior);
|
||||||
|
|
||||||
/* At this point, the process is not started. Therefore it is sufficient to
|
/* At this point, the process is not started. Therefore it is sufficient to
|
||||||
copy the precise memory request, it will be applied when the process
|
copy the precise memory request, it will be applied when the process
|
||||||
starts. */
|
starts. */
|
||||||
gdb_assert (new_info->process_id == AMD_DBGAPI_PROCESS_NONE);
|
gdb_assert (new_info.process_id == AMD_DBGAPI_PROCESS_NONE);
|
||||||
new_info->precise_memory.requested = orig_info->precise_memory.requested;
|
new_info.precise_memory.requested = orig_info.precise_memory.requested;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* inferior_execd observer. */
|
/* inferior_execd observer. */
|
||||||
@@ -2087,8 +2092,8 @@ amd_dbgapi_inferior_execd (inferior *exec_inf, inferior *follow_inf)
|
|||||||
/* If using "follow-exec-mode new", carry over the precise-memory setting
|
/* If using "follow-exec-mode new", carry over the precise-memory setting
|
||||||
to the new inferior (otherwise, FOLLOW_INF and ORIG_INF point to the same
|
to the new inferior (otherwise, FOLLOW_INF and ORIG_INF point to the same
|
||||||
inferior, so this is a no-op). */
|
inferior, so this is a no-op). */
|
||||||
get_amd_dbgapi_inferior_info (follow_inf)->precise_memory.requested
|
get_amd_dbgapi_inferior_info (follow_inf).precise_memory.requested
|
||||||
= get_amd_dbgapi_inferior_info (exec_inf)->precise_memory.requested;
|
= get_amd_dbgapi_inferior_info (exec_inf).precise_memory.requested;
|
||||||
|
|
||||||
attach_amd_dbgapi (follow_inf);
|
attach_amd_dbgapi (follow_inf);
|
||||||
}
|
}
|
||||||
@@ -2102,12 +2107,12 @@ amd_dbgapi_inferior_forked (inferior *parent_inf, inferior *child_inf,
|
|||||||
if (child_inf != nullptr)
|
if (child_inf != nullptr)
|
||||||
{
|
{
|
||||||
/* Copy precise-memory requested value from parent to child. */
|
/* Copy precise-memory requested value from parent to child. */
|
||||||
amd_dbgapi_inferior_info *parent_info
|
const amd_dbgapi_inferior_info &parent_info
|
||||||
= get_amd_dbgapi_inferior_info (parent_inf);
|
= get_amd_dbgapi_inferior_info (parent_inf);
|
||||||
amd_dbgapi_inferior_info *child_info
|
amd_dbgapi_inferior_info &child_info
|
||||||
= get_amd_dbgapi_inferior_info (child_inf);
|
= get_amd_dbgapi_inferior_info (child_inf);
|
||||||
child_info->precise_memory.requested
|
child_info.precise_memory.requested
|
||||||
= parent_info->precise_memory.requested;
|
= parent_info.precise_memory.requested;
|
||||||
|
|
||||||
if (fork_kind != TARGET_WAITKIND_VFORKED)
|
if (fork_kind != TARGET_WAITKIND_VFORKED)
|
||||||
{
|
{
|
||||||
@@ -2181,10 +2186,10 @@ amd_dbgapi_insert_breakpoint_callback
|
|||||||
amd_dbgapi_breakpoint_id_t breakpoint_id)
|
amd_dbgapi_breakpoint_id_t breakpoint_id)
|
||||||
{
|
{
|
||||||
inferior *inf = reinterpret_cast<inferior *> (client_process_id);
|
inferior *inf = reinterpret_cast<inferior *> (client_process_id);
|
||||||
struct amd_dbgapi_inferior_info *info = get_amd_dbgapi_inferior_info (inf);
|
amd_dbgapi_inferior_info &info = get_amd_dbgapi_inferior_info (inf);
|
||||||
|
|
||||||
auto it = info->breakpoint_map.find (breakpoint_id.handle);
|
auto it = info.breakpoint_map.find (breakpoint_id.handle);
|
||||||
if (it != info->breakpoint_map.end ())
|
if (it != info.breakpoint_map.end ())
|
||||||
return AMD_DBGAPI_STATUS_ERROR_INVALID_BREAKPOINT_ID;
|
return AMD_DBGAPI_STATUS_ERROR_INVALID_BREAKPOINT_ID;
|
||||||
|
|
||||||
/* We need to find the address in the given inferior's program space. */
|
/* We need to find the address in the given inferior's program space. */
|
||||||
@@ -2201,7 +2206,7 @@ amd_dbgapi_insert_breakpoint_callback
|
|||||||
|
|
||||||
breakpoint *bp = install_breakpoint (true, std::move (bp_up), 1);
|
breakpoint *bp = install_breakpoint (true, std::move (bp_up), 1);
|
||||||
|
|
||||||
info->breakpoint_map.emplace (breakpoint_id.handle, bp);
|
info.breakpoint_map.emplace (breakpoint_id.handle, bp);
|
||||||
return AMD_DBGAPI_STATUS_SUCCESS;
|
return AMD_DBGAPI_STATUS_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2213,14 +2218,14 @@ amd_dbgapi_remove_breakpoint_callback
|
|||||||
amd_dbgapi_breakpoint_id_t breakpoint_id)
|
amd_dbgapi_breakpoint_id_t breakpoint_id)
|
||||||
{
|
{
|
||||||
inferior *inf = reinterpret_cast<inferior *> (client_process_id);
|
inferior *inf = reinterpret_cast<inferior *> (client_process_id);
|
||||||
struct amd_dbgapi_inferior_info *info = get_amd_dbgapi_inferior_info (inf);
|
amd_dbgapi_inferior_info &info = get_amd_dbgapi_inferior_info (inf);
|
||||||
|
|
||||||
auto it = info->breakpoint_map.find (breakpoint_id.handle);
|
auto it = info.breakpoint_map.find (breakpoint_id.handle);
|
||||||
if (it == info->breakpoint_map.end ())
|
if (it == info.breakpoint_map.end ())
|
||||||
return AMD_DBGAPI_STATUS_ERROR_INVALID_BREAKPOINT_ID;
|
return AMD_DBGAPI_STATUS_ERROR_INVALID_BREAKPOINT_ID;
|
||||||
|
|
||||||
delete_breakpoint (it->second);
|
delete_breakpoint (it->second);
|
||||||
info->breakpoint_map.erase (it);
|
info.breakpoint_map.erase (it);
|
||||||
|
|
||||||
return AMD_DBGAPI_STATUS_SUCCESS;
|
return AMD_DBGAPI_STATUS_SUCCESS;
|
||||||
}
|
}
|
||||||
@@ -2274,10 +2279,10 @@ amd_dbgapi_xfer_global_memory_callback
|
|||||||
static void
|
static void
|
||||||
amd_dbgapi_target_signal_received (gdb_signal sig)
|
amd_dbgapi_target_signal_received (gdb_signal sig)
|
||||||
{
|
{
|
||||||
amd_dbgapi_inferior_info *info
|
const amd_dbgapi_inferior_info &info
|
||||||
= get_amd_dbgapi_inferior_info (current_inferior ());
|
= get_amd_dbgapi_inferior_info (current_inferior ());
|
||||||
|
|
||||||
if (info->process_id == AMD_DBGAPI_PROCESS_NONE)
|
if (info.process_id == AMD_DBGAPI_PROCESS_NONE)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (!ptid_is_gpu (inferior_thread ()->ptid))
|
if (!ptid_is_gpu (inferior_thread ()->ptid))
|
||||||
@@ -2286,7 +2291,7 @@ amd_dbgapi_target_signal_received (gdb_signal sig)
|
|||||||
if (sig != GDB_SIGNAL_SEGV && sig != GDB_SIGNAL_BUS)
|
if (sig != GDB_SIGNAL_SEGV && sig != GDB_SIGNAL_BUS)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (!info->precise_memory.enabled)
|
if (!info.precise_memory.enabled)
|
||||||
gdb_printf (_("\
|
gdb_printf (_("\
|
||||||
Warning: precise memory violation signal reporting is not enabled, reported\n\
|
Warning: precise memory violation signal reporting is not enabled, reported\n\
|
||||||
location may not be accurate. See \"show amdgpu precise-memory\".\n"));
|
location may not be accurate. See \"show amdgpu precise-memory\".\n"));
|
||||||
@@ -2367,14 +2372,14 @@ static void
|
|||||||
show_precise_memory_mode (struct ui_file *file, int from_tty,
|
show_precise_memory_mode (struct ui_file *file, int from_tty,
|
||||||
struct cmd_list_element *c, const char *value)
|
struct cmd_list_element *c, const char *value)
|
||||||
{
|
{
|
||||||
amd_dbgapi_inferior_info *info
|
const amd_dbgapi_inferior_info &info
|
||||||
= get_amd_dbgapi_inferior_info (current_inferior ());
|
= get_amd_dbgapi_inferior_info (current_inferior ());
|
||||||
|
|
||||||
gdb_printf (file,
|
gdb_printf (file,
|
||||||
_("AMDGPU precise memory access reporting is %s "
|
_("AMDGPU precise memory access reporting is %s "
|
||||||
"(currently %s).\n"),
|
"(currently %s).\n"),
|
||||||
info->precise_memory.requested ? "on" : "off",
|
info.precise_memory.requested ? "on" : "off",
|
||||||
info->precise_memory.enabled ? "enabled" : "disabled");
|
info.precise_memory.enabled ? "enabled" : "disabled");
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Callback for "set amdgpu precise-memory". */
|
/* Callback for "set amdgpu precise-memory". */
|
||||||
@@ -2382,13 +2387,13 @@ show_precise_memory_mode (struct ui_file *file, int from_tty,
|
|||||||
static void
|
static void
|
||||||
set_precise_memory_mode (bool value)
|
set_precise_memory_mode (bool value)
|
||||||
{
|
{
|
||||||
amd_dbgapi_inferior_info *info
|
amd_dbgapi_inferior_info &info
|
||||||
= get_amd_dbgapi_inferior_info (current_inferior ());
|
= get_amd_dbgapi_inferior_info (current_inferior ());
|
||||||
|
|
||||||
info->precise_memory.requested = value;
|
info.precise_memory.requested = value;
|
||||||
|
|
||||||
if (info->process_id != AMD_DBGAPI_PROCESS_NONE)
|
if (info.process_id != AMD_DBGAPI_PROCESS_NONE)
|
||||||
set_process_memory_precision (*info);
|
set_process_memory_precision (info);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Return whether precise-memory is requested for the current inferior. */
|
/* Return whether precise-memory is requested for the current inferior. */
|
||||||
@@ -2396,10 +2401,10 @@ set_precise_memory_mode (bool value)
|
|||||||
static bool
|
static bool
|
||||||
get_precise_memory_mode ()
|
get_precise_memory_mode ()
|
||||||
{
|
{
|
||||||
amd_dbgapi_inferior_info *info
|
const amd_dbgapi_inferior_info &info
|
||||||
= get_amd_dbgapi_inferior_info (current_inferior ());
|
= get_amd_dbgapi_inferior_info (current_inferior ());
|
||||||
|
|
||||||
return info->precise_memory.requested;
|
return info.precise_memory.requested;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* List of set/show amdgpu commands. */
|
/* List of set/show amdgpu commands. */
|
||||||
@@ -2472,9 +2477,9 @@ maybe_reset_amd_dbgapi ()
|
|||||||
{
|
{
|
||||||
for (inferior *inf : all_non_exited_inferiors ())
|
for (inferior *inf : all_non_exited_inferiors ())
|
||||||
{
|
{
|
||||||
amd_dbgapi_inferior_info *info = get_amd_dbgapi_inferior_info (inf);
|
const amd_dbgapi_inferior_info &info = get_amd_dbgapi_inferior_info (inf);
|
||||||
|
|
||||||
if (info->process_id != AMD_DBGAPI_PROCESS_NONE)
|
if (info.process_id != AMD_DBGAPI_PROCESS_NONE)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user