Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
Functions
main.cc File Reference
#include <lib/async-loop/cpp/loop.h>
#include <lib/async-loop/default.h>
#include <lib/inspect/component/cpp/component.h>
#include <lib/trace-provider/provider.h>
#include <lib/trace/event.h>
#include "dart_runner.h"
#include "flutter/fml/logging.h"
#include "flutter/fml/platform/fuchsia/log_interest_listener.h"
#include "flutter/fml/platform/fuchsia/log_state.h"
#include "flutter/fml/trace_event.h"
#include "logging.h"
#include "platform/utils.h"
#include "runtime/dart/utils/build_info.h"
#include "runtime/dart/utils/files.h"
#include "runtime/dart/utils/root_inspect_node.h"
#include "runtime/dart/utils/tempfs.h"
#include "third_party/dart/runtime/include/dart_api.h"

Go to the source code of this file.

Functions

static void RegisterProfilerSymbols (const char *symbols_path, const char *dso_name)
 
int main (int argc, const char **argv)
 

Function Documentation

◆ main()

int main ( int  argc,
const char **  argv 
)

Definition at line 38 of file main.cc.

38 {
39 async::Loop loop(&kAsyncLoopConfigAttachToCurrentThread);
40
41 // Setup logging.
43 fml::LogInterestListener listener(fml::LogState::Default().TakeClientEnd(),
44 loop.dispatcher());
45 listener.AsyncWaitForInterestChanged();
46
47 // Create our component context which is served later.
48 auto context = sys::ComponentContext::Create();
50 auto build_info = dart_utils::RootInspectNode::CreateRootChild("build_info");
52
53 dart::SetDartVmNode(std::make_unique<inspect::Node>(
55
56 std::unique_ptr<trace::TraceProviderWithFdio> provider;
57 {
58 bool already_started;
59 // Use CreateSynchronously to prevent loss of early events.
60 trace::TraceProviderWithFdio::CreateSynchronously(
61 loop.dispatcher(), "dart_runner", &provider, &already_started);
62 }
63
64#if !defined(DART_PRODUCT)
65#if defined(AOT_RUNTIME)
66 RegisterProfilerSymbols("pkg/data/dart_aot_runner.dartprofilersymbols", "");
67#else
68 RegisterProfilerSymbols("pkg/data/dart_jit_runner.dartprofilersymbols", "");
69#endif // defined(AOT_RUNTIME)
70#endif // !defined(DART_PRODUCT)
71
72 dart_runner::DartRunner runner(context.get());
73
74 // Wait to serve until we have finished all of our setup.
75 context->outgoing()->ServeFromStartupInfo();
76
77 loop.Run();
78 return 0;
79}
static void Dump(inspect::Node &node)
static void Initialize(sys::ComponentContext *context)
static inspect::Node CreateRootChild(const std::string &name)
void SetTags(const std::initializer_list< std::string > &tags)
Definition log_state.cc:56
static LogState & Default()
Definition log_state.cc:61
void SetDartVmNode(std::unique_ptr< inspect::Node > node)
#define LOG_TAG
Definition logging.h:11
static void RegisterProfilerSymbols(const char *symbols_path, const char *dso_name)
Definition main.cc:26

◆ RegisterProfilerSymbols()

static void RegisterProfilerSymbols ( const char *  symbols_path,
const char *  dso_name 
)
static

Definition at line 26 of file main.cc.

27 {
28 std::string* symbols = new std::string();
29 if (dart_utils::ReadFileToString(symbols_path, symbols)) {
30 Dart_AddSymbols(dso_name, symbols->data(), symbols->size());
31 } else {
32 FML_LOG(ERROR) << "Failed to load " << symbols_path;
33 FML_CHECK(false);
34 }
35}
DART_EXPORT void Dart_AddSymbols(const char *dso_name, void *buffer, intptr_t buffer_size)
#define FML_LOG(severity)
Definition logging.h:82
#define FML_CHECK(condition)
Definition logging.h:85
bool ReadFileToString(const std::string &path, std::string *result)
Definition files.cc:56
#define ERROR(message)