Extract the format string hash and the format string. The compiler generates the amdhsa.printf metadata in following format for HIP nonhostcall case. "0:0: , " i.e the hash is part of the format string itself delimited by character ','.
| 255 | // i.e the hash is part of the format string itself |
| 256 | // delimited by character ','. |
| 257 | bool populateFormatStringHashMap(const std::vector<device::PrintfInfo>& printfInfo, |
| 258 | std::map<uint64_t, std::string>& strMap) { |
| 259 | for (auto it : printfInfo) { |
| 260 | auto Delim = it.fmtString_.find_first_of(','); |
| 261 | auto HashStr = it.fmtString_.substr(0, Delim); |
| 262 | |
| 263 | static_assert(sizeof(long long) == sizeof(uint64_t), "unexpected long long type width"); |
| 264 | auto HashVal = std::strtoull(HashStr.c_str(), NULL, 16); |
| 265 | if (strMap.find(HashVal) != strMap.end()) { |
| 266 | LogError("Hash value collision detected, printf buffer ill formed"); |
| 267 | return false; |
| 268 | } |
| 269 | strMap[HashVal] = it.fmtString_.substr(Delim + 1, it.fmtString_.size()); |
| 270 | } |
| 271 | |
| 272 | return true; |
| 273 | } |
| 274 | |
| 275 | void handlePrintfDelayed(const uint64_t* input, uint64_t len, uint64_t control) { |
| 276 | auto end = input + len; |