MCPcopy Create free account
hub / github.com/beefytech/Beef / TraceFd

Function TraceFd

BeefRT/gperftools/src/debugallocation.cc:929–945  ·  view source on GitHub ↗

Return the file descriptor we're writing a log to

Source from the content-addressed store, hash-verified

927
928// Return the file descriptor we're writing a log to
929static int TraceFd() {
930 static int trace_fd = -1;
931 if (trace_fd == -1) { // Open the trace file on the first call
932 trace_fd = open("/tmp/google.alloc", O_CREAT|O_TRUNC|O_WRONLY, 0666);
933 if (trace_fd == -1) {
934 trace_fd = 2;
935 TracePrintf(trace_fd,
936 "Can't open /tmp/google.alloc. Logging to stderr.\n");
937 }
938 // Add a header to the log.
939 TracePrintf(trace_fd, "Trace started: %lu\n",
940 static_cast<unsigned long>(time(NULL)));
941 TracePrintf(trace_fd,
942 "func\tsize\tptr\tthread_id\tstack pcs for tools/symbolize\n");
943 }
944 return trace_fd;
945}
946
947// Print the hex stack dump on a single line. PCs are separated by tabs.
948static void TraceStack(void) {

Callers 2

TraceStackFunction · 0.70
__malloctrace_writeFunction · 0.70

Calls 2

TracePrintfFunction · 0.70
openFunction · 0.50

Tested by

no test coverage detected