Namespaces

Enumerations

enum SockType
Name Value
kStream 100
kDgram 101
kSeqPacket 102

Use arbitrarily high values to avoid that some code accidentally ends up

assuming that these enum values match the sysroot's SOCK_xxx defines rather

than using MkSockType() / MkSockFamily().

Defined at line 58 of file ../../third_party/perfetto/include/perfetto/ext/base/unix_socket.h

enum SockFamily
Name Value
kUnspec 0
kUnix 200
kInet 201
kInet6 202
kVsock 203

Defined at line 59 of file ../../third_party/perfetto/include/perfetto/ext/base/unix_socket.h

enum SockPeerCredMode
Name Value
kReadOnConnect 0
kIgnore 1
kDefault kIgnore

Controls the getsockopt(SO_PEERCRED) behavior, which allows to obtain the

peer credentials.

Defined at line 63 of file ../../third_party/perfetto/include/perfetto/ext/base/unix_socket.h

Records

Functions

  • template <typename T, size_t TSize>
    size_t ArraySize (const T (&)[TSize] )

    Defined at line 70 of file ../../third_party/perfetto/include/perfetto/ext/base/utils.h

  • template <typename T>
    T AssumeLittleEndian (T value)

    Defined at line 84 of file ../../third_party/perfetto/include/perfetto/ext/base/utils.h

  • size_t AlignUp (size_t size, size_t alignment)

    Round up |size| to a multiple of |alignment| (must be a power of two).

    Defined at line 92 of file ../../third_party/perfetto/include/perfetto/ext/base/utils.h

  • template <size_t alignment>
    size_t AlignUp (size_t size)

    TODO(primiano): clean this up and move all existing usages to the constexpr

    version above.

    Defined at line 99 of file ../../third_party/perfetto/include/perfetto/ext/base/utils.h

  • template <typename T>
    AlignedUniquePtr<T> AlignedAllocTyped (size_t n_membs)

    Defined at line 160 of file ../../third_party/perfetto/include/perfetto/ext/base/utils.h

  • ClockSnapshotVector CaptureClockSnapshots ()

    Takes snapshots of clock readings of all supported built-in clocks.

  • void SleepMicroseconds (unsigned int interval_us)
  • void InitializeTime ()
  • PlatformThreadId GetThreadId ()

    Not inlined because the result is cached internally.

  • int ClosePlatformHandle (PlatformHandle )

    The definition of this lives in base/file_utils.cc (to avoid creating an

    extra build edge for a one liner). This is really an alias for close() (UNIX)

    CloseHandle() (Windows). THe indirection layer is just to avoid leaking

    system headers like windows.h through perfetto headers.

    Thre return value is always UNIX-style: 0 on success, -1 on failure.

  • TimeSeconds GetBootTimeS ()

    Defined at line 260 of file ../../third_party/perfetto/include/perfetto/base/time.h

  • TimeMillis GetBootTimeMs ()

    Defined at line 264 of file ../../third_party/perfetto/include/perfetto/base/time.h

  • SockFamily GetSockFamily (const char * addr)

    Returns the socket family from the full address that perfetto uses.

    Addr can be:

    - /path/to/socket : for linked AF_UNIX sockets.

    -

    : for abstract AF_UNIX sockets.

    - 1.2.3.4:8080 : for Inet sockets.

    - [::1]:8080 : for Inet6 sockets.

    - vsock://-1:3000 : for VM sockets.

  • std::vector<NetAddrInfo> GetNetAddrInfo (const std::string & ip, const std::string & port)

    Returns a list of NetAddrInfo from ip and port which

    ip can be an ipv4 or an ipv6 or a domain.

    127.0.0.1 : ipv4 address

    localhost : domain

    ::1 : ipv6 address

    port is a normal tcp port as string.

  • PlatformProcessId GetProcessId ()

    Defined at line 41 of file ../../third_party/perfetto/include/perfetto/base/proc_utils.h

  • TimeNanos FromPosixTimespec (const struct timespec & ts)

    Defined at line 54 of file ../../third_party/perfetto/include/perfetto/base/time.h

  • std::string HexDump (const std::string & data, size_t bytes_per_line)

    Defined at line 192 of file ../../third_party/perfetto/include/perfetto/ext/base/utils.h

  • TimeMillis GetWallTimeMs ()

    Defined at line 268 of file ../../third_party/perfetto/include/perfetto/base/time.h

  • TimeSeconds GetWallTimeS ()

    Defined at line 272 of file ../../third_party/perfetto/include/perfetto/base/time.h

  • Uuid Uuidv4 ()
  • int CloseFile (int fd)

    Declared in file_utils.h. Forward declared to avoid #include cycles.

  • uint32_t GetSysPageSize ()

    Returns the system's page size. Use this when dealing with mmap, madvise and

    similar mm-related syscalls.

    This function might be called in hot paths. Avoid calling getpagesize() all

    the times, in many implementations getpagesize() calls sysconf() which is

    not cheap.

    Defined at line 63 of file ../../third_party/perfetto/include/perfetto/ext/base/utils.h

  • bool IsAgain (int err)

    Defined at line 104 of file ../../third_party/perfetto/include/perfetto/ext/base/utils.h

  • TimeNanos GetTimeInternalNs (clockid_t clk_id)

    Defined at line 222 of file ../../third_party/perfetto/include/perfetto/base/time.h

  • TimeNanos GetBootTimeNs ()

    Return ns from boot. Conversely to GetWallTimeNs, this clock counts also time

    during suspend (when supported).

    Defined at line 230 of file ../../third_party/perfetto/include/perfetto/base/time.h

  • TimeNanos GetWallTimeNs ()

    Defined at line 240 of file ../../third_party/perfetto/include/perfetto/base/time.h

  • TimeNanos GetWallTimeRawNs ()

    Defined at line 244 of file ../../third_party/perfetto/include/perfetto/base/time.h

  • TimeNanos GetThreadCPUTimeNs ()

    Defined at line 255 of file ../../third_party/perfetto/include/perfetto/base/time.h

  • void SetEnv (const std::string & key, const std::string & value)

    setenv(2)-equivalent. Deals with Windows vs Posix discrepancies.

  • void UnsetEnv (const std::string & key)

    unsetenv(2)-equivalent. Deals with Windows vs Posix discrepancies.

  • void MaybeReleaseAllocatorMemToOS ()

    Calls mallopt(M_PURGE, 0) on Android. Does nothing on other platforms.

    This forces the allocator to release freed memory. This is used to work

    around various Scudo inefficiencies. See b/170217718.

  • uid_t GetCurrentUserId ()

    geteuid() on POSIX OSes, returns 0 on Windows (See comment in utils.cc).

  • void Daemonize (std::function<int ()> parent_cb)

    Forks the process.

    Parent: prints the PID of the child, calls |parent_cb| and exits from the

    process with its return value.

    Child: redirects stdio onto /dev/null, chdirs into / and returns.

  • std::string GetCurExecutablePath ()

    Returns the path of the current executable, e.g. /foo/bar/exe.

  • std::string GetCurExecutableDir ()

    Returns the directory where the current executable lives in, e.g. /foo/bar.

    This is independent of cwd().

  • void * AlignedAlloc (size_t alignment, size_t size)

    Memory returned by AlignedAlloc() must be freed via AlignedFree() not just

    free. It makes a difference on Windows where _aligned_malloc() and

    _aligned_free() must be paired.

    Prefer using the AlignedAllocTyped() below which takes care of the pairing.

  • void AlignedFree (void * )
  • bool IsSyncMemoryTaggingEnabled ()

    Detects Sync-mode MTE (currently being tested in some Android builds).

    This is known to use extra memory for the stack history buffer.

  • std::string HexDump (const void * data, size_t len, size_t bytes_per_line)

    Returns a xxd-style hex dump (hex + ascii chars) of the input data.

  • std::string GetTimeFmt (const std::string & fmt)
  • std::optional<int32_t> GetTimezoneOffsetMins ()
  • bool SockShmemSupported (SockFamily sock_family)

    Returns whether inter-process shared memory is supported for the socket.

    Defined at line 108 of file ../../third_party/perfetto/include/perfetto/ext/base/unix_socket.h

  • bool SockShmemSupported (const char * addr)

    Defined at line 121 of file ../../third_party/perfetto/include/perfetto/ext/base/unix_socket.h

  • template <typename... T>
    void ignore_result (const T &... )

    Defined at line 157 of file ../../third_party/perfetto/include/perfetto/base/compiler.h

  • template <typename Func>
    OnScopeExitWrapper<Func> OnScopeExit (Func f)

    Defined at line 186 of file ../../third_party/perfetto/include/perfetto/ext/base/utils.h

  • struct timespec ToPosixTimespec (TimeMillis time)

    Defined at line 276 of file ../../third_party/perfetto/include/perfetto/base/time.h

  • int64_t TimeGm (struct tm * tms)

    Defined at line 286 of file ../../third_party/perfetto/include/perfetto/base/time.h

  • int64_t MkTime (int year, int month, int day, int h, int m, int s)

    Creates a time_t-compatible timestamp (seconds since epoch) from a tuple of

    y-m-d-h-m-s. It's a saner version of timegm(). Some remarks:

    The year is just the actual year (it's Y-1900 in timegm()).

    The month ranges 1-12 (it's 0-11 in timegm()).

    Defined at line 303 of file ../../third_party/perfetto/include/perfetto/base/time.h

  • uint64_t Rdtsc ()

    Defined at line 318 of file ../../third_party/perfetto/include/perfetto/base/time.h

  • std::unique_ptr<LinuxFileWatch> WatchUnixSocketCreation (TaskRunner * task_runnerconst char * sock_namestd::function<void ()> callback)

    Creates a LinuxFileWatch for the given unix socket.

    Returns nullptr if:

    - flags::use_unix_socket_inotify == false

    - `sock_name` is not a file-system linked unix socket.

    - The underlying filesystem doesn't support inotify (or other errors occur).

    - Any platform other than Linux/Android.

    When successful, the LinuxFileWatch is an opaque RAII handle that will remove

    the watch on destruction.