Always check thread metadata

The thread metadata file is mandatory for trace version 2, so the
emulator should fail if the file is not there or has the wrong version.
Old traces with version 1 are not supported.
This commit is contained in:
Rodrigo Arias 2023-11-22 10:37:15 +01:00
parent c424a3177d
commit 998200d507

View File

@ -50,20 +50,17 @@ create_thread(struct proc *proc, const char *tracedir, const char *relpath)
return NULL; return NULL;
} }
/* Old version 1 doesn't have thread metadata */ /* Build metadata path */
if (proc->metadata_version > 1) { char mpath[PATH_MAX];
/* Build metadata path */ if (snprintf(mpath, PATH_MAX, "%s/%s/thread.%d.json",
char mpath[PATH_MAX]; tracedir, proc->id, tid) >= PATH_MAX) {
if (snprintf(mpath, PATH_MAX, "%s/%s/thread.%d.json", err("path too long");
tracedir, proc->id, tid) >= PATH_MAX) { return NULL;
err("path too long"); }
return NULL;
}
if (metadata_load_thread(mpath, thread) != 0) { if (metadata_load_thread(mpath, thread) != 0) {
err("cannot load metadata from %s", mpath); err("cannot load metadata from %s", mpath);
return NULL; return NULL;
}
} }
if (proc_add_thread(proc, thread) != 0) { if (proc_add_thread(proc, thread) != 0) {