# Copyright (C) 2019-2026 Free Software Foundation, Inc. # Copyright (C) 2019-2026 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 . # Test "info sharedlibrary" when debugging GPU code. Test the command # both when focused on a GPU wave, and on a CPU thread. 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 } proc test_info_shared {} { # Sample output: # # (gdb) info sharedlibrary # From To Syms Read Shared Object Library # 0x00007fd120664ac0 0x00007fd120682790 Yes (*) /lib64/ld-linux-x86-64.so.2 # ... # 0x00007fd0125d8ec0 0x00007fd015f21630 Yes (*) /opt/rocm-3.5.0/hip/lib/../../lib/libamd_comgr.so # 0x00007fd11d74e870 0x00007fd11d75a868 Yes (*) /lib/x86_64-linux-gnu/libtinfo.so.5 # 0x00007fd11d008000 0x00007fd11d00adc0 Yes (*) memory://95557/mem#offset=0x7fd0083e7f60&size=41416 # 0x00007fd11d001000 0x00007fd11d00173c Yes file:///home/rocm/examples/bit_extract#offset=6477&size=10832 # (*): Shared library is missing debugging information. # Grammar: # # code_object_uri ::== file_uri | memory_uri # file_uri ::== "file://" file_path [ range_specifier ] # memory_uri ::== "memory://" process_id range_specifier # range_specifier ::== [ "#" | "?" ] "offset=" number "&" "size=" number # file_path ::== URI_ENCODED_OS_FILE_PATH # process_id ::== DECIMAL_NUMBER # number ::== HEX_NUMBER | DECIMAL_NUMBER | OCTAL_NUMBER global decimal hex fullname_syntax set number $decimal|$hex|0\[0-7\]+ set process_id $decimal set file_path "(?:\\/(?:\[A-Za-z0-9_.~-\]|%\[0-9A-F\]{2})+)+\\/?" set range_specifier (#|\\?)offset=(${number})&size=(${number}) set memory_uri "memory:\\/\\/$process_id$range_specifier" set file_uri "file://$file_path\($range_specifier\)?" set code_object_uri "\($memory_uri\)|\($file_uri\)" set ws "\[ \t\]" gdb_test_sequence "info sharedlibrary" "info sharedlibrary" [list \ "From${ws}+To${ws}+Syms${ws}+Read${ws}+Shared Object Library" \ "$hex${ws}+$hex${ws}+(Yes|No)${ws}(\\(\\*\\))?${ws}+$fullname_syntax" \ "$hex${ws}+$hex${ws}+(Yes|No)${ws}(\\(\\*\\))?${ws}+$code_object_uri" \ "$hex${ws}+$hex${ws}+(Yes|No)${ws}(\\(\\*\\))?${ws}+$code_object_uri" ] } with_rocm_gpu_lock { if {![runto kern allow-pending message]} { return } with_test_prefix "gpu" { test_info_shared } with_test_prefix "cpu" { gdb_test "thread 1" "Switching to thread 1 .*" "switch to host thread" test_info_shared } }