Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
Static Public Member Functions | List of all members
dart::bin::EXEUtils Class Reference

#include <exe_utils.h>

Static Public Member Functions

static Utils::CStringUniquePtr GetDirectoryPrefixFromExeName ()
 
static void LoadDartProfilerSymbols (const char *exepath)
 

Detailed Description

Definition at line 18 of file exe_utils.h.

Member Function Documentation

◆ GetDirectoryPrefixFromExeName()

Utils::CStringUniquePtr dart::bin::EXEUtils::GetDirectoryPrefixFromExeName ( )
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.
90 auto initial_dir_path =
92 // We might run into symlinks of symlinks, so make sure we follow the
93 // links all the way. See https://github.com/dart-lang/sdk/issues/41057 for
94 // an example where this happens with brew on MacOS.
95 do {
97 // Resolve the link without creating Dart scope String.
99 kTargetSize);
100 if (name == nullptr) {
102 }
103 } while (File::GetType(namespc, name, false) == File::kIsLink);
104 target_size = strlen(name);
105
106 char absolute_path[kTargetSize];
107
108 // Get the absolute path after we've resolved all the symlinks and before
109 // we reset the cwd, otherwise path resolution will fail.
110 File::GetCanonicalPath(namespc, name, absolute_path, kTargetSize);
111
112 // Reset cwd to the original value.
113 Directory::SetCurrent(namespc, initial_dir_path.get());
114
115 result = GetDirectoryFromPath(absolute_path, nullptr);
116 } else {
118 }
119 namespc->Release();
121 : result);
122}
static char * StrDup(const char *s)
static CStringUniquePtr CreateCStringUniquePtr(char *str)
Definition utils.cc:257
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
#define PATH_MAX
Definition globals.h:708

◆ LoadDartProfilerSymbols()

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

Definition at line 125 of file exe_utils.cc.

125 {
126 char* path = reinterpret_cast<char*>(malloc(PATH_MAX + 5));
127 if (Platform::ResolveExecutablePathInto(path, PATH_MAX) <= 0) return;
128
129 int len = strlen(path);
130 memcpy(path + len, ".sym", 5); // NOLINT
131 File* file = File::Open(nullptr, path, File::kRead);
132 free(path);
133 if (file == nullptr) return;
134
135 int64_t size = file->Length();
136 MappedMemory* mapping = file->Map(File::kReadOnly, 0, size);
137 Dart_AddSymbols(argv0, mapping->address(), size);
138 mapping->Leak(); // Let us delete the object but keep the mapping.
139 delete mapping;
140 file->Release();
141}
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: