Flutter Engine
The Flutter Engine
Static Public Member Functions | List of all members
dart::bin::EXEUtils Class Reference

#include <exe_utils.h>

Static Public Member Functions

static CStringUniquePtr GetDirectoryPrefixFromResolvedExeName ()
 
static CStringUniquePtr GetDirectoryPrefixFromUnresolvedExeName ()
 
static void LoadDartProfilerSymbols (const char *exepath)
 

Detailed Description

Definition at line 18 of file exe_utils.h.

Member Function Documentation

◆ GetDirectoryPrefixFromResolvedExeName()

CStringUniquePtr dart::bin::EXEUtils::GetDirectoryPrefixFromResolvedExeName ( )
static

Definition at line 68 of file exe_utils.cc.

68 {
69 const char* name = nullptr;
70 const int kTargetSize = PATH_MAX;
71 char target[kTargetSize];
72 intptr_t target_size =
74 if (target_size > 0 && target_size < kTargetSize - 1) {
75 target[target_size] = 0;
76 name = target;
77 }
78 if (name == nullptr) {
80 target_size = strlen(name);
81 ASSERT(target_size < kTargetSize);
82 }
83 Namespace* namespc = Namespace::Create(Namespace::Default());
84 char* result;
85 if (File::GetType(namespc, name, false) == File::kIsLink) {
86 char dir_path[kTargetSize];
87 // cwd is currently wherever we launched from, so set the cwd to the
88 // directory of the symlink while we try and resolve it. If we don't
89 // do this, we won't be able to properly resolve relative paths.
91 // We might run into symlinks of symlinks, so make sure we follow the
92 // links all the way. See https://github.com/dart-lang/sdk/issues/41057 for
93 // an example where this happens with brew on MacOS.
94 do {
96 // Resolve the link without creating Dart scope String.
98 kTargetSize);
99 if (name == nullptr) {
101 }
102 } while (File::GetType(namespc, name, false) == File::kIsLink);
103 target_size = strlen(name);
104
105 char absolute_path[kTargetSize];
106
107 // Get the absolute path after we've resolved all the symlinks and before
108 // we reset the cwd, otherwise path resolution will fail.
109 File::GetCanonicalPath(namespc, name, absolute_path, kTargetSize);
110
111 // Reset cwd to the original value.
112 Directory::SetCurrent(namespc, initial_dir_path.get());
113
114 result = GetDirectoryFromPath(absolute_path, nullptr);
115 } else {
117 }
118 namespc->Release();
119 return CStringUniquePtr(result == nullptr ? Utils::StrDup("") : result);
120}
static char * StrDup(const char *s)
static bool SetCurrent(Namespace *namespc, const char *path)
Definition: directory.cc:562
static char * CurrentNoScope()
static const char * GetCanonicalPath(Namespace *namespc, const char *path, char *dest=nullptr, int dest_size=0)
static const char * LinkTarget(Namespace *namespc, const char *pathname, char *dest=nullptr, int dest_size=0)
static Type GetType(Namespace *namespc, const char *path, bool follow_links)
static Namespace * Create(intptr_t namespc)
static intptr_t Default()
static const char * GetExecutableName()
static intptr_t ResolveExecutablePathInto(char *result, size_t result_size)
#define ASSERT(E)
GAsyncResult * result
uint32_t * target
static char * GetDirectoryFromPath(const char *path, char *dir)
Definition: exe_utils.cc:30
static const char * GetFileNameFromPath(const char *path)
Definition: exe_utils.cc:53
const char *const name
CAllocUniquePtr< char > CStringUniquePtr
Definition: utils.h:31
#define PATH_MAX
Definition: globals.h:708

◆ GetDirectoryPrefixFromUnresolvedExeName()

CStringUniquePtr dart::bin::EXEUtils::GetDirectoryPrefixFromUnresolvedExeName ( )
static

Definition at line 122 of file exe_utils.cc.

122 {
123 const char* exe = Platform::GetExecutableName();
124 return CStringUniquePtr(exe == nullptr ? nullptr
125 : GetDirectoryFromPath(exe, nullptr));
126}

◆ LoadDartProfilerSymbols()

void dart::bin::EXEUtils::LoadDartProfilerSymbols ( const char *  exepath)
static

Definition at line 129 of file exe_utils.cc.

129 {
130 char* path = reinterpret_cast<char*>(malloc(PATH_MAX + 5));
132
133 int len = strlen(path);
134 memcpy(path + len, ".sym", 5); // NOLINT
135 File* file = File::Open(nullptr, path, File::kRead);
136 free(path);
137 if (file == nullptr) return;
138
139 int64_t size = file->Length();
140 MappedMemory* mapping = file->Map(File::kReadOnly, 0, size);
141 Dart_AddSymbols(argv0, mapping->address(), size);
142 mapping->Leak(); // Let us delete the object but keep the mapping.
143 delete mapping;
144 file->Release();
145}
static File * Open(Namespace *namespc, const char *path, FileOpenMode mode)
void * malloc(size_t size)
Definition: allocation.cc:19
DART_EXPORT void Dart_AddSymbols(const char *dso_name, void *buffer, intptr_t buffer_size)
DEF_SWITCHES_START aot vmservice shared library Name of the *so containing AOT compiled Dart assets for launching the service isolate vm snapshot The VM snapshot data that will be memory mapped as read only SnapshotAssetPath must be present isolate snapshot The isolate snapshot data that will be memory mapped as read only SnapshotAssetPath must be present cache dir path
Definition: switches.h:57
it will be possible to load the file into Perfetto s trace viewer disable asset Prevents usage of any non test fonts unless they were explicitly Loaded via prefetched default font Indicates whether the embedding started a prefetch of the default font manager before creating the engine run In non interactive keep the shell running after the Dart script has completed enable serial On low power devices with low core running concurrent GC tasks on threads can cause them to contend with the UI thread which could potentially lead to jank This option turns off all concurrent GC activities domain network JSON encoded network policy per domain This overrides the DisallowInsecureConnections switch Embedder can specify whether to allow or disallow insecure connections at a domain level old gen heap size
Definition: switches.h:259

The documentation for this class was generated from the following files: