Skip to content

Implements the "maintenance info amdgpu address-aliases" command - #225

Open
czidev-amd wants to merge 1 commit into
amd-stagingfrom
users/czissule/address-alias
Open

Implements the "maintenance info amdgpu address-aliases" command#225
czidev-amd wants to merge 1 commit into
amd-stagingfrom
users/czissule/address-alias

Conversation

@czidev-amd

Copy link
Copy Markdown
Contributor

Motivation

Given an expression that evaluates to an address in some address space, show for each address space supported by the current AMDGPU architecture the aliasing address in that space, if any, along with the number of consecutive bytes for which the aliasing is valid.

This is purely a diagnostic aid: it queries amd_dbgapi_convert_address_space for every address space known to the architecture and reports "" for the ones the given address does not alias into.

Test Plan

New show_address_aliases.exp test added.

@czidev-amd
czidev-amd requested a review from a team as a code owner July 21, 2026 12:40
@czidev-amd
czidev-amd force-pushed the users/czissule/address-alias branch from 3d2d94b to d234a73 Compare July 21, 2026 12:45
@czidev-amd czidev-amd changed the title Implements the "maintenance info amdgpu address-aliases" comman Implements the "maintenance info amdgpu address-aliases" command Jul 21, 2026
Comment thread gdb/amdgpu-tdep.c
Comment thread gdb/amdgpu-tdep.c
Comment thread gdb/amdgpu-tdep.c
Comment thread gdb/testsuite/gdb.rocm/maint-print-address-aliases.cpp Outdated
Comment thread gdb/amdgpu-tdep.c
Comment thread gdb/testsuite/gdb.rocm/show_address_aliases.exp Outdated
Comment thread gdb/amdgpu-tdep.c
Comment thread gdb/amdgpu-tdep.c
Comment thread gdb/amdgpu-tdep.c
Comment thread gdb/testsuite/gdb.rocm/show_address_aliases.exp Outdated
@lumachad lumachad assigned czidev-amd and unassigned lumachad Jul 22, 2026
@czidev-amd
czidev-amd marked this pull request as draft July 27, 2026 11:39
@czidev-amd
czidev-amd marked this pull request as draft July 27, 2026 11:39
@czidev-amd
czidev-amd force-pushed the users/czissule/address-alias branch 2 times, most recently from dbe0775 to 1432895 Compare July 27, 2026 15:08

@czidev-amd czidev-amd left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you @lumachad for your review, I have reworked a bit this PR to include your comments. One observation is the renaming of the tests to match other "maint" tests naming pattern. Also, I have relaxed the test as I cannot really guarantee the same output across different architectures. Now, the tests is testing if gdb implementation is sane rather than gdbabi output sanity.

@czidev-amd
czidev-amd marked this pull request as ready for review July 27, 2026 15:14
Comment thread gdb/testsuite/gdb.rocm/maint-print-address-aliases.cpp Outdated
Comment thread gdb/testsuite/gdb.rocm/maint-print-address-aliases.cpp Outdated
Comment thread gdb/testsuite/gdb.rocm/maint-print-address-aliases.exp Outdated
Comment thread gdb/testsuite/gdb.rocm/maint-print-address-aliases.exp Outdated
Comment thread gdb/testsuite/gdb.rocm/maint-print-address-aliases.exp Outdated
Comment thread gdb/amdgpu-tdep.c Outdated
Comment thread gdb/amdgpu-tdep.c Outdated
Comment thread gdb/amdgpu-tdep.c Outdated
Comment thread gdb/amdgpu-tdep.c Outdated
Comment thread gdb/doc/gdb.texinfo Outdated
Comment thread gdb/testsuite/gdb.rocm/maint-print-address-aliases.cpp Outdated
@czidev-amd
czidev-amd force-pushed the users/czissule/address-alias branch from 1432895 to 2f1c254 Compare July 28, 2026 11:36
@czidev-amd

Copy link
Copy Markdown
Contributor Author

I have spined a new version including Pedro's and Lancelot's inputs.

Comment thread gdb/amdgpu-tdep.c Outdated
Comment thread gdb/testsuite/gdb.rocm/maint-print-address-aliases.exp
Comment thread gdb/testsuite/gdb.rocm/maint-print-address-aliases.exp
Comment thread gdb/testsuite/gdb.rocm/maint-print-address-aliases.cpp Outdated
Comment thread gdb/testsuite/gdb.rocm/maint-print-address-aliases.cpp
Comment thread gdb/testsuite/gdb.rocm/maint-print-address-aliases.cpp Outdated
Comment thread gdb/testsuite/gdb.rocm/maint-print-address-aliases.exp Outdated
Comment thread gdb/testsuite/gdb.rocm/maint-print-address-aliases.exp
Comment thread gdb/testsuite/gdb.rocm/maint-print-address-aliases.exp
Comment thread gdb/amdgpu-tdep.c
Comment thread gdb/amdgpu-tdep.c
/* Not a real alias, NULL just maps to NULL in every
space. */
if (src_is_null_address)
ui_out->field_string ("valid", "<null>");

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IMHO it wouldn't be wrong to print 0 here.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can do that, let's see if anyone else has a different idea.

Comment thread gdb/amdgpu-tdep.c Outdated
Comment thread gdb/testsuite/gdb.rocm/maint-print-address-aliases.cpp Outdated
Comment thread gdb/testsuite/gdb.rocm/maint-print-address-aliases.exp Outdated
Comment thread gdb/amdgpu-tdep.c Outdated
Comment thread gdb/amdgpu-tdep.c Outdated
Comment thread gdb/doc/gdb.texinfo Outdated
Comment thread gdb/doc/gdb.texinfo
Some address spaces are private to a wave or a lane of a wave, and
@value{GDBN} converts using whichever wave and lane are currently
selected. Not every address is reachable from every space: if it isn't,
the row for that space reads @samp{<not reachable>}.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One nit, I think that we do an LDS -> global conversion, but this is only valid (ish) while the wave is stopped. As soon as we resume, this address is not valid anymore. Not sure if this should be described, or maybe this is just a dbgapi bug we should address.

Comment thread gdb/amdgpu-tdep.c Outdated
Comment thread gdb/amdgpu-tdep.c
@czidev-amd
czidev-amd force-pushed the users/czissule/address-alias branch from 2f1c254 to 9b0c0d2 Compare August 4, 2026 13:39
Comment thread gdb/doc/gdb.texinfo
Comment thread gdb/testsuite/gdb.rocm/maint-print-address-aliases.exp Outdated
@czidev-amd
czidev-amd marked this pull request as draft August 17, 2026 11:10
@czidev-amd
czidev-amd force-pushed the users/czissule/address-alias branch from 9b0c0d2 to ec37ff2 Compare August 17, 2026 11:16
It can sometimes be useful to be able to convert address from an
address space to another one (if such conversion is possible).  This
patch proposes to add a maintenance command which shows for a given
address (in any address space) the aliasing addresses in other address
spaces.  It also shows the number of consecutive bytes this conversion
is valid for.

Here are example outputs on this new command:

    (gdb) maintenance info amdgpu address-aliases &idx
    Address space                      Address         Valid for
    global                      0x7ff7f4600c00               0x4
    generic            generic#0x2000000000030             0x3d0
    private_wave            private_wave#0xc00               0x4
    private_lane             private_lane#0x30             0x3d0
    local                      <not reachable>               0x0

    (gdb) maintenance info amdgpu address-aliases gidx_p
    Address space                      Address         Valid for
    global                     <not reachable>               0x0
    generic            generic#0x1000000000000             0x200
    private_wave               <not reachable>               0x0
    private_lane               <not reachable>               0x0
    local                            local#0x0       0x100000000

Tested on x86_64-linux + gfx942.

Change-Id: I9d118f208589c3db6a2ec966ac221b1a54d0ccb6

Co-authored-by: Claudiu Zissulescu-Ianculescu <claudiu.zissulescu-ianculescu@amd.com>
@czidev-amd
czidev-amd force-pushed the users/czissule/address-alias branch from ec37ff2 to 866d8c3 Compare August 17, 2026 13:14
@czidev-amd
czidev-amd marked this pull request as ready for review August 17, 2026 13:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants