23 #include <glog/logging.h> 27 using namespace folly;
34 constexpr
size_t kMaxAddresses = 100;
48 VLOG(1) <<
"getStackTrace\n";
52 VLOG(1) <<
"getStackTraceSafe\n";
81 TEST(StackTraceTest, Simple) {
85 TEST(StackTraceTest, Signal) {
87 memset(&sa, 0,
sizeof(sa));
89 sa.sa_flags = SA_RESETHAND | SA_SIGINFO;
90 CHECK_ERR(sigaction(SIGUSR1, &sa,
nullptr));
99 bytes_read =
read(fd, pos, size);
100 if (bytes_read < 0) {
101 if (errno == EAGAIN || errno == EWOULDBLOCK || errno == EINTR) {
109 }
while (bytes_read > 0 && size > 0);
116 off_t rv = lseek(fd, file_pos, SEEK_SET);
117 CHECK_EQ(rv, (off_t)file_pos);
120 ssize_t bytes_read =
read_all(fd, buffer, count - 1);
121 CHECK_GT(bytes_read, 0);
122 buffer[bytes_read] =
'\0';
123 return lseek(fd, 0, SEEK_CUR);
126 template <
class StackTracePr
inter>
130 printer.printStackTrace(
true);
133 std::array<uint8_t, 4000>
first;
137 printer.printStackTrace(
true);
140 std::array<uint8_t, 4000> second;
146 strchr(strchr((
const char*)first.data(),
'\n') + 1,
'\n') + 1,
147 strchr(strchr((
const char*)second.data(),
'\n') + 1,
'\n') + 1);
155 testStackTracePrinter<SafeStackTracePrinter>(printer, file.
fd());
162 std::make_unique<FDSymbolizePrinter>(file.
fd())};
164 testStackTracePrinter<FastStackTracePrinter>(printer, file.
fd());
#define ASSERT_GT(val1, val2)
std::vector< uint8_t > buffer(kBufferSize+16)
#define ASSERT_STREQ(s1, s2)
ssize_t getStackTraceSafe(uintptr_t *addresses, size_t maxAddresses)
#define EXPECT_EQ(val1, val2)
FOLLY_NOINLINE void foo2()
—— Concurrent Priority Queue Implementation ——
void println(uintptr_t address, const SymbolizedFrame &frame)
void handler(int, siginfo_t *, void *)
constexpr auto size(C const &c) -> decltype(c.size())
FOLLY_NOINLINE void foo1()
ssize_t getStackTrace(uintptr_t *addresses, size_t maxAddresses)
size_t read(T &out, folly::io::Cursor &cursor)
#define EXPECT_TRUE(condition)
off_t get_stack_trace(int fd, size_t file_pos, uint8_t *buffer, size_t count)
ssize_t read_all(int fd, uint8_t *buffer, size_t size)
void symbolize(const uintptr_t *addresses, SymbolizedFrame *frames, size_t frameCount)
TEST(SequencedExecutor, CPUThreadPoolExecutor)
void testStackTracePrinter(StackTracePrinter &printer, int fd)
constexpr detail::First first