decode thread names

This commit is contained in:
Simon Cruanes 2023-12-27 17:13:46 -05:00
parent 7f40e6cda9
commit 90b2c986ee
No known key found for this signature in database
GPG Key ID: EBFFF6F283F3A2B4

View File

@ -490,6 +490,59 @@ int main(int argc, char **argv) {
break;
}
case 7: {
// kernel object
uint8_t ty = (r.header >> 16) & 0xff;
uint16_t name_ref = (r.header >> 24) & 0xffff;
uint8_t n_args = (r.header >> 40) & 0xf;
size_t offset = 1;
uint64_t koid = r.p[offset];
offset++;
readString(dec, name, r, offset, name_ref);
readArguments(arguments, dec, r, offset, n_args);
switch (ty) {
case 1: {
// process
break;
}
case 2: {
// thread
auto real_tid = koid;
// we need the pid as well
uint64_t pid;
bool foundPid = false;
for (auto &kv : arguments) {
if (strcmp(kv.name.data(), "process") == 0 &&
std::holds_alternative<uint64_t>(kv.value)) {
// koid (argument type 8) are decoded as uint64
pid = std::get<uint64_t>(kv.value);
foundPid = true;
break;
}
}
if (!foundPid)
continue;
ThreadRef th{pid, real_tid};
const auto tid = getPseudoTid(dec, th);
dec.threadNames[tid] = name;
break;
}
default: {
}
}
}
default: {
}
}