Flutter Engine
The Flutter Engine
native_symbol_win.cc
Go to the documentation of this file.
1// Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
2// for details. All rights reserved. Use of this source code is governed by a
3// BSD-style license that can be found in the LICENSE file.
4
5#include "vm/globals.h"
6#if defined(DART_HOST_OS_WINDOWS)
7
8#include "vm/lockers.h"
9#include "vm/native_symbol.h"
10#include "vm/os.h"
11#include "vm/os_thread.h"
12
13#include <dbghelp.h> // NOLINT
14
15namespace dart {
16
17static bool running_ = false;
18static Mutex* lock_ = nullptr;
19
21 ASSERT(running_ == false);
22 if (lock_ == nullptr) {
23 lock_ = new Mutex();
24 }
25 running_ = true;
26
27// Symbol resolution API's used in this file are not supported
28// when compiled in UWP.
29#ifndef DART_TARGET_OS_WINDOWS_UWP
30 SymSetOptions(SYMOPT_UNDNAME | SYMOPT_DEFERRED_LOADS);
31 HANDLE hProcess = GetCurrentProcess();
32 if (!SymInitialize(hProcess, nullptr, TRUE)) {
34 OS::PrintErr("Failed to init NativeSymbolResolver (SymInitialize %" Pu32
35 ")\n",
36 error);
37 return;
38 }
39#endif
40}
41
43 MutexLocker lock(lock_);
44 if (!running_) {
45 return;
46 }
47 running_ = false;
48#ifndef DART_TARGET_OS_WINDOWS_UWP
49 HANDLE hProcess = GetCurrentProcess();
50 if (!SymCleanup(hProcess)) {
52 OS::PrintErr("Failed to shutdown NativeSymbolResolver (SymCleanup %" Pu32
53 ")\n",
54 error);
55 }
56#endif
57}
58
60#ifdef DART_TARGET_OS_WINDOWS_UWP
61 return nullptr;
62#else
63 const intptr_t kMaxNameLength = 2048;
64 const intptr_t kSymbolInfoSize = sizeof(SYMBOL_INFO); // NOLINT.
65 static char buffer[kSymbolInfoSize + kMaxNameLength];
66 static char name_buffer[kMaxNameLength];
67 MutexLocker lock(lock_);
68 if (!running_) {
69 return nullptr;
70 }
71 if (start != nullptr) {
72 *start = 0;
73 }
74 memset(&buffer[0], 0, sizeof(buffer));
75 HANDLE hProcess = GetCurrentProcess();
76 DWORD64 address = static_cast<DWORD64>(pc);
77 PSYMBOL_INFO pSymbol = reinterpret_cast<PSYMBOL_INFO>(&buffer[0]);
78 pSymbol->SizeOfStruct = kSymbolInfoSize;
79 pSymbol->MaxNameLen = kMaxNameLength;
80 DWORD64 displacement;
81 BOOL r = SymFromAddr(hProcess, address, &displacement, pSymbol);
82 if (r == FALSE) {
83 return nullptr;
84 }
85 if (start != nullptr) {
86 *start = pc - displacement;
87 }
88 return Utils::StrDup(pSymbol->Name);
89#endif // ifdef DART_TARGET_OS_WINDOWS_UWP
90}
91
93 free(const_cast<char*>(name));
94}
95
97 uword* dso_base,
98 const char** dso_name) {
99 return false;
100}
101
102void NativeSymbolResolver::AddSymbols(const char* dso_name,
103 void* buffer,
104 size_t size) {
105 OS::PrintErr("warning: Dart_AddSymbols has no effect on Windows\n");
106}
107
108} // namespace dart
109
110#endif // defined(DART_HOST_OS_WINDOWS)
static bool LookupSharedObject(uword pc, uword *dso_base=nullptr, const char **dso_name=nullptr)
static const char * LookupSymbolName(uword pc, uword *start)
static void AddSymbols(const char *dso_name, void *buffer, size_t size)
static void FreeSymbolName(const char *name)
static void static void PrintErr(const char *format,...) PRINTF_ATTRIBUTE(1
static char * StrDup(const char *s)
#define ASSERT(E)
const uint8_t uint32_t uint32_t GError ** error
return FALSE
Definition: dart_vm.cc:33
const char *const name
uintptr_t uword
Definition: globals.h:501
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
Definition: switches.h:126
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
#define Pu32
Definition: globals.h:413
int BOOL
Definition: windows_types.h:37
WINBASEAPI _Check_return_ _Post_equals_last_error_ DWORD WINAPI GetLastError(VOID)
void * HANDLE
Definition: windows_types.h:36
unsigned long DWORD
Definition: windows_types.h:22