[llvm-commits] [compiler-rt] r163197 - in /compiler-rt/trunk/lib: sanitizer_common/sanitizer_common.h sanitizer_common/sanitizer_symbolizer.cc sanitizer_common/sanitizer_symbolizer_linux.cc tsan/rtl/tsan_printf.cc tsan/rtl/tsan_rtl.cc tsan/rtl/tsan_rtl_report.cc tsan/rtl/tsan_suppressions.cc tsan/rtl/tsan_symbolize.cc tsan/rtl/tsan_symbolize_addr2line_linux.cc
Alexey Samsonov
samsonov at google.com
Wed Sep 5 00:23:44 PDT 2012
Author: samsonov
Date: Wed Sep 5 02:23:44 2012
New Revision: 163197
URL: http://llvm.org/viewvc/llvm-project?rev=163197&view=rev
Log:
[Sanitizer] Remove implicit conversion of InternalScopedBuffer<T> to T*
Modified:
compiler-rt/trunk/lib/sanitizer_common/sanitizer_common.h
compiler-rt/trunk/lib/sanitizer_common/sanitizer_symbolizer.cc
compiler-rt/trunk/lib/sanitizer_common/sanitizer_symbolizer_linux.cc
compiler-rt/trunk/lib/tsan/rtl/tsan_printf.cc
compiler-rt/trunk/lib/tsan/rtl/tsan_rtl.cc
compiler-rt/trunk/lib/tsan/rtl/tsan_rtl_report.cc
compiler-rt/trunk/lib/tsan/rtl/tsan_suppressions.cc
compiler-rt/trunk/lib/tsan/rtl/tsan_symbolize.cc
compiler-rt/trunk/lib/tsan/rtl/tsan_symbolize_addr2line_linux.cc
Modified: compiler-rt/trunk/lib/sanitizer_common/sanitizer_common.h
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/sanitizer_common/sanitizer_common.h?rev=163197&r1=163196&r2=163197&view=diff
==============================================================================
--- compiler-rt/trunk/lib/sanitizer_common/sanitizer_common.h (original)
+++ compiler-rt/trunk/lib/sanitizer_common/sanitizer_common.h Wed Sep 5 02:23:44 2012
@@ -67,7 +67,6 @@
~InternalScopedBuffer() {
UnmapOrDie(ptr_, cnt_ * sizeof(T));
}
- operator T*() { return ptr_; }
T &operator[](uptr i) { return ptr_[i]; }
T *data() { return ptr_; }
uptr size() { return cnt_ * sizeof(T); }
Modified: compiler-rt/trunk/lib/sanitizer_common/sanitizer_symbolizer.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/sanitizer_common/sanitizer_symbolizer.cc?rev=163197&r1=163196&r2=163197&view=diff
==============================================================================
--- compiler-rt/trunk/lib/sanitizer_common/sanitizer_symbolizer.cc (original)
+++ compiler-rt/trunk/lib/sanitizer_common/sanitizer_symbolizer.cc Wed Sep 5 02:23:44 2012
@@ -113,15 +113,16 @@
// large debug info.
static const int kMaxBufferSize = 4096;
InternalScopedBuffer<char> buffer(kMaxBufferSize);
- internal_snprintf(buffer, kMaxBufferSize, "%s 0x%zx\n",
+ char *buffer_data = buffer.data();
+ internal_snprintf(buffer_data, kMaxBufferSize, "%s 0x%zx\n",
module_name, module_offset);
- if (!writeToSymbolizer(buffer, internal_strlen(buffer)))
+ if (!writeToSymbolizer(buffer_data, internal_strlen(buffer_data)))
return 0;
- if (!readFromSymbolizer(buffer, kMaxBufferSize))
+ if (!readFromSymbolizer(buffer_data, kMaxBufferSize))
return 0;
- const char *str = buffer.data();
- int frame_id;
+ const char *str = buffer_data;
+ uptr frame_id;
CHECK_GT(max_frames, 0);
for (frame_id = 0; frame_id < max_frames; frame_id++) {
AddressInfo *info = &frames[frame_id];
Modified: compiler-rt/trunk/lib/sanitizer_common/sanitizer_symbolizer_linux.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/sanitizer_common/sanitizer_symbolizer_linux.cc?rev=163197&r1=163196&r2=163197&view=diff
==============================================================================
--- compiler-rt/trunk/lib/sanitizer_common/sanitizer_symbolizer_linux.cc (original)
+++ compiler-rt/trunk/lib/sanitizer_common/sanitizer_symbolizer_linux.cc Wed Sep 5 02:23:44 2012
@@ -126,17 +126,17 @@
if (data->current_n == 0) {
// First module is the binary itself.
uptr module_name_len = readlink("/proc/self/exe",
- module_name, module_name.size());
+ module_name.data(), module_name.size());
CHECK_NE(module_name_len, (uptr)-1);
CHECK_LT(module_name_len, module_name.size());
module_name[module_name_len] = '\0';
} else if (info->dlpi_name) {
- internal_strncpy(module_name, info->dlpi_name, module_name.size());
+ internal_strncpy(module_name.data(), info->dlpi_name, module_name.size());
}
if (module_name.data()[0] == '\0')
return 0;
void *mem = &data->modules[data->current_n];
- LoadedModule *cur_module = new(mem) LoadedModule(module_name,
+ LoadedModule *cur_module = new(mem) LoadedModule(module_name.data(),
info->dlpi_addr);
data->current_n++;
for (int i = 0; i < info->dlpi_phnum; i++) {
Modified: compiler-rt/trunk/lib/tsan/rtl/tsan_printf.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/tsan/rtl/tsan_printf.cc?rev=163197&r1=163196&r2=163197&view=diff
==============================================================================
--- compiler-rt/trunk/lib/tsan/rtl/tsan_printf.cc (original)
+++ compiler-rt/trunk/lib/tsan/rtl/tsan_printf.cc Wed Sep 5 02:23:44 2012
@@ -31,10 +31,10 @@
InternalScopedBuffer<char> buffer(kMaxLen);
va_list args;
va_start(args, format);
- uptr len = VSNPrintf(buffer, buffer.size(), format, args);
+ uptr len = VSNPrintf(buffer.data(), buffer.size(), format, args);
va_end(args);
internal_write(CTX() ? flags()->log_fileno : 2,
- buffer, len < buffer.size() ? len : buffer.size() - 1);
+ buffer.data(), len < buffer.size() ? len : buffer.size() - 1);
}
} // namespace __tsan
Modified: compiler-rt/trunk/lib/tsan/rtl/tsan_rtl.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/tsan/rtl/tsan_rtl.cc?rev=163197&r1=163196&r2=163197&view=diff
==============================================================================
--- compiler-rt/trunk/lib/tsan/rtl/tsan_rtl.cc (original)
+++ compiler-rt/trunk/lib/tsan/rtl/tsan_rtl.cc Wed Sep 5 02:23:44 2012
@@ -122,8 +122,8 @@
fd_t fd = (fd_t)(uptr)arg;
for (int i = 0; ; i++) {
InternalScopedBuffer<char> buf(4096);
- WriteMemoryProfile(buf, buf.size(), i);
- internal_write(fd, buf, internal_strlen(buf));
+ WriteMemoryProfile(buf.data(), buf.size(), i);
+ internal_write(fd, buf.data(), internal_strlen(buf.data()));
SleepForSeconds(1);
}
}
@@ -132,9 +132,9 @@
if (flags()->profile_memory == 0 || flags()->profile_memory[0] == 0)
return;
InternalScopedBuffer<char> filename(4096);
- internal_snprintf(filename, filename.size(), "%s.%d",
+ internal_snprintf(filename.data(), filename.size(), "%s.%d",
flags()->profile_memory, GetPid());
- fd_t fd = internal_open(filename, true);
+ fd_t fd = internal_open(filename.data(), true);
if (fd == kInvalidFd) {
TsanPrintf("Failed to open memory profile file '%s'\n", &filename[0]);
Die();
Modified: compiler-rt/trunk/lib/tsan/rtl/tsan_rtl_report.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/tsan/rtl/tsan_rtl_report.cc?rev=163197&r1=163196&r2=163197&view=diff
==============================================================================
--- compiler-rt/trunk/lib/tsan/rtl/tsan_rtl_report.cc (original)
+++ compiler-rt/trunk/lib/tsan/rtl/tsan_rtl_report.cc Wed Sep 5 02:23:44 2012
@@ -296,7 +296,7 @@
if (pos == 0 && stack[0] == 0)
return;
pos++;
- stk->Init(stack, pos);
+ stk->Init(stack.data(), pos);
}
static bool HandleRacyStacks(ThreadState *thr, const StackTrace (&traces)[2],
Modified: compiler-rt/trunk/lib/tsan/rtl/tsan_suppressions.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/tsan/rtl/tsan_suppressions.cc?rev=163197&r1=163196&r2=163197&view=diff
==============================================================================
--- compiler-rt/trunk/lib/tsan/rtl/tsan_suppressions.cc (original)
+++ compiler-rt/trunk/lib/tsan/rtl/tsan_suppressions.cc Wed Sep 5 02:23:44 2012
@@ -28,10 +28,10 @@
return 0;
InternalScopedBuffer<char> tmp(4*1024);
if (filename[0] == '/')
- internal_snprintf(tmp, tmp.size(), "%s", filename);
+ internal_snprintf(tmp.data(), tmp.size(), "%s", filename);
else
- internal_snprintf(tmp, tmp.size(), "%s/%s", GetPwd(), filename);
- fd_t fd = internal_open(tmp, false);
+ internal_snprintf(tmp.data(), tmp.size(), "%s/%s", GetPwd(), filename);
+ fd_t fd = internal_open(tmp.data(), false);
if (fd == kInvalidFd) {
TsanPrintf("ThreadSanitizer: failed to open suppressions file '%s'\n",
tmp.data());
Modified: compiler-rt/trunk/lib/tsan/rtl/tsan_symbolize.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/tsan/rtl/tsan_symbolize.cc?rev=163197&r1=163196&r2=163197&view=diff
==============================================================================
--- compiler-rt/trunk/lib/tsan/rtl/tsan_symbolize.cc (original)
+++ compiler-rt/trunk/lib/tsan/rtl/tsan_symbolize.cc Wed Sep 5 02:23:44 2012
@@ -50,7 +50,7 @@
InternalScopedBuffer<AddressInfo> addr_frames(kMaxAddrFrames);
for (uptr i = 0; i < kMaxAddrFrames; i++)
new(&addr_frames[i]) AddressInfo();
- uptr addr_frames_num = __sanitizer::SymbolizeCode(addr, addr_frames,
+ uptr addr_frames_num = __sanitizer::SymbolizeCode(addr, addr_frames.data(),
kMaxAddrFrames);
if (addr_frames_num == 0)
return NewReportStackEntry(addr);
Modified: compiler-rt/trunk/lib/tsan/rtl/tsan_symbolize_addr2line_linux.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/tsan/rtl/tsan_symbolize_addr2line_linux.cc?rev=163197&r1=163196&r2=163197&view=diff
==============================================================================
--- compiler-rt/trunk/lib/tsan/rtl/tsan_symbolize_addr2line_linux.cc (original)
+++ compiler-rt/trunk/lib/tsan/rtl/tsan_symbolize_addr2line_linux.cc Wed Sep 5 02:23:44 2012
@@ -87,7 +87,7 @@
DlIteratePhdrCtx *ctx = (DlIteratePhdrCtx*)arg;
InternalScopedBuffer<char> tmp(128);
if (ctx->is_first) {
- internal_snprintf(tmp, tmp.size(), "/proc/%d/exe", GetPid());
+ internal_snprintf(tmp.data(), tmp.size(), "/proc/%d/exe", GetPid());
info->dlpi_name = tmp.data();
}
ctx->is_first = false;
@@ -160,7 +160,7 @@
Die();
}
InternalScopedBuffer<char> func(1024);
- ssize_t len = internal_read(m->inp_fd, func, func.size() - 1);
+ ssize_t len = internal_read(m->inp_fd, func.data(), func.size() - 1);
if (len <= 0) {
TsanPrintf("ThreadSanitizer: can't read from symbolizer (%d, %d)\n",
m->inp_fd, errno);
@@ -170,11 +170,11 @@
ReportStack *res = NewReportStackEntry(addr);
res->module = internal_strdup(m->name);
res->offset = offset;
- char *pos = (char*)internal_strchr(func, '\n');
+ char *pos = (char*)internal_strchr(func.data(), '\n');
if (pos && func[0] != '?') {
- res->func = (char*)internal_alloc(MBlockReportStack, pos - func + 1);
- internal_memcpy(res->func, func, pos - func);
- res->func[pos - func] = 0;
+ res->func = (char*)internal_alloc(MBlockReportStack, pos - func.data() + 1);
+ internal_memcpy(res->func, func.data(), pos - func.data());
+ res->func[pos - func.data()] = 0;
char *pos2 = (char*)internal_strchr(pos, ':');
if (pos2) {
res->file = (char*)internal_alloc(MBlockReportStack, pos2 - pos - 1 + 1);
More information about the llvm-commits
mailing list