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. */
|
||||
|
||||
static struct amd_dbgapi_inferior_info *
|
||||
get_amd_dbgapi_inferior_info (struct inferior *inferior)
|
||||
static amd_dbgapi_inferior_info &
|
||||
get_amd_dbgapi_inferior_info (inferior *inferior)
|
||||
{
|
||||
amd_dbgapi_inferior_info *info = amd_dbgapi_inferior_data.get (inferior);
|
||||
|
||||
if (info == nullptr)
|
||||
info = amd_dbgapi_inferior_data.emplace (inferior, inferior);
|
||||
|
||||
return info;
|
||||
return *info;
|
||||
}
|
||||
|
||||
/* The async event handler registered with the event loop, indicating that we
|
||||
@@ -430,11 +430,11 @@ wave_coordinates::fetch ()
|
||||
static wave_info &
|
||||
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);
|
||||
|
||||
auto it = info->wave_info_map.find (wave_id.handle);
|
||||
gdb_assert (it != info->wave_info_map.end ());
|
||||
auto it = info.wave_info_map.find (wave_id.handle);
|
||||
gdb_assert (it != info.wave_info_map.end ());
|
||||
|
||||
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 ())
|
||||
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)
|
||||
require_forward_progress (*info, require);
|
||||
if (info.process_id != AMD_DBGAPI_PROCESS_NONE)
|
||||
require_forward_progress (info, require);
|
||||
|
||||
/* If ptid targets a single inferior and we have found it, no need to
|
||||
continue. */
|
||||
@@ -512,7 +512,7 @@ require_forward_progress (ptid_t ptid, process_stratum_target *proc_target,
|
||||
amd_dbgapi_process_id_t
|
||||
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
|
||||
@@ -547,7 +547,7 @@ void
|
||||
amd_dbgapi_target_breakpoint::check_status (struct bpstat *bs)
|
||||
{
|
||||
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;
|
||||
|
||||
bs->stop = 0;
|
||||
@@ -555,13 +555,13 @@ amd_dbgapi_target_breakpoint::check_status (struct bpstat *bs)
|
||||
|
||||
/* Find the address the breakpoint is set at. */
|
||||
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; };
|
||||
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);
|
||||
|
||||
if (it == info->breakpoint_map.end ())
|
||||
if (it == info.breakpoint_map.end ())
|
||||
error (_("Could not find breakpoint_id for breakpoint at %s"),
|
||||
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)
|
||||
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
|
||||
a breakpoint resume event for this breakpoint_id is seen. */
|
||||
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
|
||||
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 ();
|
||||
inferior *inf = find_inferior_pid (proc_target, ptid.pid ());
|
||||
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 it = info->wave_info_map.find (wave_id.handle);
|
||||
if (it != info->wave_info_map.end ())
|
||||
auto it = info.wave_info_map.find (wave_id.handle);
|
||||
if (it != info.wave_info_map.end ())
|
||||
return it->second.coords.to_string ();
|
||||
|
||||
/* 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)
|
||||
{
|
||||
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));
|
||||
|
||||
if (target_is_async_p ())
|
||||
@@ -976,18 +976,19 @@ private:
|
||||
static void
|
||||
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;
|
||||
|
||||
/* Drain the notifier pipe. */
|
||||
do
|
||||
{
|
||||
char buf;
|
||||
ret = read (info->notifier, &buf, 1);
|
||||
ret = read (info.notifier, &buf, 1);
|
||||
}
|
||||
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
|
||||
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_kind_t event_kind;
|
||||
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);
|
||||
if (status != AMD_DBGAPI_STATUS_SUCCESS)
|
||||
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)
|
||||
{
|
||||
case AMD_DBGAPI_RUNTIME_STATE_LOADED_SUCCESS:
|
||||
gdb_assert (info->runtime_state == AMD_DBGAPI_RUNTIME_STATE_UNLOADED);
|
||||
info->runtime_state = runtime_state;
|
||||
gdb_assert (info.runtime_state == AMD_DBGAPI_RUNTIME_STATE_UNLOADED);
|
||||
info.runtime_state = runtime_state;
|
||||
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
|
||||
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;
|
||||
switch_to_inferior_no_thread (info->inf);
|
||||
switch_to_inferior_no_thread (info.inf);
|
||||
|
||||
/* Make sure our async event handler is created. */
|
||||
target_async (true);
|
||||
@@ -1046,14 +1047,14 @@ dbgapi_notifier_handler (int err, gdb_client_data client_data)
|
||||
break;
|
||||
|
||||
case AMD_DBGAPI_RUNTIME_STATE_UNLOADED:
|
||||
gdb_assert (info->runtime_state
|
||||
gdb_assert (info.runtime_state
|
||||
== AMD_DBGAPI_RUNTIME_STATE_LOADED_ERROR_RESTRICTION);
|
||||
info->runtime_state = runtime_state;
|
||||
info.runtime_state = runtime_state;
|
||||
break;
|
||||
|
||||
case AMD_DBGAPI_RUNTIME_STATE_LOADED_ERROR_RESTRICTION:
|
||||
gdb_assert (info->runtime_state == AMD_DBGAPI_RUNTIME_STATE_UNLOADED);
|
||||
info->runtime_state = runtime_state;
|
||||
gdb_assert (info.runtime_state == AMD_DBGAPI_RUNTIME_STATE_UNLOADED);
|
||||
info.runtime_state = runtime_state;
|
||||
warning (_("amd-dbgapi: unable to enable GPU debugging "
|
||||
"due to a restriction error"));
|
||||
break;
|
||||
@@ -1082,10 +1083,10 @@ amd_dbgapi_target::async (bool enable)
|
||||
|
||||
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)
|
||||
add_file_handler (info->notifier, dbgapi_notifier_handler, info,
|
||||
if (info.notifier != -1)
|
||||
add_file_handler (info.notifier, dbgapi_notifier_handler, &info,
|
||||
string_printf ("amd-dbgapi notifier for pid %d",
|
||||
inf->pid));
|
||||
}
|
||||
@@ -1105,10 +1106,11 @@ amd_dbgapi_target::async (bool enable)
|
||||
|
||||
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)
|
||||
delete_file_handler (info->notifier);
|
||||
if (info.notifier != -1)
|
||||
delete_file_handler (info.notifier);
|
||||
}
|
||||
|
||||
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
|
||||
&& 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 it = info->wave_info_map.find (wave_id.handle);
|
||||
gdb_assert (it != info->wave_info_map.end ());
|
||||
info->wave_info_map.erase (it);
|
||||
auto it = info.wave_info_map.find (wave_id.handle);
|
||||
gdb_assert (it != info.wave_info_map.end ());
|
||||
info.wave_info_map.erase (it);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1147,11 +1149,11 @@ static thread_info *
|
||||
add_gpu_thread (inferior *inf, ptid_t wave_ptid)
|
||||
{
|
||||
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);
|
||||
|
||||
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)
|
||||
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)
|
||||
{
|
||||
auto *target = current_inferior ()->process_target ();
|
||||
struct amd_dbgapi_inferior_info *info = nullptr;
|
||||
amd_dbgapi_inferior_info *info = nullptr;
|
||||
|
||||
if (pid == -1)
|
||||
{
|
||||
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 ())
|
||||
break;
|
||||
}
|
||||
@@ -1417,7 +1419,7 @@ consume_one_event (int pid)
|
||||
inferior *inf = find_inferior_pid (target, pid);
|
||||
|
||||
gdb_assert (inf != nullptr);
|
||||
info = get_amd_dbgapi_inferior_info (inf);
|
||||
info = &get_amd_dbgapi_inferior_info (inf);
|
||||
}
|
||||
|
||||
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
|
||||
preserve the ordering. */
|
||||
auto info = get_amd_dbgapi_inferior_info (current_inferior ());
|
||||
process_event_queue (*info);
|
||||
amd_dbgapi_inferior_info &info
|
||||
= get_amd_dbgapi_inferior_info (current_inferior ());
|
||||
process_event_queue (info);
|
||||
|
||||
std::tie (event_ptid, gpu_waitstatus) = consume_one_event (ptid.pid ());
|
||||
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 ())
|
||||
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)
|
||||
{
|
||||
ws->set_ignore ();
|
||||
@@ -1605,20 +1608,20 @@ attach_amd_dbgapi (inferior *inf)
|
||||
if (inf->vfork_parent != nullptr)
|
||||
return;
|
||||
|
||||
auto *info = get_amd_dbgapi_inferior_info (inf);
|
||||
amd_dbgapi_inferior_info &info = get_amd_dbgapi_inferior_info (inf);
|
||||
|
||||
/* Are we already attached? */
|
||||
if (info->process_id != AMD_DBGAPI_PROCESS_NONE)
|
||||
if (info.process_id != AMD_DBGAPI_PROCESS_NONE)
|
||||
{
|
||||
amd_dbgapi_debug_printf
|
||||
("already attached: process_id = %" PRIu64, info->process_id.handle);
|
||||
("already attached: process_id = %" PRIu64, info.process_id.handle);
|
||||
return;
|
||||
}
|
||||
|
||||
amd_dbgapi_status_t status
|
||||
= amd_dbgapi_process_attach
|
||||
(reinterpret_cast<amd_dbgapi_client_process_id_t> (inf),
|
||||
&info->process_id);
|
||||
&info.process_id);
|
||||
if (status == AMD_DBGAPI_STATUS_ERROR_RESTRICTION)
|
||||
{
|
||||
warning (_("amd-dbgapi: unable to enable GPU debugging due to a "
|
||||
@@ -1633,29 +1636,29 @@ attach_amd_dbgapi (inferior *inf)
|
||||
return;
|
||||
}
|
||||
|
||||
if (amd_dbgapi_process_get_info (info->process_id,
|
||||
if (amd_dbgapi_process_get_info (info.process_id,
|
||||
AMD_DBGAPI_PROCESS_INFO_NOTIFIER,
|
||||
sizeof (info->notifier), &info->notifier)
|
||||
sizeof (info.notifier), &info.notifier)
|
||||
!= AMD_DBGAPI_STATUS_SUCCESS)
|
||||
{
|
||||
amd_dbgapi_process_detach (info->process_id);
|
||||
info->process_id = AMD_DBGAPI_PROCESS_NONE;
|
||||
amd_dbgapi_process_detach (info.process_id);
|
||||
info.process_id = AMD_DBGAPI_PROCESS_NONE;
|
||||
warning (_("amd-dbgapi: could not retrieve process %d's notifier, GPU "
|
||||
"debugging will not be available."), inf->pid);
|
||||
return;
|
||||
}
|
||||
|
||||
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
|
||||
already be a "runtime loaded" event available. Consume it and push the
|
||||
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");
|
||||
}
|
||||
|
||||
@@ -1672,30 +1675,30 @@ detach_amd_dbgapi (inferior *inf)
|
||||
{
|
||||
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;
|
||||
|
||||
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)
|
||||
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 != -1);
|
||||
delete_file_handler (info.notifier);
|
||||
|
||||
/* This is a noop if the target is not pushed. */
|
||||
inf->unpush_target (&the_amd_dbgapi_target);
|
||||
|
||||
/* Delete the breakpoints that are still active. */
|
||||
for (auto &&value : info->breakpoint_map)
|
||||
for (auto &&value : info.breakpoint_map)
|
||||
delete_breakpoint (value.second);
|
||||
|
||||
/* 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 ();
|
||||
}
|
||||
@@ -1971,10 +1974,10 @@ amd_dbgapi_target::displaced_step_prepare (thread_info *thread,
|
||||
}
|
||||
|
||||
/* 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
|
||||
= info->stepping_id_map.emplace (thread, stepping_id.handle).second;
|
||||
= info.stepping_id_map.emplace (thread, stepping_id.handle).second;
|
||||
gdb_assert (inserted);
|
||||
|
||||
/* 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 ());
|
||||
|
||||
/* Find the displaced stepping id for this thread. */
|
||||
amd_dbgapi_inferior_info *info = get_amd_dbgapi_inferior_info (thread->inf);
|
||||
auto entry = info->stepping_id_map.extract (thread);
|
||||
amd_dbgapi_inferior_info &info = get_amd_dbgapi_inferior_info (thread->inf);
|
||||
auto entry = info.stepping_id_map.extract (thread);
|
||||
|
||||
gdb_assert (entry.has_value ());
|
||||
amd_dbgapi_displaced_stepping_id_t stepping_id {entry->second};
|
||||
@@ -2064,14 +2067,16 @@ static void
|
||||
amd_dbgapi_target_inferior_cloned (inferior *original_inferior,
|
||||
inferior *new_inferior)
|
||||
{
|
||||
auto *orig_info = get_amd_dbgapi_inferior_info (original_inferior);
|
||||
auto *new_info = get_amd_dbgapi_inferior_info (new_inferior);
|
||||
const amd_dbgapi_inferior_info &orig_info
|
||||
= 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
|
||||
copy the precise memory request, it will be applied when the process
|
||||
starts. */
|
||||
gdb_assert (new_info->process_id == AMD_DBGAPI_PROCESS_NONE);
|
||||
new_info->precise_memory.requested = orig_info->precise_memory.requested;
|
||||
gdb_assert (new_info.process_id == AMD_DBGAPI_PROCESS_NONE);
|
||||
new_info.precise_memory.requested = orig_info.precise_memory.requested;
|
||||
}
|
||||
|
||||
/* 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
|
||||
to the new inferior (otherwise, FOLLOW_INF and ORIG_INF point to the same
|
||||
inferior, so this is a no-op). */
|
||||
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 (follow_inf).precise_memory.requested
|
||||
= get_amd_dbgapi_inferior_info (exec_inf).precise_memory.requested;
|
||||
|
||||
attach_amd_dbgapi (follow_inf);
|
||||
}
|
||||
@@ -2102,12 +2107,12 @@ amd_dbgapi_inferior_forked (inferior *parent_inf, inferior *child_inf,
|
||||
if (child_inf != nullptr)
|
||||
{
|
||||
/* 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);
|
||||
amd_dbgapi_inferior_info *child_info
|
||||
amd_dbgapi_inferior_info &child_info
|
||||
= get_amd_dbgapi_inferior_info (child_inf);
|
||||
child_info->precise_memory.requested
|
||||
= parent_info->precise_memory.requested;
|
||||
child_info.precise_memory.requested
|
||||
= parent_info.precise_memory.requested;
|
||||
|
||||
if (fork_kind != TARGET_WAITKIND_VFORKED)
|
||||
{
|
||||
@@ -2181,10 +2186,10 @@ amd_dbgapi_insert_breakpoint_callback
|
||||
amd_dbgapi_breakpoint_id_t breakpoint_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);
|
||||
if (it != info->breakpoint_map.end ())
|
||||
auto it = info.breakpoint_map.find (breakpoint_id.handle);
|
||||
if (it != info.breakpoint_map.end ())
|
||||
return AMD_DBGAPI_STATUS_ERROR_INVALID_BREAKPOINT_ID;
|
||||
|
||||
/* 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);
|
||||
|
||||
info->breakpoint_map.emplace (breakpoint_id.handle, bp);
|
||||
info.breakpoint_map.emplace (breakpoint_id.handle, bp);
|
||||
return AMD_DBGAPI_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
@@ -2213,14 +2218,14 @@ amd_dbgapi_remove_breakpoint_callback
|
||||
amd_dbgapi_breakpoint_id_t breakpoint_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);
|
||||
if (it == info->breakpoint_map.end ())
|
||||
auto it = info.breakpoint_map.find (breakpoint_id.handle);
|
||||
if (it == info.breakpoint_map.end ())
|
||||
return AMD_DBGAPI_STATUS_ERROR_INVALID_BREAKPOINT_ID;
|
||||
|
||||
delete_breakpoint (it->second);
|
||||
info->breakpoint_map.erase (it);
|
||||
info.breakpoint_map.erase (it);
|
||||
|
||||
return AMD_DBGAPI_STATUS_SUCCESS;
|
||||
}
|
||||
@@ -2274,10 +2279,10 @@ amd_dbgapi_xfer_global_memory_callback
|
||||
static void
|
||||
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 ());
|
||||
|
||||
if (info->process_id == AMD_DBGAPI_PROCESS_NONE)
|
||||
if (info.process_id == AMD_DBGAPI_PROCESS_NONE)
|
||||
return;
|
||||
|
||||
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)
|
||||
return;
|
||||
|
||||
if (!info->precise_memory.enabled)
|
||||
if (!info.precise_memory.enabled)
|
||||
gdb_printf (_("\
|
||||
Warning: precise memory violation signal reporting is not enabled, reported\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,
|
||||
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 ());
|
||||
|
||||
gdb_printf (file,
|
||||
_("AMDGPU precise memory access reporting is %s "
|
||||
"(currently %s).\n"),
|
||||
info->precise_memory.requested ? "on" : "off",
|
||||
info->precise_memory.enabled ? "enabled" : "disabled");
|
||||
info.precise_memory.requested ? "on" : "off",
|
||||
info.precise_memory.enabled ? "enabled" : "disabled");
|
||||
}
|
||||
|
||||
/* Callback for "set amdgpu precise-memory". */
|
||||
@@ -2382,13 +2387,13 @@ show_precise_memory_mode (struct ui_file *file, int from_tty,
|
||||
static void
|
||||
set_precise_memory_mode (bool value)
|
||||
{
|
||||
amd_dbgapi_inferior_info *info
|
||||
amd_dbgapi_inferior_info &info
|
||||
= 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)
|
||||
set_process_memory_precision (*info);
|
||||
if (info.process_id != AMD_DBGAPI_PROCESS_NONE)
|
||||
set_process_memory_precision (info);
|
||||
}
|
||||
|
||||
/* Return whether precise-memory is requested for the current inferior. */
|
||||
@@ -2396,10 +2401,10 @@ set_precise_memory_mode (bool value)
|
||||
static bool
|
||||
get_precise_memory_mode ()
|
||||
{
|
||||
amd_dbgapi_inferior_info *info
|
||||
const amd_dbgapi_inferior_info &info
|
||||
= get_amd_dbgapi_inferior_info (current_inferior ());
|
||||
|
||||
return info->precise_memory.requested;
|
||||
return info.precise_memory.requested;
|
||||
}
|
||||
|
||||
/* List of set/show amdgpu commands. */
|
||||
@@ -2472,9 +2477,9 @@ maybe_reset_amd_dbgapi ()
|
||||
{
|
||||
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;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user