Files
TheRock/debug-tools/rocgdb/source/gdb/amdgpu-tdep.h
T
derek.holloway 7502bf64a4
CodeQL / Analyze (actions) (push) Canceled after 0s
CodeQL / Analyze (python) (push) Canceled after 0s
pre-commit / pre-commit (push) Canceled after 0s
Multi-Arch CI / setup (push) Canceled after 0s
Publish build_manylinux_x86_64 images / publish_build_manylinux_x86_64 (push) Canceled after 0s
Setup (Multi-Arch) / setup (push) Canceled after 0s
Multi-Arch CI / Linux::${{ fromJSON(needs.setup.outputs.linux_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubi10 image / publish_no_rocm_image_ubi10 (push) Canceled after 0s
Multi-Arch CI / Windows::${{ fromJSON(needs.setup.outputs.windows_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Multi-Arch CI / Manifest Diff (push) Canceled after 0s
TheRock Manifest Diff Report / Generate Manifest Diff Report (push) Canceled after 0s
Multi-Arch CI / CI Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_ocl_rt images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_rocgdb images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Unit Tests / Unit Tests :: ubuntu-24.04 (push) Canceled after 0s
Unit Tests / Unit Tests :: windows-2022 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_media (push) Canceled after 0s
Unit Tests / Unit Tests Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_openmpi (push) Canceled after 0s
Flatten subprojects into a single base monorepo
2026-09-02 16:34:47 -07:00

123 lines
4.2 KiB
C++

/* Target-dependent code for the AMDGPU architectures.
Copyright (C) 2019-2024 Free Software Foundation, Inc.
Copyright (C) 2019-2024 Advanced Micro Devices, Inc. All rights reserved.
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_AMDGPU_TDEP_H
#define GDB_AMDGPU_TDEP_H
#include "gdbarch.h"
#include "gdbsupport/unordered_map.h"
#include <amd-dbgapi/amd-dbgapi.h>
#include <unordered_map>
/* Provide std::unordered_map::Hash for amd_dbgapi_register_id_t. */
struct register_id_hash
{
size_t
operator() (const amd_dbgapi_register_id_t &register_id) const
{
return std::hash<decltype (register_id.handle)> () (register_id.handle);
}
};
/* Provide std::unordered_map::Equal for amd_dbgapi_register_id_t. */
struct register_id_equal_to
{
bool
operator() (const amd_dbgapi_register_id_t &lhs,
const amd_dbgapi_register_id_t &rhs) const
{
return std::equal_to<decltype (lhs.handle)> () (lhs.handle, rhs.handle);
}
};
/* AMDGPU architecture specific information. */
struct amdgpu_gdbarch_tdep : gdbarch_tdep_base
{
/* This architecture's breakpoint instruction. */
gdb::unique_xmalloc_ptr<gdb_byte> breakpoint_instruction_bytes;
size_t breakpoint_instruction_size;
/* A vector of register_ids indexed by their equivalent gdb regnum.
This is not to improve performance (calling into the amd-dbgapi is not
that costly) but to reduce log pollution when running with amd-dbgapi
logging enabled. */
std::vector<amd_dbgapi_register_id_t> register_ids;
/* A map of gdb regnums keyed by they equivalent register_id. */
gdb::unordered_map<amd_dbgapi_register_id_t, int, register_id_hash,
register_id_equal_to>
regnum_map;
/* A map of register_class_ids keyed by their name. */
std::unordered_map<std::string, amd_dbgapi_register_class_id_t>
register_class_map;
/* A vector of register types created from the amd-dbgapi type strings,
indexed by their equivalent gdb regnum. These are computed lazily by
amdgpu_register_type, entries that haven't been computed yet are
nullptr. */
std::vector<type *> register_types;
/* A vector of address spaces available in this architecture.
This information is queried from dbgapi and cached here as an
optimization. */
std::vector<arch_addr_space> address_spaces;
/* The following vectors store information that we could easily obtain
on-demand from amd-dbgapi. This is not so much to improve performance
(calling into the amd-dbgapi is not that costly) but to reduce log
pollution when running with amd-dbgapi logging enabled. */
/* A vector of register_properties indexed by their equivalent regnum. */
std::vector<amd_dbgapi_register_properties_t> register_properties;
/* A vector of GDB register numbers indexed by DWARF register number.
Unused DWARF register numbers map to value -1. */
std::vector<int> dwarf_regnum_to_gdb_regnum;
/* A vector of register names indexed by their equivalent gdb regnum. */
std::vector<std::string> register_names;
};
/* Return true if GDBARCH is of an AMDGPU architecture. */
bool is_amdgpu_arch (struct gdbarch *gdbarch);
/* Return true if ABFD is of an AMDGPU architecture. */
bool is_amdgpu_arch (bfd *abfd);
/* Return the amdgpu-specific data associated to ARCH. */
amdgpu_gdbarch_tdep *get_amdgpu_gdbarch_tdep (gdbarch *arch);
/* Extract address space from a core address ADDR. */
arch_addr_space_id amdgpu_address_space_id_from_core_address (CORE_ADDR addr);
/* Extract segment address from a core address ADDR. */
CORE_ADDR amdgpu_segment_address_from_core_address (CORE_ADDR addr);
#endif /* GDB_AMDGPU_TDEP_H */