[compiler-rt] r182132 - [nolibc] Move all platforms to internal_getpid.
Peter Collingbourne
peter at pcc.me.uk
Fri May 17 09:56:54 PDT 2013
Author: pcc
Date: Fri May 17 11:56:53 2013
New Revision: 182132
URL: http://llvm.org/viewvc/llvm-project?rev=182132&view=rev
Log:
[nolibc] Move all platforms to internal_getpid.
Before, we had an unused internal_getpid function for Linux, and a
platform-independent GetPid function. To make the naming conventions
consistent for syscall-like functions, the GetPid syscall wrapper
in sanitizer_posix.cc is moved to sanitizer_mac.cc, and GetPid is
renamed to internal_getpid, bringing the Linux variant into use.
Modified:
compiler-rt/trunk/lib/asan/asan_rtl.cc
compiler-rt/trunk/lib/sanitizer_common/sanitizer_common.cc
compiler-rt/trunk/lib/sanitizer_common/sanitizer_common.h
compiler-rt/trunk/lib/sanitizer_common/sanitizer_libc.h
compiler-rt/trunk/lib/sanitizer_common/sanitizer_mac.cc
compiler-rt/trunk/lib/sanitizer_common/sanitizer_posix.cc
compiler-rt/trunk/lib/sanitizer_common/sanitizer_printf.cc
compiler-rt/trunk/lib/sanitizer_common/sanitizer_win.cc
compiler-rt/trunk/lib/tsan/rtl/tsan_interceptors.cc
compiler-rt/trunk/lib/tsan/rtl/tsan_interface_ann.cc
compiler-rt/trunk/lib/tsan/rtl/tsan_platform_linux.cc
compiler-rt/trunk/lib/tsan/rtl/tsan_report.cc
compiler-rt/trunk/lib/tsan/rtl/tsan_rtl.cc
compiler-rt/trunk/lib/tsan/rtl/tsan_suppressions.cc
compiler-rt/trunk/lib/tsan/rtl/tsan_symbolize_addr2line_linux.cc
Modified: compiler-rt/trunk/lib/asan/asan_rtl.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/asan/asan_rtl.cc?rev=182132&r1=182131&r2=182132&view=diff
==============================================================================
--- compiler-rt/trunk/lib/asan/asan_rtl.cc (original)
+++ compiler-rt/trunk/lib/asan/asan_rtl.cc Fri May 17 11:56:53 2013
@@ -524,7 +524,7 @@ void __asan_init() {
0, true, 0, &create_main_args);
CHECK_EQ(0, main_tid);
SetCurrentThread(main_thread);
- main_thread->ThreadStart(GetPid());
+ main_thread->ThreadStart(internal_getpid());
force_interface_symbols(); // no-op.
InitializeAllocator();
Modified: compiler-rt/trunk/lib/sanitizer_common/sanitizer_common.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/sanitizer_common/sanitizer_common.cc?rev=182132&r1=182131&r2=182132&view=diff
==============================================================================
--- compiler-rt/trunk/lib/sanitizer_common/sanitizer_common.cc (original)
+++ compiler-rt/trunk/lib/sanitizer_common/sanitizer_common.cc Fri May 17 11:56:53 2013
@@ -35,7 +35,7 @@ fd_t report_fd = kStderrFd;
static char report_path_prefix[4096]; // Set via __sanitizer_set_report_path.
// PID of process that opened |report_fd|. If a fork() occurs, the PID of the
// child thread will be different from |report_fd_pid|.
-static int report_fd_pid = 0;
+static uptr report_fd_pid = 0;
static void (*DieCallback)(void);
void SetDieCallback(void (*callback)(void)) {
@@ -65,10 +65,10 @@ void NORETURN CheckFailed(const char *fi
}
void MaybeOpenReportFile() {
- if (!log_to_file || (report_fd_pid == GetPid())) return;
+ if (!log_to_file || (report_fd_pid == internal_getpid())) return;
InternalScopedBuffer<char> report_path_full(4096);
internal_snprintf(report_path_full.data(), report_path_full.size(),
- "%s.%d", report_path_prefix, GetPid());
+ "%s.%d", report_path_prefix, internal_getpid());
uptr openrv = OpenFile(report_path_full.data(), true);
if (internal_iserror(openrv)) {
report_fd = kStderrFd;
@@ -81,7 +81,7 @@ void MaybeOpenReportFile() {
internal_close(report_fd);
}
report_fd = openrv;
- report_fd_pid = GetPid();
+ report_fd_pid = internal_getpid();
}
void RawWrite(const char *buffer) {
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=182132&r1=182131&r2=182132&view=diff
==============================================================================
--- compiler-rt/trunk/lib/sanitizer_common/sanitizer_common.h (original)
+++ compiler-rt/trunk/lib/sanitizer_common/sanitizer_common.h Fri May 17 11:56:53 2013
@@ -40,7 +40,6 @@ uptr GetPageSize();
uptr GetPageSizeCached();
uptr GetMmapGranularity();
// Threads
-int GetPid();
uptr GetTid();
uptr GetThreadSelf();
void GetThreadStackTopAndBottom(bool at_initialization, uptr *stack_top,
Modified: compiler-rt/trunk/lib/sanitizer_common/sanitizer_libc.h
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/sanitizer_common/sanitizer_libc.h?rev=182132&r1=182131&r2=182132&view=diff
==============================================================================
--- compiler-rt/trunk/lib/sanitizer_common/sanitizer_libc.h (original)
+++ compiler-rt/trunk/lib/sanitizer_common/sanitizer_libc.h Fri May 17 11:56:53 2013
@@ -85,6 +85,7 @@ uptr internal_lseek(fd_t fd, OFF_T offse
uptr internal_ptrace(int request, int pid, void *addr, void *data);
uptr internal_waitpid(int pid, int *status, int options);
+uptr internal_getpid();
uptr internal_getppid();
// Threading
Modified: compiler-rt/trunk/lib/sanitizer_common/sanitizer_mac.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/sanitizer_common/sanitizer_mac.cc?rev=182132&r1=182131&r2=182132&view=diff
==============================================================================
--- compiler-rt/trunk/lib/sanitizer_common/sanitizer_mac.cc (original)
+++ compiler-rt/trunk/lib/sanitizer_common/sanitizer_mac.cc Fri May 17 11:56:53 2013
@@ -115,6 +115,10 @@ void internal__exit(int exitcode) {
_exit(exitcode);
}
+uptr internal_getpid() {
+ return getpid();
+}
+
// ----------------- sanitizer_common.h
bool FileExists(const char *filename) {
struct stat st;
Modified: compiler-rt/trunk/lib/sanitizer_common/sanitizer_posix.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/sanitizer_common/sanitizer_posix.cc?rev=182132&r1=182131&r2=182132&view=diff
==============================================================================
--- compiler-rt/trunk/lib/sanitizer_common/sanitizer_posix.cc (original)
+++ compiler-rt/trunk/lib/sanitizer_common/sanitizer_posix.cc Fri May 17 11:56:53 2013
@@ -43,10 +43,6 @@ uptr GetMmapGranularity() {
return GetPageSize();
}
-int GetPid() {
- return getpid();
-}
-
u32 GetUid() {
return getuid();
}
Modified: compiler-rt/trunk/lib/sanitizer_common/sanitizer_printf.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/sanitizer_common/sanitizer_printf.cc?rev=182132&r1=182131&r2=182132&view=diff
==============================================================================
--- compiler-rt/trunk/lib/sanitizer_common/sanitizer_printf.cc (original)
+++ compiler-rt/trunk/lib/sanitizer_common/sanitizer_printf.cc Fri May 17 11:56:53 2013
@@ -218,7 +218,7 @@ static void SharedPrintfCode(bool append
}
needed_length = 0;
if (append_pid) {
- int pid = GetPid();
+ int pid = internal_getpid();
needed_length += internal_snprintf(buffer, buffer_size, "==%d==", pid);
if (needed_length >= buffer_size) {
// The pid doesn't fit into the current buffer.
Modified: compiler-rt/trunk/lib/sanitizer_common/sanitizer_win.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/sanitizer_common/sanitizer_win.cc?rev=182132&r1=182131&r2=182132&view=diff
==============================================================================
--- compiler-rt/trunk/lib/sanitizer_common/sanitizer_win.cc (original)
+++ compiler-rt/trunk/lib/sanitizer_common/sanitizer_win.cc Fri May 17 11:56:53 2013
@@ -44,7 +44,7 @@ bool FileExists(const char *filename) {
UNIMPLEMENTED();
}
-int GetPid() {
+uptr internal_getpid() {
return GetProcessId(GetCurrentProcess());
}
Modified: compiler-rt/trunk/lib/tsan/rtl/tsan_interceptors.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/tsan/rtl/tsan_interceptors.cc?rev=182132&r1=182131&r2=182132&view=diff
==============================================================================
--- compiler-rt/trunk/lib/tsan/rtl/tsan_interceptors.cc (original)
+++ compiler-rt/trunk/lib/tsan/rtl/tsan_interceptors.cc Fri May 17 11:56:53 2013
@@ -1754,11 +1754,11 @@ TSAN_INTERCEPTOR(int, kill, int pid, int
SignalContext *sctx = SigCtx(thr);
CHECK_NE(sctx, 0);
int prev = sctx->int_signal_send;
- if (pid == GetPid()) {
+ if (pid == (int)internal_getpid()) {
sctx->int_signal_send = sig;
}
int res = REAL(kill)(pid, sig);
- if (pid == GetPid()) {
+ if (pid == (int)internal_getpid()) {
CHECK_EQ(sctx->int_signal_send, sig);
sctx->int_signal_send = prev;
}
Modified: compiler-rt/trunk/lib/tsan/rtl/tsan_interface_ann.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/tsan/rtl/tsan_interface_ann.cc?rev=182132&r1=182131&r2=182132&view=diff
==============================================================================
--- compiler-rt/trunk/lib/tsan/rtl/tsan_interface_ann.cc (original)
+++ compiler-rt/trunk/lib/tsan/rtl/tsan_interface_ann.cc Fri May 17 11:56:53 2013
@@ -196,7 +196,7 @@ void PrintMatchedBenignRaces() {
&ExpectRace::addcount);
if (hit_matched.Size()) {
Printf("ThreadSanitizer: Matched %d \"benign\" races (pid=%d):\n",
- hit_count, GetPid());
+ hit_count, (int)internal_getpid());
for (uptr i = 0; i < hit_matched.Size(); i++) {
Printf("%d %s:%d %s\n",
hit_matched[i].hitcount, hit_matched[i].file,
@@ -206,7 +206,7 @@ void PrintMatchedBenignRaces() {
if (hit_matched.Size()) {
Printf("ThreadSanitizer: Annotated %d \"benign\" races, %d unique"
" (pid=%d):\n",
- add_count, unique_count, GetPid());
+ add_count, unique_count, (int)internal_getpid());
for (uptr i = 0; i < add_matched.Size(); i++) {
Printf("%d %s:%d %s\n",
add_matched[i].addcount, add_matched[i].file,
Modified: compiler-rt/trunk/lib/tsan/rtl/tsan_platform_linux.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/tsan/rtl/tsan_platform_linux.cc?rev=182132&r1=182131&r2=182132&view=diff
==============================================================================
--- compiler-rt/trunk/lib/tsan/rtl/tsan_platform_linux.cc (original)
+++ compiler-rt/trunk/lib/tsan/rtl/tsan_platform_linux.cc Fri May 17 11:56:53 2013
@@ -176,8 +176,8 @@ static void MapRodata() {
if (tmpdir == 0)
return;
char filename[256];
- internal_snprintf(filename, sizeof(filename), "%s/tsan.rodata.%u",
- tmpdir, GetPid());
+ internal_snprintf(filename, sizeof(filename), "%s/tsan.rodata.%d",
+ tmpdir, (int)internal_getpid());
uptr openrv = internal_open(filename, O_RDWR | O_CREAT | O_EXCL, 0600);
if (internal_iserror(openrv))
return;
Modified: compiler-rt/trunk/lib/tsan/rtl/tsan_report.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/tsan/rtl/tsan_report.cc?rev=182132&r1=182131&r2=182132&view=diff
==============================================================================
--- compiler-rt/trunk/lib/tsan/rtl/tsan_report.cc (original)
+++ compiler-rt/trunk/lib/tsan/rtl/tsan_report.cc Fri May 17 11:56:53 2013
@@ -179,7 +179,8 @@ ReportStack *SkipTsanInternalFrames(Repo
void PrintReport(const ReportDesc *rep) {
Printf("==================\n");
const char *rep_typ_str = ReportTypeString(rep->typ);
- Printf("WARNING: ThreadSanitizer: %s (pid=%d)\n", rep_typ_str, GetPid());
+ Printf("WARNING: ThreadSanitizer: %s (pid=%d)\n", rep_typ_str,
+ (int)internal_getpid());
for (uptr i = 0; i < rep->stacks.Size(); i++) {
if (i)
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=182132&r1=182131&r2=182132&view=diff
==============================================================================
--- compiler-rt/trunk/lib/tsan/rtl/tsan_rtl.cc (original)
+++ compiler-rt/trunk/lib/tsan/rtl/tsan_rtl.cc Fri May 17 11:56:53 2013
@@ -120,7 +120,7 @@ static void BackgroundThread(void *arg)
if (flags()->profile_memory && flags()->profile_memory[0]) {
InternalScopedBuffer<char> filename(4096);
internal_snprintf(filename.data(), filename.size(), "%s.%d",
- flags()->profile_memory, GetPid());
+ flags()->profile_memory, (int)internal_getpid());
uptr openrv = OpenFile(filename.data(), true);
if (internal_iserror(openrv)) {
Printf("ThreadSanitizer: failed to open memory profile file '%s'\n",
@@ -229,19 +229,19 @@ void Initialize(ThreadState *thr) {
if (ctx->flags.verbosity)
Printf("***** Running under ThreadSanitizer v2 (pid %d) *****\n",
- GetPid());
+ (int)internal_getpid());
// Initialize thread 0.
int tid = ThreadCreate(thr, 0, 0, true);
CHECK_EQ(tid, 0);
- ThreadStart(thr, tid, GetPid());
+ ThreadStart(thr, tid, internal_getpid());
CHECK_EQ(thr->in_rtl, 1);
ctx->initialized = true;
if (flags()->stop_on_start) {
Printf("ThreadSanitizer is suspended at startup (pid %d)."
" Call __tsan_resume().\n",
- GetPid());
+ (int)internal_getpid());
while (__tsan_resumed == 0) {}
}
}
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=182132&r1=182131&r2=182132&view=diff
==============================================================================
--- compiler-rt/trunk/lib/tsan/rtl/tsan_suppressions.cc (original)
+++ compiler-rt/trunk/lib/tsan/rtl/tsan_suppressions.cc Fri May 17 11:56:53 2013
@@ -194,7 +194,7 @@ void PrintMatchedSuppressions() {
if (hit_count == 0)
return;
Printf("ThreadSanitizer: Matched %d suppressions (pid=%d):\n",
- hit_count, GetPid());
+ hit_count, (int)internal_getpid());
for (Suppression *supp = g_suppressions; supp; supp = supp->next) {
if (supp->hit_count == 0)
continue;
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=182132&r1=182131&r2=182132&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 Fri May 17 11:56:53 2013
@@ -87,7 +87,8 @@ static int dl_iterate_phdr_cb(dl_phdr_in
DlIteratePhdrCtx *ctx = (DlIteratePhdrCtx*)arg;
InternalScopedBuffer<char> tmp(128);
if (ctx->is_first) {
- internal_snprintf(tmp.data(), tmp.size(), "/proc/%d/exe", GetPid());
+ internal_snprintf(tmp.data(), tmp.size(), "/proc/%d/exe",
+ (int)internal_getpid());
info->dlpi_name = tmp.data();
}
ctx->is_first = false;
More information about the llvm-commits
mailing list