10#include <fuchsia/io/cpp/fidl.h>
11#include <fuchsia/mem/cpp/fidl.h>
12#include <lib/fdio/directory.h>
13#include <lib/fdio/io.h>
14#include <zircon/status.h>
22bool VmoFromFd(
int fd,
bool executable, fuchsia::mem::Buffer* buffer) {
24 FML_LOG(FATAL) <<
"Invalid buffer pointer";
27 struct stat stat_struct;
28 if (fstat(fd, &stat_struct) == -1) {
29 FML_LOG(ERROR) <<
"fstat failed: " << strerror(errno);
33 zx_handle_t result = ZX_HANDLE_INVALID;
36 status = fdio_get_vmo_exec(fd, &result);
38 status = fdio_get_vmo_copy(fd, &result);
41 if (status != ZX_OK) {
42 FML_LOG(ERROR) << (executable ?
"fdio_get_vmo_exec" :
"fdio_get_vmo_copy")
43 <<
" failed: " << zx_status_get_string(status);
47 buffer->vmo = zx::vmo(result);
48 buffer->size = stat_struct.st_size;
59 fuchsia::mem::Buffer* buffer) {
64 const std::string& filename,
66 fuchsia::mem::Buffer* buffer) {
67 fuchsia::io::Flags flags = fuchsia::io::PERM_READABLE;
69 flags |= fuchsia::io::PERM_EXECUTABLE;
72 const char* path = filename.c_str();
73 if (path && path[0] ==
'/') {
77 const zx_status_t status =
78 fdio_open3_fd_at(dirfd, path, uint64_t{flags}, &fd);
79 if (status != ZX_OK) {
80 FML_LOG(ERROR) <<
"fdio_open3_fd_at(" << dirfd <<
", \"" << filename
81 <<
"\", " << std::hex << uint64_t{flags}
82 <<
") failed: " << zx_status_get_string(status);
85 bool result = VmoFromFd(fd, executable, buffer);
90zx_status_t
IsSizeValid(
const fuchsia::mem::Buffer& buffer,
bool* is_valid) {
92 zx_status_t status = buffer.vmo.get_size(&vmo_size);
93 if (status == ZX_OK) {
94 *is_valid = vmo_size >= buffer.size;
#define FML_LOG(severity)
bool VmoFromFilenameAt(int dirfd, const std::string &filename, bool executable, fuchsia::mem::Buffer *buffer)
bool VmoFromFilename(const std::string &filename, bool executable, fuchsia::mem::Buffer *buffer)
zx_status_t IsSizeValid(const fuchsia::mem::Buffer &buffer, bool *is_valid)
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 to the cache directory This is different from the persistent_cache_path in embedder which is used for Skia shader cache icu native lib Path to the library file that exports the ICU data vm service The hostname IP address on which the Dart VM Service should be served If not defaults to or::depending on whether ipv6 is specified disable vm Disable the Dart VM Service The Dart VM Service is never available in release mode Bind to the IPv6 localhost address for the Dart VM Service Ignored if vm service host is set profile Make the profiler discard new samples once the profiler sample buffer is full When this flag is not the profiler sample buffer is used as a ring buffer