Merge commit '190562e8c65c9872c5c22391400931da8e4b5dae' into develop

This commit is contained in:
systems-assistant[bot]
2025-07-30 15:21:36 +00:00
66 changed files with 7379 additions and 492 deletions
@@ -118,7 +118,7 @@ write_hw_counter_info(std::ostream&, const array_t<bool, N>& = {},
namespace
{
// initialize HIP before main so that librocprof-sys is not HSA_TOOLS_LIB
int gpu_count = rocprofsys::gpu::device_count();
int gpu_count = 0;
// statically allocated shared_ptrs to prevent use after free errors
auto timemory_manager = tim::manager::master_instance();
@@ -138,6 +138,7 @@ main(int argc, char** argv)
tim::unwind::set_bfd_verbose(3);
tim::set_env("ROCPROFSYS_INIT_TOOLING", "OFF", 1);
rocprofsys_init_library();
gpu_count = rocprofsys::gpu::device_count();
std::set<std::string> _category_options = component_categories{}();
{
@@ -488,6 +488,77 @@ find_function(image_t* app_image, const std::string& _name, const strset_t& _ext
return _func;
}
//======================================================================================//
//
// Find undefined function symbols (external references) in the binary
//
symtab_symbol_t*
find_undefined_function_symbol(image_t* app_image, const std::string& _name)
{
if(_name.empty()) return nullptr;
// Get all objects from the image
BPatch_Vector<BPatch_object*> app_objects;
app_image->getObjects(app_objects);
if(app_objects.empty())
{
verbprintf(3, "No objects found in image for symbol search\n");
return nullptr;
}
// Search helper lambda for code reuse
auto _find_symbol = [](SymTab::Symtab* symtab,
const std::string& target_name) -> symtab_symbol_t* {
if(!symtab) return nullptr;
std::vector<SymTab::Symbol*> all_symbols;
if(!symtab->getAllSymbols(all_symbols)) return nullptr;
for(auto* symbol : all_symbols)
{
if(!symbol || symbol->getType() != SymTab::Symbol::ST_FUNCTION ||
symbol->getRegion())
continue;
// Try all possible symbol name representations
std::string symbol_name = symbol->getPrettyName();
if(symbol_name.empty()) symbol_name = symbol->getMangledName();
if(symbol_name.empty()) symbol_name = symbol->getTypedName();
// Check for exact match and undefined function criteria
if(symbol_name == target_name) return symbol;
}
return nullptr;
};
// Search through each object
for(auto* app_object : app_objects)
{
if(!app_object) continue;
std::string binary_path = app_object->name();
// Open Symtab directly for comprehensive symbol access
SymTab::Symtab* symtab = nullptr;
if(!SymTab::Symtab::openFile(symtab, binary_path))
{
verbprintf(3, "Failed to open Symtab for: %s\n", binary_path.c_str());
continue;
}
// Search for the primary symbol name
auto* result = _find_symbol(symtab, _name);
if(result)
{
verbprintf(1, "Found undefined function symbol: '%s' in %s\n", _name.c_str(),
binary_path.c_str());
return result;
}
}
verbprintf(1, "Undefined function symbol: '%s' ... not found\n", _name.c_str());
return nullptr;
}
//======================================================================================//
//
// Get the realpath to this exe
@@ -360,6 +360,9 @@ insert_instr(address_space_t* mutatee, Tp traceFunc, procedure_loc_t traceLoc,
procedure_t*
find_function(image_t* appImage, const string_t& functionName, const strset_t& = {});
symtab_symbol_t*
find_undefined_function_symbol(image_t* app_image, const std::string& _name);
void
error_func_real(error_level_t level, int num, const char* const* params);
@@ -1721,6 +1721,14 @@ main(int argc, char** argv)
use_mpi = true;
break;
}
else if(find_undefined_function_symbol(app_image, itr) != nullptr)
{
verbprintf(0,
"Found undefined symbol '%s' in '%s'. Enabling MPI support...\n",
itr, _cmdv[0]);
use_mpi = true;
break;
}
}
#endif
@@ -1,3 +1,26 @@
################################################################################
# Copyright (c) 2025 Advanced Micro Devices, Inc.
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in all
# copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
#
################################################################################
set(ROCPROFSYS_ABORT_FAIL_REGEX
"### ERROR ###|unknown-hash=|address of faulting memory reference|exiting with non-zero exit code|terminate called after throwing an instance|calling abort.. in |Exit code: [1-9]"
CACHE INTERNAL
@@ -312,6 +335,7 @@ rocprofiler_systems_add_bin_test(
~PERFETTO
~PROCESS_SAMPLING
~KOKKOSP
~PAGE
--csv
--brief
--advanced