Merge "Add support for nested parcel" into main
diff --git a/src/instruction_factory.cpp b/src/instruction_factory.cpp
index 1ac4433..3112995 100644
--- a/src/instruction_factory.cpp
+++ b/src/instruction_factory.cpp
@@ -206,7 +206,9 @@
 
       std::vector<MultithreadingParams> thread_params;
       std::vector<std::unique_ptr<Instruction>> instructions;
-      for (const auto& thread : options.threads()) {
+
+      for (int t = 0; t < options.threads().size(); t++) {
+        const auto& thread = options.threads()[t];
         for (int i = 0; i < thread.spawn(); i++) {
           auto thread_ids_copy = thread_ids;
           thread_ids_copy.push_back(InstructionFactory::GenerateThreadId());
@@ -217,7 +219,7 @@
           if (thread.has_name()) {
             thread_name = thread.name() + "_" + std::to_string(i);
           } else {
-            thread_name = std::to_string(i);
+            thread_name = std::to_string(t) + "_" + std::to_string(i);
           }
 
           SchedAttr sched_attr(Syscall::GetSyscall());
diff --git a/src/multiprocessing.cpp b/src/multiprocessing.cpp
index 0b37b7a..6ab589f 100644
--- a/src/multiprocessing.cpp
+++ b/src/multiprocessing.cpp
@@ -179,8 +179,8 @@
     }
   } else {
     LOGD("Child writing... " + std::to_string(getpid()));
-    result->AddSubResult(
-        instructions_[instruction_id_]->CollectResults(std::to_string(instruction_id_) + "/"));
+    std::string child_name = thread_params_[instruction_id_].name_;
+    result->AddSubResult(instructions_[instruction_id_]->CollectResults(child_name + "/"));
 
     result_pb = result->ToPb();
 
diff --git a/src/multithreading.cpp b/src/multithreading.cpp
index b696d5e..3f685dd 100644
--- a/src/multithreading.cpp
+++ b/src/multithreading.cpp
@@ -56,7 +56,8 @@
   auto result = std::make_unique<Result>(prefix + name_, repeat_);
   result->AddMeasurement("duration", TimespecToDoubleNanos(time_sampler_.GetSamples()));
   for (std::size_t i = 0; i < instructions_.size(); ++i) {
-    result->AddSubResult(instructions_[i]->CollectResults(std::to_string(i) + "/"));
+    std::string child_name = thread_params_[i].name_;
+    result->AddSubResult(instructions_[i]->CollectResults(child_name + "/"));
   }
   return result;
 }