Implements the "maintenance info amdgpu address-aliases" command - #225
Implements the "maintenance info amdgpu address-aliases" command#225czidev-amd wants to merge 1 commit into
Conversation
3d2d94b to
d234a73
Compare
dbe0775 to
1432895
Compare
czidev-amd
left a comment
There was a problem hiding this comment.
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.
1432895 to
2f1c254
Compare
|
I have spined a new version including Pedro's and Lancelot's inputs. |
| /* Not a real alias, NULL just maps to NULL in every | ||
| space. */ | ||
| if (src_is_null_address) | ||
| ui_out->field_string ("valid", "<null>"); |
There was a problem hiding this comment.
IMHO it wouldn't be wrong to print 0 here.
There was a problem hiding this comment.
I can do that, let's see if anyone else has a different idea.
| 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>}. |
There was a problem hiding this comment.
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.
2f1c254 to
9b0c0d2
Compare
9b0c0d2 to
ec37ff2
Compare
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>
ec37ff2 to
866d8c3
Compare
lumachad
left a comment
There was a problem hiding this comment.
Some automated comments. Take it or leave it. They seem mostly nits to me.
| } | ||
|
|
||
| /* Implements the "maintenance info amdgpu address-aliases" command. | ||
|
|
There was a problem hiding this comment.
GDB function comments should be written in third-person present tense describing what the function does, not "Implements the". Consider:
/* Show for each address space supported by the current AMDGPU
architecture the aliases of a given ADDR, and the number of
consecutive bytes for which each aliasing is valid. */
"Implements the" reads more like a commit message than a source comment.
| error (_("amd_dbgapi_address_space_get_info (NULL_ADDRESS) failed (%s)"), | ||
| get_status_string (status)); | ||
| bool src_is_null_address = (offset == src_null_address); | ||
|
|
There was a problem hiding this comment.
The outer parentheses around the comparison are unnecessary in C++:
bool src_is_null_address = offset == src_null_address;| ui_out->table_header (max_aspace_name_len, ui_left, "aspace", | ||
| _("Address space")); | ||
| /* Address form is: <Name>0xNN..NNN. */ | ||
| ui_out->table_header (max_aspace_name_len + addr_width, |
There was a problem hiding this comment.
The comment on the next line (/* Address form is: <Name>0xNN..NNN. */) is inaccurate. paspace() emits a # separator between the address-space name and the hex address (e.g., generic#0x2000000000030), and for the default space it emits nothing at all. Suggested wording:
/* Address form is: <name>#0xNN..NNN for a named space,
or just 0xNN..NNN for the default (global) space. */|
|
||
| add_cmd ("address-aliases", class_maintenance, | ||
| amdgpu_info_address_aliases_command, _("\ | ||
| Show ADDRESS aliases across AMDGPU address spaces.\n\ |
There was a problem hiding this comment.
The commit message headline says "maint amdgpu info address-alias" (singular, and with amdgpu before info), but the registered command is "maintenance info amdgpu address-aliases" (plural, correct order). Please update the commit headline to match, e.g.:
gdb: Add "maint info amdgpu address-aliases" command
| @@ -0,0 +1,60 @@ | |||
| /* Copyright (C) 2026 Free Software Foundation, Inc. | |||
| Copyright (C) 2026 Advanced Micro Devices, Inc. All rights reserved. | |||
There was a problem hiding this comment.
The filename says maint-print-address-aliases but the command under test is maint info amdgpu address-aliases (note info, not print). Consider renaming both test files to maint-info-amdgpu-address-aliases.{cpp,exp} so they are discoverable by command name.
| # Count address spaces known to the architecture. | ||
| set aspaces 0 | ||
| gdb_test_multiple "maint print address-spaces" "" -lbl { | ||
| -re "\r\n${asname}\[ \t\]+$::decimal\[ \t\]+" { |
There was a problem hiding this comment.
The address-space count is obtained from maint print address-spaces and then cross-checked against the row count from maint info amdgpu address-aliases. If those two commands ever diverge (e.g. one filters address spaces the other doesn't), the assertion gives a confusing failure with no obvious cause. It would be more robust to count the rows produced by the address-aliases command itself.
| } | ||
|
|
||
| -re "^\r\n${asname}\[ \t\]+${asname}#*$::hex\[ \t\]+($::hex|<null>)${trailer}" { | ||
| # Match address space. |
There was a problem hiding this comment.
#* matches zero or more # characters, so this branch can fire even when there is no # in the address field, potentially stealing matches from the global branch above. The separator is always exactly # for named spaces, so use a literal #:
-re "^\r\n${asname}\[ \t\]+${asname}#$::hex\[ \t\]+($::hex|<null>)${trailer}" {
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.exptest added.