[PATCH] Support for saving an ordered list of compilation units
Laszlo
lszekeres at cs.stonybrook.edu
Tue Feb 17 14:03:24 PST 2015
Hi kcc,
This patch supports the reconstruction of an IR level trace from the "events" file generated by the current tracer. This can be done if we know the ordered list of compilation units. This patch extends the tracer runtime to dump this list along with the "events" file. The LLVM half of the patch is submitted separately.
http://reviews.llvm.org/D7703
Files:
lib/sanitizer_common/sanitizer_coverage_libcdep.cc
Index: lib/sanitizer_common/sanitizer_coverage_libcdep.cc
===================================================================
--- lib/sanitizer_common/sanitizer_coverage_libcdep.cc
+++ lib/sanitizer_common/sanitizer_coverage_libcdep.cc
@@ -82,7 +82,7 @@
void TraceBasicBlock(s32 *id);
void InitializeGuardArray(s32 *guards);
- void InitializeGuards(s32 *guards, uptr n);
+ void InitializeGuards(s32 *guards, uptr n, const char *mod_name);
void ReinitializeGuards();
uptr *data();
@@ -110,6 +110,9 @@
// Vector of coverage guard arrays, protected by mu.
InternalMmapVectorNoCtor<s32*> guard_array_vec;
+ // Vector of module (compilation unit) names
+ InternalMmapVectorNoCtor<const char*> comp_unit_name_vec;
+
// Caller-Callee (cc) array, size and current index.
static const uptr kCcArrayMaxSize = FIRST_32_SECOND_64(1 << 18, 1 << 24);
uptr **cc_array;
@@ -286,13 +289,14 @@
atomic_store(&pc_array_size, size, memory_order_release);
}
-void CoverageData::InitializeGuards(s32 *guards, uptr n) {
+void CoverageData::InitializeGuards(s32 *guards, uptr n, const char *mod_name) {
// The array 'guards' has n+1 elements, we use the element zero
// to store 'n'.
CHECK_LT(n, 1 << 30);
guards[0] = static_cast<s32>(n);
InitializeGuardArray(guards);
SpinMutexLock l(&mu);
+ comp_unit_name_vec.push_back(mod_name);
guard_array_vec.push_back(guards);
}
@@ -450,6 +454,14 @@
internal_write(fd, out.data(), out.length());
internal_close(fd);
+ fd = CovOpenFile(false, "trace-compunits");
+ if (fd < 0) return;
+ out.clear();
+ for (uptr i = 0; i < comp_unit_name_vec.size(); i++)
+ out.append("%s\n", comp_unit_name_vec[i]);
+ internal_write(fd, out.data(), out.length());
+ internal_close(fd);
+
fd = CovOpenFile(false, "trace-events");
if (fd < 0) return;
uptr bytes_to_write = max_idx * sizeof(tr_event_array[0]);
@@ -675,9 +687,9 @@
coverage_data.Init();
}
SANITIZER_INTERFACE_ATTRIBUTE void __sanitizer_cov_dump() { CovDump(); }
-SANITIZER_INTERFACE_ATTRIBUTE void __sanitizer_cov_module_init(s32 *guards,
- uptr npcs) {
- coverage_data.InitializeGuards(guards, npcs);
+SANITIZER_INTERFACE_ATTRIBUTE void
+__sanitizer_cov_module_init(s32 *guards, uptr npcs, const char *mod_name) {
+ coverage_data.InitializeGuards(guards, npcs, mod_name);
if (!common_flags()->coverage_direct) return;
if (SANITIZER_ANDROID && coverage_enabled) {
// dlopen/dlclose interceptors do not work on Android, so we rely on
EMAIL PREFERENCES
http://reviews.llvm.org/settings/panel/emailpreferences/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D7703.20107.patch
Type: text/x-patch
Size: 2569 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20150217/ed226a66/attachment.bin>
More information about the llvm-commits
mailing list