12#if defined(TARGET_ARCH_IS_64_BIT) && defined(DART_PRECOMPILED_RUNTIME) && \
13 (defined(DART_TARGET_OS_ANDROID) || defined(DART_TARGET_OS_LINUX))
14#define SUPPORT_ANALYZE_SNAPSHOT
17#ifdef SUPPORT_ANALYZE_SNAPSHOT
23#ifdef SUPPORT_ANALYZE_SNAPSHOT
24#define STRING_OPTIONS_LIST(V) V(out, out_path)
26#define BOOL_OPTIONS_LIST(V) \
28 V(sdk_version, sdk_version)
30#define STRING_OPTION_DEFINITION(flag, variable) \
31 static const char* variable = nullptr; \
32 DEFINE_STRING_OPTION(flag, variable)
34#undef STRING_OPTION_DEFINITION
36#define BOOL_OPTION_DEFINITION(flag, variable) \
37 static bool variable = false; \
38 DEFINE_BOOL_OPTION(flag, variable)
40#undef BOOL_OPTION_DEFINITION
45"Usage: analyze_snapshot [<vm-flags>] [<options>] <snapshot_data> \n"
49" Display this message. \n"
51" Print the SDK version. \n"
53" Path to generate the analysis results JSON. \n"
54"If omitting [<vm-flags>] the VM parsing the snapshot is created with the \n"
55"following default flags: \n"
56"--enable_mirrors=false \n"
57"--background_compilation \n"
66const uint8_t* vm_isolate_data =
nullptr;
67const uint8_t* vm_isolate_instructions =
nullptr;
97 }
else if (sdk_version) {
103 if (
inputs->count() < 1) {
123 if (
file ==
nullptr) {
124 PrintErrAndExit(
"Error: Unable to write file: %s\n\n", filename);
129static void WriteFile(
const char* filename,
131 const intptr_t
size) {
135 PrintErrAndExit(
"Error: Unable to write file: %s\n\n", filename);
139int RunAnalyzer(
int argc,
char**
argv) {
141 const int EXTRA_VM_ARGUMENTS = 7;
149 if (out_path ==
nullptr) {
156 if (vm_options.
count() == 0) {
158 vm_options.
AddArgument(
"--background_compilation");
163 if (
error !=
nullptr) {
169 const char* script_name =
nullptr;
170 script_name =
inputs.GetArgument(0);
175 if (
file ==
nullptr) {
181 const char* loader_error =
nullptr;
186 if (loaded_elf ==
nullptr) {
193 memset(&init_params, 0,
sizeof(init_params));
203#if defined(DART_HOST_OS_FUCHSIA)
204 init_params.vmex_resource = Platform::GetVMEXResource();
208 if (
error !=
nullptr) {
214 auto isolate_group_data = std::unique_ptr<IsolateGroupData>(
221 vm_isolate_instructions, &isolate_flags,
222 isolate_group_data.get(),
225 if (
error !=
nullptr) {
233 vm_isolate_instructions};
236 intptr_t out_len = 0;
256#ifdef SUPPORT_ANALYZE_SNAPSHOT
257 return dart::bin::RunAnalyzer(argc,
argv);
261 "Requires SDK with following "
262 "flags:\n\tTARGET_ARCH_IS_64_BIT\n\tDART_PRECOMPILED_RUNTIME\n\tDART_"
263 "TARGET_OS_ANDROID || DART_TARGET_OS_LINUX");
static void info(const char *fmt,...) SK_PRINTF_LIKE(1
int main(int argc, char **argv)
static void PrintErr(const char *format,...) PRINTF_ATTRIBUTE(1
const char ** arguments() const
void AddArgument(const char *argument)
static void ReadFile(uint8_t **data, intptr_t *file_len, void *stream)
static bool EntropySource(uint8_t *buffer, intptr_t length)
static void CloseFile(void *stream)
static void * OpenFile(const char *name, bool write)
static void WriteFile(const void *buffer, intptr_t num_bytes, void *stream)
static File * Open(Namespace *namespc, const char *path, FileOpenMode mode)
static bool TryProcess(const char *option, CommandLineOptions *options)
static bool IsValidShortFlag(const char *name)
#define DART_INITIALIZE_PARAMS_CURRENT_VERSION
G_BEGIN_DECLS G_MODULE_EXPORT FlValue * args
const uint8_t uint32_t uint32_t GError ** error
uint32_t uint32_t * format
#define BOOL_OPTIONS_LIST(V)
#define STRING_OPTION_DEFINITION(flag, variable)
#define BOOL_OPTION_DEFINITION(flag, variable)
#define STRING_OPTIONS_LIST(V)
void WriteFile(const void *buffer, intptr_t num_bytes, void *stream)
const uint8_t * vm_snapshot_data
const uint8_t * vm_snapshot_instructions
constexpr int kErrorExitCode
static int ParseArguments(int argc, char **argv, CommandLineOptions *vm_options, CommandLineOptions *inputs)
PRINTF_ATTRIBUTE(1, 2) static void PrintErrAndExit(const char *format
void * OpenFile(const char *name, bool write)
void Dart_DumpSnapshotInformationAsJson(const Dart_SnapshotAnalyzerInformation &info, char **buffer, intptr_t *buffer_length)
DART_EXPORT void Dart_EnterScope()
DART_EXPORT void Dart_IsolateFlagsInitialize(Dart_IsolateFlags *flags)
DART_EXPORT char * Dart_Initialize(Dart_InitializeParams *params)
DART_EXPORT const char * Dart_VersionString()
DART_EXPORT Dart_Isolate Dart_CreateIsolateGroup(const char *script_uri, const char *name, const uint8_t *snapshot_data, const uint8_t *snapshot_instructions, Dart_IsolateFlags *flags, void *isolate_group_data, void *isolate_data, char **error)
DART_EXPORT char * Dart_SetVMFlags(int argc, const char **argv)
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 vm service A custom Dart VM Service port The default is to pick a randomly available open port disable vm Disable the Dart VM Service The Dart VM Service is never available in release mode disable vm service Disable mDNS Dart VM Service publication Bind to the IPv6 localhost address for the Dart VM Service Ignored if vm service host is set endless trace buffer
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
Dart_FileReadCallback file_read
const uint8_t * vm_snapshot_data
Dart_FileOpenCallback file_open
Dart_FileWriteCallback file_write
Dart_EntropySource entropy_source
const uint8_t * vm_snapshot_instructions
Dart_FileCloseCallback file_close
DART_EXPORT Dart_LoadedElf * Dart_LoadELF(const char *filename, uint64_t file_offset, const char **error, const uint8_t **vm_snapshot_data, const uint8_t **vm_snapshot_instrs, const uint8_t **vm_isolate_data, const uint8_t **vm_isolate_instrs)
Please see documentation for Dart_LoadElf_Fd.
DART_EXPORT void Dart_UnloadELF(Dart_LoadedElf *loaded)