Files
TheRock/debug-tools/rocgdb/source/gdb/testsuite/gdb.rocm/disassemble.exp
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

134 lines
4.4 KiB
Plaintext

# Copyright (C) 2021-2024 Free Software Foundation, Inc.
# Copyright (C) 2021-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/>.
# Test the various rocgdb disassemble commands on the kernel code.
# disassembly command shows assembly instructions.
#
# Optimized executables: Please note this test takes into account different
# optimization levels for some of its patterns. Optimized binaries may have
# different instructions and execution flow, which makes documenting the
# individual outputs ineffective. See comments across the test.
load_lib rocm.exp
require allow_hip_tests
standard_testfile .cpp
if {[prepare_for_testing "failed to prepare ${testfile}" $testfile $srcfile {debug hip}]} {
return -1
}
with_rocm_gpu_lock {
if ![runto_main] {
fail "can't run to main"
return -1
}
# By default, GDB shows mangled names in disassembly listings.
# Force demangling to make it easier to match symbols in the tests below.
gdb_test_no_output "set print asm-demangle on"
# Set breakpoint in device code.
gdb_breakpoint "kernel" "allow-pending" "qualified"
gdb_continue_to_breakpoint "kernel"
# Check "disassemble /r kernel".
#
# Sample vega20 output:
#
# Dump of assembler code for function kernel():
# 0x00007efe8de01600 <+0>: ff 00 a0 be 00 04 00 00 s_mov_b32 s32, 0x400
# 0x00007efe8de01608 <+8>: 80 00 a1 be s_mov_b32 s33, 0
# 0x00007efe8de0160c <+12>: 04 07 66 80 s_add_u32 flat_scratch_lo, s4, s7
# .
# .
# End of assembler dump.
gdb_test_sequence "disassemble /r kernel" "disassemble raw" [list \
"Dump of assembler code for function kernel\\(\\):" \
"\[ \t\]+$hex <\\+0>:\[ \t\]+(\[0-9a-fA-F]+\[ \t\]+)+\[^\r\n\]+" \
"End of assembler dump\." \
]
# The /m and /s options are visually equivalent, so we check both using the
# same pattern.
#
# Sample vega20 output:
#
# Dump of assembler code for function kernel():
# 24 \{
# 0x00007efe8de01600 <+0>: s_mov_b32 s32, 0x400
# 0x00007efe8de01608 <+8>: s_mov_b32 s33, 0
# 0x00007efe8de0160c <+12>: s_add_u32 flat_scratch_lo, s4, s7
# .
# .
# End of assembler dump.
#
# With optimized executables gdb may show any of the source lines depending on
# the compiler output.
foreach_with_prefix mode {"m" "s"} {
gdb_test_sequence "disassemble /$mode kernel" "disassemble machine code" [list \
"Dump of assembler code for function kernel\\(\\):" \
"$decimal\[ \t\]+(\{|\}|tid \+= 1;|volatile int tid = threadIdx\.x)" \
"\[ \t\]+$hex <\\+0>:\[ \t\]+\[^\n\r\]+" \
"End of assembler dump\." \
]
}
# Check "x/3i kernel".
#
# Sample vega20 output:
#
# 0x7efe8de01600 <kernel()>: s_mov_b32 s32, 0x400
# 0x7efe8de01608 <kernel()+8>: s_mov_b32 s33, 0
# 0x7efe8de0160c <kernel()+12>: s_add_u32 flat_scratch_lo, s4, s7
gdb_test_sequence "x/3i kernel" "disassemble 3 instructions" [list \
"\[ \t\]+$hex <kernel\\(\\)\\+?($decimal)?>:(\[ \t\]*)" \
"\[ \t\]+$hex <kernel\\(\\)\\+?($decimal)?>:(\[ \t\]*)" \
"\[ \t\]+$hex <kernel\\(\\)\\+?($decimal)?>:(\[ \t\]*)"
]
# Check set disassemble-next-line off followed by n.
# Sample vega20 output:
# There should not be any disassemble code printed identified by the absence of the character "=>"
gdb_test_no_output "set disassemble-next-line off"
gdb_test_multiple "n" "next after disassemble-next-line off" {
-re "=>.*$gdb_prompt $" {
fail $gdb_test_name
}
-re "$gdb_prompt $" {
pass $gdb_test_name
}
}
# Check "set disassemble-next-line on followed by n".
# vega20 sample output
# There should be disassemble code printed identified by the presense of the character "=>"
gdb_test_no_output "set disassemble-next-line on"
gdb_test_multiple "n" "next after disassemble-next-line on" {
-re "=>.*$gdb_prompt $" {
pass $gdb_test_name
}
-re "$gdb_prompt $" {
fail $gdb_test_name
}
}
}