Add UUIDs to profraw filenames
Bug: 295866435
Change-Id: Ie9390f412c70202d1583e29ac83c30778ae02f70
diff --git a/trusty/utils/coverage-controller/controller.cpp b/trusty/utils/coverage-controller/controller.cpp
index 730c010..0047046 100644
--- a/trusty/utils/coverage-controller/controller.cpp
+++ b/trusty/utils/coverage-controller/controller.cpp
@@ -14,11 +14,16 @@
* limitations under the License.
*/
+#include <android-base/stringprintf.h>
+#include <array>
#include <getopt.h>
+#include <inttypes.h>
+#include <memory>
+#include <stdbool.h>
+#include <stdio.h>
+#include <string.h>
#include <trusty/line-coverage/coverage.h>
#include <trusty/tipc.h>
-#include <array>
-#include <memory>
#include <vector>
#include "controller.h"
@@ -48,10 +53,10 @@
if (complete_cnt != counters[index] && start_cnt == complete_cnt) {
WRITE_ONCE(control->cntrl_flags, FLAG_NONE);
- std::string fmt = "/%d.%lu.profraw";
- int sz = std::snprintf(nullptr, 0, fmt.c_str(), index, counters[index]);
- std::string filename(sz+1, '.');
- std::sprintf(filename.data(), fmt.c_str(), index, counters[index]);
+ std::string filename;
+ filename = android::base::StringPrintf("/%s.%lu.profraw",
+ uuid_list_[index].c_str(),
+ counters[index]);
filename.insert(0, output_dir);
android::base::Result<void> res = record_list_[index]->SaveFile(filename);
counters[index]++;
@@ -79,6 +84,7 @@
struct line_coverage_client_resp resp;
uint32_t cur_index = record_list_.size();
struct uuid zero_uuid = {0, 0, 0, { 0 }};
+ char uuid_str[UUID_STR_SIZE];
req.hdr.cmd = LINE_COVERAGE_CLIENT_CMD_SEND_LIST;
int rc = write(coverage_srv_fd, &req, sizeof(req));
if (rc != (int)sizeof(req)) {
@@ -98,6 +104,21 @@
}
if(uuid_set_.find(resp.send_list_args.uuid) == uuid_set_.end()) {
uuid_set_.insert(resp.send_list_args.uuid);
+ sprintf(uuid_str,
+ "%08" PRIx32 "-%04" PRIx16 "-%04" PRIx16 "-%02" PRIx8 "%02" PRIx8
+ "-%02" PRIx8 "%02" PRIx8 "%02" PRIx8 "%02" PRIx8 "%02" PRIx8 "%02" PRIx8,
+ resp.send_list_args.uuid.time_low,
+ resp.send_list_args.uuid.time_mid,
+ resp.send_list_args.uuid.time_hi_and_version,
+ resp.send_list_args.uuid.clock_seq_and_node[0],
+ resp.send_list_args.uuid.clock_seq_and_node[1],
+ resp.send_list_args.uuid.clock_seq_and_node[2],
+ resp.send_list_args.uuid.clock_seq_and_node[3],
+ resp.send_list_args.uuid.clock_seq_and_node[4],
+ resp.send_list_args.uuid.clock_seq_and_node[5],
+ resp.send_list_args.uuid.clock_seq_and_node[6],
+ resp.send_list_args.uuid.clock_seq_and_node[7]);
+ uuid_list_.push_back(uuid_str);
record_list_.push_back(std::make_unique<CoverageRecord>(TIPC_DEV,
&resp.send_list_args.uuid));
counters.push_back(0);
diff --git a/trusty/utils/coverage-controller/controller.h b/trusty/utils/coverage-controller/controller.h
index b771c16..f7789bf 100644
--- a/trusty/utils/coverage-controller/controller.h
+++ b/trusty/utils/coverage-controller/controller.h
@@ -26,6 +26,8 @@
#define TEST_SRV_PORT "com.android.trusty.sancov.test.srv"
#define TEST_SRV_MODULE "srv.syms.elf"
+#define UUID_STR_SIZE (37)
+
#define FLAG_NONE 0x0
#define FLAG_RUN 0x1
#define FLAG_TOGGLE_CLEAR 0x2
@@ -52,6 +54,7 @@
private:
std::vector<std::unique_ptr<line_coverage::CoverageRecord>>record_list_;
std::set<struct uuid>uuid_set_;
+ std::vector<std::string>uuid_list_;
std::vector<uint64_t> counters;
int coverage_srv_fd;