diff --git a/rocclr/device/devsanitizer.hpp b/rocclr/device/devsanitizer.hpp index bfa28267ad..c5f3395b74 100644 --- a/rocclr/device/devsanitizer.hpp +++ b/rocclr/device/devsanitizer.hpp @@ -96,9 +96,9 @@ void handleSanitizerService(Payload* packt_payload, uint64_t activemask, int64_t loadAddrAdjust = 0; auto uri_fd = amd::Os::FDescInit(); if (uri_locator) { - device::UriLocator::UriInfo fileuri_info = uri_locator->lookUpUri(callstack[0]); - std::tie(offset, size) = uri_locator->decodeUriAndGetFd(fileuri_info, &uri_fd); - loadAddrAdjust = fileuri_info.loadAddressDiff; + device::UriLocator::UriInfo uri_info = uri_locator->lookUpUri(callstack[0]); + std::tie(offset, size) = uri_locator->decodeUriAndGetFd(uri_info, &uri_fd); + loadAddrAdjust = uri_info.loadAddressDiff; } #if defined(__linux__) diff --git a/rocclr/device/rocm/rocurilocator.cpp b/rocclr/device/rocm/rocurilocator.cpp index f9c83e5b66..9a20191b40 100644 --- a/rocclr/device/rocm/rocurilocator.cpp +++ b/rocclr/device/rocm/rocurilocator.cpp @@ -106,7 +106,7 @@ std::pair UriLocator::decodeUriAndGetFd(UriInfo& uri, if (uri.uriPath.size() == 0) return {0,0}; auto pos = uri.uriPath.find("//"); - if (pos == std::string::npos || uri.uriPath.substr(0, pos) != "file:") { + if (pos == std::string::npos) { uri.uriPath=""; return {0,0}; } @@ -126,32 +126,31 @@ std::pair UriLocator::decodeUriAndGetFd(UriInfo& uri, else { rspos = uri.uriPath.size()-1; } - pos += 2; - //decode filepath - for (auto i=pos; i<= rspos;) { - cur = uri.uriPath[i]; - if (isalnum(cur) || cur == '/' || cur == '-' || - cur == '_' || cur == '.' || cur == '~') { - ss << cur; - i++; - } - else { - //characters prefix with '%' char - char tbits = uri.uriPath[i+1], lbits = uri.uriPath[i+2]; - uint8_t t = (tbits < 58) ? ( tbits - 48) : ((tbits - 65) + 10); - uint8_t l = (lbits < 58) ? ( lbits - 48) : ((lbits - 65) + 10); - ss << (char)(((0b00000000 | t)<<4) | l); - i += 3; + if (uri.uriPath.substr(0, pos) == "file:") { + pos += 2; + // decode filepath + for (auto i = pos; i <= rspos;) { + cur = uri.uriPath[i]; + if (isalnum(cur) || cur == '/' || cur == '-' || cur == '_' || cur == '.' || cur == '~') { + ss << cur; + i++; + } else { + // characters prefix with '%' char + char tbits = uri.uriPath[i + 1], lbits = uri.uriPath[i + 2]; + uint8_t t = (tbits < 58) ? (tbits - 48) : ((tbits - 65) + 10); + uint8_t l = (lbits < 58) ? (lbits - 48) : ((lbits - 65) + 10); + ss << (char)(((0b00000000 | t) << 4) | l); + i += 3; + } } + uri.uriPath = ss.str(); + size_t fd_size; + (void)amd::Os::GetFileHandle(uri.uriPath.c_str(), uri_fd, &fd_size); + // As per URI locator syntax, range_specifier is optional + // if range_specifier is absent return total size of the file + // and set offset to begin at 0. + if (size == 0) size = fd_size; } - uri.uriPath = ss.str(); - size_t fd_size; - (void) amd::Os::GetFileHandle(uri.uriPath.c_str(), uri_fd, &fd_size); - // As per URI locator syntax, range_specifier is optional - // if range_specifier is absent return total size of the file - // and set offset to begin at 0. - if (size == 0) - size = fd_size; return {offset, size}; }