Home | History | Annotate | Download | only in libbacktrace

Lines Matching refs:Pid

103 static void WaitForStop(pid_t pid) {
107 while (ptrace(PTRACE_GETSIGINFO, pid, 0, &si) < 0 && (errno == EINTR || errno == ESRCH)) {
116 static void CreateRemoteProcess(pid_t* pid) {
117 if ((*pid = fork()) == 0) {
122 ASSERT_NE(-1, *pid);
124 ASSERT_TRUE(ptrace(PTRACE_ATTACH, *pid, 0, 0) == 0);
127 WaitForStop(*pid);
130 static void FinishRemoteProcess(pid_t pid) {
131 ASSERT_TRUE(ptrace(PTRACE_DETACH, pid, 0, 0) == 0);
133 kill(pid, SIGKILL);
134 ASSERT_EQ(waitpid(pid, nullptr, 0), pid);
307 static void VerifyProcTest(pid_t pid, pid_t tid, bool share_map, bool (*ReadyFunc)(Backtrace*),
311 ptrace_tid = pid;
326 map.reset(BacktraceMap::Create(pid));
328 std::unique_ptr<Backtrace> backtrace(Backtrace::Create(pid, tid, map.get()));
347 pid_t pid;
348 if ((pid = fork()) == 0) {
352 VerifyProcTest(pid, BACKTRACE_CURRENT_THREAD, false, ReadyLevelBacktrace, VerifyLevelDump);
354 kill(pid, SIGKILL);
356 ASSERT_EQ(waitpid(pid, &status, 0), pid);
360 pid_t pid;
361 if ((pid = fork()) == 0) {
366 VerifyProcTest(pid, BACKTRACE_CURRENT_THREAD, true, ReadyLevelBacktrace, VerifyLevelDump);
368 kill(pid, SIGKILL);
370 ASSERT_EQ(waitpid(pid, &status, 0), pid);
374 pid_t pid;
375 if ((pid = fork()) == 0) {
379 VerifyProcTest(pid, BACKTRACE_CURRENT_THREAD, false, ReadyMaxBacktrace, VerifyMaxDump);
381 kill(pid, SIGKILL);
383 ASSERT_EQ(waitpid(pid, &status, 0), pid);
387 std::unique_ptr<Backtrace> ign1(Backtrace::Create(bt_all->Pid(), BACKTRACE_CURRENT_THREAD));
392 std::unique_ptr<Backtrace> ign2(Backtrace::Create(bt_all->Pid(), BACKTRACE_CURRENT_THREAD));
401 pid_t pid;
402 if ((pid = fork()) == 0) {
406 VerifyProcTest(pid, BACKTRACE_CURRENT_THREAD, false, ReadyLevelBacktrace, VerifyProcessIgnoreFrames);
408 kill(pid, SIGKILL);
410 ASSERT_EQ(waitpid(pid, &status, 0), pid);
419 static void GetThreads(pid_t pid, std::vector<pid_t>* threads) {
422 snprintf(task_path, sizeof(task_path), "/proc/%d/task", pid);
437 pid_t pid;
438 if ((pid = fork()) == 0) {
457 GetThreads(pid, &threads);
462 ASSERT_TRUE(ptrace(PTRACE_ATTACH, pid, 0, 0) == 0);
463 WaitForStop(pid);
466 if (pid == *it) {
469 VerifyProcTest(pid, *it, false, ReadyLevelBacktrace, VerifyLevelDump);
472 FinishRemoteProcess(pid);
882 static void VerifyMap(pid_t pid) {
884 snprintf(buffer, sizeof(buffer), "/proc/%d/maps", pid);
897 std::unique_ptr<BacktraceMap> map(BacktraceMap::Create(pid));
912 pid_t pid;
913 CreateRemoteProcess(&pid);
916 VerifyMap(pid);
918 FinishRemoteProcess(pid);
1062 pid_t pid;
1063 if ((pid = fork()) == 0) {
1067 ASSERT_NE(-1, pid);
1072 if (ptrace(PTRACE_ATTACH, pid, 0, 0) == 0) {
1073 WaitForStop(pid);
1075 std::unique_ptr<Backtrace> backtrace(Backtrace::Create(pid, pid));
1095 ASSERT_TRUE(ptrace(PTRACE_DETACH, pid, 0, 0) == 0);
1102 kill(pid, SIGKILL);
1103 ASSERT_EQ(waitpid(pid, nullptr, 0), pid);
1208 pid_t pid;
1209 if ((pid = fork()) == 0) {
1236 ASSERT_TRUE(pid > 0);
1241 ASSERT_TRUE(ptrace(PTRACE_ATTACH, pid, 0, 0) == 0);
1244 WaitForStop(pid);
1246 std::unique_ptr<Backtrace> backtrace(Backtrace::Create(pid, BACKTRACE_CURRENT_THREAD));
1270 ASSERT_TRUE(ptrace(PTRACE_DETACH, pid, 0, 0) == 0);
1278 kill(pid, SIGKILL);
1279 ASSERT_EQ(waitpid(pid, nullptr, 0), pid);
1358 pid_t pid;
1359 if ((pid = fork()) == 0) {
1363 ASSERT_TRUE(pid > 0);
1369 ASSERT_TRUE(ptrace(PTRACE_ATTACH, pid, 0, 0) == 0);
1372 WaitForStop(pid);
1374 std::unique_ptr<Backtrace> backtrace(Backtrace::Create(pid, BACKTRACE_CURRENT_THREAD));
1387 ASSERT_TRUE(ptrace(PTRACE_DETACH, pid, 0, 0) == 0);
1395 kill(pid, SIGKILL);
1396 ASSERT_EQ(waitpid(pid, nullptr, 0), pid);
1421 pid_t pid;
1422 CreateRemoteProcess(&pid);
1425 std::unique_ptr<Backtrace> backtrace(Backtrace::Create(pid, pid));
1432 FinishRemoteProcess(pid);
1583 pid_t pid;
1584 CreateRemoteProcess(&pid);
1587 std::unique_ptr<Backtrace> backtrace(Backtrace::Create(pid, pid));
1595 FinishRemoteProcess(pid);
1634 pid_t pid;
1635 if ((pid = fork()) == 0) {
1646 ASSERT_NE(-1, pid);
1654 ASSERT_TRUE(ptrace(PTRACE_ATTACH, pid, 0, 0) == 0);
1656 WaitForStop(pid);
1658 std::unique_ptr<Backtrace> backtrace(Backtrace::Create(pid, pid));
1664 ASSERT_TRUE(ptrace(PTRACE_DETACH, pid, 0, 0) == 0);
1671 kill(pid, SIGUSR1);
1680 ASSERT_TRUE(ptrace(PTRACE_ATTACH, pid, 0, 0) == 0);
1682 WaitForStop(pid);
1684 backtrace.reset(Backtrace::Create(pid, pid));
1698 ASSERT_TRUE(ptrace(PTRACE_DETACH, pid, 0, 0) == 0);
1737 FinishRemoteProcess(pid);
1749 static void CheckForLeak(pid_t pid, pid_t tid) {
1752 Backtrace* backtrace = Backtrace::Create(pid, tid);
1763 Backtrace* backtrace = Backtrace::Create(pid, tid);
1797 pid_t pid;
1798 CreateRemoteProcess(&pid);
1800 CheckForLeak(pid, BACKTRACE_CURRENT_THREAD);
1802 FinishRemoteProcess(pid);